his_api_controller.go 578KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. }
  82. type Result3101 struct {
  83. Infcode string `json:"infcode"`
  84. InfRefmsgid string `json:"inf_refmsgid"`
  85. RefmsgTime string `json:"refmsg_time"`
  86. RespondTime string `json:"respond_time"`
  87. Enctype string `json:"enctype"`
  88. Signtype string `json:"signtype"`
  89. ErrMsg string `json:"err_msg"`
  90. Output struct {
  91. Result []struct {
  92. JudgeResultDetailDtos []struct {
  93. VolaItemType string `json:"vola_item_type"`
  94. MdtrtID string `json:"mdtrt_id"`
  95. JrdID string `json:"jrd_id"`
  96. PatnID string `json:"patn_id"`
  97. RxID string `json:"rx_id"`
  98. VolaAmt interface{} `json:"vola_amt"`
  99. } `json:"judge_result_detail_dtos"`
  100. RuleID string `json:"rule_id"`
  101. VolaEvid string `json:"vola_evid"`
  102. MdtrtID string `json:"mdtrt_id"`
  103. RuleName string `json:"rule_name"`
  104. VolaAmtStas string `json:"vola_amt_stas"`
  105. JrID string `json:"jr_id"`
  106. PatnID string `json:"patn_id"`
  107. SevDeg string `json:"sev_deg"`
  108. VolaAmt float64 `json:"vola_amt"`
  109. VolaBhvrType string `json:"vola_bhvr_type"`
  110. VolaCont string `json:"vola_cont"`
  111. } `json:"result"`
  112. } `json:"output"`
  113. }
  114. func (c *HisApiController) ReadEleToken() {
  115. admin_user_id, _ := c.GetInt64("admin_user_id")
  116. his_patient_id, _ := c.GetInt64("his_patient_id")
  117. adminUser := c.GetAdminUserInfo()
  118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  122. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  123. if len(tokens) > 0 {
  124. c.ServeSuccessJSON(map[string]interface{}{
  125. "msg": "读取成功",
  126. })
  127. } else {
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "failed_code": -10,
  130. "msg": "读取失败",
  131. })
  132. }
  133. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  134. if initFlag == 0 {
  135. c.TestGetBasBaseInit()
  136. }
  137. token := c.GetEleBaseInfo()
  138. token = Remove0000(token)
  139. if len(token) > 0 {
  140. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  142. var res ResultTwo
  143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. if res.Infcode == 0 {
  149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  150. if err == gorm.ErrRecordNotFound {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  152. return
  153. } else if err != nil {
  154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  155. return
  156. } else {
  157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  159. infoStr := string(Iinfos)
  160. idetinfoStr := string(Idetinfos)
  161. psn := &models.HisPsn{
  162. PsnNo: res.Output.Baseinfo.PsnNo,
  163. Age: res.Output.Baseinfo.Age,
  164. PatientId: patient.ID,
  165. Certno: res.Output.Baseinfo.Certno,
  166. Brdy: res.Output.Baseinfo.Brdy,
  167. Gend: res.Output.Baseinfo.Gend,
  168. Naty: res.Output.Baseinfo.Naty,
  169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  170. PsnName: res.Output.Baseinfo.PsnName,
  171. Idetinfo: idetinfoStr,
  172. Insuinfo: infoStr,
  173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  174. CardInfo: "",
  175. VerifyNumber: token,
  176. }
  177. service.CreateHisPsn(psn)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "msg": "读取成功",
  180. })
  181. }
  182. } else {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  184. return
  185. }
  186. } else {
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "failed_code": -10,
  189. "msg": "读取失败",
  190. })
  191. }
  192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  193. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  194. if len(errMsg) == 0 {
  195. type ELeData struct {
  196. Data struct {
  197. IdNo string `json:"idNo"`
  198. IdType string `json:"idType"`
  199. UserName string `json:"userName"`
  200. EcToken string `json:"ecToken"`
  201. InsuOrg string `json:"insuOrg"`
  202. Gender string `json:"gender"`
  203. Birthday string `json:"birthday"`
  204. Nationality string `json:"nationality"`
  205. Email string `json:"email"`
  206. Extra string `json:"extra"`
  207. } `json:"data"`
  208. Code int `json:"code"`
  209. Message string `json:"message"`
  210. }
  211. var ele ELeData
  212. err := json.Unmarshal([]byte(outPutInfo), &ele)
  213. if err != nil {
  214. utils.ErrorLog("解析失败:%v", err)
  215. }
  216. token := ele.Data.EcToken
  217. if len(token) > 0 {
  218. psn := &models.HisPsn{
  219. PsnNo: his.PsnNo,
  220. Age: 0,
  221. PatientId: his.PatientId,
  222. Certno: his.Certno,
  223. Brdy: his.Brdy,
  224. Gend: his.Gend,
  225. Naty: his.Naty,
  226. PsnCertType: his.PsnCertType,
  227. PsnName: his.PsnName,
  228. Idetinfo: his.Idetinfo,
  229. Insuinfo: his.Iinfo,
  230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  231. CardInfo: outPutInfo,
  232. VerifyNumber: token,
  233. }
  234. service.CreateHisPsn(psn)
  235. }
  236. if len(token) > 0 {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "读取成功",
  239. })
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": "读取失败",
  244. })
  245. }
  246. }
  247. } else if miConfig.MdtrtareaAdmvs == "360399" {
  248. if initFlag == 0 {
  249. c.TestGetJiangXiBasBaseInit()
  250. }
  251. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  252. type ELeData struct {
  253. Data struct {
  254. IdNo string `json:"idNo"`
  255. IdType string `json:"idType"`
  256. UserName string `json:"userName"`
  257. EcToken string `json:"ecToken"`
  258. InsuOrg string `json:"insuOrg"`
  259. Gender string `json:"gender"`
  260. Birthday string `json:"birthday"`
  261. Nationality string `json:"nationality"`
  262. Email string `json:"email"`
  263. Extra string `json:"extra"`
  264. } `json:"data"`
  265. Code int `json:"code"`
  266. Message string `json:"message"`
  267. }
  268. var ele ELeData
  269. err := json.Unmarshal([]byte(json_result), &ele)
  270. if err != nil {
  271. utils.ErrorLog("解析失败:%v", err)
  272. }
  273. token := ele.Data.EcToken
  274. token = Remove0000(token)
  275. fmt.Println(ele.Data.UserName)
  276. 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)
  277. saveLog(result2, requestLog2, "1101", "获取人员信息")
  278. var res ResultTwo
  279. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  280. utils.ErrorLog("解析失败:%v", err)
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. if res.Infcode == 0 {
  285. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  286. if err == gorm.ErrRecordNotFound {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  288. return
  289. } else if err != nil {
  290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  291. return
  292. } else {
  293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  295. infoStr := string(Iinfos)
  296. idetinfoStr := string(Idetinfos)
  297. psn := &models.HisPsn{
  298. PsnNo: res.Output.Baseinfo.PsnNo,
  299. Age: res.Output.Baseinfo.Age,
  300. PatientId: patient.ID,
  301. Certno: res.Output.Baseinfo.Certno,
  302. Brdy: res.Output.Baseinfo.Brdy,
  303. Gend: res.Output.Baseinfo.Gend,
  304. Naty: res.Output.Baseinfo.Naty,
  305. PsnCertType: res.Output.Baseinfo.PsnCertType,
  306. PsnName: res.Output.Baseinfo.PsnName,
  307. Idetinfo: idetinfoStr,
  308. Insuinfo: infoStr,
  309. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  310. CardInfo: "",
  311. VerifyNumber: token,
  312. }
  313. service.CreateHisPsn(psn)
  314. c.ServeSuccessJSON(map[string]interface{}{
  315. "patient": patient,
  316. "number": token,
  317. })
  318. }
  319. } else {
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  321. return
  322. }
  323. } else if miConfig.MdtrtareaAdmvs == "430800" {
  324. if initFlag == 0 {
  325. c.TestGetJiangXiBasBaseInit()
  326. }
  327. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. type ELeData struct {
  329. Data struct {
  330. IdNo string `json:"idNo"`
  331. IdType string `json:"idType"`
  332. UserName string `json:"userName"`
  333. EcToken string `json:"ecToken"`
  334. InsuOrg string `json:"insuOrg"`
  335. Gender string `json:"gender"`
  336. Birthday string `json:"birthday"`
  337. Nationality string `json:"nationality"`
  338. Email string `json:"email"`
  339. Extra string `json:"extra"`
  340. } `json:"data"`
  341. Code int `json:"code"`
  342. Message string `json:"message"`
  343. }
  344. var ele ELeData
  345. err := json.Unmarshal([]byte(json_result), &ele)
  346. if err != nil {
  347. utils.ErrorLog("解析失败:%v", err)
  348. }
  349. token := ele.Data.EcToken
  350. token = Remove0000(token)
  351. fmt.Println(ele.Data.UserName)
  352. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  353. saveLog(result2, requestLog2, "1101", "获取人员信息")
  354. var res ResultTwo
  355. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  356. utils.ErrorLog("解析失败:%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. if res.Infcode == 0 {
  361. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  362. if err == gorm.ErrRecordNotFound {
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  364. return
  365. } else if err != nil {
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  367. return
  368. } else {
  369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  371. infoStr := string(Iinfos)
  372. idetinfoStr := string(Idetinfos)
  373. psn := &models.HisPsn{
  374. PsnNo: res.Output.Baseinfo.PsnNo,
  375. Age: res.Output.Baseinfo.Age,
  376. PatientId: patient.ID,
  377. Certno: res.Output.Baseinfo.Certno,
  378. Brdy: res.Output.Baseinfo.Brdy,
  379. Gend: res.Output.Baseinfo.Gend,
  380. Naty: res.Output.Baseinfo.Naty,
  381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  382. PsnName: res.Output.Baseinfo.PsnName,
  383. Idetinfo: idetinfoStr,
  384. Insuinfo: infoStr,
  385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  386. CardInfo: "",
  387. VerifyNumber: token,
  388. }
  389. service.CreateHisPsn(psn)
  390. c.ServeSuccessJSON(map[string]interface{}{
  391. "patient": patient,
  392. "number": token,
  393. })
  394. }
  395. } else {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  397. return
  398. }
  399. }
  400. }
  401. func (c *HisApiController) Get9001() {
  402. adminUser := c.GetAdminUserInfo()
  403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  405. if miConfig.MdtrtareaAdmvs == "350500" {
  406. service.GetFjAuthorizationInfo(miConfig.Code)
  407. } else {
  408. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  409. var dat map[string]interface{}
  410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  411. fmt.Println(dat)
  412. } else {
  413. fmt.Println(err)
  414. }
  415. userJSONBytes, _ := json.Marshal(dat)
  416. var res models.Result9001
  417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  418. utils.ErrorLog("解析失败:%v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. }
  423. }
  424. 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) {
  425. var res Result3101
  426. adminUser := c.GetAdminUserInfo()
  427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  428. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  430. //record_time := c.GetString("record_time")
  431. //trig_scen := c.GetString("trig_scen")
  432. timeLayout := "2006-01-02"
  433. loc, _ := time.LoadLocation("Local")
  434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  435. if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  437. return res
  438. }
  439. recordDateTime := theTime.Unix()
  440. var patientPrescription models.HisPrescriptionInfo
  441. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  442. //if patientPrescription.ID == 0 {
  443. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  444. //}
  445. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  446. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  447. //
  448. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  449. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  450. var pp models.PublicParams
  451. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  452. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  453. pp.FixmedinsName = miConfig.OrgName
  454. pp.FixmedinsCode = miConfig.Code
  455. pp.RequestUrl = miConfig.Url
  456. pp.Cainfo = miConfig.Cainfo
  457. pp.SecretKey = miConfig.SecretKey
  458. pp.AccessKey = miConfig.AccessKey
  459. pp.OpterName = roles.UserName
  460. var config []*models.HisXtDiagnoseConfig
  461. for _, item := range diagnosis_ids {
  462. id, _ := strconv.ParseInt(item, 10, 64)
  463. diagnosisConfig, _ := service.FindDiagnoseById(id)
  464. config = append(config, &diagnosisConfig)
  465. }
  466. var pd models.PatientDtos
  467. pd.PatnID = his.PsnNo
  468. pd.PatnName = his.Name
  469. pd.Gend = his.Gend
  470. pd.Brdy = his.Brdy
  471. pd.Poolarea = miConfig.MdtrtareaAdmvs
  472. pd.CurrMdtrtID = his.Number
  473. var fed models.FsiEncounterDtos
  474. fed.MdtrtID = his.Number
  475. fed.MedinsID = miConfig.Code
  476. fed.MedinsName = miConfig.OrgName
  477. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  478. fed.MedMdtrtType = "1"
  479. fed.MedinsType = "1"
  480. fed.MedinsLv = "11"
  481. tm := time.Unix(his.RecordDate, 0)
  482. s_tm := tm.Format("2006-01-02 15:04:05")
  483. fed.AdmDate = s_tm
  484. fed.DscgDate = s_tm
  485. fed.DscgMainDiseCodg = config[0].CountryCode
  486. fed.DscgMainDiseName = config[0].CountryContentName
  487. //诊断信息
  488. var fdds []*models.FsiDiagnoseDtos
  489. for index, item := range config {
  490. if index == 0 {
  491. var fdd models.FsiDiagnoseDtos
  492. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  493. fdd.InoutDiseType = "1"
  494. fdd.MaindiseFlag = "1"
  495. fdd.DiseDate = s_tm
  496. fdd.DiasSrtNo = "1"
  497. fdd.DiseName = item.CountryContentName
  498. fdd.DiseCodg = item.CountryCode
  499. fdds = append(fdds, &fdd)
  500. } else {
  501. var fdd models.FsiDiagnoseDtos
  502. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  503. fdd.InoutDiseType = "1"
  504. fdd.MaindiseFlag = "1"
  505. fdd.DiseDate = s_tm
  506. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  507. fdd.DiseName = item.CountryContentName
  508. fdd.DiseCodg = item.CountryCode
  509. fdds = append(fdds, &fdd)
  510. }
  511. }
  512. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  513. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  514. fed.AdmDeptName = department.Name
  515. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  516. fed.DscgDeptName = department.Name
  517. fed.MedMdtrtType = "1"
  518. fed.MedType = "11"
  519. //if his.Insutype == "390" {
  520. // fed.MedType = "1402"
  521. //} else {
  522. // fed.MedType = "9933"
  523. //}
  524. var orders []*models.FsiOrderDtos
  525. if trig_scen == "2" {
  526. //处方医嘱信息
  527. for _, item := range prescriptions {
  528. for _, subItem := range item.HisDoctorAdviceInfo {
  529. var order models.FsiOrderDtos
  530. order.RxID = strconv.FormatInt(item.ID, 10)
  531. order.Rxno = strconv.FormatInt(item.ID, 10)
  532. order.LongDrordFlag = "0"
  533. order.HilistType = "1"
  534. order.ChrgType = "1"
  535. order.DrordBhvr = "-"
  536. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  537. order.HosplistName = subItem.BaseDrugLib.DrugName
  538. order.HilistLv = "1"
  539. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  540. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  541. order.HosplistName = subItem.BaseDrugLib.DrugName
  542. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  543. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  544. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  545. order.OwnpayAmt = ""
  546. order.SelfpayAmt = ""
  547. order.Spec = ""
  548. order.SpecUnt = ""
  549. order.DrordBegnDate = s_tm
  550. order.DrordStopDate = ""
  551. order.DrordDrCodg = "1"
  552. order.DrordDeptName = department.Name
  553. order.DrordDrCodg = "1"
  554. order.DrordDrName = doctor_info.UserName
  555. order.DrordDrProfttl = ""
  556. order.CurrDrordFlag = "1"
  557. orders = append(orders, &order)
  558. }
  559. for _, subItem := range item.HisPrescriptionProject {
  560. if subItem.Type == 2 {
  561. var order models.FsiOrderDtos
  562. order.RxID = strconv.FormatInt(item.ID, 10)
  563. order.Rxno = strconv.FormatInt(item.ID, 10)
  564. order.LongDrordFlag = "0"
  565. order.HilistType = "1"
  566. order.ChrgType = "1"
  567. order.DrordBhvr = "-"
  568. order.HilistCode = subItem.HisProject.MedicalCode
  569. order.HosplistName = subItem.HisProject.ProjectName
  570. order.HilistLv = "1"
  571. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  572. order.HosplistCode = subItem.HisProject.MedicalCode
  573. order.HosplistName = subItem.HisProject.ProjectName
  574. order.Cnt = subItem.Count
  575. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  576. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  578. order.OwnpayAmt = ""
  579. order.SelfpayAmt = ""
  580. order.Spec = ""
  581. order.SpecUnt = ""
  582. order.DrordBegnDate = s_tm
  583. order.DrordStopDate = ""
  584. order.DrordDrCodg = "1"
  585. order.DrordDeptName = department.Name
  586. order.DrordDrCodg = "1"
  587. order.DrordDrName = doctor_info.UserName
  588. order.DrordDrProfttl = ""
  589. order.CurrDrordFlag = "1"
  590. orders = append(orders, &order)
  591. }
  592. if subItem.Type == 3 {
  593. var order models.FsiOrderDtos
  594. order.RxID = strconv.FormatInt(item.ID, 10)
  595. order.Rxno = strconv.FormatInt(item.ID, 10)
  596. order.LongDrordFlag = "0"
  597. order.HilistType = "1"
  598. order.ChrgType = "1"
  599. order.DrordBhvr = "-"
  600. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  601. order.HosplistName = subItem.GoodInfo.GoodName
  602. order.HilistLv = "1"
  603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  604. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  605. order.HosplistName = subItem.GoodInfo.GoodName
  606. order.Cnt = subItem.Count
  607. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  608. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  610. order.OwnpayAmt = ""
  611. order.SelfpayAmt = ""
  612. order.Spec = ""
  613. order.SpecUnt = ""
  614. order.DrordBegnDate = s_tm
  615. order.DrordStopDate = ""
  616. order.DrordDrCodg = "1"
  617. order.DrordDeptName = department.Name
  618. order.DrordDrCodg = "1"
  619. order.DrordDrName = doctor_info.UserName
  620. order.DrordDrProfttl = ""
  621. order.CurrDrordFlag = "1"
  622. orders = append(orders, &order)
  623. }
  624. }
  625. }
  626. //处方医嘱信息
  627. }
  628. fed.MatnStas = "0"
  629. fed.MedfeeSumamt = "0"
  630. fed.OwnpayAmt = "0"
  631. fed.SelfpayAmt = "0"
  632. fed.AcctPayamt = "0"
  633. fed.MaAmt = "0"
  634. fed.HifpPayamt = "0"
  635. fed.SetlTotlnum = "1"
  636. fed.Insutype = his.Insutype
  637. fed.ReimFlag = "0"
  638. fed.OutSetlFlag = "0"
  639. var fopd []*models.FsiOperationDtosData
  640. data := make(map[string]interface{})
  641. data["fed"] = fed
  642. data["fdd"] = fdds
  643. data["fod"] = orders
  644. data["pd"] = pd
  645. data["pp"] = pp
  646. data["fopd"] = fopd
  647. data["trig_scen"] = trig_scen
  648. fmt.Println(data)
  649. fmt.Println(fed)
  650. fmt.Println(fdds)
  651. fmt.Println(orders)
  652. fmt.Println(pd)
  653. fmt.Println(pp)
  654. fmt.Println(fopd)
  655. client := &http.Client{}
  656. bytesData, _ := json.Marshal(data)
  657. var req *http.Request
  658. if miConfig.MdtrtareaAdmvs == "320921" {
  659. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  660. } else {
  661. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  662. }
  663. resp, _ := client.Do(req)
  664. defer resp.Body.Close()
  665. body, ioErr := ioutil.ReadAll(resp.Body)
  666. if ioErr != nil {
  667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return res
  670. }
  671. var respJSON map[string]interface{}
  672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  675. return res
  676. }
  677. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  678. fmt.Println(respJSON)
  679. result, _ := json.Marshal(respJSON)
  680. fmt.Println(result)
  681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  682. utils.ErrorLog("解析失败:%v", err)
  683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. return res
  685. }
  686. return res
  687. }
  688. 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) {
  689. adminUser := c.GetAdminUserInfo()
  690. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  691. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  693. //record_time := c.GetString("record_time")
  694. //trig_scen := c.GetString("trig_scen")
  695. timeLayout := "2006-01-02"
  696. loc, _ := time.LoadLocation("Local")
  697. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  698. if err != nil {
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. return res
  701. }
  702. recordDateTime := theTime.Unix()
  703. var patientPrescription models.HisPrescriptionInfo
  704. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  705. if patientPrescription.ID == 0 {
  706. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  707. }
  708. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  709. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  710. //
  711. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  712. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  713. var pp models.PublicParams
  714. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  715. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  716. pp.FixmedinsName = miConfig.OrgName
  717. pp.FixmedinsCode = miConfig.Code
  718. pp.RequestUrl = miConfig.Url
  719. pp.Cainfo = miConfig.Cainfo
  720. pp.SecretKey = miConfig.SecretKey
  721. pp.AccessKey = miConfig.AccessKey
  722. pp.OpterName = roles.UserName
  723. var config []*models.HisXtDiagnoseConfig
  724. for _, item := range diagnosis_ids {
  725. id, _ := strconv.ParseInt(item, 10, 64)
  726. diagnosisConfig, _ := service.FindDiagnoseById(id)
  727. config = append(config, &diagnosisConfig)
  728. }
  729. var pd models.PatientDtos
  730. pd.PatnID = his.PsnNo
  731. pd.PatnName = his.Name
  732. pd.Gend = his.Gend
  733. pd.Brdy = his.Brdy
  734. pd.Poolarea = his.InsuplcAdmdvs
  735. pd.CurrMdtrtID = his.Number
  736. var fed models.FsiEncounterDtos
  737. fed.MdtrtID = his.Number
  738. fed.MedinsID = miConfig.Code
  739. fed.MedinsName = miConfig.OrgName
  740. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  741. fed.MedMdtrtType = "1"
  742. fed.MedinsType = "1"
  743. fed.MedinsLv = "11"
  744. tm := time.Unix(his.RecordDate, 0)
  745. s_tm := tm.Format("2006-01-02 15:04:05")
  746. fed.AdmDate = s_tm
  747. fed.DscgDate = s_tm
  748. fed.DscgMainDiseCodg = config[0].CountryCode
  749. fed.DscgMainDiseName = config[0].CountryContentName
  750. //诊断信息
  751. var fdds []*models.FsiDiagnoseDtos
  752. for index, item := range config {
  753. if index == 0 {
  754. var fdd models.FsiDiagnoseDtos
  755. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  756. fdd.InoutDiseType = "1"
  757. fdd.MaindiseFlag = "1"
  758. fdd.DiseDate = s_tm
  759. fdd.DiasSrtNo = "1"
  760. fdd.DiseName = item.CountryContentName
  761. fdd.DiseCodg = item.CountryCode
  762. fdds = append(fdds, &fdd)
  763. } else {
  764. var fdd models.FsiDiagnoseDtos
  765. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  766. fdd.InoutDiseType = "1"
  767. fdd.MaindiseFlag = "1"
  768. fdd.DiseDate = s_tm
  769. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  770. fdd.DiseName = item.CountryContentName
  771. fdd.DiseCodg = item.CountryCode
  772. fdds = append(fdds, &fdd)
  773. }
  774. }
  775. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  776. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  777. fed.AdmDeptName = department.Name
  778. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  779. fed.DscgDeptName = department.Name
  780. fed.MedMdtrtType = "1"
  781. fed.MedType = "11"
  782. //if his.Insutype == "390" {
  783. // fed.MedType = "1402"
  784. //} else {
  785. // fed.MedType = "9933"
  786. //}
  787. var orders []*models.FsiOrderDtos
  788. if trig_scen == "2" {
  789. //处方医嘱信息
  790. for _, item := range prescriptions {
  791. for _, subItem := range item.HisDoctorAdviceInfo {
  792. var order models.FsiOrderDtos
  793. order.RxID = strconv.FormatInt(item.ID, 10)
  794. order.Rxno = strconv.FormatInt(item.ID, 10)
  795. order.LongDrordFlag = "0"
  796. order.HilistType = "1"
  797. order.ChrgType = "1"
  798. order.DrordBhvr = "-"
  799. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  800. order.HosplistName = subItem.BaseDrugLib.DrugName
  801. order.HilistLv = "1"
  802. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  803. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  804. order.HosplistName = subItem.BaseDrugLib.DrugName
  805. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  807. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  808. order.OwnpayAmt = ""
  809. order.SelfpayAmt = ""
  810. order.Spec = ""
  811. order.SpecUnt = ""
  812. order.DrordBegnDate = s_tm
  813. order.DrordStopDate = ""
  814. order.DrordDrCodg = "1"
  815. order.DrordDeptName = department.Name
  816. order.DrordDrCodg = "1"
  817. order.DrordDrName = doctor_info.UserName
  818. order.DrordDrProfttl = ""
  819. order.CurrDrordFlag = "1"
  820. orders = append(orders, &order)
  821. }
  822. for _, subItem := range item.HisPrescriptionProject {
  823. if subItem.Type == 2 {
  824. var order models.FsiOrderDtos
  825. order.RxID = strconv.FormatInt(item.ID, 10)
  826. order.Rxno = strconv.FormatInt(item.ID, 10)
  827. order.LongDrordFlag = "0"
  828. order.HilistType = "1"
  829. order.ChrgType = "1"
  830. order.DrordBhvr = "-"
  831. order.HilistCode = subItem.HisProject.MedicalCode
  832. order.HosplistName = subItem.HisProject.ProjectName
  833. order.HilistLv = "1"
  834. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  835. order.HosplistCode = subItem.HisProject.MedicalCode
  836. order.HosplistName = subItem.HisProject.ProjectName
  837. order.Cnt = subItem.Count
  838. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  839. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  840. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  841. order.OwnpayAmt = ""
  842. order.SelfpayAmt = ""
  843. order.Spec = ""
  844. order.SpecUnt = ""
  845. order.DrordBegnDate = s_tm
  846. order.DrordStopDate = ""
  847. order.DrordDrCodg = "1"
  848. order.DrordDeptName = department.Name
  849. order.DrordDrCodg = "1"
  850. order.DrordDrName = doctor_info.UserName
  851. order.DrordDrProfttl = ""
  852. order.CurrDrordFlag = "1"
  853. orders = append(orders, &order)
  854. }
  855. if subItem.Type == 3 {
  856. var order models.FsiOrderDtos
  857. order.RxID = strconv.FormatInt(item.ID, 10)
  858. order.Rxno = strconv.FormatInt(item.ID, 10)
  859. order.LongDrordFlag = "0"
  860. order.HilistType = "1"
  861. order.ChrgType = "1"
  862. order.DrordBhvr = "-"
  863. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  864. order.HosplistName = subItem.GoodInfo.GoodName
  865. order.HilistLv = "1"
  866. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  867. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  868. order.HosplistName = subItem.GoodInfo.GoodName
  869. order.Cnt = subItem.Count
  870. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  871. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  872. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  873. order.OwnpayAmt = ""
  874. order.SelfpayAmt = ""
  875. order.Spec = ""
  876. order.SpecUnt = ""
  877. order.DrordBegnDate = s_tm
  878. order.DrordStopDate = ""
  879. order.DrordDrCodg = "1"
  880. order.DrordDeptName = department.Name
  881. order.DrordDrCodg = "1"
  882. order.DrordDrName = doctor_info.UserName
  883. order.DrordDrProfttl = ""
  884. order.CurrDrordFlag = "1"
  885. orders = append(orders, &order)
  886. }
  887. }
  888. }
  889. //处方医嘱信息
  890. }
  891. fed.MatnStas = "0"
  892. fed.MedfeeSumamt = "0"
  893. fed.OwnpayAmt = "0"
  894. fed.SelfpayAmt = "0"
  895. fed.AcctPayamt = "0"
  896. fed.MaAmt = "0"
  897. fed.HifpPayamt = "0"
  898. fed.SetlTotlnum = "1"
  899. fed.Insutype = his.Insutype
  900. fed.ReimFlag = "0"
  901. fed.OutSetlFlag = "0"
  902. var fopd []*models.FsiOperationDtosData
  903. data := make(map[string]interface{})
  904. data["fed"] = fed
  905. data["fdd"] = fdds
  906. data["fod"] = orders
  907. data["pd"] = pd
  908. data["pp"] = pp
  909. data["fopd"] = fopd
  910. data["trig_scen"] = trig_scen
  911. fmt.Println(data)
  912. fmt.Println(fed)
  913. fmt.Println(fdds)
  914. fmt.Println(orders)
  915. fmt.Println(pd)
  916. fmt.Println(pp)
  917. fmt.Println(fopd)
  918. client := &http.Client{}
  919. bytesData, _ := json.Marshal(data)
  920. var req *http.Request
  921. if miConfig.MdtrtareaAdmvs == "320921" {
  922. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  923. } else {
  924. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  925. }
  926. resp, _ := client.Do(req)
  927. defer resp.Body.Close()
  928. body, ioErr := ioutil.ReadAll(resp.Body)
  929. if ioErr != nil {
  930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return res
  933. }
  934. var respJSON map[string]interface{}
  935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return res
  939. }
  940. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  941. result, _ := json.Marshal(respJSON)
  942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  943. utils.ErrorLog("解析失败:%v", err)
  944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  945. return res
  946. }
  947. return res
  948. }
  949. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  950. ////patient_id, _ := c.GetInt64("patient_id")
  951. //order_id, _ := c.GetInt64("order_id")
  952. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  953. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  954. //trig_scen := c.GetString("trig_scen")
  955. adminUser := c.GetAdminUserInfo()
  956. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  957. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  959. record_time := c.GetString("record_time")
  960. order, _ := service.GetHisOrderByID(order_id)
  961. timeLayout := "2006-01-02"
  962. loc, _ := time.LoadLocation("Local")
  963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  964. if err != nil {
  965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  966. return
  967. }
  968. recordDateTime := theTime.Unix()
  969. var patientPrescription models.HisPrescriptionInfo
  970. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  971. if patientPrescription.ID == 0 {
  972. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  973. }
  974. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  975. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  976. //
  977. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  978. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  979. var pp models.PublicParams
  980. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  981. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  982. pp.FixmedinsName = miConfig.OrgName
  983. pp.FixmedinsCode = miConfig.Code
  984. pp.RequestUrl = miConfig.Url
  985. pp.Cainfo = miConfig.Cainfo
  986. pp.SecretKey = miConfig.SecretKey
  987. pp.AccessKey = miConfig.AccessKey
  988. pp.OpterName = roles.UserName
  989. var config []*models.HisXtDiagnoseConfig
  990. for _, item := range diagnosis_ids {
  991. id, _ := strconv.ParseInt(item, 10, 64)
  992. diagnosisConfig, _ := service.FindDiagnoseById(id)
  993. config = append(config, &diagnosisConfig)
  994. }
  995. var pd models.PatientDtos
  996. pd.PatnID = his.PsnNo
  997. pd.PatnName = his.Name
  998. pd.Gend = his.Gend
  999. pd.Brdy = his.Brdy
  1000. pd.Poolarea = his.InsuplcAdmdvs
  1001. pd.CurrMdtrtID = his.Number
  1002. var fed models.FsiEncounterDtos
  1003. fed.MdtrtID = his.Number
  1004. fed.MedinsID = miConfig.Code
  1005. fed.MedinsName = miConfig.OrgName
  1006. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1007. fed.MedMdtrtType = "1"
  1008. fed.MedinsType = "1"
  1009. fed.MedinsLv = "11"
  1010. tm := time.Unix(his.RecordDate, 0)
  1011. s_tm := tm.Format("2006-01-02 15:04:05")
  1012. fed.AdmDate = s_tm
  1013. fed.DscgDate = s_tm
  1014. fed.DscgMainDiseCodg = config[0].CountryCode
  1015. fed.DscgMainDiseName = config[0].CountryContentName
  1016. //诊断信息
  1017. var fdds []*models.FsiDiagnoseDtos
  1018. for index, item := range config {
  1019. if index == 0 {
  1020. var fdd models.FsiDiagnoseDtos
  1021. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1022. fdd.InoutDiseType = "1"
  1023. fdd.MaindiseFlag = "1"
  1024. fdd.DiseDate = s_tm
  1025. fdd.DiasSrtNo = "1"
  1026. fdd.DiseName = item.CountryContentName
  1027. fdd.DiseCodg = item.CountryCode
  1028. fdds = append(fdds, &fdd)
  1029. } else {
  1030. var fdd models.FsiDiagnoseDtos
  1031. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1032. fdd.InoutDiseType = "1"
  1033. fdd.MaindiseFlag = "1"
  1034. fdd.DiseDate = s_tm
  1035. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1036. fdd.DiseName = item.CountryContentName
  1037. fdd.DiseCodg = item.CountryCode
  1038. fdds = append(fdds, &fdd)
  1039. }
  1040. }
  1041. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1042. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1043. fed.AdmDeptName = department.Name
  1044. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1045. fed.DscgDeptName = department.Name
  1046. fed.MedType = order.MedType
  1047. //处方医嘱信息
  1048. var orders []*models.FsiOrderDtos
  1049. //for _, item := range prescriptions {
  1050. // for _, subItem := range item.HisDoctorAdviceInfo {
  1051. // var order models.FsiOrderDtos
  1052. // order.RxID = strconv.FormatInt(item.ID, 10)
  1053. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1054. // order.LongDrordFlag = "0"
  1055. // order.HilistType = "1"
  1056. // order.ChrgType = "1"
  1057. // order.DrordBhvr = "-"
  1058. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1059. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1060. // order.HilistLv = "1"
  1061. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1062. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1063. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1064. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1065. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1066. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1067. // order.OwnpayAmt = ""
  1068. // order.SelfpayAmt = ""
  1069. // order.Spec = ""
  1070. // order.SpecUnt = ""
  1071. // order.DrordBegnDate = s_tm
  1072. // order.DrordStopDate = ""
  1073. // order.DrordDrCodg = "1"
  1074. // order.DrordDeptName = department.Name
  1075. // order.DrordDrCodg = "1"
  1076. // order.DrordDrName = doctor_info.UserName
  1077. // order.DrordDrProfttl = ""
  1078. // order.CurrDrordFlag = "1"
  1079. // orders = append(orders, &order)
  1080. // }
  1081. // for _, subItem := range item.HisPrescriptionProject {
  1082. // if subItem.Type == 2 {
  1083. // var order models.FsiOrderDtos
  1084. // order.RxID = strconv.FormatInt(item.ID, 10)
  1085. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1086. // order.LongDrordFlag = "0"
  1087. // order.HilistType = "1"
  1088. // order.ChrgType = "1"
  1089. // order.DrordBhvr = "-"
  1090. // order.HilistCode = subItem.HisProject.MedicalCode
  1091. // order.HosplistName = subItem.HisProject.ProjectName
  1092. // order.HilistLv = "1"
  1093. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1094. // order.HosplistCode = subItem.HisProject.MedicalCode
  1095. // order.HosplistName = subItem.HisProject.ProjectName
  1096. // order.Cnt = subItem.Count
  1097. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1098. //
  1099. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1100. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1101. // order.OwnpayAmt = ""
  1102. // order.SelfpayAmt = ""
  1103. // order.Spec = ""
  1104. // order.SpecUnt = ""
  1105. // order.DrordBegnDate = s_tm
  1106. // order.DrordStopDate = ""
  1107. // order.DrordDrCodg = "1"
  1108. // order.DrordDeptName = department.Name
  1109. // order.DrordDrCodg = "1"
  1110. // order.DrordDrName = doctor_info.UserName
  1111. // order.DrordDrProfttl = ""
  1112. // order.CurrDrordFlag = "1"
  1113. // orders = append(orders, &order)
  1114. //
  1115. // }
  1116. // if subItem.Type == 3 {
  1117. //
  1118. // var order models.FsiOrderDtos
  1119. // order.RxID = strconv.FormatInt(item.ID, 10)
  1120. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1121. // order.LongDrordFlag = "0"
  1122. // order.HilistType = "1"
  1123. // order.ChrgType = "1"
  1124. // order.DrordBhvr = "-"
  1125. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1126. // order.HosplistName = subItem.GoodInfo.GoodName
  1127. // order.HilistLv = "1"
  1128. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1129. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1130. // order.HosplistName = subItem.GoodInfo.GoodName
  1131. // order.Cnt = subItem.Count
  1132. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1133. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1134. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1135. // order.OwnpayAmt = ""
  1136. // order.SelfpayAmt = ""
  1137. // order.Spec = ""
  1138. // order.SpecUnt = ""
  1139. // order.DrordBegnDate = s_tm
  1140. // order.DrordStopDate = ""
  1141. // order.DrordDrCodg = "1"
  1142. // order.DrordDeptName = department.Name
  1143. // order.DrordDrCodg = "1"
  1144. // order.DrordDrName = doctor_info.UserName
  1145. // order.DrordDrProfttl = ""
  1146. // order.CurrDrordFlag = "1"
  1147. // orders = append(orders, &order)
  1148. //
  1149. // }
  1150. // }
  1151. //}
  1152. for _, item := range prescriptions {
  1153. for _, subItem := range item.HisDoctorAdviceInfo {
  1154. var order models.FsiOrderDtos
  1155. order.RxID = strconv.FormatInt(item.ID, 10)
  1156. order.Rxno = strconv.FormatInt(item.ID, 10)
  1157. order.LongDrordFlag = "0"
  1158. order.HilistType = "1"
  1159. order.ChrgType = "1"
  1160. order.DrordBhvr = "-"
  1161. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1162. order.HosplistName = subItem.BaseDrugLib.DrugName
  1163. order.HilistLv = "1"
  1164. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1165. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1166. order.HosplistName = subItem.BaseDrugLib.DrugName
  1167. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1169. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1170. order.OwnpayAmt = ""
  1171. order.SelfpayAmt = ""
  1172. order.Spec = ""
  1173. order.SpecUnt = ""
  1174. order.DrordBegnDate = s_tm
  1175. order.DrordStopDate = ""
  1176. order.DrordDrCodg = "1"
  1177. order.DrordDeptName = department.Name
  1178. order.DrordDrCodg = "1"
  1179. order.DrordDrName = doctor_info.UserName
  1180. order.DrordDrProfttl = ""
  1181. order.CurrDrordFlag = "1"
  1182. orders = append(orders, &order)
  1183. }
  1184. for _, subItem := range item.HisPrescriptionProject {
  1185. if subItem.Type == 2 {
  1186. var order models.FsiOrderDtos
  1187. order.RxID = strconv.FormatInt(item.ID, 10)
  1188. order.Rxno = strconv.FormatInt(item.ID, 10)
  1189. order.LongDrordFlag = "0"
  1190. order.HilistType = "1"
  1191. order.ChrgType = "1"
  1192. order.DrordBhvr = "-"
  1193. order.HilistCode = subItem.HisProject.MedicalCode
  1194. order.HosplistName = subItem.HisProject.ProjectName
  1195. order.HilistLv = "1"
  1196. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1197. order.HosplistCode = subItem.HisProject.MedicalCode
  1198. order.HosplistName = subItem.HisProject.ProjectName
  1199. order.Cnt = subItem.Count
  1200. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1201. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1202. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1203. order.OwnpayAmt = ""
  1204. order.SelfpayAmt = ""
  1205. order.Spec = ""
  1206. order.SpecUnt = ""
  1207. order.DrordBegnDate = s_tm
  1208. order.DrordStopDate = ""
  1209. order.DrordDrCodg = "1"
  1210. order.DrordDeptName = department.Name
  1211. order.DrordDrCodg = "1"
  1212. order.DrordDrName = doctor_info.UserName
  1213. order.DrordDrProfttl = ""
  1214. order.CurrDrordFlag = "1"
  1215. orders = append(orders, &order)
  1216. }
  1217. if subItem.Type == 3 {
  1218. var order models.FsiOrderDtos
  1219. order.RxID = strconv.FormatInt(item.ID, 10)
  1220. order.Rxno = strconv.FormatInt(item.ID, 10)
  1221. order.LongDrordFlag = "0"
  1222. order.HilistType = "1"
  1223. order.ChrgType = "1"
  1224. order.DrordBhvr = "-"
  1225. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1226. order.HosplistName = subItem.GoodInfo.GoodName
  1227. order.HilistLv = "1"
  1228. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1229. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1230. order.HosplistName = subItem.GoodInfo.GoodName
  1231. order.Cnt = subItem.Count
  1232. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1233. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1234. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1235. order.OwnpayAmt = ""
  1236. order.SelfpayAmt = ""
  1237. order.Spec = ""
  1238. order.SpecUnt = ""
  1239. order.DrordBegnDate = s_tm
  1240. order.DrordStopDate = ""
  1241. order.DrordDrCodg = "1"
  1242. order.DrordDeptName = department.Name
  1243. order.DrordDrCodg = "1"
  1244. order.DrordDrName = doctor_info.UserName
  1245. order.DrordDrProfttl = ""
  1246. order.CurrDrordFlag = "1"
  1247. orders = append(orders, &order)
  1248. }
  1249. }
  1250. }
  1251. //处方医嘱信息
  1252. fed.MatnStas = "0"
  1253. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1254. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1255. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1256. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1257. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1258. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1259. fed.SetlTotlnum = "1"
  1260. fed.Insutype = his.Insutype
  1261. fed.ReimFlag = "0"
  1262. fed.OutSetlFlag = "0"
  1263. var fopd []*models.FsiOperationDtosData
  1264. data := make(map[string]interface{})
  1265. data["fed"] = fed
  1266. data["fdd"] = fdds
  1267. data["fod"] = orders
  1268. data["pd"] = pd
  1269. data["pp"] = pp
  1270. data["fopd"] = fopd
  1271. data["trig_scen"] = trig_scen
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return res
  1287. }
  1288. var respJSON map[string]interface{}
  1289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return res
  1293. }
  1294. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1295. result, _ := json.Marshal(respJSON)
  1296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return res
  1300. }
  1301. return res
  1302. //手术操作集合
  1303. //手术操作集合
  1304. }
  1305. func (c *HisApiController) Check() {
  1306. psn_no := c.GetString("psn_no")
  1307. in := c.GetString("in")
  1308. mt := c.GetString("mt")
  1309. baseParams := models.BaseParams{
  1310. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1311. FixmedinsCode: "H15049901371",
  1312. InsuplcAdmdvs: "150499",
  1313. MdtrtareaAdmvs: "150499",
  1314. OrgName: "赤峰费森血液透析中心",
  1315. Doctor: "1111",
  1316. }
  1317. service.Gdyb2001(baseParams, psn_no, in, mt)
  1318. }
  1319. func (c *HisApiController) GetPsnNcdsInfo() {
  1320. admin_user_id, _ := c.GetInt64("admin_user_id")
  1321. patient_id, _ := c.GetInt64("patient_id")
  1322. id, _ := c.GetInt64("id")
  1323. adminUser := c.GetAdminUserInfo()
  1324. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1325. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1326. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1327. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1328. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1329. //
  1330. //if psn_record.ID == 0 {
  1331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1332. // return
  1333. //}
  1334. var res Result5301
  1335. var res10265 Result5301For10265
  1336. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1337. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1338. var api string
  1339. if miConfig.MdtrtareaAdmvs == "320921" {
  1340. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1342. } else {
  1343. 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 +
  1344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1345. }
  1346. resp, requestErr := http.Get(api)
  1347. if requestErr != nil {
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. body, ioErr := ioutil.ReadAll(resp.Body)
  1352. if ioErr != nil {
  1353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. var respJSON map[string]interface{}
  1358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1364. result, _ := json.Marshal(respJSON)
  1365. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1366. utils.ErrorLog("解析失败:%v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. res.ErrMsg = res10265.ErrMsg
  1371. res.Output = res10265.Output
  1372. res.InfRefmsgid = res10265.InfRefmsgid
  1373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1374. res.Infcode = infocode
  1375. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1376. p, _ := service.GetHisPatientById(patient_id)
  1377. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1378. var dat map[string]interface{}
  1379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1380. fmt.Println(dat)
  1381. } else {
  1382. fmt.Println(err)
  1383. }
  1384. userJSONBytes, _ := json.Marshal(dat)
  1385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1386. utils.ErrorLog("解析失败:%v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1391. p, _ := service.GetHisPatientById(patient_id)
  1392. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1393. var dat map[string]interface{}
  1394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1395. fmt.Println(dat)
  1396. } else {
  1397. fmt.Println(err)
  1398. }
  1399. userJSONBytes, _ := json.Marshal(dat)
  1400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1401. utils.ErrorLog("解析失败:%v", err)
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1403. return
  1404. }
  1405. } else {
  1406. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1407. var dat map[string]interface{}
  1408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1409. fmt.Println(dat)
  1410. } else {
  1411. fmt.Println(err)
  1412. }
  1413. userJSONBytes, _ := json.Marshal(dat)
  1414. if miConfig.Code == "H15049901371" {
  1415. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. res.InfRefmsgid = res10265.InfRefmsgid
  1421. res.Output = res10265.Output
  1422. res.ErrMsg = res10265.ErrMsg
  1423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1424. res.Infcode = infocode
  1425. } else {
  1426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1427. utils.ErrorLog("解析失败:%v", err)
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1429. return
  1430. }
  1431. }
  1432. }
  1433. if res.Infcode == 0 {
  1434. c.ServeSuccessJSON(map[string]interface{}{
  1435. "result": res.Output.Result,
  1436. })
  1437. }
  1438. }
  1439. func (c *HisApiController) CheckInsutype() {
  1440. his_patient_id, _ := c.GetInt64("his_patient_id")
  1441. admin_user_id, _ := c.GetInt64("admin_user_id")
  1442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1445. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res Result90100
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. if res.Infcode != 0 {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "failed_code": -10,
  1462. "msg": res.ErrMsg,
  1463. })
  1464. return
  1465. } else {
  1466. fmt.Println(res)
  1467. }
  1468. }
  1469. func (c *HisApiController) CheckCardPWD() {
  1470. card_pwd := c.GetString("card_pwd")
  1471. his_patient_id, _ := c.GetInt64("his_patient_id")
  1472. admin_user_id, _ := c.GetInt64("admin_user_id")
  1473. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1475. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1476. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1477. bas := strings.Split(psn.CardInfo, "|")
  1478. basNumber := bas[2]
  1479. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1480. var dat map[string]interface{}
  1481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1482. fmt.Println(dat)
  1483. } else {
  1484. fmt.Println(err)
  1485. }
  1486. userJSONBytes, _ := json.Marshal(dat)
  1487. var res Result90991
  1488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1489. utils.ErrorLog("解析失败:%v", err)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. if res.Infcode != 0 {
  1494. c.ServeSuccessJSON(map[string]interface{}{
  1495. "failed_code": -10,
  1496. "msg": res.ErrMsg,
  1497. })
  1498. return
  1499. } else {
  1500. if res.Output.Result.SscnoCheckStat == "0" {
  1501. var msg string
  1502. switch res.Output.Result.CardStat {
  1503. case "00":
  1504. msg = "未激活"
  1505. break
  1506. case "10":
  1507. msg = "激活"
  1508. break
  1509. case "20":
  1510. msg = "窗口挂失"
  1511. break
  1512. case "21":
  1513. msg = "电话挂失"
  1514. break
  1515. case "22":
  1516. msg = "单位网上申报挂失"
  1517. break
  1518. case "23":
  1519. msg = "保健办挂失"
  1520. break
  1521. case "24":
  1522. msg = "个人网上挂失"
  1523. break
  1524. case "25":
  1525. msg = "网上服务大厅挂失"
  1526. break
  1527. case "30":
  1528. msg = "注销"
  1529. break
  1530. case "40":
  1531. msg = "回收"
  1532. break
  1533. case "99":
  1534. msg = "制卡中(无效卡)"
  1535. break
  1536. }
  1537. c.ServeSuccessJSON(map[string]interface{}{
  1538. "failed_code": -10,
  1539. "msg": msg,
  1540. })
  1541. return
  1542. } else {
  1543. c.ServeSuccessJSON(map[string]interface{}{
  1544. "msg": "校验成功",
  1545. })
  1546. return
  1547. }
  1548. }
  1549. }
  1550. func (c *HisApiController) CheckCardPWDTwo() {
  1551. //card_pwd := c.GetString("card_pwd")
  1552. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1553. admin_user_id, _ := c.GetInt64("admin_user_id")
  1554. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1556. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1557. var dat map[string]interface{}
  1558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1559. fmt.Println(dat)
  1560. } else {
  1561. fmt.Println(err)
  1562. }
  1563. userJSONBytes, _ := json.Marshal(dat)
  1564. var res Result90991
  1565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1566. utils.ErrorLog("解析失败:%v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. if res.Infcode != 0 {
  1571. c.ServeSuccessJSON(map[string]interface{}{
  1572. "failed_code": -10,
  1573. "msg": res.ErrMsg,
  1574. })
  1575. return
  1576. } else {
  1577. if res.Output.Result.SscnoCheckStat == "0" {
  1578. var msg string
  1579. switch res.Output.Result.CardStat {
  1580. case "00":
  1581. msg = "未激活"
  1582. break
  1583. case "10":
  1584. msg = "激活"
  1585. break
  1586. case "20":
  1587. msg = "窗口挂失"
  1588. break
  1589. case "21":
  1590. msg = "电话挂失"
  1591. break
  1592. case "22":
  1593. msg = "单位网上申报挂失"
  1594. break
  1595. case "23":
  1596. msg = "保健办挂失"
  1597. break
  1598. case "24":
  1599. msg = "个人网上挂失"
  1600. break
  1601. case "25":
  1602. msg = "网上服务大厅挂失"
  1603. break
  1604. case "30":
  1605. msg = "注销"
  1606. break
  1607. case "40":
  1608. msg = "回收"
  1609. break
  1610. case "99":
  1611. msg = "制卡中(无效卡)"
  1612. break
  1613. }
  1614. c.ServeSuccessJSON(map[string]interface{}{
  1615. "failed_code": -10,
  1616. "msg": msg,
  1617. })
  1618. return
  1619. } else {
  1620. c.ServeSuccessJSON(map[string]interface{}{
  1621. "msg": "校验成功",
  1622. })
  1623. return
  1624. }
  1625. }
  1626. }
  1627. type ELeCertData struct {
  1628. Data struct {
  1629. Extra string `json:"extra"`
  1630. IDNo string `json:"idNo"`
  1631. IDType string `json:"idType"`
  1632. EcToken string `json:"ecToken"`
  1633. InsuOrg string `json:"insuOrg"`
  1634. UserName string `json:"userName"`
  1635. EcIndexNo string `json:"ecIndexNo"`
  1636. Gender string `json:"gender"`
  1637. Birthday string `json:"birthday"`
  1638. Nationality string `json:"nationality"`
  1639. Email string `json:"email"`
  1640. } `json:"OutData"`
  1641. }
  1642. func (c *HisApiController) ReadCard() {
  1643. id_card_type, _ := c.GetInt64("id_card_type")
  1644. admin_user_id, _ := c.GetInt64("admin_user_id")
  1645. certificates, _ := c.GetInt64("certificates")
  1646. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1648. switch id_card_type {
  1649. case 1:
  1650. if miConfig.MdtrtareaAdmvs == "421300" {
  1651. var res ResultTwo
  1652. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1653. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1654. "&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)
  1655. resp, requestErr := http.Get(api)
  1656. if requestErr != nil {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. var respJSON map[string]interface{}
  1667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. fmt.Println("log")
  1675. fmt.Println(string(result))
  1676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1677. utils.ErrorLog("解析失败:%v", err)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. if res.Infcode == 0 {
  1682. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1683. if err == gorm.ErrRecordNotFound {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1685. return
  1686. } else if err != nil {
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1688. return
  1689. } else {
  1690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1692. infoStr := string(Iinfos)
  1693. idetinfoStr := string(Idetinfos)
  1694. psn := &models.HisPsn{
  1695. PsnNo: res.Output.Baseinfo.PsnNo,
  1696. Age: res.Output.Baseinfo.Age,
  1697. PatientId: patient.ID,
  1698. Certno: res.Output.Baseinfo.Certno,
  1699. Brdy: res.Output.Baseinfo.Brdy,
  1700. Gend: res.Output.Baseinfo.Gend,
  1701. Naty: res.Output.Baseinfo.Naty,
  1702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1703. PsnName: res.Output.Baseinfo.PsnName,
  1704. Idetinfo: idetinfoStr,
  1705. Insuinfo: infoStr,
  1706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1707. }
  1708. service.CreateHisPsn(psn)
  1709. c.ServeSuccessJSON(map[string]interface{}{
  1710. "patient": patient,
  1711. "number": res.Output.Baseinfo.Certno,
  1712. })
  1713. }
  1714. } else {
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1716. return
  1717. }
  1718. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1719. var api string
  1720. if miConfig.MdtrtareaAdmvs == "320921" {
  1721. 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 +
  1722. "&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
  1723. fmt.Println(api)
  1724. } else {
  1725. 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 +
  1726. "&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)
  1727. }
  1728. resp, requestErr := http.Get(api)
  1729. if requestErr != nil {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. body, ioErr := ioutil.ReadAll(resp.Body)
  1734. if ioErr != nil {
  1735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1737. return
  1738. }
  1739. var respJSON map[string]interface{}
  1740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1743. return
  1744. }
  1745. var status string
  1746. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1747. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1748. //console.log()
  1749. fmt.Println("type===")
  1750. fmt.Println(card_type)
  1751. var token string
  1752. var res ResultTwo //1101结果
  1753. var res10265 ResultTwo10265 //1101结果
  1754. var card_info string //卡信息
  1755. var busi_card_info string
  1756. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1757. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1758. if status == "0" { //读卡成功
  1759. if card_type == "1" {
  1760. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1761. result, _ := json.Marshal(respJSON)
  1762. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1763. utils.ErrorLog("解析失败:%v", err)
  1764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1765. return
  1766. }
  1767. res.ErrMsg = res10265.ErrMsg
  1768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1769. res.Infcode = infocode
  1770. res.Output = res10265.Output
  1771. res.InfRefmsgid = res10265.InfRefmsgid
  1772. } else {
  1773. //var card_info string //卡信息
  1774. //var busi_card_info string
  1775. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1776. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1777. //fmt.Println(card_info)
  1778. //fmt.Println(busi_card_info)
  1779. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1780. result, _ := json.Marshal(respJSON)
  1781. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1782. utils.ErrorLog("解析失败:%v", err)
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1784. return
  1785. }
  1786. res.ErrMsg = res10265.ErrMsg
  1787. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1788. res.Infcode = infocode
  1789. res.Output = res10265.Output
  1790. res.InfRefmsgid = res10265.InfRefmsgid
  1791. }
  1792. if res.Infcode == 0 {
  1793. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1794. if err == gorm.ErrRecordNotFound {
  1795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1796. return
  1797. } else if err != nil {
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1799. return
  1800. } else {
  1801. if card_type == "1" {
  1802. bas := strings.Split(card_info, "|")
  1803. basNumber := bas[2]
  1804. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1805. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1806. infoStr := string(Iinfos)
  1807. idetinfoStr := string(Idetinfos)
  1808. psn := &models.HisPsn{
  1809. PsnNo: res.Output.Baseinfo.PsnNo,
  1810. Age: res.Output.Baseinfo.Age,
  1811. PatientId: patient.ID,
  1812. Certno: res.Output.Baseinfo.Certno,
  1813. Brdy: res.Output.Baseinfo.Brdy,
  1814. Gend: res.Output.Baseinfo.Gend,
  1815. Naty: res.Output.Baseinfo.Naty,
  1816. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1817. PsnName: res.Output.Baseinfo.PsnName,
  1818. Idetinfo: idetinfoStr,
  1819. Insuinfo: infoStr,
  1820. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1821. CardInfo: card_info,
  1822. VerifyNumber: busi_card_info,
  1823. }
  1824. service.CreateHisPsn(psn)
  1825. var rf []*ResultFive
  1826. json.Unmarshal([]byte(infoStr), &rf)
  1827. var insutypes []*ResultFive
  1828. var insutype string
  1829. var is390 int = 0
  1830. var is310 int = 0
  1831. for _, item := range rf {
  1832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1833. insutypes = append(insutypes, item)
  1834. }
  1835. }
  1836. if len(insutypes) == 1 {
  1837. insutype = insutypes[0].Insutype
  1838. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1839. } else {
  1840. for _, i := range insutypes {
  1841. if i.Insutype == "390" {
  1842. is390 = 1
  1843. }
  1844. if i.Insutype == "310" {
  1845. is310 = 1
  1846. }
  1847. }
  1848. }
  1849. if is390 == 1 {
  1850. insutype = "390"
  1851. }
  1852. if is310 == 1 {
  1853. insutype = "310"
  1854. }
  1855. if len(insutypes) == 0 {
  1856. insutype = "310"
  1857. }
  1858. c.ServeSuccessJSON(map[string]interface{}{
  1859. "patient": patient,
  1860. "number": basNumber,
  1861. "insutype": insutype,
  1862. })
  1863. } else {
  1864. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1865. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1866. infoStr := string(Iinfos)
  1867. idetinfoStr := string(Idetinfos)
  1868. psn := &models.HisPsn{
  1869. PsnNo: res.Output.Baseinfo.PsnNo,
  1870. Age: res.Output.Baseinfo.Age,
  1871. PatientId: patient.ID,
  1872. Certno: res.Output.Baseinfo.Certno,
  1873. Brdy: res.Output.Baseinfo.Brdy,
  1874. Gend: res.Output.Baseinfo.Gend,
  1875. Naty: res.Output.Baseinfo.Naty,
  1876. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1877. PsnName: res.Output.Baseinfo.PsnName,
  1878. Idetinfo: idetinfoStr,
  1879. Insuinfo: infoStr,
  1880. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1881. CardInfo: card_info,
  1882. VerifyNumber: token,
  1883. }
  1884. service.CreateHisPsn(psn)
  1885. c.ServeSuccessJSON(map[string]interface{}{
  1886. "patient": patient,
  1887. "number": token,
  1888. })
  1889. }
  1890. }
  1891. } else {
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1893. return
  1894. }
  1895. } else { //读卡失败
  1896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1897. return
  1898. }
  1899. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1900. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1901. cardnum = DeleteExtraSpaceTwo(cardnum)
  1902. cardCode = DeleteExtraSpaceTwo(cardCode)
  1903. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1904. name = DeleteExtraSpaceTwo(name)
  1905. errmsg = DeleteExtraSpaceTwo(errmsg)
  1906. cardnum = Remove0000(cardnum)
  1907. cardCode = Remove0000(cardCode)
  1908. id_card_no = Remove0000(id_card_no)
  1909. name = Remove0000(name)
  1910. errmsg = Remove0000(errmsg)
  1911. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1912. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1913. saveLog(result, requestLog, "1101", "获取人员信息")
  1914. fmt.Println(errMsgLog)
  1915. if len(errMsgLog) > 0 {
  1916. } else {
  1917. var dat map[string]interface{}
  1918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1919. fmt.Println(dat)
  1920. } else {
  1921. fmt.Println(err)
  1922. }
  1923. userJSONBytes, _ := json.Marshal(dat)
  1924. var res ResultTwo
  1925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1926. utils.ErrorLog("解析失败:%v", err)
  1927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. return
  1929. }
  1930. res.ErrMsg = errMsgLog
  1931. if res.Infcode == 0 {
  1932. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1933. if err == gorm.ErrRecordNotFound {
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1935. return
  1936. } else if err != nil {
  1937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1938. return
  1939. } else {
  1940. fmt.Println(res)
  1941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1943. infoStr := string(Iinfos)
  1944. idetinfoStr := string(Idetinfos)
  1945. psn := &models.HisPsn{
  1946. PsnNo: res.Output.Baseinfo.PsnNo,
  1947. Age: res.Output.Baseinfo.Age,
  1948. PatientId: patient.ID,
  1949. Certno: res.Output.Baseinfo.Certno,
  1950. Brdy: res.Output.Baseinfo.Brdy,
  1951. Gend: res.Output.Baseinfo.Gend,
  1952. Naty: res.Output.Baseinfo.Naty,
  1953. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1954. PsnName: res.Output.Baseinfo.PsnName,
  1955. Idetinfo: idetinfoStr,
  1956. Insuinfo: infoStr,
  1957. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1958. CardInfo: basStr,
  1959. VerifyNumber: "",
  1960. }
  1961. service.CreateHisPsn(psn)
  1962. var rf []*ResultFive
  1963. json.Unmarshal([]byte(infoStr), &rf)
  1964. var insutypes []*ResultFive
  1965. var insutype string
  1966. var is390 int = 0
  1967. var is310 int = 0
  1968. for _, item := range rf {
  1969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1970. insutypes = append(insutypes, item)
  1971. }
  1972. }
  1973. if len(insutypes) == 1 {
  1974. insutype = insutypes[0].Insutype
  1975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1976. } else {
  1977. for _, i := range insutypes {
  1978. if i.Insutype == "390" {
  1979. is390 = 1
  1980. }
  1981. if i.Insutype == "310" {
  1982. is310 = 1
  1983. }
  1984. }
  1985. }
  1986. if is390 == 1 {
  1987. insutype = "390"
  1988. }
  1989. if is310 == 1 {
  1990. insutype = "310"
  1991. }
  1992. if len(insutypes) == 0 {
  1993. insutype = "310"
  1994. }
  1995. c.ServeSuccessJSON(map[string]interface{}{
  1996. "patient": patient,
  1997. "number": cardnum,
  1998. "insutype": insutype,
  1999. })
  2000. }
  2001. } else {
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2003. return
  2004. }
  2005. }
  2006. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2007. fmt.Println(initFlag)
  2008. fmt.Println("initFlag")
  2009. if initFlag == 0 {
  2010. c.TestGetJiangXiBasBaseInit()
  2011. }
  2012. basStr := c.GetBasBaseInfo()
  2013. if len(basStr) == 0 {
  2014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2015. return
  2016. }
  2017. fmt.Println(basStr)
  2018. bas := strings.Split(basStr, "|")
  2019. basNumber := bas[1]
  2020. fmt.Println(basNumber)
  2021. card_sn := bas[3]
  2022. fmt.Println(card_sn)
  2023. 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, "")
  2024. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2025. var dat map[string]interface{}
  2026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2027. fmt.Println(dat)
  2028. } else {
  2029. fmt.Println(err)
  2030. }
  2031. userJSONBytes, _ := json.Marshal(dat)
  2032. var res ResultTwo
  2033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2034. utils.ErrorLog("解析失败:%v", err)
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. return
  2037. }
  2038. if res.Infcode == 0 {
  2039. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2040. if err == gorm.ErrRecordNotFound {
  2041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2042. return
  2043. } else if err != nil {
  2044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2045. return
  2046. } else {
  2047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2048. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2049. infoStr := string(Iinfos)
  2050. idetinfoStr := string(Idetinfos)
  2051. psn := &models.HisPsn{
  2052. PsnNo: res.Output.Baseinfo.PsnNo,
  2053. Age: res.Output.Baseinfo.Age,
  2054. PatientId: patient.ID,
  2055. Certno: res.Output.Baseinfo.Certno,
  2056. Brdy: res.Output.Baseinfo.Brdy,
  2057. Gend: res.Output.Baseinfo.Gend,
  2058. Naty: res.Output.Baseinfo.Naty,
  2059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2060. PsnName: res.Output.Baseinfo.PsnName,
  2061. Idetinfo: idetinfoStr,
  2062. Insuinfo: infoStr,
  2063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2064. CardInfo: basStr,
  2065. VerifyNumber: "",
  2066. }
  2067. service.CreateHisPsn(psn)
  2068. var rf []*ResultFive
  2069. json.Unmarshal([]byte(infoStr), &rf)
  2070. var insutypes []*ResultFive
  2071. var insutype string
  2072. var is390 int = 0
  2073. var is310 int = 0
  2074. for _, item := range rf {
  2075. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2076. insutypes = append(insutypes, item)
  2077. }
  2078. }
  2079. if len(insutypes) == 1 {
  2080. insutype = insutypes[0].Insutype
  2081. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2082. } else {
  2083. for _, i := range insutypes {
  2084. if i.Insutype == "390" {
  2085. is390 = 1
  2086. }
  2087. if i.Insutype == "310" {
  2088. is310 = 1
  2089. }
  2090. }
  2091. }
  2092. if is390 == 1 {
  2093. insutype = "390"
  2094. }
  2095. if is310 == 1 {
  2096. insutype = "310"
  2097. }
  2098. if len(insutypes) == 0 {
  2099. insutype = "310"
  2100. }
  2101. c.ServeSuccessJSON(map[string]interface{}{
  2102. "patient": patient,
  2103. "number": basNumber,
  2104. "insutype": insutype,
  2105. })
  2106. }
  2107. } else {
  2108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2109. return
  2110. }
  2111. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2112. fmt.Println(initFlag)
  2113. fmt.Println("initFlag")
  2114. if initFlag == 0 {
  2115. c.TestGetHnBasBaseInit()
  2116. }
  2117. basStr := c.GetBasBaseInfo()
  2118. if len(basStr) == 0 {
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2120. return
  2121. }
  2122. fmt.Println(basStr)
  2123. bas := strings.Split(basStr, "|")
  2124. basNumber := bas[1]
  2125. fmt.Println(basNumber)
  2126. card_sn := bas[3]
  2127. card_no := bas[2]
  2128. fmt.Println(card_sn)
  2129. name := bas[4]
  2130. name = ConvertToString(name, "gbk", "utf-8")
  2131. 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)
  2132. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2133. var dat map[string]interface{}
  2134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2135. fmt.Println(dat)
  2136. } else {
  2137. fmt.Println(err)
  2138. }
  2139. userJSONBytes, _ := json.Marshal(dat)
  2140. var res ResultTwo
  2141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2142. utils.ErrorLog("解析失败:%v", err)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2144. return
  2145. }
  2146. if res.Infcode == 0 {
  2147. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2148. if err == gorm.ErrRecordNotFound {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2150. return
  2151. } else if err != nil {
  2152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2153. return
  2154. } else {
  2155. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2156. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2157. infoStr := string(Iinfos)
  2158. idetinfoStr := string(Idetinfos)
  2159. psn := &models.HisPsn{
  2160. PsnNo: res.Output.Baseinfo.PsnNo,
  2161. Age: res.Output.Baseinfo.Age,
  2162. PatientId: patient.ID,
  2163. Certno: res.Output.Baseinfo.Certno,
  2164. Brdy: res.Output.Baseinfo.Brdy,
  2165. Gend: res.Output.Baseinfo.Gend,
  2166. Naty: res.Output.Baseinfo.Naty,
  2167. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2168. PsnName: res.Output.Baseinfo.PsnName,
  2169. Idetinfo: idetinfoStr,
  2170. Insuinfo: infoStr,
  2171. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2172. CardInfo: basStr,
  2173. VerifyNumber: "",
  2174. }
  2175. service.CreateHisPsn(psn)
  2176. var rf []*ResultFive
  2177. json.Unmarshal([]byte(infoStr), &rf)
  2178. var insutypes []*ResultFive
  2179. var insutype string
  2180. var is390 int = 0
  2181. var is310 int = 0
  2182. for _, item := range rf {
  2183. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2184. insutypes = append(insutypes, item)
  2185. }
  2186. }
  2187. if len(insutypes) == 1 {
  2188. insutype = insutypes[0].Insutype
  2189. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2190. } else {
  2191. for _, i := range insutypes {
  2192. if i.Insutype == "390" {
  2193. is390 = 1
  2194. }
  2195. if i.Insutype == "310" {
  2196. is310 = 1
  2197. }
  2198. }
  2199. }
  2200. if is390 == 1 {
  2201. insutype = "390"
  2202. }
  2203. if is310 == 1 {
  2204. insutype = "310"
  2205. }
  2206. if len(insutypes) == 0 {
  2207. insutype = "310"
  2208. }
  2209. c.ServeSuccessJSON(map[string]interface{}{
  2210. "patient": patient,
  2211. "number": basNumber,
  2212. "insutype": insutype,
  2213. })
  2214. }
  2215. } else {
  2216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2217. return
  2218. }
  2219. } else {
  2220. if initFlag == 0 {
  2221. c.TestGetBasBaseInit()
  2222. }
  2223. basStr := c.GetBasBaseInfo()
  2224. if len(basStr) == 0 {
  2225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2226. return
  2227. }
  2228. fmt.Println(basStr)
  2229. bas := strings.Split(basStr, "|")
  2230. basNumber := bas[1]
  2231. fmt.Println(basNumber)
  2232. card_sn := bas[3]
  2233. fmt.Println(card_sn)
  2234. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2235. var dat map[string]interface{}
  2236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2237. fmt.Println(dat)
  2238. } else {
  2239. fmt.Println(err)
  2240. }
  2241. userJSONBytes, _ := json.Marshal(dat)
  2242. var res ResultTwo
  2243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2244. utils.ErrorLog("解析失败:%v", err)
  2245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2246. return
  2247. }
  2248. if res.Infcode == 0 {
  2249. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2250. if err == gorm.ErrRecordNotFound {
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2252. return
  2253. } else if err != nil {
  2254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2255. return
  2256. } else {
  2257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2259. infoStr := string(Iinfos)
  2260. idetinfoStr := string(Idetinfos)
  2261. psn := &models.HisPsn{
  2262. PsnNo: res.Output.Baseinfo.PsnNo,
  2263. Age: res.Output.Baseinfo.Age,
  2264. PatientId: patient.ID,
  2265. Certno: res.Output.Baseinfo.Certno,
  2266. Brdy: res.Output.Baseinfo.Brdy,
  2267. Gend: res.Output.Baseinfo.Gend,
  2268. Naty: res.Output.Baseinfo.Naty,
  2269. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2270. PsnName: res.Output.Baseinfo.PsnName,
  2271. Idetinfo: idetinfoStr,
  2272. Insuinfo: infoStr,
  2273. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2274. CardInfo: basStr,
  2275. VerifyNumber: "",
  2276. }
  2277. service.CreateHisPsn(psn)
  2278. c.ServeSuccessJSON(map[string]interface{}{
  2279. "patient": patient,
  2280. "number": basNumber,
  2281. })
  2282. }
  2283. } else {
  2284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2285. return
  2286. }
  2287. break
  2288. }
  2289. case 2:
  2290. if miConfig.MdtrtareaAdmvs == "430800" {
  2291. if initFlag == 0 {
  2292. c.TestGetHnBasBaseInit()
  2293. }
  2294. SFZStr := c.GetSFZBaseInfo()
  2295. if len(SFZStr) == 0 {
  2296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2297. return
  2298. }
  2299. fmt.Println(SFZStr)
  2300. id_card_str := strings.Split(SFZStr, "^")
  2301. card_no := id_card_str[0]
  2302. name := id_card_str[1]
  2303. name = ConvertToString(name, "gbk", "utf-8")
  2304. 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, "", name, card_no)
  2305. var dat map[string]interface{}
  2306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2307. fmt.Println(dat)
  2308. } else {
  2309. fmt.Println(err)
  2310. }
  2311. userJSONBytes, _ := json.Marshal(dat)
  2312. var res ResultTwo
  2313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2314. utils.ErrorLog("解析失败:%v", err)
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2316. return
  2317. }
  2318. if res.Infcode == 0 {
  2319. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2320. if err == gorm.ErrRecordNotFound {
  2321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2322. return
  2323. } else if err != nil {
  2324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2325. return
  2326. } else {
  2327. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2328. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2329. infoStr := string(Iinfos)
  2330. idetinfoStr := string(Idetinfos)
  2331. psn := &models.HisPsn{
  2332. PsnNo: res.Output.Baseinfo.PsnNo,
  2333. Age: res.Output.Baseinfo.Age,
  2334. PatientId: patient.ID,
  2335. Certno: res.Output.Baseinfo.Certno,
  2336. Brdy: res.Output.Baseinfo.Brdy,
  2337. Gend: res.Output.Baseinfo.Gend,
  2338. Naty: res.Output.Baseinfo.Naty,
  2339. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2340. PsnName: res.Output.Baseinfo.PsnName,
  2341. Idetinfo: idetinfoStr,
  2342. Insuinfo: infoStr,
  2343. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2344. CardInfo: SFZStr,
  2345. VerifyNumber: "",
  2346. }
  2347. service.CreateHisPsn(psn)
  2348. var rf []*ResultFive
  2349. json.Unmarshal([]byte(infoStr), &rf)
  2350. var insutypes []*ResultFive
  2351. var insutype string
  2352. var is390 int = 0
  2353. var is310 int = 0
  2354. for _, item := range rf {
  2355. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2356. insutypes = append(insutypes, item)
  2357. }
  2358. }
  2359. if len(insutypes) == 1 {
  2360. insutype = insutypes[0].Insutype
  2361. } else {
  2362. for _, i := range insutypes {
  2363. if i.Insutype == "390" {
  2364. is390 = 1
  2365. }
  2366. if i.Insutype == "310" {
  2367. is310 = 1
  2368. }
  2369. }
  2370. }
  2371. if is390 == 1 {
  2372. insutype = "390"
  2373. }
  2374. if is310 == 1 {
  2375. insutype = "310"
  2376. }
  2377. if len(insutypes) == 0 {
  2378. insutype = "310"
  2379. }
  2380. c.ServeSuccessJSON(map[string]interface{}{
  2381. "patient": patient,
  2382. "number": card_no,
  2383. "insutype": insutype,
  2384. })
  2385. }
  2386. } else {
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2388. return
  2389. }
  2390. } else {
  2391. SFZStr := c.GetSFZBaseInfo()
  2392. id_card_str := strings.Split(SFZStr, "^")
  2393. id_card_number := id_card_str[0]
  2394. card_sn := ""
  2395. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2396. var dat map[string]interface{}
  2397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2398. fmt.Println(dat)
  2399. } else {
  2400. fmt.Println(err)
  2401. }
  2402. userJSONBytes, _ := json.Marshal(dat)
  2403. var res ResultTwo
  2404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2405. utils.ErrorLog("解析失败:%v", err)
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2407. return
  2408. }
  2409. if res.Infcode == 0 {
  2410. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2411. if err == gorm.ErrRecordNotFound {
  2412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2413. return
  2414. } else if err != nil {
  2415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2416. return
  2417. } else {
  2418. c.ServeSuccessJSON(map[string]interface{}{
  2419. "patient": patient,
  2420. "number": id_card_number,
  2421. })
  2422. }
  2423. } else {
  2424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2425. return
  2426. }
  2427. }
  2428. break
  2429. case 3:
  2430. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2431. var api string
  2432. if miConfig.MdtrtareaAdmvs == "320921" {
  2433. 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 +
  2434. "&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
  2435. fmt.Println(api)
  2436. } else {
  2437. 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 +
  2438. "&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)
  2439. }
  2440. resp, requestErr := http.Get(api)
  2441. if requestErr != nil {
  2442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2443. return
  2444. }
  2445. body, ioErr := ioutil.ReadAll(resp.Body)
  2446. if ioErr != nil {
  2447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2449. return
  2450. }
  2451. var respJSON map[string]interface{}
  2452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2455. return
  2456. }
  2457. var status string
  2458. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2459. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2460. var token string
  2461. var res ResultTwo //1101结果
  2462. var res10265 ResultTwo10265 //1101结果
  2463. var card_info string //卡信息
  2464. var busi_card_info string
  2465. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2466. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2467. if status == "0" { //读卡成功
  2468. if card_type == "1" {
  2469. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2470. result, _ := json.Marshal(respJSON)
  2471. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2472. utils.ErrorLog("解析失败:%v", err)
  2473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2474. return
  2475. }
  2476. res.ErrMsg = res10265.ErrMsg
  2477. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2478. res.Infcode = infocode
  2479. res.Output = res10265.Output
  2480. res.InfRefmsgid = res10265.InfRefmsgid
  2481. } else {
  2482. //var card_info string //卡信息
  2483. //var busi_card_info string
  2484. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2485. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2486. //fmt.Println(card_info)
  2487. //fmt.Println(busi_card_info)
  2488. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2489. result, _ := json.Marshal(respJSON)
  2490. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2491. utils.ErrorLog("解析失败:%v", err)
  2492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2493. return
  2494. }
  2495. res.ErrMsg = res10265.ErrMsg
  2496. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2497. res.Infcode = infocode
  2498. res.Output = res10265.Output
  2499. res.InfRefmsgid = res10265.InfRefmsgid
  2500. }
  2501. if res.Infcode == 0 {
  2502. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2503. if err == gorm.ErrRecordNotFound {
  2504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2505. return
  2506. } else if err != nil {
  2507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2508. return
  2509. } else {
  2510. if card_type == "1" {
  2511. bas := strings.Split(card_info, "|")
  2512. basNumber := bas[2]
  2513. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2514. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2515. infoStr := string(Iinfos)
  2516. idetinfoStr := string(Idetinfos)
  2517. psn := &models.HisPsn{
  2518. PsnNo: res.Output.Baseinfo.PsnNo,
  2519. Age: res.Output.Baseinfo.Age,
  2520. PatientId: patient.ID,
  2521. Certno: res.Output.Baseinfo.Certno,
  2522. Brdy: res.Output.Baseinfo.Brdy,
  2523. Gend: res.Output.Baseinfo.Gend,
  2524. Naty: res.Output.Baseinfo.Naty,
  2525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2526. PsnName: res.Output.Baseinfo.PsnName,
  2527. Idetinfo: idetinfoStr,
  2528. Insuinfo: infoStr,
  2529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2530. CardInfo: card_info,
  2531. VerifyNumber: busi_card_info,
  2532. }
  2533. service.CreateHisPsn(psn)
  2534. c.ServeSuccessJSON(map[string]interface{}{
  2535. "patient": patient,
  2536. "number": basNumber,
  2537. })
  2538. } else {
  2539. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2540. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2541. infoStr := string(Iinfos)
  2542. idetinfoStr := string(Idetinfos)
  2543. psn := &models.HisPsn{
  2544. PsnNo: res.Output.Baseinfo.PsnNo,
  2545. Age: res.Output.Baseinfo.Age,
  2546. PatientId: patient.ID,
  2547. Certno: res.Output.Baseinfo.Certno,
  2548. Brdy: res.Output.Baseinfo.Brdy,
  2549. Gend: res.Output.Baseinfo.Gend,
  2550. Naty: res.Output.Baseinfo.Naty,
  2551. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2552. PsnName: res.Output.Baseinfo.PsnName,
  2553. Idetinfo: idetinfoStr,
  2554. Insuinfo: infoStr,
  2555. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2556. CardInfo: card_info,
  2557. VerifyNumber: token,
  2558. }
  2559. service.CreateHisPsn(psn)
  2560. var rf []*ResultFive
  2561. json.Unmarshal([]byte(infoStr), &rf)
  2562. var insutypes []*ResultFive
  2563. var insutype string
  2564. var is390 int = 0
  2565. var is310 int = 0
  2566. for _, item := range rf {
  2567. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2568. insutypes = append(insutypes, item)
  2569. }
  2570. }
  2571. if len(insutypes) == 1 {
  2572. insutype = insutypes[0].Insutype
  2573. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2574. } else {
  2575. for _, i := range insutypes {
  2576. if i.Insutype == "390" {
  2577. is390 = 1
  2578. }
  2579. if i.Insutype == "310" {
  2580. is310 = 1
  2581. }
  2582. }
  2583. }
  2584. if is390 == 1 {
  2585. insutype = "390"
  2586. }
  2587. if is310 == 1 {
  2588. insutype = "310"
  2589. }
  2590. if len(insutypes) == 0 {
  2591. insutype = "310"
  2592. }
  2593. c.ServeSuccessJSON(map[string]interface{}{
  2594. "patient": patient,
  2595. "number": token,
  2596. "insutype": insutype,
  2597. })
  2598. }
  2599. }
  2600. } else {
  2601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2602. return
  2603. }
  2604. } else { //读卡失败
  2605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2606. return
  2607. }
  2608. }
  2609. break
  2610. case 4:
  2611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2612. var api string
  2613. if miConfig.MdtrtareaAdmvs == "320921" {
  2614. 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 +
  2615. "&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
  2616. fmt.Println(api)
  2617. } else {
  2618. 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 +
  2619. "&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)
  2620. }
  2621. resp, requestErr := http.Get(api)
  2622. if requestErr != nil {
  2623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2624. return
  2625. }
  2626. body, ioErr := ioutil.ReadAll(resp.Body)
  2627. if ioErr != nil {
  2628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2630. return
  2631. }
  2632. var respJSON map[string]interface{}
  2633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. return
  2637. }
  2638. var status string
  2639. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2640. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2641. var token string
  2642. var res ResultTwo //1101结果
  2643. var res10265 ResultTwo10265 //1101结果
  2644. if status == "0" { //读卡成功
  2645. var card_info string //卡信息
  2646. var busi_card_info string
  2647. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2648. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2649. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2650. fmt.Println(card_info)
  2651. fmt.Println(busi_card_info)
  2652. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2653. result, _ := json.Marshal(respJSON)
  2654. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2655. utils.ErrorLog("解析失败:%v", err)
  2656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2657. return
  2658. }
  2659. res.ErrMsg = res10265.ErrMsg
  2660. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2661. res.Infcode = infocode
  2662. res.Output = res10265.Output
  2663. res.InfRefmsgid = res10265.InfRefmsgid
  2664. if res.Infcode == 0 {
  2665. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2666. if err == gorm.ErrRecordNotFound {
  2667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2668. return
  2669. } else if err != nil {
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2671. return
  2672. } else {
  2673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2675. infoStr := string(Iinfos)
  2676. idetinfoStr := string(Idetinfos)
  2677. psn := &models.HisPsn{
  2678. PsnNo: res.Output.Baseinfo.PsnNo,
  2679. Age: res.Output.Baseinfo.Age,
  2680. PatientId: patient.ID,
  2681. Certno: res.Output.Baseinfo.Certno,
  2682. Brdy: res.Output.Baseinfo.Brdy,
  2683. Gend: res.Output.Baseinfo.Gend,
  2684. Naty: res.Output.Baseinfo.Naty,
  2685. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2686. PsnName: res.Output.Baseinfo.PsnName,
  2687. Idetinfo: idetinfoStr,
  2688. Insuinfo: infoStr,
  2689. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2690. CardInfo: card_info,
  2691. VerifyNumber: token,
  2692. }
  2693. var rf []*ResultFive
  2694. json.Unmarshal([]byte(infoStr), &rf)
  2695. var insutypes []*ResultFive
  2696. var insutype string
  2697. var is390 int = 0
  2698. var is310 int = 0
  2699. for _, item := range rf {
  2700. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2701. insutypes = append(insutypes, item)
  2702. }
  2703. }
  2704. if len(insutypes) == 1 {
  2705. insutype = insutypes[0].Insutype
  2706. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2707. } else {
  2708. for _, i := range insutypes {
  2709. if i.Insutype == "390" {
  2710. is390 = 1
  2711. }
  2712. if i.Insutype == "310" {
  2713. is310 = 1
  2714. }
  2715. }
  2716. }
  2717. if is390 == 1 {
  2718. insutype = "390"
  2719. }
  2720. if is310 == 1 {
  2721. insutype = "310"
  2722. }
  2723. if len(insutypes) == 0 {
  2724. insutype = "310"
  2725. }
  2726. service.CreateHisPsn(psn)
  2727. c.ServeSuccessJSON(map[string]interface{}{
  2728. "patient": patient,
  2729. "number": token,
  2730. "insutype": insutype,
  2731. })
  2732. }
  2733. } else {
  2734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2735. return
  2736. }
  2737. } else { //读卡失败
  2738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2739. return
  2740. }
  2741. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2742. if initFlag == 0 {
  2743. c.TestGetBasBaseInit()
  2744. }
  2745. token := c.GetEleBaseInfo()
  2746. token = Remove0000(token)
  2747. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2748. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2749. //
  2750. var res ResultTwo
  2751. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2752. utils.ErrorLog("解析失败:%v", err)
  2753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2754. return
  2755. }
  2756. if res.Infcode == 0 {
  2757. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2758. if err == gorm.ErrRecordNotFound {
  2759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2760. return
  2761. } else if err != nil {
  2762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2763. return
  2764. } else {
  2765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2767. infoStr := string(Iinfos)
  2768. idetinfoStr := string(Idetinfos)
  2769. psn := &models.HisPsn{
  2770. PsnNo: res.Output.Baseinfo.PsnNo,
  2771. Age: res.Output.Baseinfo.Age,
  2772. PatientId: patient.ID,
  2773. Certno: res.Output.Baseinfo.Certno,
  2774. Brdy: res.Output.Baseinfo.Brdy,
  2775. Gend: res.Output.Baseinfo.Gend,
  2776. Naty: res.Output.Baseinfo.Naty,
  2777. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2778. PsnName: res.Output.Baseinfo.PsnName,
  2779. Idetinfo: idetinfoStr,
  2780. Insuinfo: infoStr,
  2781. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2782. CardInfo: "",
  2783. VerifyNumber: token,
  2784. }
  2785. service.CreateHisPsn(psn)
  2786. c.ServeSuccessJSON(map[string]interface{}{
  2787. "patient": patient,
  2788. "number": token,
  2789. })
  2790. }
  2791. } else {
  2792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2793. return
  2794. }
  2795. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2796. if initFlag == 0 {
  2797. c.TestGetBasBaseInit()
  2798. }
  2799. token := c.GetEleBaseInfo()
  2800. token = Remove0000(token)
  2801. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2802. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2803. //
  2804. var res ResultTwo
  2805. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2806. utils.ErrorLog("解析失败:%v", err)
  2807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. return
  2809. }
  2810. if res.Infcode == 0 {
  2811. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2812. if err == gorm.ErrRecordNotFound {
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2814. return
  2815. } else if err != nil {
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2817. return
  2818. } else {
  2819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2821. infoStr := string(Iinfos)
  2822. idetinfoStr := string(Idetinfos)
  2823. psn := &models.HisPsn{
  2824. PsnNo: res.Output.Baseinfo.PsnNo,
  2825. Age: res.Output.Baseinfo.Age,
  2826. PatientId: patient.ID,
  2827. Certno: res.Output.Baseinfo.Certno,
  2828. Brdy: res.Output.Baseinfo.Brdy,
  2829. Gend: res.Output.Baseinfo.Gend,
  2830. Naty: res.Output.Baseinfo.Naty,
  2831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2832. PsnName: res.Output.Baseinfo.PsnName,
  2833. Idetinfo: idetinfoStr,
  2834. Insuinfo: infoStr,
  2835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2836. CardInfo: "",
  2837. VerifyNumber: token,
  2838. }
  2839. service.CreateHisPsn(psn)
  2840. c.ServeSuccessJSON(map[string]interface{}{
  2841. "patient": patient,
  2842. "number": token,
  2843. })
  2844. }
  2845. } else {
  2846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2847. return
  2848. }
  2849. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2850. //if initFlag == 0 {
  2851. c.TestGetJiangXiBasBaseInit()
  2852. //}
  2853. //if initEleFlag == 0 {
  2854. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2855. //}
  2856. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2857. type ELeData struct {
  2858. Data struct {
  2859. IdNo string `json:"idNo"`
  2860. IdType string `json:"idType"`
  2861. UserName string `json:"userName"`
  2862. EcToken string `json:"ecToken"`
  2863. InsuOrg string `json:"insuOrg"`
  2864. Gender string `json:"gender"`
  2865. Birthday string `json:"birthday"`
  2866. Nationality string `json:"nationality"`
  2867. Email string `json:"email"`
  2868. Extra string `json:"extra"`
  2869. } `json:"data"`
  2870. Code int `json:"code"`
  2871. Message string `json:"message"`
  2872. }
  2873. var ele ELeData
  2874. err := json.Unmarshal([]byte(json_result), &ele)
  2875. if err != nil {
  2876. utils.ErrorLog("解析失败:%v", err)
  2877. }
  2878. token := ele.Data.EcToken
  2879. token = Remove0000(token)
  2880. 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)
  2881. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2882. var res ResultTwo
  2883. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2884. utils.ErrorLog("解析失败:%v", err)
  2885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2886. return
  2887. }
  2888. if res.Infcode == 0 {
  2889. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2890. if err == gorm.ErrRecordNotFound {
  2891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2892. return
  2893. } else if err != nil {
  2894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2895. return
  2896. } else {
  2897. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2898. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2899. infoStr := string(Iinfos)
  2900. idetinfoStr := string(Idetinfos)
  2901. psn := &models.HisPsn{
  2902. PsnNo: res.Output.Baseinfo.PsnNo,
  2903. Age: res.Output.Baseinfo.Age,
  2904. PatientId: patient.ID,
  2905. Certno: res.Output.Baseinfo.Certno,
  2906. Brdy: res.Output.Baseinfo.Brdy,
  2907. Gend: res.Output.Baseinfo.Gend,
  2908. Naty: res.Output.Baseinfo.Naty,
  2909. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2910. PsnName: res.Output.Baseinfo.PsnName,
  2911. Idetinfo: idetinfoStr,
  2912. Insuinfo: infoStr,
  2913. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2914. CardInfo: "",
  2915. VerifyNumber: token,
  2916. }
  2917. service.CreateHisPsn(psn)
  2918. var rf []*ResultFive
  2919. json.Unmarshal([]byte(infoStr), &rf)
  2920. var insutypes []*ResultFive
  2921. var insutype string
  2922. var is390 int = 0
  2923. var is310 int = 0
  2924. for _, item := range rf {
  2925. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2926. insutypes = append(insutypes, item)
  2927. }
  2928. }
  2929. if len(insutypes) == 1 {
  2930. insutype = insutypes[0].Insutype
  2931. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2932. } else {
  2933. for _, i := range insutypes {
  2934. if i.Insutype == "390" {
  2935. is390 = 1
  2936. }
  2937. if i.Insutype == "310" {
  2938. is310 = 1
  2939. }
  2940. }
  2941. }
  2942. if is390 == 1 {
  2943. insutype = "390"
  2944. }
  2945. if is310 == 1 {
  2946. insutype = "310"
  2947. }
  2948. if len(insutypes) == 0 {
  2949. insutype = "310"
  2950. }
  2951. c.ServeSuccessJSON(map[string]interface{}{
  2952. "patient": patient,
  2953. "number": token,
  2954. "insutype": insutype,
  2955. })
  2956. }
  2957. } else {
  2958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2959. return
  2960. }
  2961. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2962. //if initFlag == 0 {
  2963. c.TestGetJiangXiBasBaseInit()
  2964. //}
  2965. //if initEleFlag == 0 {
  2966. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. //}
  2968. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2969. type ELeData struct {
  2970. Data struct {
  2971. IdNo string `json:"idNo"`
  2972. IdType string `json:"idType"`
  2973. UserName string `json:"userName"`
  2974. EcToken string `json:"ecToken"`
  2975. InsuOrg string `json:"insuOrg"`
  2976. Gender string `json:"gender"`
  2977. Birthday string `json:"birthday"`
  2978. Nationality string `json:"nationality"`
  2979. Email string `json:"email"`
  2980. Extra string `json:"extra"`
  2981. } `json:"data"`
  2982. Code int `json:"code"`
  2983. Message string `json:"message"`
  2984. }
  2985. var ele ELeData
  2986. err := json.Unmarshal([]byte(json_result), &ele)
  2987. if err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. }
  2990. token := ele.Data.EcToken
  2991. token = Remove0000(token)
  2992. 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)
  2993. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2994. var res ResultTwo
  2995. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2996. utils.ErrorLog("解析失败:%v", err)
  2997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2998. return
  2999. }
  3000. if res.Infcode == 0 {
  3001. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3002. if err == gorm.ErrRecordNotFound {
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3004. return
  3005. } else if err != nil {
  3006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3007. return
  3008. } else {
  3009. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3010. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3011. infoStr := string(Iinfos)
  3012. idetinfoStr := string(Idetinfos)
  3013. psn := &models.HisPsn{
  3014. PsnNo: res.Output.Baseinfo.PsnNo,
  3015. Age: res.Output.Baseinfo.Age,
  3016. PatientId: patient.ID,
  3017. Certno: res.Output.Baseinfo.Certno,
  3018. Brdy: res.Output.Baseinfo.Brdy,
  3019. Gend: res.Output.Baseinfo.Gend,
  3020. Naty: res.Output.Baseinfo.Naty,
  3021. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3022. PsnName: res.Output.Baseinfo.PsnName,
  3023. Idetinfo: idetinfoStr,
  3024. Insuinfo: infoStr,
  3025. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3026. CardInfo: "",
  3027. VerifyNumber: token,
  3028. }
  3029. service.CreateHisPsn(psn)
  3030. var rf []*ResultFive
  3031. json.Unmarshal([]byte(infoStr), &rf)
  3032. var insutypes []*ResultFive
  3033. var insutype string
  3034. var is390 int = 0
  3035. var is310 int = 0
  3036. for _, item := range rf {
  3037. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3038. insutypes = append(insutypes, item)
  3039. }
  3040. }
  3041. if len(insutypes) == 1 {
  3042. insutype = insutypes[0].Insutype
  3043. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3044. } else {
  3045. for _, i := range insutypes {
  3046. if i.Insutype == "390" {
  3047. is390 = 1
  3048. }
  3049. if i.Insutype == "310" {
  3050. is310 = 1
  3051. }
  3052. }
  3053. }
  3054. if is390 == 1 {
  3055. insutype = "390"
  3056. }
  3057. if is310 == 1 {
  3058. insutype = "310"
  3059. }
  3060. if len(insutypes) == 0 {
  3061. insutype = "310"
  3062. }
  3063. c.ServeSuccessJSON(map[string]interface{}{
  3064. "patient": patient,
  3065. "number": token,
  3066. "insutype": insutype,
  3067. })
  3068. }
  3069. } else {
  3070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3071. return
  3072. }
  3073. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3074. type ELeData struct {
  3075. Code string `json:"code"`
  3076. Data struct {
  3077. Aac002 string `json:"aac002"`
  3078. Aaz500 string `json:"aaz500"`
  3079. ActCardNo string `json:"actCardNo"`
  3080. Bab520 string `json:"bab520"`
  3081. Bkz543 string `json:"bkz543"`
  3082. BusinessType string `json:"businessType"`
  3083. CertfCodg string `json:"certfCodg"`
  3084. EcIndexNo string `json:"ecIndexNo"`
  3085. EcToken string `json:"ecToken"`
  3086. ID0000 string `json:"id0000"`
  3087. IDNo string `json:"idNo"`
  3088. IDType string `json:"idType"`
  3089. Idcode string `json:"idcode"`
  3090. IdentityToken string `json:"identity_token"`
  3091. InsuOrg string `json:"insuOrg"`
  3092. OfficeID string `json:"officeId"`
  3093. OfficeName string `json:"officeName"`
  3094. OperatorID string `json:"operatorId"`
  3095. OperatorName string `json:"operatorName"`
  3096. OrgID string `json:"orgId"`
  3097. UserName string `json:"userName"`
  3098. } `json:"data"`
  3099. Infno interface{} `json:"infno"`
  3100. Message string `json:"message"`
  3101. OrgID string `json:"orgId"`
  3102. TransType string `json:"transType"`
  3103. }
  3104. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3105. outPutInfo = Remove0000(outPutInfo)
  3106. if len(outPutInfo) > 0 {
  3107. var ele ELeData
  3108. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3109. if err != nil {
  3110. utils.ErrorLog("解析失败:%v", err)
  3111. }
  3112. token := ele.Data.EcToken
  3113. fmt.Println(inputInfo)
  3114. fmt.Println(outPutInfo)
  3115. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3116. saveLog(result, requestLog, "1101", "获取人员信息")
  3117. var dat map[string]interface{}
  3118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3119. fmt.Println(dat)
  3120. } else {
  3121. fmt.Println(err)
  3122. }
  3123. userJSONBytes, _ := json.Marshal(dat)
  3124. var res ResultTwo
  3125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. res.ErrMsg = errMsgLog
  3131. if res.Infcode == 0 {
  3132. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3133. if err == gorm.ErrRecordNotFound {
  3134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3135. return
  3136. } else if err != nil {
  3137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3138. return
  3139. } else {
  3140. fmt.Println(res)
  3141. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3142. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3143. infoStr := string(Iinfos)
  3144. idetinfoStr := string(Idetinfos)
  3145. psn := &models.HisPsn{
  3146. PsnNo: res.Output.Baseinfo.PsnNo,
  3147. Age: res.Output.Baseinfo.Age,
  3148. PatientId: patient.ID,
  3149. Certno: res.Output.Baseinfo.Certno,
  3150. Brdy: res.Output.Baseinfo.Brdy,
  3151. Gend: res.Output.Baseinfo.Gend,
  3152. Naty: res.Output.Baseinfo.Naty,
  3153. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3154. PsnName: res.Output.Baseinfo.PsnName,
  3155. Idetinfo: idetinfoStr,
  3156. Insuinfo: infoStr,
  3157. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3158. CardInfo: outPutInfo,
  3159. VerifyNumber: token,
  3160. }
  3161. service.CreateHisPsn(psn)
  3162. var rf []*ResultFive
  3163. json.Unmarshal([]byte(infoStr), &rf)
  3164. var insutypes []*ResultFive
  3165. var insutype string
  3166. var is390 int = 0
  3167. var is310 int = 0
  3168. for _, item := range rf {
  3169. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3170. insutypes = append(insutypes, item)
  3171. }
  3172. }
  3173. if len(insutypes) == 1 {
  3174. insutype = insutypes[0].Insutype
  3175. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3176. } else {
  3177. for _, i := range insutypes {
  3178. if i.Insutype == "390" {
  3179. is390 = 1
  3180. }
  3181. if i.Insutype == "310" {
  3182. is310 = 1
  3183. }
  3184. }
  3185. }
  3186. if is390 == 1 {
  3187. insutype = "390"
  3188. }
  3189. if is310 == 1 {
  3190. insutype = "310"
  3191. }
  3192. if len(insutypes) == 0 {
  3193. insutype = "310"
  3194. }
  3195. c.ServeSuccessJSON(map[string]interface{}{
  3196. "patient": patient,
  3197. "number": token,
  3198. "insutype": insutype,
  3199. })
  3200. }
  3201. } else {
  3202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3203. return
  3204. }
  3205. }
  3206. }
  3207. break
  3208. }
  3209. }
  3210. var initFlag int64 = 0
  3211. var initEleFlag int64 = 0
  3212. func (c *HisApiController) TestGetBasBaseInit() {
  3213. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3214. Iinit := DllDef.MustFindProc("Init")
  3215. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3216. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3217. if ret != 0 {
  3218. fmt.Println("SSCard的报错原因:", err)
  3219. fmt.Println("SSCard的运算结果为:", ret)
  3220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3221. return
  3222. }
  3223. result := int(ret)
  3224. fmt.Println("SSCard的运算结果为1:", result)
  3225. initFlag = 1
  3226. return
  3227. }
  3228. func (c *HisApiController) HandleJiangXiReadCard() {
  3229. fmt.Println("~~~~~~")
  3230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3231. admin_user_id, _ := c.GetInt64("admin_user_id")
  3232. id_card_type, _ := c.GetInt64("id_card_type")
  3233. //certificates, _ := c.GetInt64("certificates")
  3234. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3235. if initFlag == 0 {
  3236. c.TestGetJiangXiBasBaseInit()
  3237. }
  3238. basStr := c.GetBasBaseInfo()
  3239. if len(basStr) == 0 {
  3240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3241. return
  3242. }
  3243. fmt.Println(basStr)
  3244. bas := strings.Split(basStr, "|")
  3245. basNumber := bas[1]
  3246. fmt.Println(basNumber)
  3247. card_sn := bas[3]
  3248. fmt.Println(card_sn)
  3249. 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, "")
  3250. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3251. var dat map[string]interface{}
  3252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3253. fmt.Println(dat)
  3254. } else {
  3255. fmt.Println(err)
  3256. }
  3257. userJSONBytes, _ := json.Marshal(dat)
  3258. var res ResultTwo
  3259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3260. utils.ErrorLog("解析失败:%v", err)
  3261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3262. return
  3263. }
  3264. if res.Infcode == 0 {
  3265. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3266. if err == gorm.ErrRecordNotFound {
  3267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3268. return
  3269. } else if err != nil {
  3270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3271. return
  3272. } else {
  3273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3274. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3275. infoStr := string(Iinfos)
  3276. idetinfoStr := string(Idetinfos)
  3277. psn := &models.HisPsn{
  3278. PsnNo: res.Output.Baseinfo.PsnNo,
  3279. Age: res.Output.Baseinfo.Age,
  3280. PatientId: patient.ID,
  3281. Certno: res.Output.Baseinfo.Certno,
  3282. Brdy: res.Output.Baseinfo.Brdy,
  3283. Gend: res.Output.Baseinfo.Gend,
  3284. Naty: res.Output.Baseinfo.Naty,
  3285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3286. PsnName: res.Output.Baseinfo.PsnName,
  3287. Idetinfo: idetinfoStr,
  3288. Insuinfo: infoStr,
  3289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3290. CardInfo: basStr,
  3291. VerifyNumber: "",
  3292. }
  3293. service.CreateHisPsn(psn)
  3294. c.ServeSuccessJSON(map[string]interface{}{
  3295. "patient": patient,
  3296. "number": basNumber,
  3297. })
  3298. }
  3299. } else {
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3301. return
  3302. }
  3303. }
  3304. func (c *HisApiController) TestGetHnBasBaseInit() {
  3305. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3306. Iinit := DllDef.MustFindProc("Init")
  3307. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3308. //http://10.77.211.236/CSB/hsa-fsi-1303
  3309. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3310. if ret != 0 {
  3311. fmt.Println("SSCard的报错原因:", err)
  3312. fmt.Println("SSCard的运算结果为:", ret)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3314. return
  3315. }
  3316. result := int(ret)
  3317. fmt.Println("SSCard的运算结果为1:", result)
  3318. initFlag = 1
  3319. return
  3320. }
  3321. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3322. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3323. Iinit := DllDef.MustFindProc("Init")
  3324. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3325. //http://10.77.211.236/CSB/hsa-fsi-1303
  3326. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3327. if ret != 0 {
  3328. fmt.Println("SSCard的报错原因:", err)
  3329. fmt.Println("SSCard的运算结果为:", ret)
  3330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3331. return
  3332. }
  3333. result := int(ret)
  3334. fmt.Println("SSCard的运算结果为1:", result)
  3335. initFlag = 1
  3336. return
  3337. }
  3338. func (c *HisApiController) GetSFZBaseInfo() string {
  3339. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3340. readCard := DllDef.MustFindProc("ReadSFZ")
  3341. if readCard == nil {
  3342. fmt.Println("readcard is nil")
  3343. readCard = DllDef.MustFindProc("ReadSFZ")
  3344. }
  3345. str := make([]byte, 1024)
  3346. str1 := make([]byte, 1024)
  3347. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(4096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(4096))
  3348. fmt.Println(r)
  3349. return string(str)
  3350. }
  3351. func (c *HisApiController) GetEleBaseInfo() string {
  3352. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3353. readCard := DllDef.MustFindProc("GetQRBase")
  3354. fmt.Println(readCard)
  3355. if readCard == nil {
  3356. fmt.Println("readcard is nil")
  3357. readCard = DllDef.MustFindProc("GetQRBase")
  3358. }
  3359. str := make([]byte, 1024)
  3360. str1 := make([]byte, 1024)
  3361. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3362. fmt.Println(ret2)
  3363. fmt.Println(string(str1))
  3364. fmt.Println(string(str))
  3365. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3366. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3367. if ret2 != 0 {
  3368. return ""
  3369. }
  3370. return string(str)
  3371. }
  3372. func GetJxEleBaseInfo(org_id int64) string {
  3373. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3374. readCard := DllDef.MustFindProc("NationEcTrans")
  3375. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3376. if readCard == nil {
  3377. fmt.Println("readcard is nil")
  3378. readCard = DllDef.MustFindProc("NationEcTrans")
  3379. }
  3380. str1 := make([]byte, 1024)
  3381. data := make(map[string]interface{})
  3382. inputData := make(map[string]interface{})
  3383. inputData["orgId"] = miConfig.Code
  3384. inputData["businessType"] = "01101"
  3385. inputData["operatorId"] = "test001"
  3386. inputData["operatorName"] = "cn"
  3387. inputData["officeId"] = "32760"
  3388. inputData["officeName"] = "waike"
  3389. inputData["deviceType"] = ""
  3390. data["data"] = inputData
  3391. data["transType"] = "ec.query"
  3392. data["extra "] = ""
  3393. data["orgId"] = miConfig.Code
  3394. bytesData, _ := json.Marshal(data)
  3395. //bytesData, _ := json.Marshal(data)
  3396. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3397. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3398. fmt.Println(ret2)
  3399. fmt.Println(string(str1))
  3400. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3401. if ret2 != 0 {
  3402. return ""
  3403. }
  3404. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3405. }
  3406. func GetJxEleBaseInitInfo(org_id int64) string {
  3407. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3408. readCard := DllDef.MustFindProc("NationEcTrans")
  3409. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3410. if readCard == nil {
  3411. fmt.Println("readcard is nil")
  3412. readCard = DllDef.MustFindProc("NationEcTrans")
  3413. }
  3414. str1 := make([]byte, 2048)
  3415. data := make(map[string]interface{})
  3416. inputData := make(map[string]interface{})
  3417. inputData["orgId"] = miConfig.Code
  3418. inputData["businessType"] = "01101"
  3419. inputData["operatorId"] = "1"
  3420. inputData["operatorName"] = "huangchuang"
  3421. inputData["officeId"] = "101"
  3422. inputData["officeName"] = "xuetou"
  3423. inputData["deviceType"] = ""
  3424. data["data"] = inputData
  3425. data["transType"] = "ec.query"
  3426. data["orgId"] = miConfig.Code
  3427. bytesData, _ := json.Marshal(data)
  3428. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3429. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3430. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3431. fmt.Println(ret2)
  3432. fmt.Println(string(str1))
  3433. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3434. if ret2 != 0 {
  3435. return ""
  3436. }
  3437. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3438. initEleFlag = 1
  3439. }
  3440. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3441. }
  3442. func (c *HisApiController) GetBasBaseInfo() string {
  3443. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3444. readCard := DllDef.MustFindProc("ReadCardBas")
  3445. if readCard == nil {
  3446. fmt.Println("readcard is nil")
  3447. readCard = DllDef.MustFindProc("ReadCardBas")
  3448. }
  3449. str := make([]byte, 1024)
  3450. str1 := make([]byte, 1024)
  3451. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3452. fmt.Println(string(str1))
  3453. fmt.Println(string(str))
  3454. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3455. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3456. if ret2 != 0 {
  3457. return ""
  3458. }
  3459. return string(str)
  3460. }
  3461. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3462. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3463. readCard := DllDef.MustFindProc("read_cardinfo")
  3464. if readCard == nil {
  3465. fmt.Println("readcard is nil")
  3466. readCard = DllDef.MustFindProc("read_cardinfo")
  3467. }
  3468. str := make([]byte, 1024) //卡号
  3469. str1 := make([]byte, 1024) //卡识别码
  3470. str2 := make([]byte, 1024) //身份证号
  3471. str3 := make([]byte, 1024) //姓名
  3472. str4 := make([]byte, 1024) //错误信息
  3473. 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])))
  3474. fmt.Println(string(str1))
  3475. fmt.Println(string(str))
  3476. fmt.Println(string(str2))
  3477. fmt.Println(string(str3))
  3478. fmt.Println(string(str4))
  3479. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3480. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3481. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3482. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3483. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3484. if ret2 != 0 {
  3485. return "", "", "", "", ""
  3486. }
  3487. return string(str), string(str1), string(str2), string(str3), string(str4)
  3488. }
  3489. type CustomFundPay struct {
  3490. FundPayType string `json:"fund_pay_type"`
  3491. FundPayamt float64 `json:"fund_payamt"`
  3492. }
  3493. func (c *HisApiController) GetSettleList() {
  3494. order_id, _ := c.GetInt64("order_id")
  3495. admin_user_id, _ := c.GetInt64("admin_user_id")
  3496. order, _ := service.GetHisOrderByIDTwo(order_id)
  3497. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3498. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3499. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3500. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3501. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3502. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3503. if order.ID == 0 {
  3504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3505. return
  3506. }
  3507. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3508. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3509. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3510. fmt.Println(count)
  3511. var zero string
  3512. number := count + 1
  3513. if number >= 1000 {
  3514. zero = "0000" + strconv.FormatInt(number, 10)
  3515. } else if number >= 10000 {
  3516. zero = "000" + strconv.FormatInt(number, 10)
  3517. } else if number >= 100000 {
  3518. zero = "00" + strconv.FormatInt(number, 10)
  3519. } else if number >= 1000000 {
  3520. zero = "0" + strconv.FormatInt(number, 10)
  3521. } else {
  3522. zero = strconv.FormatInt(number, 10)
  3523. }
  3524. fmt.Println(zero)
  3525. struct4101 := service.Struct4101{
  3526. PsnNo: order.PsnNo,
  3527. MdtrtId: order.MdtrtId,
  3528. SetlId: order.SetlId,
  3529. PsnName: order.PsnName,
  3530. Gend: order.Gend,
  3531. Brdy: his.Brdy,
  3532. Age: his.Age,
  3533. Naty: order.Naty,
  3534. PatnCertType: "01",
  3535. Certno: order.Certno,
  3536. Prfs: "90",
  3537. ConerName: roles[0].UserName,
  3538. PatnRlts: "99",
  3539. ConerAddr: miConfig.OrgName,
  3540. ConerTel: admin.Mobile,
  3541. HiType: order.Insutype,
  3542. Insuplc: miConfig.InsuplcAdmdvs,
  3543. MaindiagFlag: "1",
  3544. BillCode: order.SetlId,
  3545. BillNo: order.SetlId,
  3546. BizSn: order.Number,
  3547. PsnSelfPay: order.PsnPartAmt,
  3548. PsnOwnPay: order.PsnPartAmt,
  3549. AcctPay: order.AcctPay,
  3550. PsnCashpay: order.PsnCashPay,
  3551. HiPaymtd: "1",
  3552. Hsorg: miConfig.InsuplcAdmdvs,
  3553. HsorgOpter: miConfig.InsuplcAdmdvs,
  3554. MedinsFillPsn: curRoles.UserName,
  3555. MedinsFillDept: depart.Name,
  3556. IptMedType: "2",
  3557. }
  3558. struct4101.SetlBegnDate = order.SetlTime
  3559. struct4101.SetlEndDate = order.SetlTime
  3560. time_arr := strings.Split(order.SetlTime, " ")
  3561. struct4101.AdmTime = time_arr[0]
  3562. struct4101.AdmEndTime = time_arr[0]
  3563. var rf []CustomFundPay
  3564. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3565. var tempFunPays []service.CustomStruct
  3566. for _, item := range rf {
  3567. var tempFunPay service.CustomStruct
  3568. tempFunPay.FundPayamt = item.FundPayamt
  3569. tempFunPay.FundPayType = item.FundPayType
  3570. tempFunPays = append(tempFunPays, tempFunPay)
  3571. }
  3572. struct4101.CustomStruct = tempFunPays
  3573. var tempDiaginfos []service.DiaginfoStructTwo
  3574. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3575. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3576. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3577. var config []*models.HisXtDiagnoseConfig
  3578. for _, item := range diagnosis_ids {
  3579. id, _ := strconv.ParseInt(item, 10, 64)
  3580. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3581. config = append(config, &diagnosisConfig)
  3582. }
  3583. for index, item := range config {
  3584. if index == 0 {
  3585. var tempDiaginfo service.DiaginfoStructTwo
  3586. tempDiaginfo.DiagCode = item.CountryCode
  3587. tempDiaginfo.DiagName = item.CountryContentName
  3588. tempDiaginfo.DiagType = "1"
  3589. tempDiaginfo.MaindiagFlag = "1"
  3590. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3591. } else {
  3592. var tempDiaginfo service.DiaginfoStructTwo
  3593. tempDiaginfo.DiagCode = item.CountryCode
  3594. tempDiaginfo.DiagName = item.CountryContentName
  3595. tempDiaginfo.DiagType = "2"
  3596. tempDiaginfo.MaindiagFlag = "0"
  3597. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3598. }
  3599. }
  3600. struct4101.Diseinfo = tempDiaginfos
  3601. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3602. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3603. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3604. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3605. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3606. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3607. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3608. var iteminfo service.IteminfoStruct
  3609. var bedCostTotal float64 = 0 //床位总费
  3610. var bedCostSelfTotal float64 = 0 //床位自费
  3611. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3612. var operationCostTotal float64 = 0 //手术费
  3613. var operationCostSelfTotal float64 = 0 //手术费
  3614. var operationCostPartSelfTotal float64 = 0 //手术费
  3615. var otherCostTotal float64 = 0 //其他费用
  3616. var otherCostSelfTotal float64 = 0 //其他费用
  3617. var otherCostPartSelfTotal float64 = 0 //其他费用
  3618. var materialCostTotal float64 = 0 //材料费
  3619. var materialCostSelfTotal float64 = 0 //材料费
  3620. var materialCostPartSelfTotal float64 = 0 //材料费
  3621. var westernMedicineCostTotal float64 = 0 //西药费
  3622. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3623. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3624. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3625. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3626. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3627. var checkCostTotal float64 = 0 //检查费
  3628. var checkCostSelfTotal float64 = 0 //检查费
  3629. var checkCostPartSelfTotal float64 = 0 //检查费
  3630. var laboratoryCostTotal float64 = 0 //化验费
  3631. var laboratoryCostSelfTotal float64 = 0 //化验费
  3632. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3633. var treatCostTotal float64 = 0 //治疗费用
  3634. var treatCostSelfTotal float64 = 0 //治疗费用
  3635. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3636. decimal.DivisionPrecision = 2
  3637. var bed_fulamt_ownpay_amt float64 = 0
  3638. var operation_fulamt_ownpay_amt float64 = 0
  3639. var other_fulamt_ownpay_amt float64 = 0
  3640. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3641. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3642. var check_fulamt_ownpay_amt float64 = 0
  3643. var material_fulamt_ownpay_amt float64 = 0
  3644. var laboratory_fulamt_ownpay_amt float64 = 0
  3645. var treat_fulamt_ownpay_amt float64 = 0
  3646. var bed_claa_sunmfee float64 = 0
  3647. var bed_clab_amt float64 = 0
  3648. var bed_other_amt float64 = 0
  3649. var operation_claa_sunmfee float64 = 0
  3650. var operation_clab_amt float64 = 0
  3651. var operation_other_amt float64 = 0
  3652. var other_claa_sunmfee float64 = 0
  3653. var other_clab_amt float64 = 0
  3654. var other_other_amt float64 = 0
  3655. var westernMedicine_claa_sunmfee float64 = 0
  3656. var westernMedicine_clab_amt float64 = 0
  3657. var westernMedicine_other_amt float64 = 0
  3658. var chineseTraditional_claa_sunmfee float64 = 0
  3659. var chineseTraditional_clab_amt float64 = 0
  3660. var chineseTraditional_other_amt float64 = 0
  3661. var check_claa_sunmfee float64 = 0
  3662. var check_clab_amt float64 = 0
  3663. var check_other_amt float64 = 0
  3664. var material_claa_sunmfee float64 = 0
  3665. var material_clab_amt float64 = 0
  3666. var material_other_amt float64 = 0
  3667. var laboratory_claa_sunmfee float64 = 0
  3668. var laboratory_clab_amt float64 = 0
  3669. var laboratory_other_amt float64 = 0
  3670. var treat_claa_sunmfee float64 = 0
  3671. var treat_clab_amt float64 = 0
  3672. var treat_other_amt float64 = 0
  3673. for _, item := range order.HisOrderInfo {
  3674. if item.MedChrgitmType == "01" { //床位费
  3675. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3676. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3677. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3678. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3679. if item.ChrgitmLv == "1" {
  3680. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3681. }
  3682. if item.ChrgitmLv == "2" {
  3683. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3684. }
  3685. if item.ChrgitmLv == "3" {
  3686. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3687. }
  3688. }
  3689. if item.MedChrgitmType == "03" { //检查费
  3690. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3691. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3692. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3693. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3694. if item.ChrgitmLv == "1" {
  3695. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3696. }
  3697. if item.ChrgitmLv == "2" {
  3698. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3699. }
  3700. if item.ChrgitmLv == "3" {
  3701. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3702. }
  3703. }
  3704. if item.MedChrgitmType == "04" { //化验费
  3705. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3706. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3707. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3708. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3709. if item.ChrgitmLv == "1" {
  3710. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3711. }
  3712. if item.ChrgitmLv == "2" {
  3713. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3714. }
  3715. if item.ChrgitmLv == "3" {
  3716. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3717. }
  3718. }
  3719. if item.MedChrgitmType == "05" { //治疗费
  3720. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3721. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3722. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3723. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3724. if item.ChrgitmLv == "1" {
  3725. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3726. }
  3727. if item.ChrgitmLv == "2" {
  3728. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3729. }
  3730. if item.ChrgitmLv == "3" {
  3731. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3732. }
  3733. }
  3734. if item.MedChrgitmType == "06" { //手术费
  3735. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3736. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3737. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3738. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3739. if item.ChrgitmLv == "1" {
  3740. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3741. }
  3742. if item.ChrgitmLv == "2" {
  3743. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3744. }
  3745. if item.ChrgitmLv == "3" {
  3746. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3747. }
  3748. }
  3749. if item.MedChrgitmType == "08" { //材料费
  3750. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3751. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3752. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3753. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3754. if item.ChrgitmLv == "1" {
  3755. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3756. }
  3757. if item.ChrgitmLv == "2" {
  3758. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3759. }
  3760. if item.ChrgitmLv == "3" {
  3761. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3762. }
  3763. }
  3764. if item.MedChrgitmType == "09" { //西药费
  3765. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3766. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3767. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3768. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3769. if item.ChrgitmLv == "1" {
  3770. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3771. }
  3772. if item.ChrgitmLv == "2" {
  3773. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3774. }
  3775. if item.ChrgitmLv == "3" {
  3776. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3777. }
  3778. }
  3779. if item.MedChrgitmType == "11" { //中成费
  3780. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3781. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3782. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3783. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3784. if item.ChrgitmLv == "1" {
  3785. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3786. }
  3787. if item.ChrgitmLv == "2" {
  3788. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3789. }
  3790. if item.ChrgitmLv == "3" {
  3791. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3792. }
  3793. }
  3794. if item.MedChrgitmType == "14" { //其他费
  3795. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3796. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3797. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3798. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3799. if item.ChrgitmLv == "1" {
  3800. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3801. }
  3802. if item.ChrgitmLv == "2" {
  3803. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3804. }
  3805. if item.ChrgitmLv == "3" {
  3806. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3807. }
  3808. }
  3809. }
  3810. var iteminfoStructs []service.IteminfoStruct
  3811. if bedCostTotal != 0 {
  3812. iteminfo.MedChrgitm = "01"
  3813. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3814. iteminfo.Amt = bedCostTotal
  3815. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3816. iteminfo.ClabAmt = bed_clab_amt
  3817. iteminfo.OthAmt = bed_other_amt
  3818. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3819. }
  3820. if checkCostTotal != 0 {
  3821. iteminfo.MedChrgitm = "03"
  3822. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3823. iteminfo.Amt = checkCostTotal
  3824. iteminfo.ClaaSumfee = check_claa_sunmfee
  3825. iteminfo.ClabAmt = check_clab_amt
  3826. iteminfo.OthAmt = check_other_amt
  3827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3828. }
  3829. if laboratoryCostTotal != 0 {
  3830. iteminfo.MedChrgitm = "04"
  3831. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3832. iteminfo.Amt = laboratoryCostTotal
  3833. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3834. iteminfo.ClabAmt = laboratory_clab_amt
  3835. iteminfo.OthAmt = laboratory_other_amt
  3836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3837. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3838. }
  3839. if treatCostTotal != 0 {
  3840. iteminfo.MedChrgitm = "05"
  3841. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3842. iteminfo.Amt = treatCostTotal
  3843. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3844. iteminfo.ClabAmt = treat_clab_amt
  3845. iteminfo.OthAmt = treat_other_amt
  3846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3847. //(struct4101.IteminfoStruct, iteminfo)
  3848. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3849. }
  3850. if operationCostTotal != 0 {
  3851. iteminfo.MedChrgitm = "06"
  3852. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3853. iteminfo.Amt = operationCostTotal
  3854. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3855. iteminfo.ClabAmt = operation_clab_amt
  3856. iteminfo.OthAmt = operation_other_amt
  3857. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3858. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3859. }
  3860. if materialCostTotal != 0 {
  3861. iteminfo.MedChrgitm = "08"
  3862. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3863. iteminfo.Amt = materialCostTotal
  3864. iteminfo.ClaaSumfee = material_claa_sunmfee
  3865. iteminfo.ClabAmt = material_clab_amt
  3866. iteminfo.OthAmt = material_other_amt
  3867. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3868. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3869. }
  3870. if westernMedicineCostTotal != 0 {
  3871. iteminfo.MedChrgitm = "09"
  3872. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3873. iteminfo.Amt = westernMedicineCostTotal
  3874. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3875. iteminfo.ClabAmt = westernMedicine_clab_amt
  3876. iteminfo.OthAmt = westernMedicine_other_amt
  3877. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3878. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3879. }
  3880. if chineseTraditionalMedicineCostTotal != 0 {
  3881. iteminfo.MedChrgitm = "11"
  3882. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3883. iteminfo.Amt = westernMedicineCostTotal
  3884. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3885. iteminfo.ClabAmt = westernMedicine_clab_amt
  3886. iteminfo.OthAmt = westernMedicine_other_amt
  3887. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3888. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3889. }
  3890. if otherCostTotal != 0 {
  3891. iteminfo.MedChrgitm = "14"
  3892. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3893. iteminfo.Amt = otherCostTotal
  3894. iteminfo.ClaaSumfee = other_claa_sunmfee
  3895. iteminfo.ClabAmt = other_clab_amt
  3896. iteminfo.OthAmt = other_other_amt
  3897. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3898. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3899. }
  3900. struct4101.IteminfoStruct = iteminfoStructs
  3901. struct4101.Ntly = "中国"
  3902. struct4101.AdmCaty = "A03.06"
  3903. var res ResultSeventeen
  3904. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3905. struct4101.BillCode = order.Number
  3906. struct4101.BillNo = order.SetlId
  3907. var resOther ResultSeventeenOther
  3908. var pp models.PublicParams
  3909. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3910. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3911. pp.FixmedinsName = miConfig.OrgName
  3912. pp.FixmedinsCode = miConfig.Code
  3913. pp.RequestUrl = miConfig.Url
  3914. pp.Cainfo = miConfig.Cainfo
  3915. pp.SecretKey = miConfig.SecretKey
  3916. pp.AccessKey = miConfig.AccessKey
  3917. pp.OpterName = curRoles.UserName
  3918. client := &http.Client{}
  3919. var req *http.Request
  3920. data := make(map[string]interface{})
  3921. data["struct4101"] = struct4101
  3922. data["pp"] = pp
  3923. bytesData, _ := json.Marshal(data)
  3924. if miConfig.MdtrtareaAdmvs == "320921" {
  3925. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3926. } else {
  3927. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3928. }
  3929. resp, _ := client.Do(req)
  3930. defer resp.Body.Close()
  3931. body, ioErr := ioutil.ReadAll(resp.Body)
  3932. if ioErr != nil {
  3933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. return
  3936. }
  3937. var respJSON map[string]interface{}
  3938. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. return
  3942. }
  3943. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3944. userJSONBytes, _ := json.Marshal(respJSON)
  3945. fmt.Println("log")
  3946. fmt.Println(string(userJSONBytes))
  3947. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3948. utils.ErrorLog("解析失败:%v", err)
  3949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3950. return
  3951. }
  3952. res.InfRefmsgid = resOther.InfRefmsgid
  3953. res.Output = resOther.Output
  3954. res.ErrMsg = resOther.ErrMsg
  3955. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3956. res.Infcode = infocode
  3957. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3958. var pp models.PublicParams
  3959. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3961. pp.FixmedinsName = miConfig.OrgName
  3962. pp.FixmedinsCode = miConfig.Code
  3963. pp.RequestUrl = miConfig.Url
  3964. pp.Cainfo = miConfig.Cainfo
  3965. pp.SecretKey = miConfig.SecretKey
  3966. pp.AccessKey = miConfig.AccessKey
  3967. pp.OpterName = curRoles.UserName
  3968. result, _ := service.Jxyb4101(struct4101, pp)
  3969. var dat map[string]interface{}
  3970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3971. fmt.Println(dat)
  3972. } else {
  3973. fmt.Println(err)
  3974. }
  3975. userJSONBytes, _ := json.Marshal(dat)
  3976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3977. utils.ErrorLog("解析失败:%v", err)
  3978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3979. return
  3980. }
  3981. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3982. var pp models.PublicParams
  3983. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3984. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3985. pp.FixmedinsName = miConfig.OrgName
  3986. pp.FixmedinsCode = miConfig.Code
  3987. pp.RequestUrl = miConfig.Url
  3988. pp.Cainfo = miConfig.Cainfo
  3989. pp.SecretKey = miConfig.SecretKey
  3990. pp.AccessKey = miConfig.AccessKey
  3991. pp.OpterName = curRoles.UserName
  3992. result, _ := service.Hnyb4101(struct4101, pp)
  3993. var dat map[string]interface{}
  3994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3995. fmt.Println(dat)
  3996. } else {
  3997. fmt.Println(err)
  3998. }
  3999. userJSONBytes, _ := json.Marshal(dat)
  4000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4001. utils.ErrorLog("解析失败:%v", err)
  4002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. return
  4004. }
  4005. } else {
  4006. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4007. var dat map[string]interface{}
  4008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4009. fmt.Println(dat)
  4010. } else {
  4011. fmt.Println(err)
  4012. }
  4013. userJSONBytes, _ := json.Marshal(dat)
  4014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4015. utils.ErrorLog("解析失败:%v", err)
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. return
  4018. }
  4019. }
  4020. if res.Infcode != 0 {
  4021. c.ServeSuccessJSON(map[string]interface{}{
  4022. "failed_code": -10,
  4023. "msg": res.ErrMsg,
  4024. })
  4025. return
  4026. } else {
  4027. order.FaPiaoNumber = zero
  4028. order.FaPiaoCode = last_order.FaPiaoCode
  4029. service.UpdateOrder(order)
  4030. hisFundSettleListResult := &models.HisFundSettleListResult{
  4031. Number: res.Output.SetlListId,
  4032. Status: 1,
  4033. Ctime: time.Now().Unix(),
  4034. Mtime: time.Now().Unix(),
  4035. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4036. IsUpload: 1,
  4037. OrderId: order_id,
  4038. }
  4039. service.CreateUploadRecord(hisFundSettleListResult)
  4040. c.ServeSuccessJSON(map[string]interface{}{
  4041. "msg": "上传成功",
  4042. "result": hisFundSettleListResult,
  4043. })
  4044. return
  4045. }
  4046. }
  4047. func (c *HisApiController) GetSettleListHospital() {
  4048. order_id, _ := c.GetInt64("order_id")
  4049. admin_user_id, _ := c.GetInt64("admin_user_id")
  4050. order, _ := service.GetHisOrderByIDTwo(order_id)
  4051. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4052. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4053. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4054. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4055. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4057. if order.ID == 0 {
  4058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4059. return
  4060. }
  4061. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4062. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4063. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4064. fmt.Println(count)
  4065. var zero string
  4066. number := count + 1
  4067. if number >= 1000 {
  4068. zero = "0000" + strconv.FormatInt(number, 10)
  4069. } else if number >= 10000 {
  4070. zero = "000" + strconv.FormatInt(number, 10)
  4071. } else if number >= 100000 {
  4072. zero = "00" + strconv.FormatInt(number, 10)
  4073. } else if number >= 1000000 {
  4074. zero = "0" + strconv.FormatInt(number, 10)
  4075. } else {
  4076. zero = strconv.FormatInt(number, 10)
  4077. }
  4078. fmt.Println(zero)
  4079. struct4101 := service.Struct4101{
  4080. PsnNo: order.PsnNo,
  4081. MdtrtId: order.MdtrtId,
  4082. SetlId: order.SetlId,
  4083. PsnName: order.PsnName,
  4084. Gend: order.Gend,
  4085. Brdy: his.Brdy,
  4086. Age: int64(order.Age),
  4087. Naty: order.Naty,
  4088. PatnCertType: "01",
  4089. Certno: order.Certno,
  4090. Prfs: "90",
  4091. ConerName: roles[0].UserName,
  4092. PatnRlts: "99",
  4093. ConerAddr: miConfig.OrgName,
  4094. ConerTel: admin.Mobile,
  4095. HiType: order.Insutype,
  4096. Insuplc: miConfig.InsuplcAdmdvs,
  4097. MaindiagFlag: "1",
  4098. BillCode: order.SetlId,
  4099. BillNo: order.SetlId,
  4100. BizSn: order.Number,
  4101. PsnSelfPay: order.PsnPartAmt,
  4102. PsnOwnPay: order.PsnPartAmt,
  4103. AcctPay: order.AcctPay,
  4104. PsnCashpay: order.PsnCashPay,
  4105. HiPaymtd: "1",
  4106. Hsorg: miConfig.InsuplcAdmdvs,
  4107. HsorgOpter: miConfig.InsuplcAdmdvs,
  4108. MedinsFillPsn: curRoles.UserName,
  4109. MedinsFillDept: depart.Name,
  4110. IptMedType: "2",
  4111. AdmTime: his.InHosptialTime,
  4112. AdmEndTime: his.OutHosptialTime,
  4113. }
  4114. struct4101.SetlBegnDate = order.SetlTime
  4115. struct4101.SetlEndDate = order.SetlTime
  4116. var rf []CustomFundPay
  4117. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4118. var tempFunPays []service.CustomStruct
  4119. for _, item := range rf {
  4120. var tempFunPay service.CustomStruct
  4121. tempFunPay.FundPayamt = item.FundPayamt
  4122. tempFunPay.FundPayType = item.FundPayType
  4123. tempFunPays = append(tempFunPays, tempFunPay)
  4124. }
  4125. struct4101.CustomStruct = tempFunPays
  4126. var tempDiaginfos []service.DiaginfoStructTwo
  4127. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4128. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4129. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4130. var config []*models.HisXtDiagnoseConfig
  4131. for _, item := range diagnosis_ids {
  4132. id, _ := strconv.ParseInt(item, 10, 64)
  4133. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4134. config = append(config, &diagnosisConfig)
  4135. }
  4136. for index, item := range config {
  4137. if index == 0 {
  4138. var tempDiaginfo service.DiaginfoStructTwo
  4139. tempDiaginfo.DiagCode = item.CountryCode
  4140. tempDiaginfo.DiagName = item.CountryContentName
  4141. tempDiaginfo.DiagType = "1"
  4142. tempDiaginfo.MaindiagFlag = "1"
  4143. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4144. } else {
  4145. var tempDiaginfo service.DiaginfoStructTwo
  4146. tempDiaginfo.DiagCode = item.CountryCode
  4147. tempDiaginfo.DiagName = item.CountryContentName
  4148. tempDiaginfo.DiagType = "2"
  4149. tempDiaginfo.MaindiagFlag = "0"
  4150. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4151. }
  4152. }
  4153. struct4101.Diseinfo = tempDiaginfos
  4154. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4155. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4156. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4157. tempOpspdiseinfo2.OprnOprtCode = ""
  4158. tempOpspdiseinfo2.OprnOprtName = ""
  4159. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4160. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4161. var iteminfo service.IteminfoStruct
  4162. var bedCostTotal float64 = 0 //床位总费
  4163. var bedCostSelfTotal float64 = 0 //床位自费
  4164. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4165. var operationCostTotal float64 = 0 //手术费
  4166. var operationCostSelfTotal float64 = 0 //手术费
  4167. var operationCostPartSelfTotal float64 = 0 //手术费
  4168. var otherCostTotal float64 = 0 //其他费用
  4169. var otherCostSelfTotal float64 = 0 //其他费用
  4170. var otherCostPartSelfTotal float64 = 0 //其他费用
  4171. var materialCostTotal float64 = 0 //材料费
  4172. var materialCostSelfTotal float64 = 0 //材料费
  4173. var materialCostPartSelfTotal float64 = 0 //材料费
  4174. var westernMedicineCostTotal float64 = 0 //西药费
  4175. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4176. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4177. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4178. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4179. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4180. var checkCostTotal float64 = 0 //检查费
  4181. var checkCostSelfTotal float64 = 0 //检查费
  4182. var checkCostPartSelfTotal float64 = 0 //检查费
  4183. var laboratoryCostTotal float64 = 0 //化验费
  4184. var laboratoryCostSelfTotal float64 = 0 //化验费
  4185. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4186. var treatCostTotal float64 = 0 //治疗费用
  4187. var treatCostSelfTotal float64 = 0 //治疗费用
  4188. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4189. decimal.DivisionPrecision = 2
  4190. var bed_fulamt_ownpay_amt float64 = 0
  4191. var operation_fulamt_ownpay_amt float64 = 0
  4192. var other_fulamt_ownpay_amt float64 = 0
  4193. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4194. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4195. var check_fulamt_ownpay_amt float64 = 0
  4196. var material_fulamt_ownpay_amt float64 = 0
  4197. var laboratory_fulamt_ownpay_amt float64 = 0
  4198. var treat_fulamt_ownpay_amt float64 = 0
  4199. var bed_claa_sunmfee float64 = 0
  4200. var bed_clab_amt float64 = 0
  4201. var bed_other_amt float64 = 0
  4202. var operation_claa_sunmfee float64 = 0
  4203. var operation_clab_amt float64 = 0
  4204. var operation_other_amt float64 = 0
  4205. var other_claa_sunmfee float64 = 0
  4206. var other_clab_amt float64 = 0
  4207. var other_other_amt float64 = 0
  4208. var westernMedicine_claa_sunmfee float64 = 0
  4209. var westernMedicine_clab_amt float64 = 0
  4210. var westernMedicine_other_amt float64 = 0
  4211. var chineseTraditional_claa_sunmfee float64 = 0
  4212. var chineseTraditional_clab_amt float64 = 0
  4213. var chineseTraditional_other_amt float64 = 0
  4214. var check_claa_sunmfee float64 = 0
  4215. var check_clab_amt float64 = 0
  4216. var check_other_amt float64 = 0
  4217. var material_claa_sunmfee float64 = 0
  4218. var material_clab_amt float64 = 0
  4219. var material_other_amt float64 = 0
  4220. var laboratory_claa_sunmfee float64 = 0
  4221. var laboratory_clab_amt float64 = 0
  4222. var laboratory_other_amt float64 = 0
  4223. var treat_claa_sunmfee float64 = 0
  4224. var treat_clab_amt float64 = 0
  4225. var treat_other_amt float64 = 0
  4226. for _, item := range order.HisOrderInfo {
  4227. if item.MedChrgitmType == "01" { //床位费
  4228. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4229. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4230. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4231. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4232. if item.ChrgitmLv == "1" {
  4233. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4234. }
  4235. if item.ChrgitmLv == "2" {
  4236. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4237. }
  4238. if item.ChrgitmLv == "3" {
  4239. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4240. }
  4241. }
  4242. if item.MedChrgitmType == "03" { //检查费
  4243. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4244. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4245. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4246. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4247. if item.ChrgitmLv == "1" {
  4248. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4249. }
  4250. if item.ChrgitmLv == "2" {
  4251. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4252. }
  4253. if item.ChrgitmLv == "3" {
  4254. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4255. }
  4256. }
  4257. if item.MedChrgitmType == "04" { //化验费
  4258. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4259. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4260. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4261. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4262. if item.ChrgitmLv == "1" {
  4263. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4264. }
  4265. if item.ChrgitmLv == "2" {
  4266. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4267. }
  4268. if item.ChrgitmLv == "3" {
  4269. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4270. }
  4271. }
  4272. if item.MedChrgitmType == "05" { //治疗费
  4273. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4274. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4275. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4276. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4277. if item.ChrgitmLv == "1" {
  4278. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4279. }
  4280. if item.ChrgitmLv == "2" {
  4281. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4282. }
  4283. if item.ChrgitmLv == "3" {
  4284. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4285. }
  4286. }
  4287. if item.MedChrgitmType == "06" { //手术费
  4288. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4289. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4290. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4291. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4292. if item.ChrgitmLv == "1" {
  4293. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4294. }
  4295. if item.ChrgitmLv == "2" {
  4296. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4297. }
  4298. if item.ChrgitmLv == "3" {
  4299. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4300. }
  4301. }
  4302. if item.MedChrgitmType == "08" { //材料费
  4303. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4304. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4305. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4306. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4307. if item.ChrgitmLv == "1" {
  4308. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4309. }
  4310. if item.ChrgitmLv == "2" {
  4311. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4312. }
  4313. if item.ChrgitmLv == "3" {
  4314. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4315. }
  4316. }
  4317. if item.MedChrgitmType == "09" { //西药费
  4318. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4319. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4320. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4321. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4322. if item.ChrgitmLv == "1" {
  4323. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4324. }
  4325. if item.ChrgitmLv == "2" {
  4326. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4327. }
  4328. if item.ChrgitmLv == "3" {
  4329. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4330. }
  4331. }
  4332. if item.MedChrgitmType == "11" { //中成费
  4333. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4334. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4335. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4336. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4337. if item.ChrgitmLv == "1" {
  4338. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4339. }
  4340. if item.ChrgitmLv == "2" {
  4341. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4342. }
  4343. if item.ChrgitmLv == "3" {
  4344. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4345. }
  4346. }
  4347. if item.MedChrgitmType == "14" { //其他费
  4348. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4349. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4350. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4351. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4352. if item.ChrgitmLv == "1" {
  4353. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4354. }
  4355. if item.ChrgitmLv == "2" {
  4356. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4357. }
  4358. if item.ChrgitmLv == "3" {
  4359. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4360. }
  4361. }
  4362. }
  4363. var iteminfoStructs []service.IteminfoStruct
  4364. if bedCostTotal != 0 {
  4365. iteminfo.MedChrgitm = "01"
  4366. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4367. iteminfo.Amt = bedCostTotal
  4368. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4369. iteminfo.ClabAmt = bed_clab_amt
  4370. iteminfo.OthAmt = bed_other_amt
  4371. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4372. }
  4373. if checkCostTotal != 0 {
  4374. iteminfo.MedChrgitm = "03"
  4375. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4376. iteminfo.Amt = checkCostTotal
  4377. iteminfo.ClaaSumfee = check_claa_sunmfee
  4378. iteminfo.ClabAmt = check_clab_amt
  4379. iteminfo.OthAmt = check_other_amt
  4380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4381. }
  4382. if laboratoryCostTotal != 0 {
  4383. iteminfo.MedChrgitm = "04"
  4384. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4385. iteminfo.Amt = laboratoryCostTotal
  4386. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4387. iteminfo.ClabAmt = laboratory_clab_amt
  4388. iteminfo.OthAmt = laboratory_other_amt
  4389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4390. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4391. }
  4392. if treatCostTotal != 0 {
  4393. iteminfo.MedChrgitm = "05"
  4394. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4395. iteminfo.Amt = treatCostTotal
  4396. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4397. iteminfo.ClabAmt = treat_clab_amt
  4398. iteminfo.OthAmt = treat_other_amt
  4399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4400. //(struct4101.IteminfoStruct, iteminfo)
  4401. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4402. }
  4403. if operationCostTotal != 0 {
  4404. iteminfo.MedChrgitm = "06"
  4405. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4406. iteminfo.Amt = operationCostTotal
  4407. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4408. iteminfo.ClabAmt = operation_clab_amt
  4409. iteminfo.OthAmt = operation_other_amt
  4410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4412. }
  4413. if materialCostTotal != 0 {
  4414. iteminfo.MedChrgitm = "08"
  4415. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4416. iteminfo.Amt = materialCostTotal
  4417. iteminfo.ClaaSumfee = material_claa_sunmfee
  4418. iteminfo.ClabAmt = material_clab_amt
  4419. iteminfo.OthAmt = material_other_amt
  4420. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4422. }
  4423. if westernMedicineCostTotal != 0 {
  4424. iteminfo.MedChrgitm = "09"
  4425. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4426. iteminfo.Amt = westernMedicineCostTotal
  4427. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4428. iteminfo.ClabAmt = westernMedicine_clab_amt
  4429. iteminfo.OthAmt = westernMedicine_other_amt
  4430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4432. }
  4433. if chineseTraditionalMedicineCostTotal != 0 {
  4434. iteminfo.MedChrgitm = "11"
  4435. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4436. iteminfo.Amt = westernMedicineCostTotal
  4437. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4438. iteminfo.ClabAmt = westernMedicine_clab_amt
  4439. iteminfo.OthAmt = westernMedicine_other_amt
  4440. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4441. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4442. }
  4443. if otherCostTotal != 0 {
  4444. iteminfo.MedChrgitm = "14"
  4445. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4446. iteminfo.Amt = otherCostTotal
  4447. iteminfo.ClaaSumfee = other_claa_sunmfee
  4448. iteminfo.ClabAmt = other_clab_amt
  4449. iteminfo.OthAmt = other_other_amt
  4450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4452. }
  4453. struct4101.IteminfoStruct = iteminfoStructs
  4454. struct4101.Ntly = "中国"
  4455. struct4101.AdmCaty = "A03.06"
  4456. var resOther ResultSeventeenOther
  4457. var res ResultSeventeen
  4458. if miConfig.MdtrtareaAdmvs == "150499" {
  4459. var pp models.PublicParams
  4460. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4461. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4462. pp.FixmedinsName = miConfig.OrgName
  4463. pp.FixmedinsCode = miConfig.Code
  4464. pp.RequestUrl = miConfig.Url
  4465. pp.Cainfo = miConfig.Cainfo
  4466. pp.SecretKey = miConfig.SecretKey
  4467. pp.AccessKey = miConfig.AccessKey
  4468. pp.OpterName = curRoles.UserName
  4469. client := &http.Client{}
  4470. var req *http.Request
  4471. data := make(map[string]interface{})
  4472. data["struct4101"] = struct4101
  4473. data["pp"] = pp
  4474. bytesData, _ := json.Marshal(data)
  4475. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4476. resp, _ := client.Do(req)
  4477. defer resp.Body.Close()
  4478. body, ioErr := ioutil.ReadAll(resp.Body)
  4479. if ioErr != nil {
  4480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. var respJSON map[string]interface{}
  4485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4491. userJSONBytes, _ := json.Marshal(respJSON)
  4492. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4493. utils.ErrorLog("解析失败:%v", err)
  4494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4495. return
  4496. }
  4497. res.InfRefmsgid = resOther.InfRefmsgid
  4498. res.Output = resOther.Output
  4499. res.ErrMsg = resOther.ErrMsg
  4500. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4501. res.Infcode = infocode
  4502. } else {
  4503. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4504. var dat map[string]interface{}
  4505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4506. fmt.Println(dat)
  4507. } else {
  4508. fmt.Println(err)
  4509. }
  4510. userJSONBytes, _ := json.Marshal(dat)
  4511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. }
  4517. if res.Infcode != 0 {
  4518. c.ServeSuccessJSON(map[string]interface{}{
  4519. "failed_code": -10,
  4520. "msg": res.ErrMsg,
  4521. })
  4522. return
  4523. } else {
  4524. if miConfig.MdtrtareaAdmvs != "150499" {
  4525. order.FaPiaoNumber = zero
  4526. order.FaPiaoCode = last_order.FaPiaoCode
  4527. service.UpdateOrder(order)
  4528. }
  4529. hisFundSettleListResult := &models.HisFundSettleListResult{
  4530. Number: res.Output.SetlListId,
  4531. Status: 1,
  4532. Ctime: time.Now().Unix(),
  4533. Mtime: time.Now().Unix(),
  4534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4535. IsUpload: 1,
  4536. OrderId: order_id,
  4537. }
  4538. service.CreateUploadRecord(hisFundSettleListResult)
  4539. c.ServeSuccessJSON(map[string]interface{}{
  4540. "msg": "上传成功",
  4541. "result": hisFundSettleListResult,
  4542. })
  4543. return
  4544. }
  4545. }
  4546. func (c *HisApiController) GetBatchSettleList() {
  4547. orders, _ := service.GetAllHisOrder(10138)
  4548. for _, item := range orders {
  4549. order_id := item.ID
  4550. order, _ := service.GetHisOrderByIDTwo(order_id)
  4551. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4552. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4553. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4554. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  4555. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4556. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4557. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4558. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4559. if order.ID == 0 {
  4560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4561. return
  4562. }
  4563. if his.BalanceAccountsType == 2 {
  4564. continue
  4565. }
  4566. struct4101 := service.Struct4101{
  4567. PsnNo: order.PsnNo,
  4568. MdtrtId: order.MdtrtId,
  4569. SetlId: order.SetlId,
  4570. PsnName: order.PsnName,
  4571. Gend: order.Gend,
  4572. Brdy: his.Brdy,
  4573. Age: his.Age,
  4574. Naty: order.Naty,
  4575. PatnCertType: "01",
  4576. Certno: order.Certno,
  4577. Prfs: "90",
  4578. ConerName: roles[0].UserName,
  4579. PatnRlts: "99",
  4580. ConerAddr: miConfig.OrgName,
  4581. ConerTel: admin.Mobile,
  4582. HiType: order.Insutype,
  4583. Insuplc: his.InsuplcAdmdvs,
  4584. MaindiagFlag: "1",
  4585. BillCode: order.SetlId,
  4586. BillNo: order.SetlId,
  4587. BizSn: order.Number,
  4588. PsnSelfPay: order.PsnPartAmt,
  4589. PsnOwnPay: order.PsnPartAmt,
  4590. AcctPay: order.AcctPay,
  4591. PsnCashpay: order.PsnCashPay,
  4592. HiPaymtd: "1",
  4593. Hsorg: his.InsuplcAdmdvs,
  4594. HsorgOpter: his.InsuplcAdmdvs,
  4595. MedinsFillPsn: curRoles.UserName,
  4596. MedinsFillDept: depart.Name,
  4597. IptMedType: "2",
  4598. }
  4599. struct4101.SetlBegnDate = order.SetlTime
  4600. struct4101.SetlEndDate = order.SetlTime
  4601. //if order.SettleType == 1 {
  4602. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4603. // dateStr := t.Format("2006-01-02")
  4604. // struct4101.SetlBegnDate = dateStr
  4605. // struct4101.SetlEndDate = dateStr
  4606. //} else {
  4607. // t := time.Unix(int64(order.SettleStartTime), 0)
  4608. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4609. // dateStartStr := t.Format("2006-01-02")
  4610. // dateEndStr := t2.Format("2006-01-02")
  4611. // struct4101.SetlBegnDate = dateStartStr
  4612. // struct4101.SetlEndDate = dateEndStr
  4613. //}
  4614. var rf []CustomFundPay
  4615. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4616. var tempFunPays []service.CustomStruct
  4617. var tempFunPay610100 service.CustomStruct
  4618. for _, item := range rf {
  4619. if item.FundPayType == "610100" {
  4620. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4621. tempFunPay610100.FundPayType = item.FundPayType
  4622. } else {
  4623. var tempFunPay service.CustomStruct
  4624. tempFunPay.FundPayamt = item.FundPayamt
  4625. tempFunPay.FundPayType = item.FundPayType
  4626. tempFunPays = append(tempFunPays, tempFunPay)
  4627. }
  4628. }
  4629. tempFunPays = append(tempFunPays, tempFunPay610100)
  4630. struct4101.CustomStruct = tempFunPays
  4631. var tempDiaginfos []service.DiaginfoStructTwo
  4632. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4633. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4634. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4635. var config []*models.HisXtDiagnoseConfig
  4636. for _, item := range diagnosis_ids {
  4637. id, _ := strconv.ParseInt(item, 10, 64)
  4638. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4639. config = append(config, &diagnosisConfig)
  4640. }
  4641. for index, item := range config {
  4642. if index == 0 {
  4643. var tempDiaginfo service.DiaginfoStructTwo
  4644. tempDiaginfo.DiagCode = item.CountryCode
  4645. tempDiaginfo.DiagName = item.CountryContentName
  4646. tempDiaginfo.DiagType = "1"
  4647. tempDiaginfo.MaindiagFlag = "1"
  4648. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4649. } else {
  4650. var tempDiaginfo service.DiaginfoStructTwo
  4651. tempDiaginfo.DiagCode = item.CountryCode
  4652. tempDiaginfo.DiagName = item.CountryContentName
  4653. tempDiaginfo.DiagType = "2"
  4654. tempDiaginfo.MaindiagFlag = "0"
  4655. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4656. }
  4657. }
  4658. struct4101.Diseinfo = tempDiaginfos
  4659. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4660. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4661. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4662. tempOpspdiseinfo2.OprnOprtCode = ""
  4663. tempOpspdiseinfo2.OprnOprtName = ""
  4664. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4665. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4666. var iteminfo service.IteminfoStruct
  4667. var bedCostTotal float64 = 0 //床位总费
  4668. var bedCostSelfTotal float64 = 0 //床位自费
  4669. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4670. var examineCostTotal float64 = 0 //诊查总费
  4671. var examineCostSelfTotal float64 = 0 //诊查自费
  4672. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4673. var nursingCostTotal float64 = 0 //护理总费
  4674. var nursingCostSelfTotal float64 = 0 //护理自费
  4675. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4676. var chineseMedicineCostTotal float64 = 0 //中成药
  4677. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4678. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4679. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4680. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4681. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4682. var registerCostTotal float64 = 0 //一般诊疗费
  4683. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4684. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4685. var operationCostTotal float64 = 0 //手术费
  4686. var operationCostSelfTotal float64 = 0 //手术费
  4687. var operationCostPartSelfTotal float64 = 0 //手术费
  4688. var otherCostTotal float64 = 0 //其他费用
  4689. var otherCostSelfTotal float64 = 0 //其他费用
  4690. var otherCostPartSelfTotal float64 = 0 //其他费用
  4691. var materialCostTotal float64 = 0 //材料费
  4692. var materialCostSelfTotal float64 = 0 //材料费
  4693. var materialCostPartSelfTotal float64 = 0 //材料费
  4694. var westernMedicineCostTotal float64 = 0 //西药费
  4695. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4696. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4697. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4698. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4699. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4700. var checkCostTotal float64 = 0 //检查费
  4701. var checkCostSelfTotal float64 = 0 //检查费
  4702. var checkCostPartSelfTotal float64 = 0 //检查费
  4703. var laboratoryCostTotal float64 = 0 //化验费
  4704. var laboratoryCostSelfTotal float64 = 0 //化验费
  4705. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4706. var treatCostTotal float64 = 0 //治疗费用
  4707. var treatCostSelfTotal float64 = 0 //治疗费用
  4708. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4709. decimal.DivisionPrecision = 2
  4710. var bed_fulamt_ownpay_amt float64 = 0
  4711. var examine_fulamt_ownpay_amt float64 = 0
  4712. var nursing_fulamt_ownpay_amt float64 = 0
  4713. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4714. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4715. var register_fulamt_ownpay_amt float64 = 0
  4716. var operation_fulamt_ownpay_amt float64 = 0
  4717. var other_fulamt_ownpay_amt float64 = 0
  4718. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4719. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4720. var check_fulamt_ownpay_amt float64 = 0
  4721. var material_fulamt_ownpay_amt float64 = 0
  4722. var laboratory_fulamt_ownpay_amt float64 = 0
  4723. var treat_fulamt_ownpay_amt float64 = 0
  4724. var bed_claa_sunmfee float64 = 0
  4725. var bed_clab_amt float64 = 0
  4726. var bed_other_amt float64 = 0
  4727. var examine_claa_sunmfee float64 = 0
  4728. var examine_clab_amt float64 = 0
  4729. var examine_other_amt float64 = 0
  4730. var nursing_claa_sunmfee float64 = 0
  4731. var nursing_clab_amt float64 = 0
  4732. var nursing_other_amt float64 = 0
  4733. var chinese_medicine_claa_sunmfee float64 = 0
  4734. var chinese_medicine_clab_amt float64 = 0
  4735. var chinese_medicine_other_amt float64 = 0
  4736. var commonly_treatment_claa_sunmfee float64 = 0
  4737. var commonly_treatment_clab_amt float64 = 0
  4738. var commonly_treatment_other_amt float64 = 0
  4739. var operation_claa_sunmfee float64 = 0
  4740. var operation_clab_amt float64 = 0
  4741. var operation_other_amt float64 = 0
  4742. var other_claa_sunmfee float64 = 0
  4743. var other_clab_amt float64 = 0
  4744. var other_other_amt float64 = 0
  4745. var westernMedicine_claa_sunmfee float64 = 0
  4746. var westernMedicine_clab_amt float64 = 0
  4747. var westernMedicine_other_amt float64 = 0
  4748. var chineseTraditional_claa_sunmfee float64 = 0
  4749. var chineseTraditional_clab_amt float64 = 0
  4750. var chineseTraditional_other_amt float64 = 0
  4751. var check_claa_sunmfee float64 = 0
  4752. var check_clab_amt float64 = 0
  4753. var check_other_amt float64 = 0
  4754. var material_claa_sunmfee float64 = 0
  4755. var material_clab_amt float64 = 0
  4756. var material_other_amt float64 = 0
  4757. var laboratory_claa_sunmfee float64 = 0
  4758. var laboratory_clab_amt float64 = 0
  4759. var laboratory_other_amt float64 = 0
  4760. var treat_claa_sunmfee float64 = 0
  4761. var treat_clab_amt float64 = 0
  4762. var treat_other_amt float64 = 0
  4763. var register_claa_sunmfee float64 = 0
  4764. var register_clab_amt float64 = 0
  4765. var register_other_amt float64 = 0
  4766. for _, item := range order.HisOrderInfo {
  4767. if item.MedChrgitmType == "01" { //床位费
  4768. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4769. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4770. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4771. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4772. if item.ChrgitmLv == "1" {
  4773. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4774. }
  4775. if item.ChrgitmLv == "2" {
  4776. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4777. }
  4778. if item.ChrgitmLv == "3" {
  4779. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4780. }
  4781. }
  4782. if item.MedChrgitmType == "02" { //诊查
  4783. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4784. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4785. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4786. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4787. if item.ChrgitmLv == "1" {
  4788. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4789. }
  4790. if item.ChrgitmLv == "2" {
  4791. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4792. }
  4793. if item.ChrgitmLv == "3" {
  4794. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4795. }
  4796. }
  4797. if item.MedChrgitmType == "03" { //检查费
  4798. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4799. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4800. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4801. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4802. if item.ChrgitmLv == "1" {
  4803. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4804. }
  4805. if item.ChrgitmLv == "2" {
  4806. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4807. }
  4808. if item.ChrgitmLv == "3" {
  4809. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4810. }
  4811. }
  4812. if item.MedChrgitmType == "04" { //化验费
  4813. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4814. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4815. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4816. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4817. if item.ChrgitmLv == "1" {
  4818. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4819. }
  4820. if item.ChrgitmLv == "2" {
  4821. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4822. }
  4823. if item.ChrgitmLv == "3" {
  4824. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4825. }
  4826. }
  4827. if item.MedChrgitmType == "05" { //治疗费
  4828. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4829. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4830. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4831. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4832. if item.ChrgitmLv == "1" {
  4833. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4834. }
  4835. if item.ChrgitmLv == "2" {
  4836. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4837. }
  4838. if item.ChrgitmLv == "3" {
  4839. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4840. }
  4841. }
  4842. if item.MedChrgitmType == "06" { //手术费
  4843. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4844. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4845. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4846. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4847. if item.ChrgitmLv == "1" {
  4848. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4849. }
  4850. if item.ChrgitmLv == "2" {
  4851. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4852. }
  4853. if item.ChrgitmLv == "3" {
  4854. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4855. }
  4856. }
  4857. if item.MedChrgitmType == "07" { //手术费
  4858. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4859. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4860. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4861. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4862. if item.ChrgitmLv == "1" {
  4863. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4864. }
  4865. if item.ChrgitmLv == "2" {
  4866. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4867. }
  4868. if item.ChrgitmLv == "3" {
  4869. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4870. }
  4871. }
  4872. if item.MedChrgitmType == "08" { //材料费
  4873. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4874. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4875. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4876. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4877. if item.ChrgitmLv == "1" {
  4878. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4879. }
  4880. if item.ChrgitmLv == "2" {
  4881. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4882. }
  4883. if item.ChrgitmLv == "3" {
  4884. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4885. }
  4886. }
  4887. if item.MedChrgitmType == "09" { //西药费
  4888. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4889. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4890. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4891. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4892. if item.ChrgitmLv == "1" {
  4893. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4894. }
  4895. if item.ChrgitmLv == "2" {
  4896. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4897. }
  4898. if item.ChrgitmLv == "3" {
  4899. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4900. }
  4901. }
  4902. if item.MedChrgitmType == "10" { //中药饮片
  4903. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4904. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4905. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4906. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4907. if item.ChrgitmLv == "1" {
  4908. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4909. }
  4910. if item.ChrgitmLv == "2" {
  4911. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4912. }
  4913. if item.ChrgitmLv == "3" {
  4914. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4915. }
  4916. }
  4917. if item.MedChrgitmType == "11" { //中成费
  4918. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4919. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4920. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4921. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4922. if item.ChrgitmLv == "1" {
  4923. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4924. }
  4925. if item.ChrgitmLv == "2" {
  4926. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4927. }
  4928. if item.ChrgitmLv == "3" {
  4929. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4930. }
  4931. }
  4932. if item.MedChrgitmType == "12" { //中成费
  4933. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4934. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4935. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4936. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4937. if item.ChrgitmLv == "1" {
  4938. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4939. }
  4940. if item.ChrgitmLv == "2" {
  4941. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4942. }
  4943. if item.ChrgitmLv == "3" {
  4944. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4945. }
  4946. }
  4947. if item.MedChrgitmType == "13" { //中成费
  4948. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4949. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4950. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4951. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4952. if item.ChrgitmLv == "1" {
  4953. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4954. }
  4955. if item.ChrgitmLv == "2" {
  4956. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4957. }
  4958. if item.ChrgitmLv == "3" {
  4959. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4960. }
  4961. }
  4962. if item.MedChrgitmType == "14" { //其他费
  4963. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4964. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4965. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4966. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4967. if item.ChrgitmLv == "1" {
  4968. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4969. }
  4970. if item.ChrgitmLv == "2" {
  4971. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4972. }
  4973. if item.ChrgitmLv == "3" {
  4974. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4975. }
  4976. }
  4977. }
  4978. var iteminfoStructs []service.IteminfoStruct
  4979. if bedCostTotal != 0 {
  4980. iteminfo.MedChrgitm = "01"
  4981. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4982. iteminfo.Amt = bedCostTotal
  4983. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4984. iteminfo.ClabAmt = bed_clab_amt
  4985. iteminfo.OthAmt = bed_other_amt
  4986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4987. }
  4988. if examineCostTotal != 0 {
  4989. iteminfo.MedChrgitm = "02"
  4990. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  4991. iteminfo.Amt = examineCostTotal
  4992. iteminfo.ClaaSumfee = examine_claa_sunmfee
  4993. iteminfo.ClabAmt = examine_clab_amt
  4994. iteminfo.OthAmt = examine_other_amt
  4995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4997. }
  4998. if checkCostTotal != 0 {
  4999. iteminfo.MedChrgitm = "03"
  5000. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5001. iteminfo.Amt = checkCostTotal
  5002. iteminfo.ClaaSumfee = check_claa_sunmfee
  5003. iteminfo.ClabAmt = check_clab_amt
  5004. iteminfo.OthAmt = check_other_amt
  5005. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5006. }
  5007. if laboratoryCostTotal != 0 {
  5008. iteminfo.MedChrgitm = "04"
  5009. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5010. iteminfo.Amt = laboratoryCostTotal
  5011. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5012. iteminfo.ClabAmt = laboratory_clab_amt
  5013. iteminfo.OthAmt = laboratory_other_amt
  5014. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5016. }
  5017. if treatCostTotal != 0 {
  5018. iteminfo.MedChrgitm = "05"
  5019. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5020. iteminfo.Amt = treatCostTotal
  5021. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5022. iteminfo.ClabAmt = treat_clab_amt
  5023. iteminfo.OthAmt = treat_other_amt
  5024. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5025. //(struct4101.IteminfoStruct, iteminfo)
  5026. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5027. }
  5028. if operationCostTotal != 0 {
  5029. iteminfo.MedChrgitm = "06"
  5030. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5031. iteminfo.Amt = operationCostTotal
  5032. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5033. iteminfo.ClabAmt = operation_clab_amt
  5034. iteminfo.OthAmt = operation_other_amt
  5035. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5037. }
  5038. if nursingCostTotal != 0 {
  5039. iteminfo.MedChrgitm = "07"
  5040. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5041. iteminfo.Amt = nursingCostTotal
  5042. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5043. iteminfo.ClabAmt = nursing_clab_amt
  5044. iteminfo.OthAmt = nursing_other_amt
  5045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5046. }
  5047. if materialCostTotal != 0 {
  5048. iteminfo.MedChrgitm = "08"
  5049. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5050. iteminfo.Amt = materialCostTotal
  5051. iteminfo.ClaaSumfee = material_claa_sunmfee
  5052. iteminfo.ClabAmt = material_clab_amt
  5053. iteminfo.OthAmt = material_other_amt
  5054. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5055. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5056. }
  5057. if westernMedicineCostTotal != 0 {
  5058. iteminfo.MedChrgitm = "09"
  5059. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5060. iteminfo.Amt = westernMedicineCostTotal
  5061. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5062. iteminfo.ClabAmt = westernMedicine_clab_amt
  5063. iteminfo.OthAmt = westernMedicine_other_amt
  5064. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5065. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5066. }
  5067. if chineseMedicineCostTotal != 0 {
  5068. iteminfo.MedChrgitm = "10"
  5069. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5070. iteminfo.Amt = chineseMedicineCostTotal
  5071. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5072. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5073. iteminfo.OthAmt = chinese_medicine_other_amt
  5074. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5075. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5076. }
  5077. if chineseTraditionalMedicineCostTotal != 0 {
  5078. iteminfo.MedChrgitm = "11"
  5079. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5080. iteminfo.Amt = westernMedicineCostTotal
  5081. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5082. iteminfo.ClabAmt = westernMedicine_clab_amt
  5083. iteminfo.OthAmt = westernMedicine_other_amt
  5084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5085. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5086. }
  5087. if commonlyTreatmentCostTotal != 0 {
  5088. iteminfo.MedChrgitm = "12"
  5089. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5090. iteminfo.Amt = commonlyTreatmentCostTotal
  5091. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5092. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5093. iteminfo.OthAmt = commonly_treatment_other_amt
  5094. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5095. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5096. }
  5097. if registerCostTotal != 0 {
  5098. iteminfo.MedChrgitm = "13"
  5099. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5100. iteminfo.Amt = registerCostTotal
  5101. iteminfo.ClaaSumfee = register_claa_sunmfee
  5102. iteminfo.ClabAmt = register_clab_amt
  5103. iteminfo.OthAmt = register_other_amt
  5104. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5106. }
  5107. if otherCostTotal != 0 {
  5108. iteminfo.MedChrgitm = "14"
  5109. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5110. iteminfo.Amt = otherCostTotal
  5111. iteminfo.ClaaSumfee = other_claa_sunmfee
  5112. iteminfo.ClabAmt = other_clab_amt
  5113. iteminfo.OthAmt = other_other_amt
  5114. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5115. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5116. }
  5117. struct4101.IteminfoStruct = iteminfoStructs
  5118. time_arr := strings.Split(order.SetlTime, " ")
  5119. struct4101.AdmTime = time_arr[0]
  5120. struct4101.AdmEndTime = time_arr[0]
  5121. struct4101.DoctorName = doctor.UserName
  5122. struct4101.DoctorCode = doctor.DoctorNumber
  5123. struct4101.Ntly = "中国"
  5124. struct4101.AdmCaty = "A03.06"
  5125. var res ResultSeventeen
  5126. if miConfig.MdtrtareaAdmvs == "421300" {
  5127. data := make(map[string]interface{})
  5128. data["struct4101"] = struct4101
  5129. data["secret_key"] = miConfig.SecretKey
  5130. data["org_name"] = miConfig.OrgName
  5131. data["opera"] = curRoles.UserName
  5132. data["code"] = miConfig.Code
  5133. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5134. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5135. client := &http.Client{}
  5136. bytesData, _ := json.Marshal(data)
  5137. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5138. resp, _ := client.Do(req)
  5139. defer resp.Body.Close()
  5140. body, ioErr := ioutil.ReadAll(resp.Body)
  5141. if ioErr != nil {
  5142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5144. return
  5145. }
  5146. var respJSON map[string]interface{}
  5147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5150. return
  5151. }
  5152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5153. userJSONBytes, _ := json.Marshal(respJSON)
  5154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5155. utils.ErrorLog("解析失败:%v", err)
  5156. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5157. adminUser := c.GetAdminUserInfo()
  5158. errlog := &models.HisOrderError{
  5159. UserOrgId: adminUser.CurrentOrgId,
  5160. Ctime: time.Now().Unix(),
  5161. Mtime: time.Now().Unix(),
  5162. ErrMsg: res.ErrMsg + "解析失败",
  5163. Status: 1,
  5164. PatientId: order_id,
  5165. Stage: 10088,
  5166. }
  5167. service.CreateErrMsgLog(errlog)
  5168. continue
  5169. }
  5170. } else {
  5171. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5172. fmt.Println(result)
  5173. var dat map[string]interface{}
  5174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5175. fmt.Println(dat)
  5176. } else {
  5177. fmt.Println(err)
  5178. }
  5179. userJSONBytes, _ := json.Marshal(dat)
  5180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5181. utils.ErrorLog("解析失败:%v", err)
  5182. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5183. adminUser := c.GetAdminUserInfo()
  5184. errlog := &models.HisOrderError{
  5185. UserOrgId: adminUser.CurrentOrgId,
  5186. Ctime: time.Now().Unix(),
  5187. Mtime: time.Now().Unix(),
  5188. ErrMsg: res.ErrMsg + "解析失败",
  5189. Status: 1,
  5190. PatientId: order_id,
  5191. Stage: 10106,
  5192. }
  5193. service.CreateErrMsgLog(errlog)
  5194. continue
  5195. }
  5196. }
  5197. if res.Infcode != 0 {
  5198. adminUser := c.GetAdminUserInfo()
  5199. errlog := &models.HisOrderError{
  5200. UserOrgId: adminUser.CurrentOrgId,
  5201. Ctime: time.Now().Unix(),
  5202. Mtime: time.Now().Unix(),
  5203. ErrMsg: res.ErrMsg,
  5204. Status: 1,
  5205. PatientId: order_id,
  5206. Stage: 10106,
  5207. }
  5208. service.CreateErrMsgLog(errlog)
  5209. continue
  5210. } else {
  5211. hisFundSettleListResult := &models.HisFundSettleListResult{
  5212. Number: res.Output.SetlListId,
  5213. Status: 1,
  5214. Ctime: time.Now().Unix(),
  5215. Mtime: time.Now().Unix(),
  5216. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5217. IsUpload: 1,
  5218. OrderId: order_id,
  5219. }
  5220. service.CreateUploadRecord(hisFundSettleListResult)
  5221. continue
  5222. }
  5223. }
  5224. }
  5225. func (c *HisApiController) GetOrgInfo() {
  5226. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5227. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5228. }
  5229. func (c *HisApiController) GetHisPatientInfo() {
  5230. medical_insurance_card := c.GetString("medical_insurance_card")
  5231. id_card_type, _ := c.GetInt64("id_card_type")
  5232. id_card := c.GetString("id_card")
  5233. adminInfo := c.GetAdminUserInfo()
  5234. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5235. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5236. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5237. IdCardNo := ""
  5238. if id_card_type == 1 {
  5239. IdCardNo = medical_insurance_card
  5240. } else if id_card_type == 2 {
  5241. IdCardNo = id_card
  5242. }
  5243. if config.IsOpen == 1 {
  5244. 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
  5245. resp, requestErr := http.Get(api)
  5246. if requestErr != nil {
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. defer resp.Body.Close()
  5251. body, ioErr := ioutil.ReadAll(resp.Body)
  5252. if ioErr != nil {
  5253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. var respJSON map[string]interface{}
  5258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5264. userJSONBytes, _ := json.Marshal(userJSON)
  5265. var res ResultTwo
  5266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5267. utils.ErrorLog("解析失败:%v", err)
  5268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5269. return
  5270. }
  5271. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5272. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5273. infoStr := string(Iinfos)
  5274. idetinfoStr := string(Idetinfos)
  5275. if res.Infcode == 0 {
  5276. his := models.VMHisPatient{
  5277. Status: 1,
  5278. Ctime: time.Now().Unix(),
  5279. Mtime: time.Now().Unix(),
  5280. PsnNo: res.Output.Baseinfo.PsnNo,
  5281. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5282. Certno: res.Output.Baseinfo.Certno,
  5283. PsnName: res.Output.Baseinfo.PsnName,
  5284. Gend: res.Output.Baseinfo.Gend,
  5285. Naty: res.Output.Baseinfo.Naty,
  5286. Brdy: res.Output.Baseinfo.Brdy,
  5287. Age: res.Output.Baseinfo.Age,
  5288. Iinfo: infoStr,
  5289. Idetinfo: idetinfoStr,
  5290. UserOrgId: adminInfo.CurrentOrgId,
  5291. IsReturn: 1,
  5292. IdCardType: id_card_type,
  5293. }
  5294. c.ServeSuccessJSON(map[string]interface{}{
  5295. "info": his,
  5296. })
  5297. } else {
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5299. return
  5300. }
  5301. }
  5302. }
  5303. //func GetBasBaseInfo() (jsonStr string, err error) {
  5304. //
  5305. // handle := syscall.NewLazyDLL("SSCard.dll")
  5306. // add := handle.NewProc("ReadCardBas")
  5307. // str := make([]byte, 1024)
  5308. // str1 := make([]byte, 1024)
  5309. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5310. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5311. //
  5312. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5313. //
  5314. // fmt.Println("> Add(4,5)的结果为:", ret)
  5315. // handle.Release()
  5316. //
  5317. // return "", nil
  5318. //
  5319. //}
  5320. //func GetQRBaseInfo() (jsonStr string, err error) {
  5321. // handle := syscall.LoadDLL("SSCard.dll")
  5322. // ReadCardBas := handle.FindProc("GetQRBase")
  5323. //
  5324. // str := make([]byte, 256)
  5325. // str1 := make([]byte, 256)
  5326. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5327. //
  5328. // fmt.Println(string(str))
  5329. // fmt.Println(r)
  5330. // return string(str), nil
  5331. //}
  5332. //func CardInit() int {
  5333. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5334. // add := DllTestDef.MustFindProc("Init")
  5335. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5336. // if err != nil {
  5337. // fmt.Println("SSCard的运算结果为:", ret)
  5338. // }
  5339. // result := int(ret)
  5340. // return result
  5341. //}
  5342. //func CardInit() int {
  5343. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5344. // if err != nil {
  5345. // fmt.Println("SSCard的运算结果为:", ret)
  5346. // }
  5347. // fmt.Println(err)
  5348. // result := int(ret)
  5349. // return result
  5350. //}
  5351. func IntPtr(n int) uintptr {
  5352. return uintptr(n)
  5353. }
  5354. func StrPtr(s string) uintptr {
  5355. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5356. }
  5357. type Result2001 struct {
  5358. Cainfo interface{} `json:"cainfo"`
  5359. ErrMsg string `json:"err_msg"`
  5360. InfRefmsgid string `json:"inf_refmsgid"`
  5361. Infcode int64 `json:"infcode"`
  5362. Output struct {
  5363. Trtinfo struct {
  5364. PsnNo string `json:"psn_no"`
  5365. TrtChkType string `json:"trt_chk_type"`
  5366. FundPayType string `json:"fund_pay_type"`
  5367. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5368. Begndate string `json:"begndate"`
  5369. Enddate string `json:"enddate"`
  5370. TrtChkRslt string `json:"trt_chk_rslt"`
  5371. } `json:"trtinfo"`
  5372. } `json:"output"`
  5373. RefmsgTime string `json:"refmsg_time"`
  5374. RespondTime string `json:"respond_time"`
  5375. Signtype interface{} `json:"signtype"`
  5376. WarnMsg interface{} `json:"warn_msg"`
  5377. }
  5378. type Result2001Org10265 struct {
  5379. Cainfo interface{} `json:"cainfo"`
  5380. ErrMsg string `json:"err_msg"`
  5381. InfRefmsgid string `json:"inf_refmsgid"`
  5382. Infcode string `json:"infcode"`
  5383. Output struct {
  5384. Trtinfo struct {
  5385. PsnNo string `json:"psn_no"`
  5386. TrtChkType string `json:"trt_chk_type"`
  5387. FundPayType string `json:"fund_pay_type"`
  5388. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5389. Begndate string `json:"begndate"`
  5390. Enddate string `json:"enddate"`
  5391. TrtChkRslt string `json:"trt_chk_rslt"`
  5392. } `json:"trtinfo"`
  5393. } `json:"output"`
  5394. RefmsgTime string `json:"refmsg_time"`
  5395. RespondTime string `json:"respond_time"`
  5396. Signtype interface{} `json:"signtype"`
  5397. WarnMsg interface{} `json:"warn_msg"`
  5398. }
  5399. type ResultTwo struct {
  5400. ErrMsg string `json:"err_msg"`
  5401. InfRefmsgid string `json:"inf_refmsgid"`
  5402. Infcode int64 `json:"infcode"`
  5403. Output struct {
  5404. Baseinfo struct {
  5405. Age float64 `json:"age"`
  5406. Brdy string `json:"brdy"`
  5407. Certno string `json:"certno"`
  5408. Gend string `json:"gend"`
  5409. Naty string `json:"naty"`
  5410. PsnCertType string `json:"psn_cert_type"`
  5411. PsnName string `json:"psn_name"`
  5412. PsnNo string `json:"psn_no"`
  5413. } `json:"baseinfo"`
  5414. Idetinfo []interface{} `json:"idetinfo"`
  5415. Iinfo []struct {
  5416. Balc float64 `json:"balc"`
  5417. CvlservFlag string `json:"cvlserv_flag"`
  5418. EmpName string `json:"emp_name"`
  5419. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5420. Insutype string `json:"insutype"`
  5421. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5422. PausInsuDate string `json:"paus_insu_date"`
  5423. PsnInsuDate string `json:"psn_insu_date"`
  5424. PsnInsuStas string `json:"psn_insu_stas"`
  5425. PsnType string `json:"psn_type"`
  5426. } `json:"insuinfo"`
  5427. } `json:"output"`
  5428. RefmsgTime string `json:"refmsg_time"`
  5429. RespondTime string `json:"respond_time"`
  5430. Signtype interface{} `json:"signtype"`
  5431. WarnInfo interface{} `json:"warn_info"`
  5432. }
  5433. type ResultTwo10265 struct {
  5434. ErrMsg string `json:"err_msg"`
  5435. InfRefmsgid string `json:"inf_refmsgid"`
  5436. Infcode string `json:"infcode"`
  5437. Output struct {
  5438. Baseinfo struct {
  5439. Age float64 `json:"age"`
  5440. Brdy string `json:"brdy"`
  5441. Certno string `json:"certno"`
  5442. Gend string `json:"gend"`
  5443. Naty string `json:"naty"`
  5444. PsnCertType string `json:"psn_cert_type"`
  5445. PsnName string `json:"psn_name"`
  5446. PsnNo string `json:"psn_no"`
  5447. } `json:"baseinfo"`
  5448. Idetinfo []interface{} `json:"idetinfo"`
  5449. Iinfo []struct {
  5450. Balc float64 `json:"balc"`
  5451. CvlservFlag string `json:"cvlserv_flag"`
  5452. EmpName string `json:"emp_name"`
  5453. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5454. Insutype string `json:"insutype"`
  5455. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5456. PausInsuDate string `json:"paus_insu_date"`
  5457. PsnInsuDate string `json:"psn_insu_date"`
  5458. PsnInsuStas string `json:"psn_insu_stas"`
  5459. PsnType string `json:"psn_type"`
  5460. } `json:"insuinfo"`
  5461. } `json:"output"`
  5462. RefmsgTime string `json:"refmsg_time"`
  5463. RespondTime string `json:"respond_time"`
  5464. Signtype interface{} `json:"signtype"`
  5465. WarnInfo interface{} `json:"warn_info"`
  5466. }
  5467. type ResultThree struct {
  5468. Cainfo interface{} `json:"cainfo"`
  5469. ErrMsg string `json:"err_msg"`
  5470. InfRefmsgid string `json:"inf_refmsgid"`
  5471. Infcode int64 `json:"infcode"`
  5472. Output struct {
  5473. Data struct {
  5474. IptOtpNo string `json:"ipt_otp_no"`
  5475. MdtrtID string `json:"mdtrt_id"`
  5476. PsnNo string `json:"psn_no"`
  5477. } `json:"data"`
  5478. } `json:"output"`
  5479. RefmsgTime string `json:"refmsg_time"`
  5480. RespondTime string `json:"respond_time"`
  5481. Signtype interface{} `json:"signtype"`
  5482. WarnMsg interface{} `json:"warn_msg"`
  5483. }
  5484. type ResultThree10265 struct {
  5485. Cainfo interface{} `json:"cainfo"`
  5486. ErrMsg string `json:"err_msg"`
  5487. InfRefmsgid string `json:"inf_refmsgid"`
  5488. Infcode string `json:"infcode"`
  5489. Output struct {
  5490. Data struct {
  5491. IptOtpNo string `json:"ipt_otp_no"`
  5492. MdtrtID string `json:"mdtrt_id"`
  5493. PsnNo string `json:"psn_no"`
  5494. } `json:"data"`
  5495. } `json:"output"`
  5496. RefmsgTime string `json:"refmsg_time"`
  5497. RespondTime string `json:"respond_time"`
  5498. Signtype interface{} `json:"signtype"`
  5499. WarnMsg interface{} `json:"warn_msg"`
  5500. }
  5501. type ResultFour struct {
  5502. Cainfo string `json:"cainfo"`
  5503. ErrMsg string `json:"err_msg"`
  5504. InfRefmsgid string `json:"inf_refmsgid"`
  5505. Infcode int64 `json:"infcode"`
  5506. Output struct {
  5507. Result []struct {
  5508. BasMednFlag string `json:"bas_medn_flag"`
  5509. ChldMedcFlag string `json:"chld_medc_flag"`
  5510. ChrgitmLv string `json:"chrgitm_lv"`
  5511. Cnt float64 `json:"cnt"`
  5512. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5513. DrtReimFlag string `json:"drt_reim_flag"`
  5514. FeedetlSn string `json:"feedetl_sn"`
  5515. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5516. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5517. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5518. ListSpItemFlag string `json:"list_sp_item_flag"`
  5519. LmtUsedFlag string `json:"lmt_used_flag"`
  5520. MedChrgitmType string `json:"med_chrgitm_type"`
  5521. Memo string `json:"memo"`
  5522. OverlmtAmt float64 `json:"overlmt_amt"`
  5523. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5524. Pric float64 `json:"pric"`
  5525. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5526. SelfpayProp float64 `json:"selfpay_prop"`
  5527. } `json:"result"`
  5528. } `json:"output"`
  5529. RefmsgTime string `json:"refmsg_time"`
  5530. RespondTime string `json:"respond_time"`
  5531. Signtype string `json:"signtype"`
  5532. WarnMsg string `json:"warn_msg"`
  5533. }
  5534. type ResultFour10265 struct {
  5535. Cainfo string `json:"cainfo"`
  5536. ErrMsg string `json:"err_msg"`
  5537. InfRefmsgid string `json:"inf_refmsgid"`
  5538. Infcode string `json:"infcode"`
  5539. Output struct {
  5540. Result []struct {
  5541. BasMednFlag string `json:"bas_medn_flag"`
  5542. ChldMedcFlag string `json:"chld_medc_flag"`
  5543. ChrgitmLv string `json:"chrgitm_lv"`
  5544. Cnt float64 `json:"cnt"`
  5545. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5546. DrtReimFlag string `json:"drt_reim_flag"`
  5547. FeedetlSn string `json:"feedetl_sn"`
  5548. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5549. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5550. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5551. ListSpItemFlag string `json:"list_sp_item_flag"`
  5552. LmtUsedFlag string `json:"lmt_used_flag"`
  5553. MedChrgitmType string `json:"med_chrgitm_type"`
  5554. Memo string `json:"memo"`
  5555. OverlmtAmt float64 `json:"overlmt_amt"`
  5556. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5557. Pric float64 `json:"pric"`
  5558. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5559. SelfpayProp float64 `json:"selfpay_prop"`
  5560. } `json:"result"`
  5561. } `json:"output"`
  5562. RefmsgTime string `json:"refmsg_time"`
  5563. RespondTime string `json:"respond_time"`
  5564. Signtype string `json:"signtype"`
  5565. WarnMsg string `json:"warn_msg"`
  5566. }
  5567. type ResultFive struct {
  5568. Balc float64 `json:"balc"`
  5569. CvlservFlag string `json:"cvlserv_flag"`
  5570. EmpName string `json:"emp_name"`
  5571. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5572. Insutype string `json:"insutype"`
  5573. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5574. PausInsuDate string `json:"paus_insu_date"`
  5575. PsnInsuDate string `json:"psn_insu_date"`
  5576. PsnInsuStas string `json:"psn_insu_stas"`
  5577. PsnType string `json:"psn_type"`
  5578. }
  5579. type ResultSix struct {
  5580. Cainfo interface{} `json:"cainfo"`
  5581. ErrMsg string `json:"err_msg"`
  5582. InfRefmsgid string `json:"inf_refmsgid"`
  5583. Infcode int64 `json:"infcode"`
  5584. Output struct {
  5585. } `json:"output"`
  5586. RefmsgTime string `json:"refmsg_time"`
  5587. RespondTime string `json:"respond_time"`
  5588. Signtype interface{} `json:"signtype"`
  5589. WarnMsg interface{} `json:"warn_msg"`
  5590. }
  5591. type ResultSix10265 struct {
  5592. Cainfo interface{} `json:"cainfo"`
  5593. ErrMsg string `json:"err_msg"`
  5594. InfRefmsgid string `json:"inf_refmsgid"`
  5595. Infcode string `json:"infcode"`
  5596. Output struct {
  5597. } `json:"output"`
  5598. RefmsgTime string `json:"refmsg_time"`
  5599. RespondTime string `json:"respond_time"`
  5600. Signtype interface{} `json:"signtype"`
  5601. WarnMsg interface{} `json:"warn_msg"`
  5602. }
  5603. type ResultSeven struct {
  5604. Cainfo string `json:"cainfo"`
  5605. ErrMsg string `json:"err_msg"`
  5606. InfRefmsgid string `json:"inf_refmsgid"`
  5607. Infcode int64 `json:"infcode"`
  5608. Output struct {
  5609. Setldetail []interface{} `json:"setldetail"`
  5610. Setlinfo struct {
  5611. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5612. AcctPay float64 `json:"acct_pay"`
  5613. ActPayDedc float64 `json:"act_pay_dedc"`
  5614. Age float64 `json:"age"`
  5615. Balc float64 `json:"balc"`
  5616. Brdy string `json:"brdy"`
  5617. Certno string `json:"certno"`
  5618. ClrOptins string `json:"clr_optins"`
  5619. ClrType string `json:"clr_type"`
  5620. ClrWay string `json:"clr_way"`
  5621. CvlservFlag string `json:"cvlserv_flag"`
  5622. CvlservPay float64 `json:"cvlserv_pay"`
  5623. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5624. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5625. Gend string `json:"gend"`
  5626. HifesPay float64 `json:"hifes_pay"`
  5627. HifmiPay float64 `json:"hifmi_pay"`
  5628. HifpPay float64 `json:"hifp_pay"`
  5629. HospPartAmt float64 `json:"hosp_part_amt"`
  5630. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5631. Insutype string `json:"insutype"`
  5632. MafPay float64 `json:"maf_pay"`
  5633. MdtrtCertType string `json:"mdtrt_cert_type"`
  5634. HifobPay float64 `json:"hifob_pay"`
  5635. MdtrtID string `json:"mdtrt_id"`
  5636. MedType string `json:"med_type"`
  5637. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5638. MedinsSetlID string `json:"medins_setl_id"`
  5639. Naty string `json:"naty"`
  5640. OthPay float64 `json:"oth_pay"`
  5641. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5642. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5643. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5644. PsnCashPay float64 `json:"psn_cash_pay"`
  5645. PsnCertType string `json:"psn_cert_type"`
  5646. PsnName string `json:"psn_name"`
  5647. PsnNo string `json:"psn_no"`
  5648. PsnPartAmt float64 `json:"psn_part_amt"`
  5649. PsnType string `json:"psn_type"`
  5650. SetlID string `json:"setl_id"`
  5651. SetlTime string `json:"setl_time"`
  5652. } `json:"setlinfo"`
  5653. } `json:"output"`
  5654. RefmsgTime string `json:"refmsg_time"`
  5655. RespondTime string `json:"respond_time"`
  5656. Signtype interface{} `json:"signtype"`
  5657. WarnMsg interface{} `json:"warn_msg"`
  5658. }
  5659. type ResultSeven10265 struct {
  5660. Cainfo string `json:"cainfo"`
  5661. ErrMsg string `json:"err_msg"`
  5662. InfRefmsgid string `json:"inf_refmsgid"`
  5663. Infcode string `json:"infcode"`
  5664. Output struct {
  5665. Setldetail []interface{} `json:"setldetail"`
  5666. Setlinfo struct {
  5667. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5668. AcctPay float64 `json:"acct_pay"`
  5669. ActPayDedc float64 `json:"act_pay_dedc"`
  5670. Age float64 `json:"age"`
  5671. Balc float64 `json:"balc"`
  5672. Brdy string `json:"brdy"`
  5673. Certno string `json:"certno"`
  5674. ClrOptins string `json:"clr_optins"`
  5675. ClrType string `json:"clr_type"`
  5676. ClrWay string `json:"clr_way"`
  5677. CvlservFlag string `json:"cvlserv_flag"`
  5678. CvlservPay float64 `json:"cvlserv_pay"`
  5679. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5680. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5681. Gend string `json:"gend"`
  5682. HifesPay float64 `json:"hifes_pay"`
  5683. HifmiPay float64 `json:"hifmi_pay"`
  5684. HifpPay float64 `json:"hifp_pay"`
  5685. HospPartAmt float64 `json:"hosp_part_amt"`
  5686. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5687. Insutype string `json:"insutype"`
  5688. MafPay float64 `json:"maf_pay"`
  5689. MdtrtCertType string `json:"mdtrt_cert_type"`
  5690. HifobPay float64 `json:"hifob_pay"`
  5691. MdtrtID string `json:"mdtrt_id"`
  5692. MedType string `json:"med_type"`
  5693. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5694. MedinsSetlID string `json:"medins_setl_id"`
  5695. Naty string `json:"naty"`
  5696. OthPay float64 `json:"oth_pay"`
  5697. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5698. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5699. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5700. PsnCashPay float64 `json:"psn_cash_pay"`
  5701. PsnCertType string `json:"psn_cert_type"`
  5702. PsnName string `json:"psn_name"`
  5703. PsnNo string `json:"psn_no"`
  5704. PsnPartAmt float64 `json:"psn_part_amt"`
  5705. PsnType string `json:"psn_type"`
  5706. SetlID string `json:"setl_id"`
  5707. SetlTime string `json:"setl_time"`
  5708. } `json:"setlinfo"`
  5709. } `json:"output"`
  5710. RefmsgTime string `json:"refmsg_time"`
  5711. RespondTime string `json:"respond_time"`
  5712. Signtype interface{} `json:"signtype"`
  5713. WarnMsg interface{} `json:"warn_msg"`
  5714. }
  5715. type ResultEight struct {
  5716. Cainfo string `json:"cainfo"`
  5717. ErrMsg string `json:"err_msg"`
  5718. InfRefmsgid string `json:"inf_refmsgid"`
  5719. Infcode int64 `json:"infcode"`
  5720. Output struct {
  5721. Stmtinfo struct {
  5722. SetlOptins string `json:"setl_optins"`
  5723. StmtRslt string `json:"stmt_rslt"`
  5724. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5725. } `json:"stmtinfo"`
  5726. } `json:"output"`
  5727. RefmsgTime string `json:"refmsg_time"`
  5728. RespondTime string `json:"respond_time"`
  5729. Signtype interface{} `json:"signtype"`
  5730. WarnMsg interface{} `json:"warn_msg"`
  5731. }
  5732. type ResultEightFor10188 struct {
  5733. Cainfo string `json:"cainfo"`
  5734. ErrMsg string `json:"err_msg"`
  5735. InfRefmsgid string `json:"inf_refmsgid"`
  5736. Infcode string `json:"infcode"`
  5737. Output struct {
  5738. Stmtinfo struct {
  5739. SetlOptins string `json:"setl_optins"`
  5740. StmtRslt string `json:"stmt_rslt"`
  5741. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5742. } `json:"stmtinfo"`
  5743. } `json:"output"`
  5744. RefmsgTime string `json:"refmsg_time"`
  5745. RespondTime string `json:"respond_time"`
  5746. Signtype interface{} `json:"signtype"`
  5747. WarnMsg interface{} `json:"warn_msg"`
  5748. }
  5749. type ResultNine struct {
  5750. Cainfo string `json:"cainfo"`
  5751. ErrMsg string `json:"err_msg"`
  5752. InfRefmsgid string `json:"inf_refmsgid"`
  5753. Infcode int64 `json:"infcode"`
  5754. Output struct {
  5755. FileQuryNo string `json:"file_qury_no"`
  5756. } `json:"output"`
  5757. RefmsgTime string `json:"refmsg_time"`
  5758. RespondTime string `json:"respond_time"`
  5759. Signtype interface{} `json:"signtype"`
  5760. WarnMsg interface{} `json:"warn_msg"`
  5761. }
  5762. type ResultTen struct {
  5763. Cainfo string `json:"cainfo"`
  5764. ErrMsg string `json:"err_msg"`
  5765. InfRefmsgid string `json:"inf_refmsgid"`
  5766. Infcode int64 `json:"infcode"`
  5767. Output struct {
  5768. DldEndtime string `json:"dld_endtime"`
  5769. FileQuryNo string `json:"file_qury_no"`
  5770. Filename string `json:"filename"`
  5771. } `json:"output"`
  5772. RefmsgTime string `json:"refmsg_time"`
  5773. RespondTime string `json:"respond_time"`
  5774. Signtype interface{} `json:"signtype"`
  5775. WarnMsg interface{} `json:"warn_msg"`
  5776. }
  5777. //type Autogenerated struct {
  5778. // Output struct {
  5779. // Setlinfo struct {
  5780. // SetlTime string `json:"setl_time"`
  5781. // CvlservPay float64 `json:"cvlserv_pay"`
  5782. // Year string `json:"year"`
  5783. // MedType string `json:"med_type"`
  5784. // PsnPay float64 `json:"psn_pay"`
  5785. // OpterID string `json:"opter_id"`
  5786. // Begndate string `json:"begndate"`
  5787. // FlxempeFlag string `json:"flxempe_flag"`
  5788. // HifmiPay float64 `json:"hifmi_pay"`
  5789. // PsnNo string `json:"psn_no"`
  5790. // ActPayDedc float64 `json:"act_pay_dedc"`
  5791. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5792. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5793. // ClrWay string `json:"clr_way"`
  5794. // OthPay float64 `json:"oth_pay"`
  5795. // Gend string `json:"gend"`
  5796. // MdtrtID string `json:"mdtrt_id"`
  5797. // AcctPay float64 `json:"acct_pay"`
  5798. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5799. // Insutype string `json:"insutype"`
  5800. // Invono interface{} `json:"invono"`
  5801. // Enddate string `json:"enddate"`
  5802. // CashPayamt float64 `json:"cash_payamt"`
  5803. // PsnType string `json:"psn_type"`
  5804. // FixmedinsName string `json:"fixmedins_name"`
  5805. // HifpPay float64 `json:"hifp_pay"`
  5806. // NewFlag interface{} `json:"new_flag"`
  5807. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5808. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5809. // PayLoc string `json:"pay_loc"`
  5810. // ClrType string `json:"clr_type"`
  5811. // RefdSetlFlag string `json:"refd_setl_flag"`
  5812. // CvlservFlag string `json:"cvlserv_flag"`
  5813. // EmpName string `json:"emp_name"`
  5814. // Brdy string `json:"brdy"`
  5815. // Naty string `json:"naty"`
  5816. // Certno string `json:"certno"`
  5817. // DiseCode string `json:"dise_code"`
  5818. // FixmedinsCode string `json:"fixmedins_code"`
  5819. // DedcHospLv string `json:"dedc_hosp_lv"`
  5820. // OpterName string `json:"opter_name"`
  5821. // Balc float64 `json:"balc"`
  5822. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5823. // PsnCertType string `json:"psn_cert_type"`
  5824. // HifobPay float64 `json:"hifob_pay"`
  5825. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5826. // HifesPay float64 `json:"hifes_pay"`
  5827. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5828. // OptTime string `json:"opt_time"`
  5829. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5830. // SetlID string `json:"setl_id"`
  5831. // MafPay float64 `json:"maf_pay"`
  5832. // PsnName string `json:"psn_name"`
  5833. // InsuOptins interface{} `json:"insu_optins"`
  5834. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5835. // ClrOptins string `json:"clr_optins"`
  5836. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5837. // DiseName string `json:"dise_name"`
  5838. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5839. // Age float64 `json:"age"`
  5840. // DtrtCertType string `json:"dtrt_cert_type"`
  5841. // HospLv string `json:"hosp_lv"`
  5842. // } `json:"setlinfo"`
  5843. // Setldetail []struct {
  5844. // FundPayType string `json:"fund_pay_type"`
  5845. // FundPayamt float64 `json:"fund_payamt"`
  5846. // SetlProcInfo interface{} `json:"setl_proc_info"`
  5847. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  5848. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  5849. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  5850. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5851. // } `json:"setldetail"`
  5852. // } `json:"output"`
  5853. // Infcode int `json:"infcode"`
  5854. // WarnMsg interface{} `json:"warn_msg"`
  5855. // Cainfo interface{} `json:"cainfo"`
  5856. // ErrMsg interface{} `json:"err_msg"`
  5857. // RefmsgTime string `json:"refmsg_time"`
  5858. // Signtype interface{} `json:"signtype"`
  5859. // RespondTime string `json:"respond_time"`
  5860. // InfRefmsgid string `json:"inf_refmsgid"`
  5861. //}
  5862. type ResultEleven struct {
  5863. Cainfo string `json:"cainfo"`
  5864. ErrMsg string `json:"err_msg"`
  5865. InfRefmsgid string `json:"inf_refmsgid"`
  5866. Infcode int64 `json:"infcode"`
  5867. Output struct {
  5868. Setlinfo struct {
  5869. SetlTime string `json:"setl_time"`
  5870. CvlservPay float64 `json:"cvlserv_pay"`
  5871. Year string `json:"year"`
  5872. MedType string `json:"med_type"`
  5873. PsnPay float64 `json:"psn_pay"`
  5874. OpterID string `json:"opter_id"`
  5875. Begndate string `json:"begndate"`
  5876. FlxempeFlag string `json:"flxempe_flag"`
  5877. HifmiPay float64 `json:"hifmi_pay"`
  5878. PsnNo string `json:"psn_no"`
  5879. ActPayDedc float64 `json:"act_pay_dedc"`
  5880. MedinsSetlID interface{} `json:"medins_setl_id"`
  5881. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5882. ClrWay string `json:"clr_way"`
  5883. OthPay float64 `json:"oth_pay"`
  5884. Gend string `json:"gend"`
  5885. MdtrtID string `json:"mdtrt_id"`
  5886. AcctPay float64 `json:"acct_pay"`
  5887. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5888. Insutype string `json:"insutype"`
  5889. Invono interface{} `json:"invono"`
  5890. Enddate string `json:"enddate"`
  5891. CashPayamt float64 `json:"cash_payamt"`
  5892. PsnType string `json:"psn_type"`
  5893. FixmedinsName string `json:"fixmedins_name"`
  5894. HifpPay float64 `json:"hifp_pay"`
  5895. NewFlag interface{} `json:"new_flag"`
  5896. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5897. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5898. PayLoc string `json:"pay_loc"`
  5899. ClrType string `json:"clr_type"`
  5900. RefdSetlFlag string `json:"refd_setl_flag"`
  5901. CvlservFlag string `json:"cvlserv_flag"`
  5902. EmpName string `json:"emp_name"`
  5903. Brdy string `json:"brdy"`
  5904. Naty string `json:"naty"`
  5905. Certno string `json:"certno"`
  5906. DiseCode string `json:"dise_code"`
  5907. FixmedinsCode string `json:"fixmedins_code"`
  5908. DedcHospLv string `json:"dedc_hosp_lv"`
  5909. OpterName string `json:"opter_name"`
  5910. Balc float64 `json:"balc"`
  5911. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5912. PsnCertType string `json:"psn_cert_type"`
  5913. HifobPay float64 `json:"hifob_pay"`
  5914. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5915. HifesPay float64 `json:"hifes_pay"`
  5916. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5917. OptTime string `json:"opt_time"`
  5918. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5919. SetlID string `json:"setl_id"`
  5920. MafPay float64 `json:"maf_pay"`
  5921. PsnName string `json:"psn_name"`
  5922. InsuOptins interface{} `json:"insu_optins"`
  5923. PrefFundPay interface{} `json:"pref_fund_pay"`
  5924. ClrOptins string `json:"clr_optins"`
  5925. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5926. DiseName string `json:"dise_name"`
  5927. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5928. Age float64 `json:"age"`
  5929. DtrtCertType string `json:"dtrt_cert_type"`
  5930. HospLv string `json:"hosp_lv"`
  5931. PsnCashPay float64
  5932. } `json:"setlinfo"`
  5933. } `json:"output"`
  5934. RefmsgTime string `json:"refmsg_time"`
  5935. RespondTime string `json:"respond_time"`
  5936. Signtype interface{} `json:"signtype"`
  5937. WarnMsg interface{} `json:"warn_msg"`
  5938. }
  5939. type ResultEleven10265 struct {
  5940. Cainfo string `json:"cainfo"`
  5941. ErrMsg string `json:"err_msg"`
  5942. InfRefmsgid string `json:"inf_refmsgid"`
  5943. Infcode string `json:"infcode"`
  5944. Output struct {
  5945. Setlinfo struct {
  5946. SetlTime string `json:"setl_time"`
  5947. CvlservPay float64 `json:"cvlserv_pay"`
  5948. Year string `json:"year"`
  5949. MedType string `json:"med_type"`
  5950. PsnPay float64 `json:"psn_pay"`
  5951. OpterID string `json:"opter_id"`
  5952. Begndate string `json:"begndate"`
  5953. FlxempeFlag string `json:"flxempe_flag"`
  5954. HifmiPay float64 `json:"hifmi_pay"`
  5955. PsnNo string `json:"psn_no"`
  5956. ActPayDedc float64 `json:"act_pay_dedc"`
  5957. MedinsSetlID interface{} `json:"medins_setl_id"`
  5958. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5959. ClrWay string `json:"clr_way"`
  5960. OthPay float64 `json:"oth_pay"`
  5961. Gend string `json:"gend"`
  5962. MdtrtID string `json:"mdtrt_id"`
  5963. AcctPay float64 `json:"acct_pay"`
  5964. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5965. Insutype string `json:"insutype"`
  5966. Invono interface{} `json:"invono"`
  5967. Enddate string `json:"enddate"`
  5968. CashPayamt float64 `json:"cash_payamt"`
  5969. PsnType string `json:"psn_type"`
  5970. FixmedinsName string `json:"fixmedins_name"`
  5971. HifpPay float64 `json:"hifp_pay"`
  5972. NewFlag interface{} `json:"new_flag"`
  5973. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5974. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5975. PayLoc string `json:"pay_loc"`
  5976. ClrType string `json:"clr_type"`
  5977. RefdSetlFlag string `json:"refd_setl_flag"`
  5978. CvlservFlag string `json:"cvlserv_flag"`
  5979. EmpName string `json:"emp_name"`
  5980. Brdy string `json:"brdy"`
  5981. Naty string `json:"naty"`
  5982. Certno string `json:"certno"`
  5983. DiseCode string `json:"dise_code"`
  5984. FixmedinsCode string `json:"fixmedins_code"`
  5985. DedcHospLv string `json:"dedc_hosp_lv"`
  5986. OpterName string `json:"opter_name"`
  5987. Balc float64 `json:"balc"`
  5988. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5989. PsnCertType string `json:"psn_cert_type"`
  5990. HifobPay float64 `json:"hifob_pay"`
  5991. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5992. HifesPay float64 `json:"hifes_pay"`
  5993. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5994. OptTime string `json:"opt_time"`
  5995. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5996. SetlID string `json:"setl_id"`
  5997. MafPay float64 `json:"maf_pay"`
  5998. PsnName string `json:"psn_name"`
  5999. InsuOptins interface{} `json:"insu_optins"`
  6000. PrefFundPay interface{} `json:"pref_fund_pay"`
  6001. ClrOptins string `json:"clr_optins"`
  6002. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6003. DiseName string `json:"dise_name"`
  6004. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6005. Age float64 `json:"age"`
  6006. DtrtCertType string `json:"dtrt_cert_type"`
  6007. HospLv string `json:"hosp_lv"`
  6008. PsnCashPay float64
  6009. } `json:"setlinfo"`
  6010. } `json:"output"`
  6011. RefmsgTime string `json:"refmsg_time"`
  6012. RespondTime string `json:"respond_time"`
  6013. Signtype interface{} `json:"signtype"`
  6014. WarnMsg interface{} `json:"warn_msg"`
  6015. }
  6016. type ResultTwelve struct {
  6017. Cainfo string `json:"cainfo"`
  6018. ErrMsg string `json:"err_msg"`
  6019. InfRefmsgid string `json:"inf_refmsgid"`
  6020. Infcode int64 `json:"infcode"`
  6021. Output struct {
  6022. MdtrtId string `json:"mdtrt_id"`
  6023. ChrgBchno string `json:"chrg_bchno"`
  6024. PsnNo string `json:"psn_no"`
  6025. } `json:"output"`
  6026. RefmsgTime string `json:"refmsg_time"`
  6027. RespondTime string `json:"respond_time"`
  6028. Signtype interface{} `json:"signtype"`
  6029. WarnMsg interface{} `json:"warn_msg"`
  6030. }
  6031. type ResultThirteen struct {
  6032. ErrMsg string `json:"err_msg"`
  6033. InfRefmsgid string `json:"inf_refmsgid"`
  6034. Infcode int64 `json:"infcode"`
  6035. Output struct {
  6036. Result struct {
  6037. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6038. } `json:"result"`
  6039. } `json:"output"`
  6040. RefmsgTime string `json:"refmsg_time"`
  6041. RespondTime string `json:"respond_time"`
  6042. Signtype interface{} `json:"signtype"`
  6043. WarnInfo interface{} `json:"warn_info"`
  6044. }
  6045. type ResultThirteen10265 struct {
  6046. ErrMsg string `json:"err_msg"`
  6047. InfRefmsgid string `json:"inf_refmsgid"`
  6048. Infcode string `json:"infcode"`
  6049. Output struct {
  6050. Result struct {
  6051. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6052. } `json:"result"`
  6053. } `json:"output"`
  6054. RefmsgTime string `json:"refmsg_time"`
  6055. RespondTime string `json:"respond_time"`
  6056. Signtype interface{} `json:"signtype"`
  6057. WarnInfo interface{} `json:"warn_info"`
  6058. }
  6059. type ResultFourteen struct {
  6060. ErrMsg string `json:"err_msg"`
  6061. InfRefmsgid string `json:"inf_refmsgid"`
  6062. Infcode int64 `json:"infcode"`
  6063. Output struct {
  6064. } `json:"output"`
  6065. RefmsgTime string `json:"refmsg_time"`
  6066. RespondTime string `json:"respond_time"`
  6067. Signtype interface{} `json:"signtype"`
  6068. WarnInfo interface{} `json:"warn_info"`
  6069. }
  6070. type ResultFourteen10265 struct {
  6071. ErrMsg string `json:"err_msg"`
  6072. InfRefmsgid string `json:"inf_refmsgid"`
  6073. Infcode string `json:"infcode"`
  6074. Output struct {
  6075. } `json:"output"`
  6076. RefmsgTime string `json:"refmsg_time"`
  6077. RespondTime string `json:"respond_time"`
  6078. Signtype interface{} `json:"signtype"`
  6079. WarnInfo interface{} `json:"warn_info"`
  6080. }
  6081. type ResultSixteen struct {
  6082. Cainfo string `json:"cainfo"`
  6083. ErrMsg string `json:"err_msg"`
  6084. InfRefmsgid string `json:"inf_refmsgid"`
  6085. Infcode int64 `json:"infcode"`
  6086. Output struct {
  6087. Setldetail []interface{} `json:"setldetail"`
  6088. Setlinfo struct {
  6089. MdtrtID string `json:"mdtrt_id"`
  6090. SetlID string `json:"setl_id"`
  6091. ClrOptins string `json:"clr_optins"`
  6092. SetlTime string `json:"setl_time"`
  6093. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6094. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6095. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6096. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6097. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6098. ActPayDedc float64 `json:"act_pay_dedc"`
  6099. HifpPay float64 `json:"hifp_pay"`
  6100. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6101. Lfpay float64 `json:"selfpay"`
  6102. CvlservPay float64 `json:"cvlserv_pay"`
  6103. HifesPay float64 `json:"hifes_pay"`
  6104. HifmiPay float64 `json:"hifmi_pay"`
  6105. HifobPay float64 `json:"hifob_pay"`
  6106. MafPay float64 `json:"maf_pay"`
  6107. OthPay float64 `json:"oth_pay"`
  6108. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6109. PsnPartAmt float64 `json:"psn_part_amt"`
  6110. AcctPay float64 `json:"acct_pay"`
  6111. Balc float64 `json:"balc"`
  6112. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6113. HospPartAmt float64 `json:"hosp_part_amt"`
  6114. MedinsSetlID string `json:"medins_setl_id"`
  6115. PdnCashPay string `json:"pdn_cash_pay"`
  6116. } `json:"setlinfo"`
  6117. } `json:"output"`
  6118. RefmsgTime string `json:"refmsg_time"`
  6119. RespondTime string `json:"respond_time"`
  6120. Signtype interface{} `json:"signtype"`
  6121. WarnMsg interface{} `json:"warn_msg"`
  6122. }
  6123. type ResultSixteen10265 struct {
  6124. Cainfo string `json:"cainfo"`
  6125. ErrMsg string `json:"err_msg"`
  6126. InfRefmsgid string `json:"inf_refmsgid"`
  6127. Infcode string `json:"infcode"`
  6128. Output struct {
  6129. Setldetail []interface{} `json:"setldetail"`
  6130. Setlinfo struct {
  6131. MdtrtID string `json:"mdtrt_id"`
  6132. SetlID string `json:"setl_id"`
  6133. ClrOptins string `json:"clr_optins"`
  6134. SetlTime string `json:"setl_time"`
  6135. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6136. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6137. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6138. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6139. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6140. ActPayDedc float64 `json:"act_pay_dedc"`
  6141. HifpPay float64 `json:"hifp_pay"`
  6142. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6143. Lfpay float64 `json:"selfpay"`
  6144. CvlservPay float64 `json:"cvlserv_pay"`
  6145. HifesPay float64 `json:"hifes_pay"`
  6146. HifmiPay float64 `json:"hifmi_pay"`
  6147. HifobPay float64 `json:"hifob_pay"`
  6148. MafPay float64 `json:"maf_pay"`
  6149. OthPay float64 `json:"oth_pay"`
  6150. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6151. PsnPartAmt float64 `json:"psn_part_amt"`
  6152. AcctPay float64 `json:"acct_pay"`
  6153. Balc float64 `json:"balc"`
  6154. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6155. HospPartAmt float64 `json:"hosp_part_amt"`
  6156. MedinsSetlID string `json:"medins_setl_id"`
  6157. PdnCashPay string `json:"pdn_cash_pay"`
  6158. } `json:"setlinfo"`
  6159. } `json:"output"`
  6160. RefmsgTime string `json:"refmsg_time"`
  6161. RespondTime string `json:"respond_time"`
  6162. Signtype interface{} `json:"signtype"`
  6163. WarnMsg interface{} `json:"warn_msg"`
  6164. }
  6165. type ResultSeventeen struct {
  6166. ErrMsg string `json:"err_msg"`
  6167. InfRefmsgid string `json:"inf_refmsgid"`
  6168. Infcode int64 `json:"infcode"`
  6169. Output struct {
  6170. SetlListId string `json:"setl_list_id"`
  6171. } `json:"output"`
  6172. RefmsgTime string `json:"refmsg_time"`
  6173. RespondTime string `json:"respond_time"`
  6174. Signtype string `json:"signtype"`
  6175. WarnInfo string `json:"warn_info"`
  6176. }
  6177. type ResultSeventeenOther struct {
  6178. ErrMsg string `json:"err_msg"`
  6179. InfRefmsgid string `json:"inf_refmsgid"`
  6180. Infcode string `json:"infcode"`
  6181. Output struct {
  6182. SetlListId string `json:"setl_list_id"`
  6183. } `json:"output"`
  6184. RefmsgTime string `json:"refmsg_time"`
  6185. RespondTime string `json:"respond_time"`
  6186. Signtype string `json:"signtype"`
  6187. WarnInfo string `json:"warn_info"`
  6188. }
  6189. type Result90991 struct {
  6190. ErrMsg string `json:"err_msg"`
  6191. InfRefmsgid string `json:"inf_refmsgid"`
  6192. Infcode int64 `json:"infcode"`
  6193. Output struct {
  6194. Result struct {
  6195. PsnNo string `json:"psn_no"`
  6196. CardStat string `json:"card_stat"`
  6197. Certno string `json:"certno"`
  6198. PsnName string `json:"psn_name"`
  6199. CheckStat string `json:"check_stat"`
  6200. SscnoCheckStat string `json:"sscno_check_stat"`
  6201. } `json:"result"`
  6202. } `json:"output"`
  6203. RefmsgTime string `json:"refmsg_time"`
  6204. RespondTime string `json:"respond_time"`
  6205. Signtype interface{} `json:"signtype"`
  6206. WarnInfo interface{} `json:"warn_info"`
  6207. }
  6208. type Result90100 struct {
  6209. ErrMsg string `json:"err_msg"`
  6210. InfRefmsgid string `json:"inf_refmsgid"`
  6211. Infcode int64 `json:"infcode"`
  6212. Output struct {
  6213. PoolareaNo string `json:"poolarea_no"`
  6214. PoolareaNoName string `json:"poolarea_no_name"`
  6215. Insutype string `json:"insutype"`
  6216. InsutypeName string `json:"insutype_name"`
  6217. ClctType string `json:"clct_type"`
  6218. ClctTypeName string `json:"clct_type_name"`
  6219. ClctFlag string `json:"clct_flag"`
  6220. ClctFlagName string `json:"clct_flag_name"`
  6221. AccrymBegn string `json:"accrym_begn"`
  6222. AccrymEnd string `json:"accrym_end"`
  6223. ClctTime string `json:"clct_time"`
  6224. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6225. } `json:"output"`
  6226. RefmsgTime string `json:"refmsg_time"`
  6227. RespondTime string `json:"respond_time"`
  6228. Signtype interface{} `json:"signtype"`
  6229. WarnInfo interface{} `json:"warn_info"`
  6230. }
  6231. type Custom struct {
  6232. DetItemFeeSumamt string
  6233. Cut string
  6234. FeedetlSn string
  6235. Price string
  6236. MedListCodg string
  6237. Type int64
  6238. AdviceId int64
  6239. ProjectId int64
  6240. ItemId int64
  6241. }
  6242. type Result5301 struct {
  6243. ErrMsg string `json:"err_msg"`
  6244. InfRefmsgid string `json:"inf_refmsgid"`
  6245. Infcode int64 `json:"infcode"`
  6246. Output struct {
  6247. Result []struct {
  6248. OpspDiseCode string `json:"opsp_dise_code"`
  6249. OpspDiseName string `json:"opsp_dise_name"`
  6250. Begndate string `json:"begndate"`
  6251. Enddate string `json:"enddate"`
  6252. } `json:"feedetail"`
  6253. } `json:"output"`
  6254. RefmsgTime string `json:"refmsg_time"`
  6255. RespondTime string `json:"respond_time"`
  6256. Signtype interface{} `json:"signtype"`
  6257. WarnInfo interface{} `json:"warn_info"`
  6258. }
  6259. type Result5301For10265 struct {
  6260. ErrMsg string `json:"err_msg"`
  6261. InfRefmsgid string `json:"inf_refmsgid"`
  6262. Infcode string `json:"infcode"`
  6263. Output struct {
  6264. Result []struct {
  6265. OpspDiseCode string `json:"opsp_dise_code"`
  6266. OpspDiseName string `json:"opsp_dise_name"`
  6267. Begndate string `json:"begndate"`
  6268. Enddate string `json:"enddate"`
  6269. } `json:"feedetail"`
  6270. } `json:"output"`
  6271. RefmsgTime string `json:"refmsg_time"`
  6272. RespondTime string `json:"respond_time"`
  6273. Signtype interface{} `json:"signtype"`
  6274. WarnInfo interface{} `json:"warn_info"`
  6275. }
  6276. //获取个人信息----挂号-----上传就诊信息
  6277. func (c *HisApiController) GetRegisterInfo() {
  6278. id, _ := c.GetInt64("id")
  6279. record_time := c.GetString("record_time")
  6280. settlementValue, _ := c.GetInt64("settlement_value")
  6281. medical_insurance_card := c.GetString("medical_insurance_card")
  6282. name := c.GetString("name")
  6283. id_card_type, _ := c.GetInt64("id_card_type")
  6284. certificates, _ := c.GetInt64("certificates")
  6285. medical_care, _ := c.GetInt64("medical_care")
  6286. birthday := c.GetString("birthday")
  6287. id_card := c.GetString("id_card")
  6288. register_type, _ := c.GetInt64("register")
  6289. doctor, _ := c.GetInt64("doctor")
  6290. department, _ := c.GetInt64("department")
  6291. gender, _ := c.GetInt64("sex")
  6292. registration_fee, _ := c.GetFloat("registration_fee")
  6293. medical_expenses, _ := c.GetFloat("medical_expenses")
  6294. social_type, _ := c.GetInt64("social_type")
  6295. med_type := c.GetString("social_type")
  6296. admin_user_id, _ := c.GetInt64("admin_user_id")
  6297. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6298. timeLayout := "2006-01-02"
  6299. loc, _ := time.LoadLocation("Local")
  6300. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6301. birthUnix := birthdays.Unix()
  6302. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6303. if err != nil {
  6304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6305. return
  6306. }
  6307. recordDateTime := theTime.Unix()
  6308. adminInfo := c.GetAdminUserInfo()
  6309. var patient service.Patients
  6310. if id == 0 {
  6311. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6312. } else {
  6313. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6314. }
  6315. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6316. if patientPrescription.ID == 0 {
  6317. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6318. }
  6319. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6320. if patient.ID == 0 {
  6321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6322. return
  6323. }
  6324. if len(patient.IdCardNo) == 0 {
  6325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6326. return
  6327. }
  6328. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6329. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6330. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6331. //就诊结算未完成,不能进行二次挂号
  6332. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6333. if len(his) >= 1 {
  6334. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6335. if len(his) >= 1 && order.ID == 0 {
  6336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6337. return
  6338. }
  6339. }
  6340. //var register_log string
  6341. if config.IsOpen == 1 {
  6342. var res ResultTwo
  6343. var res10265 ResultTwo10265
  6344. var PsnNo string
  6345. var PsnCertType string
  6346. var Certno string
  6347. var PsnName string
  6348. var Gend string
  6349. var Naty string
  6350. var Brdy string
  6351. var Age float64
  6352. var infoStr string
  6353. var idetinfoStr string
  6354. var infocode int64
  6355. var verify_number string
  6356. fmt.Println(verify_number)
  6357. if miConfig.MdtrtareaAdmvs == "421300" {
  6358. psn_info, _ := service.GetPsnByPatientId(id)
  6359. PsnNo = psn_info.PsnNo
  6360. PsnCertType = psn_info.PsnCertType
  6361. Certno = psn_info.Certno
  6362. PsnName = psn_info.PsnName
  6363. Gend = psn_info.Gend
  6364. Naty = psn_info.Naty
  6365. Brdy = psn_info.Brdy
  6366. Age = psn_info.Age
  6367. infoStr = psn_info.Insuinfo
  6368. idetinfoStr = psn_info.Idetinfo
  6369. infocode = 0
  6370. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6371. psn_info, _ := service.GetPsnByPatientId(id)
  6372. PsnNo = psn_info.PsnNo
  6373. PsnCertType = psn_info.PsnCertType
  6374. Certno = psn_info.Certno
  6375. PsnName = psn_info.PsnName
  6376. Gend = psn_info.Gend
  6377. Naty = psn_info.Naty
  6378. Brdy = psn_info.Brdy
  6379. Age = psn_info.Age
  6380. infoStr = psn_info.Insuinfo
  6381. idetinfoStr = psn_info.Idetinfo
  6382. infocode = 0
  6383. verify_number = psn_info.VerifyNumber
  6384. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6385. if id_card_type == 1 {
  6386. psn_info, _ := service.GetPsnByPatientId(id)
  6387. PsnNo = psn_info.PsnNo
  6388. PsnCertType = psn_info.PsnCertType
  6389. Certno = psn_info.Certno
  6390. PsnName = psn_info.PsnName
  6391. Gend = psn_info.Gend
  6392. Naty = psn_info.Naty
  6393. Brdy = psn_info.Brdy
  6394. Age = psn_info.Age
  6395. infoStr = psn_info.Insuinfo
  6396. idetinfoStr = psn_info.Idetinfo
  6397. infocode = 0
  6398. verify_number = psn_info.VerifyNumber
  6399. } else if id_card_type == 2 {
  6400. 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)
  6401. fmt.Println(errMsgLog)
  6402. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6404. utils.ErrorLog("解析失败:%v", err)
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. return
  6407. }
  6408. PsnNo = res.Output.Baseinfo.PsnNo
  6409. PsnCertType = res.Output.Baseinfo.PsnCertType
  6410. Certno = res.Output.Baseinfo.Certno
  6411. PsnName = res.Output.Baseinfo.PsnName
  6412. Gend = res.Output.Baseinfo.Gend
  6413. Naty = res.Output.Baseinfo.Naty
  6414. Brdy = res.Output.Baseinfo.Brdy
  6415. Age = res.Output.Baseinfo.Age
  6416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6418. infoStr = string(Iinfos)
  6419. idetinfoStr = string(Idetinfos)
  6420. infocode = res.Infcode
  6421. }
  6422. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6423. if id_card_type == 1 {
  6424. psn_info, _ := service.GetPsnByPatientId(id)
  6425. PsnNo = psn_info.PsnNo
  6426. PsnCertType = psn_info.PsnCertType
  6427. Certno = psn_info.Certno
  6428. PsnName = psn_info.PsnName
  6429. Gend = psn_info.Gend
  6430. Naty = psn_info.Naty
  6431. Brdy = psn_info.Brdy
  6432. Age = psn_info.Age
  6433. infoStr = psn_info.Insuinfo
  6434. idetinfoStr = psn_info.Idetinfo
  6435. infocode = 0
  6436. verify_number = psn_info.VerifyNumber
  6437. } else if id_card_type == 2 {
  6438. 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, "")
  6439. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6440. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6441. utils.ErrorLog("解析失败:%v", err)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return
  6444. }
  6445. PsnNo = res.Output.Baseinfo.PsnNo
  6446. PsnCertType = res.Output.Baseinfo.PsnCertType
  6447. Certno = res.Output.Baseinfo.Certno
  6448. PsnName = res.Output.Baseinfo.PsnName
  6449. Gend = res.Output.Baseinfo.Gend
  6450. Naty = res.Output.Baseinfo.Naty
  6451. Brdy = res.Output.Baseinfo.Brdy
  6452. Age = res.Output.Baseinfo.Age
  6453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6455. infoStr = string(Iinfos)
  6456. idetinfoStr = string(Idetinfos)
  6457. infocode = res.Infcode
  6458. }
  6459. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6460. if id_card_type == 1 {
  6461. psn_info, _ := service.GetPsnByPatientId(id)
  6462. PsnNo = psn_info.PsnNo
  6463. PsnCertType = psn_info.PsnCertType
  6464. Certno = psn_info.Certno
  6465. PsnName = psn_info.PsnName
  6466. Gend = psn_info.Gend
  6467. Naty = psn_info.Naty
  6468. Brdy = psn_info.Brdy
  6469. Age = psn_info.Age
  6470. infoStr = psn_info.Insuinfo
  6471. idetinfoStr = psn_info.Idetinfo
  6472. infocode = 0
  6473. verify_number = psn_info.VerifyNumber
  6474. } else if id_card_type == 2 {
  6475. 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)
  6476. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6478. utils.ErrorLog("解析失败:%v", err)
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. PsnNo = res.Output.Baseinfo.PsnNo
  6483. PsnCertType = res.Output.Baseinfo.PsnCertType
  6484. Certno = res.Output.Baseinfo.Certno
  6485. PsnName = res.Output.Baseinfo.PsnName
  6486. Gend = res.Output.Baseinfo.Gend
  6487. Naty = res.Output.Baseinfo.Naty
  6488. Brdy = res.Output.Baseinfo.Brdy
  6489. Age = res.Output.Baseinfo.Age
  6490. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6491. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6492. infoStr = string(Iinfos)
  6493. idetinfoStr = string(Idetinfos)
  6494. infocode = res.Infcode
  6495. }
  6496. } else {
  6497. var result string
  6498. var requestLog string
  6499. if miConfig.UserOrgId == 10138 {
  6500. if id_card_type != 4 {
  6501. //psn_info, _ := service.GetPsnByPatientId(id)
  6502. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6503. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6504. }
  6505. } else {
  6506. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6507. }
  6508. if id_card_type == 4 {
  6509. psn_info, _ := service.GetPsnByPatientId(id)
  6510. PsnNo = psn_info.PsnNo
  6511. PsnCertType = psn_info.PsnCertType
  6512. Certno = psn_info.Certno
  6513. PsnName = psn_info.PsnName
  6514. Gend = psn_info.Gend
  6515. Naty = psn_info.Naty
  6516. Brdy = psn_info.Brdy
  6517. Age = psn_info.Age
  6518. infoStr = psn_info.Insuinfo
  6519. idetinfoStr = psn_info.Idetinfo
  6520. infocode = 0
  6521. verify_number = psn_info.VerifyNumber
  6522. } else {
  6523. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6524. if miConfig.Code == "H15049901371" {
  6525. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6526. utils.ErrorLog("解析失败:%v", err)
  6527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. return
  6529. }
  6530. res.ErrMsg = res10265.ErrMsg
  6531. res.Output = res10265.Output
  6532. res.InfRefmsgid = res10265.InfRefmsgid
  6533. } else {
  6534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6535. utils.ErrorLog("解析失败:%v", err)
  6536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6537. return
  6538. }
  6539. }
  6540. PsnNo = res.Output.Baseinfo.PsnNo
  6541. PsnCertType = res.Output.Baseinfo.PsnCertType
  6542. Certno = res.Output.Baseinfo.Certno
  6543. PsnName = res.Output.Baseinfo.PsnName
  6544. Gend = res.Output.Baseinfo.Gend
  6545. Naty = res.Output.Baseinfo.Naty
  6546. Brdy = res.Output.Baseinfo.Brdy
  6547. Age = res.Output.Baseinfo.Age
  6548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6550. infoStr = string(Iinfos)
  6551. idetinfoStr = string(Idetinfos)
  6552. if miConfig.Code == "H15049901371" {
  6553. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6554. } else {
  6555. infocode = res.Infcode
  6556. }
  6557. }
  6558. }
  6559. if infocode == 0 {
  6560. his := models.VMHisPatient{
  6561. Name: name,
  6562. Gender: gender,
  6563. Birthday: birthUnix,
  6564. MedicalTreatmentType: medical_care,
  6565. IdType: certificates,
  6566. IdCardNo: id_card,
  6567. BalanceAccountsType: settlementValue,
  6568. SocialType: social_type,
  6569. MedicalInsuranceNumber: medical_insurance_card,
  6570. RegisterType: register_type,
  6571. RegisterCost: registration_fee,
  6572. TreatmentCost: medical_expenses,
  6573. Status: 1,
  6574. Ctime: time.Now().Unix(),
  6575. Mtime: time.Now().Unix(),
  6576. PsnNo: PsnNo,
  6577. PsnCertType: PsnCertType,
  6578. Certno: Certno,
  6579. PsnName: PsnName,
  6580. Gend: Gend,
  6581. Naty: Naty,
  6582. Brdy: Brdy,
  6583. Age: Age,
  6584. Iinfo: infoStr,
  6585. Idetinfo: idetinfoStr,
  6586. PatientId: patient.ID,
  6587. RecordDate: theTime.Unix(),
  6588. UserOrgId: adminInfo.CurrentOrgId,
  6589. AdminUserId: admin_user_id,
  6590. IsReturn: 1,
  6591. IdCardType: id_card_type,
  6592. Doctor: doctor,
  6593. Departments: department,
  6594. }
  6595. timestamp := time.Now().Unix()
  6596. tempTime := time.Unix(timestamp, 0)
  6597. timeFormat := tempTime.Format("20060102150405")
  6598. chrgBchno := rand.Intn(100000) + 10000
  6599. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6600. his.Number = ipt_otp_no
  6601. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6602. department, _ := service.GetDepartMentDetail(department)
  6603. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6604. IdCardNo := ""
  6605. if id_card_type == 1 {
  6606. // IdCardNo = medical_insurance_card
  6607. IdCardNo = patient.IdCardNo
  6608. } else {
  6609. IdCardNo = patient.IdCardNo
  6610. }
  6611. var rf []*ResultFive
  6612. json.Unmarshal([]byte(his.Iinfo), &rf)
  6613. var insutypes []*ResultFive
  6614. var insutype string
  6615. var insuplc_admdvs_temp string
  6616. var is390 int = 0
  6617. var is310 int = 0
  6618. for _, item := range rf {
  6619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6620. insutypes = append(insutypes, item)
  6621. }
  6622. }
  6623. if len(insutypes) == 1 {
  6624. insutype = insutypes[0].Insutype
  6625. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6626. } else {
  6627. for _, i := range insutypes {
  6628. if i.Insutype == "390" {
  6629. is390 = 1
  6630. }
  6631. if i.Insutype == "310" {
  6632. is310 = 1
  6633. }
  6634. }
  6635. }
  6636. if is390 == 1 {
  6637. insutype = "390"
  6638. }
  6639. if is310 == 1 {
  6640. insutype = "310"
  6641. }
  6642. if len(insutypes) == 0 {
  6643. insutype = "310"
  6644. }
  6645. if len(insutypes) == 2 {
  6646. insutype = med_type
  6647. }
  6648. if len(med_type) > 0 {
  6649. insutype = med_type
  6650. }
  6651. var infocode int64
  6652. var resThree ResultThree
  6653. var resThree10265 ResultThree10265
  6654. if len(insuplc_admdvs) == 0 {
  6655. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6656. } else {
  6657. insuplc_admdvs_temp = insuplc_admdvs
  6658. }
  6659. if miConfig.MdtrtareaAdmvs == "421300" {
  6660. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6661. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6662. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6663. "&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
  6664. resp, requestErr := http.Get(api)
  6665. if requestErr != nil {
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6667. return
  6668. }
  6669. body, ioErr := ioutil.ReadAll(resp.Body)
  6670. if ioErr != nil {
  6671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. return
  6674. }
  6675. var respJSON map[string]interface{}
  6676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6682. result, _ := json.Marshal(respJSON)
  6683. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6684. utils.ErrorLog("解析失败:%v", err)
  6685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6686. return
  6687. }
  6688. infocode = resThree.Infcode
  6689. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6690. psn_info, _ := service.GetPsnByPatientId(id)
  6691. his.PsnNo = psn_info.PsnNo
  6692. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6693. var cert_no string
  6694. if id_card_type == 3 {
  6695. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6696. cert_no = IdCardNo
  6697. } else if id_card_type == 4 {
  6698. cert_no = IdCardNo
  6699. psn_info.VerifyNumber = psn_info.VerifyNumber
  6700. } else {
  6701. bas := strings.Split(psn_info.CardInfo, "|")
  6702. cert_no = bas[2]
  6703. }
  6704. var hisPrescription []*models.HisPrescription
  6705. for _, item := range rf {
  6706. if item.Insutype == insutype {
  6707. //insuplc_admdvs = item.InsuplcAdmdvs
  6708. his.InsuplcAdmdvs = insuplc_admdvs
  6709. }
  6710. }
  6711. his.Insutype = insutype
  6712. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6713. fmt.Println(res3101)
  6714. fmt.Println(res3101.Infcode)
  6715. if res3101.Infcode == "0" {
  6716. fmt.Println("33333333")
  6717. if len(res3101.Output.Result) > 0 {
  6718. fmt.Println("222222")
  6719. for _, item := range res3101.Output.Result {
  6720. if len(res3101.ErrMsg) == 0 {
  6721. res3101.ErrMsg = item.VolaCont
  6722. } else {
  6723. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6724. }
  6725. }
  6726. c.ServeSuccessJSON(map[string]interface{}{
  6727. "failed_code": -10,
  6728. "msg": res3101.ErrMsg,
  6729. })
  6730. return
  6731. } else {
  6732. fmt.Println("11111")
  6733. var api string
  6734. if miConfig.MdtrtareaAdmvs == "320921" {
  6735. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6736. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6737. "&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
  6738. } else {
  6739. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6740. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6741. "&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
  6742. }
  6743. resp, requestErr := http.Get(api)
  6744. if requestErr != nil {
  6745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6746. return
  6747. }
  6748. body, ioErr := ioutil.ReadAll(resp.Body)
  6749. if ioErr != nil {
  6750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. var respJSON map[string]interface{}
  6755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return
  6759. }
  6760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6761. result, _ := json.Marshal(respJSON)
  6762. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6763. utils.ErrorLog("解析失败:%v", err)
  6764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6765. return
  6766. }
  6767. resThree.ErrMsg = resThree10265.ErrMsg
  6768. resThree.Output = resThree10265.Output
  6769. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6770. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6771. }
  6772. } else if res3101.Infcode != "0" {
  6773. c.ServeSuccessJSON(map[string]interface{}{
  6774. "failed_code": -10,
  6775. "msg": res3101.ErrMsg,
  6776. })
  6777. return
  6778. }
  6779. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6780. psn_info, _ := service.GetPsnByPatientId(id)
  6781. var cert_no string
  6782. if id_card_type == 1 {
  6783. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6784. } else if id_card_type == 4 {
  6785. cert_no = psn_info.VerifyNumber
  6786. } else {
  6787. cert_no = psn_info.VerifyNumber
  6788. }
  6789. 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)
  6790. saveLog(result, requestLog, "2201", "挂号")
  6791. if miConfig.Code == "H15049901371" {
  6792. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6793. utils.ErrorLog("解析失败:%v", err)
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6795. return
  6796. }
  6797. resThree.ErrMsg = resThree10265.ErrMsg
  6798. resThree.Output = resThree10265.Output
  6799. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6800. } else {
  6801. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6802. utils.ErrorLog("解析失败:%v", err)
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. }
  6807. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6808. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  6809. psn_info, _ := service.GetPsnByPatientId(id)
  6810. var result string
  6811. var requestLog string
  6812. if id_card_type == 1 {
  6813. bas := strings.Split(psn_info.CardInfo, "|")
  6814. basNumber := bas[2]
  6815. card_sn := bas[3]
  6816. 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)
  6817. saveLog(result, requestLog, "2201A", "挂号")
  6818. } else if id_card_type == 2 {
  6819. 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, "", "")
  6820. saveLog(result, requestLog, "2201A", "挂号")
  6821. } else {
  6822. 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, "", "")
  6823. saveLog(result, requestLog, "2201A", "挂号")
  6824. }
  6825. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6826. utils.ErrorLog("解析失败:%v", err)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. infocode = resThree.Infcode
  6831. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  6832. psn_info, _ := service.GetPsnByPatientId(id)
  6833. var result string
  6834. var requestLog string
  6835. if id_card_type == 1 {
  6836. bas := strings.Split(psn_info.CardInfo, "|")
  6837. basNumber := bas[2]
  6838. card_sn := bas[3]
  6839. 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)
  6840. saveLog(result, requestLog, "2201A", "挂号")
  6841. } else if id_card_type == 2 {
  6842. 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, "", "")
  6843. saveLog(result, requestLog, "2201A", "挂号")
  6844. } else {
  6845. 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, "", "")
  6846. saveLog(result, requestLog, "2201A", "挂号")
  6847. }
  6848. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6849. utils.ErrorLog("解析失败:%v", err)
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. return
  6852. }
  6853. infocode = resThree.Infcode
  6854. } else {
  6855. psn_info, _ := service.GetPsnByPatientId(id)
  6856. 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)
  6857. saveLog(result, requestLog, "2201A", "挂号")
  6858. if miConfig.Code == "H15049901371" {
  6859. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6860. utils.ErrorLog("解析失败:%v", err)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. resThree.ErrMsg = resThree10265.ErrMsg
  6865. resThree.Output = resThree10265.Output
  6866. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6867. } else {
  6868. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6869. utils.ErrorLog("解析失败:%v", err)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. }
  6874. if miConfig.Code == "H15049901371" {
  6875. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6876. } else {
  6877. infocode = resThree.Infcode
  6878. }
  6879. }
  6880. if infocode != 0 {
  6881. adminUser := c.GetAdminUserInfo()
  6882. errlog := &models.HisOrderError{
  6883. UserOrgId: adminUser.CurrentOrgId,
  6884. Ctime: time.Now().Unix(),
  6885. Mtime: time.Now().Unix(),
  6886. ErrMsg: resThree.ErrMsg,
  6887. Status: 1,
  6888. PatientId: id,
  6889. RecordTime: recordDateTime,
  6890. Stage: 2,
  6891. }
  6892. service.CreateErrMsgLog(errlog)
  6893. c.ServeSuccessJSON(map[string]interface{}{
  6894. "failed_code": -10,
  6895. "msg": resThree.ErrMsg,
  6896. })
  6897. return
  6898. }
  6899. his.Number = resThree.Output.Data.MdtrtID
  6900. his.PsnNo = resThree.Output.Data.PsnNo
  6901. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  6902. his.IdCardNo = patient.IdCardNo
  6903. his.PhoneNumber = patient.Phone
  6904. his.UserOrgId = adminInfo.CurrentOrgId
  6905. his.Insutype = insutype
  6906. his.Ctime = time.Now().Unix()
  6907. his.Mtime = time.Now().Unix()
  6908. his.InsuplcAdmdvs = insuplc_admdvs_temp
  6909. his.Status = 1
  6910. service.UpdateHisPatientStatus(&his)
  6911. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  6912. c.ServeSuccessJSON(map[string]interface{}{
  6913. "his_info": his,
  6914. })
  6915. } else {
  6916. adminUser := c.GetAdminUserInfo()
  6917. errlog := &models.HisOrderError{
  6918. UserOrgId: adminUser.CurrentOrgId,
  6919. Ctime: time.Now().Unix(),
  6920. Mtime: time.Now().Unix(),
  6921. ErrMsg: res.ErrMsg,
  6922. Status: 1,
  6923. PatientId: id,
  6924. RecordTime: recordDateTime,
  6925. Stage: 1,
  6926. }
  6927. service.CreateErrMsgLog(errlog)
  6928. c.ServeSuccessJSON(map[string]interface{}{
  6929. "failed_code": -10,
  6930. "msg": res.ErrMsg,
  6931. })
  6932. return
  6933. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6934. }
  6935. }
  6936. }
  6937. //上传明细----预结算----确认订单
  6938. func (c *HisApiController) GetUploadInfo() {
  6939. id, _ := c.GetInt64("id")
  6940. record_time := c.GetString("record_time")
  6941. his_patient_id, _ := c.GetInt64("his_patient_id")
  6942. order_id, _ := c.GetInt64("order_id")
  6943. pay_way, _ := c.GetInt64("pay_way")
  6944. pay_price, _ := c.GetFloat("pay_price")
  6945. pay_card_no := c.GetString("pay_card_no")
  6946. discount_price, _ := c.GetFloat("discount_price")
  6947. preferential_price, _ := c.GetFloat("preferential_price")
  6948. reality_price, _ := c.GetFloat("reality_price")
  6949. found_price, _ := c.GetFloat("found_price")
  6950. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6951. private_price, _ := c.GetFloat("private_price")
  6952. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6953. admin_user_id, _ := c.GetInt64("admin_user_id")
  6954. fapiao_code := c.GetString("fapiao_code")
  6955. fapiao_number := c.GetString("fapiao_number")
  6956. diagnosis_id := c.GetString("diagnosis")
  6957. sick_type, _ := c.GetInt64("sick_type")
  6958. reg_type, _ := c.GetInt64("p_type")
  6959. begin_time := c.GetString("begin_time")
  6960. id_str := c.GetString("ids")
  6961. ids_arr := strings.Split(id_str, ",")
  6962. timeLayout := "2006-01-02"
  6963. loc, _ := time.LoadLocation("Local")
  6964. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6965. if err != nil {
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6967. return
  6968. }
  6969. recordDateTime := theTime.Unix()
  6970. adminUser := c.GetAdminUserInfo()
  6971. var tempOrder models.HisOrder
  6972. tempOrder, _ = service.GetHisOrderByID(order_id)
  6973. var prescriptions []*models.HisPrescription
  6974. var start_time int64
  6975. var end_time int64
  6976. //押金模块
  6977. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  6978. tmp_decimal := c.GetString("tmp_decimal")
  6979. var decimal float64 //本次使用的押金
  6980. var errmsg error
  6981. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  6982. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  6983. return
  6984. }
  6985. if len(tmp_decimal) > 0 {
  6986. if tmp_decimal[0] == 45 {
  6987. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  6988. return
  6989. }
  6990. }
  6991. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  6992. fmt.Println(errs)
  6993. decimal = tt
  6994. //if adminUser.CurrentOrgId == 10106{
  6995. // if len(fapiao_code) == 0{
  6996. // fapiao_code = "144072080589"
  6997. // }
  6998. // if len(fapiao_number) == 0{
  6999. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7000. // if order.ID == 0{
  7001. // fapiao_number = "00001520"
  7002. // }else{
  7003. // //fapiao_code = "00001520"
  7004. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7005. // var zero string
  7006. // if fpNumber >= 1000{
  7007. // zero = "0000" + strconv.Itoa(fpNumber)
  7008. // }else if fpNumber >= 10000{
  7009. // zero = "000" + strconv.Itoa(fpNumber)
  7010. // } else if fpNumber >= 100000{
  7011. // zero = "00" + strconv.Itoa(fpNumber)
  7012. // } else if fpNumber >= 1000000{
  7013. // zero = "0" + strconv.Itoa(fpNumber)
  7014. // }else {
  7015. // zero = strconv.Itoa(fpNumber)
  7016. // }
  7017. // fapiao_number = zero
  7018. // }
  7019. // }
  7020. //}
  7021. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7022. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7023. var patientPrescription models.HisPrescriptionInfo
  7024. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7025. if patientPrescription.ID == 0 {
  7026. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7027. }
  7028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7029. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7030. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7031. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7032. var config []*models.HisXtDiagnoseConfig
  7033. for _, item := range diagnosis_ids {
  7034. id, _ := strconv.ParseInt(item, 10, 64)
  7035. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7036. config = append(config, &diagnosisConfig)
  7037. }
  7038. sickConfig, _ := service.FindSickById(sick_type)
  7039. //if tempOrder.ID == 0 {
  7040. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7041. //}
  7042. if tempOrder.ID == 0 {
  7043. var result string
  7044. var requestLog string
  7045. var res2 ResultSix
  7046. var ressix10265 ResultSix10265
  7047. if miConfig.MdtrtareaAdmvs == "421300" {
  7048. data := make(map[string]interface{})
  7049. client := &http.Client{}
  7050. data["psn_no"] = his.PsnNo
  7051. data["mdtrt_id"] = his.Number
  7052. data["opter"] = roles.UserName
  7053. data["org_name"] = miConfig.OrgName
  7054. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7055. data["doctor_id"] = doctor_info.DoctorNumber
  7056. data["doctor_name"] = doctor_info.UserName
  7057. data["department"] = department.Name
  7058. data["fixmedins_code"] = miConfig.Code
  7059. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7060. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7061. data["secret_key"] = miConfig.SecretKey
  7062. data["sick_code"] = sickConfig.CountryCode
  7063. data["sick_name"] = sickConfig.ClassName
  7064. data["dept"] = strconv.FormatInt(department.ID, 10)
  7065. data["config"] = config
  7066. data["begin_time"] = begin_time
  7067. bytesData, _ := json.Marshal(data)
  7068. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7069. resp, _ := client.Do(req)
  7070. defer resp.Body.Close()
  7071. body, ioErr := ioutil.ReadAll(resp.Body)
  7072. if ioErr != nil {
  7073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. var respJSON map[string]interface{}
  7078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. userJSONBytes, _ := json.Marshal(respJSON)
  7085. fmt.Println("log")
  7086. fmt.Println(string(userJSONBytes))
  7087. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. return
  7091. }
  7092. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7093. data := make(map[string]interface{})
  7094. client := &http.Client{}
  7095. data["psn_no"] = his.PsnNo
  7096. data["mdtrt_id"] = his.Number
  7097. data["doctor"] = roles.UserName
  7098. data["department"] = department.Name
  7099. data["org_name"] = miConfig.OrgName
  7100. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7101. data["doctor_id"] = doctor_info.DoctorNumber
  7102. data["new_doctor_name"] = doctor_info.UserName
  7103. data["fixmedins_code"] = miConfig.Code
  7104. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7106. data["secret_key"] = miConfig.SecretKey
  7107. data["sick_code"] = sickConfig.CountryCode
  7108. data["sick_name"] = sickConfig.ClassName
  7109. data["url"] = miConfig.Url
  7110. data["ak"] = miConfig.AccessKey
  7111. data["begin_time"] = begin_time
  7112. data["cainfo"] = miConfig.Cainfo
  7113. data["dept"] = strconv.FormatInt(department.ID, 10)
  7114. data["config"] = config
  7115. bytesData, _ := json.Marshal(data)
  7116. var req *http.Request
  7117. if miConfig.MdtrtareaAdmvs == "320921" {
  7118. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7119. //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 +
  7120. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7121. } else {
  7122. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7123. }
  7124. resp, _ := client.Do(req)
  7125. defer resp.Body.Close()
  7126. body, ioErr := ioutil.ReadAll(resp.Body)
  7127. if ioErr != nil {
  7128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. var respJSON map[string]interface{}
  7133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7139. userJSONBytes, _ := json.Marshal(respJSON)
  7140. fmt.Println("log")
  7141. fmt.Println(string(userJSONBytes))
  7142. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7143. utils.ErrorLog("解析失败:%v", err)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. return
  7146. }
  7147. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7148. res2.Output = ressix10265.Output
  7149. res2.ErrMsg = ressix10265.ErrMsg
  7150. res2.Cainfo = ressix10265.Cainfo
  7151. res2.WarnMsg = ressix10265.WarnMsg
  7152. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7153. res2.Infcode = infocode
  7154. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7155. 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)
  7156. saveLog(result, requestLog, "2203", "上传就诊信息")
  7157. var respJSON2 map[string]interface{}
  7158. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. userJSONBytes2, _ := json.Marshal(respJSON2)
  7164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7165. utils.ErrorLog("解析失败:%v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. } else {
  7170. if miConfig.MdtrtareaAdmvs == "440781" { //
  7171. 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)
  7172. } else {
  7173. if miConfig.Code == "H15049901371" {
  7174. //赤峰地区国家医保医疗类别
  7175. //职工透析:医疗类别选特殊情况门诊990502
  7176. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7177. var med_type string
  7178. if his.Insutype == "390" {
  7179. if reg_type == 14 {
  7180. med_type = "9933"
  7181. } else if reg_type == 11 {
  7182. med_type = "11"
  7183. }
  7184. } else if his.Insutype == "310" {
  7185. if reg_type == 14 {
  7186. med_type = "990502"
  7187. } else if reg_type == 11 {
  7188. med_type = "11"
  7189. }
  7190. }
  7191. 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)
  7192. } else {
  7193. 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)
  7194. }
  7195. }
  7196. saveLog(result, requestLog, "2203", "上传就诊信息")
  7197. var respJSON2 map[string]interface{}
  7198. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7201. return
  7202. }
  7203. userJSONBytes2, _ := json.Marshal(respJSON2)
  7204. if miConfig.Code == "H15049901371" {
  7205. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7206. utils.ErrorLog("解析失败:%v", err)
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. return
  7209. }
  7210. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7211. res2.Output = ressix10265.Output
  7212. res2.ErrMsg = ressix10265.ErrMsg
  7213. res2.Cainfo = ressix10265.Cainfo
  7214. res2.WarnMsg = ressix10265.WarnMsg
  7215. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7216. res2.Infcode = infocode
  7217. } else {
  7218. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7219. utils.ErrorLog("解析失败:%v", err)
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7221. return
  7222. }
  7223. }
  7224. }
  7225. if res2.Infcode != 0 {
  7226. adminUser := c.GetAdminUserInfo()
  7227. errlog := &models.HisOrderError{
  7228. UserOrgId: adminUser.CurrentOrgId,
  7229. Ctime: time.Now().Unix(),
  7230. Mtime: time.Now().Unix(),
  7231. ErrMsg: res2.ErrMsg,
  7232. Status: 1,
  7233. PatientId: id,
  7234. RecordTime: recordDateTime,
  7235. Stage: 3,
  7236. }
  7237. service.CreateErrMsgLog(errlog)
  7238. c.ServeSuccessJSON(map[string]interface{}{
  7239. "failed_code": -10,
  7240. "msg": res2.ErrMsg,
  7241. })
  7242. return
  7243. } else {
  7244. his.Diagnosis = diagnosis_id
  7245. his.SickType = sickConfig.ID
  7246. //var p_type int64
  7247. //if reg_type == 1111 || reg_type == 1112 {
  7248. // p_type = 11
  7249. //
  7250. //}
  7251. his.PType = fmt.Sprintf("%d", reg_type)
  7252. service.UpdateHisPatientThree(&his)
  7253. data := make(map[string]interface{})
  7254. if settle_accounts_type == 1 { //日结
  7255. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7256. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7257. } else {
  7258. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7259. }
  7260. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7261. data["pre"] = prescriptions
  7262. } else { //月结
  7263. start_time_str := c.GetString("start_time")
  7264. end_time_str := c.GetString("end_time")
  7265. timeLayout := "2006-01-02"
  7266. loc, _ := time.LoadLocation("Local")
  7267. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7268. if err != nil {
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7270. return
  7271. }
  7272. recordStartTime := theStartTime.Unix()
  7273. start_time = recordStartTime
  7274. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7275. if err != nil {
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7277. return
  7278. }
  7279. recordEndTime := theEndTime.Unix()
  7280. end_time = recordEndTime
  7281. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7282. data["pre"] = prescriptions
  7283. }
  7284. timestamp := time.Now().Unix()
  7285. tempTime := time.Unix(timestamp, 0)
  7286. timeFormat := tempTime.Format("20060102150405")
  7287. chrgBchno := rand.Intn(100000) + 10000
  7288. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7289. strconv.FormatInt(his.PatientId, 10)
  7290. client := &http.Client{}
  7291. data["psn_no"] = his.PsnNo
  7292. data["mdtrt_id"] = his.Number
  7293. data["chrg_bchno"] = chrg_bchno
  7294. data["org_name"] = miConfig.OrgName
  7295. data["doctor"] = doctor_info.UserName
  7296. data["doctor_id"] = doctor_info.DoctorNumber
  7297. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7298. data["fixmedins_code"] = miConfig.Code
  7299. data["opter"] = roles.UserName
  7300. data["dept_code"] = department.Number
  7301. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7302. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7303. data["secret_key"] = miConfig.SecretKey
  7304. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7305. data["url"] = miConfig.Url
  7306. data["ak"] = miConfig.AccessKey
  7307. data["new_doctor_name"] = patientPrescription.Doctor
  7308. data["diag_code"] = sickConfig.CountryCode
  7309. data["cainfo"] = miConfig.Cainfo
  7310. data["opter"] = roles.UserName
  7311. var ids []int64
  7312. for _, item := range prescriptions {
  7313. ids = append(ids, item.ID)
  7314. }
  7315. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7316. if config.IsOpen == 1 { //对接了医保,走医保流程
  7317. var res ResultFour
  7318. var resFour10265 ResultFour10265
  7319. if miConfig.MdtrtareaAdmvs == "421300" {
  7320. bytesData, _ := json.Marshal(data)
  7321. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7322. resp, _ := client.Do(req)
  7323. defer resp.Body.Close()
  7324. body, ioErr := ioutil.ReadAll(resp.Body)
  7325. if ioErr != nil {
  7326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7328. return
  7329. }
  7330. var respJSON map[string]interface{}
  7331. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7337. userJSONBytes, _ := json.Marshal(respJSON)
  7338. fmt.Println("log")
  7339. fmt.Println(string(userJSONBytes))
  7340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7341. utils.ErrorLog("解析失败:%v", err)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7346. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7347. if result3101.Infcode == "0" {
  7348. if len(result3101.Output.Result) > 0 {
  7349. var errMsgs []string
  7350. for _, item := range result3101.Output.Result {
  7351. errMsgs = append(errMsgs, item.VolaCont)
  7352. }
  7353. c.ServeSuccessJSON(map[string]interface{}{
  7354. "failed_code": -10,
  7355. "msg": errMsgs,
  7356. })
  7357. return
  7358. }
  7359. }
  7360. bytesData, _ := json.Marshal(data)
  7361. var req *http.Request
  7362. if miConfig.MdtrtareaAdmvs == "320921" {
  7363. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7364. } else {
  7365. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7366. }
  7367. resp, _ := client.Do(req)
  7368. defer resp.Body.Close()
  7369. body, ioErr := ioutil.ReadAll(resp.Body)
  7370. if ioErr != nil {
  7371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7373. return
  7374. }
  7375. var respJSON map[string]interface{}
  7376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7382. userJSONBytes, _ := json.Marshal(respJSON)
  7383. fmt.Println("log")
  7384. fmt.Println(string(userJSONBytes))
  7385. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7386. utils.ErrorLog("解析失败:%v", err)
  7387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7388. return
  7389. }
  7390. res.InfRefmsgid = resFour10265.InfRefmsgid
  7391. res.Output = resFour10265.Output
  7392. res.ErrMsg = resFour10265.ErrMsg
  7393. res.Cainfo = resFour10265.Cainfo
  7394. res.WarnMsg = resFour10265.WarnMsg
  7395. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7396. res.Infcode = infocode
  7397. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7398. 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)
  7399. var dat map[string]interface{}
  7400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7401. fmt.Println(dat)
  7402. } else {
  7403. fmt.Println(err)
  7404. }
  7405. saveLog(result, request_log, "2204", "上传费用明细")
  7406. userJSONBytes, _ := json.Marshal(dat)
  7407. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7408. utils.ErrorLog("解析失败:%v", err)
  7409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7410. return
  7411. }
  7412. res.InfRefmsgid = resFour10265.InfRefmsgid
  7413. res.Output = resFour10265.Output
  7414. res.ErrMsg = resFour10265.ErrMsg
  7415. res.Cainfo = resFour10265.Cainfo
  7416. res.WarnMsg = resFour10265.WarnMsg
  7417. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7418. res.Infcode = infocode
  7419. } else {
  7420. if miConfig.Code == "H15049901371" {
  7421. 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)
  7422. var dat map[string]interface{}
  7423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7424. fmt.Println(dat)
  7425. } else {
  7426. fmt.Println(err)
  7427. }
  7428. saveLog(result, request_log, "2204", "上传费用明细")
  7429. userJSONBytes, _ := json.Marshal(dat)
  7430. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7431. utils.ErrorLog("解析失败:%v", err)
  7432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7433. return
  7434. }
  7435. res.InfRefmsgid = resFour10265.InfRefmsgid
  7436. res.Output = resFour10265.Output
  7437. res.ErrMsg = resFour10265.ErrMsg
  7438. res.Cainfo = resFour10265.Cainfo
  7439. res.WarnMsg = resFour10265.WarnMsg
  7440. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7441. res.Infcode = infocode
  7442. } else {
  7443. 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)
  7444. var dat map[string]interface{}
  7445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7446. fmt.Println(dat)
  7447. } else {
  7448. fmt.Println(err)
  7449. }
  7450. saveLog(result, request_log, "2204", "上传费用明细")
  7451. userJSONBytes, _ := json.Marshal(dat)
  7452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7453. utils.ErrorLog("解析失败:%v", err)
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. }
  7458. }
  7459. if res.Infcode == 0 {
  7460. order := &models.HisOrder{
  7461. UserOrgId: adminUser.CurrentOrgId,
  7462. HisPatientId: his.ID,
  7463. PatientId: his.PatientId,
  7464. SettleAccountsDate: recordDateTime,
  7465. MdtrtId: his.Number,
  7466. PsnNo: his.PsnNo,
  7467. MedType: strconv.FormatInt(reg_type, 10),
  7468. Ctime: time.Now().Unix(),
  7469. Mtime: time.Now().Unix(),
  7470. Status: 1,
  7471. Number: chrg_bchno,
  7472. Infcode: res.Infcode,
  7473. WarnMsg: res.WarnMsg,
  7474. Cainfo: res.Cainfo,
  7475. ErrMsg: res.ErrMsg,
  7476. RespondTime: res.RefmsgTime,
  7477. InfRefmsgid: res.InfRefmsgid,
  7478. OrderStatus: 1,
  7479. PayWay: pay_way,
  7480. PayPrice: pay_price,
  7481. PayCardNo: pay_card_no,
  7482. DiscountPrice: discount_price,
  7483. PreferentialPrice: preferential_price,
  7484. RealityPrice: reality_price,
  7485. FoundPrice: found_price,
  7486. MedicalInsurancePrice: medical_insurance_price,
  7487. PrivatePrice: private_price,
  7488. IsMedicineInsurance: 1,
  7489. SettleType: settle_accounts_type,
  7490. SettleStartTime: start_time,
  7491. SettleEndTime: end_time,
  7492. Creator: roles.AdminUserId,
  7493. Modify: roles.AdminUserId,
  7494. FaPiaoNumber: fapiao_number,
  7495. FaPiaoCode: fapiao_code,
  7496. PType: 2,
  7497. Diagnosis: diagnosis_id,
  7498. }
  7499. err = service.CreateOrder(order)
  7500. if err != nil {
  7501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7502. return
  7503. }
  7504. for _, item := range res.Output.Result {
  7505. temp := strings.Split(item.FeedetlSn, "-")
  7506. var advice_id int64 = 0
  7507. var project_id int64 = 0
  7508. var types int64 = 0
  7509. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7510. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7511. if temp[1] == "1" {
  7512. advice_id = id
  7513. project_id = 0
  7514. } else if temp[1] == "2" {
  7515. advice_id = 0
  7516. project_id = id
  7517. }
  7518. info := &models.HisOrderInfo{
  7519. OrderNumber: order.Number,
  7520. FeedetlSn: item.FeedetlSn,
  7521. UploadDate: time.Now().Unix(),
  7522. AdviceId: advice_id,
  7523. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7524. Cnt: item.Cnt,
  7525. Pric: float64(item.Pric),
  7526. PatientId: his.PatientId,
  7527. PricUplmtAmt: item.PricUplmtAmt,
  7528. SelfpayProp: item.SelfpayProp,
  7529. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7530. OverlmtAmt: item.OverlmtAmt,
  7531. PreselfpayAmt: item.PreselfpayAmt,
  7532. BasMednFlag: item.BasMednFlag,
  7533. MedChrgitmType: item.MedChrgitmType,
  7534. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7535. Status: 1,
  7536. Memo: item.Memo,
  7537. Mtime: time.Now().Unix(),
  7538. InscpScpAmt: item.InscpScpAmt,
  7539. DrtReimFlag: item.DrtReimFlag,
  7540. Ctime: time.Now().Unix(),
  7541. ListSpItemFlag: item.ListSpItemFlag,
  7542. ChldMedcFlag: item.ChldMedcFlag,
  7543. LmtUsedFlag: item.LmtUsedFlag,
  7544. ChrgitmLv: item.ChrgitmLv,
  7545. UserOrgId: adminUser.CurrentOrgId,
  7546. HisPatientId: his.ID,
  7547. OrderId: order.ID,
  7548. ProjectId: project_id,
  7549. Type: types,
  7550. }
  7551. service.CreateOrderInfo(info)
  7552. }
  7553. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7554. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7555. var total float64
  7556. for _, item := range prescriptions {
  7557. if item.Type == 1 { //药品
  7558. for _, subItem := range item.HisDoctorAdviceInfo {
  7559. total = total + (subItem.Price * subItem.PrescribingNumber)
  7560. }
  7561. }
  7562. if item.Type == 2 { //项目
  7563. for _, subItem := range item.HisPrescriptionProject {
  7564. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7565. total = total + (subItem.Price * cnt)
  7566. }
  7567. }
  7568. }
  7569. for _, item := range prescriptions {
  7570. for _, subItem := range item.HisAdditionalCharge {
  7571. total = total + (subItem.Price * float64(subItem.Count))
  7572. }
  7573. }
  7574. var allTotal string
  7575. if adminUser.CurrentOrgId == 9919 {
  7576. allTotal = fmt.Sprintf("%.4f", total)
  7577. } else {
  7578. allTotal = fmt.Sprintf("%.4f", total)
  7579. }
  7580. if res.Infcode == 0 {
  7581. var rf []*ResultFive
  7582. json.Unmarshal([]byte(his.Iinfo), &rf)
  7583. chrg_bchno := chrg_bchno
  7584. cert_no := his.Certno
  7585. var insutypes []string
  7586. var insutype string
  7587. var is390 int = 0
  7588. var is310 int = 0
  7589. for _, item := range rf {
  7590. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7591. insutypes = append(insutypes, item.Insutype)
  7592. }
  7593. }
  7594. if len(insutypes) == 1 {
  7595. insutype = insutypes[0]
  7596. } else {
  7597. for _, i := range insutypes {
  7598. if i == "390" {
  7599. is390 = 1
  7600. }
  7601. if i == "310" {
  7602. is310 = 1
  7603. }
  7604. }
  7605. }
  7606. if is390 == 1 {
  7607. insutype = "390"
  7608. }
  7609. if is310 == 1 {
  7610. insutype = "310"
  7611. }
  7612. if len(insutypes) == 0 {
  7613. insutype = "310"
  7614. }
  7615. if len(insutypes) == 2 {
  7616. insutype = strconv.FormatInt(his.SocialType, 10)
  7617. }
  7618. insutype = strconv.FormatInt(his.SocialType, 10)
  7619. //insutype = "390"
  7620. if his.IdCardType == 1 {
  7621. // cert_no = his.MedicalInsuranceNumber
  7622. cert_no = his.Certno
  7623. } else {
  7624. cert_no = his.Certno
  7625. }
  7626. var res ResultSeven
  7627. var resSeven10265 ResultSeven10265
  7628. var src_resquest string
  7629. var result2 string
  7630. var acct_used_flag string
  7631. fmt.Println("pay_way")
  7632. fmt.Println(pay_way)
  7633. fmt.Println("pay_way")
  7634. if pay_way == 4 {
  7635. acct_used_flag = "1"
  7636. } else {
  7637. acct_used_flag = "0"
  7638. }
  7639. if miConfig.MdtrtareaAdmvs == "421300" {
  7640. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7641. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7642. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7644. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7645. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7646. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7647. resp, requestErr := http.Get(api)
  7648. if requestErr != nil {
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. body, ioErr := ioutil.ReadAll(resp.Body)
  7653. if ioErr != nil {
  7654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. var respJSON map[string]interface{}
  7659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7665. result, _ := json.Marshal(respJSON)
  7666. if miConfig.Code == "H15049901371" {
  7667. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7668. utils.ErrorLog("解析失败:%v", err)
  7669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7670. return
  7671. }
  7672. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7673. res.Output = resSeven10265.Output
  7674. res.ErrMsg = resSeven10265.ErrMsg
  7675. res.Cainfo = resSeven10265.Cainfo
  7676. res.WarnMsg = resSeven10265.WarnMsg
  7677. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7678. res.Infcode = infocode
  7679. } else {
  7680. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7681. utils.ErrorLog("解析失败:%v", err)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. }
  7686. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7687. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7688. if result3101.Infcode == "0" {
  7689. if len(result3101.Output.Result) > 0 {
  7690. var errMsgs []string
  7691. for _, item := range result3101.Output.Result {
  7692. errMsgs = append(errMsgs, item.VolaCont)
  7693. }
  7694. c.ServeSuccessJSON(map[string]interface{}{
  7695. "failed_code": -10,
  7696. "msg": errMsgs,
  7697. })
  7698. return
  7699. } else {
  7700. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7701. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7702. bas := strings.Split(psn_info.CardInfo, "|")
  7703. if his.IdCardType == 1 {
  7704. cert_no = bas[2]
  7705. } else if his.IdCardType == 3 {
  7706. cert_no = his.Certno
  7707. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7708. } else if his.IdCardType == 4 {
  7709. cert_no = his.Certno
  7710. psn_info.VerifyNumber = psn_info.VerifyNumber
  7711. }
  7712. var api string
  7713. if miConfig.MdtrtareaAdmvs == "320921" {
  7714. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7715. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7716. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7717. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7718. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7719. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7720. "&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
  7721. } else {
  7722. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7723. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7724. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7725. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7726. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7727. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7728. "&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
  7729. }
  7730. resp, requestErr := http.Get(api)
  7731. if requestErr != nil {
  7732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7733. return
  7734. }
  7735. body, ioErr := ioutil.ReadAll(resp.Body)
  7736. if ioErr != nil {
  7737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. return
  7740. }
  7741. var respJSON map[string]interface{}
  7742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7745. return
  7746. }
  7747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7748. result, _ := json.Marshal(respJSON)
  7749. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7750. utils.ErrorLog("解析失败:%v", err)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7755. res.Output = resSeven10265.Output
  7756. res.ErrMsg = resSeven10265.ErrMsg
  7757. res.Cainfo = resSeven10265.Cainfo
  7758. res.WarnMsg = resSeven10265.WarnMsg
  7759. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7760. res.Infcode = infocode
  7761. }
  7762. }
  7763. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7764. var cert_no string
  7765. if his.IdCardType == 4 {
  7766. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7767. cert_no = psn_info.VerifyNumber
  7768. 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)
  7769. } else if his.IdCardType == 1 {
  7770. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7771. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7772. 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)
  7773. }
  7774. //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)
  7775. var dat map[string]interface{}
  7776. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7777. fmt.Println(dat)
  7778. } else {
  7779. fmt.Println(err)
  7780. }
  7781. saveLog(result2, src_resquest, "2207", "结算")
  7782. userJSONBytes, _ := json.Marshal(dat)
  7783. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7784. utils.ErrorLog("解析失败:%v", err)
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7789. res.Output = resSeven10265.Output
  7790. res.ErrMsg = resSeven10265.ErrMsg
  7791. res.Cainfo = resSeven10265.Cainfo
  7792. res.WarnMsg = resSeven10265.WarnMsg
  7793. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7794. res.Infcode = infocode
  7795. } else {
  7796. if miConfig.Code == "H15049901371" {
  7797. //赤峰地区国家医保医疗类别
  7798. //职工透析:医疗类别选特殊情况门诊990502
  7799. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7800. var med_type string
  7801. if his.Insutype == "390" {
  7802. if reg_type == 14 {
  7803. med_type = "9933"
  7804. } else if reg_type == 11 {
  7805. med_type = "11"
  7806. }
  7807. } else if his.Insutype == "310" {
  7808. if reg_type == 14 {
  7809. med_type = "990502"
  7810. } else if reg_type == 11 {
  7811. med_type = "11"
  7812. }
  7813. }
  7814. 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, "")
  7815. } else {
  7816. if his.IdCardType == 4 {
  7817. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7818. var token string
  7819. token = psn_info.VerifyNumber
  7820. 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)
  7821. } else {
  7822. 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, "")
  7823. }
  7824. }
  7825. //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)
  7826. var dat map[string]interface{}
  7827. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7828. fmt.Println(dat)
  7829. } else {
  7830. fmt.Println(err)
  7831. }
  7832. saveLog(result2, src_resquest, "2207", "结算")
  7833. userJSONBytes, _ := json.Marshal(dat)
  7834. if miConfig.Code == "H15049901371" {
  7835. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7836. utils.ErrorLog("解析失败:%v", err)
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7841. res.Output = resSeven10265.Output
  7842. res.ErrMsg = resSeven10265.ErrMsg
  7843. res.Cainfo = resSeven10265.Cainfo
  7844. res.WarnMsg = resSeven10265.WarnMsg
  7845. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7846. res.Infcode = infocode
  7847. } else {
  7848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7849. utils.ErrorLog("解析失败:%v", err)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. }
  7854. }
  7855. if res.Infcode != 0 {
  7856. errlog := &models.HisOrderError{
  7857. UserOrgId: adminUser.CurrentOrgId,
  7858. Ctime: time.Now().Unix(),
  7859. Mtime: time.Now().Unix(),
  7860. Number: chrg_bchno,
  7861. ErrMsg: res.ErrMsg,
  7862. Status: 1,
  7863. PatientId: id,
  7864. RecordTime: recordDateTime,
  7865. Stage: 6,
  7866. }
  7867. service.CreateErrMsgLog(errlog)
  7868. c.ServeSuccessJSON(map[string]interface{}{
  7869. "failed_code": -10,
  7870. "msg": res.ErrMsg,
  7871. })
  7872. return
  7873. } else {
  7874. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7875. order.OrderStatus = 2
  7876. order.Status = 1
  7877. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7878. order.SetlId = res.Output.Setlinfo.SetlID
  7879. order.PsnNo = res.Output.Setlinfo.PsnNo
  7880. order.PsnName = res.Output.Setlinfo.PsnName
  7881. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7882. order.Certno = res.Output.Setlinfo.Certno
  7883. order.Gend = res.Output.Setlinfo.Gend
  7884. order.Naty = res.Output.Setlinfo.Naty
  7885. order.Age = res.Output.Setlinfo.Age
  7886. order.Insutype = res.Output.Setlinfo.Insutype
  7887. order.PsnType = res.Output.Setlinfo.PsnType
  7888. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7889. order.SetlTime = res.Output.Setlinfo.SetlTime
  7890. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7891. if res.Output.Setlinfo.MedType == "140101" {
  7892. order.MedType = "14"
  7893. } else {
  7894. order.MedType = res.Output.Setlinfo.MedType
  7895. }
  7896. if reg_type == 1112 {
  7897. order.MedType = "1112"
  7898. }
  7899. if reg_type == 1111 {
  7900. order.MedType = "1111"
  7901. }
  7902. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7903. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7904. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7905. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7906. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7907. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7908. order.HifpPay = res.Output.Setlinfo.HifpPay
  7909. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7910. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7911. order.HifesPay = res.Output.Setlinfo.HifesPay
  7912. order.HifobPay = res.Output.Setlinfo.HifobPay
  7913. order.MafPay = res.Output.Setlinfo.MafPay
  7914. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7915. order.OthPay = res.Output.Setlinfo.OthPay
  7916. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7917. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7918. order.AcctPay = res.Output.Setlinfo.AcctPay
  7919. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7920. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7921. order.Balc = res.Output.Setlinfo.Balc
  7922. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7923. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7924. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7925. order.ClrType = res.Output.Setlinfo.ClrType
  7926. order.ClrWay = res.Output.Setlinfo.ClrWay
  7927. order.Creator = order.Creator
  7928. order.Modify = roles.AdminUserId
  7929. order.RequestLog = src_resquest
  7930. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7931. detailStr := string(setlDetail)
  7932. order.SetlDetail = detailStr
  7933. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7934. err = service.UpDateOrder(order)
  7935. if err == nil {
  7936. //判断是否使用了押金
  7937. if dec_way == "true" {
  7938. tmpstring := strconv.FormatInt(order.ID, 10)
  7939. order.Decimal = decimal
  7940. service.UpDateOrder(order)
  7941. //扣押金
  7942. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  7943. if errmsg != nil {
  7944. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  7945. return
  7946. }
  7947. }
  7948. c.ServeSuccessJSON(map[string]interface{}{
  7949. "msg": "结算成功",
  7950. })
  7951. } else {
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7953. return
  7954. }
  7955. }
  7956. } else {
  7957. adminUser := c.GetAdminUserInfo()
  7958. errlog := &models.HisOrderError{
  7959. UserOrgId: adminUser.CurrentOrgId,
  7960. Ctime: time.Now().Unix(),
  7961. Mtime: time.Now().Unix(),
  7962. ErrMsg: res.ErrMsg,
  7963. Status: 1,
  7964. PatientId: id,
  7965. RecordTime: recordDateTime,
  7966. Stage: 4,
  7967. }
  7968. service.CreateErrMsgLog(errlog)
  7969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7970. return
  7971. }
  7972. } else {
  7973. adminUser := c.GetAdminUserInfo()
  7974. errlog := &models.HisOrderError{
  7975. UserOrgId: adminUser.CurrentOrgId,
  7976. Ctime: time.Now().Unix(),
  7977. Mtime: time.Now().Unix(),
  7978. ErrMsg: res.ErrMsg,
  7979. Status: 1,
  7980. PatientId: id,
  7981. RecordTime: recordDateTime,
  7982. Stage: 4,
  7983. }
  7984. service.CreateErrMsgLog(errlog)
  7985. c.ServeSuccessJSON(map[string]interface{}{
  7986. "failed_code": -10,
  7987. "msg": res.ErrMsg,
  7988. })
  7989. return
  7990. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7991. //return
  7992. }
  7993. }
  7994. }
  7995. } else if tempOrder.ID > 0 {
  7996. if tempOrder.IsPre == 1 {
  7997. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  7998. var rf []*ResultFive
  7999. json.Unmarshal([]byte(his.Iinfo), &rf)
  8000. chrg_bchno := tempOrder.Number
  8001. cert_no := his.Certno
  8002. var insutypes []string
  8003. var insutype string
  8004. var is390 int = 0
  8005. var is310 int = 0
  8006. for _, item := range rf {
  8007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8008. insutypes = append(insutypes, item.Insutype)
  8009. }
  8010. }
  8011. if len(insutypes) == 1 {
  8012. insutype = insutypes[0]
  8013. } else {
  8014. for _, i := range insutypes {
  8015. if i == "390" {
  8016. is390 = 1
  8017. }
  8018. if i == "310" {
  8019. is310 = 1
  8020. }
  8021. }
  8022. }
  8023. if is390 == 1 {
  8024. insutype = "390"
  8025. }
  8026. if is310 == 1 {
  8027. insutype = "310"
  8028. }
  8029. if len(insutypes) == 0 {
  8030. insutype = "310"
  8031. }
  8032. if len(insutypes) == 2 {
  8033. insutype = strconv.FormatInt(his.SocialType, 64)
  8034. }
  8035. //insutype = "390"
  8036. if his.IdCardType == 1 {
  8037. // cert_no = his.MedicalInsuranceNumber
  8038. cert_no = his.Certno
  8039. } else {
  8040. cert_no = his.Certno
  8041. }
  8042. var res ResultSeven
  8043. var resSeven10265 ResultSeven10265
  8044. var src_resquest string
  8045. var result2 string
  8046. var acct_used_flag string
  8047. fmt.Println("pay_way")
  8048. fmt.Println(pay_way)
  8049. fmt.Println("pay_way")
  8050. if pay_way == 4 {
  8051. acct_used_flag = "1"
  8052. } else {
  8053. acct_used_flag = "0"
  8054. }
  8055. if miConfig.MdtrtareaAdmvs == "421300" {
  8056. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8057. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8058. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8059. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8060. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8061. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8062. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8063. resp, requestErr := http.Get(api)
  8064. if requestErr != nil {
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. body, ioErr := ioutil.ReadAll(resp.Body)
  8069. if ioErr != nil {
  8070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. var respJSON map[string]interface{}
  8075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8081. result, _ := json.Marshal(respJSON)
  8082. fmt.Println("log")
  8083. fmt.Println(string(result))
  8084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8085. utils.ErrorLog("解析失败:%v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8090. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8091. if result3101.Infcode == "0" {
  8092. if len(result3101.Output.Result) > 0 {
  8093. var errMsgs []string
  8094. for _, item := range result3101.Output.Result {
  8095. errMsgs = append(errMsgs, item.VolaCont)
  8096. }
  8097. c.ServeSuccessJSON(map[string]interface{}{
  8098. "failed_code": -10,
  8099. "msg": errMsgs,
  8100. })
  8101. return
  8102. } else {
  8103. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8104. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8105. bas := strings.Split(psn_info.CardInfo, "|")
  8106. if his.IdCardType == 1 {
  8107. cert_no = bas[2]
  8108. } else if his.IdCardType == 3 {
  8109. cert_no = his.Certno
  8110. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8111. } else if his.IdCardType == 4 {
  8112. cert_no = his.Certno
  8113. psn_info.VerifyNumber = psn_info.VerifyNumber
  8114. }
  8115. //江苏地区国家医保医疗类别
  8116. //职工透析:医疗类别选特殊情况门诊9933
  8117. //居民血透门慢: 医疗类别选门诊慢病1402
  8118. //var med_type string
  8119. //if his.Insutype == "310" {
  8120. // if reg_type == 14 {
  8121. // med_type = "9933"
  8122. // } else if reg_type == 11 {
  8123. // med_type = "11"
  8124. //
  8125. // }
  8126. //} else if his.Insutype == "390" {
  8127. // if reg_type == 14 {
  8128. // med_type = "1402"
  8129. // } else if reg_type == 11 {
  8130. // med_type = "11"
  8131. // }
  8132. //}
  8133. var api string
  8134. if miConfig.MdtrtareaAdmvs == "320921" {
  8135. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8141. "&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
  8142. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8143. } else {
  8144. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8145. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8146. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8147. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8149. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8150. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8151. "&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
  8152. }
  8153. resp, requestErr := http.Get(api)
  8154. if requestErr != nil {
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. body, ioErr := ioutil.ReadAll(resp.Body)
  8159. if ioErr != nil {
  8160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8162. return
  8163. }
  8164. var respJSON map[string]interface{}
  8165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8171. result, _ := json.Marshal(respJSON)
  8172. fmt.Println("log")
  8173. fmt.Println(string(result))
  8174. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8180. res.Output = resSeven10265.Output
  8181. res.ErrMsg = resSeven10265.ErrMsg
  8182. res.Cainfo = resSeven10265.Cainfo
  8183. res.WarnMsg = resSeven10265.WarnMsg
  8184. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8185. res.Infcode = infocode
  8186. }
  8187. }
  8188. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8189. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8190. var cert_no string
  8191. if his.IdCardType == 1 {
  8192. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8193. } else {
  8194. cert_no = psn_info.VerifyNumber
  8195. }
  8196. 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)
  8197. var dat map[string]interface{}
  8198. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8199. fmt.Println(dat)
  8200. } else {
  8201. fmt.Println(err)
  8202. }
  8203. saveLog(result2, src_resquest, "2207", "结算")
  8204. userJSONBytes, _ := json.Marshal(dat)
  8205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8206. utils.ErrorLog("解析失败:%v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8211. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8212. var cert_no string
  8213. if his.IdCardType == 1 {
  8214. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8215. } else if his.IdCardType == 2 {
  8216. cert_no = his.IdCardNo
  8217. } else {
  8218. cert_no = psn_info.VerifyNumber
  8219. }
  8220. 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, "")
  8221. var dat map[string]interface{}
  8222. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8223. fmt.Println(dat)
  8224. } else {
  8225. fmt.Println(err)
  8226. }
  8227. saveLog(result2, src_resquest, "2207", "结算")
  8228. userJSONBytes, _ := json.Marshal(dat)
  8229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8230. utils.ErrorLog("解析失败:%v", err)
  8231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8232. return
  8233. }
  8234. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8235. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8236. var cert_no string
  8237. if his.IdCardType == 1 {
  8238. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8239. } else if his.IdCardType == 2 {
  8240. cert_no = his.IdCardNo
  8241. } else {
  8242. cert_no = psn_info.VerifyNumber
  8243. }
  8244. 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, "")
  8245. var dat map[string]interface{}
  8246. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8247. fmt.Println(dat)
  8248. } else {
  8249. fmt.Println(err)
  8250. }
  8251. saveLog(result2, src_resquest, "2207", "结算")
  8252. userJSONBytes, _ := json.Marshal(dat)
  8253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8254. utils.ErrorLog("解析失败:%v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. } else {
  8259. var src_resquest string
  8260. if miConfig.Code == "H15049901371" {
  8261. //赤峰地区国家医保医疗类别
  8262. //职工透析:医疗类别选特殊情况门诊990502
  8263. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8264. var med_type string
  8265. if his.Insutype == "390" {
  8266. if reg_type == 14 {
  8267. med_type = "9933"
  8268. } else if reg_type == 11 {
  8269. med_type = "11"
  8270. }
  8271. } else if his.Insutype == "310" {
  8272. if reg_type == 14 {
  8273. med_type = "990502"
  8274. } else if reg_type == 11 {
  8275. med_type = "11"
  8276. }
  8277. }
  8278. 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, "")
  8279. } else {
  8280. if his.IdCardType == 4 {
  8281. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8282. token := psn_info.VerifyNumber
  8283. 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)
  8284. } else {
  8285. 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, "")
  8286. }
  8287. }
  8288. var dat map[string]interface{}
  8289. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8290. fmt.Println(dat)
  8291. } else {
  8292. fmt.Println(err)
  8293. }
  8294. saveLog(result2, src_resquest, "2207", "结算")
  8295. userJSONBytes, _ := json.Marshal(dat)
  8296. if miConfig.Code == "H15049901371" {
  8297. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8298. utils.ErrorLog("解析失败:%v", err)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8300. return
  8301. }
  8302. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8303. res.Output = resSeven10265.Output
  8304. res.ErrMsg = resSeven10265.ErrMsg
  8305. res.Cainfo = resSeven10265.Cainfo
  8306. res.WarnMsg = resSeven10265.WarnMsg
  8307. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8308. res.Infcode = infocode
  8309. } else {
  8310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8311. utils.ErrorLog("解析失败:%v", err)
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. }
  8316. }
  8317. if res.Infcode != 0 {
  8318. errlog := &models.HisOrderError{
  8319. UserOrgId: adminUser.CurrentOrgId,
  8320. Ctime: time.Now().Unix(),
  8321. Mtime: time.Now().Unix(),
  8322. Number: chrg_bchno,
  8323. ErrMsg: res.ErrMsg,
  8324. Status: 1,
  8325. PatientId: id,
  8326. RecordTime: recordDateTime,
  8327. Stage: 6,
  8328. }
  8329. service.CreateErrMsgLog(errlog)
  8330. c.ServeSuccessJSON(map[string]interface{}{
  8331. "failed_code": -10,
  8332. "msg": res.ErrMsg,
  8333. })
  8334. return
  8335. } else {
  8336. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8337. order.OrderStatus = 2
  8338. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8339. order.SetlId = res.Output.Setlinfo.SetlID
  8340. order.PsnNo = res.Output.Setlinfo.PsnNo
  8341. order.PsnName = res.Output.Setlinfo.PsnName
  8342. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8343. order.Certno = res.Output.Setlinfo.Certno
  8344. order.Gend = res.Output.Setlinfo.Gend
  8345. order.Naty = res.Output.Setlinfo.Naty
  8346. order.Age = res.Output.Setlinfo.Age
  8347. order.Insutype = res.Output.Setlinfo.Insutype
  8348. order.PsnType = res.Output.Setlinfo.PsnType
  8349. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8350. order.SetlTime = res.Output.Setlinfo.SetlTime
  8351. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8352. //order.MedType = res.Output.Setlinfo.MedType
  8353. if reg_type == 1112 {
  8354. order.MedType = "1112"
  8355. }
  8356. if reg_type == 1111 {
  8357. order.MedType = "1111"
  8358. }
  8359. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8360. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8361. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8362. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8363. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8364. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8365. order.HifpPay = res.Output.Setlinfo.HifpPay
  8366. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8367. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8368. order.HifesPay = res.Output.Setlinfo.HifesPay
  8369. order.HifobPay = res.Output.Setlinfo.HifobPay
  8370. order.MafPay = res.Output.Setlinfo.MafPay
  8371. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8372. order.OthPay = res.Output.Setlinfo.OthPay
  8373. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8374. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8375. order.AcctPay = res.Output.Setlinfo.AcctPay
  8376. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8377. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8378. order.Balc = res.Output.Setlinfo.Balc
  8379. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8380. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8381. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8382. order.ClrWay = res.Output.Setlinfo.ClrWay
  8383. order.Creator = order.Creator
  8384. order.Modify = roles.AdminUserId
  8385. order.RequestLog = src_resquest
  8386. order.Diagnosis = diagnosis_id
  8387. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8388. detailStr := string(setlDetail)
  8389. order.SetlDetail = detailStr
  8390. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8391. err = service.UpDateOrder(order)
  8392. if err == nil {
  8393. //判断是否使用了押金
  8394. if dec_way == "true" {
  8395. tmpstring := strconv.FormatInt(order.ID, 10)
  8396. //扣押金
  8397. order.Decimal = decimal
  8398. service.UpDateOrder(order)
  8399. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8400. if errmsg != nil {
  8401. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8402. return
  8403. }
  8404. }
  8405. c.ServeSuccessJSON(map[string]interface{}{
  8406. "msg": "结算成功",
  8407. })
  8408. } else {
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8410. return
  8411. }
  8412. }
  8413. }
  8414. }
  8415. }
  8416. //func (c *HisApiController) GetPreUploadInfo() {
  8417. // id, _ := c.GetInt64("id")
  8418. // record_time := c.GetString("record_time")
  8419. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8420. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8421. //
  8422. // timeLayout := "2006-01-02"
  8423. // loc, _ := time.LoadLocation("Local")
  8424. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8425. // if err != nil {
  8426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8427. // return
  8428. // }
  8429. // recordDateTime := theTime.Unix()
  8430. // adminUser := c.GetAdminUserInfo()
  8431. //
  8432. // var prescriptions []*models.HisPrescription
  8433. //
  8434. // var start_time int64
  8435. // var end_time int64
  8436. //
  8437. // data := make(map[string]interface{})
  8438. // if settle_accounts_type == 1 { //日结
  8439. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8440. // data["pre"] = prescriptions
  8441. //
  8442. // } else { //月结
  8443. // start_time_str := c.GetString("start_time")
  8444. // end_time_str := c.GetString("end_time")
  8445. // timeLayout := "2006-01-02"
  8446. // loc, _ := time.LoadLocation("Local")
  8447. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8448. // if err != nil {
  8449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8450. // return
  8451. // }
  8452. // recordStartTime := theStartTime.Unix()
  8453. // start_time = recordStartTime
  8454. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8455. // if err != nil {
  8456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8457. // return
  8458. // }
  8459. // recordEndTime := theEndTime.Unix()
  8460. // end_time = recordEndTime
  8461. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8462. // data["pre"] = prescriptions
  8463. //
  8464. // }
  8465. //
  8466. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8467. //
  8468. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8469. // timestamp := time.Now().Unix()
  8470. // tempTime := time.Unix(timestamp, 0)
  8471. // timeFormat := tempTime.Format("20060102150405")
  8472. // chrgBchno := rand.Intn(100000) + 10000
  8473. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8474. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8475. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8476. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8477. // strconv.FormatInt(his.PatientId, 10)
  8478. // client := &http.Client{}
  8479. // data["psn_no"] = his.PsnNo
  8480. // data["mdtrt_id"] = his.Number
  8481. // data["chrg_bchno"] = chrg_bchno
  8482. // data["org_name"] = miConfig.OrgName
  8483. // data["doctor"] = roles.UserName
  8484. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8485. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8486. // data["fixmedins_code"] = miConfig.Code
  8487. // data["dept_code"] = department.Number
  8488. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8489. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8490. // data["secret_key"] = miConfig.SecretKey
  8491. // var ids []int64
  8492. //
  8493. // for _, item := range prescriptions {
  8494. // ids = append(ids, item.ID)
  8495. // }
  8496. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8497. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8498. // bytesData, _ := json.Marshal(data)
  8499. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8500. // resp, _ := client.Do(req)
  8501. // defer resp.Body.Close()
  8502. // body, ioErr := ioutil.ReadAll(resp.Body)
  8503. // if ioErr != nil {
  8504. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8506. // return
  8507. // }
  8508. // var respJSON map[string]interface{}
  8509. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8510. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8512. // return
  8513. // }
  8514. //
  8515. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8516. // userJSONBytes, _ := json.Marshal(respJSON)
  8517. // var res ResultFour
  8518. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8519. // utils.ErrorLog("解析失败:%v", err)
  8520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. // return
  8522. // }
  8523. //
  8524. // if res.Infcode == 0 {
  8525. // order := &models.HisOrder{
  8526. // UserOrgId: adminUser.CurrentOrgId,
  8527. // HisPatientId: his.ID,
  8528. // PatientId: his.PatientId,
  8529. // SettleAccountsDate: recordDateTime,
  8530. // Ctime: time.Now().Unix(),
  8531. // Mtime: time.Now().Unix(),
  8532. // Status: 1,
  8533. // Number: chrg_bchno,
  8534. // Infcode: res.Infcode,
  8535. // WarnMsg: res.WarnMsg,
  8536. // Cainfo: res.Cainfo,
  8537. // ErrMsg: res.ErrMsg,
  8538. // RespondTime: res.RefmsgTime,
  8539. // InfRefmsgid: res.InfRefmsgid,
  8540. // OrderStatus: 1,
  8541. // IsMedicineInsurance: 1,
  8542. // SettleType: settle_accounts_type,
  8543. // SettleStartTime: start_time,
  8544. // SettleEndTime: end_time,
  8545. // Creator: roles.ID,
  8546. // Modify: roles.ID,
  8547. // PType: 2,
  8548. // }
  8549. // err = service.CreateOrder(order)
  8550. // if err != nil {
  8551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8552. // return
  8553. // }
  8554. //
  8555. // for _, item := range res.Output.Result {
  8556. // temp := strings.Split(item.FeedetlSn, "-")
  8557. // var advice_id int64 = 0
  8558. // var project_id int64 = 0
  8559. // var types int64 = 0
  8560. //
  8561. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8562. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8563. //
  8564. // if temp[1] == "1" {
  8565. // advice_id = id
  8566. // project_id = 0
  8567. // } else if temp[1] == "2" {
  8568. // advice_id = 0
  8569. // project_id = id
  8570. // }
  8571. //
  8572. // info := &models.HisOrderInfo{
  8573. // OrderNumber: order.Number,
  8574. // FeedetlSn: item.FeedetlSn,
  8575. // UploadDate: time.Now().Unix(),
  8576. // AdviceId: advice_id,
  8577. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8578. // Cnt: item.Cnt,
  8579. // Pric: float64(item.Pric),
  8580. // PatientId: his.PatientId,
  8581. // PricUplmtAmt: item.PricUplmtAmt,
  8582. // SelfpayProp: item.SelfpayProp,
  8583. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8584. // OverlmtAmt: item.OverlmtAmt,
  8585. // PreselfpayAmt: item.PreselfpayAmt,
  8586. // BasMednFlag: item.BasMednFlag,
  8587. // MedChrgitmType: item.MedChrgitmType,
  8588. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8589. // Status: 1,
  8590. // Memo: item.Memo,
  8591. // Mtime: time.Now().Unix(),
  8592. // InscpScpAmt: item.InscpScpAmt,
  8593. // DrtReimFlag: item.DrtReimFlag,
  8594. // Ctime: time.Now().Unix(),
  8595. // ListSpItemFlag: item.ListSpItemFlag,
  8596. // ChldMedcFlag: item.ChldMedcFlag,
  8597. // LmtUsedFlag: item.LmtUsedFlag,
  8598. // ChrgitmLv: item.ChrgitmLv,
  8599. // UserOrgId: adminUser.CurrentOrgId,
  8600. // HisPatientId: his.ID,
  8601. // OrderId: order.ID,
  8602. // ProjectId: project_id,
  8603. // Type: types,
  8604. // }
  8605. // service.CreateOrderInfo(info)
  8606. //
  8607. // }
  8608. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8609. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8610. //
  8611. // var total float64
  8612. // for _, item := range prescriptions {
  8613. // if item.Type == 1 { //药品
  8614. // for _, subItem := range item.HisDoctorAdviceInfo {
  8615. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8616. // }
  8617. // }
  8618. // if item.Type == 2 { //项目
  8619. // for _, subItem := range item.HisPrescriptionProject {
  8620. // total = total + (subItem.Price * float64(subItem.Count))
  8621. // }
  8622. // }
  8623. // }
  8624. //
  8625. // for _, item := range prescriptions {
  8626. // for _, subItem := range item.HisAdditionalCharge {
  8627. // total = total + (subItem.Price * float64(subItem.Count))
  8628. // }
  8629. // }
  8630. //
  8631. // allTotal := fmt.Sprintf("%.2f", total)
  8632. // if res.Infcode == 0 {
  8633. // var rf []*ResultFive
  8634. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8635. // psn_no := his.PsnNo
  8636. // mdtrt_id := his.Number
  8637. // chrg_bchno := chrg_bchno
  8638. // cert_no := his.Certno
  8639. // insutype := rf[0].Insutype
  8640. //
  8641. // if his.IdCardType == 1 {
  8642. // cert_no = his.MedicalInsuranceNumber
  8643. //
  8644. // } else {
  8645. //
  8646. // cert_no = his.Certno
  8647. //
  8648. // }
  8649. //
  8650. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8651. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8652. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8653. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8654. // resp, requestErr := http.Get(api)
  8655. // if requestErr != nil {
  8656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8657. // return
  8658. // }
  8659. // defer resp.Body.Close()
  8660. // body, ioErr := ioutil.ReadAll(resp.Body)
  8661. // if ioErr != nil {
  8662. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8664. // return
  8665. // }
  8666. // var respJSON map[string]interface{}
  8667. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8668. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8670. // return
  8671. // }
  8672. // fmt.Println(respJSON)
  8673. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8674. // userJSONBytes, _ := json.Marshal(respJSON)
  8675. // var res ResultSeven
  8676. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8677. // utils.ErrorLog("解析失败:%v", err)
  8678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. // return
  8680. // }
  8681. // if res.Infcode != 0 {
  8682. // errlog := &models.HisOrderError{
  8683. // UserOrgId: adminUser.CurrentOrgId,
  8684. // Ctime: time.Now().Unix(),
  8685. // Mtime: time.Now().Unix(),
  8686. // Number: chrg_bchno,
  8687. // ErrMsg: res.ErrMsg,
  8688. // Status: 1,
  8689. // PatientId: id,
  8690. // RecordTime: recordDateTime,
  8691. // Stage: 7,
  8692. // }
  8693. // service.CreateErrMsgLog(errlog)
  8694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8695. // return
  8696. // } else {
  8697. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8698. // order.OrderStatus = 1
  8699. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8700. // order.SetlId = res.Output.Setlinfo.SetlID
  8701. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8702. // order.PsnName = res.Output.Setlinfo.PsnName
  8703. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8704. // order.Certno = res.Output.Setlinfo.Certno
  8705. // order.Gend = res.Output.Setlinfo.Gend
  8706. // order.Naty = res.Output.Setlinfo.Naty
  8707. // order.Age = res.Output.Setlinfo.Age
  8708. // order.Insutype = res.Output.Setlinfo.Insutype
  8709. // order.PsnType = res.Output.Setlinfo.PsnType
  8710. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8711. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8712. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8713. // order.MedType = res.Output.Setlinfo.MedType
  8714. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8715. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8716. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8717. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8718. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8719. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8720. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8721. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8722. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8723. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8724. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8725. // order.MafPay = res.Output.Setlinfo.MafPay
  8726. // order.OthPay = res.Output.Setlinfo.OthPay
  8727. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8728. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8729. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8730. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8731. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8732. // order.Balc = res.Output.Setlinfo.Balc
  8733. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8734. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8735. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8736. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8737. // order.Creator = order.Creator
  8738. // order.Modify = roles.ID
  8739. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8740. // detailStr := string(setlDetail)
  8741. // order.SetlDetail = detailStr
  8742. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8743. // err = service.UpDateOrder(order)
  8744. // if err == nil {
  8745. // c.ServeSuccessJSON(map[string]interface{}{
  8746. // "msg": "预结算成功",
  8747. // })
  8748. // } else {
  8749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8750. // return
  8751. // }
  8752. // }
  8753. // } else {
  8754. // adminUser := c.GetAdminUserInfo()
  8755. // errlog := &models.HisOrderError{
  8756. // UserOrgId: adminUser.CurrentOrgId,
  8757. // Ctime: time.Now().Unix(),
  8758. // Mtime: time.Now().Unix(),
  8759. // ErrMsg: res.ErrMsg,
  8760. // Status: 1,
  8761. // PatientId: id,
  8762. // RecordTime: recordDateTime,
  8763. // Stage: 4,
  8764. // }
  8765. // service.CreateErrMsgLog(errlog)
  8766. //
  8767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8768. // return
  8769. // }
  8770. // } else {
  8771. // adminUser := c.GetAdminUserInfo()
  8772. // errlog := &models.HisOrderError{
  8773. // UserOrgId: adminUser.CurrentOrgId,
  8774. // Ctime: time.Now().Unix(),
  8775. // Mtime: time.Now().Unix(),
  8776. // ErrMsg: res.ErrMsg,
  8777. // Status: 1,
  8778. // PatientId: id,
  8779. // RecordTime: recordDateTime,
  8780. // Stage: 4,
  8781. // }
  8782. // service.CreateErrMsgLog(errlog)
  8783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8784. // return
  8785. // }
  8786. //
  8787. // } else {
  8788. // var total float64
  8789. // for _, item := range prescriptions {
  8790. // if item.Type == 1 { //药品
  8791. // for _, subItem := range item.HisDoctorAdviceInfo {
  8792. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8793. // }
  8794. // }
  8795. // if item.Type == 2 { //项目
  8796. // for _, subItem := range item.HisPrescriptionProject {
  8797. // total = total + (subItem.Price * float64(subItem.Count))
  8798. // }
  8799. // }
  8800. //
  8801. // for _, subItem := range item.HisAdditionalCharge {
  8802. // total = total + (subItem.Price * float64(subItem.Count))
  8803. // }
  8804. // }
  8805. //
  8806. // allTotal := fmt.Sprintf("%.2f", total)
  8807. // totals, _ := strconv.ParseFloat(allTotal, 64)
  8808. // order := &models.HisOrder{
  8809. // UserOrgId: adminUser.CurrentOrgId,
  8810. // HisPatientId: his.ID,
  8811. // PatientId: id,
  8812. // SettleAccountsDate: recordDateTime,
  8813. // Ctime: time.Now().Unix(),
  8814. // Mtime: time.Now().Unix(),
  8815. // Status: 1,
  8816. // OrderStatus: 2,
  8817. // Number: chrg_bchno,
  8818. // MedfeeSumamt: totals,
  8819. // }
  8820. // err = service.CreateOrder(order)
  8821. // if err != nil {
  8822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8823. // return
  8824. // }
  8825. //
  8826. // var customs []*Custom
  8827. // for _, item := range prescriptions {
  8828. //
  8829. // if item.Type == 1 { //药品
  8830. // for _, subItem := range item.HisDoctorAdviceInfo {
  8831. // cus := &Custom{
  8832. // AdviceId: subItem.ID,
  8833. // ProjectId: 0,
  8834. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  8835. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  8836. // FeedetlSn: subItem.FeedetlSn,
  8837. // Price: fmt.Sprintf("%.2f", subItem.Price),
  8838. // MedListCodg: subItem.MedListCodg,
  8839. // Type: 1,
  8840. // }
  8841. // customs = append(customs, cus)
  8842. // }
  8843. // }
  8844. //
  8845. // if item.Type == 2 { //项目
  8846. // for _, subItem := range item.HisPrescriptionProject {
  8847. //
  8848. // cus := &Custom{
  8849. // AdviceId: 0,
  8850. // ProjectId: subItem.ID,
  8851. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  8852. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  8853. // FeedetlSn: subItem.FeedetlSn,
  8854. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  8855. // MedListCodg: subItem.MedListCodg,
  8856. // Type: 2,
  8857. // }
  8858. //
  8859. // customs = append(customs, cus)
  8860. // }
  8861. // }
  8862. //
  8863. // for _, item := range item.HisAdditionalCharge {
  8864. // cus := &Custom{
  8865. // ItemId: item.ID,
  8866. // AdviceId: 0,
  8867. // ProjectId: 0,
  8868. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  8869. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  8870. // FeedetlSn: item.FeedetlSn,
  8871. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  8872. // MedListCodg: item.XtHisAddtionConfig.Code,
  8873. // Type: 3,
  8874. // }
  8875. //
  8876. // customs = append(customs, cus)
  8877. // }
  8878. //
  8879. // }
  8880. //
  8881. // for _, item := range customs {
  8882. // var advice_id int64 = 0
  8883. // var project_id int64 = 0
  8884. // var item_id int64 = 0
  8885. //
  8886. // var types int64 = 0
  8887. //
  8888. // if item.Type == 1 {
  8889. // advice_id = item.AdviceId
  8890. // project_id = 0
  8891. // item_id = 0
  8892. // } else if item.Type == 2 {
  8893. // advice_id = 0
  8894. // item_id = 0
  8895. //
  8896. // project_id = item.ProjectId
  8897. // } else if item.Type == 3 {
  8898. // advice_id = 0
  8899. // item_id = item.ItemId
  8900. // project_id = 0
  8901. // }
  8902. //
  8903. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  8904. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  8905. // pric, _ := strconv.ParseFloat(item.Price, 32)
  8906. //
  8907. // info := &models.HisOrderInfo{
  8908. // OrderNumber: order.Number,
  8909. // UploadDate: time.Now().Unix(),
  8910. // AdviceId: advice_id,
  8911. // DetItemFeeSumamt: detItemFeeSumamt,
  8912. // Cnt: cut,
  8913. // Pric: pric,
  8914. // PatientId: id,
  8915. // Status: 1,
  8916. // Mtime: time.Now().Unix(),
  8917. // Ctime: time.Now().Unix(),
  8918. // UserOrgId: adminUser.CurrentOrgId,
  8919. // HisPatientId: his.ID,
  8920. // OrderId: order.ID,
  8921. // ProjectId: project_id,
  8922. // Type: types,
  8923. // ItemId: item_id,
  8924. // }
  8925. // service.CreateOrderInfo(info)
  8926. // }
  8927. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8928. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8929. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  8930. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8931. // if err == nil {
  8932. // c.ServeSuccessJSON(map[string]interface{}{
  8933. // "msg": "结算成功",
  8934. // })
  8935. // } else {
  8936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8937. // return
  8938. // }
  8939. // }
  8940. //}
  8941. //上传明细-预结算-
  8942. func (c *HisApiController) GetPreUploadInfo() {
  8943. id, _ := c.GetInt64("id")
  8944. record_time := c.GetString("record_time")
  8945. his_patient_id, _ := c.GetInt64("his_patient_id")
  8946. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8947. admin_user_id, _ := c.GetInt64("admin_user_id")
  8948. diagnosis_id := c.GetString("diagnosis")
  8949. sick_type, _ := c.GetInt64("sick_type")
  8950. reg_type, _ := c.GetInt64("p_type")
  8951. begin_time := c.GetString("begin_time")
  8952. id_str := c.GetString("ids")
  8953. ids_arr := strings.Split(id_str, ",")
  8954. timeLayout := "2006-01-02"
  8955. loc, _ := time.LoadLocation("Local")
  8956. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8957. if err != nil {
  8958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8959. return
  8960. }
  8961. recordDateTime := theTime.Unix()
  8962. adminUser := c.GetAdminUserInfo()
  8963. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8964. var config []*models.HisXtDiagnoseConfig
  8965. for _, item := range diagnosis_ids {
  8966. id, _ := strconv.ParseInt(item, 10, 64)
  8967. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8968. config = append(config, &diagnosisConfig)
  8969. }
  8970. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8971. sickConfig, _ := service.FindSickById(sick_type)
  8972. var prescriptions []*models.HisPrescription
  8973. var start_time int64
  8974. var end_time int64
  8975. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8976. fmt.Println(his_patient_id)
  8977. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8978. timestamp := time.Now().Unix()
  8979. tempTime := time.Unix(timestamp, 0)
  8980. timeFormat := tempTime.Format("20060102150405")
  8981. chrgBchno := rand.Intn(100000) + 10000
  8982. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8984. var patientPrescription models.HisPrescriptionInfo
  8985. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8986. if patientPrescription.ID == 0 {
  8987. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8988. }
  8989. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8990. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8991. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8992. strconv.FormatInt(his.PatientId, 10)
  8993. var res2 ResultSix
  8994. var resSix10265 ResultSix10265
  8995. //var time_stamp string
  8996. if miConfig.MdtrtareaAdmvs == "421300" {
  8997. data := make(map[string]interface{})
  8998. client := &http.Client{}
  8999. data["psn_no"] = his.PsnNo
  9000. data["mdtrt_id"] = his.Number
  9001. data["department"] = department.Name
  9002. data["org_name"] = miConfig.OrgName
  9003. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9004. data["doctor_id"] = doctor_info.DoctorNumber
  9005. data["doctor_name"] = roles.UserName
  9006. data["fixmedins_code"] = miConfig.Code
  9007. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9008. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9009. data["secret_key"] = miConfig.SecretKey
  9010. data["sick_code"] = sickConfig.CountryCode
  9011. data["sick_name"] = sickConfig.ClassName
  9012. data["begin_time"] = begin_time
  9013. data["dept"] = strconv.FormatInt(department.ID, 10)
  9014. data["config"] = config
  9015. data["opter"] = roles.UserName
  9016. fmt.Println(data)
  9017. bytesData, _ := json.Marshal(data)
  9018. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9019. resp, _ := client.Do(req)
  9020. defer resp.Body.Close()
  9021. body, ioErr := ioutil.ReadAll(resp.Body)
  9022. if ioErr != nil {
  9023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. var respJSON map[string]interface{}
  9028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9031. return
  9032. }
  9033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9034. userJSONBytes, _ := json.Marshal(respJSON)
  9035. fmt.Println("log")
  9036. fmt.Println(string(userJSONBytes))
  9037. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9038. utils.ErrorLog("解析失败:%v", err)
  9039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9040. return
  9041. }
  9042. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9043. data := make(map[string]interface{})
  9044. client := &http.Client{}
  9045. data["psn_no"] = his.PsnNo
  9046. data["mdtrt_id"] = his.Number
  9047. data["doctor"] = roles.UserName
  9048. data["department"] = department.Name
  9049. data["org_name"] = miConfig.OrgName
  9050. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9051. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9052. data["fixmedins_code"] = miConfig.Code
  9053. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9055. data["secret_key"] = miConfig.SecretKey
  9056. data["sick_code"] = sickConfig.CountryCode
  9057. data["sick_name"] = sickConfig.ClassName
  9058. data["begin_time"] = begin_time
  9059. data["dept"] = strconv.FormatInt(department.ID, 10)
  9060. data["config"] = config
  9061. data["url"] = miConfig.Url
  9062. data["ak"] = miConfig.AccessKey
  9063. data["cainfo"] = miConfig.Cainfo
  9064. bytesData, _ := json.Marshal(data)
  9065. var req *http.Request
  9066. if miConfig.MdtrtareaAdmvs == "320921" {
  9067. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9068. } else {
  9069. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9070. }
  9071. resp, _ := client.Do(req)
  9072. defer resp.Body.Close()
  9073. body, ioErr := ioutil.ReadAll(resp.Body)
  9074. if ioErr != nil {
  9075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9077. return
  9078. }
  9079. var respJSON map[string]interface{}
  9080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9086. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9087. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9089. userJSONBytes, _ := json.Marshal(respJSON)
  9090. fmt.Println("log")
  9091. fmt.Println(string(userJSONBytes))
  9092. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9093. utils.ErrorLog("解析失败:%v", err)
  9094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9095. return
  9096. }
  9097. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9098. res2.Output = resSix10265.Output
  9099. res2.ErrMsg = resSix10265.ErrMsg
  9100. res2.Cainfo = resSix10265.Cainfo
  9101. res2.WarnMsg = resSix10265.WarnMsg
  9102. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9103. res2.Infcode = infocode
  9104. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9105. 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)
  9106. saveLog(result, requestLog, "2203", "上传就诊信息")
  9107. var respJSON2 map[string]interface{}
  9108. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9111. return
  9112. }
  9113. userJSONBytes2, _ := json.Marshal(respJSON2)
  9114. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9115. utils.ErrorLog("解析失败:%v", err)
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9120. var result string
  9121. var requestLog string
  9122. 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, "")
  9123. saveLog(result, requestLog, "2203", "上传就诊信息")
  9124. var respJSON2 map[string]interface{}
  9125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9128. return
  9129. }
  9130. userJSONBytes2, _ := json.Marshal(respJSON2)
  9131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9132. utils.ErrorLog("解析失败:%v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9137. var result string
  9138. var requestLog string
  9139. 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, "")
  9140. saveLog(result, requestLog, "2203", "上传就诊信息")
  9141. var respJSON2 map[string]interface{}
  9142. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. userJSONBytes2, _ := json.Marshal(respJSON2)
  9148. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9149. utils.ErrorLog("解析失败:%v", err)
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9151. return
  9152. }
  9153. } else {
  9154. var result string
  9155. var requestLog string
  9156. if miConfig.MdtrtareaAdmvs == "440781" { //
  9157. 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)
  9158. } else {
  9159. if miConfig.Code == "H15049901371" {
  9160. //赤峰地区国家医保医疗类别
  9161. //职工透析:医疗类别选特殊情况门诊990502
  9162. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9163. var med_type string
  9164. if his.Insutype == "390" {
  9165. if reg_type == 14 {
  9166. med_type = "9933"
  9167. } else if reg_type == 11 {
  9168. med_type = "11"
  9169. }
  9170. } else if his.Insutype == "310" {
  9171. if reg_type == 14 {
  9172. med_type = "990502"
  9173. } else if reg_type == 11 {
  9174. med_type = "11"
  9175. }
  9176. }
  9177. 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)
  9178. } else {
  9179. 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)
  9180. }
  9181. saveLog(result, requestLog, "2203", "上传就诊信息")
  9182. var respJSON2 map[string]interface{}
  9183. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9186. return
  9187. }
  9188. userJSONBytes2, _ := json.Marshal(respJSON2)
  9189. if miConfig.Code == "H15049901371" {
  9190. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9191. utils.ErrorLog("解析失败:%v", err)
  9192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9193. return
  9194. }
  9195. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9196. res2.Output = resSix10265.Output
  9197. res2.ErrMsg = resSix10265.ErrMsg
  9198. res2.Cainfo = resSix10265.Cainfo
  9199. res2.WarnMsg = resSix10265.WarnMsg
  9200. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9201. res2.Infcode = infocode
  9202. } else {
  9203. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9204. utils.ErrorLog("解析失败:%v", err)
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. }
  9209. }
  9210. }
  9211. if res2.Infcode != 0 {
  9212. adminUser := c.GetAdminUserInfo()
  9213. errlog := &models.HisOrderError{
  9214. UserOrgId: adminUser.CurrentOrgId,
  9215. Ctime: time.Now().Unix(),
  9216. Mtime: time.Now().Unix(),
  9217. ErrMsg: res2.ErrMsg,
  9218. Status: 1,
  9219. PatientId: id,
  9220. RecordTime: recordDateTime,
  9221. Stage: 3,
  9222. }
  9223. service.CreateErrMsgLog(errlog)
  9224. c.ServeSuccessJSON(map[string]interface{}{
  9225. "failed_code": -10,
  9226. "msg": res2.ErrMsg,
  9227. })
  9228. return
  9229. } else {
  9230. his.Diagnosis = diagnosis_id
  9231. his.SickType = sickConfig.ID
  9232. his.PType = fmt.Sprintf("%d", reg_type)
  9233. service.UpdateHisPatientThree(&his)
  9234. data := make(map[string]interface{})
  9235. if settle_accounts_type == 1 { //日结
  9236. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9237. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9238. } else {
  9239. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9240. }
  9241. data["pre"] = prescriptions
  9242. } else { //月结
  9243. start_time_str := c.GetString("start_time")
  9244. end_time_str := c.GetString("end_time")
  9245. timeLayout := "2006-01-02"
  9246. loc, _ := time.LoadLocation("Local")
  9247. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9248. if err != nil {
  9249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9250. return
  9251. }
  9252. recordStartTime := theStartTime.Unix()
  9253. start_time = recordStartTime
  9254. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9255. if err != nil {
  9256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9257. return
  9258. }
  9259. recordEndTime := theEndTime.Unix()
  9260. end_time = recordEndTime
  9261. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9262. data["pre"] = prescriptions
  9263. }
  9264. client := &http.Client{}
  9265. data["psn_no"] = his.PsnNo
  9266. data["mdtrt_id"] = his.Number
  9267. data["chrg_bchno"] = chrg_bchno
  9268. data["org_name"] = miConfig.OrgName
  9269. data["doctor"] = doctor_info.UserName
  9270. data["doctor_id"] = doctor_info.DoctorNumber
  9271. data["dept"] = department.Name
  9272. data["fixmedins_code"] = miConfig.Code
  9273. data["opter"] = roles.UserName
  9274. data["dept_code"] = department.Number
  9275. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9276. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9277. data["secret_key"] = miConfig.SecretKey
  9278. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9279. data["url"] = miConfig.Url
  9280. data["ak"] = miConfig.AccessKey
  9281. data["new_doctor_name"] = patientPrescription.Doctor
  9282. data["diag_code"] = sickConfig.CountryCode
  9283. data["cainfo"] = miConfig.Cainfo
  9284. data["opter"] = roles.UserName
  9285. var ids []int64
  9286. for _, item := range prescriptions {
  9287. ids = append(ids, item.ID)
  9288. }
  9289. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9290. if config.IsOpen == 1 { //对接了医保,走医保流程
  9291. var res ResultFour
  9292. var resFour10265 ResultFour10265
  9293. if miConfig.MdtrtareaAdmvs == "421300" {
  9294. bytesData, _ := json.Marshal(data)
  9295. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9296. resp, _ := client.Do(req)
  9297. defer resp.Body.Close()
  9298. body, ioErr := ioutil.ReadAll(resp.Body)
  9299. if ioErr != nil {
  9300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9302. return
  9303. }
  9304. var respJSON map[string]interface{}
  9305. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9308. return
  9309. }
  9310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9311. userJSONBytes, _ := json.Marshal(respJSON)
  9312. fmt.Println("log")
  9313. fmt.Println(string(userJSONBytes))
  9314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9315. utils.ErrorLog("解析失败:%v", err)
  9316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9317. return
  9318. }
  9319. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9320. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9321. if result3101.Infcode == "0" {
  9322. if len(result3101.Output.Result) > 0 {
  9323. var errMsgs []string
  9324. for _, item := range result3101.Output.Result {
  9325. errMsgs = append(errMsgs, item.VolaCont)
  9326. }
  9327. c.ServeSuccessJSON(map[string]interface{}{
  9328. "failed_code": -10,
  9329. "msg": errMsgs,
  9330. })
  9331. return
  9332. } else {
  9333. bytesData, _ := json.Marshal(data)
  9334. var req *http.Request
  9335. if miConfig.MdtrtareaAdmvs == "320921" {
  9336. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9337. } else {
  9338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9339. }
  9340. resp, _ := client.Do(req)
  9341. defer resp.Body.Close()
  9342. body, ioErr := ioutil.ReadAll(resp.Body)
  9343. if ioErr != nil {
  9344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. var respJSON map[string]interface{}
  9349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9355. userJSONBytes, _ := json.Marshal(respJSON)
  9356. fmt.Println("log")
  9357. fmt.Println(string(userJSONBytes))
  9358. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9359. utils.ErrorLog("解析失败:%v", err)
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. return
  9362. }
  9363. res.InfRefmsgid = resFour10265.InfRefmsgid
  9364. res.Output = resFour10265.Output
  9365. res.ErrMsg = resFour10265.ErrMsg
  9366. res.Cainfo = resFour10265.Cainfo
  9367. res.WarnMsg = resFour10265.WarnMsg
  9368. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9369. res.Infcode = infocode
  9370. }
  9371. }
  9372. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9373. 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)
  9374. var dat map[string]interface{}
  9375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9376. fmt.Println(dat)
  9377. } else {
  9378. fmt.Println(err)
  9379. }
  9380. saveLog(result, request_log, "2204", "上传费用明细")
  9381. userJSONBytes, _ := json.Marshal(dat)
  9382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9383. utils.ErrorLog("解析失败:%v", err)
  9384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9385. return
  9386. }
  9387. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9388. 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, "", "")
  9389. var dat map[string]interface{}
  9390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9391. fmt.Println(dat)
  9392. } else {
  9393. fmt.Println(err)
  9394. }
  9395. saveLog(result, request_log, "2204", "上传费用明细")
  9396. userJSONBytes, _ := json.Marshal(dat)
  9397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9398. utils.ErrorLog("解析失败:%v", err)
  9399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9400. return
  9401. }
  9402. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9403. 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, "", "")
  9404. var dat map[string]interface{}
  9405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9406. fmt.Println(dat)
  9407. } else {
  9408. fmt.Println(err)
  9409. }
  9410. saveLog(result, request_log, "2204", "上传费用明细")
  9411. userJSONBytes, _ := json.Marshal(dat)
  9412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9413. utils.ErrorLog("解析失败:%v", err)
  9414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9415. return
  9416. }
  9417. } else {
  9418. if miConfig.Code == "H15049901371" {
  9419. 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)
  9420. var dat map[string]interface{}
  9421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9422. fmt.Println(dat)
  9423. } else {
  9424. fmt.Println(err)
  9425. }
  9426. saveLog(result, request_log, "2204", "上传费用明细")
  9427. userJSONBytes, _ := json.Marshal(dat)
  9428. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9429. utils.ErrorLog("解析失败:%v", err)
  9430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9431. return
  9432. }
  9433. res.InfRefmsgid = resFour10265.InfRefmsgid
  9434. res.Output = resFour10265.Output
  9435. res.ErrMsg = resFour10265.ErrMsg
  9436. res.Cainfo = resFour10265.Cainfo
  9437. res.WarnMsg = resFour10265.WarnMsg
  9438. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9439. res.Infcode = infocode
  9440. } else {
  9441. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  9442. var dat map[string]interface{}
  9443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9444. fmt.Println(dat)
  9445. } else {
  9446. fmt.Println(err)
  9447. }
  9448. saveLog(result, request_log, "2204", "上传费用明细")
  9449. userJSONBytes, _ := json.Marshal(dat)
  9450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9451. utils.ErrorLog("解析失败:%v", err)
  9452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9453. return
  9454. }
  9455. }
  9456. }
  9457. if res.Infcode == 0 {
  9458. order := &models.HisOrder{
  9459. UserOrgId: adminUser.CurrentOrgId,
  9460. HisPatientId: his.ID,
  9461. PatientId: his.PatientId,
  9462. SettleAccountsDate: recordDateTime,
  9463. Ctime: time.Now().Unix(),
  9464. Mtime: time.Now().Unix(),
  9465. MdtrtId: his.Number,
  9466. PsnNo: his.PsnNo,
  9467. MedType: strconv.FormatInt(reg_type, 10),
  9468. Status: 1,
  9469. Number: chrg_bchno,
  9470. Infcode: res.Infcode,
  9471. WarnMsg: res.WarnMsg,
  9472. Cainfo: res.Cainfo,
  9473. ErrMsg: res.ErrMsg,
  9474. RespondTime: res.RefmsgTime,
  9475. InfRefmsgid: res.InfRefmsgid,
  9476. OrderStatus: 1,
  9477. IsMedicineInsurance: 1,
  9478. SettleType: settle_accounts_type,
  9479. SettleStartTime: start_time,
  9480. SettleEndTime: end_time,
  9481. Creator: roles.AdminUserId,
  9482. Modify: roles.AdminUserId,
  9483. PType: 2,
  9484. Diagnosis: diagnosis_id,
  9485. }
  9486. err = service.CreateOrder(order)
  9487. if err != nil {
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9489. return
  9490. }
  9491. for _, item := range res.Output.Result {
  9492. temp := strings.Split(item.FeedetlSn, "-")
  9493. var advice_id int64 = 0
  9494. var project_id int64 = 0
  9495. var types int64 = 0
  9496. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9497. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9498. if temp[1] == "1" {
  9499. advice_id = id
  9500. project_id = 0
  9501. } else if temp[1] == "2" {
  9502. advice_id = 0
  9503. project_id = id
  9504. }
  9505. info := &models.HisOrderInfo{
  9506. OrderNumber: order.Number,
  9507. FeedetlSn: item.FeedetlSn,
  9508. UploadDate: time.Now().Unix(),
  9509. AdviceId: advice_id,
  9510. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9511. Cnt: item.Cnt,
  9512. Pric: float64(item.Pric),
  9513. PatientId: his.PatientId,
  9514. PricUplmtAmt: item.PricUplmtAmt,
  9515. SelfpayProp: item.SelfpayProp,
  9516. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9517. OverlmtAmt: item.OverlmtAmt,
  9518. PreselfpayAmt: item.PreselfpayAmt,
  9519. BasMednFlag: item.BasMednFlag,
  9520. MedChrgitmType: item.MedChrgitmType,
  9521. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9522. Status: 1,
  9523. Memo: item.Memo,
  9524. Mtime: time.Now().Unix(),
  9525. InscpScpAmt: item.InscpScpAmt,
  9526. DrtReimFlag: item.DrtReimFlag,
  9527. Ctime: time.Now().Unix(),
  9528. ListSpItemFlag: item.ListSpItemFlag,
  9529. ChldMedcFlag: item.ChldMedcFlag,
  9530. LmtUsedFlag: item.LmtUsedFlag,
  9531. ChrgitmLv: item.ChrgitmLv,
  9532. UserOrgId: adminUser.CurrentOrgId,
  9533. HisPatientId: his.ID,
  9534. OrderId: order.ID,
  9535. ProjectId: project_id,
  9536. Type: types,
  9537. }
  9538. service.CreateOrderInfo(info)
  9539. }
  9540. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9541. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9542. var total float64
  9543. for _, item := range prescriptions {
  9544. if item.Type == 1 { //药品
  9545. for _, subItem := range item.HisDoctorAdviceInfo {
  9546. total = total + (subItem.Price * subItem.PrescribingNumber)
  9547. }
  9548. }
  9549. if item.Type == 2 { //项目
  9550. for _, subItem := range item.HisPrescriptionProject {
  9551. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9552. total = total + (subItem.Price * cnt)
  9553. }
  9554. }
  9555. }
  9556. for _, item := range prescriptions {
  9557. for _, subItem := range item.HisAdditionalCharge {
  9558. total = total + (subItem.Price * float64(subItem.Count))
  9559. }
  9560. }
  9561. allTotal := fmt.Sprintf("%.4f", total)
  9562. if res.Infcode == 0 {
  9563. var rf []*ResultFive
  9564. json.Unmarshal([]byte(his.Iinfo), &rf)
  9565. chrg_bchno := chrg_bchno
  9566. cert_no := his.Certno
  9567. var insutypes []string
  9568. var insutype string
  9569. var is390 int = 0
  9570. var is310 int = 0
  9571. for _, item := range rf {
  9572. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9573. insutypes = append(insutypes, item.Insutype)
  9574. }
  9575. }
  9576. if len(insutypes) == 1 {
  9577. insutype = insutypes[0]
  9578. } else {
  9579. for _, i := range insutypes {
  9580. if i == "390" {
  9581. is390 = 1
  9582. }
  9583. if i == "310" {
  9584. is310 = 1
  9585. }
  9586. }
  9587. }
  9588. if is390 == 1 {
  9589. insutype = "390"
  9590. }
  9591. if is310 == 1 {
  9592. insutype = "310"
  9593. }
  9594. if len(insutypes) == 0 {
  9595. insutype = "310"
  9596. }
  9597. if len(insutypes) == 2 {
  9598. insutype = strconv.FormatInt(his.SocialType, 64)
  9599. }
  9600. //insutype = "390"
  9601. if his.IdCardType == 1 {
  9602. cert_no = his.MedicalInsuranceNumber
  9603. } else {
  9604. cert_no = his.Certno
  9605. }
  9606. var res ResultSeven
  9607. var resSeven10265 ResultSeven10265
  9608. if miConfig.MdtrtareaAdmvs == "421300" {
  9609. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9615. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9616. resp, requestErr := http.Get(api)
  9617. if requestErr != nil {
  9618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9619. return
  9620. }
  9621. body, ioErr := ioutil.ReadAll(resp.Body)
  9622. if ioErr != nil {
  9623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9625. return
  9626. }
  9627. var respJSON map[string]interface{}
  9628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9631. return
  9632. }
  9633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9634. result, _ := json.Marshal(respJSON)
  9635. fmt.Println("log")
  9636. fmt.Println(string(result))
  9637. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9638. utils.ErrorLog("解析失败:%v", err)
  9639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9640. return
  9641. }
  9642. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9643. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9644. if result3101.Infcode == "0" {
  9645. if len(result3101.Output.Result) > 0 {
  9646. var errMsgs []string
  9647. for _, item := range result3101.Output.Result {
  9648. errMsgs = append(errMsgs, item.VolaCont)
  9649. }
  9650. c.ServeSuccessJSON(map[string]interface{}{
  9651. "failed_code": -10,
  9652. "msg": errMsgs,
  9653. })
  9654. return
  9655. } else {
  9656. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9657. if his.IdCardType != 4 {
  9658. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9659. bas := strings.Split(psn_info.CardInfo, "|")
  9660. if his.IdCardType == 1 {
  9661. cert_no = bas[2]
  9662. } else {
  9663. cert_no = bas[1]
  9664. }
  9665. } else {
  9666. cert_no = his.Certno
  9667. }
  9668. //江苏地区国家医保医疗类别
  9669. //职工透析:医疗类别选特殊情况门诊9933
  9670. //居民血透门慢: 医疗类别选门诊慢病1402
  9671. //var med_type string
  9672. //if his.Insutype == "310" {
  9673. // if reg_type == 14 {
  9674. // med_type = "9933"
  9675. // } else if reg_type == 11 {
  9676. // med_type = "11"
  9677. //
  9678. // }
  9679. //} else if his.Insutype == "390" {
  9680. // if reg_type == 14 {
  9681. // med_type = "1402"
  9682. // } else if reg_type == 11 {
  9683. // med_type = "11"
  9684. // }
  9685. //}
  9686. var api string
  9687. if miConfig.MdtrtareaAdmvs == "320921" {
  9688. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9689. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9690. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9692. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9693. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9694. "&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
  9695. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9696. } else {
  9697. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9698. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9699. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9700. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9702. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9703. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9704. "&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
  9705. }
  9706. resp, requestErr := http.Get(api)
  9707. if requestErr != nil {
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9709. return
  9710. }
  9711. body, ioErr := ioutil.ReadAll(resp.Body)
  9712. if ioErr != nil {
  9713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9715. return
  9716. }
  9717. var respJSON map[string]interface{}
  9718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9721. return
  9722. }
  9723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9724. result, _ := json.Marshal(respJSON)
  9725. fmt.Println("log")
  9726. fmt.Println(string(result))
  9727. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9728. utils.ErrorLog("解析失败:%v", err)
  9729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9730. return
  9731. }
  9732. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9733. res.Output = resSeven10265.Output
  9734. res.ErrMsg = resSeven10265.ErrMsg
  9735. res.Cainfo = resSeven10265.Cainfo
  9736. res.WarnMsg = resSeven10265.WarnMsg
  9737. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9738. res.Infcode = infocode
  9739. }
  9740. }
  9741. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9742. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9743. var result string
  9744. var request_log string
  9745. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  9746. 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)
  9747. } else {
  9748. 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)
  9749. }
  9750. var dat map[string]interface{}
  9751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9752. fmt.Println(dat)
  9753. } else {
  9754. fmt.Println(err)
  9755. }
  9756. saveLog(result, request_log, "2206", "预结算")
  9757. userJSONBytes, _ := json.Marshal(dat)
  9758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9759. utils.ErrorLog("解析失败:%v", err)
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9761. return
  9762. }
  9763. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9764. var result string
  9765. var request_log string
  9766. if his.IdCardType == 2 {
  9767. 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, "")
  9768. } else if his.IdCardType == 1 {
  9769. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9770. bas := strings.Split(psn_info.CardInfo, "|")
  9771. basNumber := bas[2]
  9772. card_sn := bas[3]
  9773. 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)
  9774. } else {
  9775. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9776. 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, "")
  9777. }
  9778. var dat map[string]interface{}
  9779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9780. fmt.Println(dat)
  9781. } else {
  9782. fmt.Println(err)
  9783. }
  9784. saveLog(result, request_log, "2206", "预结算")
  9785. userJSONBytes, _ := json.Marshal(dat)
  9786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9787. utils.ErrorLog("解析失败:%v", err)
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. return
  9790. }
  9791. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9792. var result string
  9793. var request_log string
  9794. if his.IdCardType == 2 {
  9795. 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, "")
  9796. } else if his.IdCardType == 1 {
  9797. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9798. bas := strings.Split(psn_info.CardInfo, "|")
  9799. basNumber := bas[2]
  9800. card_sn := bas[3]
  9801. 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)
  9802. } else {
  9803. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9804. 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, "")
  9805. }
  9806. var dat map[string]interface{}
  9807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9808. fmt.Println(dat)
  9809. } else {
  9810. fmt.Println(err)
  9811. }
  9812. saveLog(result, request_log, "2206", "预结算")
  9813. userJSONBytes, _ := json.Marshal(dat)
  9814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9815. utils.ErrorLog("解析失败:%v", err)
  9816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9817. return
  9818. }
  9819. } else {
  9820. var result string
  9821. var request_log string
  9822. if miConfig.Code == "H15049901371" {
  9823. //赤峰地区国家医保医疗类别
  9824. //职工透析:医疗类别选特殊情况门诊990502
  9825. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9826. var med_type string
  9827. if his.Insutype == "390" {
  9828. if reg_type == 14 {
  9829. med_type = "9933"
  9830. } else if reg_type == 11 {
  9831. med_type = "11"
  9832. }
  9833. } else if his.Insutype == "310" {
  9834. if reg_type == 14 {
  9835. med_type = "990502"
  9836. } else if reg_type == 11 {
  9837. med_type = "11"
  9838. }
  9839. }
  9840. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  9841. } else {
  9842. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9843. if his.IdCardType == 4 {
  9844. 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)
  9845. } else {
  9846. 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)
  9847. }
  9848. }
  9849. var dat map[string]interface{}
  9850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9851. fmt.Println(dat)
  9852. } else {
  9853. fmt.Println(err)
  9854. }
  9855. saveLog(result, request_log, "2206", "预结算")
  9856. //userJSONBytes, _ := json.Marshal(dat)
  9857. //
  9858. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9859. // utils.ErrorLog("解析失败:%v", err)
  9860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9861. // return
  9862. //}
  9863. userJSONBytes, _ := json.Marshal(dat)
  9864. if miConfig.Code == "H15049901371" {
  9865. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9866. utils.ErrorLog("解析失败:%v", err)
  9867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9868. return
  9869. }
  9870. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9871. res.Output = resSeven10265.Output
  9872. res.ErrMsg = resSeven10265.ErrMsg
  9873. res.Cainfo = resSeven10265.Cainfo
  9874. res.WarnMsg = resSeven10265.WarnMsg
  9875. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9876. res.Infcode = infocode
  9877. } else {
  9878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9879. utils.ErrorLog("解析失败:%v", err)
  9880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9881. return
  9882. }
  9883. }
  9884. }
  9885. if res.Infcode != 0 {
  9886. errlog := &models.HisOrderError{
  9887. UserOrgId: adminUser.CurrentOrgId,
  9888. Ctime: time.Now().Unix(),
  9889. Mtime: time.Now().Unix(),
  9890. Number: chrg_bchno,
  9891. ErrMsg: res.ErrMsg,
  9892. Status: 1,
  9893. PatientId: id,
  9894. RecordTime: recordDateTime,
  9895. Stage: 20,
  9896. }
  9897. service.CreateErrMsgLog(errlog)
  9898. c.ServeSuccessJSON(map[string]interface{}{
  9899. "failed_code": -10,
  9900. "msg": res.ErrMsg,
  9901. })
  9902. return
  9903. } else {
  9904. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9905. order.OrderStatus = 1
  9906. order.IsPre = 1
  9907. order.Status = 1
  9908. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9909. order.SetlId = res.Output.Setlinfo.SetlID
  9910. order.PsnNo = res.Output.Setlinfo.PsnNo
  9911. order.PsnName = res.Output.Setlinfo.PsnName
  9912. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9913. order.Certno = res.Output.Setlinfo.Certno
  9914. order.Gend = res.Output.Setlinfo.Gend
  9915. order.Naty = res.Output.Setlinfo.Naty
  9916. order.Age = res.Output.Setlinfo.Age
  9917. order.Insutype = res.Output.Setlinfo.Insutype
  9918. order.PsnType = res.Output.Setlinfo.PsnType
  9919. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9920. order.SetlTime = res.Output.Setlinfo.SetlTime
  9921. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9922. if res.Output.Setlinfo.MedType == "140101" {
  9923. order.MedType = "14"
  9924. } else {
  9925. order.MedType = res.Output.Setlinfo.MedType
  9926. }
  9927. if reg_type == 1112 {
  9928. order.MedType = "1112"
  9929. }
  9930. if reg_type == 1111 {
  9931. order.MedType = "1111"
  9932. }
  9933. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9934. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9935. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9936. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9937. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9938. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9939. order.HifpPay = res.Output.Setlinfo.HifpPay
  9940. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9941. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9942. order.HifesPay = res.Output.Setlinfo.HifesPay
  9943. order.HifobPay = res.Output.Setlinfo.HifobPay
  9944. order.MafPay = res.Output.Setlinfo.MafPay
  9945. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9946. order.OthPay = res.Output.Setlinfo.OthPay
  9947. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9948. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9949. order.AcctPay = res.Output.Setlinfo.AcctPay
  9950. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9951. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9952. order.Balc = res.Output.Setlinfo.Balc
  9953. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9954. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9955. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9956. order.ClrWay = res.Output.Setlinfo.ClrWay
  9957. order.Creator = order.Creator
  9958. order.Modify = roles.AdminUserId
  9959. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9960. detailStr := string(setlDetail)
  9961. order.SetlDetail = detailStr
  9962. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9963. err = service.UpDateOrder(order)
  9964. if err == nil {
  9965. c.ServeSuccessJSON(map[string]interface{}{
  9966. "msg": "预结算成功",
  9967. })
  9968. } else {
  9969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9970. return
  9971. }
  9972. }
  9973. } else {
  9974. adminUser := c.GetAdminUserInfo()
  9975. errlog := &models.HisOrderError{
  9976. UserOrgId: adminUser.CurrentOrgId,
  9977. Ctime: time.Now().Unix(),
  9978. Mtime: time.Now().Unix(),
  9979. ErrMsg: res.ErrMsg,
  9980. Status: 1,
  9981. PatientId: id,
  9982. RecordTime: recordDateTime,
  9983. Stage: 4,
  9984. }
  9985. service.CreateErrMsgLog(errlog)
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9987. return
  9988. }
  9989. } else {
  9990. adminUser := c.GetAdminUserInfo()
  9991. errlog := &models.HisOrderError{
  9992. UserOrgId: adminUser.CurrentOrgId,
  9993. Ctime: time.Now().Unix(),
  9994. Mtime: time.Now().Unix(),
  9995. ErrMsg: res.ErrMsg,
  9996. Status: 1,
  9997. PatientId: id,
  9998. RecordTime: recordDateTime,
  9999. Stage: 4,
  10000. }
  10001. service.CreateErrMsgLog(errlog)
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "failed_code": -10,
  10004. "msg": res.ErrMsg,
  10005. })
  10006. return
  10007. }
  10008. }
  10009. }
  10010. }
  10011. //退款
  10012. func (c *HisApiController) Refund() {
  10013. order_id, _ := c.GetInt64("order_id")
  10014. admin_user_id, _ := c.GetInt64("admin_user_id")
  10015. adminUser := c.GetAdminUserInfo()
  10016. var order models.HisOrder
  10017. order, _ = service.GetHisOrderByID(order_id)
  10018. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10019. if order.ID == 0 {
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10021. return
  10022. }
  10023. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10024. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10025. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10026. if config.IsOpen == 1 { //对接了医保,走医保流程
  10027. var res ResultSixteen
  10028. var resSixteen10265 ResultSixteen10265
  10029. var src_resquest string
  10030. var result string
  10031. if miConfig.MdtrtareaAdmvs == "421300" {
  10032. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10033. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10035. resp3, requestErr3 := http.Get(api3)
  10036. if requestErr3 != nil {
  10037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10038. return
  10039. }
  10040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10041. if ioErr3 != nil {
  10042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return
  10045. }
  10046. var respJSON3 map[string]interface{}
  10047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10050. return
  10051. }
  10052. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10053. userJSONBytes3, _ := json.Marshal(respJSON3)
  10054. fmt.Println("log")
  10055. fmt.Println(string(userJSONBytes3))
  10056. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10057. utils.ErrorLog("解析失败:%v", err)
  10058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10059. return
  10060. }
  10061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10062. var api3 string
  10063. if miConfig.MdtrtareaAdmvs == "320921" {
  10064. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10065. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10067. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10068. } else {
  10069. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10070. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10071. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10072. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10073. }
  10074. resp3, requestErr3 := http.Get(api3)
  10075. if requestErr3 != nil {
  10076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10077. return
  10078. }
  10079. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10080. if ioErr3 != nil {
  10081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10083. return
  10084. }
  10085. var respJSON3 map[string]interface{}
  10086. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10092. userJSONBytes3, _ := json.Marshal(respJSON3)
  10093. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10099. res.Output = resSixteen10265.Output
  10100. res.ErrMsg = resSixteen10265.ErrMsg
  10101. res.Cainfo = resSixteen10265.Cainfo
  10102. res.WarnMsg = resSixteen10265.WarnMsg
  10103. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10104. res.Infcode = infocode
  10105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10106. 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)
  10107. var dat map[string]interface{}
  10108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10109. fmt.Println(dat)
  10110. } else {
  10111. fmt.Println(err)
  10112. }
  10113. saveLog(result, src_resquest, "2208", "退费")
  10114. userJSONBytes, _ := json.Marshal(dat)
  10115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10116. utils.ErrorLog("解析失败:%v", err)
  10117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10118. return
  10119. }
  10120. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10121. 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, "")
  10122. var dat map[string]interface{}
  10123. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10124. fmt.Println(dat)
  10125. } else {
  10126. fmt.Println(err)
  10127. }
  10128. saveLog(result, src_resquest, "2208", "退费")
  10129. userJSONBytes, _ := json.Marshal(dat)
  10130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10131. utils.ErrorLog("解析失败:%v", err)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10136. 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, "")
  10137. var dat map[string]interface{}
  10138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10139. fmt.Println(dat)
  10140. } else {
  10141. fmt.Println(err)
  10142. }
  10143. saveLog(result, src_resquest, "2208", "退费")
  10144. userJSONBytes, _ := json.Marshal(dat)
  10145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10146. utils.ErrorLog("解析失败:%v", err)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. } else {
  10151. if miConfig.Code == "H15049901371" {
  10152. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10153. var dat map[string]interface{}
  10154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10155. fmt.Println(dat)
  10156. } else {
  10157. fmt.Println(err)
  10158. }
  10159. saveLog(result, src_resquest, "2208", "退费")
  10160. userJSONBytes, _ := json.Marshal(dat)
  10161. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10167. res.Output = resSixteen10265.Output
  10168. res.ErrMsg = resSixteen10265.ErrMsg
  10169. res.Cainfo = resSixteen10265.Cainfo
  10170. res.WarnMsg = resSixteen10265.WarnMsg
  10171. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10172. res.Infcode = infocode
  10173. } else {
  10174. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10175. var dat map[string]interface{}
  10176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10177. fmt.Println(dat)
  10178. } else {
  10179. fmt.Println(err)
  10180. }
  10181. saveLog(result, src_resquest, "2208", "退费")
  10182. userJSONBytes, _ := json.Marshal(dat)
  10183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10184. utils.ErrorLog("解析失败:%v", err)
  10185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10186. return
  10187. }
  10188. }
  10189. }
  10190. if res.Infcode == 0 {
  10191. var res2 ResultSix
  10192. var resSix10265 ResultSix10265
  10193. if miConfig.MdtrtareaAdmvs == "421300" {
  10194. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10195. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10196. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10197. resp3, requestErr3 := http.Get(api3)
  10198. if requestErr3 != nil {
  10199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10200. return
  10201. }
  10202. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10203. if ioErr3 != nil {
  10204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10206. return
  10207. }
  10208. var respJSON3 map[string]interface{}
  10209. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10212. return
  10213. }
  10214. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10215. userJSONBytes3, _ := json.Marshal(respJSON3)
  10216. fmt.Println("log")
  10217. fmt.Println(string(userJSONBytes3))
  10218. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10219. utils.ErrorLog("解析失败:%v", err)
  10220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10221. return
  10222. }
  10223. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10224. var api3 string
  10225. if miConfig.MdtrtareaAdmvs == "320921" {
  10226. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10227. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10228. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10229. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10230. } else {
  10231. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10232. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10233. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10234. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10235. }
  10236. resp3, requestErr3 := http.Get(api3)
  10237. if requestErr3 != nil {
  10238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10239. return
  10240. }
  10241. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10242. if ioErr3 != nil {
  10243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10245. return
  10246. }
  10247. var respJSON3 map[string]interface{}
  10248. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10251. return
  10252. }
  10253. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10254. userJSONBytes3, _ := json.Marshal(respJSON3)
  10255. fmt.Println("log")
  10256. fmt.Println(string(userJSONBytes3))
  10257. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10263. res2.Output = resSix10265.Output
  10264. res2.ErrMsg = resSix10265.ErrMsg
  10265. res2.Cainfo = resSix10265.Cainfo
  10266. res2.WarnMsg = resSix10265.WarnMsg
  10267. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10268. res2.Infcode = infocode
  10269. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10270. 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)
  10271. var dat map[string]interface{}
  10272. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10273. fmt.Println(dat)
  10274. } else {
  10275. fmt.Println(err)
  10276. }
  10277. saveLog(result2, src_request, "2205", "撤销明细")
  10278. userJSONBytes, _ := json.Marshal(dat)
  10279. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10280. utils.ErrorLog("解析失败:%v", err)
  10281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10282. return
  10283. }
  10284. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10285. 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, "")
  10286. var dat map[string]interface{}
  10287. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10288. fmt.Println(dat)
  10289. } else {
  10290. fmt.Println(err)
  10291. }
  10292. saveLog(result2, src_request, "2205", "撤销明细")
  10293. userJSONBytes, _ := json.Marshal(dat)
  10294. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10295. utils.ErrorLog("解析失败:%v", err)
  10296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10297. return
  10298. }
  10299. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10300. 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, "")
  10301. var dat map[string]interface{}
  10302. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10303. fmt.Println(dat)
  10304. } else {
  10305. fmt.Println(err)
  10306. }
  10307. saveLog(result2, src_request, "2205", "撤销明细")
  10308. userJSONBytes, _ := json.Marshal(dat)
  10309. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. } else {
  10315. if miConfig.Code == "H15049901371" {
  10316. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10317. var dat map[string]interface{}
  10318. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10319. fmt.Println(dat)
  10320. } else {
  10321. fmt.Println(err)
  10322. }
  10323. saveLog(result2, src_request, "2205", "撤销明细")
  10324. userJSONBytes, _ := json.Marshal(dat)
  10325. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10326. utils.ErrorLog("解析失败:%v", err)
  10327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10328. return
  10329. }
  10330. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10331. res2.Output = resSix10265.Output
  10332. res2.ErrMsg = resSix10265.ErrMsg
  10333. res2.Cainfo = resSix10265.Cainfo
  10334. res2.WarnMsg = resSix10265.WarnMsg
  10335. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10336. res2.Infcode = infocode
  10337. } else {
  10338. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10339. var dat map[string]interface{}
  10340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10341. fmt.Println(dat)
  10342. } else {
  10343. fmt.Println(err)
  10344. }
  10345. saveLog(result2, src_request, "2205", "撤销明细")
  10346. userJSONBytes, _ := json.Marshal(dat)
  10347. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10348. utils.ErrorLog("解析失败:%v", err)
  10349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10350. return
  10351. }
  10352. }
  10353. }
  10354. if res2.Infcode == 0 {
  10355. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10356. if err == nil {
  10357. //当押金不为零时产生退费记录
  10358. if order.Decimal != 0 {
  10359. tmp := strconv.FormatInt(order.ID, 10)
  10360. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10361. if err != nil {
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10363. return
  10364. }
  10365. }
  10366. c.ServeSuccessJSON(map[string]interface{}{
  10367. "msg": "退费成功",
  10368. })
  10369. } else {
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. } else {
  10374. c.ServeSuccessJSON(map[string]interface{}{
  10375. "code": -10,
  10376. "msg": res2.ErrMsg,
  10377. })
  10378. }
  10379. } else {
  10380. c.ServeSuccessJSON(map[string]interface{}{
  10381. "code": -10,
  10382. "msg": res.ErrMsg,
  10383. })
  10384. }
  10385. }
  10386. }
  10387. func (c *HisApiController) RefundNumber() {
  10388. record_time := c.GetString("record_time")
  10389. //patient_id, _ := c.GetInt64("patient_id")
  10390. admin_user_id, _ := c.GetInt64("admin_user_id")
  10391. his_patient_id, _ := c.GetInt64("id")
  10392. timeLayout := "2006-01-02"
  10393. loc, _ := time.LoadLocation("Local")
  10394. adminUser := c.GetAdminUserInfo()
  10395. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10396. fmt.Println(err)
  10397. if err != nil {
  10398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10399. return
  10400. }
  10401. recordDateTime := theTime.Unix()
  10402. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10403. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10404. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10405. //order, _ := service.GetHisOrderByID(order_id)
  10406. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10407. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10408. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10409. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10410. if count > 0 {
  10411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10412. return
  10413. }
  10414. if config.IsOpen == 1 { //对接了医保,走医保流程
  10415. var res2 ResultSix
  10416. var resSix10265 ResultSix10265
  10417. if miConfig.MdtrtareaAdmvs == "421300" {
  10418. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10419. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10420. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10421. resp3, requestErr3 := http.Get(api3)
  10422. if requestErr3 != nil {
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10427. if ioErr3 != nil {
  10428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10430. return
  10431. }
  10432. var respJSON3 map[string]interface{}
  10433. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10436. return
  10437. }
  10438. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10439. userJSONBytes3, _ := json.Marshal(respJSON3)
  10440. fmt.Println("log")
  10441. fmt.Println(string(userJSONBytes3))
  10442. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10443. utils.ErrorLog("解析失败:%v", err)
  10444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10445. return
  10446. }
  10447. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10448. var api3 string
  10449. if miConfig.MdtrtareaAdmvs == "320921" {
  10450. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10451. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10452. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10453. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10454. } else {
  10455. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10456. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10457. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10459. }
  10460. resp3, requestErr3 := http.Get(api3)
  10461. if requestErr3 != nil {
  10462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10463. return
  10464. }
  10465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10466. if ioErr3 != nil {
  10467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10469. return
  10470. }
  10471. var respJSON3 map[string]interface{}
  10472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return
  10476. }
  10477. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10478. userJSONBytes3, _ := json.Marshal(respJSON3)
  10479. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10480. utils.ErrorLog("解析失败:%v", err)
  10481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10482. return
  10483. }
  10484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10485. res2.Output = resSix10265.Output
  10486. res2.ErrMsg = resSix10265.ErrMsg
  10487. res2.Cainfo = resSix10265.Cainfo
  10488. res2.WarnMsg = resSix10265.WarnMsg
  10489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10490. res2.Infcode = infocode
  10491. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10492. 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)
  10493. var dat map[string]interface{}
  10494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10495. fmt.Println(dat)
  10496. } else {
  10497. fmt.Println(err)
  10498. }
  10499. saveLog(result, request, "2202", "退号")
  10500. userJSONBytes, _ := json.Marshal(dat)
  10501. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10502. utils.ErrorLog("解析失败:%v", err)
  10503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10504. return
  10505. }
  10506. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10507. 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, "")
  10508. var dat map[string]interface{}
  10509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10510. fmt.Println(dat)
  10511. } else {
  10512. fmt.Println(err)
  10513. }
  10514. saveLog(result, request, "2202", "退号")
  10515. userJSONBytes, _ := json.Marshal(dat)
  10516. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10517. utils.ErrorLog("解析失败:%v", err)
  10518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10519. return
  10520. }
  10521. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10522. 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, "")
  10523. var dat map[string]interface{}
  10524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10525. fmt.Println(dat)
  10526. } else {
  10527. fmt.Println(err)
  10528. }
  10529. saveLog(result, request, "2202", "退号")
  10530. userJSONBytes, _ := json.Marshal(dat)
  10531. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10532. utils.ErrorLog("解析失败:%v", err)
  10533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10534. return
  10535. }
  10536. } else {
  10537. var api3 string
  10538. if miConfig.Code == "H15049901371" {
  10539. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10540. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10542. } else {
  10543. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10544. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10546. }
  10547. resp3, requestErr3 := http.Get(api3)
  10548. if requestErr3 != nil {
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10553. if ioErr3 != nil {
  10554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return
  10557. }
  10558. var respJSON3 map[string]interface{}
  10559. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10565. userJSONBytes3, _ := json.Marshal(respJSON3)
  10566. if miConfig.Code == "H15049901371" {
  10567. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10568. utils.ErrorLog("解析失败:%v", err)
  10569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10570. return
  10571. }
  10572. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10573. res2.Output = resSix10265.Output
  10574. res2.ErrMsg = resSix10265.ErrMsg
  10575. res2.Cainfo = resSix10265.Cainfo
  10576. res2.WarnMsg = resSix10265.WarnMsg
  10577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10578. res2.Infcode = infocode
  10579. } else {
  10580. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10581. utils.ErrorLog("解析失败:%v", err)
  10582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10583. return
  10584. }
  10585. }
  10586. }
  10587. if res2.Infcode == 0 {
  10588. if err == nil {
  10589. c.ServeSuccessJSON(map[string]interface{}{
  10590. "msg": "退号成功",
  10591. })
  10592. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10593. } else {
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. } else {
  10598. c.ServeSuccessJSON(map[string]interface{}{
  10599. "code": -10,
  10600. "msg": res2.ErrMsg,
  10601. })
  10602. }
  10603. } else {
  10604. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10605. //if err == nil {
  10606. // c.ServeSuccessJSON(map[string]interface{}{
  10607. // "msg": "退费成功",
  10608. // })
  10609. //} else {
  10610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10611. // return
  10612. //}
  10613. }
  10614. }
  10615. func (c *HisApiController) RefundDetail() {
  10616. order_id, _ := c.GetInt64("order_id")
  10617. admin_user_id, _ := c.GetInt64("admin_user_id")
  10618. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10619. number := c.GetString("number")
  10620. record_time := c.GetString("record_time")
  10621. patient_id, _ := c.GetInt64("patient_id")
  10622. //med_type, _ := c.GetInt64("med_type")
  10623. timeLayout := "2006-01-02"
  10624. loc, _ := time.LoadLocation("Local")
  10625. adminUser := c.GetAdminUserInfo()
  10626. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10627. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10628. fmt.Println(err)
  10629. if err != nil {
  10630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10631. return
  10632. }
  10633. recordDateTime := theTime.Unix()
  10634. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10635. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10636. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10637. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10638. var order models.HisOrder
  10639. order, _ = service.GetHisOrderByID(order_id)
  10640. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10641. if config.IsOpen == 1 { //对接了医保,走医保流程
  10642. var res2 ResultSix
  10643. if miConfig.MdtrtareaAdmvs == "421300" {
  10644. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10645. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10647. resp3, requestErr3 := http.Get(api3)
  10648. if requestErr3 != nil {
  10649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10650. return
  10651. }
  10652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10653. if ioErr3 != nil {
  10654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10656. return
  10657. }
  10658. var respJSON3 map[string]interface{}
  10659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10662. return
  10663. }
  10664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10665. userJSONBytes3, _ := json.Marshal(respJSON3)
  10666. fmt.Println("log")
  10667. fmt.Println(string(userJSONBytes3))
  10668. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10669. utils.ErrorLog("解析失败:%v", err)
  10670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10671. return
  10672. }
  10673. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10674. if err == nil {
  10675. c.ServeSuccessJSON(map[string]interface{}{
  10676. "msg": "撤销明细成功",
  10677. })
  10678. return
  10679. } else {
  10680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10681. return
  10682. }
  10683. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10684. var resSix10265 ResultSix10265
  10685. var api3 string
  10686. if miConfig.MdtrtareaAdmvs == "320921" {
  10687. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10688. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10689. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10690. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10691. } else {
  10692. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10693. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10694. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10695. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10696. }
  10697. resp3, requestErr3 := http.Get(api3)
  10698. if requestErr3 != nil {
  10699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10700. return
  10701. }
  10702. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10703. if ioErr3 != nil {
  10704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10706. return
  10707. }
  10708. var respJSON3 map[string]interface{}
  10709. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10712. return
  10713. }
  10714. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10715. userJSONBytes3, _ := json.Marshal(respJSON3)
  10716. fmt.Println("log")
  10717. fmt.Println(string(userJSONBytes3))
  10718. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10719. utils.ErrorLog("解析失败:%v", err)
  10720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10721. return
  10722. }
  10723. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10724. res2.Output = resSix10265.Output
  10725. res2.ErrMsg = resSix10265.ErrMsg
  10726. res2.Cainfo = resSix10265.Cainfo
  10727. res2.WarnMsg = resSix10265.WarnMsg
  10728. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10729. res2.Infcode = infocode
  10730. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10731. if err == nil {
  10732. c.ServeSuccessJSON(map[string]interface{}{
  10733. "msg": "撤销明细成功",
  10734. })
  10735. return
  10736. } else {
  10737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10738. return
  10739. }
  10740. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10741. 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)
  10742. var dat map[string]interface{}
  10743. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10744. fmt.Println(dat)
  10745. } else {
  10746. fmt.Println(err)
  10747. }
  10748. saveLog(result2, src_request, "2205", "撤销明细")
  10749. userJSONBytes, _ := json.Marshal(dat)
  10750. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10751. utils.ErrorLog("解析失败:%v", err)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return
  10754. }
  10755. if res2.Infcode == 0 {
  10756. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10757. if err == nil {
  10758. c.ServeSuccessJSON(map[string]interface{}{
  10759. "msg": "撤销明细成功",
  10760. })
  10761. return
  10762. } else {
  10763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10764. return
  10765. }
  10766. } else {
  10767. c.ServeSuccessJSON(map[string]interface{}{
  10768. "code": -10,
  10769. "msg": res2.ErrMsg,
  10770. })
  10771. }
  10772. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10773. 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, "")
  10774. var dat map[string]interface{}
  10775. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10776. fmt.Println(dat)
  10777. } else {
  10778. fmt.Println(err)
  10779. }
  10780. saveLog(result2, src_request, "2205", "撤销明细")
  10781. userJSONBytes, _ := json.Marshal(dat)
  10782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10783. utils.ErrorLog("解析失败:%v", err)
  10784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10785. return
  10786. }
  10787. if res2.Infcode == 0 {
  10788. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10789. if err == nil {
  10790. c.ServeSuccessJSON(map[string]interface{}{
  10791. "msg": "撤销明细成功",
  10792. })
  10793. return
  10794. } else {
  10795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10796. return
  10797. }
  10798. } else {
  10799. c.ServeSuccessJSON(map[string]interface{}{
  10800. "code": -10,
  10801. "msg": res2.ErrMsg,
  10802. })
  10803. }
  10804. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10805. 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, "")
  10806. var dat map[string]interface{}
  10807. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10808. fmt.Println(dat)
  10809. } else {
  10810. fmt.Println(err)
  10811. }
  10812. saveLog(result2, src_request, "2205", "撤销明细")
  10813. userJSONBytes, _ := json.Marshal(dat)
  10814. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10815. utils.ErrorLog("解析失败:%v", err)
  10816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10817. return
  10818. }
  10819. if res2.Infcode == 0 {
  10820. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10821. if err == nil {
  10822. c.ServeSuccessJSON(map[string]interface{}{
  10823. "msg": "撤销明细成功",
  10824. })
  10825. return
  10826. } else {
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10828. return
  10829. }
  10830. } else {
  10831. c.ServeSuccessJSON(map[string]interface{}{
  10832. "code": -10,
  10833. "msg": res2.ErrMsg,
  10834. })
  10835. }
  10836. } else {
  10837. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  10838. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10840. resp2, requestErr2 := http.Get(api2)
  10841. if requestErr2 != nil {
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10846. if ioErr2 != nil {
  10847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10849. return
  10850. }
  10851. var respJSON2 map[string]interface{}
  10852. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10855. return
  10856. }
  10857. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10858. if err == nil {
  10859. c.ServeSuccessJSON(map[string]interface{}{
  10860. "msg": "撤销明细成功",
  10861. })
  10862. return
  10863. } else {
  10864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10865. return
  10866. }
  10867. }
  10868. } else {
  10869. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10870. if err == nil {
  10871. c.ServeSuccessJSON(map[string]interface{}{
  10872. "msg": "退费成功",
  10873. })
  10874. } else {
  10875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10876. return
  10877. }
  10878. }
  10879. }
  10880. //对账
  10881. func (c *HisApiController) GetCheckAccount() {
  10882. start_time := c.GetString("start_time")
  10883. end_time := c.GetString("end_time")
  10884. insutype := c.GetString("insutype")
  10885. clr_type := c.GetString("clr_type")
  10886. clr_org := c.GetString("clr_optins")
  10887. admin_user_id, _ := c.GetInt64("admin_user_id")
  10888. adminUser := c.GetAdminUserInfo()
  10889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10891. if len(clr_org) == 0 {
  10892. clr_org = miConfig.MdtrtareaAdmvs
  10893. }
  10894. timeLayout := "2006-01-02"
  10895. loc, _ := time.LoadLocation("Local")
  10896. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  10897. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  10898. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10899. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10900. fixmedins_setl_cnt := int64(len(orders))
  10901. var medfee_sumamt float64
  10902. var acct_pay float64
  10903. var fund_pay_sumamt float64
  10904. for _, item := range orders {
  10905. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  10906. acct_pay = acct_pay + item.AcctPay
  10907. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  10908. }
  10909. var user_name string
  10910. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10911. if role.ID == 0 {
  10912. user_name = "xxx"
  10913. } else {
  10914. user_name = role.UserName
  10915. }
  10916. var res ResultEight
  10917. var res10188 ResultEightFor10188
  10918. if config.IsOpen == 1 {
  10919. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10920. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  10921. "insutype=" + insutype +
  10922. "&clr_type=" + clr_type +
  10923. "&setl_optins=" + clr_org +
  10924. "&stmt_begndate=" + start_time +
  10925. "&stm_enddate=" + end_time +
  10926. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10927. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10928. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10929. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10930. "&fixmedins_code=" + miConfig.Code +
  10931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10932. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10933. "&secret_key=" + miConfig.SecretKey +
  10934. "&org_name=" + miConfig.OrgName +
  10935. "&doctor=" + user_name +
  10936. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10937. fmt.Println(api)
  10938. resp, requestErr := http.Get(api)
  10939. if requestErr != nil {
  10940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10941. return
  10942. }
  10943. body, ioErr := ioutil.ReadAll(resp.Body)
  10944. fmt.Println(body)
  10945. if ioErr != nil {
  10946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10948. return
  10949. }
  10950. var respJSON map[string]interface{}
  10951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10957. userJSONBytes, _ := json.Marshal(respJSON)
  10958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10959. utils.ErrorLog("解析失败:%v", err)
  10960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10961. return
  10962. }
  10963. res.InfRefmsgid = res10188.InfRefmsgid
  10964. res.Output = res10188.Output
  10965. res.ErrMsg = res10188.ErrMsg
  10966. res.Cainfo = res10188.Cainfo
  10967. res.WarnMsg = res10188.WarnMsg
  10968. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  10969. res.Infcode = infocode
  10970. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10971. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  10972. "insutype=" + insutype +
  10973. "&clr_type=" + "21" +
  10974. "&setl_optins=" + clr_org +
  10975. "&stmt_begndate=" + start_time +
  10976. "&stm_enddate=" + end_time +
  10977. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10978. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10979. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10980. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10981. "&fixmedins_code=" + miConfig.Code +
  10982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10983. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10984. "&secret_key=" + miConfig.SecretKey +
  10985. "&org_name=" + miConfig.OrgName +
  10986. "&doctor=" + user_name
  10987. resp, requestErr := http.Get(api)
  10988. if requestErr != nil {
  10989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10990. return
  10991. }
  10992. body, ioErr := ioutil.ReadAll(resp.Body)
  10993. if ioErr != nil {
  10994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10996. return
  10997. }
  10998. var respJSON map[string]interface{}
  10999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11005. result, _ := json.Marshal(respJSON)
  11006. fmt.Println("log")
  11007. fmt.Println(string(result))
  11008. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11009. utils.ErrorLog("解析失败:%v", err)
  11010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11011. return
  11012. }
  11013. res.InfRefmsgid = res10188.InfRefmsgid
  11014. res.Output = res10188.Output
  11015. res.ErrMsg = res10188.ErrMsg
  11016. res.Cainfo = res10188.Cainfo
  11017. res.WarnMsg = res10188.WarnMsg
  11018. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11019. res.Infcode = infocode
  11020. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11021. var baseParams models.BaseParams
  11022. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11023. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11024. baseParams.SecretKey = miConfig.SecretKey
  11025. baseParams.OrgName = miConfig.OrgName
  11026. baseParams.FixmedinsCode = miConfig.Code
  11027. baseParams.EncKey = miConfig.EncKey
  11028. baseParams.AppSecret = miConfig.AppSecret
  11029. baseParams.SignKey = miConfig.SignKey
  11030. baseParams.AppID = miConfig.Code
  11031. baseParams.Doctor = role.UserName
  11032. baseParams.RequestUrl = miConfig.Url
  11033. businessParams := models.BusinessParams{
  11034. Insutype: insutype,
  11035. ClrType: clr_type,
  11036. SetlOptins: clr_org,
  11037. StmtBegndate: start_time,
  11038. StmtEnddate: end_time,
  11039. MedfeeSumamt: medfee_sumamt,
  11040. FundPaySumamt: fund_pay_sumamt,
  11041. AcctPay: acct_pay,
  11042. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11043. }
  11044. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11045. fmt.Println(requestLog)
  11046. fmt.Println(result)
  11047. fmt.Println(err_msg)
  11048. var dat map[string]interface{}
  11049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11050. fmt.Println(dat)
  11051. } else {
  11052. fmt.Println(err)
  11053. }
  11054. userJSONBytes, _ := json.Marshal(dat)
  11055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11056. utils.ErrorLog("解析失败:%v", err)
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11058. return
  11059. }
  11060. } else if miConfig.MdtrtareaAdmvs == "" {
  11061. var baseParams models.BaseParams
  11062. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11063. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11064. baseParams.SecretKey = miConfig.SecretKey
  11065. baseParams.OrgName = miConfig.OrgName
  11066. baseParams.FixmedinsCode = miConfig.Code
  11067. baseParams.EncKey = miConfig.EncKey
  11068. baseParams.AppSecret = miConfig.AppSecret
  11069. baseParams.SignKey = miConfig.SignKey
  11070. baseParams.AppID = miConfig.Code
  11071. baseParams.Doctor = role.UserName
  11072. baseParams.RequestUrl = miConfig.Url
  11073. businessParams := models.BusinessParams{
  11074. Insutype: insutype,
  11075. ClrType: clr_type,
  11076. SetlOptins: clr_org,
  11077. StmtBegndate: start_time,
  11078. StmtEnddate: end_time,
  11079. MedfeeSumamt: medfee_sumamt,
  11080. FundPaySumamt: fund_pay_sumamt,
  11081. AcctPay: acct_pay,
  11082. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11083. }
  11084. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11085. fmt.Println(requestLog)
  11086. fmt.Println(result)
  11087. fmt.Println(err_msg)
  11088. var dat map[string]interface{}
  11089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11090. fmt.Println(dat)
  11091. } else {
  11092. fmt.Println(err)
  11093. }
  11094. userJSONBytes, _ := json.Marshal(dat)
  11095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11096. utils.ErrorLog("解析失败:%v", err)
  11097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11098. return
  11099. }
  11100. } else {
  11101. if len(clr_type) == 0 {
  11102. clr_type = "11"
  11103. }
  11104. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11105. "insutype=" + insutype +
  11106. "&clr_type=" + clr_type +
  11107. "&setl_optins=" + clr_org +
  11108. "&stmt_begndate=" + start_time +
  11109. "&stm_enddate=" + end_time +
  11110. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11111. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11112. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11113. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11114. "&fixmedins_code=" + miConfig.Code +
  11115. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11116. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11117. "&secret_key=" + miConfig.SecretKey +
  11118. "&org_name=" + miConfig.OrgName +
  11119. "&doctor=" + user_name
  11120. fmt.Println(api)
  11121. resp, requestErr := http.Get(api)
  11122. if requestErr != nil {
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. body, ioErr := ioutil.ReadAll(resp.Body)
  11127. fmt.Println(body)
  11128. if ioErr != nil {
  11129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11131. return
  11132. }
  11133. var respJSON map[string]interface{}
  11134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11140. userJSONBytes, _ := json.Marshal(respJSON)
  11141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11142. utils.ErrorLog("解析失败:%v", err)
  11143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11144. return
  11145. }
  11146. }
  11147. if res.Infcode == 0 {
  11148. if res.Output.Stmtinfo.StmtRslt == "0" {
  11149. micc := &models.MedicalInsuranceCostCompare{
  11150. StartTime: startime.Unix(),
  11151. EndTime: endtime.Unix(),
  11152. Insutype: insutype,
  11153. CheckType: 1,
  11154. Num: fixmedins_setl_cnt,
  11155. Mtime: time.Now().Unix(),
  11156. Status: 1,
  11157. UserOrgId: adminUser.CurrentOrgId,
  11158. CostTotal: medfee_sumamt,
  11159. FuncTotal: fund_pay_sumamt,
  11160. PsnPay: acct_pay,
  11161. Creator: admin_user_id,
  11162. Ctime: time.Now().Unix(),
  11163. ClrType: clr_type,
  11164. }
  11165. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11166. if err == nil {
  11167. c.ServeSuccessJSON(map[string]interface{}{
  11168. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11169. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11170. })
  11171. } else {
  11172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11173. }
  11174. } else {
  11175. c.ServeSuccessJSON(map[string]interface{}{
  11176. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11177. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11178. })
  11179. }
  11180. } else {
  11181. c.ServeSuccessJSON(map[string]interface{}{
  11182. "code": -10,
  11183. "msg": res.ErrMsg,
  11184. })
  11185. }
  11186. }
  11187. }
  11188. func (c *HisApiController) Check310() {
  11189. adminUser := c.GetAdminUserInfo()
  11190. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11191. var user_name string
  11192. user_name = "高慧裕"
  11193. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11194. "insutype=" + "310" +
  11195. "&clr_type=" + "" +
  11196. "&setl_optins=" + "441202" +
  11197. "&stmt_begndate=" + "2022-03-01" +
  11198. "&stm_enddate=" + "2022-03-31" +
  11199. "&medfee_sumamt=" + "194930.12" +
  11200. "&fund_pay_sumamt=" + "188741.46" +
  11201. "&acct_pay=" + "0" +
  11202. "&fixmedins_setl_cnt=" + "452" +
  11203. "&fixmedins_code=" + miConfig.Code +
  11204. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11205. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11206. "&secret_key=" + miConfig.SecretKey +
  11207. "&org_name=" + miConfig.OrgName +
  11208. "&doctor=" + user_name
  11209. fmt.Println(api)
  11210. resp, requestErr := http.Get(api)
  11211. if requestErr != nil {
  11212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11213. return
  11214. }
  11215. body, ioErr := ioutil.ReadAll(resp.Body)
  11216. fmt.Println(body)
  11217. if ioErr != nil {
  11218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11220. return
  11221. }
  11222. var respJSON map[string]interface{}
  11223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11226. return
  11227. }
  11228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11229. userJSONBytes, _ := json.Marshal(respJSON)
  11230. var res ResultEight
  11231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11232. utils.ErrorLog("解析失败:%v", err)
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11234. return
  11235. }
  11236. }
  11237. func (c *HisApiController) Check390() {
  11238. adminUser := c.GetAdminUserInfo()
  11239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11240. var user_name string
  11241. user_name = "高慧裕"
  11242. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11243. "insutype=" + "390" +
  11244. "&clr_type=" + "" +
  11245. "&setl_optins=" + "441202" +
  11246. "&stmt_begndate=" + "2022-03-01" +
  11247. "&stm_enddate=" + "2022-03-31" +
  11248. "&medfee_sumamt=" + "1068448.89" +
  11249. "&fund_pay_sumamt=" + "1014677.62" +
  11250. "&acct_pay=" + "0" +
  11251. "&fixmedins_setl_cnt=" + "1950" +
  11252. "&fixmedins_code=" + miConfig.Code +
  11253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11254. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11255. "&secret_key=" + miConfig.SecretKey +
  11256. "&org_name=" + miConfig.OrgName +
  11257. "&doctor=" + user_name
  11258. fmt.Println(api)
  11259. resp, requestErr := http.Get(api)
  11260. if requestErr != nil {
  11261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11262. return
  11263. }
  11264. body, ioErr := ioutil.ReadAll(resp.Body)
  11265. fmt.Println(body)
  11266. if ioErr != nil {
  11267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11269. return
  11270. }
  11271. var respJSON map[string]interface{}
  11272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11275. return
  11276. }
  11277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11278. userJSONBytes, _ := json.Marshal(respJSON)
  11279. var res ResultEight
  11280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11281. utils.ErrorLog("解析失败:%v", err)
  11282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11283. return
  11284. }
  11285. }
  11286. //对账明细
  11287. func (c *HisApiController) GetCheckDetailAccount() {
  11288. start_time := c.GetString("start_time")
  11289. end_time := c.GetString("end_time")
  11290. admin_user_id, _ := c.GetInt64("admin_user_id")
  11291. adminUser := c.GetAdminUserInfo()
  11292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11293. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11294. timeLayout := "2006-01-02"
  11295. loc, _ := time.LoadLocation("Local")
  11296. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11297. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11298. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11299. rand.Seed(time.Now().UnixNano())
  11300. num := rand.Intn(30000)
  11301. Mkdir(miConfig.OrgName)
  11302. file := strconv.FormatInt(int64(num), 10)
  11303. file_name := file + ".txt"
  11304. zip_name := file + ".zip"
  11305. zip_path := miConfig.OrgName + "/" + zip_name
  11306. file_path := miConfig.OrgName + "/" + file_name
  11307. decimal.DivisionPrecision = 2
  11308. var medfee_sumamt float64
  11309. var psn_cash_pay float64
  11310. var fund_pay_sumamt float64
  11311. fixmedins_setl_cnt := int64(len(orders))
  11312. for _, item := range orders {
  11313. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11314. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11315. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11316. }
  11317. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11318. defer f.Close()
  11319. if err != nil {
  11320. fmt.Println(err.Error())
  11321. } else {
  11322. for _, item := range orders {
  11323. var refd_setl_flag string
  11324. if item.OrderStatus == 2 {
  11325. refd_setl_flag = "0"
  11326. var str string
  11327. str = item.SetlId + " " +
  11328. item.MdtrtId + " " +
  11329. item.PsnNo + " " +
  11330. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11331. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11332. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11333. _, err = f.Write([]byte(str))
  11334. }
  11335. if item.OrderStatus == 3 {
  11336. var str string
  11337. str = item.SetlId + " " +
  11338. item.MdtrtId + " " +
  11339. item.PsnNo + " " +
  11340. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11341. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11342. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11343. _, err = f.Write([]byte(str))
  11344. var str2 string
  11345. str2 = item.SetlId + " " +
  11346. item.MdtrtId + " " +
  11347. item.PsnNo + " " +
  11348. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11349. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11350. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11351. _, err = f.Write([]byte(str2))
  11352. }
  11353. }
  11354. }
  11355. Zip(file_path, zip_path)
  11356. fmt.Println(ReadFile(zip_path))
  11357. fmt.Println(string(ReadFile(zip_path)))
  11358. if config.IsOpen == 1 {
  11359. var user_name string
  11360. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11361. if role.ID == 0 {
  11362. user_name = "管理员"
  11363. } else {
  11364. user_name = role.UserName
  11365. }
  11366. baseParams := models.BaseParams{
  11367. SecretKey: miConfig.SecretKey,
  11368. FixmedinsCode: miConfig.Code,
  11369. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11370. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11371. OrgName: miConfig.OrgName,
  11372. Doctor: user_name,
  11373. }
  11374. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11375. var dat map[string]interface{}
  11376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11377. fmt.Println(dat)
  11378. } else {
  11379. fmt.Println(err)
  11380. }
  11381. userJSONBytes, _ := json.Marshal(dat)
  11382. var res ResultNine
  11383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11384. utils.ErrorLog("解析失败:%v", err)
  11385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11386. return
  11387. }
  11388. if res.Infcode == 0 {
  11389. fileNo := res.Output.FileQuryNo
  11390. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11391. "file_qury_no=" + fileNo +
  11392. "&setl_optins=" + "定点医保中心" +
  11393. "&stmt_begndate=" + start_time +
  11394. "&stm_enddate=" + end_time +
  11395. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11396. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11397. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11398. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11399. "&fixmedins_code=" + miConfig.Code +
  11400. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11401. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11402. "&secret_key=" + miConfig.SecretKey +
  11403. "&org_name=" + miConfig.OrgName +
  11404. "&doctor=" + user_name
  11405. resp, requestErr := http.Get(api)
  11406. if requestErr != nil {
  11407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11408. return
  11409. }
  11410. body, ioErr := ioutil.ReadAll(resp.Body)
  11411. if ioErr != nil {
  11412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11414. return
  11415. }
  11416. var respJSON map[string]interface{}
  11417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11420. return
  11421. }
  11422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11423. userJSONBytes, _ := json.Marshal(respJSON)
  11424. var res ResultTen
  11425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11426. utils.ErrorLog("解析失败:%v", err)
  11427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11428. return
  11429. }
  11430. if res.Infcode == 0 {
  11431. service.Gdyb9102(baseParams, zip_name, fileNo)
  11432. micc := &models.MedicalInsuranceCostCompare{
  11433. StartTime: startime.Unix(),
  11434. EndTime: endtime.Unix(),
  11435. Insutype: "0",
  11436. CheckType: 2,
  11437. Num: fixmedins_setl_cnt,
  11438. Mtime: time.Now().Unix(),
  11439. Status: 1,
  11440. UserOrgId: adminUser.CurrentOrgId,
  11441. CostTotal: medfee_sumamt,
  11442. FuncTotal: fund_pay_sumamt,
  11443. PsnPay: psn_cash_pay,
  11444. Creator: admin_user_id,
  11445. Ctime: time.Now().Unix(),
  11446. }
  11447. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11448. c.ServeSuccessJSON(map[string]interface{}{
  11449. "msg": "明细对账成功",
  11450. })
  11451. }
  11452. } else {
  11453. }
  11454. }
  11455. }
  11456. type CustomOrderInfo struct {
  11457. Name string
  11458. Spec string
  11459. Unit string
  11460. Count float64
  11461. Price float64
  11462. Total float64
  11463. }
  11464. func (c *HisApiController) GetSettleAccounts() {
  11465. //id, _ := c.GetInt64("id")
  11466. //record_time := c.GetString("record_time")
  11467. order_id, _ := c.GetInt64("order_id")
  11468. admin_user_id, _ := c.GetInt64("admin_user_id")
  11469. //timeLayout := "2006-01-02"
  11470. //loc, _ := time.LoadLocation("Local")
  11471. //
  11472. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11473. //if err != nil {
  11474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11475. // return
  11476. //}
  11477. //recordDateTime := theTime.Unix()
  11478. adminUser := c.GetAdminUserInfo()
  11479. order, _ := service.GetHisOrderByID(order_id)
  11480. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11481. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11482. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11483. orderInfos = append(orderInfos, orderInfos_two...)
  11484. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11485. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11486. var diagnosis_ids []string
  11487. if his.ID > 0 {
  11488. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11489. } else {
  11490. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11491. }
  11492. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11493. var dia_config []*models.HisXtDiagnoseConfig
  11494. var name string
  11495. for _, item := range diagnosis_ids {
  11496. id, _ := strconv.ParseInt(item, 10, 64)
  11497. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11498. dia_config = append(dia_config, &diagnosisConfig)
  11499. if len(name) == 0 {
  11500. name = diagnosisConfig.ClassName
  11501. } else {
  11502. name = name + "," + diagnosisConfig.ClassName
  11503. }
  11504. }
  11505. var bedCostTotal float64 = 0 //床位总费
  11506. var bedCostSelfTotal float64 = 0 //床位自费
  11507. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11508. var operationCostTotal float64 = 0 //手术费
  11509. var operationCostSelfTotal float64 = 0 //手术费
  11510. var operationCostPartSelfTotal float64 = 0 //手术费
  11511. var otherCostTotal float64 = 0 //其他费用
  11512. var otherCostSelfTotal float64 = 0 //其他费用
  11513. var otherCostPartSelfTotal float64 = 0 //其他费用
  11514. var materialCostTotal float64 = 0 //材料费
  11515. var materialCostSelfTotal float64 = 0 //材料费
  11516. var materialCostPartSelfTotal float64 = 0 //材料费
  11517. var westernMedicineCostTotal float64 = 0 //西药费
  11518. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11519. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11520. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11521. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11522. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11523. var checkCostTotal float64 = 0 //检查费
  11524. var checkCostSelfTotal float64 = 0 //检查费
  11525. var checkCostPartSelfTotal float64 = 0 //检查费
  11526. var laboratoryCostTotal float64 = 0 //化验费
  11527. var laboratoryCostSelfTotal float64 = 0 //化验费
  11528. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11529. var treatCostTotal float64 = 0 //治疗费用
  11530. var treatCostSelfTotal float64 = 0 //治疗费用
  11531. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11532. decimal.DivisionPrecision = 2
  11533. for _, item := range orderInfos {
  11534. if item.MedChrgitmType == "01" { //床位费
  11535. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11536. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11537. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11538. }
  11539. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11540. if item.MedChrgitmType == "03" { //检查费
  11541. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11542. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11543. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11544. }
  11545. } else {
  11546. if item.MedChrgitmType == "03" { //检查费
  11547. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11548. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11549. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11550. }
  11551. }
  11552. if item.MedChrgitmType == "04" { //化验费
  11553. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11554. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11555. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11556. }
  11557. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11558. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11559. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11560. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11561. }
  11562. if item.MedChrgitmType == "06" { //手术费
  11563. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11564. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11565. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11566. }
  11567. if item.MedChrgitmType == "08" { //材料费
  11568. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11569. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11570. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11571. }
  11572. if item.MedChrgitmType == "09" { //西药费
  11573. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11574. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11575. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11576. }
  11577. if item.MedChrgitmType == "11" { //中成费
  11578. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11579. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11580. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11581. }
  11582. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11583. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11584. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11585. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11586. }
  11587. }
  11588. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11589. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11590. var user_name string
  11591. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11592. if role.ID == 0 {
  11593. user_name = "管理员"
  11594. } else {
  11595. user_name = role.UserName
  11596. }
  11597. baseParams := models.BaseParams{
  11598. SecretKey: miConfig.SecretKey,
  11599. FixmedinsCode: miConfig.Code,
  11600. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11601. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11602. OrgName: miConfig.OrgName,
  11603. Doctor: user_name,
  11604. RequestUrl: miConfig.Url,
  11605. AccessKey: miConfig.AccessKey,
  11606. }
  11607. businessParams := models.BusinessParams{
  11608. PsnNo: order.PsnNo,
  11609. MdtrtId: order.MdtrtId,
  11610. SetlId: order.SetlId,
  11611. }
  11612. var res ResultEleven
  11613. var resEleven10265 ResultEleven10265
  11614. if config.IsOpen == 1 {
  11615. if miConfig.MdtrtareaAdmvs == "421300" {
  11616. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11617. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11619. resp, requestErr := http.Get(api)
  11620. if requestErr != nil {
  11621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11622. return
  11623. }
  11624. body, ioErr := ioutil.ReadAll(resp.Body)
  11625. if ioErr != nil {
  11626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11628. return
  11629. }
  11630. var respJSON map[string]interface{}
  11631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11634. return
  11635. }
  11636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11637. result, _ := json.Marshal(respJSON)
  11638. fmt.Println("log")
  11639. fmt.Println(string(result))
  11640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11641. utils.ErrorLog("解析失败:%v", err)
  11642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11643. return
  11644. }
  11645. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11646. var api string
  11647. if miConfig.MdtrtareaAdmvs == "320921" {
  11648. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11649. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11650. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11651. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11652. } else {
  11653. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11654. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11655. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11656. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11657. }
  11658. resp, requestErr := http.Get(api)
  11659. if requestErr != nil {
  11660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11661. return
  11662. }
  11663. body, ioErr := ioutil.ReadAll(resp.Body)
  11664. if ioErr != nil {
  11665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11667. return
  11668. }
  11669. var respJSON map[string]interface{}
  11670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11673. return
  11674. }
  11675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11676. result, _ := json.Marshal(respJSON)
  11677. fmt.Println("log")
  11678. fmt.Println(string(result))
  11679. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11680. utils.ErrorLog("解析失败:%v", err)
  11681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11682. return
  11683. }
  11684. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11685. res.Output = resEleven10265.Output
  11686. res.ErrMsg = resEleven10265.ErrMsg
  11687. res.Cainfo = resEleven10265.Cainfo
  11688. res.WarnMsg = resEleven10265.WarnMsg
  11689. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11690. res.Infcode = infocode
  11691. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11692. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11693. saveLog(result, requestLog, "5203", "结算单")
  11694. var dat map[string]interface{}
  11695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11696. fmt.Println(dat)
  11697. } else {
  11698. fmt.Println(err)
  11699. }
  11700. userJSONBytes, _ := json.Marshal(dat)
  11701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11702. utils.ErrorLog("解析失败:%v", err)
  11703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11704. return
  11705. }
  11706. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11707. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  11708. saveLog(result, requestLog, "5203", "结算单")
  11709. var dat map[string]interface{}
  11710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11711. fmt.Println(dat)
  11712. } else {
  11713. fmt.Println(err)
  11714. }
  11715. userJSONBytes, _ := json.Marshal(dat)
  11716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11717. utils.ErrorLog("解析失败:%v", err)
  11718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11719. return
  11720. }
  11721. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11722. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  11723. saveLog(result, requestLog, "5203", "结算单")
  11724. var dat map[string]interface{}
  11725. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11726. fmt.Println(dat)
  11727. } else {
  11728. fmt.Println(err)
  11729. }
  11730. userJSONBytes, _ := json.Marshal(dat)
  11731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11732. utils.ErrorLog("解析失败:%v", err)
  11733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11734. return
  11735. }
  11736. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11737. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11738. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11740. resp, requestErr := http.Get(api)
  11741. if requestErr != nil {
  11742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11743. return
  11744. }
  11745. body, ioErr := ioutil.ReadAll(resp.Body)
  11746. if ioErr != nil {
  11747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11749. return
  11750. }
  11751. var respJSON map[string]interface{}
  11752. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11755. return
  11756. }
  11757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11758. result, _ := json.Marshal(respJSON)
  11759. fmt.Println("log")
  11760. fmt.Println(string(result))
  11761. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11762. utils.ErrorLog("解析失败:%v", err)
  11763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11764. return
  11765. }
  11766. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11767. res.Output = resEleven10265.Output
  11768. res.ErrMsg = resEleven10265.ErrMsg
  11769. res.Cainfo = resEleven10265.Cainfo
  11770. res.WarnMsg = resEleven10265.WarnMsg
  11771. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11772. res.Infcode = infocode
  11773. } else {
  11774. result := service.Gdyb5203(baseParams, businessParams)
  11775. //service.Gdyb5204(baseParams, businessParams)
  11776. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  11777. var dat map[string]interface{}
  11778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11779. fmt.Println(dat)
  11780. } else {
  11781. fmt.Println(err)
  11782. }
  11783. userJSONBytes, _ := json.Marshal(dat)
  11784. if miConfig.Code == "H15049901371" {
  11785. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  11786. utils.ErrorLog("解析失败:%v", err)
  11787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11788. return
  11789. }
  11790. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11791. res.Output = resEleven10265.Output
  11792. res.ErrMsg = resEleven10265.ErrMsg
  11793. res.Cainfo = resEleven10265.Cainfo
  11794. res.WarnMsg = resEleven10265.WarnMsg
  11795. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11796. res.Infcode = infocode
  11797. } else {
  11798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11799. utils.ErrorLog("解析失败:%v", err)
  11800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11801. return
  11802. }
  11803. }
  11804. }
  11805. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11806. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  11807. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  11808. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11809. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  11810. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11811. var doctor_name string
  11812. if roles.ID == 0 {
  11813. doctor_name = "管理员"
  11814. } else {
  11815. doctor_name = roles.UserName
  11816. }
  11817. yiliao_leibie := ""
  11818. switch order.MedType {
  11819. case "11":
  11820. yiliao_leibie = "普通门诊"
  11821. break
  11822. case "12":
  11823. yiliao_leibie = "门诊挂号"
  11824. break
  11825. case "13":
  11826. yiliao_leibie = "急诊"
  11827. break
  11828. case "14":
  11829. yiliao_leibie = "门诊特殊病"
  11830. break
  11831. case "15":
  11832. yiliao_leibie = "门诊统筹"
  11833. break
  11834. case "16":
  11835. yiliao_leibie = "门诊慢性病"
  11836. break
  11837. case "21":
  11838. yiliao_leibie = "普通住院"
  11839. break
  11840. }
  11841. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11842. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  11843. if res.Infcode == 0 {
  11844. c.ServeSuccessJSON(map[string]interface{}{
  11845. "diagnosis": name,
  11846. "order_infos": orderInfos,
  11847. "number": order.MdtrtId,
  11848. "date": order.SettleAccountsDate,
  11849. "charge_admin": charge_admin,
  11850. "printor_admin": printor_admin,
  11851. "info": res.Output.Setlinfo,
  11852. "order": order,
  11853. "bedCostTotal": bedCostTotal,
  11854. "bedCostSelfTotal": bedCostSelfTotal,
  11855. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  11856. "operationCostTotal": operationCostTotal,
  11857. "operationCostSelfTotal": operationCostSelfTotal,
  11858. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  11859. "otherCostTotal": otherCostTotal,
  11860. "otherCostSelfTotal": otherCostSelfTotal,
  11861. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  11862. "materialCostTotal": materialCostTotal,
  11863. "materialCostSelfTotal": materialCostSelfTotal,
  11864. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  11865. "westernMedicineCostTotal": westernMedicineCostTotal,
  11866. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  11867. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  11868. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  11869. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  11870. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  11871. "checkCostTotal": checkCostTotal,
  11872. "checkCostSelfTotal": checkCostSelfTotal,
  11873. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  11874. "laboratoryCostTotal": laboratoryCostTotal,
  11875. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  11876. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  11877. "treatCostTotal": treatCostTotal,
  11878. "treatCostSelfTotal": treatCostSelfTotal,
  11879. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  11880. "doctor_info": doctor_info,
  11881. "doctor_code": adminRole_two.DoctorCode,
  11882. "doctor_name": doctor_name,
  11883. "health_card_no": order.PsnNo,
  11884. "department": departments.Name,
  11885. "yiliao_leibie": yiliao_leibie,
  11886. "after_money": order.AccountPrice,
  11887. "patient": patient,
  11888. "org_name": miConfig.OrgName,
  11889. "org_code": miConfig.Code,
  11890. "order_number": order.Number,
  11891. "his_hospital": his_hospital,
  11892. "his": his,
  11893. "dia_config": dia_config,
  11894. //"check_order_info": cus_slice,
  11895. })
  11896. }
  11897. }
  11898. }
  11899. func (c *HisApiController) CheckTreatment() {
  11900. patient_id, _ := c.GetInt64("patient_id")
  11901. id_card_no := c.GetString("id_card_no")
  11902. insutype := c.GetString("insutype")
  11903. med_type := c.GetString("med_type")
  11904. admin_user_id, _ := c.GetInt64("admin_user_id")
  11905. adminUser := c.GetAdminUserInfo()
  11906. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  11907. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11908. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11909. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11910. if miConfig.MdtrtareaAdmvs == "421300" {
  11911. var res ResultTwo
  11912. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11913. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11914. "&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)
  11915. resp, requestErr := http.Get(api)
  11916. if requestErr != nil {
  11917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11918. return
  11919. }
  11920. body, ioErr := ioutil.ReadAll(resp.Body)
  11921. if ioErr != nil {
  11922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11924. return
  11925. }
  11926. var respJSON map[string]interface{}
  11927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11930. return
  11931. }
  11932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11933. result, _ := json.Marshal(respJSON)
  11934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11935. utils.ErrorLog("解析失败:%v", err)
  11936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11937. return
  11938. }
  11939. if res.Infcode == 0 {
  11940. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  11941. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  11943. resp, requestErr := http.Get(api)
  11944. if requestErr != nil {
  11945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11946. return
  11947. }
  11948. body, ioErr := ioutil.ReadAll(resp.Body)
  11949. if ioErr != nil {
  11950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11952. return
  11953. }
  11954. var respJSON map[string]interface{}
  11955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11958. return
  11959. }
  11960. var res Result2001
  11961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11962. result2, _ := json.Marshal(respJSON)
  11963. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11964. utils.ErrorLog("解析失败:%v", err)
  11965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11966. return
  11967. }
  11968. if res.Infcode == 0 {
  11969. c.ServeSuccessJSON(map[string]interface{}{
  11970. "msg": res.Output.Trtinfo,
  11971. })
  11972. }
  11973. } else {
  11974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11975. return
  11976. }
  11977. } else {
  11978. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  11979. var dat map[string]interface{}
  11980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11981. fmt.Println(dat)
  11982. } else {
  11983. fmt.Println(err)
  11984. }
  11985. userJSONBytes, _ := json.Marshal(dat)
  11986. var res ResultTwo
  11987. var res10265 ResultTwo10265
  11988. if miConfig.Code == "H15049901371" {
  11989. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11990. utils.ErrorLog("解析失败:%v", err)
  11991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11992. return
  11993. }
  11994. res.ErrMsg = res10265.ErrMsg
  11995. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11996. res.Infcode = infocode
  11997. res.Output = res10265.Output
  11998. res.InfRefmsgid = res10265.InfRefmsgid
  11999. } else {
  12000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12001. utils.ErrorLog("解析失败:%v", err)
  12002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12003. return
  12004. }
  12005. }
  12006. var user_name string
  12007. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12008. if role.ID == 0 {
  12009. user_name = "xxx"
  12010. } else {
  12011. user_name = role.UserName
  12012. }
  12013. baseParams := models.BaseParams{
  12014. SecretKey: miConfig.SecretKey,
  12015. FixmedinsCode: miConfig.Code,
  12016. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12017. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12018. OrgName: miConfig.OrgName,
  12019. Doctor: user_name,
  12020. }
  12021. if config.IsOpen == 1 {
  12022. if miConfig.Code == "H15049901371" {
  12023. if med_type == "14" {
  12024. if insutype == "390" {
  12025. med_type = "9933"
  12026. } else if insutype == "310" {
  12027. med_type = "990502"
  12028. }
  12029. } else if med_type == "11" {
  12030. med_type = "11"
  12031. }
  12032. }
  12033. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12034. var dat map[string]interface{}
  12035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12036. fmt.Println(dat)
  12037. } else {
  12038. fmt.Println(err)
  12039. }
  12040. var res Result2001
  12041. var res10265 Result2001Org10265
  12042. if miConfig.Code == "H15049901371" {
  12043. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12044. utils.ErrorLog("解析失败:%v", err)
  12045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12046. return
  12047. }
  12048. res.ErrMsg = res10265.ErrMsg
  12049. res.Output = res10265.Output
  12050. res.InfRefmsgid = res10265.InfRefmsgid
  12051. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12052. res.Infcode = infocode
  12053. } else {
  12054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12055. utils.ErrorLog("解析失败:%v", err)
  12056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12057. return
  12058. }
  12059. }
  12060. if res.Infcode == 0 {
  12061. c.ServeSuccessJSON(map[string]interface{}{
  12062. "msg": res.Output.Trtinfo,
  12063. })
  12064. }
  12065. }
  12066. }
  12067. }
  12068. //func (c *HisApiController) PutRecord() {
  12069. // id, _ := c.GetInt64("id")
  12070. // record_time := c.GetString("record_time")
  12071. // timeLayout := "2006-01-02"
  12072. // loc, _ := time.LoadLocation("Local")
  12073. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12074. // if err != nil {
  12075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12076. // return
  12077. // }
  12078. // recordDateTime := theTime.Unix()
  12079. //
  12080. // adminInfo := c.GetAdminUserInfo()
  12081. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12082. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12083. //
  12084. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12085. //
  12086. // fmt.Println(miConfig.SecretKey)
  12087. //
  12088. // if patient == nil {
  12089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12090. // return
  12091. // }
  12092. // if len(patient.IdCardNo) == 0 {
  12093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12094. // return
  12095. // }
  12096. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12097. // if config.IsOpen == 1 {
  12098. // 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
  12099. // resp, requestErr := http.Get(api)
  12100. // if requestErr != nil {
  12101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12102. // return
  12103. // }
  12104. // defer resp.Body.Close()
  12105. // body, ioErr := ioutil.ReadAll(resp.Body)
  12106. // if ioErr != nil {
  12107. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12109. // return
  12110. // }
  12111. // var respJSON map[string]interface{}
  12112. //
  12113. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12114. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12116. // return
  12117. // }
  12118. //
  12119. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12120. // userJSONBytes, _ := json.Marshal(userJSON)
  12121. // var res ResultTwo
  12122. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12123. // utils.ErrorLog("解析失败:%v", err)
  12124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12125. // return
  12126. // }
  12127. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12128. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12129. // infoStr := string(Iinfos)
  12130. // idetinfoStr := string(Idetinfos)
  12131. //
  12132. // if res.Infcode == 0 {
  12133. // his := models.VMHisPatient{
  12134. // Status: 1,
  12135. // Ctime: time.Now().Unix(),
  12136. // Mtime: time.Now().Unix(),
  12137. // PsnNo: res.Output.Baseinfo.PsnNo,
  12138. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12139. // Certno: res.Output.Baseinfo.Certno,
  12140. // PsnName: res.Output.Baseinfo.PsnName,
  12141. // Gend: res.Output.Baseinfo.Gend,
  12142. // Naty: res.Output.Baseinfo.Naty,
  12143. // Brdy: res.Output.Baseinfo.Brdy,
  12144. // Age: res.Output.Baseinfo.Age,
  12145. // Iinfo: infoStr,
  12146. // Idetinfo: idetinfoStr,
  12147. // PatientId: patient.ID,
  12148. // RecordDate: theTime.Unix(),
  12149. // UserOrgId: adminInfo.CurrentOrgId,
  12150. // AdminUserId: adminInfo.AdminUser.Id,
  12151. // IsReturn: 1,
  12152. // }
  12153. //
  12154. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12155. // //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")
  12156. // //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")
  12157. //
  12158. // //var dat map[string]interface{}
  12159. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12160. // // fmt.Println(dat)
  12161. // //} else {
  12162. // // fmt.Println(err)
  12163. // //}
  12164. //
  12165. // var dat2 map[string]interface{}
  12166. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12167. // fmt.Println(dat2)
  12168. // } else {
  12169. // fmt.Println(err)
  12170. // }
  12171. //
  12172. // } else {
  12173. // adminUser := c.GetAdminUserInfo()
  12174. // errlog := &models.HisOrderError{
  12175. // UserOrgId: adminUser.CurrentOrgId,
  12176. // Ctime: time.Now().Unix(),
  12177. // Mtime: time.Now().Unix(),
  12178. // ErrMsg: res.ErrMsg,
  12179. // Status: 1,
  12180. // PatientId: id,
  12181. // RecordTime: recordDateTime,
  12182. // Stage: 1,
  12183. // }
  12184. // service.CreateErrMsgLog(errlog)
  12185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12186. // return
  12187. // }
  12188. // }
  12189. //
  12190. //}
  12191. //func (c *HisApiController) GetUploadDiag() {
  12192. // id, _ := c.GetInt64("id")
  12193. // record_time := c.GetString("record_time")
  12194. //
  12195. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12196. // sick_type, _ := c.GetInt64("sick_type")
  12197. // reg_type, _ := c.GetInt64("reg_type")
  12198. //
  12199. // timeLayout := "2006-01-02"
  12200. // loc, _ := time.LoadLocation("Local")
  12201. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12202. // if err != nil {
  12203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12204. // return
  12205. // }
  12206. //
  12207. // var patientPrescription models.HisPrescriptionInfo
  12208. // recordDateTime := theTime.Unix()
  12209. // adminInfo := c.GetAdminUserInfo()
  12210. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12211. //
  12212. // if patientPrescription.ID == 0 {
  12213. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12214. // }
  12215. //
  12216. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12217. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12218. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12219. // sickConfig, _ := service.FindSickById(sick_type)
  12220. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12221. //
  12222. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12223. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12224. // "&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 +
  12225. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12226. // resp2, requestErr2 := http.Get(api2)
  12227. // if requestErr2 != nil {
  12228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. // return
  12230. // }
  12231. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12232. // if ioErr2 != nil {
  12233. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. // return
  12236. // }
  12237. // var respJSON2 map[string]interface{}
  12238. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12239. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. // return
  12242. // }
  12243. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12244. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12245. //
  12246. // var res2 ResultSix
  12247. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12248. // utils.ErrorLog("解析失败:%v", err)
  12249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12250. // return
  12251. // }
  12252. // if res2.Infcode != 0 {
  12253. // adminUser := c.GetAdminUserInfo()
  12254. // errlog := &models.HisOrderError{
  12255. // UserOrgId: adminUser.CurrentOrgId,
  12256. // Ctime: time.Now().Unix(),
  12257. // Mtime: time.Now().Unix(),
  12258. // ErrMsg: res2.ErrMsg,
  12259. // Status: 1,
  12260. // PatientId: id,
  12261. // RecordTime: recordDateTime,
  12262. // Stage: 3,
  12263. // }
  12264. // service.CreateErrMsgLog(errlog)
  12265. //
  12266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12267. // return
  12268. // }
  12269. //
  12270. // c.ServeSuccessJSON(map[string]interface{}{
  12271. // "msg": "上传成功",
  12272. // })
  12273. //
  12274. //}
  12275. type QueryResult struct {
  12276. ID int64
  12277. Name string
  12278. Code string
  12279. List_type_code string
  12280. }
  12281. func (c *HisApiController) GetCheckCode() {
  12282. ids_str := c.GetString("ids")
  12283. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12284. ids_arr := strings.Split(ids_str, ",")
  12285. var queryResult []QueryResult
  12286. ids := make([]int64, 0)
  12287. for _, item := range ids_arr {
  12288. id, _ := strconv.ParseInt(item, 10, 64)
  12289. ids = append(ids, id)
  12290. }
  12291. if record_type == 1 {
  12292. drugs, _ := service.GetBatchDrugList(ids)
  12293. for _, item := range drugs {
  12294. result := QueryResult{
  12295. ID: item.ID,
  12296. Name: item.DrugName,
  12297. Code: item.MedicalInsuranceNumber,
  12298. List_type_code: "101",
  12299. }
  12300. queryResult = append(queryResult, result)
  12301. }
  12302. } else if record_type == 2 {
  12303. goods, _ := service.GetBatchGoodInformationList(ids)
  12304. for _, item := range goods {
  12305. result := QueryResult{
  12306. ID: item.ID,
  12307. Name: item.GoodName,
  12308. Code: item.MedicalInsuranceNumber,
  12309. List_type_code: "301",
  12310. }
  12311. queryResult = append(queryResult, result)
  12312. }
  12313. } else if record_type == 3 {
  12314. projects, _ := service.GetBathchMyPorjecgList(ids)
  12315. for _, item := range projects {
  12316. result := QueryResult{
  12317. ID: item.ID,
  12318. Name: item.ProjectName,
  12319. Code: item.MedicalCode,
  12320. List_type_code: "201",
  12321. }
  12322. queryResult = append(queryResult, result)
  12323. }
  12324. }
  12325. admin_user_id, _ := c.GetInt64("admin_user_id")
  12326. adminUser := c.GetAdminUserInfo()
  12327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12329. var user_name string
  12330. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12331. if role.ID == 0 {
  12332. user_name = "xxx"
  12333. } else {
  12334. user_name = role.UserName
  12335. }
  12336. baseParams := &models.BaseParams{
  12337. SecretKey: miConfig.SecretKey,
  12338. FixmedinsCode: miConfig.Code,
  12339. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12340. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12341. OrgName: miConfig.OrgName,
  12342. Doctor: user_name,
  12343. }
  12344. if config.IsOpen == 1 {
  12345. for _, item := range queryResult {
  12346. var result string
  12347. if record_type == 1 {
  12348. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12349. } else if record_type == 2 {
  12350. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12351. } else if record_type == 3 {
  12352. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12353. }
  12354. var dat map[string]interface{}
  12355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12356. fmt.Println(dat)
  12357. } else {
  12358. fmt.Println(err)
  12359. }
  12360. userJSONBytes, _ := json.Marshal(dat)
  12361. var res ResultSix
  12362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12363. utils.ErrorLog("解析失败:%v", err)
  12364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12365. return
  12366. }
  12367. if res.Infcode == 0 {
  12368. if record_type == 1 {
  12369. service.UpdateBaseDrugById(item.ID)
  12370. } else if record_type == 2 {
  12371. service.UpdateGoodInformaitonByDetail(item.ID)
  12372. } else if record_type == 3 {
  12373. service.UpdateProjectById(item.ID)
  12374. }
  12375. c.ServeSuccessJSON(map[string]interface{}{
  12376. "failed_code": 0,
  12377. "msg": "目录对照成功",
  12378. })
  12379. } else {
  12380. c.ServeSuccessJSON(map[string]interface{}{
  12381. "failed_code": -10,
  12382. "msg": res.ErrMsg,
  12383. })
  12384. }
  12385. }
  12386. }
  12387. }
  12388. func (c *HisApiController) UnCheckCode() {
  12389. ids_str := c.GetString("ids")
  12390. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12391. admin_user_id, _ := c.GetInt64("admin_user_id")
  12392. ids_arr := strings.Split(ids_str, ",")
  12393. var queryResult []QueryResult
  12394. ids := make([]int64, 0)
  12395. for _, item := range ids_arr {
  12396. id, _ := strconv.ParseInt(item, 10, 64)
  12397. ids = append(ids, id)
  12398. }
  12399. if record_type == 1 {
  12400. drugs, _ := service.GetBatchDrugList(ids)
  12401. for _, item := range drugs {
  12402. result := QueryResult{
  12403. ID: item.ID,
  12404. Name: item.DrugName,
  12405. Code: item.MedicalInsuranceNumber,
  12406. List_type_code: "101",
  12407. }
  12408. queryResult = append(queryResult, result)
  12409. }
  12410. } else if record_type == 2 {
  12411. goods, _ := service.GetBatchGoodInformationList(ids)
  12412. for _, item := range goods {
  12413. result := QueryResult{
  12414. ID: item.ID,
  12415. Name: item.GoodName,
  12416. Code: item.MedicalInsuranceNumber,
  12417. List_type_code: "301",
  12418. }
  12419. queryResult = append(queryResult, result)
  12420. }
  12421. } else if record_type == 3 {
  12422. projects, _ := service.GetBathchMyPorjecgList(ids)
  12423. for _, item := range projects {
  12424. result := QueryResult{
  12425. ID: item.ID,
  12426. Name: item.ProjectName,
  12427. Code: item.MedicalCode,
  12428. List_type_code: "201",
  12429. }
  12430. queryResult = append(queryResult, result)
  12431. }
  12432. }
  12433. adminUser := c.GetAdminUserInfo()
  12434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12436. var user_name string
  12437. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12438. if role.ID == 0 {
  12439. user_name = "xxx"
  12440. } else {
  12441. user_name = role.UserName
  12442. }
  12443. baseParams := &models.BaseParams{
  12444. SecretKey: miConfig.SecretKey,
  12445. FixmedinsCode: miConfig.Code,
  12446. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12447. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12448. OrgName: miConfig.OrgName,
  12449. Doctor: user_name,
  12450. }
  12451. if config.IsOpen == 1 {
  12452. for _, item := range queryResult {
  12453. var result string
  12454. if record_type == 1 {
  12455. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12456. } else if record_type == 2 {
  12457. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12458. } else if record_type == 3 {
  12459. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12460. }
  12461. var dat2 map[string]interface{}
  12462. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12463. fmt.Println(dat2)
  12464. } else {
  12465. fmt.Println(err)
  12466. }
  12467. userJSONBytes, _ := json.Marshal(dat2)
  12468. var res ResultSix
  12469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12470. utils.ErrorLog("解析失败:%v", err)
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12472. return
  12473. }
  12474. if res.Infcode == 0 {
  12475. if record_type == 1 {
  12476. service.UpdateDrugByIdDetail(item.ID)
  12477. } else if record_type == 2 {
  12478. service.UpdateGoodInfoById(item.ID)
  12479. } else if record_type == 3 {
  12480. service.UpdateMyProjectById(item.ID)
  12481. }
  12482. c.ServeSuccessJSON(map[string]interface{}{
  12483. "failed_code": 0,
  12484. "msg": "撤销目录对照成功",
  12485. })
  12486. } else {
  12487. c.ServeSuccessJSON(map[string]interface{}{
  12488. "failed_code": -10,
  12489. "msg": res.ErrMsg,
  12490. })
  12491. }
  12492. }
  12493. }
  12494. }
  12495. func (c *HisApiController) GetPatientInfo() {
  12496. id_card_no := c.GetString("id_card_no")
  12497. admin_user_id, _ := c.GetInt64("admin_user_id")
  12498. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12499. if patient.ID == 0 {
  12500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12501. return
  12502. }
  12503. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12504. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12505. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12506. if config.IsOpen == 1 {
  12507. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12508. var dat map[string]interface{}
  12509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12510. fmt.Println(dat)
  12511. } else {
  12512. fmt.Println(err)
  12513. }
  12514. userJSONBytes, _ := json.Marshal(dat)
  12515. var res ResultTwo
  12516. var res10265 ResultTwo10265
  12517. if miConfig.Code == "H15049901371" {
  12518. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12519. utils.ErrorLog("解析失败:%v", err)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return
  12522. }
  12523. res.ErrMsg = res10265.ErrMsg
  12524. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12525. res.Infcode = infocode
  12526. res.Output = res10265.Output
  12527. res.InfRefmsgid = res10265.InfRefmsgid
  12528. } else {
  12529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12530. utils.ErrorLog("解析失败:%v", err)
  12531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12532. return
  12533. }
  12534. }
  12535. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12536. // utils.ErrorLog("解析失败:%v", err)
  12537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12538. // return
  12539. //}
  12540. if res.Infcode != 0 {
  12541. c.ServeSuccessJSON(map[string]interface{}{
  12542. "failed_code": -10,
  12543. "msg": res.ErrMsg,
  12544. })
  12545. } else {
  12546. c.ServeSuccessJSON(map[string]interface{}{
  12547. "failed_code": 0,
  12548. "info": res,
  12549. })
  12550. }
  12551. }
  12552. }
  12553. func (c *HisApiController) PsnPutOnRecord() {
  12554. record_type, _ := c.GetInt64("type")
  12555. patient_id, _ := c.GetInt64("patient_id")
  12556. admin_user_id, _ := c.GetInt64("admin_user_id")
  12557. start_time := c.GetString("start_time")
  12558. end_time := c.GetString("end_time")
  12559. adminUser := c.GetAdminUserInfo()
  12560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12561. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12562. var patients []*models.Patients
  12563. if record_type == 1 { //全部备案
  12564. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12565. patients = append(patients, patient...)
  12566. } else { //单个备案
  12567. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12568. patients = append(patients, patient)
  12569. }
  12570. var user_name string
  12571. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12572. if role.ID == 0 {
  12573. user_name = "xxx"
  12574. } else {
  12575. user_name = role.UserName
  12576. }
  12577. if config.IsOpen == 1 {
  12578. for _, item := range patients {
  12579. 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
  12580. resp, requestErr := http.Get(api)
  12581. if requestErr != nil {
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return
  12584. }
  12585. defer resp.Body.Close()
  12586. body, ioErr := ioutil.ReadAll(resp.Body)
  12587. if ioErr != nil {
  12588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12590. return
  12591. }
  12592. var respJSON map[string]interface{}
  12593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12596. return
  12597. }
  12598. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12599. userJSONBytes, _ := json.Marshal(userJSON)
  12600. var res ResultTwo
  12601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12602. utils.ErrorLog("解析失败:%v", err)
  12603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12604. return
  12605. }
  12606. if res.Infcode == 0 {
  12607. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12608. var dat map[string]interface{}
  12609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12610. fmt.Println(dat)
  12611. } else {
  12612. fmt.Println(err)
  12613. }
  12614. userJSONBytes, _ := json.Marshal(dat)
  12615. var res2 ResultThirteen
  12616. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12617. utils.ErrorLog("解析失败:%v", err)
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12619. return
  12620. }
  12621. if res2.Infcode == 0 {
  12622. psnResult := &models.GdybPsnRecord{
  12623. UserOrgId: adminUser.CurrentOrgId,
  12624. PatientId: item.ID,
  12625. PsnNo: res.Output.Baseinfo.PsnNo,
  12626. Ctime: time.Now().Unix(),
  12627. Mtime: time.Now().Unix(),
  12628. Status: 1,
  12629. IsCancel: 1,
  12630. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12631. }
  12632. service.CreatePsnRecord(psnResult)
  12633. } else {
  12634. c.ServeSuccessJSON(map[string]interface{}{
  12635. "failed_code": -10,
  12636. "msg": res2.ErrMsg,
  12637. })
  12638. return
  12639. }
  12640. }
  12641. }
  12642. }
  12643. }
  12644. func (c *HisApiController) PsnUnPutOnRecord() {
  12645. id, _ := c.GetInt64("id")
  12646. //record_type, _ := c.GetInt64("type")
  12647. admin_user_id, _ := c.GetInt64("admin_user_id")
  12648. adminUser := c.GetAdminUserInfo()
  12649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12651. var user_name string
  12652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12653. if role.ID == 0 {
  12654. user_name = "xxx"
  12655. } else {
  12656. user_name = role.UserName
  12657. }
  12658. psn_record, _ := service.GetPsnRecordById(id)
  12659. if psn_record.ID == 0 {
  12660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12661. return
  12662. }
  12663. if config.IsOpen == 1 {
  12664. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12665. var dat map[string]interface{}
  12666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12667. fmt.Println(dat)
  12668. } else {
  12669. fmt.Println(err)
  12670. }
  12671. userJSONBytes, _ := json.Marshal(dat)
  12672. var res ResultFourteen
  12673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12674. utils.ErrorLog("解析失败:%v", err)
  12675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12676. return
  12677. }
  12678. if res.Infcode == 0 {
  12679. psn_record.IsCancel = 2
  12680. service.CreatePsnRecord(&psn_record)
  12681. } else {
  12682. c.ServeSuccessJSON(map[string]interface{}{
  12683. "failed_code": -10,
  12684. "msg": res.ErrMsg,
  12685. })
  12686. return
  12687. }
  12688. }
  12689. }
  12690. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12691. patient_id, _ := c.GetInt64("patient_id")
  12692. insutype_two := c.GetString("insutype")
  12693. psn_no := c.GetString("psn_no")
  12694. doctor_id, _ := c.GetInt64("doctor_id")
  12695. sick_id, _ := c.GetInt64("sick_id")
  12696. department_id, _ := c.GetInt64("department_id")
  12697. start_time := c.GetString("start_time")
  12698. end_time := c.GetString("end_time")
  12699. check_time := c.GetString("check_time")
  12700. adminUser := c.GetAdminUserInfo()
  12701. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12703. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12704. sick, _ := service.FindSickById(sick_id)
  12705. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12706. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12707. var res ResultTwo
  12708. var res10265 ResultTwo10265
  12709. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12710. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  12711. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  12712. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12713. "&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
  12714. resp, requestErr := http.Get(api)
  12715. if requestErr != nil {
  12716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12717. return
  12718. }
  12719. body, ioErr := ioutil.ReadAll(resp.Body)
  12720. if ioErr != nil {
  12721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12723. return
  12724. }
  12725. var respJSON map[string]interface{}
  12726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12729. return
  12730. }
  12731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12732. result, _ := json.Marshal(respJSON)
  12733. fmt.Println("log")
  12734. fmt.Println(string(result))
  12735. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12736. utils.ErrorLog("解析失败:%v", err)
  12737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12738. return
  12739. }
  12740. res.ErrMsg = res10265.ErrMsg
  12741. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12742. res.Infcode = infocode
  12743. res.Output = res10265.Output
  12744. res.InfRefmsgid = res10265.InfRefmsgid
  12745. } else {
  12746. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12747. if miConfig.Code == "H15049901371" {
  12748. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12749. utils.ErrorLog("解析失败:%v", err)
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12751. return
  12752. }
  12753. res.ErrMsg = res10265.ErrMsg
  12754. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12755. res.Infcode = infocode
  12756. res.Output = res10265.Output
  12757. res.InfRefmsgid = res10265.InfRefmsgid
  12758. } else {
  12759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12760. utils.ErrorLog("解析失败:%v", err)
  12761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12762. return
  12763. }
  12764. }
  12765. }
  12766. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12767. infoStr := string(Iinfos)
  12768. var rf []*ResultFive
  12769. json.Unmarshal([]byte(infoStr), &rf)
  12770. var insuplc_admdvs string
  12771. var insutype string
  12772. var is390 int = 0
  12773. var is310 int = 0
  12774. var insutypes []*ResultFive
  12775. for _, item := range rf {
  12776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12777. insutypes = append(insutypes, item)
  12778. }
  12779. }
  12780. if len(insutypes) == 1 {
  12781. insutype = insutypes[0].Insutype
  12782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12783. } else {
  12784. for _, i := range insutypes {
  12785. if i.Insutype == "390" {
  12786. is390 = 1
  12787. }
  12788. if i.Insutype == "310" {
  12789. is310 = 1
  12790. }
  12791. }
  12792. }
  12793. if is390 == 1 {
  12794. insutype = "390"
  12795. }
  12796. if is310 == 1 {
  12797. insutype = "310"
  12798. }
  12799. if len(insutypes) == 2 {
  12800. insutype = insutype_two
  12801. }
  12802. if len(insutypes) == 0 {
  12803. insutype = "310"
  12804. }
  12805. insutype = insutype_two
  12806. fmt.Println(insutype)
  12807. for _, item := range rf {
  12808. fmt.Println(item.Insutype)
  12809. fmt.Println(insutype)
  12810. if item.Insutype == insutype {
  12811. fmt.Println(item.Insutype)
  12812. fmt.Println(insutype)
  12813. insuplc_admdvs = item.InsuplcAdmdvs
  12814. }
  12815. }
  12816. fmt.Println(insuplc_admdvs)
  12817. var res2 ResultThirteen
  12818. var res10265_2 ResultThirteen10265
  12819. if config.IsOpen == 1 {
  12820. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12821. } else {
  12822. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  12823. var dat map[string]interface{}
  12824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12825. fmt.Println(dat)
  12826. } else {
  12827. fmt.Println(err)
  12828. }
  12829. userJSONBytes, _ := json.Marshal(dat)
  12830. if miConfig.Code == "H15049901371" {
  12831. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  12832. utils.ErrorLog("解析失败:%v", err)
  12833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12834. return
  12835. }
  12836. res2.ErrMsg = res10265_2.ErrMsg
  12837. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  12838. res2.Infcode = infocode
  12839. res2.Output = res10265_2.Output
  12840. res2.InfRefmsgid = res10265_2.InfRefmsgid
  12841. } else {
  12842. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12843. utils.ErrorLog("解析失败:%v", err)
  12844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12845. return
  12846. }
  12847. }
  12848. }
  12849. if res2.Infcode == 0 {
  12850. psnResult := &models.GdybPsnNcdsRecord{
  12851. UserOrgId: adminUser.CurrentOrgId,
  12852. PatientId: patient.ID,
  12853. PsnNo: psn_no,
  12854. DoctorId: doctor.AdminUserId,
  12855. DepartmentId: department_id,
  12856. SickType: sick_id,
  12857. Insutype: insutype,
  12858. Ctime: time.Now().Unix(),
  12859. Mtime: time.Now().Unix(),
  12860. Status: 1,
  12861. IsCancel: 1,
  12862. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12863. }
  12864. service.CreatePsnNCDSRecord(psnResult)
  12865. c.ServeSuccessJSON(map[string]interface{}{
  12866. "failed_code": 0,
  12867. "msg": "备案成功",
  12868. "result": psnResult,
  12869. })
  12870. } else {
  12871. c.ServeSuccessJSON(map[string]interface{}{
  12872. "failed_code": -10,
  12873. "msg": res2.ErrMsg,
  12874. })
  12875. return
  12876. }
  12877. }
  12878. }
  12879. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  12880. id, _ := c.GetInt64("id")
  12881. admin_user_id, _ := c.GetInt64("admin_user_id")
  12882. adminUser := c.GetAdminUserInfo()
  12883. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12884. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12885. //config, _ := service.Ge(adminUser.CurrentOrgId)
  12886. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12887. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12888. //var user_name string
  12889. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12890. //if role.ID == 0 {
  12891. // user_name = "xxx"
  12892. //} else {
  12893. // user_name = role.UserName
  12894. //}
  12895. psn_record, _ := service.GetPsnNCDSRecordById(id)
  12896. if psn_record.ID == 0 {
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12898. return
  12899. }
  12900. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12901. var res ResultTwo
  12902. var res10265 ResultTwo10265
  12903. if miConfig.Code == "H15049901371" {
  12904. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12905. utils.ErrorLog("解析失败:%v", err)
  12906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12907. return
  12908. }
  12909. res.ErrMsg = res10265.ErrMsg
  12910. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12911. res.Infcode = infocode
  12912. res.Output = res10265.Output
  12913. res.InfRefmsgid = res10265.InfRefmsgid
  12914. } else {
  12915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12916. utils.ErrorLog("解析失败:%v", err)
  12917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12918. return
  12919. }
  12920. }
  12921. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12922. infoStr := string(Iinfos)
  12923. var rf []*ResultFive
  12924. json.Unmarshal([]byte(infoStr), &rf)
  12925. var insuplc_admdvs string
  12926. var insutype string
  12927. var is390 int = 0
  12928. var is310 int = 0
  12929. var insutypes []*ResultFive
  12930. for _, item := range rf {
  12931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12932. insutypes = append(insutypes, item)
  12933. }
  12934. }
  12935. if len(insutypes) == 1 {
  12936. insutype = insutypes[0].Insutype
  12937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12938. } else {
  12939. for _, i := range insutypes {
  12940. if i.Insutype == "390" {
  12941. is390 = 1
  12942. }
  12943. if i.Insutype == "310" {
  12944. is310 = 1
  12945. }
  12946. }
  12947. }
  12948. if is390 == 1 {
  12949. insutype = "390"
  12950. }
  12951. if is310 == 1 {
  12952. insutype = "310"
  12953. }
  12954. if len(insutypes) == 0 {
  12955. insutype = "310"
  12956. }
  12957. insutype = psn_record.Insutype
  12958. for _, item := range rf {
  12959. if item.Insutype == insutype {
  12960. insuplc_admdvs = item.InsuplcAdmdvs
  12961. }
  12962. }
  12963. if config.IsOpen == 1 {
  12964. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12965. var dat map[string]interface{}
  12966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12967. fmt.Println(dat)
  12968. } else {
  12969. fmt.Println(err)
  12970. }
  12971. userJSONBytes, _ := json.Marshal(dat)
  12972. var res ResultFourteen
  12973. var res10265 ResultFourteen10265
  12974. if miConfig.Code == "H15049901371" {
  12975. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12976. utils.ErrorLog("解析失败:%v", err)
  12977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12978. return
  12979. }
  12980. res.ErrMsg = res10265.ErrMsg
  12981. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12982. res.Infcode = infocode
  12983. res.Output = res10265.Output
  12984. res.InfRefmsgid = res10265.InfRefmsgid
  12985. } else {
  12986. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12987. utils.ErrorLog("解析失败:%v", err)
  12988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. return
  12990. }
  12991. }
  12992. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12993. // utils.ErrorLog("解析失败:%v", err)
  12994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12995. // return
  12996. //}
  12997. if res.Infcode == 0 {
  12998. psn_record.IsCancel = 2
  12999. service.CreatePsnNCDSRecord(&psn_record)
  13000. c.ServeSuccessJSON(map[string]interface{}{
  13001. "failed_code": 0,
  13002. "msg": "撤销备案成功",
  13003. })
  13004. } else {
  13005. c.ServeSuccessJSON(map[string]interface{}{
  13006. "failed_code": -10,
  13007. "msg": res.ErrMsg,
  13008. })
  13009. return
  13010. }
  13011. }
  13012. }
  13013. func (c *HisApiController) TestTest() {
  13014. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13015. fmt.Println(patient.Iinfo)
  13016. }
  13017. type CustomData struct {
  13018. MsgId string
  13019. PsnNo string
  13020. Info string
  13021. }
  13022. func (c *HisApiController) ReversalData() {
  13023. var customData []*CustomData
  13024. custom := &CustomData{
  13025. MsgId: "H44022900158202103301714472004",
  13026. PsnNo: "44020000001101329945",
  13027. Info: "2207",
  13028. }
  13029. customData = append(customData, custom)
  13030. custom1 := &CustomData{
  13031. MsgId: "H4402290015820210330172057803",
  13032. PsnNo: "44020000001101161813",
  13033. Info: "2207",
  13034. }
  13035. customData = append(customData, custom1)
  13036. custom2 := &CustomData{
  13037. MsgId: "H44022900158202103301705198813",
  13038. PsnNo: "44190000133097375417",
  13039. Info: "2207",
  13040. }
  13041. customData = append(customData, custom2)
  13042. custom3 := &CustomData{
  13043. MsgId: "H44022900158202103301715524756",
  13044. PsnNo: "44020000001100187221",
  13045. Info: "2207",
  13046. }
  13047. customData = append(customData, custom3)
  13048. custom4 := &CustomData{
  13049. MsgId: "H44022900158202103301730376224",
  13050. PsnNo: "44020000001101959155",
  13051. Info: "2207",
  13052. }
  13053. customData = append(customData, custom4)
  13054. custom5 := &CustomData{
  13055. MsgId: "H44022900158202103301748008725",
  13056. PsnNo: "44020000001104246641",
  13057. Info: "2207",
  13058. }
  13059. customData = append(customData, custom5)
  13060. custom6 := &CustomData{
  13061. MsgId: "H44022900158202103301718096755",
  13062. PsnNo: "44020000001102211860",
  13063. Info: "2207",
  13064. }
  13065. customData = append(customData, custom6)
  13066. custom7 := &CustomData{
  13067. MsgId: "H44022900158202103301736551640",
  13068. PsnNo: "44020000001102687718",
  13069. Info: "2207",
  13070. }
  13071. customData = append(customData, custom7)
  13072. custom8 := &CustomData{
  13073. MsgId: "H44022900158202103301743097676",
  13074. PsnNo: "44020000001102127785",
  13075. Info: "2207",
  13076. }
  13077. customData = append(customData, custom8)
  13078. custom9 := &CustomData{
  13079. MsgId: "H44022900158202103301712304203",
  13080. PsnNo: "44020000001101518097",
  13081. Info: "2207",
  13082. }
  13083. customData = append(customData, custom9)
  13084. custom10 := &CustomData{
  13085. MsgId: "H44022900158202103301738448785",
  13086. PsnNo: "44020000001100500813",
  13087. Info: "2207",
  13088. }
  13089. customData = append(customData, custom10)
  13090. custom11 := &CustomData{
  13091. MsgId: "H44022900158202103301732455843",
  13092. PsnNo: "44020000001102690557",
  13093. Info: "2207",
  13094. }
  13095. customData = append(customData, custom11)
  13096. custom12 := &CustomData{
  13097. MsgId: "H44022900158202103301745421708",
  13098. PsnNo: "44020000001102211928",
  13099. Info: "2207",
  13100. }
  13101. customData = append(customData, custom12)
  13102. custom1212 := &CustomData{
  13103. MsgId: "H440229001582021033017351627",
  13104. PsnNo: "44020000001102481733",
  13105. Info: "2207",
  13106. }
  13107. customData = append(customData, custom1212)
  13108. custom13 := &CustomData{
  13109. MsgId: "H44022900158202103301740327951",
  13110. PsnNo: "44020000001103174866",
  13111. Info: "2207",
  13112. }
  13113. customData = append(customData, custom13)
  13114. custom14 := &CustomData{
  13115. MsgId: "H4402290015820210330174922668",
  13116. PsnNo: "44020000001102927272",
  13117. Info: "2207",
  13118. }
  13119. customData = append(customData, custom14)
  13120. custom15 := &CustomData{
  13121. MsgId: "H44022900158202103301752362273",
  13122. PsnNo: "44020000001102942890",
  13123. Info: "2207",
  13124. }
  13125. customData = append(customData, custom15)
  13126. custom16 := &CustomData{
  13127. MsgId: "H44022900158202103301751082917",
  13128. PsnNo: "44020000001101662162",
  13129. Info: "2207",
  13130. }
  13131. customData = append(customData, custom16)
  13132. custom17 := &CustomData{
  13133. MsgId: "H44022900158202103301754147728",
  13134. PsnNo: "44020000000229014511",
  13135. Info: "2207",
  13136. }
  13137. customData = append(customData, custom17)
  13138. adminUser := c.GetAdminUserInfo()
  13139. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13140. for _, item := range customData {
  13141. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13142. fmt.Println(result)
  13143. }
  13144. }
  13145. //func (c *HisApiController) GetAllopatry() {
  13146. // year := c.GetString("year")
  13147. // month := c.GetString("month")
  13148. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13149. // adminUser := c.GetAdminUserInfo()
  13150. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13151. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13152. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13153. //
  13154. // var dat map[string]interface{}
  13155. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13156. // fmt.Println(dat)
  13157. // } else {
  13158. // fmt.Println(err)
  13159. // }
  13160. // userJSONBytes, _ := json.Marshal(dat)
  13161. // var res models.Result9001
  13162. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13163. // utils.ErrorLog("解析失败:%v", err)
  13164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. // return
  13166. // }
  13167. //
  13168. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13169. // var dat2 map[string]interface{}
  13170. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13171. // fmt.Println(dat)
  13172. // } else {
  13173. // fmt.Println(err)
  13174. // }
  13175. // userJSONBytes2, _ := json.Marshal(dat2)
  13176. // var res2 models.Result3260
  13177. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13178. // utils.ErrorLog("解析失败:%v", err)
  13179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13180. // return
  13181. // }
  13182. // if res2.Infcode == 0 {
  13183. // c.ServeSuccessJSON(map[string]interface{}{
  13184. // "list": res2.Output.Data,
  13185. // })
  13186. // return
  13187. // } else {
  13188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13189. // return
  13190. // }
  13191. //
  13192. //}
  13193. //func (c *HisApiController) ComfirmAllopatry() {
  13194. // year := c.GetString("year")
  13195. // month := c.GetString("month")
  13196. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13197. // adminUser := c.GetAdminUserInfo()
  13198. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13199. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13200. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13201. // var dat map[string]interface{}
  13202. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13203. // fmt.Println(dat)
  13204. // } else {
  13205. // fmt.Println(err)
  13206. // }
  13207. // userJSONBytes, _ := json.Marshal(dat)
  13208. // var res models.Result9001
  13209. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13210. // utils.ErrorLog("解析失败:%v", err)
  13211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13212. // return
  13213. // }
  13214. //
  13215. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13216. // var dat2 map[string]interface{}
  13217. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13218. // fmt.Println(dat)
  13219. // } else {
  13220. // fmt.Println(err)
  13221. // }
  13222. // userJSONBytes2, _ := json.Marshal(dat2)
  13223. // var res2 models.Result3260
  13224. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13225. // utils.ErrorLog("解析失败:%v", err)
  13226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13227. // return
  13228. // }
  13229. //
  13230. // if res2.Infcode == 0 {
  13231. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13232. // var dat map[string]interface{}
  13233. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13234. // fmt.Println(dat)
  13235. // } else {
  13236. // fmt.Println(err)
  13237. // }
  13238. // userJSONBytes, _ := json.Marshal(dat)
  13239. // var res3 models.Result3261
  13240. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13241. // utils.ErrorLog("解析失败:%v", err)
  13242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13243. // return
  13244. // }
  13245. //
  13246. // if res3.Infcode == 0 {
  13247. // record := &models.HisYidiClearRecord{
  13248. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13249. // Ctime: time.Now().Unix(),
  13250. // Mtime: time.Now().Unix(),
  13251. // Status: 1,
  13252. // MsgId: msgId,
  13253. // }
  13254. // service.SaveClearRecord(record)
  13255. // c.ServeSuccessJSON(map[string]interface{}{
  13256. // "msg": "提取成功",
  13257. // })
  13258. // }
  13259. // }
  13260. //}
  13261. func (c *HisApiController) RefundAllopatry() {
  13262. year := c.GetString("year")
  13263. month := c.GetString("month")
  13264. id, _ := c.GetInt64("id")
  13265. admin_user_id, _ := c.GetInt64("admin_user_id")
  13266. adminUser := c.GetAdminUserInfo()
  13267. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13268. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13269. record, _ := service.GetClearRecordById(id)
  13270. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13271. var dat map[string]interface{}
  13272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13273. fmt.Println(dat)
  13274. } else {
  13275. fmt.Println(err)
  13276. }
  13277. userJSONBytes, _ := json.Marshal(dat)
  13278. var empty ResultFourteen
  13279. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13280. utils.ErrorLog("解析失败:%v", err)
  13281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13282. return
  13283. }
  13284. if empty.Infcode == 0 {
  13285. c.ServeSuccessJSON(map[string]interface{}{
  13286. "msg": "撤销成功",
  13287. })
  13288. return
  13289. }
  13290. }
  13291. func (c *HisApiController) ReversalOtherData() {
  13292. var customData []*CustomData
  13293. custom := &CustomData{
  13294. MsgId: "H44022900158202103301714472004",
  13295. PsnNo: "44020000001101329945",
  13296. Info: "2208",
  13297. }
  13298. customData = append(customData, custom)
  13299. custom1 := &CustomData{
  13300. MsgId: "H4402290015820210330172057803",
  13301. PsnNo: "44020000001101161813",
  13302. Info: "2208",
  13303. }
  13304. customData = append(customData, custom1)
  13305. custom2 := &CustomData{
  13306. MsgId: "H44022900158202103301705198813",
  13307. PsnNo: "44190000133097375417",
  13308. Info: "2208",
  13309. }
  13310. customData = append(customData, custom2)
  13311. custom3 := &CustomData{
  13312. MsgId: "H44022900158202103301715524756",
  13313. PsnNo: "44020000001100187221",
  13314. Info: "2208",
  13315. }
  13316. customData = append(customData, custom3)
  13317. custom4 := &CustomData{
  13318. MsgId: "H44022900158202103301730376224",
  13319. PsnNo: "44020000001101959155",
  13320. Info: "2208",
  13321. }
  13322. customData = append(customData, custom4)
  13323. custom5 := &CustomData{
  13324. MsgId: "H44022900158202103301748008725",
  13325. PsnNo: "44020000001104246641",
  13326. Info: "2208",
  13327. }
  13328. customData = append(customData, custom5)
  13329. custom6 := &CustomData{
  13330. MsgId: "H44022900158202103301718096755",
  13331. PsnNo: "44020000001102211860",
  13332. Info: "2208",
  13333. }
  13334. customData = append(customData, custom6)
  13335. custom7 := &CustomData{
  13336. MsgId: "H44022900158202103301736551640",
  13337. PsnNo: "44020000001102687718",
  13338. Info: "2208",
  13339. }
  13340. customData = append(customData, custom7)
  13341. custom8 := &CustomData{
  13342. MsgId: "H44022900158202103301743097676",
  13343. PsnNo: "44020000001102127785",
  13344. Info: "2208",
  13345. }
  13346. customData = append(customData, custom8)
  13347. custom9 := &CustomData{
  13348. MsgId: "H44022900158202103301712304203",
  13349. PsnNo: "44020000001101518097",
  13350. Info: "2208",
  13351. }
  13352. customData = append(customData, custom9)
  13353. custom10 := &CustomData{
  13354. MsgId: "H44022900158202103301738448785",
  13355. PsnNo: "44020000001100500813",
  13356. Info: "2208",
  13357. }
  13358. customData = append(customData, custom10)
  13359. custom11 := &CustomData{
  13360. MsgId: "H44022900158202103301732455843",
  13361. PsnNo: "44020000001102690557",
  13362. Info: "2208",
  13363. }
  13364. customData = append(customData, custom11)
  13365. custom12 := &CustomData{
  13366. MsgId: "H44022900158202103301745421708",
  13367. PsnNo: "44020000001102211928",
  13368. Info: "2208",
  13369. }
  13370. customData = append(customData, custom12)
  13371. custom1212 := &CustomData{
  13372. MsgId: "H440229001582021033017351627",
  13373. PsnNo: "44020000001102481733",
  13374. Info: "2208",
  13375. }
  13376. customData = append(customData, custom1212)
  13377. custom13 := &CustomData{
  13378. MsgId: "H44022900158202103301740327951",
  13379. PsnNo: "44020000001103174866",
  13380. Info: "2208",
  13381. }
  13382. customData = append(customData, custom13)
  13383. custom14 := &CustomData{
  13384. MsgId: "H4402290015820210330174922668",
  13385. PsnNo: "44020000001102927272",
  13386. Info: "2208",
  13387. }
  13388. customData = append(customData, custom14)
  13389. custom15 := &CustomData{
  13390. MsgId: "H44022900158202103301752362273",
  13391. PsnNo: "44020000001102942890",
  13392. Info: "2208",
  13393. }
  13394. customData = append(customData, custom15)
  13395. custom16 := &CustomData{
  13396. MsgId: "H44022900158202103301751082917",
  13397. PsnNo: "44020000001101662162",
  13398. Info: "2208",
  13399. }
  13400. customData = append(customData, custom16)
  13401. custom17 := &CustomData{
  13402. MsgId: "H44022900158202103301754147728",
  13403. PsnNo: "44020000000229014511",
  13404. Info: "2208",
  13405. }
  13406. customData = append(customData, custom17)
  13407. adminUser := c.GetAdminUserInfo()
  13408. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13409. for _, item := range customData {
  13410. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13411. fmt.Println(result)
  13412. }
  13413. }
  13414. func PathExists(path string) (bool, error) {
  13415. _, err := os.Stat(path)
  13416. if err == nil {
  13417. return true, nil
  13418. }
  13419. if os.IsNotExist(err) {
  13420. return false, nil
  13421. }
  13422. return false, err
  13423. }
  13424. //创建文件夹
  13425. func Mkdir(dir string) {
  13426. // 创建文件夹
  13427. exist, err := PathExists(dir)
  13428. if err != nil {
  13429. fmt.Println(err.Error())
  13430. } else {
  13431. if exist {
  13432. fmt.Println(dir + "文件夹已存在!")
  13433. } else {
  13434. // 文件夹名称,权限
  13435. err := os.Mkdir(dir, os.ModePerm)
  13436. if err != nil {
  13437. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13438. } else {
  13439. fmt.Println(dir + "文件夹创建成功!")
  13440. }
  13441. }
  13442. }
  13443. }
  13444. //压缩文件
  13445. func Zip(srcFile string, destZip string) error {
  13446. zipfile, err := os.Create(destZip)
  13447. if err != nil {
  13448. return err
  13449. }
  13450. defer zipfile.Close()
  13451. archive := zip.NewWriter(zipfile)
  13452. defer archive.Close()
  13453. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13454. if err != nil {
  13455. return err
  13456. }
  13457. header, err := zip.FileInfoHeader(info)
  13458. if err != nil {
  13459. return err
  13460. }
  13461. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13462. // header.Name = path
  13463. if info.IsDir() {
  13464. header.Name += "/"
  13465. } else {
  13466. header.Method = zip.Deflate
  13467. }
  13468. writer, err := archive.CreateHeader(header)
  13469. if err != nil {
  13470. return err
  13471. }
  13472. if !info.IsDir() {
  13473. file, err := os.Open(path)
  13474. if err != nil {
  13475. return err
  13476. }
  13477. defer file.Close()
  13478. _, err = io.Copy(writer, file)
  13479. }
  13480. return err
  13481. })
  13482. return err
  13483. }
  13484. func ReadFile(filePath string) []byte {
  13485. f, err := os.Open(filePath)
  13486. if err != nil {
  13487. fmt.Println("read file fail", err)
  13488. return nil
  13489. }
  13490. defer f.Close()
  13491. fd, err := ioutil.ReadAll(f)
  13492. if err != nil {
  13493. fmt.Println("read to fd fail", err)
  13494. return nil
  13495. }
  13496. return fd
  13497. }
  13498. func saveLog(result string, request string, infno string, desc string) {
  13499. org_id, _ := beego.AppConfig.Int64("org_id")
  13500. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13501. dir := miConfig.OrgName + "日志"
  13502. utils.Mkdir(dir)
  13503. month := time.Unix(1557042972, 0).Format("1")
  13504. year := time.Now().Format("2006")
  13505. month = time.Now().Format("01")
  13506. day := time.Now().Format("02")
  13507. hour := time.Now().Format("15")
  13508. min := time.Now().Format("04")
  13509. sec := time.Now().Format("05")
  13510. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13511. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13512. file_name := file + ".txt"
  13513. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13514. exist, _ := utils.PathExists(file_path)
  13515. if exist { //存在
  13516. fmt.Println("存在")
  13517. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13518. if err != nil {
  13519. fmt.Println("read fail")
  13520. }
  13521. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13522. n, _ := f.Seek(0, 2)
  13523. _, err = f.WriteAt([]byte(content), n)
  13524. } else { //不存在
  13525. fmt.Println("文件不存在,创建文件")
  13526. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13527. defer f.Close()
  13528. if err != nil {
  13529. } else {
  13530. _, err = f.Write([]byte("记录日志"))
  13531. }
  13532. }
  13533. }
  13534. type Charset string
  13535. const (
  13536. UTF8 = Charset("UTF-8")
  13537. GB18030 = Charset("GB18030")
  13538. )
  13539. func ConvertToString(src string, srcCode string, tagCode string) string {
  13540. srcCoder := mahonia.NewDecoder(srcCode)
  13541. srcResult := srcCoder.ConvertString(src)
  13542. tagCoder := mahonia.NewDecoder(tagCode)
  13543. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13544. result := string(cdata)
  13545. return result
  13546. }
  13547. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13548. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13549. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13550. var token string
  13551. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13552. var api string
  13553. if miConfig.MdtrtareaAdmvs == "320921" {
  13554. 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 +
  13555. "&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
  13556. fmt.Println(api)
  13557. } else {
  13558. 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 +
  13559. "&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
  13560. }
  13561. resp, requestErr := http.Get(api)
  13562. if requestErr != nil {
  13563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13564. return ""
  13565. }
  13566. body, ioErr := ioutil.ReadAll(resp.Body)
  13567. if ioErr != nil {
  13568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13570. return ""
  13571. }
  13572. var respJSON map[string]interface{}
  13573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13576. return ""
  13577. }
  13578. var status string
  13579. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13580. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13581. var res ResultTwo //1101结果
  13582. var res10265 ResultTwo10265 //1101结果
  13583. if status == "0" { //读卡成功
  13584. var card_info string //卡信息
  13585. var busi_card_info string
  13586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13587. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13588. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13589. fmt.Println(card_info)
  13590. fmt.Println(busi_card_info)
  13591. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13592. result, _ := json.Marshal(respJSON)
  13593. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13594. utils.ErrorLog("解析失败:%v", err)
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13596. return ""
  13597. }
  13598. res.ErrMsg = res10265.ErrMsg
  13599. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13600. res.Infcode = infocode
  13601. res.Output = res10265.Output
  13602. res.InfRefmsgid = res10265.InfRefmsgid
  13603. if res.Infcode == 0 {
  13604. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13605. if err == gorm.ErrRecordNotFound {
  13606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13607. return ""
  13608. } else if err != nil {
  13609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13610. return ""
  13611. } else {
  13612. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13613. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13614. infoStr := string(Iinfos)
  13615. idetinfoStr := string(Idetinfos)
  13616. psn := &models.HisPsn{
  13617. PsnNo: res.Output.Baseinfo.PsnNo,
  13618. Age: res.Output.Baseinfo.Age,
  13619. PatientId: patient.ID,
  13620. Certno: res.Output.Baseinfo.Certno,
  13621. Brdy: res.Output.Baseinfo.Brdy,
  13622. Gend: res.Output.Baseinfo.Gend,
  13623. Naty: res.Output.Baseinfo.Naty,
  13624. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13625. PsnName: res.Output.Baseinfo.PsnName,
  13626. Idetinfo: idetinfoStr,
  13627. Insuinfo: infoStr,
  13628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13629. CardInfo: card_info,
  13630. VerifyNumber: token,
  13631. }
  13632. service.CreateHisPsn(psn)
  13633. return token
  13634. }
  13635. }
  13636. } else {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13638. return ""
  13639. }
  13640. } else { //读卡失败
  13641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13642. return ""
  13643. }
  13644. return token
  13645. }
  13646. func DeleteExtraSpaceTwo(s string) string {
  13647. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13648. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13649. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13650. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13651. s2 := make([]byte, len(s1)) //定义字符数组切片
  13652. copy(s2, s1) //将字符串复制到切片
  13653. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13654. for len(spc_index) > 0 { //找到适配项
  13655. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13656. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13657. }
  13658. return string(s2)
  13659. }
  13660. func Remove0000(s string) string {
  13661. str := make([]rune, 0, len(s))
  13662. for _, v := range []rune(s) {
  13663. if v == 0 {
  13664. continue
  13665. }
  13666. str = append(str, v)
  13667. }
  13668. return string(str)
  13669. }
  13670. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13671. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13672. readCard := DllDef.MustFindProc("EcQuery")
  13673. pCardInfo := make([]byte, 8192)
  13674. pBusiCardInfo := make([]byte, 8192)
  13675. data := make(map[string]interface{})
  13676. //pData := make(map[string]interface{})
  13677. inputData := make(map[string]interface{})
  13678. inputData["orgId"] = code
  13679. inputData["businessType"] = "01101"
  13680. inputData["operatorId"] = operator_id
  13681. inputData["operatorName"] = operator_name
  13682. inputData["officeId"] = "001"
  13683. inputData["officeName"] = "血透室"
  13684. //
  13685. data["data"] = inputData
  13686. data["transType"] = "ec.query"
  13687. data["orgId"] = code
  13688. bytesData, _ := json.Marshal(data)
  13689. pCardInfo = bytesData
  13690. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13691. fmt.Println(ret2)
  13692. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13693. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13694. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13695. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13696. if ret2 != 0 {
  13697. return "", ""
  13698. }
  13699. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13700. }
  13701. func DeleteExtraSpace(s string) string {
  13702. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13703. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13704. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13705. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13706. s2 := make([]byte, len(s1)) //定义字符数组切片
  13707. copy(s2, s1) //将字符串复制到切片
  13708. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13709. for len(spc_index) > 0 { //找到适配项
  13710. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13711. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13712. }
  13713. return string(s2)
  13714. }
  13715. //对账
  13716. func (c *HisApiController) Post3202() {
  13717. start_time := c.GetString("start_time")
  13718. end_time := c.GetString("end_time")
  13719. //insutype := c.GetString("insutype")
  13720. clr_type := c.GetString("clr_type")
  13721. clr_org := c.GetString("clr_optins")
  13722. admin_user_id, _ := c.GetInt64("admin_user_id")
  13723. adminUser := c.GetAdminUserInfo()
  13724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13725. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13726. if len(clr_org) == 0 {
  13727. clr_org = miConfig.MdtrtareaAdmvs
  13728. }
  13729. timeLayout := "2006-01-02"
  13730. loc, _ := time.LoadLocation("Local")
  13731. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13732. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13733. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13734. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  13735. //fixmedins_setl_cnt := int64(len(orders))
  13736. var medfee_sumamt float64
  13737. var acct_pay float64
  13738. var fund_pay_sumamt float64
  13739. for _, item := range orders {
  13740. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13741. acct_pay = acct_pay + item.AcctPay
  13742. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13743. }
  13744. //var medfee_sumamt_two float64
  13745. //var acct_pay_two float64
  13746. //var fund_pay_sumamt_two float64
  13747. //for _, item := range orders_two {
  13748. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  13749. // acct_pay_two = acct_pay_two + item.AcctPay
  13750. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  13751. //}
  13752. //var user_name string
  13753. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13754. //if role.ID == 0 {
  13755. // user_name = "xxx"
  13756. //} else {
  13757. // user_name = role.UserName
  13758. //}
  13759. var res ResultSix
  13760. if config.IsOpen == 1 {
  13761. var bps []*models.BusinessParamsTwo
  13762. var bp models.BusinessParamsTwo
  13763. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  13764. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  13765. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  13766. bp.MedfeeSumamt = medfee_sumamt_str
  13767. bp.AcctPay = acct_pay_str
  13768. bp.FundPaySumamt = fund_pay_sumamt_str
  13769. bp.Insutype = "390"
  13770. bp.StmtBegndate = start_time
  13771. bp.ClrType = clr_type
  13772. bp.SetlOptins = clr_org
  13773. bp.StmtEnddate = end_time
  13774. bps = append(bps, &bp)
  13775. data := make(map[string]interface{})
  13776. data["bps"] = bps
  13777. data["org_name"] = miConfig.OrgName
  13778. data["doctor"] = role.UserName
  13779. data["fixmedins_code"] = miConfig.Code
  13780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13782. if miConfig.MdtrtareaAdmvs == "421300" {
  13783. client := &http.Client{}
  13784. bytesData, _ := json.Marshal(data)
  13785. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  13786. resp, _ := client.Do(req)
  13787. defer resp.Body.Close()
  13788. body, ioErr := ioutil.ReadAll(resp.Body)
  13789. if ioErr != nil {
  13790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13792. return
  13793. }
  13794. var respJSON map[string]interface{}
  13795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13798. return
  13799. }
  13800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13801. userJSONBytes, _ := json.Marshal(respJSON)
  13802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13803. utils.ErrorLog("解析失败:%v", err)
  13804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13805. return
  13806. }
  13807. }
  13808. if res.Infcode == 0 {
  13809. c.ServeSuccessJSON(map[string]interface{}{
  13810. "msg": "发起成功",
  13811. })
  13812. } else {
  13813. c.ServeSuccessJSON(map[string]interface{}{
  13814. "code": -10,
  13815. "msg": res.ErrMsg,
  13816. })
  13817. }
  13818. }
  13819. }
  13820. func (c *HisApiController) Post3501() {
  13821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13822. data := make(map[string]interface{})
  13823. var struct3501s []models.Struct3501
  13824. var struct3501 models.Struct3501
  13825. struct3501.OrgName = miConfig.OrgName
  13826. struct3501.AccessKey = miConfig.AccessKey
  13827. struct3501.RequestUrl = miConfig.Url
  13828. struct3501.SecretKey = miConfig.SecretKey
  13829. struct3501.ManuDate = "2022-08-17"
  13830. struct3501.FixmedinsBchno = ""
  13831. struct3501.ManuLotnum = ""
  13832. struct3501.RxFlag = "0"
  13833. struct3501.ExpyEnd = "2022-08-17"
  13834. struct3501.Invdate = "2022-08-17"
  13835. struct3501.InvCnt = "20.25"
  13836. struct3501.Memo = ""
  13837. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13838. struct3501.FixmedinsHilistId = miConfig.Code
  13839. struct3501.FixmedinsHilistName = miConfig.OrgName
  13840. struct3501s = append(struct3501s, struct3501)
  13841. data["struct_3501s"] = struct3501s
  13842. client := &http.Client{}
  13843. bytesData, _ := json.Marshal(data)
  13844. var req *http.Request
  13845. if miConfig.MdtrtareaAdmvs == "320921" {
  13846. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13847. } else {
  13848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13849. }
  13850. resp, _ := client.Do(req)
  13851. defer resp.Body.Close()
  13852. body, ioErr := ioutil.ReadAll(resp.Body)
  13853. if ioErr != nil {
  13854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13856. return
  13857. }
  13858. var respJSON map[string]interface{}
  13859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13862. return
  13863. }
  13864. var res ResultSix
  13865. var resSix10265 ResultSix10265 //1101结果
  13866. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13867. result, _ := json.Marshal(respJSON)
  13868. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13869. utils.ErrorLog("解析失败:%v", err)
  13870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13871. return
  13872. }
  13873. res.InfRefmsgid = resSix10265.InfRefmsgid
  13874. res.Output = resSix10265.Output
  13875. res.ErrMsg = resSix10265.ErrMsg
  13876. res.Cainfo = resSix10265.Cainfo
  13877. res.WarnMsg = resSix10265.WarnMsg
  13878. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13879. res.Infcode = infocode
  13880. if infocode == 0 {
  13881. c.ServeSuccessJSON(map[string]interface{}{
  13882. "msg": "上传成功",
  13883. })
  13884. return
  13885. } else {
  13886. c.ServeSuccessJSON(map[string]interface{}{
  13887. "failed_code": -10,
  13888. "msg": res.ErrMsg,
  13889. })
  13890. return
  13891. }
  13892. }
  13893. func (c *HisApiController) Post3502() {
  13894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13895. data := make(map[string]interface{})
  13896. var struct3502s []models.Struct3502
  13897. var struct3502 models.Struct3502
  13898. struct3502.OrgName = miConfig.OrgName
  13899. struct3502.AccessKey = miConfig.AccessKey
  13900. struct3502.RequestUrl = miConfig.Url
  13901. struct3502.SecretKey = miConfig.SecretKey
  13902. struct3502.ManuDate = "2022-08-15"
  13903. struct3502.FixmedinsBchno = ""
  13904. struct3502.ManuLotnum = ""
  13905. struct3502.RxFlag = "0"
  13906. struct3502.ExpyEnd = "2022-08-15"
  13907. struct3502.Invdate = "2022-08-15"
  13908. struct3502.InvCnt = "20.25"
  13909. struct3502.Memo = ""
  13910. struct3502.MedListCodg = "XB01ABD056B002020200517"
  13911. struct3502.FixmedinsHilistId = miConfig.Code
  13912. struct3502.FixmedinsHilistName = miConfig.OrgName
  13913. struct3502s = append(struct3502s, struct3502)
  13914. data["struct_3502s"] = struct3502s
  13915. client := &http.Client{}
  13916. bytesData, _ := json.Marshal(data)
  13917. var req *http.Request
  13918. if miConfig.MdtrtareaAdmvs == "320921" {
  13919. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13920. } else {
  13921. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13922. }
  13923. resp, _ := client.Do(req)
  13924. defer resp.Body.Close()
  13925. body, ioErr := ioutil.ReadAll(resp.Body)
  13926. if ioErr != nil {
  13927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. var respJSON map[string]interface{}
  13932. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13935. return
  13936. }
  13937. var res ResultSix
  13938. var resSix10265 ResultSix10265 //1101结果
  13939. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13940. result, _ := json.Marshal(respJSON)
  13941. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13942. utils.ErrorLog("解析失败:%v", err)
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13944. return
  13945. }
  13946. res.InfRefmsgid = resSix10265.InfRefmsgid
  13947. res.Output = resSix10265.Output
  13948. res.ErrMsg = resSix10265.ErrMsg
  13949. res.Cainfo = resSix10265.Cainfo
  13950. res.WarnMsg = resSix10265.WarnMsg
  13951. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13952. res.Infcode = infocode
  13953. if infocode == 0 {
  13954. c.ServeSuccessJSON(map[string]interface{}{
  13955. "msg": "上传成功",
  13956. })
  13957. return
  13958. } else {
  13959. c.ServeSuccessJSON(map[string]interface{}{
  13960. "failed_code": -10,
  13961. "msg": res.ErrMsg,
  13962. })
  13963. return
  13964. }
  13965. }
  13966. func (c *HisApiController) Post3503() {
  13967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13968. data := make(map[string]interface{})
  13969. var struct3501s []models.Struct3501
  13970. var struct3501 models.Struct3501
  13971. struct3501.OrgName = miConfig.OrgName
  13972. struct3501.AccessKey = miConfig.AccessKey
  13973. struct3501.RequestUrl = miConfig.Url
  13974. struct3501.SecretKey = miConfig.SecretKey
  13975. struct3501.ManuDate = "2022-08-15"
  13976. struct3501.FixmedinsBchno = ""
  13977. struct3501.ManuLotnum = ""
  13978. struct3501.RxFlag = "0"
  13979. struct3501.ExpyEnd = "2022-08-15"
  13980. struct3501.Invdate = "2022-08-15"
  13981. struct3501.InvCnt = "20.25"
  13982. struct3501.Memo = ""
  13983. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13984. struct3501.FixmedinsHilistId = miConfig.Code
  13985. struct3501.FixmedinsHilistName = miConfig.OrgName
  13986. struct3501s = append(struct3501s, struct3501)
  13987. data["struct_3501s"] = struct3501s
  13988. client := &http.Client{}
  13989. bytesData, _ := json.Marshal(data)
  13990. var req *http.Request
  13991. if miConfig.MdtrtareaAdmvs == "320921" {
  13992. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13993. } else {
  13994. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13995. }
  13996. resp, _ := client.Do(req)
  13997. defer resp.Body.Close()
  13998. body, ioErr := ioutil.ReadAll(resp.Body)
  13999. if ioErr != nil {
  14000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14002. return
  14003. }
  14004. var respJSON map[string]interface{}
  14005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14008. return
  14009. }
  14010. var res ResultSix
  14011. var resSix10265 ResultSix10265 //1101结果
  14012. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14013. result, _ := json.Marshal(respJSON)
  14014. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14015. utils.ErrorLog("解析失败:%v", err)
  14016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14017. return
  14018. }
  14019. res.InfRefmsgid = resSix10265.InfRefmsgid
  14020. res.Output = resSix10265.Output
  14021. res.ErrMsg = resSix10265.ErrMsg
  14022. res.Cainfo = resSix10265.Cainfo
  14023. res.WarnMsg = resSix10265.WarnMsg
  14024. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14025. res.Infcode = infocode
  14026. if infocode == 0 {
  14027. c.ServeSuccessJSON(map[string]interface{}{
  14028. "msg": "上传成功",
  14029. })
  14030. return
  14031. } else {
  14032. c.ServeSuccessJSON(map[string]interface{}{
  14033. "failed_code": -10,
  14034. "msg": res.ErrMsg,
  14035. })
  14036. return
  14037. }
  14038. }
  14039. func (c *HisApiController) Post3504() {
  14040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14041. data := make(map[string]interface{})
  14042. var struct3501s []models.Struct3501
  14043. var struct3501 models.Struct3501
  14044. struct3501.OrgName = miConfig.OrgName
  14045. struct3501.AccessKey = miConfig.AccessKey
  14046. struct3501.RequestUrl = miConfig.Url
  14047. struct3501.SecretKey = miConfig.SecretKey
  14048. struct3501.ManuDate = "2022-08-15"
  14049. struct3501.FixmedinsBchno = ""
  14050. struct3501.ManuLotnum = ""
  14051. struct3501.RxFlag = "0"
  14052. struct3501.ExpyEnd = "2022-08-15"
  14053. struct3501.Invdate = "2022-08-15"
  14054. struct3501.InvCnt = "20.25"
  14055. struct3501.Memo = ""
  14056. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14057. struct3501.FixmedinsHilistId = miConfig.Code
  14058. struct3501.FixmedinsHilistName = miConfig.OrgName
  14059. struct3501s = append(struct3501s, struct3501)
  14060. data["struct_3501s"] = struct3501s
  14061. client := &http.Client{}
  14062. bytesData, _ := json.Marshal(data)
  14063. var req *http.Request
  14064. if miConfig.MdtrtareaAdmvs == "320921" {
  14065. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14066. } else {
  14067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14068. }
  14069. resp, _ := client.Do(req)
  14070. defer resp.Body.Close()
  14071. body, ioErr := ioutil.ReadAll(resp.Body)
  14072. if ioErr != nil {
  14073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14075. return
  14076. }
  14077. var respJSON map[string]interface{}
  14078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14081. return
  14082. }
  14083. var res ResultSix
  14084. var resSix10265 ResultSix10265 //1101结果
  14085. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14086. result, _ := json.Marshal(respJSON)
  14087. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14088. utils.ErrorLog("解析失败:%v", err)
  14089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14090. return
  14091. }
  14092. res.InfRefmsgid = resSix10265.InfRefmsgid
  14093. res.Output = resSix10265.Output
  14094. res.ErrMsg = resSix10265.ErrMsg
  14095. res.Cainfo = resSix10265.Cainfo
  14096. res.WarnMsg = resSix10265.WarnMsg
  14097. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14098. res.Infcode = infocode
  14099. if infocode == 0 {
  14100. c.ServeSuccessJSON(map[string]interface{}{
  14101. "msg": "上传成功",
  14102. })
  14103. return
  14104. } else {
  14105. c.ServeSuccessJSON(map[string]interface{}{
  14106. "failed_code": -10,
  14107. "msg": res.ErrMsg,
  14108. })
  14109. return
  14110. }
  14111. }
  14112. func (c *HisApiController) Post3505() {
  14113. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14114. data := make(map[string]interface{})
  14115. var struct3501s []models.Struct3501
  14116. var struct3501 models.Struct3501
  14117. struct3501.OrgName = miConfig.OrgName
  14118. struct3501.AccessKey = miConfig.AccessKey
  14119. struct3501.RequestUrl = miConfig.Url
  14120. struct3501.SecretKey = miConfig.SecretKey
  14121. struct3501.ManuDate = "2022-08-15"
  14122. struct3501.FixmedinsBchno = ""
  14123. struct3501.ManuLotnum = ""
  14124. struct3501.RxFlag = "0"
  14125. struct3501.ExpyEnd = "2022-08-15"
  14126. struct3501.Invdate = "2022-08-15"
  14127. struct3501.InvCnt = "20.25"
  14128. struct3501.Memo = ""
  14129. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14130. struct3501.FixmedinsHilistId = miConfig.Code
  14131. struct3501.FixmedinsHilistName = miConfig.OrgName
  14132. struct3501s = append(struct3501s, struct3501)
  14133. data["struct_3501s"] = struct3501s
  14134. client := &http.Client{}
  14135. bytesData, _ := json.Marshal(data)
  14136. var req *http.Request
  14137. if miConfig.MdtrtareaAdmvs == "320921" {
  14138. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14139. } else {
  14140. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14141. }
  14142. resp, _ := client.Do(req)
  14143. defer resp.Body.Close()
  14144. body, ioErr := ioutil.ReadAll(resp.Body)
  14145. if ioErr != nil {
  14146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14148. return
  14149. }
  14150. var respJSON map[string]interface{}
  14151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14154. return
  14155. }
  14156. var res ResultSix
  14157. var resSix10265 ResultSix10265 //1101结果
  14158. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14159. result, _ := json.Marshal(respJSON)
  14160. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14161. utils.ErrorLog("解析失败:%v", err)
  14162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14163. return
  14164. }
  14165. res.InfRefmsgid = resSix10265.InfRefmsgid
  14166. res.Output = resSix10265.Output
  14167. res.ErrMsg = resSix10265.ErrMsg
  14168. res.Cainfo = resSix10265.Cainfo
  14169. res.WarnMsg = resSix10265.WarnMsg
  14170. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14171. res.Infcode = infocode
  14172. if infocode == 0 {
  14173. c.ServeSuccessJSON(map[string]interface{}{
  14174. "msg": "上传成功",
  14175. })
  14176. return
  14177. } else {
  14178. c.ServeSuccessJSON(map[string]interface{}{
  14179. "failed_code": -10,
  14180. "msg": res.ErrMsg,
  14181. })
  14182. return
  14183. }
  14184. }
  14185. func (c *HisApiController) Post3506() {
  14186. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14187. data := make(map[string]interface{})
  14188. var struct3501s []models.Struct3501
  14189. var struct3501 models.Struct3501
  14190. struct3501.OrgName = miConfig.OrgName
  14191. struct3501.AccessKey = miConfig.AccessKey
  14192. struct3501.RequestUrl = miConfig.Url
  14193. struct3501.SecretKey = miConfig.SecretKey
  14194. struct3501.ManuDate = "2022-08-15"
  14195. struct3501.FixmedinsBchno = ""
  14196. struct3501.ManuLotnum = ""
  14197. struct3501.RxFlag = "0"
  14198. struct3501.ExpyEnd = "2022-08-15"
  14199. struct3501.Invdate = "2022-08-15"
  14200. struct3501.InvCnt = "20.25"
  14201. struct3501.Memo = ""
  14202. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14203. struct3501.FixmedinsHilistId = miConfig.Code
  14204. struct3501.FixmedinsHilistName = miConfig.OrgName
  14205. struct3501s = append(struct3501s, struct3501)
  14206. data["struct_3501s"] = struct3501s
  14207. client := &http.Client{}
  14208. bytesData, _ := json.Marshal(data)
  14209. var req *http.Request
  14210. if miConfig.MdtrtareaAdmvs == "320921" {
  14211. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14212. } else {
  14213. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14214. }
  14215. resp, _ := client.Do(req)
  14216. defer resp.Body.Close()
  14217. body, ioErr := ioutil.ReadAll(resp.Body)
  14218. if ioErr != nil {
  14219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14221. return
  14222. }
  14223. var respJSON map[string]interface{}
  14224. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14227. return
  14228. }
  14229. var res ResultSix
  14230. var resSix10265 ResultSix10265 //1101结果
  14231. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14232. result, _ := json.Marshal(respJSON)
  14233. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14234. utils.ErrorLog("解析失败:%v", err)
  14235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14236. return
  14237. }
  14238. res.InfRefmsgid = resSix10265.InfRefmsgid
  14239. res.Output = resSix10265.Output
  14240. res.ErrMsg = resSix10265.ErrMsg
  14241. res.Cainfo = resSix10265.Cainfo
  14242. res.WarnMsg = resSix10265.WarnMsg
  14243. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14244. res.Infcode = infocode
  14245. if infocode == 0 {
  14246. c.ServeSuccessJSON(map[string]interface{}{
  14247. "msg": "上传成功",
  14248. })
  14249. return
  14250. } else {
  14251. c.ServeSuccessJSON(map[string]interface{}{
  14252. "failed_code": -10,
  14253. "msg": res.ErrMsg,
  14254. })
  14255. return
  14256. }
  14257. }
  14258. func (c *HisApiController) Post3507() {
  14259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14260. data := make(map[string]interface{})
  14261. var struct3501s []models.Struct3501
  14262. var struct3501 models.Struct3501
  14263. struct3501.OrgName = miConfig.OrgName
  14264. struct3501.AccessKey = miConfig.AccessKey
  14265. struct3501.RequestUrl = miConfig.Url
  14266. struct3501.SecretKey = miConfig.SecretKey
  14267. struct3501.ManuDate = "2022-08-15"
  14268. struct3501.FixmedinsBchno = ""
  14269. struct3501.ManuLotnum = ""
  14270. struct3501.RxFlag = "0"
  14271. struct3501.ExpyEnd = "2022-08-15"
  14272. struct3501.Invdate = "2022-08-15"
  14273. struct3501.InvCnt = "20.25"
  14274. struct3501.Memo = ""
  14275. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14276. struct3501.FixmedinsHilistId = miConfig.Code
  14277. struct3501.FixmedinsHilistName = miConfig.OrgName
  14278. struct3501s = append(struct3501s, struct3501)
  14279. data["struct_3501s"] = struct3501s
  14280. client := &http.Client{}
  14281. bytesData, _ := json.Marshal(data)
  14282. var req *http.Request
  14283. if miConfig.MdtrtareaAdmvs == "320921" {
  14284. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14285. } else {
  14286. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14287. }
  14288. resp, _ := client.Do(req)
  14289. defer resp.Body.Close()
  14290. body, ioErr := ioutil.ReadAll(resp.Body)
  14291. if ioErr != nil {
  14292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14294. return
  14295. }
  14296. var respJSON map[string]interface{}
  14297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14300. return
  14301. }
  14302. var res ResultSix
  14303. var resSix10265 ResultSix10265 //1101结果
  14304. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14305. result, _ := json.Marshal(respJSON)
  14306. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14307. utils.ErrorLog("解析失败:%v", err)
  14308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14309. return
  14310. }
  14311. res.InfRefmsgid = resSix10265.InfRefmsgid
  14312. res.Output = resSix10265.Output
  14313. res.ErrMsg = resSix10265.ErrMsg
  14314. res.Cainfo = resSix10265.Cainfo
  14315. res.WarnMsg = resSix10265.WarnMsg
  14316. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14317. res.Infcode = infocode
  14318. if infocode == 0 {
  14319. c.ServeSuccessJSON(map[string]interface{}{
  14320. "msg": "上传成功",
  14321. })
  14322. return
  14323. } else {
  14324. c.ServeSuccessJSON(map[string]interface{}{
  14325. "failed_code": -10,
  14326. "msg": res.ErrMsg,
  14327. })
  14328. return
  14329. }
  14330. }