his_api_controller.go 583KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080
  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 if miConfig.MdtrtareaAdmvs == "131023" {
  408. result, _ := service.HeBeiyb9001(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. } else {
  423. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  424. var dat map[string]interface{}
  425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  426. fmt.Println(dat)
  427. } else {
  428. fmt.Println(err)
  429. }
  430. userJSONBytes, _ := json.Marshal(dat)
  431. var res models.Result9001
  432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  433. utils.ErrorLog("解析失败:%v", err)
  434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  435. return
  436. }
  437. }
  438. }
  439. 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) {
  440. var res Result3101
  441. adminUser := c.GetAdminUserInfo()
  442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  443. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  445. //record_time := c.GetString("record_time")
  446. //trig_scen := c.GetString("trig_scen")
  447. timeLayout := "2006-01-02"
  448. loc, _ := time.LoadLocation("Local")
  449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  450. if err != nil {
  451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  452. return res
  453. }
  454. recordDateTime := theTime.Unix()
  455. var patientPrescription models.HisPrescriptionInfo
  456. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  457. //if patientPrescription.ID == 0 {
  458. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  459. //}
  460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  462. //
  463. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  464. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  465. var pp models.PublicParams
  466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  468. pp.FixmedinsName = miConfig.OrgName
  469. pp.FixmedinsCode = miConfig.Code
  470. pp.RequestUrl = miConfig.Url
  471. pp.Cainfo = miConfig.Cainfo
  472. pp.SecretKey = miConfig.SecretKey
  473. pp.AccessKey = miConfig.AccessKey
  474. pp.OpterName = roles.UserName
  475. var config []*models.HisXtDiagnoseConfig
  476. for _, item := range diagnosis_ids {
  477. id, _ := strconv.ParseInt(item, 10, 64)
  478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  479. config = append(config, &diagnosisConfig)
  480. }
  481. var pd models.PatientDtos
  482. pd.PatnID = his.PsnNo
  483. pd.PatnName = his.Name
  484. pd.Gend = his.Gend
  485. pd.Brdy = his.Brdy
  486. pd.Poolarea = miConfig.MdtrtareaAdmvs
  487. pd.CurrMdtrtID = his.Number
  488. var fed models.FsiEncounterDtos
  489. fed.MdtrtID = his.Number
  490. fed.MedinsID = miConfig.Code
  491. fed.MedinsName = miConfig.OrgName
  492. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  493. fed.MedMdtrtType = "1"
  494. fed.MedinsType = "1"
  495. fed.MedinsLv = "11"
  496. tm := time.Unix(his.RecordDate, 0)
  497. s_tm := tm.Format("2006-01-02 15:04:05")
  498. fed.AdmDate = s_tm
  499. fed.DscgDate = s_tm
  500. fed.DscgMainDiseCodg = config[0].CountryCode
  501. fed.DscgMainDiseName = config[0].CountryContentName
  502. //诊断信息
  503. var fdds []*models.FsiDiagnoseDtos
  504. for index, item := range config {
  505. if index == 0 {
  506. var fdd models.FsiDiagnoseDtos
  507. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  508. fdd.InoutDiseType = "1"
  509. fdd.MaindiseFlag = "1"
  510. fdd.DiseDate = s_tm
  511. fdd.DiasSrtNo = "1"
  512. fdd.DiseName = item.CountryContentName
  513. fdd.DiseCodg = item.CountryCode
  514. fdds = append(fdds, &fdd)
  515. } else {
  516. var fdd models.FsiDiagnoseDtos
  517. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  518. fdd.InoutDiseType = "1"
  519. fdd.MaindiseFlag = "1"
  520. fdd.DiseDate = s_tm
  521. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  522. fdd.DiseName = item.CountryContentName
  523. fdd.DiseCodg = item.CountryCode
  524. fdds = append(fdds, &fdd)
  525. }
  526. }
  527. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  528. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  529. fed.AdmDeptName = department.Name
  530. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  531. fed.DscgDeptName = department.Name
  532. fed.MedMdtrtType = "1"
  533. fed.MedType = "11"
  534. //if his.Insutype == "390" {
  535. // fed.MedType = "1402"
  536. //} else {
  537. // fed.MedType = "9933"
  538. //}
  539. var orders []*models.FsiOrderDtos
  540. if trig_scen == "2" {
  541. //处方医嘱信息
  542. for _, item := range prescriptions {
  543. for _, subItem := range item.HisDoctorAdviceInfo {
  544. var order models.FsiOrderDtos
  545. order.RxID = strconv.FormatInt(item.ID, 10)
  546. order.Rxno = strconv.FormatInt(item.ID, 10)
  547. order.LongDrordFlag = "0"
  548. order.HilistType = "1"
  549. order.ChrgType = "1"
  550. order.DrordBhvr = "-"
  551. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  552. order.HosplistName = subItem.BaseDrugLib.DrugName
  553. order.HilistLv = "1"
  554. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  555. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  556. order.HosplistName = subItem.BaseDrugLib.DrugName
  557. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  558. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  559. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  560. order.OwnpayAmt = ""
  561. order.SelfpayAmt = ""
  562. order.Spec = ""
  563. order.SpecUnt = ""
  564. order.DrordBegnDate = s_tm
  565. order.DrordStopDate = ""
  566. order.DrordDrCodg = "1"
  567. order.DrordDeptName = department.Name
  568. order.DrordDrCodg = "1"
  569. order.DrordDrName = doctor_info.UserName
  570. order.DrordDrProfttl = ""
  571. order.CurrDrordFlag = "1"
  572. orders = append(orders, &order)
  573. }
  574. for _, subItem := range item.HisPrescriptionProject {
  575. if subItem.Type == 2 {
  576. var order models.FsiOrderDtos
  577. order.RxID = strconv.FormatInt(item.ID, 10)
  578. order.Rxno = strconv.FormatInt(item.ID, 10)
  579. order.LongDrordFlag = "0"
  580. order.HilistType = "1"
  581. order.ChrgType = "1"
  582. order.DrordBhvr = "-"
  583. order.HilistCode = subItem.HisProject.MedicalCode
  584. order.HosplistName = subItem.HisProject.ProjectName
  585. order.HilistLv = "1"
  586. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  587. order.HosplistCode = subItem.HisProject.MedicalCode
  588. order.HosplistName = subItem.HisProject.ProjectName
  589. order.Cnt = subItem.Count
  590. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  591. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  592. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  593. order.OwnpayAmt = ""
  594. order.SelfpayAmt = ""
  595. order.Spec = ""
  596. order.SpecUnt = ""
  597. order.DrordBegnDate = s_tm
  598. order.DrordStopDate = ""
  599. order.DrordDrCodg = "1"
  600. order.DrordDeptName = department.Name
  601. order.DrordDrCodg = "1"
  602. order.DrordDrName = doctor_info.UserName
  603. order.DrordDrProfttl = ""
  604. order.CurrDrordFlag = "1"
  605. orders = append(orders, &order)
  606. }
  607. if subItem.Type == 3 {
  608. var order models.FsiOrderDtos
  609. order.RxID = strconv.FormatInt(item.ID, 10)
  610. order.Rxno = strconv.FormatInt(item.ID, 10)
  611. order.LongDrordFlag = "0"
  612. order.HilistType = "1"
  613. order.ChrgType = "1"
  614. order.DrordBhvr = "-"
  615. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  616. order.HosplistName = subItem.GoodInfo.GoodName
  617. order.HilistLv = "1"
  618. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  619. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  620. order.HosplistName = subItem.GoodInfo.GoodName
  621. order.Cnt = subItem.Count
  622. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  623. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  624. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  625. order.OwnpayAmt = ""
  626. order.SelfpayAmt = ""
  627. order.Spec = ""
  628. order.SpecUnt = ""
  629. order.DrordBegnDate = s_tm
  630. order.DrordStopDate = ""
  631. order.DrordDrCodg = "1"
  632. order.DrordDeptName = department.Name
  633. order.DrordDrCodg = "1"
  634. order.DrordDrName = doctor_info.UserName
  635. order.DrordDrProfttl = ""
  636. order.CurrDrordFlag = "1"
  637. orders = append(orders, &order)
  638. }
  639. }
  640. }
  641. //处方医嘱信息
  642. }
  643. fed.MatnStas = "0"
  644. fed.MedfeeSumamt = "0"
  645. fed.OwnpayAmt = "0"
  646. fed.SelfpayAmt = "0"
  647. fed.AcctPayamt = "0"
  648. fed.MaAmt = "0"
  649. fed.HifpPayamt = "0"
  650. fed.SetlTotlnum = "1"
  651. fed.Insutype = his.Insutype
  652. fed.ReimFlag = "0"
  653. fed.OutSetlFlag = "0"
  654. var fopd []*models.FsiOperationDtosData
  655. data := make(map[string]interface{})
  656. data["fed"] = fed
  657. data["fdd"] = fdds
  658. data["fod"] = orders
  659. data["pd"] = pd
  660. data["pp"] = pp
  661. data["fopd"] = fopd
  662. data["trig_scen"] = trig_scen
  663. fmt.Println(data)
  664. fmt.Println(fed)
  665. fmt.Println(fdds)
  666. fmt.Println(orders)
  667. fmt.Println(pd)
  668. fmt.Println(pp)
  669. fmt.Println(fopd)
  670. client := &http.Client{}
  671. bytesData, _ := json.Marshal(data)
  672. var req *http.Request
  673. if miConfig.MdtrtareaAdmvs == "320921" {
  674. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  675. } else {
  676. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  677. }
  678. resp, _ := client.Do(req)
  679. defer resp.Body.Close()
  680. body, ioErr := ioutil.ReadAll(resp.Body)
  681. if ioErr != nil {
  682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. return res
  685. }
  686. var respJSON map[string]interface{}
  687. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return res
  691. }
  692. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  693. fmt.Println(respJSON)
  694. result, _ := json.Marshal(respJSON)
  695. fmt.Println(result)
  696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return res
  700. }
  701. return res
  702. }
  703. 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) {
  704. adminUser := c.GetAdminUserInfo()
  705. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  706. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  707. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  708. //record_time := c.GetString("record_time")
  709. //trig_scen := c.GetString("trig_scen")
  710. timeLayout := "2006-01-02"
  711. loc, _ := time.LoadLocation("Local")
  712. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  713. if err != nil {
  714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  715. return res
  716. }
  717. recordDateTime := theTime.Unix()
  718. var patientPrescription models.HisPrescriptionInfo
  719. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  720. if patientPrescription.ID == 0 {
  721. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  722. }
  723. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  724. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  725. //
  726. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  727. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  728. var pp models.PublicParams
  729. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  731. pp.FixmedinsName = miConfig.OrgName
  732. pp.FixmedinsCode = miConfig.Code
  733. pp.RequestUrl = miConfig.Url
  734. pp.Cainfo = miConfig.Cainfo
  735. pp.SecretKey = miConfig.SecretKey
  736. pp.AccessKey = miConfig.AccessKey
  737. pp.OpterName = roles.UserName
  738. var config []*models.HisXtDiagnoseConfig
  739. for _, item := range diagnosis_ids {
  740. id, _ := strconv.ParseInt(item, 10, 64)
  741. diagnosisConfig, _ := service.FindDiagnoseById(id)
  742. config = append(config, &diagnosisConfig)
  743. }
  744. var pd models.PatientDtos
  745. pd.PatnID = his.PsnNo
  746. pd.PatnName = his.Name
  747. pd.Gend = his.Gend
  748. pd.Brdy = his.Brdy
  749. pd.Poolarea = his.InsuplcAdmdvs
  750. pd.CurrMdtrtID = his.Number
  751. var fed models.FsiEncounterDtos
  752. fed.MdtrtID = his.Number
  753. fed.MedinsID = miConfig.Code
  754. fed.MedinsName = miConfig.OrgName
  755. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  756. fed.MedMdtrtType = "1"
  757. fed.MedinsType = "1"
  758. fed.MedinsLv = "11"
  759. tm := time.Unix(his.RecordDate, 0)
  760. s_tm := tm.Format("2006-01-02 15:04:05")
  761. fed.AdmDate = s_tm
  762. fed.DscgDate = s_tm
  763. fed.DscgMainDiseCodg = config[0].CountryCode
  764. fed.DscgMainDiseName = config[0].CountryContentName
  765. //诊断信息
  766. var fdds []*models.FsiDiagnoseDtos
  767. for index, item := range config {
  768. if index == 0 {
  769. var fdd models.FsiDiagnoseDtos
  770. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  771. fdd.InoutDiseType = "1"
  772. fdd.MaindiseFlag = "1"
  773. fdd.DiseDate = s_tm
  774. fdd.DiasSrtNo = "1"
  775. fdd.DiseName = item.CountryContentName
  776. fdd.DiseCodg = item.CountryCode
  777. fdds = append(fdds, &fdd)
  778. } else {
  779. var fdd models.FsiDiagnoseDtos
  780. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  781. fdd.InoutDiseType = "1"
  782. fdd.MaindiseFlag = "1"
  783. fdd.DiseDate = s_tm
  784. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  785. fdd.DiseName = item.CountryContentName
  786. fdd.DiseCodg = item.CountryCode
  787. fdds = append(fdds, &fdd)
  788. }
  789. }
  790. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  791. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  792. fed.AdmDeptName = department.Name
  793. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  794. fed.DscgDeptName = department.Name
  795. fed.MedMdtrtType = "1"
  796. fed.MedType = "11"
  797. //if his.Insutype == "390" {
  798. // fed.MedType = "1402"
  799. //} else {
  800. // fed.MedType = "9933"
  801. //}
  802. var orders []*models.FsiOrderDtos
  803. if trig_scen == "2" {
  804. //处方医嘱信息
  805. for _, item := range prescriptions {
  806. for _, subItem := range item.HisDoctorAdviceInfo {
  807. var order models.FsiOrderDtos
  808. order.RxID = strconv.FormatInt(item.ID, 10)
  809. order.Rxno = strconv.FormatInt(item.ID, 10)
  810. order.LongDrordFlag = "0"
  811. order.HilistType = "1"
  812. order.ChrgType = "1"
  813. order.DrordBhvr = "-"
  814. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  815. order.HosplistName = subItem.BaseDrugLib.DrugName
  816. order.HilistLv = "1"
  817. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  818. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  819. order.HosplistName = subItem.BaseDrugLib.DrugName
  820. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  821. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  822. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  823. order.OwnpayAmt = ""
  824. order.SelfpayAmt = ""
  825. order.Spec = ""
  826. order.SpecUnt = ""
  827. order.DrordBegnDate = s_tm
  828. order.DrordStopDate = ""
  829. order.DrordDrCodg = "1"
  830. order.DrordDeptName = department.Name
  831. order.DrordDrCodg = "1"
  832. order.DrordDrName = doctor_info.UserName
  833. order.DrordDrProfttl = ""
  834. order.CurrDrordFlag = "1"
  835. orders = append(orders, &order)
  836. }
  837. for _, subItem := range item.HisPrescriptionProject {
  838. if subItem.Type == 2 {
  839. var order models.FsiOrderDtos
  840. order.RxID = strconv.FormatInt(item.ID, 10)
  841. order.Rxno = strconv.FormatInt(item.ID, 10)
  842. order.LongDrordFlag = "0"
  843. order.HilistType = "1"
  844. order.ChrgType = "1"
  845. order.DrordBhvr = "-"
  846. order.HilistCode = subItem.HisProject.MedicalCode
  847. order.HosplistName = subItem.HisProject.ProjectName
  848. order.HilistLv = "1"
  849. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  850. order.HosplistCode = subItem.HisProject.MedicalCode
  851. order.HosplistName = subItem.HisProject.ProjectName
  852. order.Cnt = subItem.Count
  853. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  854. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  855. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  856. order.OwnpayAmt = ""
  857. order.SelfpayAmt = ""
  858. order.Spec = ""
  859. order.SpecUnt = ""
  860. order.DrordBegnDate = s_tm
  861. order.DrordStopDate = ""
  862. order.DrordDrCodg = "1"
  863. order.DrordDeptName = department.Name
  864. order.DrordDrCodg = "1"
  865. order.DrordDrName = doctor_info.UserName
  866. order.DrordDrProfttl = ""
  867. order.CurrDrordFlag = "1"
  868. orders = append(orders, &order)
  869. }
  870. if subItem.Type == 3 {
  871. var order models.FsiOrderDtos
  872. order.RxID = strconv.FormatInt(item.ID, 10)
  873. order.Rxno = strconv.FormatInt(item.ID, 10)
  874. order.LongDrordFlag = "0"
  875. order.HilistType = "1"
  876. order.ChrgType = "1"
  877. order.DrordBhvr = "-"
  878. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  879. order.HosplistName = subItem.GoodInfo.GoodName
  880. order.HilistLv = "1"
  881. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  882. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  883. order.HosplistName = subItem.GoodInfo.GoodName
  884. order.Cnt = subItem.Count
  885. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  886. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  887. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  888. order.OwnpayAmt = ""
  889. order.SelfpayAmt = ""
  890. order.Spec = ""
  891. order.SpecUnt = ""
  892. order.DrordBegnDate = s_tm
  893. order.DrordStopDate = ""
  894. order.DrordDrCodg = "1"
  895. order.DrordDeptName = department.Name
  896. order.DrordDrCodg = "1"
  897. order.DrordDrName = doctor_info.UserName
  898. order.DrordDrProfttl = ""
  899. order.CurrDrordFlag = "1"
  900. orders = append(orders, &order)
  901. }
  902. }
  903. }
  904. //处方医嘱信息
  905. }
  906. fed.MatnStas = "0"
  907. fed.MedfeeSumamt = "0"
  908. fed.OwnpayAmt = "0"
  909. fed.SelfpayAmt = "0"
  910. fed.AcctPayamt = "0"
  911. fed.MaAmt = "0"
  912. fed.HifpPayamt = "0"
  913. fed.SetlTotlnum = "1"
  914. fed.Insutype = his.Insutype
  915. fed.ReimFlag = "0"
  916. fed.OutSetlFlag = "0"
  917. var fopd []*models.FsiOperationDtosData
  918. data := make(map[string]interface{})
  919. data["fed"] = fed
  920. data["fdd"] = fdds
  921. data["fod"] = orders
  922. data["pd"] = pd
  923. data["pp"] = pp
  924. data["fopd"] = fopd
  925. data["trig_scen"] = trig_scen
  926. fmt.Println(data)
  927. fmt.Println(fed)
  928. fmt.Println(fdds)
  929. fmt.Println(orders)
  930. fmt.Println(pd)
  931. fmt.Println(pp)
  932. fmt.Println(fopd)
  933. client := &http.Client{}
  934. bytesData, _ := json.Marshal(data)
  935. var req *http.Request
  936. if miConfig.MdtrtareaAdmvs == "320921" {
  937. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  938. } else {
  939. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  940. }
  941. resp, _ := client.Do(req)
  942. defer resp.Body.Close()
  943. body, ioErr := ioutil.ReadAll(resp.Body)
  944. if ioErr != nil {
  945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  947. return res
  948. }
  949. var respJSON map[string]interface{}
  950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  953. return res
  954. }
  955. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  956. result, _ := json.Marshal(respJSON)
  957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  958. utils.ErrorLog("解析失败:%v", err)
  959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  960. return res
  961. }
  962. return res
  963. }
  964. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  965. ////patient_id, _ := c.GetInt64("patient_id")
  966. //order_id, _ := c.GetInt64("order_id")
  967. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  968. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  969. //trig_scen := c.GetString("trig_scen")
  970. adminUser := c.GetAdminUserInfo()
  971. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  972. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  973. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  974. record_time := c.GetString("record_time")
  975. order, _ := service.GetHisOrderByID(order_id)
  976. timeLayout := "2006-01-02"
  977. loc, _ := time.LoadLocation("Local")
  978. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  979. if err != nil {
  980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  981. return
  982. }
  983. recordDateTime := theTime.Unix()
  984. var patientPrescription models.HisPrescriptionInfo
  985. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  986. if patientPrescription.ID == 0 {
  987. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  988. }
  989. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  990. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  991. //
  992. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  993. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  994. var pp models.PublicParams
  995. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  997. pp.FixmedinsName = miConfig.OrgName
  998. pp.FixmedinsCode = miConfig.Code
  999. pp.RequestUrl = miConfig.Url
  1000. pp.Cainfo = miConfig.Cainfo
  1001. pp.SecretKey = miConfig.SecretKey
  1002. pp.AccessKey = miConfig.AccessKey
  1003. pp.OpterName = roles.UserName
  1004. var config []*models.HisXtDiagnoseConfig
  1005. for _, item := range diagnosis_ids {
  1006. id, _ := strconv.ParseInt(item, 10, 64)
  1007. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1008. config = append(config, &diagnosisConfig)
  1009. }
  1010. var pd models.PatientDtos
  1011. pd.PatnID = his.PsnNo
  1012. pd.PatnName = his.Name
  1013. pd.Gend = his.Gend
  1014. pd.Brdy = his.Brdy
  1015. pd.Poolarea = his.InsuplcAdmdvs
  1016. pd.CurrMdtrtID = his.Number
  1017. var fed models.FsiEncounterDtos
  1018. fed.MdtrtID = his.Number
  1019. fed.MedinsID = miConfig.Code
  1020. fed.MedinsName = miConfig.OrgName
  1021. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1022. fed.MedMdtrtType = "1"
  1023. fed.MedinsType = "1"
  1024. fed.MedinsLv = "11"
  1025. tm := time.Unix(his.RecordDate, 0)
  1026. s_tm := tm.Format("2006-01-02 15:04:05")
  1027. fed.AdmDate = s_tm
  1028. fed.DscgDate = s_tm
  1029. fed.DscgMainDiseCodg = config[0].CountryCode
  1030. fed.DscgMainDiseName = config[0].CountryContentName
  1031. //诊断信息
  1032. var fdds []*models.FsiDiagnoseDtos
  1033. for index, item := range config {
  1034. if index == 0 {
  1035. var fdd models.FsiDiagnoseDtos
  1036. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1037. fdd.InoutDiseType = "1"
  1038. fdd.MaindiseFlag = "1"
  1039. fdd.DiseDate = s_tm
  1040. fdd.DiasSrtNo = "1"
  1041. fdd.DiseName = item.CountryContentName
  1042. fdd.DiseCodg = item.CountryCode
  1043. fdds = append(fdds, &fdd)
  1044. } else {
  1045. var fdd models.FsiDiagnoseDtos
  1046. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1047. fdd.InoutDiseType = "1"
  1048. fdd.MaindiseFlag = "1"
  1049. fdd.DiseDate = s_tm
  1050. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1051. fdd.DiseName = item.CountryContentName
  1052. fdd.DiseCodg = item.CountryCode
  1053. fdds = append(fdds, &fdd)
  1054. }
  1055. }
  1056. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1057. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1058. fed.AdmDeptName = department.Name
  1059. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1060. fed.DscgDeptName = department.Name
  1061. fed.MedType = order.MedType
  1062. //处方医嘱信息
  1063. var orders []*models.FsiOrderDtos
  1064. //for _, item := range prescriptions {
  1065. // for _, subItem := range item.HisDoctorAdviceInfo {
  1066. // var order models.FsiOrderDtos
  1067. // order.RxID = strconv.FormatInt(item.ID, 10)
  1068. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1069. // order.LongDrordFlag = "0"
  1070. // order.HilistType = "1"
  1071. // order.ChrgType = "1"
  1072. // order.DrordBhvr = "-"
  1073. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1074. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1075. // order.HilistLv = "1"
  1076. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1077. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1078. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1079. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1080. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1081. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1082. // order.OwnpayAmt = ""
  1083. // order.SelfpayAmt = ""
  1084. // order.Spec = ""
  1085. // order.SpecUnt = ""
  1086. // order.DrordBegnDate = s_tm
  1087. // order.DrordStopDate = ""
  1088. // order.DrordDrCodg = "1"
  1089. // order.DrordDeptName = department.Name
  1090. // order.DrordDrCodg = "1"
  1091. // order.DrordDrName = doctor_info.UserName
  1092. // order.DrordDrProfttl = ""
  1093. // order.CurrDrordFlag = "1"
  1094. // orders = append(orders, &order)
  1095. // }
  1096. // for _, subItem := range item.HisPrescriptionProject {
  1097. // if subItem.Type == 2 {
  1098. // var order models.FsiOrderDtos
  1099. // order.RxID = strconv.FormatInt(item.ID, 10)
  1100. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1101. // order.LongDrordFlag = "0"
  1102. // order.HilistType = "1"
  1103. // order.ChrgType = "1"
  1104. // order.DrordBhvr = "-"
  1105. // order.HilistCode = subItem.HisProject.MedicalCode
  1106. // order.HosplistName = subItem.HisProject.ProjectName
  1107. // order.HilistLv = "1"
  1108. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1109. // order.HosplistCode = subItem.HisProject.MedicalCode
  1110. // order.HosplistName = subItem.HisProject.ProjectName
  1111. // order.Cnt = subItem.Count
  1112. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1113. //
  1114. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1115. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1116. // order.OwnpayAmt = ""
  1117. // order.SelfpayAmt = ""
  1118. // order.Spec = ""
  1119. // order.SpecUnt = ""
  1120. // order.DrordBegnDate = s_tm
  1121. // order.DrordStopDate = ""
  1122. // order.DrordDrCodg = "1"
  1123. // order.DrordDeptName = department.Name
  1124. // order.DrordDrCodg = "1"
  1125. // order.DrordDrName = doctor_info.UserName
  1126. // order.DrordDrProfttl = ""
  1127. // order.CurrDrordFlag = "1"
  1128. // orders = append(orders, &order)
  1129. //
  1130. // }
  1131. // if subItem.Type == 3 {
  1132. //
  1133. // var order models.FsiOrderDtos
  1134. // order.RxID = strconv.FormatInt(item.ID, 10)
  1135. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1136. // order.LongDrordFlag = "0"
  1137. // order.HilistType = "1"
  1138. // order.ChrgType = "1"
  1139. // order.DrordBhvr = "-"
  1140. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1141. // order.HosplistName = subItem.GoodInfo.GoodName
  1142. // order.HilistLv = "1"
  1143. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1144. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1145. // order.HosplistName = subItem.GoodInfo.GoodName
  1146. // order.Cnt = subItem.Count
  1147. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1148. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1149. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1150. // order.OwnpayAmt = ""
  1151. // order.SelfpayAmt = ""
  1152. // order.Spec = ""
  1153. // order.SpecUnt = ""
  1154. // order.DrordBegnDate = s_tm
  1155. // order.DrordStopDate = ""
  1156. // order.DrordDrCodg = "1"
  1157. // order.DrordDeptName = department.Name
  1158. // order.DrordDrCodg = "1"
  1159. // order.DrordDrName = doctor_info.UserName
  1160. // order.DrordDrProfttl = ""
  1161. // order.CurrDrordFlag = "1"
  1162. // orders = append(orders, &order)
  1163. //
  1164. // }
  1165. // }
  1166. //}
  1167. for _, item := range prescriptions {
  1168. for _, subItem := range item.HisDoctorAdviceInfo {
  1169. var order models.FsiOrderDtos
  1170. order.RxID = strconv.FormatInt(item.ID, 10)
  1171. order.Rxno = strconv.FormatInt(item.ID, 10)
  1172. order.LongDrordFlag = "0"
  1173. order.HilistType = "1"
  1174. order.ChrgType = "1"
  1175. order.DrordBhvr = "-"
  1176. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1177. order.HosplistName = subItem.BaseDrugLib.DrugName
  1178. order.HilistLv = "1"
  1179. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1180. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1181. order.HosplistName = subItem.BaseDrugLib.DrugName
  1182. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1183. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1184. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1185. order.OwnpayAmt = ""
  1186. order.SelfpayAmt = ""
  1187. order.Spec = ""
  1188. order.SpecUnt = ""
  1189. order.DrordBegnDate = s_tm
  1190. order.DrordStopDate = ""
  1191. order.DrordDrCodg = "1"
  1192. order.DrordDeptName = department.Name
  1193. order.DrordDrCodg = "1"
  1194. order.DrordDrName = doctor_info.UserName
  1195. order.DrordDrProfttl = ""
  1196. order.CurrDrordFlag = "1"
  1197. orders = append(orders, &order)
  1198. }
  1199. for _, subItem := range item.HisPrescriptionProject {
  1200. if subItem.Type == 2 {
  1201. var order models.FsiOrderDtos
  1202. order.RxID = strconv.FormatInt(item.ID, 10)
  1203. order.Rxno = strconv.FormatInt(item.ID, 10)
  1204. order.LongDrordFlag = "0"
  1205. order.HilistType = "1"
  1206. order.ChrgType = "1"
  1207. order.DrordBhvr = "-"
  1208. order.HilistCode = subItem.HisProject.MedicalCode
  1209. order.HosplistName = subItem.HisProject.ProjectName
  1210. order.HilistLv = "1"
  1211. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1212. order.HosplistCode = subItem.HisProject.MedicalCode
  1213. order.HosplistName = subItem.HisProject.ProjectName
  1214. order.Cnt = subItem.Count
  1215. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1216. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1217. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1218. order.OwnpayAmt = ""
  1219. order.SelfpayAmt = ""
  1220. order.Spec = ""
  1221. order.SpecUnt = ""
  1222. order.DrordBegnDate = s_tm
  1223. order.DrordStopDate = ""
  1224. order.DrordDrCodg = "1"
  1225. order.DrordDeptName = department.Name
  1226. order.DrordDrCodg = "1"
  1227. order.DrordDrName = doctor_info.UserName
  1228. order.DrordDrProfttl = ""
  1229. order.CurrDrordFlag = "1"
  1230. orders = append(orders, &order)
  1231. }
  1232. if subItem.Type == 3 {
  1233. var order models.FsiOrderDtos
  1234. order.RxID = strconv.FormatInt(item.ID, 10)
  1235. order.Rxno = strconv.FormatInt(item.ID, 10)
  1236. order.LongDrordFlag = "0"
  1237. order.HilistType = "1"
  1238. order.ChrgType = "1"
  1239. order.DrordBhvr = "-"
  1240. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1241. order.HosplistName = subItem.GoodInfo.GoodName
  1242. order.HilistLv = "1"
  1243. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1244. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1245. order.HosplistName = subItem.GoodInfo.GoodName
  1246. order.Cnt = subItem.Count
  1247. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1248. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1249. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1250. order.OwnpayAmt = ""
  1251. order.SelfpayAmt = ""
  1252. order.Spec = ""
  1253. order.SpecUnt = ""
  1254. order.DrordBegnDate = s_tm
  1255. order.DrordStopDate = ""
  1256. order.DrordDrCodg = "1"
  1257. order.DrordDeptName = department.Name
  1258. order.DrordDrCodg = "1"
  1259. order.DrordDrName = doctor_info.UserName
  1260. order.DrordDrProfttl = ""
  1261. order.CurrDrordFlag = "1"
  1262. orders = append(orders, &order)
  1263. }
  1264. }
  1265. }
  1266. //处方医嘱信息
  1267. fed.MatnStas = "0"
  1268. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1269. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1270. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1271. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1272. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1273. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1274. fed.SetlTotlnum = "1"
  1275. fed.Insutype = his.Insutype
  1276. fed.ReimFlag = "0"
  1277. fed.OutSetlFlag = "0"
  1278. var fopd []*models.FsiOperationDtosData
  1279. data := make(map[string]interface{})
  1280. data["fed"] = fed
  1281. data["fdd"] = fdds
  1282. data["fod"] = orders
  1283. data["pd"] = pd
  1284. data["pp"] = pp
  1285. data["fopd"] = fopd
  1286. data["trig_scen"] = trig_scen
  1287. client := &http.Client{}
  1288. bytesData, _ := json.Marshal(data)
  1289. var req *http.Request
  1290. if miConfig.MdtrtareaAdmvs == "320921" {
  1291. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1292. } else {
  1293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1294. }
  1295. resp, _ := client.Do(req)
  1296. defer resp.Body.Close()
  1297. body, ioErr := ioutil.ReadAll(resp.Body)
  1298. if ioErr != nil {
  1299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1301. return res
  1302. }
  1303. var respJSON map[string]interface{}
  1304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. return res
  1308. }
  1309. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1310. result, _ := json.Marshal(respJSON)
  1311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1312. utils.ErrorLog("解析失败:%v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return res
  1315. }
  1316. return res
  1317. //手术操作集合
  1318. //手术操作集合
  1319. }
  1320. func (c *HisApiController) Check() {
  1321. psn_no := c.GetString("psn_no")
  1322. in := c.GetString("in")
  1323. mt := c.GetString("mt")
  1324. baseParams := models.BaseParams{
  1325. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1326. FixmedinsCode: "H15049901371",
  1327. InsuplcAdmdvs: "150499",
  1328. MdtrtareaAdmvs: "150499",
  1329. OrgName: "赤峰费森血液透析中心",
  1330. Doctor: "1111",
  1331. }
  1332. service.Gdyb2001(baseParams, psn_no, in, mt)
  1333. }
  1334. func (c *HisApiController) GetPsnNcdsInfo() {
  1335. admin_user_id, _ := c.GetInt64("admin_user_id")
  1336. patient_id, _ := c.GetInt64("patient_id")
  1337. id, _ := c.GetInt64("id")
  1338. adminUser := c.GetAdminUserInfo()
  1339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1340. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1341. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1342. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1343. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1344. //
  1345. //if psn_record.ID == 0 {
  1346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1347. // return
  1348. //}
  1349. var res Result5301
  1350. var res10265 Result5301For10265
  1351. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1352. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1353. var api string
  1354. if miConfig.MdtrtareaAdmvs == "320921" {
  1355. 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 +
  1356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1357. } else {
  1358. 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 +
  1359. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1360. }
  1361. resp, requestErr := http.Get(api)
  1362. if requestErr != nil {
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1364. return
  1365. }
  1366. body, ioErr := ioutil.ReadAll(resp.Body)
  1367. if ioErr != nil {
  1368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1370. return
  1371. }
  1372. var respJSON map[string]interface{}
  1373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1376. return
  1377. }
  1378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1379. result, _ := json.Marshal(respJSON)
  1380. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. res.ErrMsg = res10265.ErrMsg
  1386. res.Output = res10265.Output
  1387. res.InfRefmsgid = res10265.InfRefmsgid
  1388. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1389. res.Infcode = infocode
  1390. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1391. p, _ := service.GetHisPatientById(patient_id)
  1392. result, _ := service.Jxyb5301(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 if miConfig.MdtrtareaAdmvs == "430800" {
  1406. p, _ := service.GetHisPatientById(patient_id)
  1407. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1408. var dat map[string]interface{}
  1409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1410. fmt.Println(dat)
  1411. } else {
  1412. fmt.Println(err)
  1413. }
  1414. userJSONBytes, _ := json.Marshal(dat)
  1415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. } else {
  1421. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1422. var dat map[string]interface{}
  1423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1424. fmt.Println(dat)
  1425. } else {
  1426. fmt.Println(err)
  1427. }
  1428. userJSONBytes, _ := json.Marshal(dat)
  1429. if miConfig.Code == "H15049901371" {
  1430. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1431. utils.ErrorLog("解析失败:%v", err)
  1432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1433. return
  1434. }
  1435. res.InfRefmsgid = res10265.InfRefmsgid
  1436. res.Output = res10265.Output
  1437. res.ErrMsg = res10265.ErrMsg
  1438. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1439. res.Infcode = infocode
  1440. } else {
  1441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1442. utils.ErrorLog("解析失败:%v", err)
  1443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1444. return
  1445. }
  1446. }
  1447. }
  1448. if res.Infcode == 0 {
  1449. c.ServeSuccessJSON(map[string]interface{}{
  1450. "result": res.Output.Result,
  1451. })
  1452. }
  1453. }
  1454. func (c *HisApiController) CheckInsutype() {
  1455. his_patient_id, _ := c.GetInt64("his_patient_id")
  1456. admin_user_id, _ := c.GetInt64("admin_user_id")
  1457. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1458. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1460. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1461. var dat map[string]interface{}
  1462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1463. fmt.Println(dat)
  1464. } else {
  1465. fmt.Println(err)
  1466. }
  1467. userJSONBytes, _ := json.Marshal(dat)
  1468. var res Result90100
  1469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1470. utils.ErrorLog("解析失败:%v", err)
  1471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1472. return
  1473. }
  1474. if res.Infcode != 0 {
  1475. c.ServeSuccessJSON(map[string]interface{}{
  1476. "failed_code": -10,
  1477. "msg": res.ErrMsg,
  1478. })
  1479. return
  1480. } else {
  1481. fmt.Println(res)
  1482. }
  1483. }
  1484. func (c *HisApiController) CheckCardPWD() {
  1485. card_pwd := c.GetString("card_pwd")
  1486. his_patient_id, _ := c.GetInt64("his_patient_id")
  1487. admin_user_id, _ := c.GetInt64("admin_user_id")
  1488. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1490. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1491. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1492. bas := strings.Split(psn.CardInfo, "|")
  1493. basNumber := bas[2]
  1494. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1495. var dat map[string]interface{}
  1496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1497. fmt.Println(dat)
  1498. } else {
  1499. fmt.Println(err)
  1500. }
  1501. userJSONBytes, _ := json.Marshal(dat)
  1502. var res Result90991
  1503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1504. utils.ErrorLog("解析失败:%v", err)
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1506. return
  1507. }
  1508. if res.Infcode != 0 {
  1509. c.ServeSuccessJSON(map[string]interface{}{
  1510. "failed_code": -10,
  1511. "msg": res.ErrMsg,
  1512. })
  1513. return
  1514. } else {
  1515. if res.Output.Result.SscnoCheckStat == "0" {
  1516. var msg string
  1517. switch res.Output.Result.CardStat {
  1518. case "00":
  1519. msg = "未激活"
  1520. break
  1521. case "10":
  1522. msg = "激活"
  1523. break
  1524. case "20":
  1525. msg = "窗口挂失"
  1526. break
  1527. case "21":
  1528. msg = "电话挂失"
  1529. break
  1530. case "22":
  1531. msg = "单位网上申报挂失"
  1532. break
  1533. case "23":
  1534. msg = "保健办挂失"
  1535. break
  1536. case "24":
  1537. msg = "个人网上挂失"
  1538. break
  1539. case "25":
  1540. msg = "网上服务大厅挂失"
  1541. break
  1542. case "30":
  1543. msg = "注销"
  1544. break
  1545. case "40":
  1546. msg = "回收"
  1547. break
  1548. case "99":
  1549. msg = "制卡中(无效卡)"
  1550. break
  1551. }
  1552. c.ServeSuccessJSON(map[string]interface{}{
  1553. "failed_code": -10,
  1554. "msg": msg,
  1555. })
  1556. return
  1557. } else {
  1558. c.ServeSuccessJSON(map[string]interface{}{
  1559. "msg": "校验成功",
  1560. })
  1561. return
  1562. }
  1563. }
  1564. }
  1565. func (c *HisApiController) CheckCardPWDTwo() {
  1566. //card_pwd := c.GetString("card_pwd")
  1567. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1568. admin_user_id, _ := c.GetInt64("admin_user_id")
  1569. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1570. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1571. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1572. var dat map[string]interface{}
  1573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1574. fmt.Println(dat)
  1575. } else {
  1576. fmt.Println(err)
  1577. }
  1578. userJSONBytes, _ := json.Marshal(dat)
  1579. var res Result90991
  1580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1581. utils.ErrorLog("解析失败:%v", err)
  1582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1583. return
  1584. }
  1585. if res.Infcode != 0 {
  1586. c.ServeSuccessJSON(map[string]interface{}{
  1587. "failed_code": -10,
  1588. "msg": res.ErrMsg,
  1589. })
  1590. return
  1591. } else {
  1592. if res.Output.Result.SscnoCheckStat == "0" {
  1593. var msg string
  1594. switch res.Output.Result.CardStat {
  1595. case "00":
  1596. msg = "未激活"
  1597. break
  1598. case "10":
  1599. msg = "激活"
  1600. break
  1601. case "20":
  1602. msg = "窗口挂失"
  1603. break
  1604. case "21":
  1605. msg = "电话挂失"
  1606. break
  1607. case "22":
  1608. msg = "单位网上申报挂失"
  1609. break
  1610. case "23":
  1611. msg = "保健办挂失"
  1612. break
  1613. case "24":
  1614. msg = "个人网上挂失"
  1615. break
  1616. case "25":
  1617. msg = "网上服务大厅挂失"
  1618. break
  1619. case "30":
  1620. msg = "注销"
  1621. break
  1622. case "40":
  1623. msg = "回收"
  1624. break
  1625. case "99":
  1626. msg = "制卡中(无效卡)"
  1627. break
  1628. }
  1629. c.ServeSuccessJSON(map[string]interface{}{
  1630. "failed_code": -10,
  1631. "msg": msg,
  1632. })
  1633. return
  1634. } else {
  1635. c.ServeSuccessJSON(map[string]interface{}{
  1636. "msg": "校验成功",
  1637. })
  1638. return
  1639. }
  1640. }
  1641. }
  1642. type ELeCertData struct {
  1643. Data struct {
  1644. Extra string `json:"extra"`
  1645. IDNo string `json:"idNo"`
  1646. IDType string `json:"idType"`
  1647. EcToken string `json:"ecToken"`
  1648. InsuOrg string `json:"insuOrg"`
  1649. UserName string `json:"userName"`
  1650. EcIndexNo string `json:"ecIndexNo"`
  1651. Gender string `json:"gender"`
  1652. Birthday string `json:"birthday"`
  1653. Nationality string `json:"nationality"`
  1654. Email string `json:"email"`
  1655. } `json:"OutData"`
  1656. }
  1657. func (c *HisApiController) ReadCard() {
  1658. id_card_type, _ := c.GetInt64("id_card_type")
  1659. admin_user_id, _ := c.GetInt64("admin_user_id")
  1660. certificates, _ := c.GetInt64("certificates")
  1661. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1663. switch id_card_type {
  1664. case 1:
  1665. if miConfig.MdtrtareaAdmvs == "421300" {
  1666. var res ResultTwo
  1667. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1668. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1669. "&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)
  1670. resp, requestErr := http.Get(api)
  1671. if requestErr != nil {
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. return
  1674. }
  1675. body, ioErr := ioutil.ReadAll(resp.Body)
  1676. if ioErr != nil {
  1677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. var respJSON map[string]interface{}
  1682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1685. return
  1686. }
  1687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1688. result, _ := json.Marshal(respJSON)
  1689. fmt.Println("log")
  1690. fmt.Println(string(result))
  1691. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1692. utils.ErrorLog("解析失败:%v", err)
  1693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1694. return
  1695. }
  1696. if res.Infcode == 0 {
  1697. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1698. if err == gorm.ErrRecordNotFound {
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1700. return
  1701. } else if err != nil {
  1702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1703. return
  1704. } else {
  1705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1707. infoStr := string(Iinfos)
  1708. idetinfoStr := string(Idetinfos)
  1709. psn := &models.HisPsn{
  1710. PsnNo: res.Output.Baseinfo.PsnNo,
  1711. Age: res.Output.Baseinfo.Age,
  1712. PatientId: patient.ID,
  1713. Certno: res.Output.Baseinfo.Certno,
  1714. Brdy: res.Output.Baseinfo.Brdy,
  1715. Gend: res.Output.Baseinfo.Gend,
  1716. Naty: res.Output.Baseinfo.Naty,
  1717. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1718. PsnName: res.Output.Baseinfo.PsnName,
  1719. Idetinfo: idetinfoStr,
  1720. Insuinfo: infoStr,
  1721. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1722. }
  1723. service.CreateHisPsn(psn)
  1724. c.ServeSuccessJSON(map[string]interface{}{
  1725. "patient": patient,
  1726. "number": res.Output.Baseinfo.Certno,
  1727. })
  1728. }
  1729. } else {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1731. return
  1732. }
  1733. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1734. var api string
  1735. if miConfig.MdtrtareaAdmvs == "320921" {
  1736. 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 +
  1737. "&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
  1738. fmt.Println(api)
  1739. } else {
  1740. 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 +
  1741. "&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)
  1742. }
  1743. resp, requestErr := http.Get(api)
  1744. if requestErr != nil {
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. body, ioErr := ioutil.ReadAll(resp.Body)
  1749. if ioErr != nil {
  1750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1752. return
  1753. }
  1754. var respJSON map[string]interface{}
  1755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. return
  1759. }
  1760. var status string
  1761. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1762. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1763. //console.log()
  1764. fmt.Println("type===")
  1765. fmt.Println(card_type)
  1766. var token string
  1767. var res ResultTwo //1101结果
  1768. var res10265 ResultTwo10265 //1101结果
  1769. var card_info string //卡信息
  1770. var busi_card_info string
  1771. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1772. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1773. if status == "0" { //读卡成功
  1774. if card_type == "1" {
  1775. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1776. result, _ := json.Marshal(respJSON)
  1777. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1778. utils.ErrorLog("解析失败:%v", err)
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. return
  1781. }
  1782. res.ErrMsg = res10265.ErrMsg
  1783. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1784. res.Infcode = infocode
  1785. res.Output = res10265.Output
  1786. res.InfRefmsgid = res10265.InfRefmsgid
  1787. } else {
  1788. //var card_info string //卡信息
  1789. //var busi_card_info string
  1790. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1791. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1792. //fmt.Println(card_info)
  1793. //fmt.Println(busi_card_info)
  1794. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1795. result, _ := json.Marshal(respJSON)
  1796. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1797. utils.ErrorLog("解析失败:%v", err)
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1799. return
  1800. }
  1801. res.ErrMsg = res10265.ErrMsg
  1802. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1803. res.Infcode = infocode
  1804. res.Output = res10265.Output
  1805. res.InfRefmsgid = res10265.InfRefmsgid
  1806. }
  1807. if res.Infcode == 0 {
  1808. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1809. if err == gorm.ErrRecordNotFound {
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1811. return
  1812. } else if err != nil {
  1813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1814. return
  1815. } else {
  1816. if card_type == "1" {
  1817. bas := strings.Split(card_info, "|")
  1818. basNumber := bas[2]
  1819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1821. infoStr := string(Iinfos)
  1822. idetinfoStr := string(Idetinfos)
  1823. psn := &models.HisPsn{
  1824. PsnNo: res.Output.Baseinfo.PsnNo,
  1825. Age: res.Output.Baseinfo.Age,
  1826. PatientId: patient.ID,
  1827. Certno: res.Output.Baseinfo.Certno,
  1828. Brdy: res.Output.Baseinfo.Brdy,
  1829. Gend: res.Output.Baseinfo.Gend,
  1830. Naty: res.Output.Baseinfo.Naty,
  1831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1832. PsnName: res.Output.Baseinfo.PsnName,
  1833. Idetinfo: idetinfoStr,
  1834. Insuinfo: infoStr,
  1835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1836. CardInfo: card_info,
  1837. VerifyNumber: busi_card_info,
  1838. }
  1839. service.CreateHisPsn(psn)
  1840. var rf []*ResultFive
  1841. json.Unmarshal([]byte(infoStr), &rf)
  1842. var insutypes []*ResultFive
  1843. var insutype string
  1844. var is390 int = 0
  1845. var is310 int = 0
  1846. for _, item := range rf {
  1847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1848. insutypes = append(insutypes, item)
  1849. }
  1850. }
  1851. if len(insutypes) == 1 {
  1852. insutype = insutypes[0].Insutype
  1853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1854. } else {
  1855. for _, i := range insutypes {
  1856. if i.Insutype == "390" {
  1857. is390 = 1
  1858. }
  1859. if i.Insutype == "310" {
  1860. is310 = 1
  1861. }
  1862. }
  1863. }
  1864. if is390 == 1 {
  1865. insutype = "390"
  1866. }
  1867. if is310 == 1 {
  1868. insutype = "310"
  1869. }
  1870. if len(insutypes) == 0 {
  1871. insutype = "310"
  1872. }
  1873. c.ServeSuccessJSON(map[string]interface{}{
  1874. "patient": patient,
  1875. "number": basNumber,
  1876. "insutype": insutype,
  1877. })
  1878. } else {
  1879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1881. infoStr := string(Iinfos)
  1882. idetinfoStr := string(Idetinfos)
  1883. psn := &models.HisPsn{
  1884. PsnNo: res.Output.Baseinfo.PsnNo,
  1885. Age: res.Output.Baseinfo.Age,
  1886. PatientId: patient.ID,
  1887. Certno: res.Output.Baseinfo.Certno,
  1888. Brdy: res.Output.Baseinfo.Brdy,
  1889. Gend: res.Output.Baseinfo.Gend,
  1890. Naty: res.Output.Baseinfo.Naty,
  1891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1892. PsnName: res.Output.Baseinfo.PsnName,
  1893. Idetinfo: idetinfoStr,
  1894. Insuinfo: infoStr,
  1895. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1896. CardInfo: card_info,
  1897. VerifyNumber: token,
  1898. }
  1899. service.CreateHisPsn(psn)
  1900. c.ServeSuccessJSON(map[string]interface{}{
  1901. "patient": patient,
  1902. "number": token,
  1903. })
  1904. }
  1905. }
  1906. } else {
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1908. return
  1909. }
  1910. } else { //读卡失败
  1911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1912. return
  1913. }
  1914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1915. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1916. cardnum = DeleteExtraSpaceTwo(cardnum)
  1917. cardCode = DeleteExtraSpaceTwo(cardCode)
  1918. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1919. name = DeleteExtraSpaceTwo(name)
  1920. errmsg = DeleteExtraSpaceTwo(errmsg)
  1921. cardnum = Remove0000(cardnum)
  1922. cardCode = Remove0000(cardCode)
  1923. id_card_no = Remove0000(id_card_no)
  1924. name = Remove0000(name)
  1925. errmsg = Remove0000(errmsg)
  1926. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1927. 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)
  1928. saveLog(result, requestLog, "1101", "获取人员信息")
  1929. fmt.Println(errMsgLog)
  1930. if len(errMsgLog) > 0 {
  1931. } else {
  1932. var dat map[string]interface{}
  1933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1934. fmt.Println(dat)
  1935. } else {
  1936. fmt.Println(err)
  1937. }
  1938. userJSONBytes, _ := json.Marshal(dat)
  1939. var res ResultTwo
  1940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1941. utils.ErrorLog("解析失败:%v", err)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. return
  1944. }
  1945. res.ErrMsg = errMsgLog
  1946. if res.Infcode == 0 {
  1947. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1948. if err == gorm.ErrRecordNotFound {
  1949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1950. return
  1951. } else if err != nil {
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1953. return
  1954. } else {
  1955. fmt.Println(res)
  1956. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1957. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1958. infoStr := string(Iinfos)
  1959. idetinfoStr := string(Idetinfos)
  1960. psn := &models.HisPsn{
  1961. PsnNo: res.Output.Baseinfo.PsnNo,
  1962. Age: res.Output.Baseinfo.Age,
  1963. PatientId: patient.ID,
  1964. Certno: res.Output.Baseinfo.Certno,
  1965. Brdy: res.Output.Baseinfo.Brdy,
  1966. Gend: res.Output.Baseinfo.Gend,
  1967. Naty: res.Output.Baseinfo.Naty,
  1968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1969. PsnName: res.Output.Baseinfo.PsnName,
  1970. Idetinfo: idetinfoStr,
  1971. Insuinfo: infoStr,
  1972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1973. CardInfo: basStr,
  1974. VerifyNumber: "",
  1975. }
  1976. service.CreateHisPsn(psn)
  1977. var rf []*ResultFive
  1978. json.Unmarshal([]byte(infoStr), &rf)
  1979. var insutypes []*ResultFive
  1980. var insutype string
  1981. var is390 int = 0
  1982. var is310 int = 0
  1983. for _, item := range rf {
  1984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1985. insutypes = append(insutypes, item)
  1986. }
  1987. }
  1988. if len(insutypes) == 1 {
  1989. insutype = insutypes[0].Insutype
  1990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1991. } else {
  1992. for _, i := range insutypes {
  1993. if i.Insutype == "390" {
  1994. is390 = 1
  1995. }
  1996. if i.Insutype == "310" {
  1997. is310 = 1
  1998. }
  1999. }
  2000. }
  2001. if is390 == 1 {
  2002. insutype = "390"
  2003. }
  2004. if is310 == 1 {
  2005. insutype = "310"
  2006. }
  2007. if len(insutypes) == 0 {
  2008. insutype = "310"
  2009. }
  2010. c.ServeSuccessJSON(map[string]interface{}{
  2011. "patient": patient,
  2012. "number": cardnum,
  2013. "insutype": insutype,
  2014. })
  2015. }
  2016. } else {
  2017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2018. return
  2019. }
  2020. }
  2021. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2022. fmt.Println(initFlag)
  2023. fmt.Println("initFlag")
  2024. if initFlag == 0 {
  2025. c.TestGetJiangXiBasBaseInit()
  2026. }
  2027. basStr := c.GetBasBaseInfo()
  2028. if len(basStr) == 0 {
  2029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2030. return
  2031. }
  2032. fmt.Println(basStr)
  2033. bas := strings.Split(basStr, "|")
  2034. basNumber := bas[1]
  2035. fmt.Println(basNumber)
  2036. card_sn := bas[3]
  2037. fmt.Println(card_sn)
  2038. 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, "")
  2039. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2040. var dat map[string]interface{}
  2041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2042. fmt.Println(dat)
  2043. } else {
  2044. fmt.Println(err)
  2045. }
  2046. userJSONBytes, _ := json.Marshal(dat)
  2047. var res ResultTwo
  2048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2049. utils.ErrorLog("解析失败:%v", err)
  2050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. return
  2052. }
  2053. if res.Infcode == 0 {
  2054. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2055. if err == gorm.ErrRecordNotFound {
  2056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2057. return
  2058. } else if err != nil {
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2060. return
  2061. } else {
  2062. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2063. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2064. infoStr := string(Iinfos)
  2065. idetinfoStr := string(Idetinfos)
  2066. psn := &models.HisPsn{
  2067. PsnNo: res.Output.Baseinfo.PsnNo,
  2068. Age: res.Output.Baseinfo.Age,
  2069. PatientId: patient.ID,
  2070. Certno: res.Output.Baseinfo.Certno,
  2071. Brdy: res.Output.Baseinfo.Brdy,
  2072. Gend: res.Output.Baseinfo.Gend,
  2073. Naty: res.Output.Baseinfo.Naty,
  2074. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2075. PsnName: res.Output.Baseinfo.PsnName,
  2076. Idetinfo: idetinfoStr,
  2077. Insuinfo: infoStr,
  2078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2079. CardInfo: basStr,
  2080. VerifyNumber: "",
  2081. }
  2082. service.CreateHisPsn(psn)
  2083. var rf []*ResultFive
  2084. json.Unmarshal([]byte(infoStr), &rf)
  2085. var insutypes []*ResultFive
  2086. var insutype string
  2087. var is390 int = 0
  2088. var is310 int = 0
  2089. for _, item := range rf {
  2090. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2091. insutypes = append(insutypes, item)
  2092. }
  2093. }
  2094. if len(insutypes) == 1 {
  2095. insutype = insutypes[0].Insutype
  2096. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2097. } else {
  2098. for _, i := range insutypes {
  2099. if i.Insutype == "390" {
  2100. is390 = 1
  2101. }
  2102. if i.Insutype == "310" {
  2103. is310 = 1
  2104. }
  2105. }
  2106. }
  2107. if is390 == 1 {
  2108. insutype = "390"
  2109. }
  2110. if is310 == 1 {
  2111. insutype = "310"
  2112. }
  2113. if len(insutypes) == 0 {
  2114. insutype = "310"
  2115. }
  2116. c.ServeSuccessJSON(map[string]interface{}{
  2117. "patient": patient,
  2118. "number": basNumber,
  2119. "insutype": insutype,
  2120. })
  2121. }
  2122. } else {
  2123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2124. return
  2125. }
  2126. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2127. fmt.Println(initFlag)
  2128. fmt.Println("initFlag")
  2129. if initFlag == 0 {
  2130. c.TestGetHnBasBaseInit()
  2131. }
  2132. basStr := c.GetBasBaseInfo()
  2133. if len(basStr) == 0 {
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2135. return
  2136. }
  2137. fmt.Println(basStr)
  2138. bas := strings.Split(basStr, "|")
  2139. basNumber := bas[1]
  2140. fmt.Println(basNumber)
  2141. card_sn := bas[3]
  2142. card_no := bas[2]
  2143. fmt.Println(card_sn)
  2144. name := bas[4]
  2145. name = ConvertToString(name, "gbk", "utf-8")
  2146. 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)
  2147. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2148. var dat map[string]interface{}
  2149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2150. fmt.Println(dat)
  2151. } else {
  2152. fmt.Println(err)
  2153. }
  2154. userJSONBytes, _ := json.Marshal(dat)
  2155. var res ResultTwo
  2156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2157. utils.ErrorLog("解析失败:%v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. return
  2160. }
  2161. if res.Infcode == 0 {
  2162. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2163. if err == gorm.ErrRecordNotFound {
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2165. return
  2166. } else if err != nil {
  2167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2168. return
  2169. } else {
  2170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2172. infoStr := string(Iinfos)
  2173. idetinfoStr := string(Idetinfos)
  2174. psn := &models.HisPsn{
  2175. PsnNo: res.Output.Baseinfo.PsnNo,
  2176. Age: res.Output.Baseinfo.Age,
  2177. PatientId: patient.ID,
  2178. Certno: res.Output.Baseinfo.Certno,
  2179. Brdy: res.Output.Baseinfo.Brdy,
  2180. Gend: res.Output.Baseinfo.Gend,
  2181. Naty: res.Output.Baseinfo.Naty,
  2182. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2183. PsnName: res.Output.Baseinfo.PsnName,
  2184. Idetinfo: idetinfoStr,
  2185. Insuinfo: infoStr,
  2186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2187. CardInfo: basStr,
  2188. VerifyNumber: "",
  2189. }
  2190. service.CreateHisPsn(psn)
  2191. var rf []*ResultFive
  2192. json.Unmarshal([]byte(infoStr), &rf)
  2193. var insutypes []*ResultFive
  2194. var insutype string
  2195. var is390 int = 0
  2196. var is310 int = 0
  2197. for _, item := range rf {
  2198. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2199. insutypes = append(insutypes, item)
  2200. }
  2201. }
  2202. if len(insutypes) == 1 {
  2203. insutype = insutypes[0].Insutype
  2204. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2205. } else {
  2206. for _, i := range insutypes {
  2207. if i.Insutype == "390" {
  2208. is390 = 1
  2209. }
  2210. if i.Insutype == "310" {
  2211. is310 = 1
  2212. }
  2213. }
  2214. }
  2215. if is390 == 1 {
  2216. insutype = "390"
  2217. }
  2218. if is310 == 1 {
  2219. insutype = "310"
  2220. }
  2221. if len(insutypes) == 0 {
  2222. insutype = "310"
  2223. }
  2224. c.ServeSuccessJSON(map[string]interface{}{
  2225. "patient": patient,
  2226. "number": basNumber,
  2227. "insutype": insutype,
  2228. })
  2229. }
  2230. } else {
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2232. return
  2233. }
  2234. } else {
  2235. if initFlag == 0 {
  2236. c.TestGetBasBaseInit()
  2237. }
  2238. basStr := c.GetBasBaseInfo()
  2239. if len(basStr) == 0 {
  2240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2241. return
  2242. }
  2243. fmt.Println(basStr)
  2244. bas := strings.Split(basStr, "|")
  2245. basNumber := bas[1]
  2246. fmt.Println(basNumber)
  2247. card_sn := bas[3]
  2248. fmt.Println(card_sn)
  2249. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2250. var dat map[string]interface{}
  2251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2252. fmt.Println(dat)
  2253. } else {
  2254. fmt.Println(err)
  2255. }
  2256. userJSONBytes, _ := json.Marshal(dat)
  2257. var res ResultTwo
  2258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2259. utils.ErrorLog("解析失败:%v", err)
  2260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2261. return
  2262. }
  2263. if res.Infcode == 0 {
  2264. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2265. if err == gorm.ErrRecordNotFound {
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2267. return
  2268. } else if err != nil {
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2270. return
  2271. } else {
  2272. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2273. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2274. infoStr := string(Iinfos)
  2275. idetinfoStr := string(Idetinfos)
  2276. psn := &models.HisPsn{
  2277. PsnNo: res.Output.Baseinfo.PsnNo,
  2278. Age: res.Output.Baseinfo.Age,
  2279. PatientId: patient.ID,
  2280. Certno: res.Output.Baseinfo.Certno,
  2281. Brdy: res.Output.Baseinfo.Brdy,
  2282. Gend: res.Output.Baseinfo.Gend,
  2283. Naty: res.Output.Baseinfo.Naty,
  2284. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2285. PsnName: res.Output.Baseinfo.PsnName,
  2286. Idetinfo: idetinfoStr,
  2287. Insuinfo: infoStr,
  2288. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2289. CardInfo: basStr,
  2290. VerifyNumber: "",
  2291. }
  2292. service.CreateHisPsn(psn)
  2293. c.ServeSuccessJSON(map[string]interface{}{
  2294. "patient": patient,
  2295. "number": basNumber,
  2296. })
  2297. }
  2298. } else {
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2300. return
  2301. }
  2302. break
  2303. }
  2304. case 2:
  2305. if miConfig.MdtrtareaAdmvs == "430800" {
  2306. if initFlag == 0 {
  2307. c.TestGetHnBasBaseInit()
  2308. }
  2309. SFZStr := c.GetSFZBaseInfo()
  2310. if len(SFZStr) == 0 {
  2311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2312. return
  2313. }
  2314. fmt.Println(SFZStr)
  2315. id_card_str := strings.Split(SFZStr, "^")
  2316. card_no := id_card_str[0]
  2317. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2318. //name := id_card_str[1]
  2319. //name = ConvertToString(name, "gbk", "utf-8")
  2320. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  2321. var dat map[string]interface{}
  2322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2323. fmt.Println(dat)
  2324. } else {
  2325. fmt.Println(err)
  2326. }
  2327. userJSONBytes, _ := json.Marshal(dat)
  2328. var res ResultTwo
  2329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2330. utils.ErrorLog("解析失败:%v", err)
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. return
  2333. }
  2334. if res.Infcode == 0 {
  2335. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2336. if err == gorm.ErrRecordNotFound {
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2338. return
  2339. } else if err != nil {
  2340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2341. return
  2342. } else {
  2343. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2344. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2345. infoStr := string(Iinfos)
  2346. idetinfoStr := string(Idetinfos)
  2347. psn := &models.HisPsn{
  2348. PsnNo: res.Output.Baseinfo.PsnNo,
  2349. Age: res.Output.Baseinfo.Age,
  2350. PatientId: patient.ID,
  2351. Certno: res.Output.Baseinfo.Certno,
  2352. Brdy: res.Output.Baseinfo.Brdy,
  2353. Gend: res.Output.Baseinfo.Gend,
  2354. Naty: res.Output.Baseinfo.Naty,
  2355. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2356. PsnName: res.Output.Baseinfo.PsnName,
  2357. Idetinfo: idetinfoStr,
  2358. Insuinfo: infoStr,
  2359. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2360. CardInfo: SFZStr,
  2361. VerifyNumber: "",
  2362. }
  2363. service.CreateHisPsn(psn)
  2364. var rf []*ResultFive
  2365. json.Unmarshal([]byte(infoStr), &rf)
  2366. var insutypes []*ResultFive
  2367. var insutype string
  2368. var is390 int = 0
  2369. var is310 int = 0
  2370. for _, item := range rf {
  2371. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2372. insutypes = append(insutypes, item)
  2373. }
  2374. }
  2375. if len(insutypes) == 1 {
  2376. insutype = insutypes[0].Insutype
  2377. } else {
  2378. for _, i := range insutypes {
  2379. if i.Insutype == "390" {
  2380. is390 = 1
  2381. }
  2382. if i.Insutype == "310" {
  2383. is310 = 1
  2384. }
  2385. }
  2386. }
  2387. if is390 == 1 {
  2388. insutype = "390"
  2389. }
  2390. if is310 == 1 {
  2391. insutype = "310"
  2392. }
  2393. if len(insutypes) == 0 {
  2394. insutype = "310"
  2395. }
  2396. c.ServeSuccessJSON(map[string]interface{}{
  2397. "patient": patient,
  2398. "number": card_no,
  2399. "insutype": insutype,
  2400. })
  2401. }
  2402. } else {
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2404. return
  2405. }
  2406. } else {
  2407. SFZStr := c.GetSFZBaseInfo()
  2408. id_card_str := strings.Split(SFZStr, "^")
  2409. id_card_number := id_card_str[0]
  2410. card_sn := ""
  2411. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2412. var dat map[string]interface{}
  2413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2414. fmt.Println(dat)
  2415. } else {
  2416. fmt.Println(err)
  2417. }
  2418. userJSONBytes, _ := json.Marshal(dat)
  2419. var res ResultTwo
  2420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. if res.Infcode == 0 {
  2426. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2427. if err == gorm.ErrRecordNotFound {
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2429. return
  2430. } else if err != nil {
  2431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2432. return
  2433. } else {
  2434. c.ServeSuccessJSON(map[string]interface{}{
  2435. "patient": patient,
  2436. "number": id_card_number,
  2437. })
  2438. }
  2439. } else {
  2440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2441. return
  2442. }
  2443. }
  2444. break
  2445. case 3:
  2446. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2447. var api string
  2448. if miConfig.MdtrtareaAdmvs == "320921" {
  2449. 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 +
  2450. "&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
  2451. fmt.Println(api)
  2452. } else {
  2453. 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 +
  2454. "&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)
  2455. }
  2456. resp, requestErr := http.Get(api)
  2457. if requestErr != nil {
  2458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. return
  2460. }
  2461. body, ioErr := ioutil.ReadAll(resp.Body)
  2462. if ioErr != nil {
  2463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. return
  2466. }
  2467. var respJSON map[string]interface{}
  2468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2471. return
  2472. }
  2473. var status string
  2474. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2475. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2476. var token string
  2477. var res ResultTwo //1101结果
  2478. var res10265 ResultTwo10265 //1101结果
  2479. var card_info string //卡信息
  2480. var busi_card_info string
  2481. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2482. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2483. if status == "0" { //读卡成功
  2484. if card_type == "1" {
  2485. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2486. result, _ := json.Marshal(respJSON)
  2487. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2488. utils.ErrorLog("解析失败:%v", err)
  2489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2490. return
  2491. }
  2492. res.ErrMsg = res10265.ErrMsg
  2493. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2494. res.Infcode = infocode
  2495. res.Output = res10265.Output
  2496. res.InfRefmsgid = res10265.InfRefmsgid
  2497. } else {
  2498. //var card_info string //卡信息
  2499. //var busi_card_info string
  2500. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2501. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2502. //fmt.Println(card_info)
  2503. //fmt.Println(busi_card_info)
  2504. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2505. result, _ := json.Marshal(respJSON)
  2506. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2507. utils.ErrorLog("解析失败:%v", err)
  2508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. return
  2510. }
  2511. res.ErrMsg = res10265.ErrMsg
  2512. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2513. res.Infcode = infocode
  2514. res.Output = res10265.Output
  2515. res.InfRefmsgid = res10265.InfRefmsgid
  2516. }
  2517. if res.Infcode == 0 {
  2518. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2519. if err == gorm.ErrRecordNotFound {
  2520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2521. return
  2522. } else if err != nil {
  2523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2524. return
  2525. } else {
  2526. if card_type == "1" {
  2527. bas := strings.Split(card_info, "|")
  2528. basNumber := bas[2]
  2529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2531. infoStr := string(Iinfos)
  2532. idetinfoStr := string(Idetinfos)
  2533. psn := &models.HisPsn{
  2534. PsnNo: res.Output.Baseinfo.PsnNo,
  2535. Age: res.Output.Baseinfo.Age,
  2536. PatientId: patient.ID,
  2537. Certno: res.Output.Baseinfo.Certno,
  2538. Brdy: res.Output.Baseinfo.Brdy,
  2539. Gend: res.Output.Baseinfo.Gend,
  2540. Naty: res.Output.Baseinfo.Naty,
  2541. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2542. PsnName: res.Output.Baseinfo.PsnName,
  2543. Idetinfo: idetinfoStr,
  2544. Insuinfo: infoStr,
  2545. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2546. CardInfo: card_info,
  2547. VerifyNumber: busi_card_info,
  2548. }
  2549. service.CreateHisPsn(psn)
  2550. c.ServeSuccessJSON(map[string]interface{}{
  2551. "patient": patient,
  2552. "number": basNumber,
  2553. })
  2554. } else {
  2555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2557. infoStr := string(Iinfos)
  2558. idetinfoStr := string(Idetinfos)
  2559. psn := &models.HisPsn{
  2560. PsnNo: res.Output.Baseinfo.PsnNo,
  2561. Age: res.Output.Baseinfo.Age,
  2562. PatientId: patient.ID,
  2563. Certno: res.Output.Baseinfo.Certno,
  2564. Brdy: res.Output.Baseinfo.Brdy,
  2565. Gend: res.Output.Baseinfo.Gend,
  2566. Naty: res.Output.Baseinfo.Naty,
  2567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2568. PsnName: res.Output.Baseinfo.PsnName,
  2569. Idetinfo: idetinfoStr,
  2570. Insuinfo: infoStr,
  2571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2572. CardInfo: card_info,
  2573. VerifyNumber: token,
  2574. }
  2575. service.CreateHisPsn(psn)
  2576. var rf []*ResultFive
  2577. json.Unmarshal([]byte(infoStr), &rf)
  2578. var insutypes []*ResultFive
  2579. var insutype string
  2580. var is390 int = 0
  2581. var is310 int = 0
  2582. for _, item := range rf {
  2583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2584. insutypes = append(insutypes, item)
  2585. }
  2586. }
  2587. if len(insutypes) == 1 {
  2588. insutype = insutypes[0].Insutype
  2589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2590. } else {
  2591. for _, i := range insutypes {
  2592. if i.Insutype == "390" {
  2593. is390 = 1
  2594. }
  2595. if i.Insutype == "310" {
  2596. is310 = 1
  2597. }
  2598. }
  2599. }
  2600. if is390 == 1 {
  2601. insutype = "390"
  2602. }
  2603. if is310 == 1 {
  2604. insutype = "310"
  2605. }
  2606. if len(insutypes) == 0 {
  2607. insutype = "310"
  2608. }
  2609. c.ServeSuccessJSON(map[string]interface{}{
  2610. "patient": patient,
  2611. "number": token,
  2612. "insutype": insutype,
  2613. })
  2614. }
  2615. }
  2616. } else {
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2618. return
  2619. }
  2620. } else { //读卡失败
  2621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2622. return
  2623. }
  2624. }
  2625. break
  2626. case 4:
  2627. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2628. var api string
  2629. if miConfig.MdtrtareaAdmvs == "320921" {
  2630. 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 +
  2631. "&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
  2632. fmt.Println(api)
  2633. } else {
  2634. 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 +
  2635. "&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)
  2636. }
  2637. resp, requestErr := http.Get(api)
  2638. if requestErr != nil {
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. return
  2641. }
  2642. body, ioErr := ioutil.ReadAll(resp.Body)
  2643. if ioErr != nil {
  2644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2646. return
  2647. }
  2648. var respJSON map[string]interface{}
  2649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2652. return
  2653. }
  2654. var status string
  2655. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2656. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2657. var token string
  2658. var res ResultTwo //1101结果
  2659. var res10265 ResultTwo10265 //1101结果
  2660. if status == "0" { //读卡成功
  2661. var card_info string //卡信息
  2662. var busi_card_info string
  2663. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2664. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2665. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2666. fmt.Println(card_info)
  2667. fmt.Println(busi_card_info)
  2668. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2669. result, _ := json.Marshal(respJSON)
  2670. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2671. utils.ErrorLog("解析失败:%v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. res.ErrMsg = res10265.ErrMsg
  2676. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2677. res.Infcode = infocode
  2678. res.Output = res10265.Output
  2679. res.InfRefmsgid = res10265.InfRefmsgid
  2680. if res.Infcode == 0 {
  2681. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2682. if err == gorm.ErrRecordNotFound {
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2684. return
  2685. } else if err != nil {
  2686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2687. return
  2688. } else {
  2689. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2690. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2691. infoStr := string(Iinfos)
  2692. idetinfoStr := string(Idetinfos)
  2693. psn := &models.HisPsn{
  2694. PsnNo: res.Output.Baseinfo.PsnNo,
  2695. Age: res.Output.Baseinfo.Age,
  2696. PatientId: patient.ID,
  2697. Certno: res.Output.Baseinfo.Certno,
  2698. Brdy: res.Output.Baseinfo.Brdy,
  2699. Gend: res.Output.Baseinfo.Gend,
  2700. Naty: res.Output.Baseinfo.Naty,
  2701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2702. PsnName: res.Output.Baseinfo.PsnName,
  2703. Idetinfo: idetinfoStr,
  2704. Insuinfo: infoStr,
  2705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2706. CardInfo: card_info,
  2707. VerifyNumber: token,
  2708. }
  2709. var rf []*ResultFive
  2710. json.Unmarshal([]byte(infoStr), &rf)
  2711. var insutypes []*ResultFive
  2712. var insutype string
  2713. var is390 int = 0
  2714. var is310 int = 0
  2715. for _, item := range rf {
  2716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2717. insutypes = append(insutypes, item)
  2718. }
  2719. }
  2720. if len(insutypes) == 1 {
  2721. insutype = insutypes[0].Insutype
  2722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2723. } else {
  2724. for _, i := range insutypes {
  2725. if i.Insutype == "390" {
  2726. is390 = 1
  2727. }
  2728. if i.Insutype == "310" {
  2729. is310 = 1
  2730. }
  2731. }
  2732. }
  2733. if is390 == 1 {
  2734. insutype = "390"
  2735. }
  2736. if is310 == 1 {
  2737. insutype = "310"
  2738. }
  2739. if len(insutypes) == 0 {
  2740. insutype = "310"
  2741. }
  2742. service.CreateHisPsn(psn)
  2743. c.ServeSuccessJSON(map[string]interface{}{
  2744. "patient": patient,
  2745. "number": token,
  2746. "insutype": insutype,
  2747. })
  2748. }
  2749. } else {
  2750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2751. return
  2752. }
  2753. } else { //读卡失败
  2754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2755. return
  2756. }
  2757. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2758. if initFlag == 0 {
  2759. c.TestGetBasBaseInit()
  2760. }
  2761. token := c.GetEleBaseInfo()
  2762. token = Remove0000(token)
  2763. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2764. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2765. //
  2766. var res ResultTwo
  2767. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2768. utils.ErrorLog("解析失败:%v", err)
  2769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. return
  2771. }
  2772. if res.Infcode == 0 {
  2773. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2774. if err == gorm.ErrRecordNotFound {
  2775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2776. return
  2777. } else if err != nil {
  2778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2779. return
  2780. } else {
  2781. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2782. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2783. infoStr := string(Iinfos)
  2784. idetinfoStr := string(Idetinfos)
  2785. psn := &models.HisPsn{
  2786. PsnNo: res.Output.Baseinfo.PsnNo,
  2787. Age: res.Output.Baseinfo.Age,
  2788. PatientId: patient.ID,
  2789. Certno: res.Output.Baseinfo.Certno,
  2790. Brdy: res.Output.Baseinfo.Brdy,
  2791. Gend: res.Output.Baseinfo.Gend,
  2792. Naty: res.Output.Baseinfo.Naty,
  2793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2794. PsnName: res.Output.Baseinfo.PsnName,
  2795. Idetinfo: idetinfoStr,
  2796. Insuinfo: infoStr,
  2797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2798. CardInfo: "",
  2799. VerifyNumber: token,
  2800. }
  2801. service.CreateHisPsn(psn)
  2802. c.ServeSuccessJSON(map[string]interface{}{
  2803. "patient": patient,
  2804. "number": token,
  2805. })
  2806. }
  2807. } else {
  2808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2809. return
  2810. }
  2811. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2812. if initFlag == 0 {
  2813. c.TestGetBasBaseInit()
  2814. }
  2815. token := c.GetEleBaseInfo()
  2816. token = Remove0000(token)
  2817. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2818. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2819. //
  2820. var res ResultTwo
  2821. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2822. utils.ErrorLog("解析失败:%v", err)
  2823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2824. return
  2825. }
  2826. if res.Infcode == 0 {
  2827. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2828. if err == gorm.ErrRecordNotFound {
  2829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2830. return
  2831. } else if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2833. return
  2834. } else {
  2835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2837. infoStr := string(Iinfos)
  2838. idetinfoStr := string(Idetinfos)
  2839. psn := &models.HisPsn{
  2840. PsnNo: res.Output.Baseinfo.PsnNo,
  2841. Age: res.Output.Baseinfo.Age,
  2842. PatientId: patient.ID,
  2843. Certno: res.Output.Baseinfo.Certno,
  2844. Brdy: res.Output.Baseinfo.Brdy,
  2845. Gend: res.Output.Baseinfo.Gend,
  2846. Naty: res.Output.Baseinfo.Naty,
  2847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2848. PsnName: res.Output.Baseinfo.PsnName,
  2849. Idetinfo: idetinfoStr,
  2850. Insuinfo: infoStr,
  2851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2852. CardInfo: "",
  2853. VerifyNumber: token,
  2854. }
  2855. service.CreateHisPsn(psn)
  2856. c.ServeSuccessJSON(map[string]interface{}{
  2857. "patient": patient,
  2858. "number": token,
  2859. })
  2860. }
  2861. } else {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2863. return
  2864. }
  2865. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2866. //if initFlag == 0 {
  2867. c.TestGetJiangXiBasBaseInit()
  2868. //}
  2869. //if initEleFlag == 0 {
  2870. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2871. //}
  2872. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2873. type ELeData struct {
  2874. Data struct {
  2875. IdNo string `json:"idNo"`
  2876. IdType string `json:"idType"`
  2877. UserName string `json:"userName"`
  2878. EcToken string `json:"ecToken"`
  2879. InsuOrg string `json:"insuOrg"`
  2880. Gender string `json:"gender"`
  2881. Birthday string `json:"birthday"`
  2882. Nationality string `json:"nationality"`
  2883. Email string `json:"email"`
  2884. Extra string `json:"extra"`
  2885. } `json:"data"`
  2886. Code int `json:"code"`
  2887. Message string `json:"message"`
  2888. }
  2889. var ele ELeData
  2890. err := json.Unmarshal([]byte(json_result), &ele)
  2891. if err != nil {
  2892. utils.ErrorLog("解析失败:%v", err)
  2893. }
  2894. token := ele.Data.EcToken
  2895. token = Remove0000(token)
  2896. 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)
  2897. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2898. var res ResultTwo
  2899. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2900. utils.ErrorLog("解析失败:%v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. if res.Infcode == 0 {
  2905. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2906. if err == gorm.ErrRecordNotFound {
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2908. return
  2909. } else if err != nil {
  2910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2911. return
  2912. } else {
  2913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2915. infoStr := string(Iinfos)
  2916. idetinfoStr := string(Idetinfos)
  2917. psn := &models.HisPsn{
  2918. PsnNo: res.Output.Baseinfo.PsnNo,
  2919. Age: res.Output.Baseinfo.Age,
  2920. PatientId: patient.ID,
  2921. Certno: res.Output.Baseinfo.Certno,
  2922. Brdy: res.Output.Baseinfo.Brdy,
  2923. Gend: res.Output.Baseinfo.Gend,
  2924. Naty: res.Output.Baseinfo.Naty,
  2925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2926. PsnName: res.Output.Baseinfo.PsnName,
  2927. Idetinfo: idetinfoStr,
  2928. Insuinfo: infoStr,
  2929. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2930. CardInfo: "",
  2931. VerifyNumber: token,
  2932. }
  2933. service.CreateHisPsn(psn)
  2934. var rf []*ResultFive
  2935. json.Unmarshal([]byte(infoStr), &rf)
  2936. var insutypes []*ResultFive
  2937. var insutype string
  2938. var is390 int = 0
  2939. var is310 int = 0
  2940. for _, item := range rf {
  2941. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2942. insutypes = append(insutypes, item)
  2943. }
  2944. }
  2945. if len(insutypes) == 1 {
  2946. insutype = insutypes[0].Insutype
  2947. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2948. } else {
  2949. for _, i := range insutypes {
  2950. if i.Insutype == "390" {
  2951. is390 = 1
  2952. }
  2953. if i.Insutype == "310" {
  2954. is310 = 1
  2955. }
  2956. }
  2957. }
  2958. if is390 == 1 {
  2959. insutype = "390"
  2960. }
  2961. if is310 == 1 {
  2962. insutype = "310"
  2963. }
  2964. if len(insutypes) == 0 {
  2965. insutype = "310"
  2966. }
  2967. c.ServeSuccessJSON(map[string]interface{}{
  2968. "patient": patient,
  2969. "number": token,
  2970. "insutype": insutype,
  2971. })
  2972. }
  2973. } else {
  2974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2975. return
  2976. }
  2977. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2978. //if initFlag == 0 {
  2979. c.TestGetJiangXiBasBaseInit()
  2980. //}
  2981. //if initEleFlag == 0 {
  2982. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2983. //}
  2984. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2985. type ELeData struct {
  2986. Data struct {
  2987. IdNo string `json:"idNo"`
  2988. IdType string `json:"idType"`
  2989. UserName string `json:"userName"`
  2990. EcToken string `json:"ecToken"`
  2991. InsuOrg string `json:"insuOrg"`
  2992. Gender string `json:"gender"`
  2993. Birthday string `json:"birthday"`
  2994. Nationality string `json:"nationality"`
  2995. Email string `json:"email"`
  2996. Extra string `json:"extra"`
  2997. } `json:"data"`
  2998. Code int `json:"code"`
  2999. Message string `json:"message"`
  3000. }
  3001. var ele ELeData
  3002. err := json.Unmarshal([]byte(json_result), &ele)
  3003. if err != nil {
  3004. utils.ErrorLog("解析失败:%v", err)
  3005. }
  3006. token := ele.Data.EcToken
  3007. token = Remove0000(token)
  3008. 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)
  3009. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3010. var res ResultTwo
  3011. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3012. utils.ErrorLog("解析失败:%v", err)
  3013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3014. return
  3015. }
  3016. if res.Infcode == 0 {
  3017. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3018. if err == gorm.ErrRecordNotFound {
  3019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3020. return
  3021. } else if err != nil {
  3022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3023. return
  3024. } else {
  3025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3027. infoStr := string(Iinfos)
  3028. idetinfoStr := string(Idetinfos)
  3029. psn := &models.HisPsn{
  3030. PsnNo: res.Output.Baseinfo.PsnNo,
  3031. Age: res.Output.Baseinfo.Age,
  3032. PatientId: patient.ID,
  3033. Certno: res.Output.Baseinfo.Certno,
  3034. Brdy: res.Output.Baseinfo.Brdy,
  3035. Gend: res.Output.Baseinfo.Gend,
  3036. Naty: res.Output.Baseinfo.Naty,
  3037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3038. PsnName: res.Output.Baseinfo.PsnName,
  3039. Idetinfo: idetinfoStr,
  3040. Insuinfo: infoStr,
  3041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3042. CardInfo: "",
  3043. VerifyNumber: token,
  3044. }
  3045. service.CreateHisPsn(psn)
  3046. var rf []*ResultFive
  3047. json.Unmarshal([]byte(infoStr), &rf)
  3048. var insutypes []*ResultFive
  3049. var insutype string
  3050. var is390 int = 0
  3051. var is310 int = 0
  3052. for _, item := range rf {
  3053. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3054. insutypes = append(insutypes, item)
  3055. }
  3056. }
  3057. if len(insutypes) == 1 {
  3058. insutype = insutypes[0].Insutype
  3059. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3060. } else {
  3061. for _, i := range insutypes {
  3062. if i.Insutype == "390" {
  3063. is390 = 1
  3064. }
  3065. if i.Insutype == "310" {
  3066. is310 = 1
  3067. }
  3068. }
  3069. }
  3070. if is390 == 1 {
  3071. insutype = "390"
  3072. }
  3073. if is310 == 1 {
  3074. insutype = "310"
  3075. }
  3076. if len(insutypes) == 0 {
  3077. insutype = "310"
  3078. }
  3079. c.ServeSuccessJSON(map[string]interface{}{
  3080. "patient": patient,
  3081. "number": token,
  3082. "insutype": insutype,
  3083. })
  3084. }
  3085. } else {
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3087. return
  3088. }
  3089. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3090. type ELeData struct {
  3091. Code string `json:"code"`
  3092. Data struct {
  3093. Aac002 string `json:"aac002"`
  3094. Aaz500 string `json:"aaz500"`
  3095. ActCardNo string `json:"actCardNo"`
  3096. Bab520 string `json:"bab520"`
  3097. Bkz543 string `json:"bkz543"`
  3098. BusinessType string `json:"businessType"`
  3099. CertfCodg string `json:"certfCodg"`
  3100. EcIndexNo string `json:"ecIndexNo"`
  3101. EcToken string `json:"ecToken"`
  3102. ID0000 string `json:"id0000"`
  3103. IDNo string `json:"idNo"`
  3104. IDType string `json:"idType"`
  3105. Idcode string `json:"idcode"`
  3106. IdentityToken string `json:"identity_token"`
  3107. InsuOrg string `json:"insuOrg"`
  3108. OfficeID string `json:"officeId"`
  3109. OfficeName string `json:"officeName"`
  3110. OperatorID string `json:"operatorId"`
  3111. OperatorName string `json:"operatorName"`
  3112. OrgID string `json:"orgId"`
  3113. UserName string `json:"userName"`
  3114. } `json:"data"`
  3115. Infno interface{} `json:"infno"`
  3116. Message string `json:"message"`
  3117. OrgID string `json:"orgId"`
  3118. TransType string `json:"transType"`
  3119. }
  3120. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3121. outPutInfo = Remove0000(outPutInfo)
  3122. if len(outPutInfo) > 0 {
  3123. var ele ELeData
  3124. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3125. if err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. }
  3128. token := ele.Data.EcToken
  3129. fmt.Println(inputInfo)
  3130. fmt.Println(outPutInfo)
  3131. 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)
  3132. saveLog(result, requestLog, "1101", "获取人员信息")
  3133. var dat map[string]interface{}
  3134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3135. fmt.Println(dat)
  3136. } else {
  3137. fmt.Println(err)
  3138. }
  3139. userJSONBytes, _ := json.Marshal(dat)
  3140. var res ResultTwo
  3141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3142. utils.ErrorLog("解析失败:%v", err)
  3143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. return
  3145. }
  3146. res.ErrMsg = errMsgLog
  3147. if res.Infcode == 0 {
  3148. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3149. if err == gorm.ErrRecordNotFound {
  3150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3151. return
  3152. } else if err != nil {
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3154. return
  3155. } else {
  3156. fmt.Println(res)
  3157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3159. infoStr := string(Iinfos)
  3160. idetinfoStr := string(Idetinfos)
  3161. psn := &models.HisPsn{
  3162. PsnNo: res.Output.Baseinfo.PsnNo,
  3163. Age: res.Output.Baseinfo.Age,
  3164. PatientId: patient.ID,
  3165. Certno: res.Output.Baseinfo.Certno,
  3166. Brdy: res.Output.Baseinfo.Brdy,
  3167. Gend: res.Output.Baseinfo.Gend,
  3168. Naty: res.Output.Baseinfo.Naty,
  3169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3170. PsnName: res.Output.Baseinfo.PsnName,
  3171. Idetinfo: idetinfoStr,
  3172. Insuinfo: infoStr,
  3173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3174. CardInfo: outPutInfo,
  3175. VerifyNumber: token,
  3176. }
  3177. service.CreateHisPsn(psn)
  3178. var rf []*ResultFive
  3179. json.Unmarshal([]byte(infoStr), &rf)
  3180. var insutypes []*ResultFive
  3181. var insutype string
  3182. var is390 int = 0
  3183. var is310 int = 0
  3184. for _, item := range rf {
  3185. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3186. insutypes = append(insutypes, item)
  3187. }
  3188. }
  3189. if len(insutypes) == 1 {
  3190. insutype = insutypes[0].Insutype
  3191. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3192. } else {
  3193. for _, i := range insutypes {
  3194. if i.Insutype == "390" {
  3195. is390 = 1
  3196. }
  3197. if i.Insutype == "310" {
  3198. is310 = 1
  3199. }
  3200. }
  3201. }
  3202. if is390 == 1 {
  3203. insutype = "390"
  3204. }
  3205. if is310 == 1 {
  3206. insutype = "310"
  3207. }
  3208. if len(insutypes) == 0 {
  3209. insutype = "310"
  3210. }
  3211. c.ServeSuccessJSON(map[string]interface{}{
  3212. "patient": patient,
  3213. "number": token,
  3214. "insutype": insutype,
  3215. })
  3216. }
  3217. } else {
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3219. return
  3220. }
  3221. }
  3222. }
  3223. break
  3224. }
  3225. }
  3226. var initFlag int64 = 0
  3227. var initEleFlag int64 = 0
  3228. func (c *HisApiController) TestGetBasBaseInit() {
  3229. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3230. Iinit := DllDef.MustFindProc("Init")
  3231. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3232. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3233. if ret != 0 {
  3234. fmt.Println("SSCard的报错原因:", err)
  3235. fmt.Println("SSCard的运算结果为:", ret)
  3236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3237. return
  3238. }
  3239. result := int(ret)
  3240. fmt.Println("SSCard的运算结果为1:", result)
  3241. initFlag = 1
  3242. return
  3243. }
  3244. func (c *HisApiController) HandleJiangXiReadCard() {
  3245. fmt.Println("~~~~~~")
  3246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3247. admin_user_id, _ := c.GetInt64("admin_user_id")
  3248. id_card_type, _ := c.GetInt64("id_card_type")
  3249. //certificates, _ := c.GetInt64("certificates")
  3250. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3251. if initFlag == 0 {
  3252. c.TestGetJiangXiBasBaseInit()
  3253. }
  3254. basStr := c.GetBasBaseInfo()
  3255. if len(basStr) == 0 {
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3257. return
  3258. }
  3259. fmt.Println(basStr)
  3260. bas := strings.Split(basStr, "|")
  3261. basNumber := bas[1]
  3262. fmt.Println(basNumber)
  3263. card_sn := bas[3]
  3264. fmt.Println(card_sn)
  3265. 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, "")
  3266. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3267. var dat map[string]interface{}
  3268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3269. fmt.Println(dat)
  3270. } else {
  3271. fmt.Println(err)
  3272. }
  3273. userJSONBytes, _ := json.Marshal(dat)
  3274. var res ResultTwo
  3275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3276. utils.ErrorLog("解析失败:%v", err)
  3277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. return
  3279. }
  3280. if res.Infcode == 0 {
  3281. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3282. if err == gorm.ErrRecordNotFound {
  3283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3284. return
  3285. } else if err != nil {
  3286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3287. return
  3288. } else {
  3289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3291. infoStr := string(Iinfos)
  3292. idetinfoStr := string(Idetinfos)
  3293. psn := &models.HisPsn{
  3294. PsnNo: res.Output.Baseinfo.PsnNo,
  3295. Age: res.Output.Baseinfo.Age,
  3296. PatientId: patient.ID,
  3297. Certno: res.Output.Baseinfo.Certno,
  3298. Brdy: res.Output.Baseinfo.Brdy,
  3299. Gend: res.Output.Baseinfo.Gend,
  3300. Naty: res.Output.Baseinfo.Naty,
  3301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3302. PsnName: res.Output.Baseinfo.PsnName,
  3303. Idetinfo: idetinfoStr,
  3304. Insuinfo: infoStr,
  3305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3306. CardInfo: basStr,
  3307. VerifyNumber: "",
  3308. }
  3309. service.CreateHisPsn(psn)
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "patient": patient,
  3312. "number": basNumber,
  3313. })
  3314. }
  3315. } else {
  3316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3317. return
  3318. }
  3319. }
  3320. func (c *HisApiController) TestGetHnBasBaseInit() {
  3321. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3322. Iinit := DllDef.MustFindProc("Init")
  3323. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3324. //http://10.77.211.236/CSB/hsa-fsi-1303
  3325. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3326. if ret != 0 {
  3327. fmt.Println("SSCard的报错原因:", err)
  3328. fmt.Println("SSCard的运算结果为:", ret)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3330. return
  3331. }
  3332. result := int(ret)
  3333. fmt.Println("SSCard的运算结果为1:", result)
  3334. initFlag = 1
  3335. return
  3336. }
  3337. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3338. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3339. Iinit := DllDef.MustFindProc("Init")
  3340. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3341. //http://10.77.211.236/CSB/hsa-fsi-1303
  3342. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3343. if ret != 0 {
  3344. fmt.Println("SSCard的报错原因:", err)
  3345. fmt.Println("SSCard的运算结果为:", ret)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3347. return
  3348. }
  3349. result := int(ret)
  3350. fmt.Println("SSCard的运算结果为1:", result)
  3351. initFlag = 1
  3352. return
  3353. }
  3354. func (c *HisApiController) GetSFZBaseInfo() string {
  3355. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3356. readCard := DllDef.MustFindProc("ReadSFZ")
  3357. if readCard == nil {
  3358. fmt.Println("readcard is nil")
  3359. readCard = DllDef.MustFindProc("ReadSFZ")
  3360. }
  3361. str := make([]byte, 8096)
  3362. str1 := make([]byte, 8096)
  3363. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3364. fmt.Println(r)
  3365. return Remove0000(string(str))
  3366. }
  3367. func (c *HisApiController) GetEleBaseInfo() string {
  3368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3369. readCard := DllDef.MustFindProc("GetQRBase")
  3370. fmt.Println(readCard)
  3371. if readCard == nil {
  3372. fmt.Println("readcard is nil")
  3373. readCard = DllDef.MustFindProc("GetQRBase")
  3374. }
  3375. str := make([]byte, 1024)
  3376. str1 := make([]byte, 1024)
  3377. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3378. fmt.Println(ret2)
  3379. fmt.Println(string(str1))
  3380. fmt.Println(string(str))
  3381. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3382. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3383. if ret2 != 0 {
  3384. return ""
  3385. }
  3386. return string(str)
  3387. }
  3388. func GetJxEleBaseInfo(org_id int64) string {
  3389. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3390. readCard := DllDef.MustFindProc("NationEcTrans")
  3391. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3392. if readCard == nil {
  3393. fmt.Println("readcard is nil")
  3394. readCard = DllDef.MustFindProc("NationEcTrans")
  3395. }
  3396. str1 := make([]byte, 1024)
  3397. data := make(map[string]interface{})
  3398. inputData := make(map[string]interface{})
  3399. inputData["orgId"] = miConfig.Code
  3400. inputData["businessType"] = "01101"
  3401. inputData["operatorId"] = "test001"
  3402. inputData["operatorName"] = "cn"
  3403. inputData["officeId"] = "32760"
  3404. inputData["officeName"] = "waike"
  3405. inputData["deviceType"] = ""
  3406. data["data"] = inputData
  3407. data["transType"] = "ec.query"
  3408. data["extra "] = ""
  3409. data["orgId"] = miConfig.Code
  3410. bytesData, _ := json.Marshal(data)
  3411. //bytesData, _ := json.Marshal(data)
  3412. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3413. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3414. fmt.Println(ret2)
  3415. fmt.Println(string(str1))
  3416. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3417. if ret2 != 0 {
  3418. return ""
  3419. }
  3420. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3421. }
  3422. func GetJxEleBaseInitInfo(org_id int64) string {
  3423. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3424. readCard := DllDef.MustFindProc("NationEcTrans")
  3425. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3426. if readCard == nil {
  3427. fmt.Println("readcard is nil")
  3428. readCard = DllDef.MustFindProc("NationEcTrans")
  3429. }
  3430. str1 := make([]byte, 2048)
  3431. data := make(map[string]interface{})
  3432. inputData := make(map[string]interface{})
  3433. inputData["orgId"] = miConfig.Code
  3434. inputData["businessType"] = "01101"
  3435. inputData["operatorId"] = "1"
  3436. inputData["operatorName"] = "huangchuang"
  3437. inputData["officeId"] = "101"
  3438. inputData["officeName"] = "xuetou"
  3439. inputData["deviceType"] = ""
  3440. data["data"] = inputData
  3441. data["transType"] = "ec.query"
  3442. data["orgId"] = miConfig.Code
  3443. bytesData, _ := json.Marshal(data)
  3444. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3445. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3446. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3447. fmt.Println(ret2)
  3448. fmt.Println(string(str1))
  3449. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3450. if ret2 != 0 {
  3451. return ""
  3452. }
  3453. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3454. initEleFlag = 1
  3455. }
  3456. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3457. }
  3458. func (c *HisApiController) GetBasBaseInfo() string {
  3459. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3460. readCard := DllDef.MustFindProc("ReadCardBas")
  3461. if readCard == nil {
  3462. fmt.Println("readcard is nil")
  3463. readCard = DllDef.MustFindProc("ReadCardBas")
  3464. }
  3465. str := make([]byte, 1024)
  3466. str1 := make([]byte, 1024)
  3467. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3468. fmt.Println(string(str1))
  3469. fmt.Println(string(str))
  3470. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3471. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3472. if ret2 != 0 {
  3473. return ""
  3474. }
  3475. return string(str)
  3476. }
  3477. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3478. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3479. readCard := DllDef.MustFindProc("read_cardinfo")
  3480. if readCard == nil {
  3481. fmt.Println("readcard is nil")
  3482. readCard = DllDef.MustFindProc("read_cardinfo")
  3483. }
  3484. str := make([]byte, 1024) //卡号
  3485. str1 := make([]byte, 1024) //卡识别码
  3486. str2 := make([]byte, 1024) //身份证号
  3487. str3 := make([]byte, 1024) //姓名
  3488. str4 := make([]byte, 1024) //错误信息
  3489. 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])))
  3490. fmt.Println(string(str1))
  3491. fmt.Println(string(str))
  3492. fmt.Println(string(str2))
  3493. fmt.Println(string(str3))
  3494. fmt.Println(string(str4))
  3495. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3496. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3497. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3498. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3499. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3500. if ret2 != 0 {
  3501. return "", "", "", "", ""
  3502. }
  3503. return string(str), string(str1), string(str2), string(str3), string(str4)
  3504. }
  3505. type CustomFundPay struct {
  3506. FundPayType string `json:"fund_pay_type"`
  3507. FundPayamt float64 `json:"fund_payamt"`
  3508. }
  3509. func (c *HisApiController) GetSettleList() {
  3510. order_id, _ := c.GetInt64("order_id")
  3511. admin_user_id, _ := c.GetInt64("admin_user_id")
  3512. order, _ := service.GetHisOrderByIDTwo(order_id)
  3513. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3514. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3515. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3516. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3517. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3518. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3519. if order.ID == 0 {
  3520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3521. return
  3522. }
  3523. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3524. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3525. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3526. fmt.Println(count)
  3527. var zero string
  3528. number := count + 1
  3529. if number >= 1000 {
  3530. zero = "0000" + strconv.FormatInt(number, 10)
  3531. } else if number >= 10000 {
  3532. zero = "000" + strconv.FormatInt(number, 10)
  3533. } else if number >= 100000 {
  3534. zero = "00" + strconv.FormatInt(number, 10)
  3535. } else if number >= 1000000 {
  3536. zero = "0" + strconv.FormatInt(number, 10)
  3537. } else {
  3538. zero = strconv.FormatInt(number, 10)
  3539. }
  3540. fmt.Println(zero)
  3541. struct4101 := service.Struct4101{
  3542. PsnNo: order.PsnNo,
  3543. MdtrtId: order.MdtrtId,
  3544. SetlId: order.SetlId,
  3545. PsnName: order.PsnName,
  3546. Gend: order.Gend,
  3547. Brdy: his.Brdy,
  3548. Age: his.Age,
  3549. Naty: order.Naty,
  3550. PatnCertType: "01",
  3551. Certno: order.Certno,
  3552. Prfs: "90",
  3553. ConerName: roles[0].UserName,
  3554. PatnRlts: "99",
  3555. ConerAddr: miConfig.OrgName,
  3556. ConerTel: admin.Mobile,
  3557. HiType: order.Insutype,
  3558. Insuplc: miConfig.InsuplcAdmdvs,
  3559. MaindiagFlag: "1",
  3560. BillCode: order.SetlId,
  3561. BillNo: order.SetlId,
  3562. BizSn: order.Number,
  3563. PsnSelfPay: order.PsnPartAmt,
  3564. PsnOwnPay: order.PsnPartAmt,
  3565. AcctPay: order.AcctPay,
  3566. PsnCashpay: order.PsnCashPay,
  3567. HiPaymtd: "1",
  3568. Hsorg: miConfig.InsuplcAdmdvs,
  3569. HsorgOpter: miConfig.InsuplcAdmdvs,
  3570. MedinsFillPsn: curRoles.UserName,
  3571. MedinsFillDept: depart.Name,
  3572. IptMedType: "2",
  3573. }
  3574. struct4101.SetlBegnDate = order.SetlTime
  3575. struct4101.SetlEndDate = order.SetlTime
  3576. time_arr := strings.Split(order.SetlTime, " ")
  3577. struct4101.AdmTime = time_arr[0]
  3578. struct4101.AdmEndTime = time_arr[0]
  3579. var rf []CustomFundPay
  3580. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3581. var tempFunPays []service.CustomStruct
  3582. for _, item := range rf {
  3583. var tempFunPay service.CustomStruct
  3584. tempFunPay.FundPayamt = item.FundPayamt
  3585. tempFunPay.FundPayType = item.FundPayType
  3586. tempFunPays = append(tempFunPays, tempFunPay)
  3587. }
  3588. struct4101.CustomStruct = tempFunPays
  3589. var tempDiaginfos []service.DiaginfoStructTwo
  3590. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3591. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3592. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3593. var config []*models.HisXtDiagnoseConfig
  3594. for _, item := range diagnosis_ids {
  3595. id, _ := strconv.ParseInt(item, 10, 64)
  3596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3597. config = append(config, &diagnosisConfig)
  3598. }
  3599. for index, item := range config {
  3600. if index == 0 {
  3601. var tempDiaginfo service.DiaginfoStructTwo
  3602. tempDiaginfo.DiagCode = item.CountryCode
  3603. tempDiaginfo.DiagName = item.CountryContentName
  3604. tempDiaginfo.DiagType = "1"
  3605. tempDiaginfo.MaindiagFlag = "1"
  3606. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3607. } else {
  3608. var tempDiaginfo service.DiaginfoStructTwo
  3609. tempDiaginfo.DiagCode = item.CountryCode
  3610. tempDiaginfo.DiagName = item.CountryContentName
  3611. tempDiaginfo.DiagType = "2"
  3612. tempDiaginfo.MaindiagFlag = "0"
  3613. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3614. }
  3615. }
  3616. struct4101.Diseinfo = tempDiaginfos
  3617. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3618. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3619. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3620. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3621. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3622. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3623. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3624. var iteminfo service.IteminfoStruct
  3625. var bedCostTotal float64 = 0 //床位总费
  3626. var bedCostSelfTotal float64 = 0 //床位自费
  3627. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3628. var operationCostTotal float64 = 0 //手术费
  3629. var operationCostSelfTotal float64 = 0 //手术费
  3630. var operationCostPartSelfTotal float64 = 0 //手术费
  3631. var otherCostTotal float64 = 0 //其他费用
  3632. var otherCostSelfTotal float64 = 0 //其他费用
  3633. var otherCostPartSelfTotal float64 = 0 //其他费用
  3634. var materialCostTotal float64 = 0 //材料费
  3635. var materialCostSelfTotal float64 = 0 //材料费
  3636. var materialCostPartSelfTotal float64 = 0 //材料费
  3637. var westernMedicineCostTotal float64 = 0 //西药费
  3638. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3639. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3640. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3641. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3642. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3643. var checkCostTotal float64 = 0 //检查费
  3644. var checkCostSelfTotal float64 = 0 //检查费
  3645. var checkCostPartSelfTotal float64 = 0 //检查费
  3646. var laboratoryCostTotal float64 = 0 //化验费
  3647. var laboratoryCostSelfTotal float64 = 0 //化验费
  3648. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3649. var treatCostTotal float64 = 0 //治疗费用
  3650. var treatCostSelfTotal float64 = 0 //治疗费用
  3651. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3652. decimal.DivisionPrecision = 2
  3653. var bed_fulamt_ownpay_amt float64 = 0
  3654. var operation_fulamt_ownpay_amt float64 = 0
  3655. var other_fulamt_ownpay_amt float64 = 0
  3656. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3657. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3658. var check_fulamt_ownpay_amt float64 = 0
  3659. var material_fulamt_ownpay_amt float64 = 0
  3660. var laboratory_fulamt_ownpay_amt float64 = 0
  3661. var treat_fulamt_ownpay_amt float64 = 0
  3662. var bed_claa_sunmfee float64 = 0
  3663. var bed_clab_amt float64 = 0
  3664. var bed_other_amt float64 = 0
  3665. var operation_claa_sunmfee float64 = 0
  3666. var operation_clab_amt float64 = 0
  3667. var operation_other_amt float64 = 0
  3668. var other_claa_sunmfee float64 = 0
  3669. var other_clab_amt float64 = 0
  3670. var other_other_amt float64 = 0
  3671. var westernMedicine_claa_sunmfee float64 = 0
  3672. var westernMedicine_clab_amt float64 = 0
  3673. var westernMedicine_other_amt float64 = 0
  3674. var chineseTraditional_claa_sunmfee float64 = 0
  3675. var chineseTraditional_clab_amt float64 = 0
  3676. var chineseTraditional_other_amt float64 = 0
  3677. var check_claa_sunmfee float64 = 0
  3678. var check_clab_amt float64 = 0
  3679. var check_other_amt float64 = 0
  3680. var material_claa_sunmfee float64 = 0
  3681. var material_clab_amt float64 = 0
  3682. var material_other_amt float64 = 0
  3683. var laboratory_claa_sunmfee float64 = 0
  3684. var laboratory_clab_amt float64 = 0
  3685. var laboratory_other_amt float64 = 0
  3686. var treat_claa_sunmfee float64 = 0
  3687. var treat_clab_amt float64 = 0
  3688. var treat_other_amt float64 = 0
  3689. for _, item := range order.HisOrderInfo {
  3690. if item.MedChrgitmType == "01" { //床位费
  3691. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3692. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3693. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3694. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3695. if item.ChrgitmLv == "1" {
  3696. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3697. }
  3698. if item.ChrgitmLv == "2" {
  3699. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3700. }
  3701. if item.ChrgitmLv == "3" {
  3702. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3703. }
  3704. }
  3705. if item.MedChrgitmType == "03" { //检查费
  3706. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3707. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3708. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3709. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3710. if item.ChrgitmLv == "1" {
  3711. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3712. }
  3713. if item.ChrgitmLv == "2" {
  3714. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3715. }
  3716. if item.ChrgitmLv == "3" {
  3717. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3718. }
  3719. }
  3720. if item.MedChrgitmType == "04" { //化验费
  3721. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3722. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3723. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3724. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3725. if item.ChrgitmLv == "1" {
  3726. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3727. }
  3728. if item.ChrgitmLv == "2" {
  3729. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3730. }
  3731. if item.ChrgitmLv == "3" {
  3732. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3733. }
  3734. }
  3735. if item.MedChrgitmType == "05" { //治疗费
  3736. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3737. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3738. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3739. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3740. if item.ChrgitmLv == "1" {
  3741. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3742. }
  3743. if item.ChrgitmLv == "2" {
  3744. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3745. }
  3746. if item.ChrgitmLv == "3" {
  3747. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3748. }
  3749. }
  3750. if item.MedChrgitmType == "06" { //手术费
  3751. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3752. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3753. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3754. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3755. if item.ChrgitmLv == "1" {
  3756. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3757. }
  3758. if item.ChrgitmLv == "2" {
  3759. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3760. }
  3761. if item.ChrgitmLv == "3" {
  3762. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3763. }
  3764. }
  3765. if item.MedChrgitmType == "08" { //材料费
  3766. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3767. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3768. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3769. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3770. if item.ChrgitmLv == "1" {
  3771. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3772. }
  3773. if item.ChrgitmLv == "2" {
  3774. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3775. }
  3776. if item.ChrgitmLv == "3" {
  3777. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3778. }
  3779. }
  3780. if item.MedChrgitmType == "09" { //西药费
  3781. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3782. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3783. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3784. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3785. if item.ChrgitmLv == "1" {
  3786. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3787. }
  3788. if item.ChrgitmLv == "2" {
  3789. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3790. }
  3791. if item.ChrgitmLv == "3" {
  3792. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3793. }
  3794. }
  3795. if item.MedChrgitmType == "11" { //中成费
  3796. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3797. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3798. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3799. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3800. if item.ChrgitmLv == "1" {
  3801. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3802. }
  3803. if item.ChrgitmLv == "2" {
  3804. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3805. }
  3806. if item.ChrgitmLv == "3" {
  3807. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3808. }
  3809. }
  3810. if item.MedChrgitmType == "14" { //其他费
  3811. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3812. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3813. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3814. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3815. if item.ChrgitmLv == "1" {
  3816. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3817. }
  3818. if item.ChrgitmLv == "2" {
  3819. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3820. }
  3821. if item.ChrgitmLv == "3" {
  3822. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3823. }
  3824. }
  3825. }
  3826. var iteminfoStructs []service.IteminfoStruct
  3827. if bedCostTotal != 0 {
  3828. iteminfo.MedChrgitm = "01"
  3829. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3830. iteminfo.Amt = bedCostTotal
  3831. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3832. iteminfo.ClabAmt = bed_clab_amt
  3833. iteminfo.OthAmt = bed_other_amt
  3834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3835. }
  3836. if checkCostTotal != 0 {
  3837. iteminfo.MedChrgitm = "03"
  3838. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3839. iteminfo.Amt = checkCostTotal
  3840. iteminfo.ClaaSumfee = check_claa_sunmfee
  3841. iteminfo.ClabAmt = check_clab_amt
  3842. iteminfo.OthAmt = check_other_amt
  3843. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3844. }
  3845. if laboratoryCostTotal != 0 {
  3846. iteminfo.MedChrgitm = "04"
  3847. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3848. iteminfo.Amt = laboratoryCostTotal
  3849. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3850. iteminfo.ClabAmt = laboratory_clab_amt
  3851. iteminfo.OthAmt = laboratory_other_amt
  3852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3853. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3854. }
  3855. if treatCostTotal != 0 {
  3856. iteminfo.MedChrgitm = "05"
  3857. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3858. iteminfo.Amt = treatCostTotal
  3859. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3860. iteminfo.ClabAmt = treat_clab_amt
  3861. iteminfo.OthAmt = treat_other_amt
  3862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3863. //(struct4101.IteminfoStruct, iteminfo)
  3864. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3865. }
  3866. if operationCostTotal != 0 {
  3867. iteminfo.MedChrgitm = "06"
  3868. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3869. iteminfo.Amt = operationCostTotal
  3870. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3871. iteminfo.ClabAmt = operation_clab_amt
  3872. iteminfo.OthAmt = operation_other_amt
  3873. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3875. }
  3876. if materialCostTotal != 0 {
  3877. iteminfo.MedChrgitm = "08"
  3878. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3879. iteminfo.Amt = materialCostTotal
  3880. iteminfo.ClaaSumfee = material_claa_sunmfee
  3881. iteminfo.ClabAmt = material_clab_amt
  3882. iteminfo.OthAmt = material_other_amt
  3883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3885. }
  3886. if westernMedicineCostTotal != 0 {
  3887. iteminfo.MedChrgitm = "09"
  3888. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3889. iteminfo.Amt = westernMedicineCostTotal
  3890. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3891. iteminfo.ClabAmt = westernMedicine_clab_amt
  3892. iteminfo.OthAmt = westernMedicine_other_amt
  3893. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3895. }
  3896. if chineseTraditionalMedicineCostTotal != 0 {
  3897. iteminfo.MedChrgitm = "11"
  3898. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3899. iteminfo.Amt = westernMedicineCostTotal
  3900. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3901. iteminfo.ClabAmt = westernMedicine_clab_amt
  3902. iteminfo.OthAmt = westernMedicine_other_amt
  3903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3905. }
  3906. if otherCostTotal != 0 {
  3907. iteminfo.MedChrgitm = "14"
  3908. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3909. iteminfo.Amt = otherCostTotal
  3910. iteminfo.ClaaSumfee = other_claa_sunmfee
  3911. iteminfo.ClabAmt = other_clab_amt
  3912. iteminfo.OthAmt = other_other_amt
  3913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3915. }
  3916. struct4101.IteminfoStruct = iteminfoStructs
  3917. struct4101.Ntly = "中国"
  3918. struct4101.AdmCaty = "A03.06"
  3919. var res ResultSeventeen
  3920. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3921. struct4101.BillCode = order.Number
  3922. struct4101.BillNo = order.SetlId
  3923. var resOther ResultSeventeenOther
  3924. var pp models.PublicParams
  3925. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3926. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3927. pp.FixmedinsName = miConfig.OrgName
  3928. pp.FixmedinsCode = miConfig.Code
  3929. pp.RequestUrl = miConfig.Url
  3930. pp.Cainfo = miConfig.Cainfo
  3931. pp.SecretKey = miConfig.SecretKey
  3932. pp.AccessKey = miConfig.AccessKey
  3933. pp.OpterName = curRoles.UserName
  3934. client := &http.Client{}
  3935. var req *http.Request
  3936. data := make(map[string]interface{})
  3937. data["struct4101"] = struct4101
  3938. data["pp"] = pp
  3939. bytesData, _ := json.Marshal(data)
  3940. if miConfig.MdtrtareaAdmvs == "320921" {
  3941. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3942. } else {
  3943. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3944. }
  3945. resp, _ := client.Do(req)
  3946. defer resp.Body.Close()
  3947. body, ioErr := ioutil.ReadAll(resp.Body)
  3948. if ioErr != nil {
  3949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3951. return
  3952. }
  3953. var respJSON map[string]interface{}
  3954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3960. userJSONBytes, _ := json.Marshal(respJSON)
  3961. fmt.Println("log")
  3962. fmt.Println(string(userJSONBytes))
  3963. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3964. utils.ErrorLog("解析失败:%v", err)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. res.InfRefmsgid = resOther.InfRefmsgid
  3969. res.Output = resOther.Output
  3970. res.ErrMsg = resOther.ErrMsg
  3971. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3972. res.Infcode = infocode
  3973. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3974. var pp models.PublicParams
  3975. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3976. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3977. pp.FixmedinsName = miConfig.OrgName
  3978. pp.FixmedinsCode = miConfig.Code
  3979. pp.RequestUrl = miConfig.Url
  3980. pp.Cainfo = miConfig.Cainfo
  3981. pp.SecretKey = miConfig.SecretKey
  3982. pp.AccessKey = miConfig.AccessKey
  3983. pp.OpterName = curRoles.UserName
  3984. result, _ := service.Jxyb4101(struct4101, pp)
  3985. var dat map[string]interface{}
  3986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3987. fmt.Println(dat)
  3988. } else {
  3989. fmt.Println(err)
  3990. }
  3991. userJSONBytes, _ := json.Marshal(dat)
  3992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3993. utils.ErrorLog("解析失败:%v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3998. var pp models.PublicParams
  3999. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4000. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4001. pp.FixmedinsName = miConfig.OrgName
  4002. pp.FixmedinsCode = miConfig.Code
  4003. pp.RequestUrl = miConfig.Url
  4004. pp.Cainfo = miConfig.Cainfo
  4005. pp.SecretKey = miConfig.SecretKey
  4006. pp.AccessKey = miConfig.AccessKey
  4007. pp.OpterName = curRoles.UserName
  4008. result, _ := service.Hnyb4101(struct4101, pp)
  4009. var dat map[string]interface{}
  4010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4011. fmt.Println(dat)
  4012. } else {
  4013. fmt.Println(err)
  4014. }
  4015. userJSONBytes, _ := json.Marshal(dat)
  4016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4017. utils.ErrorLog("解析失败:%v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. } else {
  4022. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4023. var dat map[string]interface{}
  4024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4025. fmt.Println(dat)
  4026. } else {
  4027. fmt.Println(err)
  4028. }
  4029. userJSONBytes, _ := json.Marshal(dat)
  4030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4031. utils.ErrorLog("解析失败:%v", err)
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. }
  4036. if res.Infcode != 0 {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": res.ErrMsg,
  4040. })
  4041. return
  4042. } else {
  4043. order.FaPiaoNumber = zero
  4044. order.FaPiaoCode = last_order.FaPiaoCode
  4045. service.UpdateOrder(order)
  4046. hisFundSettleListResult := &models.HisFundSettleListResult{
  4047. Number: res.Output.SetlListId,
  4048. Status: 1,
  4049. Ctime: time.Now().Unix(),
  4050. Mtime: time.Now().Unix(),
  4051. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4052. IsUpload: 1,
  4053. OrderId: order_id,
  4054. }
  4055. service.CreateUploadRecord(hisFundSettleListResult)
  4056. c.ServeSuccessJSON(map[string]interface{}{
  4057. "msg": "上传成功",
  4058. "result": hisFundSettleListResult,
  4059. })
  4060. return
  4061. }
  4062. }
  4063. func (c *HisApiController) GetSettleListHospital() {
  4064. order_id, _ := c.GetInt64("order_id")
  4065. admin_user_id, _ := c.GetInt64("admin_user_id")
  4066. order, _ := service.GetHisOrderByIDTwo(order_id)
  4067. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4068. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4069. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4071. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4072. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4073. if order.ID == 0 {
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4075. return
  4076. }
  4077. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4078. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4079. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4080. fmt.Println(count)
  4081. var zero string
  4082. number := count + 1
  4083. if number >= 1000 {
  4084. zero = "0000" + strconv.FormatInt(number, 10)
  4085. } else if number >= 10000 {
  4086. zero = "000" + strconv.FormatInt(number, 10)
  4087. } else if number >= 100000 {
  4088. zero = "00" + strconv.FormatInt(number, 10)
  4089. } else if number >= 1000000 {
  4090. zero = "0" + strconv.FormatInt(number, 10)
  4091. } else {
  4092. zero = strconv.FormatInt(number, 10)
  4093. }
  4094. fmt.Println(zero)
  4095. struct4101 := service.Struct4101{
  4096. PsnNo: order.PsnNo,
  4097. MdtrtId: order.MdtrtId,
  4098. SetlId: order.SetlId,
  4099. PsnName: order.PsnName,
  4100. Gend: order.Gend,
  4101. Brdy: his.Brdy,
  4102. Age: int64(order.Age),
  4103. Naty: order.Naty,
  4104. PatnCertType: "01",
  4105. Certno: order.Certno,
  4106. Prfs: "90",
  4107. ConerName: roles[0].UserName,
  4108. PatnRlts: "99",
  4109. ConerAddr: miConfig.OrgName,
  4110. ConerTel: admin.Mobile,
  4111. HiType: order.Insutype,
  4112. Insuplc: miConfig.InsuplcAdmdvs,
  4113. MaindiagFlag: "1",
  4114. BillCode: order.SetlId,
  4115. BillNo: order.SetlId,
  4116. BizSn: order.Number,
  4117. PsnSelfPay: order.PsnPartAmt,
  4118. PsnOwnPay: order.PsnPartAmt,
  4119. AcctPay: order.AcctPay,
  4120. PsnCashpay: order.PsnCashPay,
  4121. HiPaymtd: "1",
  4122. Hsorg: miConfig.InsuplcAdmdvs,
  4123. HsorgOpter: miConfig.InsuplcAdmdvs,
  4124. MedinsFillPsn: curRoles.UserName,
  4125. MedinsFillDept: depart.Name,
  4126. IptMedType: "2",
  4127. AdmTime: his.InHosptialTime,
  4128. AdmEndTime: his.OutHosptialTime,
  4129. }
  4130. struct4101.SetlBegnDate = order.SetlTime
  4131. struct4101.SetlEndDate = order.SetlTime
  4132. var rf []CustomFundPay
  4133. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4134. var tempFunPays []service.CustomStruct
  4135. for _, item := range rf {
  4136. var tempFunPay service.CustomStruct
  4137. tempFunPay.FundPayamt = item.FundPayamt
  4138. tempFunPay.FundPayType = item.FundPayType
  4139. tempFunPays = append(tempFunPays, tempFunPay)
  4140. }
  4141. struct4101.CustomStruct = tempFunPays
  4142. var tempDiaginfos []service.DiaginfoStructTwo
  4143. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4144. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4145. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4146. var config []*models.HisXtDiagnoseConfig
  4147. for _, item := range diagnosis_ids {
  4148. id, _ := strconv.ParseInt(item, 10, 64)
  4149. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4150. config = append(config, &diagnosisConfig)
  4151. }
  4152. for index, item := range config {
  4153. if index == 0 {
  4154. var tempDiaginfo service.DiaginfoStructTwo
  4155. tempDiaginfo.DiagCode = item.CountryCode
  4156. tempDiaginfo.DiagName = item.CountryContentName
  4157. tempDiaginfo.DiagType = "1"
  4158. tempDiaginfo.MaindiagFlag = "1"
  4159. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4160. } else {
  4161. var tempDiaginfo service.DiaginfoStructTwo
  4162. tempDiaginfo.DiagCode = item.CountryCode
  4163. tempDiaginfo.DiagName = item.CountryContentName
  4164. tempDiaginfo.DiagType = "2"
  4165. tempDiaginfo.MaindiagFlag = "0"
  4166. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4167. }
  4168. }
  4169. struct4101.Diseinfo = tempDiaginfos
  4170. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4171. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4172. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4173. tempOpspdiseinfo2.OprnOprtCode = ""
  4174. tempOpspdiseinfo2.OprnOprtName = ""
  4175. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4176. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4177. var iteminfo service.IteminfoStruct
  4178. var bedCostTotal float64 = 0 //床位总费
  4179. var bedCostSelfTotal float64 = 0 //床位自费
  4180. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4181. var operationCostTotal float64 = 0 //手术费
  4182. var operationCostSelfTotal float64 = 0 //手术费
  4183. var operationCostPartSelfTotal float64 = 0 //手术费
  4184. var otherCostTotal float64 = 0 //其他费用
  4185. var otherCostSelfTotal float64 = 0 //其他费用
  4186. var otherCostPartSelfTotal float64 = 0 //其他费用
  4187. var materialCostTotal float64 = 0 //材料费
  4188. var materialCostSelfTotal float64 = 0 //材料费
  4189. var materialCostPartSelfTotal float64 = 0 //材料费
  4190. var westernMedicineCostTotal float64 = 0 //西药费
  4191. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4192. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4193. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4194. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4195. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4196. var checkCostTotal float64 = 0 //检查费
  4197. var checkCostSelfTotal float64 = 0 //检查费
  4198. var checkCostPartSelfTotal float64 = 0 //检查费
  4199. var laboratoryCostTotal float64 = 0 //化验费
  4200. var laboratoryCostSelfTotal float64 = 0 //化验费
  4201. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4202. var treatCostTotal float64 = 0 //治疗费用
  4203. var treatCostSelfTotal float64 = 0 //治疗费用
  4204. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4205. decimal.DivisionPrecision = 2
  4206. var bed_fulamt_ownpay_amt float64 = 0
  4207. var operation_fulamt_ownpay_amt float64 = 0
  4208. var other_fulamt_ownpay_amt float64 = 0
  4209. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4210. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4211. var check_fulamt_ownpay_amt float64 = 0
  4212. var material_fulamt_ownpay_amt float64 = 0
  4213. var laboratory_fulamt_ownpay_amt float64 = 0
  4214. var treat_fulamt_ownpay_amt float64 = 0
  4215. var bed_claa_sunmfee float64 = 0
  4216. var bed_clab_amt float64 = 0
  4217. var bed_other_amt float64 = 0
  4218. var operation_claa_sunmfee float64 = 0
  4219. var operation_clab_amt float64 = 0
  4220. var operation_other_amt float64 = 0
  4221. var other_claa_sunmfee float64 = 0
  4222. var other_clab_amt float64 = 0
  4223. var other_other_amt float64 = 0
  4224. var westernMedicine_claa_sunmfee float64 = 0
  4225. var westernMedicine_clab_amt float64 = 0
  4226. var westernMedicine_other_amt float64 = 0
  4227. var chineseTraditional_claa_sunmfee float64 = 0
  4228. var chineseTraditional_clab_amt float64 = 0
  4229. var chineseTraditional_other_amt float64 = 0
  4230. var check_claa_sunmfee float64 = 0
  4231. var check_clab_amt float64 = 0
  4232. var check_other_amt float64 = 0
  4233. var material_claa_sunmfee float64 = 0
  4234. var material_clab_amt float64 = 0
  4235. var material_other_amt float64 = 0
  4236. var laboratory_claa_sunmfee float64 = 0
  4237. var laboratory_clab_amt float64 = 0
  4238. var laboratory_other_amt float64 = 0
  4239. var treat_claa_sunmfee float64 = 0
  4240. var treat_clab_amt float64 = 0
  4241. var treat_other_amt float64 = 0
  4242. for _, item := range order.HisOrderInfo {
  4243. if item.MedChrgitmType == "01" { //床位费
  4244. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4245. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4246. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4247. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4248. if item.ChrgitmLv == "1" {
  4249. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4250. }
  4251. if item.ChrgitmLv == "2" {
  4252. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4253. }
  4254. if item.ChrgitmLv == "3" {
  4255. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4256. }
  4257. }
  4258. if item.MedChrgitmType == "03" { //检查费
  4259. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4260. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4261. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4262. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4263. if item.ChrgitmLv == "1" {
  4264. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4265. }
  4266. if item.ChrgitmLv == "2" {
  4267. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4268. }
  4269. if item.ChrgitmLv == "3" {
  4270. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4271. }
  4272. }
  4273. if item.MedChrgitmType == "04" { //化验费
  4274. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4275. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4276. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4277. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4278. if item.ChrgitmLv == "1" {
  4279. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4280. }
  4281. if item.ChrgitmLv == "2" {
  4282. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4283. }
  4284. if item.ChrgitmLv == "3" {
  4285. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4286. }
  4287. }
  4288. if item.MedChrgitmType == "05" { //治疗费
  4289. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4290. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4291. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4292. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4293. if item.ChrgitmLv == "1" {
  4294. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4295. }
  4296. if item.ChrgitmLv == "2" {
  4297. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4298. }
  4299. if item.ChrgitmLv == "3" {
  4300. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4301. }
  4302. }
  4303. if item.MedChrgitmType == "06" { //手术费
  4304. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4305. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4306. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4307. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4308. if item.ChrgitmLv == "1" {
  4309. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4310. }
  4311. if item.ChrgitmLv == "2" {
  4312. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4313. }
  4314. if item.ChrgitmLv == "3" {
  4315. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4316. }
  4317. }
  4318. if item.MedChrgitmType == "08" { //材料费
  4319. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4320. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4321. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4322. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4323. if item.ChrgitmLv == "1" {
  4324. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4325. }
  4326. if item.ChrgitmLv == "2" {
  4327. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4328. }
  4329. if item.ChrgitmLv == "3" {
  4330. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4331. }
  4332. }
  4333. if item.MedChrgitmType == "09" { //西药费
  4334. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4335. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4336. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4337. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4338. if item.ChrgitmLv == "1" {
  4339. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4340. }
  4341. if item.ChrgitmLv == "2" {
  4342. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4343. }
  4344. if item.ChrgitmLv == "3" {
  4345. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4346. }
  4347. }
  4348. if item.MedChrgitmType == "11" { //中成费
  4349. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4350. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4351. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4352. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4353. if item.ChrgitmLv == "1" {
  4354. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4355. }
  4356. if item.ChrgitmLv == "2" {
  4357. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4358. }
  4359. if item.ChrgitmLv == "3" {
  4360. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4361. }
  4362. }
  4363. if item.MedChrgitmType == "14" { //其他费
  4364. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4365. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4366. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4367. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4368. if item.ChrgitmLv == "1" {
  4369. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4370. }
  4371. if item.ChrgitmLv == "2" {
  4372. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4373. }
  4374. if item.ChrgitmLv == "3" {
  4375. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4376. }
  4377. }
  4378. }
  4379. var iteminfoStructs []service.IteminfoStruct
  4380. if bedCostTotal != 0 {
  4381. iteminfo.MedChrgitm = "01"
  4382. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4383. iteminfo.Amt = bedCostTotal
  4384. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4385. iteminfo.ClabAmt = bed_clab_amt
  4386. iteminfo.OthAmt = bed_other_amt
  4387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4388. }
  4389. if checkCostTotal != 0 {
  4390. iteminfo.MedChrgitm = "03"
  4391. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4392. iteminfo.Amt = checkCostTotal
  4393. iteminfo.ClaaSumfee = check_claa_sunmfee
  4394. iteminfo.ClabAmt = check_clab_amt
  4395. iteminfo.OthAmt = check_other_amt
  4396. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4397. }
  4398. if laboratoryCostTotal != 0 {
  4399. iteminfo.MedChrgitm = "04"
  4400. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4401. iteminfo.Amt = laboratoryCostTotal
  4402. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4403. iteminfo.ClabAmt = laboratory_clab_amt
  4404. iteminfo.OthAmt = laboratory_other_amt
  4405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4407. }
  4408. if treatCostTotal != 0 {
  4409. iteminfo.MedChrgitm = "05"
  4410. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4411. iteminfo.Amt = treatCostTotal
  4412. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4413. iteminfo.ClabAmt = treat_clab_amt
  4414. iteminfo.OthAmt = treat_other_amt
  4415. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4416. //(struct4101.IteminfoStruct, iteminfo)
  4417. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4418. }
  4419. if operationCostTotal != 0 {
  4420. iteminfo.MedChrgitm = "06"
  4421. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4422. iteminfo.Amt = operationCostTotal
  4423. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4424. iteminfo.ClabAmt = operation_clab_amt
  4425. iteminfo.OthAmt = operation_other_amt
  4426. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4428. }
  4429. if materialCostTotal != 0 {
  4430. iteminfo.MedChrgitm = "08"
  4431. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4432. iteminfo.Amt = materialCostTotal
  4433. iteminfo.ClaaSumfee = material_claa_sunmfee
  4434. iteminfo.ClabAmt = material_clab_amt
  4435. iteminfo.OthAmt = material_other_amt
  4436. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4437. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4438. }
  4439. if westernMedicineCostTotal != 0 {
  4440. iteminfo.MedChrgitm = "09"
  4441. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4442. iteminfo.Amt = westernMedicineCostTotal
  4443. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4444. iteminfo.ClabAmt = westernMedicine_clab_amt
  4445. iteminfo.OthAmt = westernMedicine_other_amt
  4446. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4447. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4448. }
  4449. if chineseTraditionalMedicineCostTotal != 0 {
  4450. iteminfo.MedChrgitm = "11"
  4451. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4452. iteminfo.Amt = westernMedicineCostTotal
  4453. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4454. iteminfo.ClabAmt = westernMedicine_clab_amt
  4455. iteminfo.OthAmt = westernMedicine_other_amt
  4456. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4458. }
  4459. if otherCostTotal != 0 {
  4460. iteminfo.MedChrgitm = "14"
  4461. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4462. iteminfo.Amt = otherCostTotal
  4463. iteminfo.ClaaSumfee = other_claa_sunmfee
  4464. iteminfo.ClabAmt = other_clab_amt
  4465. iteminfo.OthAmt = other_other_amt
  4466. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4467. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4468. }
  4469. struct4101.IteminfoStruct = iteminfoStructs
  4470. struct4101.Ntly = "中国"
  4471. struct4101.AdmCaty = "A03.06"
  4472. var resOther ResultSeventeenOther
  4473. var res ResultSeventeen
  4474. if miConfig.MdtrtareaAdmvs == "150499" {
  4475. var pp models.PublicParams
  4476. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4477. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4478. pp.FixmedinsName = miConfig.OrgName
  4479. pp.FixmedinsCode = miConfig.Code
  4480. pp.RequestUrl = miConfig.Url
  4481. pp.Cainfo = miConfig.Cainfo
  4482. pp.SecretKey = miConfig.SecretKey
  4483. pp.AccessKey = miConfig.AccessKey
  4484. pp.OpterName = curRoles.UserName
  4485. client := &http.Client{}
  4486. var req *http.Request
  4487. data := make(map[string]interface{})
  4488. data["struct4101"] = struct4101
  4489. data["pp"] = pp
  4490. bytesData, _ := json.Marshal(data)
  4491. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4492. resp, _ := client.Do(req)
  4493. defer resp.Body.Close()
  4494. body, ioErr := ioutil.ReadAll(resp.Body)
  4495. if ioErr != nil {
  4496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4498. return
  4499. }
  4500. var respJSON map[string]interface{}
  4501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. return
  4505. }
  4506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4507. userJSONBytes, _ := json.Marshal(respJSON)
  4508. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4509. utils.ErrorLog("解析失败:%v", err)
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4511. return
  4512. }
  4513. res.InfRefmsgid = resOther.InfRefmsgid
  4514. res.Output = resOther.Output
  4515. res.ErrMsg = resOther.ErrMsg
  4516. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4517. res.Infcode = infocode
  4518. } else {
  4519. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4520. var dat map[string]interface{}
  4521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4522. fmt.Println(dat)
  4523. } else {
  4524. fmt.Println(err)
  4525. }
  4526. userJSONBytes, _ := json.Marshal(dat)
  4527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4528. utils.ErrorLog("解析失败:%v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. }
  4533. if res.Infcode != 0 {
  4534. c.ServeSuccessJSON(map[string]interface{}{
  4535. "failed_code": -10,
  4536. "msg": res.ErrMsg,
  4537. })
  4538. return
  4539. } else {
  4540. if miConfig.MdtrtareaAdmvs != "150499" {
  4541. order.FaPiaoNumber = zero
  4542. order.FaPiaoCode = last_order.FaPiaoCode
  4543. service.UpdateOrder(order)
  4544. }
  4545. hisFundSettleListResult := &models.HisFundSettleListResult{
  4546. Number: res.Output.SetlListId,
  4547. Status: 1,
  4548. Ctime: time.Now().Unix(),
  4549. Mtime: time.Now().Unix(),
  4550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4551. IsUpload: 1,
  4552. OrderId: order_id,
  4553. }
  4554. service.CreateUploadRecord(hisFundSettleListResult)
  4555. c.ServeSuccessJSON(map[string]interface{}{
  4556. "msg": "上传成功",
  4557. "result": hisFundSettleListResult,
  4558. })
  4559. return
  4560. }
  4561. }
  4562. func (c *HisApiController) GetBatchSettleList() {
  4563. orders, _ := service.GetAllHisOrder(10106)
  4564. for _, item := range orders {
  4565. order_id := item.ID
  4566. order, _ := service.GetHisOrderByIDTwo(order_id)
  4567. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4568. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4569. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4571. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4573. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4574. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4575. if order.ID == 0 {
  4576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4577. return
  4578. }
  4579. if his.BalanceAccountsType == 2 {
  4580. continue
  4581. }
  4582. struct4101 := service.Struct4101{
  4583. PsnNo: order.PsnNo,
  4584. MdtrtId: order.MdtrtId,
  4585. SetlId: order.SetlId,
  4586. PsnName: order.PsnName,
  4587. Gend: order.Gend,
  4588. Brdy: his.Brdy,
  4589. Age: his.Age,
  4590. Naty: order.Naty,
  4591. PatnCertType: "01",
  4592. Certno: order.Certno,
  4593. Prfs: "90",
  4594. ConerName: roles[0].UserName,
  4595. PatnRlts: "99",
  4596. ConerAddr: miConfig.OrgName,
  4597. ConerTel: admin.Mobile,
  4598. HiType: order.Insutype,
  4599. Insuplc: his.InsuplcAdmdvs,
  4600. MaindiagFlag: "1",
  4601. BillCode: order.SetlId,
  4602. BillNo: order.SetlId,
  4603. BizSn: order.Number,
  4604. PsnSelfPay: order.PsnPartAmt,
  4605. PsnOwnPay: order.PsnPartAmt,
  4606. AcctPay: order.AcctPay,
  4607. PsnCashpay: order.PsnCashPay,
  4608. HiPaymtd: "1",
  4609. Hsorg: his.InsuplcAdmdvs,
  4610. HsorgOpter: his.InsuplcAdmdvs,
  4611. MedinsFillPsn: curRoles.UserName,
  4612. MedinsFillDept: depart.Name,
  4613. IptMedType: "2",
  4614. }
  4615. struct4101.SetlBegnDate = order.SetlTime
  4616. struct4101.SetlEndDate = order.SetlTime
  4617. //if order.SettleType == 1 {
  4618. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4619. // dateStr := t.Format("2006-01-02")
  4620. // struct4101.SetlBegnDate = dateStr
  4621. // struct4101.SetlEndDate = dateStr
  4622. //} else {
  4623. // t := time.Unix(int64(order.SettleStartTime), 0)
  4624. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4625. // dateStartStr := t.Format("2006-01-02")
  4626. // dateEndStr := t2.Format("2006-01-02")
  4627. // struct4101.SetlBegnDate = dateStartStr
  4628. // struct4101.SetlEndDate = dateEndStr
  4629. //}
  4630. var rf []CustomFundPay
  4631. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4632. var tempFunPays []service.CustomStruct
  4633. var tempFunPay610100 service.CustomStruct
  4634. for _, item := range rf {
  4635. if item.FundPayType == "610100" {
  4636. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4637. tempFunPay610100.FundPayType = item.FundPayType
  4638. } else {
  4639. var tempFunPay service.CustomStruct
  4640. tempFunPay.FundPayamt = item.FundPayamt
  4641. tempFunPay.FundPayType = item.FundPayType
  4642. tempFunPays = append(tempFunPays, tempFunPay)
  4643. }
  4644. }
  4645. tempFunPays = append(tempFunPays, tempFunPay610100)
  4646. struct4101.CustomStruct = tempFunPays
  4647. var tempDiaginfos []service.DiaginfoStructTwo
  4648. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4649. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4650. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4651. var config []*models.HisXtDiagnoseConfig
  4652. for _, item := range diagnosis_ids {
  4653. id, _ := strconv.ParseInt(item, 10, 64)
  4654. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4655. config = append(config, &diagnosisConfig)
  4656. }
  4657. for index, item := range config {
  4658. if index == 0 {
  4659. var tempDiaginfo service.DiaginfoStructTwo
  4660. tempDiaginfo.DiagCode = item.CountryCode
  4661. tempDiaginfo.DiagName = item.CountryContentName
  4662. tempDiaginfo.DiagType = "1"
  4663. tempDiaginfo.MaindiagFlag = "1"
  4664. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4665. } else {
  4666. var tempDiaginfo service.DiaginfoStructTwo
  4667. tempDiaginfo.DiagCode = item.CountryCode
  4668. tempDiaginfo.DiagName = item.CountryContentName
  4669. tempDiaginfo.DiagType = "2"
  4670. tempDiaginfo.MaindiagFlag = "0"
  4671. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4672. }
  4673. }
  4674. struct4101.Diseinfo = tempDiaginfos
  4675. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4676. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4677. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4678. tempOpspdiseinfo2.OprnOprtCode = ""
  4679. tempOpspdiseinfo2.OprnOprtName = ""
  4680. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4681. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4682. var iteminfo service.IteminfoStruct
  4683. var bedCostTotal float64 = 0 //床位总费
  4684. var bedCostSelfTotal float64 = 0 //床位自费
  4685. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4686. var examineCostTotal float64 = 0 //诊查总费
  4687. var examineCostSelfTotal float64 = 0 //诊查自费
  4688. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4689. var nursingCostTotal float64 = 0 //护理总费
  4690. var nursingCostSelfTotal float64 = 0 //护理自费
  4691. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4692. var chineseMedicineCostTotal float64 = 0 //中成药
  4693. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4694. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4695. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4696. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4697. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4698. var registerCostTotal float64 = 0 //一般诊疗费
  4699. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4700. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4701. var operationCostTotal float64 = 0 //手术费
  4702. var operationCostSelfTotal float64 = 0 //手术费
  4703. var operationCostPartSelfTotal float64 = 0 //手术费
  4704. var otherCostTotal float64 = 0 //其他费用
  4705. var otherCostSelfTotal float64 = 0 //其他费用
  4706. var otherCostPartSelfTotal float64 = 0 //其他费用
  4707. var materialCostTotal float64 = 0 //材料费
  4708. var materialCostSelfTotal float64 = 0 //材料费
  4709. var materialCostPartSelfTotal float64 = 0 //材料费
  4710. var westernMedicineCostTotal float64 = 0 //西药费
  4711. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4712. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4713. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4714. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4715. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4716. var checkCostTotal float64 = 0 //检查费
  4717. var checkCostSelfTotal float64 = 0 //检查费
  4718. var checkCostPartSelfTotal float64 = 0 //检查费
  4719. var laboratoryCostTotal float64 = 0 //化验费
  4720. var laboratoryCostSelfTotal float64 = 0 //化验费
  4721. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4722. var treatCostTotal float64 = 0 //治疗费用
  4723. var treatCostSelfTotal float64 = 0 //治疗费用
  4724. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4725. decimal.DivisionPrecision = 2
  4726. var bed_fulamt_ownpay_amt float64 = 0
  4727. var examine_fulamt_ownpay_amt float64 = 0
  4728. var nursing_fulamt_ownpay_amt float64 = 0
  4729. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4730. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4731. var register_fulamt_ownpay_amt float64 = 0
  4732. var operation_fulamt_ownpay_amt float64 = 0
  4733. var other_fulamt_ownpay_amt float64 = 0
  4734. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4735. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4736. var check_fulamt_ownpay_amt float64 = 0
  4737. var material_fulamt_ownpay_amt float64 = 0
  4738. var laboratory_fulamt_ownpay_amt float64 = 0
  4739. var treat_fulamt_ownpay_amt float64 = 0
  4740. var bed_claa_sunmfee float64 = 0
  4741. var bed_clab_amt float64 = 0
  4742. var bed_other_amt float64 = 0
  4743. var examine_claa_sunmfee float64 = 0
  4744. var examine_clab_amt float64 = 0
  4745. var examine_other_amt float64 = 0
  4746. var nursing_claa_sunmfee float64 = 0
  4747. var nursing_clab_amt float64 = 0
  4748. var nursing_other_amt float64 = 0
  4749. var chinese_medicine_claa_sunmfee float64 = 0
  4750. var chinese_medicine_clab_amt float64 = 0
  4751. var chinese_medicine_other_amt float64 = 0
  4752. var commonly_treatment_claa_sunmfee float64 = 0
  4753. var commonly_treatment_clab_amt float64 = 0
  4754. var commonly_treatment_other_amt float64 = 0
  4755. var operation_claa_sunmfee float64 = 0
  4756. var operation_clab_amt float64 = 0
  4757. var operation_other_amt float64 = 0
  4758. var other_claa_sunmfee float64 = 0
  4759. var other_clab_amt float64 = 0
  4760. var other_other_amt float64 = 0
  4761. var westernMedicine_claa_sunmfee float64 = 0
  4762. var westernMedicine_clab_amt float64 = 0
  4763. var westernMedicine_other_amt float64 = 0
  4764. var chineseTraditional_claa_sunmfee float64 = 0
  4765. var chineseTraditional_clab_amt float64 = 0
  4766. var chineseTraditional_other_amt float64 = 0
  4767. var check_claa_sunmfee float64 = 0
  4768. var check_clab_amt float64 = 0
  4769. var check_other_amt float64 = 0
  4770. var material_claa_sunmfee float64 = 0
  4771. var material_clab_amt float64 = 0
  4772. var material_other_amt float64 = 0
  4773. var laboratory_claa_sunmfee float64 = 0
  4774. var laboratory_clab_amt float64 = 0
  4775. var laboratory_other_amt float64 = 0
  4776. var treat_claa_sunmfee float64 = 0
  4777. var treat_clab_amt float64 = 0
  4778. var treat_other_amt float64 = 0
  4779. var register_claa_sunmfee float64 = 0
  4780. var register_clab_amt float64 = 0
  4781. var register_other_amt float64 = 0
  4782. for _, item := range order.HisOrderInfo {
  4783. if item.MedChrgitmType == "01" { //床位费
  4784. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4785. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4786. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4787. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4788. if item.ChrgitmLv == "1" {
  4789. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4790. }
  4791. if item.ChrgitmLv == "2" {
  4792. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4793. }
  4794. if item.ChrgitmLv == "3" {
  4795. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4796. }
  4797. }
  4798. if item.MedChrgitmType == "02" { //诊查
  4799. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4800. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4801. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4802. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4803. if item.ChrgitmLv == "1" {
  4804. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4805. }
  4806. if item.ChrgitmLv == "2" {
  4807. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4808. }
  4809. if item.ChrgitmLv == "3" {
  4810. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4811. }
  4812. }
  4813. if item.MedChrgitmType == "03" { //检查费
  4814. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4815. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4816. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4817. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4818. if item.ChrgitmLv == "1" {
  4819. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4820. }
  4821. if item.ChrgitmLv == "2" {
  4822. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4823. }
  4824. if item.ChrgitmLv == "3" {
  4825. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4826. }
  4827. }
  4828. if item.MedChrgitmType == "04" { //化验费
  4829. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4830. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4831. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4832. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4833. if item.ChrgitmLv == "1" {
  4834. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4835. }
  4836. if item.ChrgitmLv == "2" {
  4837. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4838. }
  4839. if item.ChrgitmLv == "3" {
  4840. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4841. }
  4842. }
  4843. if item.MedChrgitmType == "05" { //治疗费
  4844. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4845. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4846. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4847. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4848. if item.ChrgitmLv == "1" {
  4849. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4850. }
  4851. if item.ChrgitmLv == "2" {
  4852. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4853. }
  4854. if item.ChrgitmLv == "3" {
  4855. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4856. }
  4857. }
  4858. if item.MedChrgitmType == "06" { //手术费
  4859. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4860. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4861. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4862. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4863. if item.ChrgitmLv == "1" {
  4864. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4865. }
  4866. if item.ChrgitmLv == "2" {
  4867. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4868. }
  4869. if item.ChrgitmLv == "3" {
  4870. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4871. }
  4872. }
  4873. if item.MedChrgitmType == "07" { //手术费
  4874. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4875. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4876. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4877. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4878. if item.ChrgitmLv == "1" {
  4879. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4880. }
  4881. if item.ChrgitmLv == "2" {
  4882. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4883. }
  4884. if item.ChrgitmLv == "3" {
  4885. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4886. }
  4887. }
  4888. if item.MedChrgitmType == "08" { //材料费
  4889. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4890. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4891. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4892. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4893. if item.ChrgitmLv == "1" {
  4894. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4895. }
  4896. if item.ChrgitmLv == "2" {
  4897. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4898. }
  4899. if item.ChrgitmLv == "3" {
  4900. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4901. }
  4902. }
  4903. if item.MedChrgitmType == "09" { //西药费
  4904. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4905. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4906. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4907. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4908. if item.ChrgitmLv == "1" {
  4909. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4910. }
  4911. if item.ChrgitmLv == "2" {
  4912. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4913. }
  4914. if item.ChrgitmLv == "3" {
  4915. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4916. }
  4917. }
  4918. if item.MedChrgitmType == "10" { //中药饮片
  4919. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4920. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4921. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4922. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4923. if item.ChrgitmLv == "1" {
  4924. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4925. }
  4926. if item.ChrgitmLv == "2" {
  4927. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4928. }
  4929. if item.ChrgitmLv == "3" {
  4930. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4931. }
  4932. }
  4933. if item.MedChrgitmType == "11" { //中成费
  4934. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4935. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4936. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4937. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4938. if item.ChrgitmLv == "1" {
  4939. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4940. }
  4941. if item.ChrgitmLv == "2" {
  4942. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4943. }
  4944. if item.ChrgitmLv == "3" {
  4945. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4946. }
  4947. }
  4948. if item.MedChrgitmType == "12" { //中成费
  4949. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4950. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4951. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4952. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4953. if item.ChrgitmLv == "1" {
  4954. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4955. }
  4956. if item.ChrgitmLv == "2" {
  4957. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4958. }
  4959. if item.ChrgitmLv == "3" {
  4960. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4961. }
  4962. }
  4963. if item.MedChrgitmType == "13" { //中成费
  4964. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4965. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4966. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4967. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4968. if item.ChrgitmLv == "1" {
  4969. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4970. }
  4971. if item.ChrgitmLv == "2" {
  4972. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4973. }
  4974. if item.ChrgitmLv == "3" {
  4975. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4976. }
  4977. }
  4978. if item.MedChrgitmType == "14" { //其他费
  4979. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4980. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4981. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4982. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4983. if item.ChrgitmLv == "1" {
  4984. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4985. }
  4986. if item.ChrgitmLv == "2" {
  4987. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4988. }
  4989. if item.ChrgitmLv == "3" {
  4990. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4991. }
  4992. }
  4993. }
  4994. var iteminfoStructs []service.IteminfoStruct
  4995. if bedCostTotal != 0 {
  4996. iteminfo.MedChrgitm = "01"
  4997. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4998. iteminfo.Amt = bedCostTotal
  4999. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5000. iteminfo.ClabAmt = bed_clab_amt
  5001. iteminfo.OthAmt = bed_other_amt
  5002. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5003. }
  5004. if examineCostTotal != 0 {
  5005. iteminfo.MedChrgitm = "02"
  5006. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5007. iteminfo.Amt = examineCostTotal
  5008. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5009. iteminfo.ClabAmt = examine_clab_amt
  5010. iteminfo.OthAmt = examine_other_amt
  5011. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5012. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5013. }
  5014. if checkCostTotal != 0 {
  5015. iteminfo.MedChrgitm = "03"
  5016. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5017. iteminfo.Amt = checkCostTotal
  5018. iteminfo.ClaaSumfee = check_claa_sunmfee
  5019. iteminfo.ClabAmt = check_clab_amt
  5020. iteminfo.OthAmt = check_other_amt
  5021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5022. }
  5023. if laboratoryCostTotal != 0 {
  5024. iteminfo.MedChrgitm = "04"
  5025. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5026. iteminfo.Amt = laboratoryCostTotal
  5027. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5028. iteminfo.ClabAmt = laboratory_clab_amt
  5029. iteminfo.OthAmt = laboratory_other_amt
  5030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5031. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5032. }
  5033. if treatCostTotal != 0 {
  5034. iteminfo.MedChrgitm = "05"
  5035. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5036. iteminfo.Amt = treatCostTotal
  5037. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5038. iteminfo.ClabAmt = treat_clab_amt
  5039. iteminfo.OthAmt = treat_other_amt
  5040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5041. //(struct4101.IteminfoStruct, iteminfo)
  5042. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5043. }
  5044. if operationCostTotal != 0 {
  5045. iteminfo.MedChrgitm = "06"
  5046. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5047. iteminfo.Amt = operationCostTotal
  5048. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5049. iteminfo.ClabAmt = operation_clab_amt
  5050. iteminfo.OthAmt = operation_other_amt
  5051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5052. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5053. }
  5054. if nursingCostTotal != 0 {
  5055. iteminfo.MedChrgitm = "07"
  5056. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5057. iteminfo.Amt = nursingCostTotal
  5058. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5059. iteminfo.ClabAmt = nursing_clab_amt
  5060. iteminfo.OthAmt = nursing_other_amt
  5061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5062. }
  5063. if materialCostTotal != 0 {
  5064. iteminfo.MedChrgitm = "08"
  5065. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5066. iteminfo.Amt = materialCostTotal
  5067. iteminfo.ClaaSumfee = material_claa_sunmfee
  5068. iteminfo.ClabAmt = material_clab_amt
  5069. iteminfo.OthAmt = material_other_amt
  5070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5072. }
  5073. if westernMedicineCostTotal != 0 {
  5074. iteminfo.MedChrgitm = "09"
  5075. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5076. iteminfo.Amt = westernMedicineCostTotal
  5077. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5078. iteminfo.ClabAmt = westernMedicine_clab_amt
  5079. iteminfo.OthAmt = westernMedicine_other_amt
  5080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5082. }
  5083. if chineseMedicineCostTotal != 0 {
  5084. iteminfo.MedChrgitm = "10"
  5085. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5086. iteminfo.Amt = chineseMedicineCostTotal
  5087. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5088. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5089. iteminfo.OthAmt = chinese_medicine_other_amt
  5090. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5092. }
  5093. if chineseTraditionalMedicineCostTotal != 0 {
  5094. iteminfo.MedChrgitm = "11"
  5095. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5096. iteminfo.Amt = westernMedicineCostTotal
  5097. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5098. iteminfo.ClabAmt = westernMedicine_clab_amt
  5099. iteminfo.OthAmt = westernMedicine_other_amt
  5100. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5102. }
  5103. if commonlyTreatmentCostTotal != 0 {
  5104. iteminfo.MedChrgitm = "12"
  5105. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5106. iteminfo.Amt = commonlyTreatmentCostTotal
  5107. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5108. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5109. iteminfo.OthAmt = commonly_treatment_other_amt
  5110. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5111. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5112. }
  5113. if registerCostTotal != 0 {
  5114. iteminfo.MedChrgitm = "13"
  5115. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5116. iteminfo.Amt = registerCostTotal
  5117. iteminfo.ClaaSumfee = register_claa_sunmfee
  5118. iteminfo.ClabAmt = register_clab_amt
  5119. iteminfo.OthAmt = register_other_amt
  5120. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5121. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5122. }
  5123. if otherCostTotal != 0 {
  5124. iteminfo.MedChrgitm = "14"
  5125. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5126. iteminfo.Amt = otherCostTotal
  5127. iteminfo.ClaaSumfee = other_claa_sunmfee
  5128. iteminfo.ClabAmt = other_clab_amt
  5129. iteminfo.OthAmt = other_other_amt
  5130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5132. }
  5133. struct4101.IteminfoStruct = iteminfoStructs
  5134. time_arr := strings.Split(order.SetlTime, " ")
  5135. struct4101.AdmTime = time_arr[0]
  5136. struct4101.AdmEndTime = time_arr[0]
  5137. struct4101.DoctorName = doctor.UserName
  5138. struct4101.DoctorCode = doctor.DoctorNumber
  5139. struct4101.Ntly = "中国"
  5140. struct4101.AdmCaty = "A03.06"
  5141. var res ResultSeventeen
  5142. if miConfig.MdtrtareaAdmvs == "421300" {
  5143. data := make(map[string]interface{})
  5144. data["struct4101"] = struct4101
  5145. data["secret_key"] = miConfig.SecretKey
  5146. data["org_name"] = miConfig.OrgName
  5147. data["opera"] = curRoles.UserName
  5148. data["code"] = miConfig.Code
  5149. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5150. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5151. client := &http.Client{}
  5152. bytesData, _ := json.Marshal(data)
  5153. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5154. resp, _ := client.Do(req)
  5155. defer resp.Body.Close()
  5156. body, ioErr := ioutil.ReadAll(resp.Body)
  5157. if ioErr != nil {
  5158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5160. return
  5161. }
  5162. var respJSON map[string]interface{}
  5163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5169. userJSONBytes, _ := json.Marshal(respJSON)
  5170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5171. utils.ErrorLog("解析失败:%v", err)
  5172. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5173. adminUser := c.GetAdminUserInfo()
  5174. errlog := &models.HisOrderError{
  5175. UserOrgId: adminUser.CurrentOrgId,
  5176. Ctime: time.Now().Unix(),
  5177. Mtime: time.Now().Unix(),
  5178. ErrMsg: res.ErrMsg + "解析失败",
  5179. Status: 1,
  5180. PatientId: order_id,
  5181. Stage: 10088,
  5182. }
  5183. service.CreateErrMsgLog(errlog)
  5184. continue
  5185. }
  5186. } else {
  5187. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5188. fmt.Println(result)
  5189. var dat map[string]interface{}
  5190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5191. fmt.Println(dat)
  5192. } else {
  5193. fmt.Println(err)
  5194. }
  5195. userJSONBytes, _ := json.Marshal(dat)
  5196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5197. utils.ErrorLog("解析失败:%v", err)
  5198. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5199. adminUser := c.GetAdminUserInfo()
  5200. errlog := &models.HisOrderError{
  5201. UserOrgId: adminUser.CurrentOrgId,
  5202. Ctime: time.Now().Unix(),
  5203. Mtime: time.Now().Unix(),
  5204. ErrMsg: res.ErrMsg + "解析失败",
  5205. Status: 1,
  5206. PatientId: order_id,
  5207. Stage: 10106,
  5208. }
  5209. service.CreateErrMsgLog(errlog)
  5210. continue
  5211. }
  5212. }
  5213. if res.Infcode != 0 {
  5214. adminUser := c.GetAdminUserInfo()
  5215. errlog := &models.HisOrderError{
  5216. UserOrgId: adminUser.CurrentOrgId,
  5217. Ctime: time.Now().Unix(),
  5218. Mtime: time.Now().Unix(),
  5219. ErrMsg: res.ErrMsg,
  5220. Status: 1,
  5221. PatientId: order_id,
  5222. Stage: 10106,
  5223. }
  5224. service.CreateErrMsgLog(errlog)
  5225. continue
  5226. } else {
  5227. hisFundSettleListResult := &models.HisFundSettleListResult{
  5228. Number: res.Output.SetlListId,
  5229. Status: 1,
  5230. Ctime: time.Now().Unix(),
  5231. Mtime: time.Now().Unix(),
  5232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5233. IsUpload: 1,
  5234. OrderId: order_id,
  5235. }
  5236. service.CreateUploadRecord(hisFundSettleListResult)
  5237. continue
  5238. }
  5239. }
  5240. }
  5241. func (c *HisApiController) GetOrgInfo() {
  5242. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5243. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5244. }
  5245. func (c *HisApiController) GetHisPatientInfo() {
  5246. medical_insurance_card := c.GetString("medical_insurance_card")
  5247. id_card_type, _ := c.GetInt64("id_card_type")
  5248. id_card := c.GetString("id_card")
  5249. adminInfo := c.GetAdminUserInfo()
  5250. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5251. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5252. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5253. IdCardNo := ""
  5254. if id_card_type == 1 {
  5255. IdCardNo = medical_insurance_card
  5256. } else if id_card_type == 2 {
  5257. IdCardNo = id_card
  5258. }
  5259. if config.IsOpen == 1 {
  5260. 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
  5261. resp, requestErr := http.Get(api)
  5262. if requestErr != nil {
  5263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5264. return
  5265. }
  5266. defer resp.Body.Close()
  5267. body, ioErr := ioutil.ReadAll(resp.Body)
  5268. if ioErr != nil {
  5269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5271. return
  5272. }
  5273. var respJSON map[string]interface{}
  5274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. return
  5278. }
  5279. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5280. userJSONBytes, _ := json.Marshal(userJSON)
  5281. var res ResultTwo
  5282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5283. utils.ErrorLog("解析失败:%v", err)
  5284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5285. return
  5286. }
  5287. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5288. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5289. infoStr := string(Iinfos)
  5290. idetinfoStr := string(Idetinfos)
  5291. if res.Infcode == 0 {
  5292. his := models.VMHisPatient{
  5293. Status: 1,
  5294. Ctime: time.Now().Unix(),
  5295. Mtime: time.Now().Unix(),
  5296. PsnNo: res.Output.Baseinfo.PsnNo,
  5297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5298. Certno: res.Output.Baseinfo.Certno,
  5299. PsnName: res.Output.Baseinfo.PsnName,
  5300. Gend: res.Output.Baseinfo.Gend,
  5301. Naty: res.Output.Baseinfo.Naty,
  5302. Brdy: res.Output.Baseinfo.Brdy,
  5303. Age: res.Output.Baseinfo.Age,
  5304. Iinfo: infoStr,
  5305. Idetinfo: idetinfoStr,
  5306. UserOrgId: adminInfo.CurrentOrgId,
  5307. IsReturn: 1,
  5308. IdCardType: id_card_type,
  5309. }
  5310. c.ServeSuccessJSON(map[string]interface{}{
  5311. "info": his,
  5312. })
  5313. } else {
  5314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5315. return
  5316. }
  5317. }
  5318. }
  5319. //func GetBasBaseInfo() (jsonStr string, err error) {
  5320. //
  5321. // handle := syscall.NewLazyDLL("SSCard.dll")
  5322. // add := handle.NewProc("ReadCardBas")
  5323. // str := make([]byte, 1024)
  5324. // str1 := make([]byte, 1024)
  5325. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5326. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5327. //
  5328. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5329. //
  5330. // fmt.Println("> Add(4,5)的结果为:", ret)
  5331. // handle.Release()
  5332. //
  5333. // return "", nil
  5334. //
  5335. //}
  5336. //func GetQRBaseInfo() (jsonStr string, err error) {
  5337. // handle := syscall.LoadDLL("SSCard.dll")
  5338. // ReadCardBas := handle.FindProc("GetQRBase")
  5339. //
  5340. // str := make([]byte, 256)
  5341. // str1 := make([]byte, 256)
  5342. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5343. //
  5344. // fmt.Println(string(str))
  5345. // fmt.Println(r)
  5346. // return string(str), nil
  5347. //}
  5348. //func CardInit() int {
  5349. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5350. // add := DllTestDef.MustFindProc("Init")
  5351. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5352. // if err != nil {
  5353. // fmt.Println("SSCard的运算结果为:", ret)
  5354. // }
  5355. // result := int(ret)
  5356. // return result
  5357. //}
  5358. //func CardInit() int {
  5359. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5360. // if err != nil {
  5361. // fmt.Println("SSCard的运算结果为:", ret)
  5362. // }
  5363. // fmt.Println(err)
  5364. // result := int(ret)
  5365. // return result
  5366. //}
  5367. func IntPtr(n int) uintptr {
  5368. return uintptr(n)
  5369. }
  5370. func StrPtr(s string) uintptr {
  5371. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5372. }
  5373. type Result2001 struct {
  5374. Cainfo interface{} `json:"cainfo"`
  5375. ErrMsg string `json:"err_msg"`
  5376. InfRefmsgid string `json:"inf_refmsgid"`
  5377. Infcode int64 `json:"infcode"`
  5378. Output struct {
  5379. Trtinfo struct {
  5380. PsnNo string `json:"psn_no"`
  5381. TrtChkType string `json:"trt_chk_type"`
  5382. FundPayType string `json:"fund_pay_type"`
  5383. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5384. Begndate string `json:"begndate"`
  5385. Enddate string `json:"enddate"`
  5386. TrtChkRslt string `json:"trt_chk_rslt"`
  5387. } `json:"trtinfo"`
  5388. } `json:"output"`
  5389. RefmsgTime string `json:"refmsg_time"`
  5390. RespondTime string `json:"respond_time"`
  5391. Signtype interface{} `json:"signtype"`
  5392. WarnMsg interface{} `json:"warn_msg"`
  5393. }
  5394. type Result2001Org10265 struct {
  5395. Cainfo interface{} `json:"cainfo"`
  5396. ErrMsg string `json:"err_msg"`
  5397. InfRefmsgid string `json:"inf_refmsgid"`
  5398. Infcode string `json:"infcode"`
  5399. Output struct {
  5400. Trtinfo struct {
  5401. PsnNo string `json:"psn_no"`
  5402. TrtChkType string `json:"trt_chk_type"`
  5403. FundPayType string `json:"fund_pay_type"`
  5404. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5405. Begndate string `json:"begndate"`
  5406. Enddate string `json:"enddate"`
  5407. TrtChkRslt string `json:"trt_chk_rslt"`
  5408. } `json:"trtinfo"`
  5409. } `json:"output"`
  5410. RefmsgTime string `json:"refmsg_time"`
  5411. RespondTime string `json:"respond_time"`
  5412. Signtype interface{} `json:"signtype"`
  5413. WarnMsg interface{} `json:"warn_msg"`
  5414. }
  5415. type ResultTwo struct {
  5416. ErrMsg string `json:"err_msg"`
  5417. InfRefmsgid string `json:"inf_refmsgid"`
  5418. Infcode int64 `json:"infcode"`
  5419. Output struct {
  5420. Baseinfo struct {
  5421. Age float64 `json:"age"`
  5422. Brdy string `json:"brdy"`
  5423. Certno string `json:"certno"`
  5424. Gend string `json:"gend"`
  5425. Naty string `json:"naty"`
  5426. PsnCertType string `json:"psn_cert_type"`
  5427. PsnName string `json:"psn_name"`
  5428. PsnNo string `json:"psn_no"`
  5429. } `json:"baseinfo"`
  5430. Idetinfo []interface{} `json:"idetinfo"`
  5431. Iinfo []struct {
  5432. Balc float64 `json:"balc"`
  5433. CvlservFlag string `json:"cvlserv_flag"`
  5434. EmpName string `json:"emp_name"`
  5435. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5436. Insutype string `json:"insutype"`
  5437. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5438. PausInsuDate string `json:"paus_insu_date"`
  5439. PsnInsuDate string `json:"psn_insu_date"`
  5440. PsnInsuStas string `json:"psn_insu_stas"`
  5441. PsnType string `json:"psn_type"`
  5442. } `json:"insuinfo"`
  5443. } `json:"output"`
  5444. RefmsgTime string `json:"refmsg_time"`
  5445. RespondTime string `json:"respond_time"`
  5446. Signtype interface{} `json:"signtype"`
  5447. WarnInfo interface{} `json:"warn_info"`
  5448. }
  5449. type ResultTwo10265 struct {
  5450. ErrMsg string `json:"err_msg"`
  5451. InfRefmsgid string `json:"inf_refmsgid"`
  5452. Infcode string `json:"infcode"`
  5453. Output struct {
  5454. Baseinfo struct {
  5455. Age float64 `json:"age"`
  5456. Brdy string `json:"brdy"`
  5457. Certno string `json:"certno"`
  5458. Gend string `json:"gend"`
  5459. Naty string `json:"naty"`
  5460. PsnCertType string `json:"psn_cert_type"`
  5461. PsnName string `json:"psn_name"`
  5462. PsnNo string `json:"psn_no"`
  5463. } `json:"baseinfo"`
  5464. Idetinfo []interface{} `json:"idetinfo"`
  5465. Iinfo []struct {
  5466. Balc float64 `json:"balc"`
  5467. CvlservFlag string `json:"cvlserv_flag"`
  5468. EmpName string `json:"emp_name"`
  5469. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5470. Insutype string `json:"insutype"`
  5471. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5472. PausInsuDate string `json:"paus_insu_date"`
  5473. PsnInsuDate string `json:"psn_insu_date"`
  5474. PsnInsuStas string `json:"psn_insu_stas"`
  5475. PsnType string `json:"psn_type"`
  5476. } `json:"insuinfo"`
  5477. } `json:"output"`
  5478. RefmsgTime string `json:"refmsg_time"`
  5479. RespondTime string `json:"respond_time"`
  5480. Signtype interface{} `json:"signtype"`
  5481. WarnInfo interface{} `json:"warn_info"`
  5482. }
  5483. type ResultThree struct {
  5484. Cainfo interface{} `json:"cainfo"`
  5485. ErrMsg string `json:"err_msg"`
  5486. InfRefmsgid string `json:"inf_refmsgid"`
  5487. Infcode int64 `json:"infcode"`
  5488. Output struct {
  5489. Data struct {
  5490. IptOtpNo string `json:"ipt_otp_no"`
  5491. MdtrtID string `json:"mdtrt_id"`
  5492. PsnNo string `json:"psn_no"`
  5493. } `json:"data"`
  5494. } `json:"output"`
  5495. RefmsgTime string `json:"refmsg_time"`
  5496. RespondTime string `json:"respond_time"`
  5497. Signtype interface{} `json:"signtype"`
  5498. WarnMsg interface{} `json:"warn_msg"`
  5499. }
  5500. type ResultThree10265 struct {
  5501. Cainfo interface{} `json:"cainfo"`
  5502. ErrMsg string `json:"err_msg"`
  5503. InfRefmsgid string `json:"inf_refmsgid"`
  5504. Infcode string `json:"infcode"`
  5505. Output struct {
  5506. Data struct {
  5507. IptOtpNo string `json:"ipt_otp_no"`
  5508. MdtrtID string `json:"mdtrt_id"`
  5509. PsnNo string `json:"psn_no"`
  5510. } `json:"data"`
  5511. } `json:"output"`
  5512. RefmsgTime string `json:"refmsg_time"`
  5513. RespondTime string `json:"respond_time"`
  5514. Signtype interface{} `json:"signtype"`
  5515. WarnMsg interface{} `json:"warn_msg"`
  5516. }
  5517. type ResultFour struct {
  5518. Cainfo string `json:"cainfo"`
  5519. ErrMsg string `json:"err_msg"`
  5520. InfRefmsgid string `json:"inf_refmsgid"`
  5521. Infcode int64 `json:"infcode"`
  5522. Output struct {
  5523. Result []struct {
  5524. BasMednFlag string `json:"bas_medn_flag"`
  5525. ChldMedcFlag string `json:"chld_medc_flag"`
  5526. ChrgitmLv string `json:"chrgitm_lv"`
  5527. Cnt float64 `json:"cnt"`
  5528. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5529. DrtReimFlag string `json:"drt_reim_flag"`
  5530. FeedetlSn string `json:"feedetl_sn"`
  5531. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5532. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5533. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5534. ListSpItemFlag string `json:"list_sp_item_flag"`
  5535. LmtUsedFlag string `json:"lmt_used_flag"`
  5536. MedChrgitmType string `json:"med_chrgitm_type"`
  5537. Memo string `json:"memo"`
  5538. OverlmtAmt float64 `json:"overlmt_amt"`
  5539. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5540. Pric float64 `json:"pric"`
  5541. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5542. SelfpayProp float64 `json:"selfpay_prop"`
  5543. } `json:"result"`
  5544. } `json:"output"`
  5545. RefmsgTime string `json:"refmsg_time"`
  5546. RespondTime string `json:"respond_time"`
  5547. Signtype string `json:"signtype"`
  5548. WarnMsg string `json:"warn_msg"`
  5549. }
  5550. type ResultFour10265 struct {
  5551. Cainfo string `json:"cainfo"`
  5552. ErrMsg string `json:"err_msg"`
  5553. InfRefmsgid string `json:"inf_refmsgid"`
  5554. Infcode string `json:"infcode"`
  5555. Output struct {
  5556. Result []struct {
  5557. BasMednFlag string `json:"bas_medn_flag"`
  5558. ChldMedcFlag string `json:"chld_medc_flag"`
  5559. ChrgitmLv string `json:"chrgitm_lv"`
  5560. Cnt float64 `json:"cnt"`
  5561. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5562. DrtReimFlag string `json:"drt_reim_flag"`
  5563. FeedetlSn string `json:"feedetl_sn"`
  5564. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5565. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5566. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5567. ListSpItemFlag string `json:"list_sp_item_flag"`
  5568. LmtUsedFlag string `json:"lmt_used_flag"`
  5569. MedChrgitmType string `json:"med_chrgitm_type"`
  5570. Memo string `json:"memo"`
  5571. OverlmtAmt float64 `json:"overlmt_amt"`
  5572. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5573. Pric float64 `json:"pric"`
  5574. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5575. SelfpayProp float64 `json:"selfpay_prop"`
  5576. } `json:"result"`
  5577. } `json:"output"`
  5578. RefmsgTime string `json:"refmsg_time"`
  5579. RespondTime string `json:"respond_time"`
  5580. Signtype string `json:"signtype"`
  5581. WarnMsg string `json:"warn_msg"`
  5582. }
  5583. type ResultMemo struct {
  5584. InsuAdmdvs string `json:"insuAdmdvs"`
  5585. }
  5586. //[{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  5587. type ResultIDInfo struct {
  5588. Begntime string `json:"begntime"`
  5589. Endtime string `json:"endtime"`
  5590. Memo ResultMemo `json:"memo"`
  5591. }
  5592. type ResultFive struct {
  5593. Balc float64 `json:"balc"`
  5594. CvlservFlag string `json:"cvlserv_flag"`
  5595. EmpName string `json:"emp_name"`
  5596. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5597. Insutype string `json:"insutype"`
  5598. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5599. PausInsuDate string `json:"paus_insu_date"`
  5600. PsnInsuDate string `json:"psn_insu_date"`
  5601. PsnInsuStas string `json:"psn_insu_stas"`
  5602. PsnType string `json:"psn_type"`
  5603. }
  5604. type ResultSix struct {
  5605. Cainfo interface{} `json:"cainfo"`
  5606. ErrMsg string `json:"err_msg"`
  5607. InfRefmsgid string `json:"inf_refmsgid"`
  5608. Infcode int64 `json:"infcode"`
  5609. Output struct {
  5610. } `json:"output"`
  5611. RefmsgTime string `json:"refmsg_time"`
  5612. RespondTime string `json:"respond_time"`
  5613. Signtype interface{} `json:"signtype"`
  5614. WarnMsg interface{} `json:"warn_msg"`
  5615. }
  5616. type ResultSix10265 struct {
  5617. Cainfo interface{} `json:"cainfo"`
  5618. ErrMsg string `json:"err_msg"`
  5619. InfRefmsgid string `json:"inf_refmsgid"`
  5620. Infcode string `json:"infcode"`
  5621. Output struct {
  5622. } `json:"output"`
  5623. RefmsgTime string `json:"refmsg_time"`
  5624. RespondTime string `json:"respond_time"`
  5625. Signtype interface{} `json:"signtype"`
  5626. WarnMsg interface{} `json:"warn_msg"`
  5627. }
  5628. type ResultSeven struct {
  5629. Cainfo string `json:"cainfo"`
  5630. ErrMsg string `json:"err_msg"`
  5631. InfRefmsgid string `json:"inf_refmsgid"`
  5632. Infcode int64 `json:"infcode"`
  5633. Output struct {
  5634. Setldetail []interface{} `json:"setldetail"`
  5635. Setlinfo struct {
  5636. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5637. AcctPay float64 `json:"acct_pay"`
  5638. ActPayDedc float64 `json:"act_pay_dedc"`
  5639. Age float64 `json:"age"`
  5640. Balc float64 `json:"balc"`
  5641. Brdy string `json:"brdy"`
  5642. Certno string `json:"certno"`
  5643. ClrOptins string `json:"clr_optins"`
  5644. ClrType string `json:"clr_type"`
  5645. ClrWay string `json:"clr_way"`
  5646. CvlservFlag string `json:"cvlserv_flag"`
  5647. CvlservPay float64 `json:"cvlserv_pay"`
  5648. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5649. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5650. Gend string `json:"gend"`
  5651. HifesPay float64 `json:"hifes_pay"`
  5652. HifmiPay float64 `json:"hifmi_pay"`
  5653. HifpPay float64 `json:"hifp_pay"`
  5654. HospPartAmt float64 `json:"hosp_part_amt"`
  5655. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5656. Insutype string `json:"insutype"`
  5657. MafPay float64 `json:"maf_pay"`
  5658. MdtrtCertType string `json:"mdtrt_cert_type"`
  5659. HifobPay float64 `json:"hifob_pay"`
  5660. MdtrtID string `json:"mdtrt_id"`
  5661. MedType string `json:"med_type"`
  5662. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5663. MedinsSetlID string `json:"medins_setl_id"`
  5664. Naty string `json:"naty"`
  5665. OthPay float64 `json:"oth_pay"`
  5666. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5667. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5668. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5669. PsnCashPay float64 `json:"psn_cash_pay"`
  5670. PsnCertType string `json:"psn_cert_type"`
  5671. PsnName string `json:"psn_name"`
  5672. PsnNo string `json:"psn_no"`
  5673. PsnPartAmt float64 `json:"psn_part_amt"`
  5674. PsnType string `json:"psn_type"`
  5675. SetlID string `json:"setl_id"`
  5676. SetlTime string `json:"setl_time"`
  5677. } `json:"setlinfo"`
  5678. } `json:"output"`
  5679. RefmsgTime string `json:"refmsg_time"`
  5680. RespondTime string `json:"respond_time"`
  5681. Signtype interface{} `json:"signtype"`
  5682. WarnMsg interface{} `json:"warn_msg"`
  5683. }
  5684. type ResultSeven10265 struct {
  5685. Cainfo string `json:"cainfo"`
  5686. ErrMsg string `json:"err_msg"`
  5687. InfRefmsgid string `json:"inf_refmsgid"`
  5688. Infcode string `json:"infcode"`
  5689. Output struct {
  5690. Setldetail []interface{} `json:"setldetail"`
  5691. Setlinfo struct {
  5692. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5693. AcctPay float64 `json:"acct_pay"`
  5694. ActPayDedc float64 `json:"act_pay_dedc"`
  5695. Age float64 `json:"age"`
  5696. Balc float64 `json:"balc"`
  5697. Brdy string `json:"brdy"`
  5698. Certno string `json:"certno"`
  5699. ClrOptins string `json:"clr_optins"`
  5700. ClrType string `json:"clr_type"`
  5701. ClrWay string `json:"clr_way"`
  5702. CvlservFlag string `json:"cvlserv_flag"`
  5703. CvlservPay float64 `json:"cvlserv_pay"`
  5704. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5705. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5706. Gend string `json:"gend"`
  5707. HifesPay float64 `json:"hifes_pay"`
  5708. HifmiPay float64 `json:"hifmi_pay"`
  5709. HifpPay float64 `json:"hifp_pay"`
  5710. HospPartAmt float64 `json:"hosp_part_amt"`
  5711. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5712. Insutype string `json:"insutype"`
  5713. MafPay float64 `json:"maf_pay"`
  5714. MdtrtCertType string `json:"mdtrt_cert_type"`
  5715. HifobPay float64 `json:"hifob_pay"`
  5716. MdtrtID string `json:"mdtrt_id"`
  5717. MedType string `json:"med_type"`
  5718. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5719. MedinsSetlID string `json:"medins_setl_id"`
  5720. Naty string `json:"naty"`
  5721. OthPay float64 `json:"oth_pay"`
  5722. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5723. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5724. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5725. PsnCashPay float64 `json:"psn_cash_pay"`
  5726. PsnCertType string `json:"psn_cert_type"`
  5727. PsnName string `json:"psn_name"`
  5728. PsnNo string `json:"psn_no"`
  5729. PsnPartAmt float64 `json:"psn_part_amt"`
  5730. PsnType string `json:"psn_type"`
  5731. SetlID string `json:"setl_id"`
  5732. SetlTime string `json:"setl_time"`
  5733. } `json:"setlinfo"`
  5734. } `json:"output"`
  5735. RefmsgTime string `json:"refmsg_time"`
  5736. RespondTime string `json:"respond_time"`
  5737. Signtype interface{} `json:"signtype"`
  5738. WarnMsg interface{} `json:"warn_msg"`
  5739. }
  5740. type ResultEight struct {
  5741. Cainfo string `json:"cainfo"`
  5742. ErrMsg string `json:"err_msg"`
  5743. InfRefmsgid string `json:"inf_refmsgid"`
  5744. Infcode int64 `json:"infcode"`
  5745. Output struct {
  5746. Stmtinfo struct {
  5747. SetlOptins string `json:"setl_optins"`
  5748. StmtRslt string `json:"stmt_rslt"`
  5749. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5750. } `json:"stmtinfo"`
  5751. } `json:"output"`
  5752. RefmsgTime string `json:"refmsg_time"`
  5753. RespondTime string `json:"respond_time"`
  5754. Signtype interface{} `json:"signtype"`
  5755. WarnMsg interface{} `json:"warn_msg"`
  5756. }
  5757. type ResultEightFor10188 struct {
  5758. Cainfo string `json:"cainfo"`
  5759. ErrMsg string `json:"err_msg"`
  5760. InfRefmsgid string `json:"inf_refmsgid"`
  5761. Infcode string `json:"infcode"`
  5762. Output struct {
  5763. Stmtinfo struct {
  5764. SetlOptins string `json:"setl_optins"`
  5765. StmtRslt string `json:"stmt_rslt"`
  5766. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5767. } `json:"stmtinfo"`
  5768. } `json:"output"`
  5769. RefmsgTime string `json:"refmsg_time"`
  5770. RespondTime string `json:"respond_time"`
  5771. Signtype interface{} `json:"signtype"`
  5772. WarnMsg interface{} `json:"warn_msg"`
  5773. }
  5774. type ResultNine struct {
  5775. Cainfo string `json:"cainfo"`
  5776. ErrMsg string `json:"err_msg"`
  5777. InfRefmsgid string `json:"inf_refmsgid"`
  5778. Infcode int64 `json:"infcode"`
  5779. Output struct {
  5780. FileQuryNo string `json:"file_qury_no"`
  5781. } `json:"output"`
  5782. RefmsgTime string `json:"refmsg_time"`
  5783. RespondTime string `json:"respond_time"`
  5784. Signtype interface{} `json:"signtype"`
  5785. WarnMsg interface{} `json:"warn_msg"`
  5786. }
  5787. type ResultTen struct {
  5788. Cainfo string `json:"cainfo"`
  5789. ErrMsg string `json:"err_msg"`
  5790. InfRefmsgid string `json:"inf_refmsgid"`
  5791. Infcode int64 `json:"infcode"`
  5792. Output struct {
  5793. DldEndtime string `json:"dld_endtime"`
  5794. FileQuryNo string `json:"file_qury_no"`
  5795. Filename string `json:"filename"`
  5796. } `json:"output"`
  5797. RefmsgTime string `json:"refmsg_time"`
  5798. RespondTime string `json:"respond_time"`
  5799. Signtype interface{} `json:"signtype"`
  5800. WarnMsg interface{} `json:"warn_msg"`
  5801. }
  5802. //type Autogenerated struct {
  5803. // Output struct {
  5804. // Setlinfo struct {
  5805. // SetlTime string `json:"setl_time"`
  5806. // CvlservPay float64 `json:"cvlserv_pay"`
  5807. // Year string `json:"year"`
  5808. // MedType string `json:"med_type"`
  5809. // PsnPay float64 `json:"psn_pay"`
  5810. // OpterID string `json:"opter_id"`
  5811. // Begndate string `json:"begndate"`
  5812. // FlxempeFlag string `json:"flxempe_flag"`
  5813. // HifmiPay float64 `json:"hifmi_pay"`
  5814. // PsnNo string `json:"psn_no"`
  5815. // ActPayDedc float64 `json:"act_pay_dedc"`
  5816. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5817. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5818. // ClrWay string `json:"clr_way"`
  5819. // OthPay float64 `json:"oth_pay"`
  5820. // Gend string `json:"gend"`
  5821. // MdtrtID string `json:"mdtrt_id"`
  5822. // AcctPay float64 `json:"acct_pay"`
  5823. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5824. // Insutype string `json:"insutype"`
  5825. // Invono interface{} `json:"invono"`
  5826. // Enddate string `json:"enddate"`
  5827. // CashPayamt float64 `json:"cash_payamt"`
  5828. // PsnType string `json:"psn_type"`
  5829. // FixmedinsName string `json:"fixmedins_name"`
  5830. // HifpPay float64 `json:"hifp_pay"`
  5831. // NewFlag interface{} `json:"new_flag"`
  5832. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5833. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5834. // PayLoc string `json:"pay_loc"`
  5835. // ClrType string `json:"clr_type"`
  5836. // RefdSetlFlag string `json:"refd_setl_flag"`
  5837. // CvlservFlag string `json:"cvlserv_flag"`
  5838. // EmpName string `json:"emp_name"`
  5839. // Brdy string `json:"brdy"`
  5840. // Naty string `json:"naty"`
  5841. // Certno string `json:"certno"`
  5842. // DiseCode string `json:"dise_code"`
  5843. // FixmedinsCode string `json:"fixmedins_code"`
  5844. // DedcHospLv string `json:"dedc_hosp_lv"`
  5845. // OpterName string `json:"opter_name"`
  5846. // Balc float64 `json:"balc"`
  5847. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5848. // PsnCertType string `json:"psn_cert_type"`
  5849. // HifobPay float64 `json:"hifob_pay"`
  5850. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5851. // HifesPay float64 `json:"hifes_pay"`
  5852. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5853. // OptTime string `json:"opt_time"`
  5854. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5855. // SetlID string `json:"setl_id"`
  5856. // MafPay float64 `json:"maf_pay"`
  5857. // PsnName string `json:"psn_name"`
  5858. // InsuOptins interface{} `json:"insu_optins"`
  5859. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5860. // ClrOptins string `json:"clr_optins"`
  5861. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5862. // DiseName string `json:"dise_name"`
  5863. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5864. // Age float64 `json:"age"`
  5865. // DtrtCertType string `json:"dtrt_cert_type"`
  5866. // HospLv string `json:"hosp_lv"`
  5867. // } `json:"setlinfo"`
  5868. // Setldetail []struct {
  5869. // FundPayType string `json:"fund_pay_type"`
  5870. // FundPayamt float64 `json:"fund_payamt"`
  5871. // SetlProcInfo interface{} `json:"setl_proc_info"`
  5872. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  5873. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  5874. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  5875. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5876. // } `json:"setldetail"`
  5877. // } `json:"output"`
  5878. // Infcode int `json:"infcode"`
  5879. // WarnMsg interface{} `json:"warn_msg"`
  5880. // Cainfo interface{} `json:"cainfo"`
  5881. // ErrMsg interface{} `json:"err_msg"`
  5882. // RefmsgTime string `json:"refmsg_time"`
  5883. // Signtype interface{} `json:"signtype"`
  5884. // RespondTime string `json:"respond_time"`
  5885. // InfRefmsgid string `json:"inf_refmsgid"`
  5886. //}
  5887. type ResultEleven struct {
  5888. Cainfo string `json:"cainfo"`
  5889. ErrMsg string `json:"err_msg"`
  5890. InfRefmsgid string `json:"inf_refmsgid"`
  5891. Infcode int64 `json:"infcode"`
  5892. Output struct {
  5893. Setlinfo struct {
  5894. SetlTime string `json:"setl_time"`
  5895. CvlservPay float64 `json:"cvlserv_pay"`
  5896. Year string `json:"year"`
  5897. MedType string `json:"med_type"`
  5898. PsnPay float64 `json:"psn_pay"`
  5899. OpterID string `json:"opter_id"`
  5900. Begndate string `json:"begndate"`
  5901. FlxempeFlag string `json:"flxempe_flag"`
  5902. HifmiPay float64 `json:"hifmi_pay"`
  5903. PsnNo string `json:"psn_no"`
  5904. ActPayDedc float64 `json:"act_pay_dedc"`
  5905. MedinsSetlID interface{} `json:"medins_setl_id"`
  5906. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5907. ClrWay string `json:"clr_way"`
  5908. OthPay float64 `json:"oth_pay"`
  5909. Gend string `json:"gend"`
  5910. MdtrtID string `json:"mdtrt_id"`
  5911. AcctPay float64 `json:"acct_pay"`
  5912. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5913. Insutype string `json:"insutype"`
  5914. Invono interface{} `json:"invono"`
  5915. Enddate string `json:"enddate"`
  5916. CashPayamt float64 `json:"cash_payamt"`
  5917. PsnType string `json:"psn_type"`
  5918. FixmedinsName string `json:"fixmedins_name"`
  5919. HifpPay float64 `json:"hifp_pay"`
  5920. NewFlag interface{} `json:"new_flag"`
  5921. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5922. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5923. PayLoc string `json:"pay_loc"`
  5924. ClrType string `json:"clr_type"`
  5925. RefdSetlFlag string `json:"refd_setl_flag"`
  5926. CvlservFlag string `json:"cvlserv_flag"`
  5927. EmpName string `json:"emp_name"`
  5928. Brdy string `json:"brdy"`
  5929. Naty string `json:"naty"`
  5930. Certno string `json:"certno"`
  5931. DiseCode string `json:"dise_code"`
  5932. FixmedinsCode string `json:"fixmedins_code"`
  5933. DedcHospLv string `json:"dedc_hosp_lv"`
  5934. OpterName string `json:"opter_name"`
  5935. Balc float64 `json:"balc"`
  5936. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5937. PsnCertType string `json:"psn_cert_type"`
  5938. HifobPay float64 `json:"hifob_pay"`
  5939. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5940. HifesPay float64 `json:"hifes_pay"`
  5941. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5942. OptTime string `json:"opt_time"`
  5943. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5944. SetlID string `json:"setl_id"`
  5945. MafPay float64 `json:"maf_pay"`
  5946. PsnName string `json:"psn_name"`
  5947. InsuOptins interface{} `json:"insu_optins"`
  5948. PrefFundPay interface{} `json:"pref_fund_pay"`
  5949. ClrOptins string `json:"clr_optins"`
  5950. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5951. DiseName string `json:"dise_name"`
  5952. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5953. Age float64 `json:"age"`
  5954. DtrtCertType string `json:"dtrt_cert_type"`
  5955. HospLv string `json:"hosp_lv"`
  5956. PsnCashPay float64
  5957. } `json:"setlinfo"`
  5958. } `json:"output"`
  5959. RefmsgTime string `json:"refmsg_time"`
  5960. RespondTime string `json:"respond_time"`
  5961. Signtype interface{} `json:"signtype"`
  5962. WarnMsg interface{} `json:"warn_msg"`
  5963. }
  5964. type ResultEleven10265 struct {
  5965. Cainfo string `json:"cainfo"`
  5966. ErrMsg string `json:"err_msg"`
  5967. InfRefmsgid string `json:"inf_refmsgid"`
  5968. Infcode string `json:"infcode"`
  5969. Output struct {
  5970. Setlinfo struct {
  5971. SetlTime string `json:"setl_time"`
  5972. CvlservPay float64 `json:"cvlserv_pay"`
  5973. Year string `json:"year"`
  5974. MedType string `json:"med_type"`
  5975. PsnPay float64 `json:"psn_pay"`
  5976. OpterID string `json:"opter_id"`
  5977. Begndate string `json:"begndate"`
  5978. FlxempeFlag string `json:"flxempe_flag"`
  5979. HifmiPay float64 `json:"hifmi_pay"`
  5980. PsnNo string `json:"psn_no"`
  5981. ActPayDedc float64 `json:"act_pay_dedc"`
  5982. MedinsSetlID interface{} `json:"medins_setl_id"`
  5983. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5984. ClrWay string `json:"clr_way"`
  5985. OthPay float64 `json:"oth_pay"`
  5986. Gend string `json:"gend"`
  5987. MdtrtID string `json:"mdtrt_id"`
  5988. AcctPay float64 `json:"acct_pay"`
  5989. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5990. Insutype string `json:"insutype"`
  5991. Invono interface{} `json:"invono"`
  5992. Enddate string `json:"enddate"`
  5993. CashPayamt float64 `json:"cash_payamt"`
  5994. PsnType string `json:"psn_type"`
  5995. FixmedinsName string `json:"fixmedins_name"`
  5996. HifpPay float64 `json:"hifp_pay"`
  5997. NewFlag interface{} `json:"new_flag"`
  5998. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5999. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6000. PayLoc string `json:"pay_loc"`
  6001. ClrType string `json:"clr_type"`
  6002. RefdSetlFlag string `json:"refd_setl_flag"`
  6003. CvlservFlag string `json:"cvlserv_flag"`
  6004. EmpName string `json:"emp_name"`
  6005. Brdy string `json:"brdy"`
  6006. Naty string `json:"naty"`
  6007. Certno string `json:"certno"`
  6008. DiseCode string `json:"dise_code"`
  6009. FixmedinsCode string `json:"fixmedins_code"`
  6010. DedcHospLv string `json:"dedc_hosp_lv"`
  6011. OpterName string `json:"opter_name"`
  6012. Balc float64 `json:"balc"`
  6013. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6014. PsnCertType string `json:"psn_cert_type"`
  6015. HifobPay float64 `json:"hifob_pay"`
  6016. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6017. HifesPay float64 `json:"hifes_pay"`
  6018. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6019. OptTime string `json:"opt_time"`
  6020. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6021. SetlID string `json:"setl_id"`
  6022. MafPay float64 `json:"maf_pay"`
  6023. PsnName string `json:"psn_name"`
  6024. InsuOptins interface{} `json:"insu_optins"`
  6025. PrefFundPay interface{} `json:"pref_fund_pay"`
  6026. ClrOptins string `json:"clr_optins"`
  6027. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6028. DiseName string `json:"dise_name"`
  6029. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6030. Age float64 `json:"age"`
  6031. DtrtCertType string `json:"dtrt_cert_type"`
  6032. HospLv string `json:"hosp_lv"`
  6033. PsnCashPay float64
  6034. } `json:"setlinfo"`
  6035. } `json:"output"`
  6036. RefmsgTime string `json:"refmsg_time"`
  6037. RespondTime string `json:"respond_time"`
  6038. Signtype interface{} `json:"signtype"`
  6039. WarnMsg interface{} `json:"warn_msg"`
  6040. }
  6041. type ResultTwelve struct {
  6042. Cainfo string `json:"cainfo"`
  6043. ErrMsg string `json:"err_msg"`
  6044. InfRefmsgid string `json:"inf_refmsgid"`
  6045. Infcode int64 `json:"infcode"`
  6046. Output struct {
  6047. MdtrtId string `json:"mdtrt_id"`
  6048. ChrgBchno string `json:"chrg_bchno"`
  6049. PsnNo string `json:"psn_no"`
  6050. } `json:"output"`
  6051. RefmsgTime string `json:"refmsg_time"`
  6052. RespondTime string `json:"respond_time"`
  6053. Signtype interface{} `json:"signtype"`
  6054. WarnMsg interface{} `json:"warn_msg"`
  6055. }
  6056. type ResultThirteen struct {
  6057. ErrMsg string `json:"err_msg"`
  6058. InfRefmsgid string `json:"inf_refmsgid"`
  6059. Infcode int64 `json:"infcode"`
  6060. Output struct {
  6061. Result struct {
  6062. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6063. } `json:"result"`
  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 ResultThirteen10265 struct {
  6071. ErrMsg string `json:"err_msg"`
  6072. InfRefmsgid string `json:"inf_refmsgid"`
  6073. Infcode string `json:"infcode"`
  6074. Output struct {
  6075. Result struct {
  6076. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6077. } `json:"result"`
  6078. } `json:"output"`
  6079. RefmsgTime string `json:"refmsg_time"`
  6080. RespondTime string `json:"respond_time"`
  6081. Signtype interface{} `json:"signtype"`
  6082. WarnInfo interface{} `json:"warn_info"`
  6083. }
  6084. type ResultFourteen struct {
  6085. ErrMsg string `json:"err_msg"`
  6086. InfRefmsgid string `json:"inf_refmsgid"`
  6087. Infcode int64 `json:"infcode"`
  6088. Output struct {
  6089. } `json:"output"`
  6090. RefmsgTime string `json:"refmsg_time"`
  6091. RespondTime string `json:"respond_time"`
  6092. Signtype interface{} `json:"signtype"`
  6093. WarnInfo interface{} `json:"warn_info"`
  6094. }
  6095. type ResultFourteen10265 struct {
  6096. ErrMsg string `json:"err_msg"`
  6097. InfRefmsgid string `json:"inf_refmsgid"`
  6098. Infcode string `json:"infcode"`
  6099. Output struct {
  6100. } `json:"output"`
  6101. RefmsgTime string `json:"refmsg_time"`
  6102. RespondTime string `json:"respond_time"`
  6103. Signtype interface{} `json:"signtype"`
  6104. WarnInfo interface{} `json:"warn_info"`
  6105. }
  6106. type ResultSixteen struct {
  6107. Cainfo string `json:"cainfo"`
  6108. ErrMsg string `json:"err_msg"`
  6109. InfRefmsgid string `json:"inf_refmsgid"`
  6110. Infcode int64 `json:"infcode"`
  6111. Output struct {
  6112. Setldetail []interface{} `json:"setldetail"`
  6113. Setlinfo struct {
  6114. MdtrtID string `json:"mdtrt_id"`
  6115. SetlID string `json:"setl_id"`
  6116. ClrOptins string `json:"clr_optins"`
  6117. SetlTime string `json:"setl_time"`
  6118. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6119. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6120. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6121. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6122. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6123. ActPayDedc float64 `json:"act_pay_dedc"`
  6124. HifpPay float64 `json:"hifp_pay"`
  6125. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6126. Lfpay float64 `json:"selfpay"`
  6127. CvlservPay float64 `json:"cvlserv_pay"`
  6128. HifesPay float64 `json:"hifes_pay"`
  6129. HifmiPay float64 `json:"hifmi_pay"`
  6130. HifobPay float64 `json:"hifob_pay"`
  6131. MafPay float64 `json:"maf_pay"`
  6132. OthPay float64 `json:"oth_pay"`
  6133. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6134. PsnPartAmt float64 `json:"psn_part_amt"`
  6135. AcctPay float64 `json:"acct_pay"`
  6136. Balc float64 `json:"balc"`
  6137. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6138. HospPartAmt float64 `json:"hosp_part_amt"`
  6139. MedinsSetlID string `json:"medins_setl_id"`
  6140. PdnCashPay string `json:"pdn_cash_pay"`
  6141. } `json:"setlinfo"`
  6142. } `json:"output"`
  6143. RefmsgTime string `json:"refmsg_time"`
  6144. RespondTime string `json:"respond_time"`
  6145. Signtype interface{} `json:"signtype"`
  6146. WarnMsg interface{} `json:"warn_msg"`
  6147. }
  6148. type ResultSixteen10265 struct {
  6149. Cainfo string `json:"cainfo"`
  6150. ErrMsg string `json:"err_msg"`
  6151. InfRefmsgid string `json:"inf_refmsgid"`
  6152. Infcode string `json:"infcode"`
  6153. Output struct {
  6154. Setldetail []interface{} `json:"setldetail"`
  6155. Setlinfo struct {
  6156. MdtrtID string `json:"mdtrt_id"`
  6157. SetlID string `json:"setl_id"`
  6158. ClrOptins string `json:"clr_optins"`
  6159. SetlTime string `json:"setl_time"`
  6160. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6161. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6162. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6163. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6164. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6165. ActPayDedc float64 `json:"act_pay_dedc"`
  6166. HifpPay float64 `json:"hifp_pay"`
  6167. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6168. Lfpay float64 `json:"selfpay"`
  6169. CvlservPay float64 `json:"cvlserv_pay"`
  6170. HifesPay float64 `json:"hifes_pay"`
  6171. HifmiPay float64 `json:"hifmi_pay"`
  6172. HifobPay float64 `json:"hifob_pay"`
  6173. MafPay float64 `json:"maf_pay"`
  6174. OthPay float64 `json:"oth_pay"`
  6175. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6176. PsnPartAmt float64 `json:"psn_part_amt"`
  6177. AcctPay float64 `json:"acct_pay"`
  6178. Balc float64 `json:"balc"`
  6179. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6180. HospPartAmt float64 `json:"hosp_part_amt"`
  6181. MedinsSetlID string `json:"medins_setl_id"`
  6182. PdnCashPay string `json:"pdn_cash_pay"`
  6183. } `json:"setlinfo"`
  6184. } `json:"output"`
  6185. RefmsgTime string `json:"refmsg_time"`
  6186. RespondTime string `json:"respond_time"`
  6187. Signtype interface{} `json:"signtype"`
  6188. WarnMsg interface{} `json:"warn_msg"`
  6189. }
  6190. type ResultSeventeen struct {
  6191. ErrMsg string `json:"err_msg"`
  6192. InfRefmsgid string `json:"inf_refmsgid"`
  6193. Infcode int64 `json:"infcode"`
  6194. Output struct {
  6195. SetlListId string `json:"setl_list_id"`
  6196. } `json:"output"`
  6197. RefmsgTime string `json:"refmsg_time"`
  6198. RespondTime string `json:"respond_time"`
  6199. Signtype string `json:"signtype"`
  6200. WarnInfo string `json:"warn_info"`
  6201. }
  6202. type ResultSeventeenOther struct {
  6203. ErrMsg string `json:"err_msg"`
  6204. InfRefmsgid string `json:"inf_refmsgid"`
  6205. Infcode string `json:"infcode"`
  6206. Output struct {
  6207. SetlListId string `json:"setl_list_id"`
  6208. } `json:"output"`
  6209. RefmsgTime string `json:"refmsg_time"`
  6210. RespondTime string `json:"respond_time"`
  6211. Signtype string `json:"signtype"`
  6212. WarnInfo string `json:"warn_info"`
  6213. }
  6214. type Result90991 struct {
  6215. ErrMsg string `json:"err_msg"`
  6216. InfRefmsgid string `json:"inf_refmsgid"`
  6217. Infcode int64 `json:"infcode"`
  6218. Output struct {
  6219. Result struct {
  6220. PsnNo string `json:"psn_no"`
  6221. CardStat string `json:"card_stat"`
  6222. Certno string `json:"certno"`
  6223. PsnName string `json:"psn_name"`
  6224. CheckStat string `json:"check_stat"`
  6225. SscnoCheckStat string `json:"sscno_check_stat"`
  6226. } `json:"result"`
  6227. } `json:"output"`
  6228. RefmsgTime string `json:"refmsg_time"`
  6229. RespondTime string `json:"respond_time"`
  6230. Signtype interface{} `json:"signtype"`
  6231. WarnInfo interface{} `json:"warn_info"`
  6232. }
  6233. type Result90100 struct {
  6234. ErrMsg string `json:"err_msg"`
  6235. InfRefmsgid string `json:"inf_refmsgid"`
  6236. Infcode int64 `json:"infcode"`
  6237. Output struct {
  6238. PoolareaNo string `json:"poolarea_no"`
  6239. PoolareaNoName string `json:"poolarea_no_name"`
  6240. Insutype string `json:"insutype"`
  6241. InsutypeName string `json:"insutype_name"`
  6242. ClctType string `json:"clct_type"`
  6243. ClctTypeName string `json:"clct_type_name"`
  6244. ClctFlag string `json:"clct_flag"`
  6245. ClctFlagName string `json:"clct_flag_name"`
  6246. AccrymBegn string `json:"accrym_begn"`
  6247. AccrymEnd string `json:"accrym_end"`
  6248. ClctTime string `json:"clct_time"`
  6249. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6250. } `json:"output"`
  6251. RefmsgTime string `json:"refmsg_time"`
  6252. RespondTime string `json:"respond_time"`
  6253. Signtype interface{} `json:"signtype"`
  6254. WarnInfo interface{} `json:"warn_info"`
  6255. }
  6256. type Custom struct {
  6257. DetItemFeeSumamt string
  6258. Cut string
  6259. FeedetlSn string
  6260. Price string
  6261. MedListCodg string
  6262. Type int64
  6263. AdviceId int64
  6264. ProjectId int64
  6265. ItemId int64
  6266. }
  6267. type Result5301 struct {
  6268. ErrMsg string `json:"err_msg"`
  6269. InfRefmsgid string `json:"inf_refmsgid"`
  6270. Infcode int64 `json:"infcode"`
  6271. Output struct {
  6272. Result []struct {
  6273. OpspDiseCode string `json:"opsp_dise_code"`
  6274. OpspDiseName string `json:"opsp_dise_name"`
  6275. Begndate string `json:"begndate"`
  6276. Enddate string `json:"enddate"`
  6277. } `json:"feedetail"`
  6278. } `json:"output"`
  6279. RefmsgTime string `json:"refmsg_time"`
  6280. RespondTime string `json:"respond_time"`
  6281. Signtype interface{} `json:"signtype"`
  6282. WarnInfo interface{} `json:"warn_info"`
  6283. }
  6284. type Result5301For10265 struct {
  6285. ErrMsg string `json:"err_msg"`
  6286. InfRefmsgid string `json:"inf_refmsgid"`
  6287. Infcode string `json:"infcode"`
  6288. Output struct {
  6289. Result []struct {
  6290. OpspDiseCode string `json:"opsp_dise_code"`
  6291. OpspDiseName string `json:"opsp_dise_name"`
  6292. Begndate string `json:"begndate"`
  6293. Enddate string `json:"enddate"`
  6294. } `json:"feedetail"`
  6295. } `json:"output"`
  6296. RefmsgTime string `json:"refmsg_time"`
  6297. RespondTime string `json:"respond_time"`
  6298. Signtype interface{} `json:"signtype"`
  6299. WarnInfo interface{} `json:"warn_info"`
  6300. }
  6301. //获取个人信息----挂号-----上传就诊信息
  6302. func (c *HisApiController) GetRegisterInfo() {
  6303. id, _ := c.GetInt64("id")
  6304. record_time := c.GetString("record_time")
  6305. settlementValue, _ := c.GetInt64("settlement_value")
  6306. medical_insurance_card := c.GetString("medical_insurance_card")
  6307. name := c.GetString("name")
  6308. id_card_type, _ := c.GetInt64("id_card_type")
  6309. certificates, _ := c.GetInt64("certificates")
  6310. medical_care, _ := c.GetInt64("medical_care")
  6311. birthday := c.GetString("birthday")
  6312. id_card := c.GetString("id_card")
  6313. register_type, _ := c.GetInt64("register")
  6314. doctor, _ := c.GetInt64("doctor")
  6315. department, _ := c.GetInt64("department")
  6316. gender, _ := c.GetInt64("sex")
  6317. registration_fee, _ := c.GetFloat("registration_fee")
  6318. medical_expenses, _ := c.GetFloat("medical_expenses")
  6319. social_type, _ := c.GetInt64("social_type")
  6320. med_type := c.GetString("social_type")
  6321. admin_user_id, _ := c.GetInt64("admin_user_id")
  6322. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6323. timeLayout := "2006-01-02"
  6324. loc, _ := time.LoadLocation("Local")
  6325. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6326. birthUnix := birthdays.Unix()
  6327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6328. if err != nil {
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6330. return
  6331. }
  6332. recordDateTime := theTime.Unix()
  6333. adminInfo := c.GetAdminUserInfo()
  6334. var patient service.Patients
  6335. if id == 0 {
  6336. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6337. } else {
  6338. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6339. }
  6340. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6341. if patientPrescription.ID == 0 {
  6342. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6343. }
  6344. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6345. if patient.ID == 0 {
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6347. return
  6348. }
  6349. if len(patient.IdCardNo) == 0 {
  6350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6351. return
  6352. }
  6353. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6354. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6355. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6356. //就诊结算未完成,不能进行二次挂号
  6357. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6358. if len(his) >= 1 {
  6359. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6360. if len(his) >= 1 && order.ID == 0 {
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6362. return
  6363. }
  6364. }
  6365. //var register_log string
  6366. if config.IsOpen == 1 {
  6367. var res ResultTwo
  6368. var res10265 ResultTwo10265
  6369. var PsnNo string
  6370. var PsnCertType string
  6371. var Certno string
  6372. var PsnName string
  6373. var Gend string
  6374. var Naty string
  6375. var Brdy string
  6376. var Age float64
  6377. var infoStr string
  6378. var idetinfoStr string
  6379. var infocode int64
  6380. var verify_number string
  6381. fmt.Println(verify_number)
  6382. if miConfig.MdtrtareaAdmvs == "421300" {
  6383. psn_info, _ := service.GetPsnByPatientId(id)
  6384. PsnNo = psn_info.PsnNo
  6385. PsnCertType = psn_info.PsnCertType
  6386. Certno = psn_info.Certno
  6387. PsnName = psn_info.PsnName
  6388. Gend = psn_info.Gend
  6389. Naty = psn_info.Naty
  6390. Brdy = psn_info.Brdy
  6391. Age = psn_info.Age
  6392. infoStr = psn_info.Insuinfo
  6393. idetinfoStr = psn_info.Idetinfo
  6394. infocode = 0
  6395. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6396. psn_info, _ := service.GetPsnByPatientId(id)
  6397. PsnNo = psn_info.PsnNo
  6398. PsnCertType = psn_info.PsnCertType
  6399. Certno = psn_info.Certno
  6400. PsnName = psn_info.PsnName
  6401. Gend = psn_info.Gend
  6402. Naty = psn_info.Naty
  6403. Brdy = psn_info.Brdy
  6404. Age = psn_info.Age
  6405. infoStr = psn_info.Insuinfo
  6406. idetinfoStr = psn_info.Idetinfo
  6407. infocode = 0
  6408. verify_number = psn_info.VerifyNumber
  6409. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6410. if id_card_type == 1 {
  6411. psn_info, _ := service.GetPsnByPatientId(id)
  6412. PsnNo = psn_info.PsnNo
  6413. PsnCertType = psn_info.PsnCertType
  6414. Certno = psn_info.Certno
  6415. PsnName = psn_info.PsnName
  6416. Gend = psn_info.Gend
  6417. Naty = psn_info.Naty
  6418. Brdy = psn_info.Brdy
  6419. Age = psn_info.Age
  6420. infoStr = psn_info.Insuinfo
  6421. idetinfoStr = psn_info.Idetinfo
  6422. infocode = 0
  6423. verify_number = psn_info.VerifyNumber
  6424. } else if id_card_type == 2 {
  6425. 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)
  6426. fmt.Println(errMsgLog)
  6427. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6429. utils.ErrorLog("解析失败:%v", err)
  6430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6431. return
  6432. }
  6433. PsnNo = res.Output.Baseinfo.PsnNo
  6434. PsnCertType = res.Output.Baseinfo.PsnCertType
  6435. Certno = res.Output.Baseinfo.Certno
  6436. PsnName = res.Output.Baseinfo.PsnName
  6437. Gend = res.Output.Baseinfo.Gend
  6438. Naty = res.Output.Baseinfo.Naty
  6439. Brdy = res.Output.Baseinfo.Brdy
  6440. Age = res.Output.Baseinfo.Age
  6441. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6442. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6443. infoStr = string(Iinfos)
  6444. idetinfoStr = string(Idetinfos)
  6445. infocode = res.Infcode
  6446. }
  6447. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6448. if id_card_type == 1 {
  6449. psn_info, _ := service.GetPsnByPatientId(id)
  6450. PsnNo = psn_info.PsnNo
  6451. PsnCertType = psn_info.PsnCertType
  6452. Certno = psn_info.Certno
  6453. PsnName = psn_info.PsnName
  6454. Gend = psn_info.Gend
  6455. Naty = psn_info.Naty
  6456. Brdy = psn_info.Brdy
  6457. Age = psn_info.Age
  6458. infoStr = psn_info.Insuinfo
  6459. idetinfoStr = psn_info.Idetinfo
  6460. infocode = 0
  6461. verify_number = psn_info.VerifyNumber
  6462. } else if id_card_type == 2 {
  6463. 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, "")
  6464. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6466. utils.ErrorLog("解析失败:%v", err)
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return
  6469. }
  6470. PsnNo = res.Output.Baseinfo.PsnNo
  6471. PsnCertType = res.Output.Baseinfo.PsnCertType
  6472. Certno = res.Output.Baseinfo.Certno
  6473. PsnName = res.Output.Baseinfo.PsnName
  6474. Gend = res.Output.Baseinfo.Gend
  6475. Naty = res.Output.Baseinfo.Naty
  6476. Brdy = res.Output.Baseinfo.Brdy
  6477. Age = res.Output.Baseinfo.Age
  6478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6480. infoStr = string(Iinfos)
  6481. idetinfoStr = string(Idetinfos)
  6482. infocode = res.Infcode
  6483. }
  6484. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6485. if id_card_type == 1 {
  6486. psn_info, _ := service.GetPsnByPatientId(id)
  6487. PsnNo = psn_info.PsnNo
  6488. PsnCertType = psn_info.PsnCertType
  6489. Certno = psn_info.Certno
  6490. PsnName = psn_info.PsnName
  6491. Gend = psn_info.Gend
  6492. Naty = psn_info.Naty
  6493. Brdy = psn_info.Brdy
  6494. Age = psn_info.Age
  6495. infoStr = psn_info.Insuinfo
  6496. idetinfoStr = psn_info.Idetinfo
  6497. infocode = 0
  6498. verify_number = psn_info.VerifyNumber
  6499. } else if id_card_type == 2 {
  6500. 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)
  6501. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6502. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6503. utils.ErrorLog("解析失败:%v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. PsnNo = res.Output.Baseinfo.PsnNo
  6508. PsnCertType = res.Output.Baseinfo.PsnCertType
  6509. Certno = res.Output.Baseinfo.Certno
  6510. PsnName = res.Output.Baseinfo.PsnName
  6511. Gend = res.Output.Baseinfo.Gend
  6512. Naty = res.Output.Baseinfo.Naty
  6513. Brdy = res.Output.Baseinfo.Brdy
  6514. Age = res.Output.Baseinfo.Age
  6515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6517. infoStr = string(Iinfos)
  6518. idetinfoStr = string(Idetinfos)
  6519. infocode = res.Infcode
  6520. }
  6521. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6522. var result string
  6523. var requestLog string
  6524. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  6525. if id_card_type == 4 {
  6526. psn_info, _ := service.GetPsnByPatientId(id)
  6527. PsnNo = psn_info.PsnNo
  6528. PsnCertType = psn_info.PsnCertType
  6529. Certno = psn_info.Certno
  6530. PsnName = psn_info.PsnName
  6531. Gend = psn_info.Gend
  6532. Naty = psn_info.Naty
  6533. Brdy = psn_info.Brdy
  6534. Age = psn_info.Age
  6535. infoStr = psn_info.Insuinfo
  6536. idetinfoStr = psn_info.Idetinfo
  6537. infocode = 0
  6538. verify_number = psn_info.VerifyNumber
  6539. } else {
  6540. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6541. if miConfig.Code == "H15049901371" {
  6542. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6543. utils.ErrorLog("解析失败:%v", err)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return
  6546. }
  6547. res.ErrMsg = res10265.ErrMsg
  6548. res.Output = res10265.Output
  6549. res.InfRefmsgid = res10265.InfRefmsgid
  6550. } else {
  6551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6552. utils.ErrorLog("解析失败:%v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. }
  6557. PsnNo = res.Output.Baseinfo.PsnNo
  6558. PsnCertType = res.Output.Baseinfo.PsnCertType
  6559. Certno = res.Output.Baseinfo.Certno
  6560. PsnName = res.Output.Baseinfo.PsnName
  6561. Gend = res.Output.Baseinfo.Gend
  6562. Naty = res.Output.Baseinfo.Naty
  6563. Brdy = res.Output.Baseinfo.Brdy
  6564. Age = res.Output.Baseinfo.Age
  6565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6567. infoStr = string(Iinfos)
  6568. idetinfoStr = string(Idetinfos)
  6569. if miConfig.Code == "H15049901371" {
  6570. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6571. } else {
  6572. infocode = res.Infcode
  6573. }
  6574. }
  6575. } else {
  6576. var result string
  6577. var requestLog string
  6578. if miConfig.UserOrgId == 10138 {
  6579. if id_card_type != 4 {
  6580. //psn_info, _ := service.GetPsnByPatientId(id)
  6581. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6582. 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)
  6583. }
  6584. } else {
  6585. 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)
  6586. }
  6587. if id_card_type == 4 {
  6588. psn_info, _ := service.GetPsnByPatientId(id)
  6589. PsnNo = psn_info.PsnNo
  6590. PsnCertType = psn_info.PsnCertType
  6591. Certno = psn_info.Certno
  6592. PsnName = psn_info.PsnName
  6593. Gend = psn_info.Gend
  6594. Naty = psn_info.Naty
  6595. Brdy = psn_info.Brdy
  6596. Age = psn_info.Age
  6597. infoStr = psn_info.Insuinfo
  6598. idetinfoStr = psn_info.Idetinfo
  6599. infocode = 0
  6600. verify_number = psn_info.VerifyNumber
  6601. } else {
  6602. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6603. if miConfig.Code == "H15049901371" {
  6604. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6605. utils.ErrorLog("解析失败:%v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. res.ErrMsg = res10265.ErrMsg
  6610. res.Output = res10265.Output
  6611. res.InfRefmsgid = res10265.InfRefmsgid
  6612. } else {
  6613. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. }
  6619. PsnNo = res.Output.Baseinfo.PsnNo
  6620. PsnCertType = res.Output.Baseinfo.PsnCertType
  6621. Certno = res.Output.Baseinfo.Certno
  6622. PsnName = res.Output.Baseinfo.PsnName
  6623. Gend = res.Output.Baseinfo.Gend
  6624. Naty = res.Output.Baseinfo.Naty
  6625. Brdy = res.Output.Baseinfo.Brdy
  6626. Age = res.Output.Baseinfo.Age
  6627. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6628. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6629. infoStr = string(Iinfos)
  6630. idetinfoStr = string(Idetinfos)
  6631. if miConfig.Code == "H15049901371" {
  6632. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6633. } else {
  6634. infocode = res.Infcode
  6635. }
  6636. }
  6637. }
  6638. if infocode == 0 {
  6639. his := models.VMHisPatient{
  6640. Name: name,
  6641. Gender: gender,
  6642. Birthday: birthUnix,
  6643. MedicalTreatmentType: medical_care,
  6644. IdType: certificates,
  6645. IdCardNo: id_card,
  6646. BalanceAccountsType: settlementValue,
  6647. SocialType: social_type,
  6648. MedicalInsuranceNumber: medical_insurance_card,
  6649. RegisterType: register_type,
  6650. RegisterCost: registration_fee,
  6651. TreatmentCost: medical_expenses,
  6652. Status: 1,
  6653. Ctime: time.Now().Unix(),
  6654. Mtime: time.Now().Unix(),
  6655. PsnNo: PsnNo,
  6656. PsnCertType: PsnCertType,
  6657. Certno: Certno,
  6658. PsnName: PsnName,
  6659. Gend: Gend,
  6660. Naty: Naty,
  6661. Brdy: Brdy,
  6662. Age: Age,
  6663. Iinfo: infoStr,
  6664. Idetinfo: idetinfoStr,
  6665. PatientId: patient.ID,
  6666. RecordDate: theTime.Unix(),
  6667. UserOrgId: adminInfo.CurrentOrgId,
  6668. AdminUserId: admin_user_id,
  6669. IsReturn: 1,
  6670. IdCardType: id_card_type,
  6671. Doctor: doctor,
  6672. Departments: department,
  6673. }
  6674. timestamp := time.Now().Unix()
  6675. tempTime := time.Unix(timestamp, 0)
  6676. timeFormat := tempTime.Format("20060102150405")
  6677. chrgBchno := rand.Intn(100000) + 10000
  6678. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6679. his.Number = ipt_otp_no
  6680. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6681. department, _ := service.GetDepartMentDetail(department)
  6682. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6683. IdCardNo := ""
  6684. if id_card_type == 1 {
  6685. // IdCardNo = medical_insurance_card
  6686. IdCardNo = patient.IdCardNo
  6687. } else {
  6688. IdCardNo = patient.IdCardNo
  6689. }
  6690. var rf []*ResultFive
  6691. json.Unmarshal([]byte(his.Iinfo), &rf)
  6692. var insutypes []*ResultFive
  6693. var insutype string
  6694. var insuplc_admdvs_temp string
  6695. var is390 int = 0
  6696. var is310 int = 0
  6697. for _, item := range rf {
  6698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6699. insutypes = append(insutypes, item)
  6700. }
  6701. }
  6702. if len(insutypes) == 1 {
  6703. insutype = insutypes[0].Insutype
  6704. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6705. } else {
  6706. for _, i := range insutypes {
  6707. if i.Insutype == "390" {
  6708. is390 = 1
  6709. }
  6710. if i.Insutype == "310" {
  6711. is310 = 1
  6712. }
  6713. }
  6714. }
  6715. if is390 == 1 {
  6716. insutype = "390"
  6717. }
  6718. if is310 == 1 {
  6719. insutype = "310"
  6720. }
  6721. if len(insutypes) == 0 {
  6722. insutype = "310"
  6723. }
  6724. if len(insutypes) == 2 {
  6725. insutype = med_type
  6726. }
  6727. if len(med_type) > 0 {
  6728. insutype = med_type
  6729. }
  6730. var infocode int64
  6731. var resThree ResultThree
  6732. var resThree10265 ResultThree10265
  6733. if len(insuplc_admdvs) == 0 {
  6734. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6735. } else {
  6736. insuplc_admdvs_temp = insuplc_admdvs
  6737. }
  6738. if miConfig.MdtrtareaAdmvs == "350500" {
  6739. var rf []*ResultIDInfo
  6740. json.Unmarshal([]byte(idetinfoStr), &rf)
  6741. if len(rf) > 0 {
  6742. if len(rf[0].Memo.InsuAdmdvs) > 0 {
  6743. insuplc_admdvs_temp = rf[0].Memo.InsuAdmdvs
  6744. }
  6745. }
  6746. }
  6747. if miConfig.MdtrtareaAdmvs == "421300" {
  6748. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6749. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6750. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6751. "&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
  6752. resp, requestErr := http.Get(api)
  6753. if requestErr != nil {
  6754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6755. return
  6756. }
  6757. body, ioErr := ioutil.ReadAll(resp.Body)
  6758. if ioErr != nil {
  6759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. return
  6762. }
  6763. var respJSON map[string]interface{}
  6764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. return
  6768. }
  6769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6770. result, _ := json.Marshal(respJSON)
  6771. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6772. utils.ErrorLog("解析失败:%v", err)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. return
  6775. }
  6776. infocode = resThree.Infcode
  6777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6778. psn_info, _ := service.GetPsnByPatientId(id)
  6779. his.PsnNo = psn_info.PsnNo
  6780. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6781. var cert_no string
  6782. if id_card_type == 3 {
  6783. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6784. cert_no = IdCardNo
  6785. } else if id_card_type == 4 {
  6786. cert_no = IdCardNo
  6787. psn_info.VerifyNumber = psn_info.VerifyNumber
  6788. } else {
  6789. bas := strings.Split(psn_info.CardInfo, "|")
  6790. cert_no = bas[2]
  6791. }
  6792. var hisPrescription []*models.HisPrescription
  6793. for _, item := range rf {
  6794. if item.Insutype == insutype {
  6795. //insuplc_admdvs = item.InsuplcAdmdvs
  6796. his.InsuplcAdmdvs = insuplc_admdvs
  6797. }
  6798. }
  6799. his.Insutype = insutype
  6800. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6801. fmt.Println(res3101)
  6802. fmt.Println(res3101.Infcode)
  6803. if res3101.Infcode == "0" {
  6804. fmt.Println("33333333")
  6805. if len(res3101.Output.Result) > 0 {
  6806. fmt.Println("222222")
  6807. for _, item := range res3101.Output.Result {
  6808. if len(res3101.ErrMsg) == 0 {
  6809. res3101.ErrMsg = item.VolaCont
  6810. } else {
  6811. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6812. }
  6813. }
  6814. c.ServeSuccessJSON(map[string]interface{}{
  6815. "failed_code": -10,
  6816. "msg": res3101.ErrMsg,
  6817. })
  6818. return
  6819. } else {
  6820. fmt.Println("11111")
  6821. var api string
  6822. if miConfig.MdtrtareaAdmvs == "320921" {
  6823. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6824. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6825. "&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
  6826. } else {
  6827. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6828. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6829. "&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
  6830. }
  6831. resp, requestErr := http.Get(api)
  6832. if requestErr != nil {
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. return
  6835. }
  6836. body, ioErr := ioutil.ReadAll(resp.Body)
  6837. if ioErr != nil {
  6838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. return
  6841. }
  6842. var respJSON map[string]interface{}
  6843. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6849. result, _ := json.Marshal(respJSON)
  6850. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6851. utils.ErrorLog("解析失败:%v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. return
  6854. }
  6855. resThree.ErrMsg = resThree10265.ErrMsg
  6856. resThree.Output = resThree10265.Output
  6857. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6858. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6859. }
  6860. } else if res3101.Infcode != "0" {
  6861. c.ServeSuccessJSON(map[string]interface{}{
  6862. "failed_code": -10,
  6863. "msg": res3101.ErrMsg,
  6864. })
  6865. return
  6866. }
  6867. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6868. psn_info, _ := service.GetPsnByPatientId(id)
  6869. var cert_no string
  6870. if id_card_type == 1 {
  6871. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6872. } else if id_card_type == 4 {
  6873. cert_no = psn_info.VerifyNumber
  6874. } else {
  6875. cert_no = psn_info.VerifyNumber
  6876. }
  6877. 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)
  6878. saveLog(result, requestLog, "2201", "挂号")
  6879. if miConfig.Code == "H15049901371" {
  6880. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6881. utils.ErrorLog("解析失败:%v", err)
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. return
  6884. }
  6885. resThree.ErrMsg = resThree10265.ErrMsg
  6886. resThree.Output = resThree10265.Output
  6887. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6888. } else {
  6889. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6890. utils.ErrorLog("解析失败:%v", err)
  6891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6892. return
  6893. }
  6894. }
  6895. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6896. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  6897. psn_info, _ := service.GetPsnByPatientId(id)
  6898. var result string
  6899. var requestLog string
  6900. if id_card_type == 1 {
  6901. bas := strings.Split(psn_info.CardInfo, "|")
  6902. basNumber := bas[2]
  6903. card_sn := bas[3]
  6904. 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)
  6905. saveLog(result, requestLog, "2201A", "挂号")
  6906. } else if id_card_type == 2 {
  6907. 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, "", "")
  6908. saveLog(result, requestLog, "2201A", "挂号")
  6909. } else {
  6910. 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, "", "")
  6911. saveLog(result, requestLog, "2201A", "挂号")
  6912. }
  6913. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. infocode = resThree.Infcode
  6919. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  6920. psn_info, _ := service.GetPsnByPatientId(id)
  6921. var result string
  6922. var requestLog string
  6923. if id_card_type == 1 {
  6924. bas := strings.Split(psn_info.CardInfo, "|")
  6925. basNumber := bas[2]
  6926. card_sn := bas[3]
  6927. 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)
  6928. saveLog(result, requestLog, "2201A", "挂号")
  6929. } else if id_card_type == 2 {
  6930. 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, "", "")
  6931. saveLog(result, requestLog, "2201A", "挂号")
  6932. } else {
  6933. 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, "", "")
  6934. saveLog(result, requestLog, "2201A", "挂号")
  6935. }
  6936. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6937. utils.ErrorLog("解析失败:%v", err)
  6938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. return
  6940. }
  6941. infocode = resThree.Infcode
  6942. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6943. psn_info, _ := service.GetPsnByPatientId(id)
  6944. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  6945. saveLog(result, requestLog, "2201A", "挂号")
  6946. if miConfig.Code == "H15049901371" {
  6947. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6948. utils.ErrorLog("解析失败:%v", err)
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. return
  6951. }
  6952. resThree.ErrMsg = resThree10265.ErrMsg
  6953. resThree.Output = resThree10265.Output
  6954. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6955. } else {
  6956. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6957. utils.ErrorLog("解析失败:%v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. }
  6962. if miConfig.Code == "H15049901371" {
  6963. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6964. } else {
  6965. infocode = resThree.Infcode
  6966. }
  6967. } else {
  6968. psn_info, _ := service.GetPsnByPatientId(id)
  6969. 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)
  6970. saveLog(result, requestLog, "2201A", "挂号")
  6971. if miConfig.Code == "H15049901371" {
  6972. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6973. utils.ErrorLog("解析失败:%v", err)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. resThree.ErrMsg = resThree10265.ErrMsg
  6978. resThree.Output = resThree10265.Output
  6979. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6980. } else {
  6981. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6982. utils.ErrorLog("解析失败:%v", err)
  6983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6984. return
  6985. }
  6986. }
  6987. if miConfig.Code == "H15049901371" {
  6988. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6989. } else {
  6990. infocode = resThree.Infcode
  6991. }
  6992. }
  6993. if infocode != 0 {
  6994. adminUser := c.GetAdminUserInfo()
  6995. errlog := &models.HisOrderError{
  6996. UserOrgId: adminUser.CurrentOrgId,
  6997. Ctime: time.Now().Unix(),
  6998. Mtime: time.Now().Unix(),
  6999. ErrMsg: resThree.ErrMsg,
  7000. Status: 1,
  7001. PatientId: id,
  7002. RecordTime: recordDateTime,
  7003. Stage: 2,
  7004. }
  7005. service.CreateErrMsgLog(errlog)
  7006. c.ServeSuccessJSON(map[string]interface{}{
  7007. "failed_code": -10,
  7008. "msg": resThree.ErrMsg,
  7009. })
  7010. return
  7011. }
  7012. his.Number = resThree.Output.Data.MdtrtID
  7013. his.PsnNo = resThree.Output.Data.PsnNo
  7014. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7015. his.IdCardNo = patient.IdCardNo
  7016. his.PhoneNumber = patient.Phone
  7017. his.UserOrgId = adminInfo.CurrentOrgId
  7018. his.Insutype = insutype
  7019. his.Ctime = time.Now().Unix()
  7020. his.Mtime = time.Now().Unix()
  7021. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7022. his.Status = 1
  7023. service.UpdateHisPatientStatus(&his)
  7024. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7025. c.ServeSuccessJSON(map[string]interface{}{
  7026. "his_info": his,
  7027. })
  7028. } else {
  7029. adminUser := c.GetAdminUserInfo()
  7030. errlog := &models.HisOrderError{
  7031. UserOrgId: adminUser.CurrentOrgId,
  7032. Ctime: time.Now().Unix(),
  7033. Mtime: time.Now().Unix(),
  7034. ErrMsg: res.ErrMsg,
  7035. Status: 1,
  7036. PatientId: id,
  7037. RecordTime: recordDateTime,
  7038. Stage: 1,
  7039. }
  7040. service.CreateErrMsgLog(errlog)
  7041. c.ServeSuccessJSON(map[string]interface{}{
  7042. "failed_code": -10,
  7043. "msg": res.ErrMsg,
  7044. })
  7045. return
  7046. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7047. }
  7048. }
  7049. }
  7050. //上传明细----预结算----确认订单
  7051. func (c *HisApiController) GetUploadInfo() {
  7052. id, _ := c.GetInt64("id")
  7053. record_time := c.GetString("record_time")
  7054. his_patient_id, _ := c.GetInt64("his_patient_id")
  7055. order_id, _ := c.GetInt64("order_id")
  7056. pay_way, _ := c.GetInt64("pay_way")
  7057. pay_price, _ := c.GetFloat("pay_price")
  7058. pay_card_no := c.GetString("pay_card_no")
  7059. discount_price, _ := c.GetFloat("discount_price")
  7060. preferential_price, _ := c.GetFloat("preferential_price")
  7061. reality_price, _ := c.GetFloat("reality_price")
  7062. found_price, _ := c.GetFloat("found_price")
  7063. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7064. private_price, _ := c.GetFloat("private_price")
  7065. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7066. admin_user_id, _ := c.GetInt64("admin_user_id")
  7067. fapiao_code := c.GetString("fapiao_code")
  7068. fapiao_number := c.GetString("fapiao_number")
  7069. diagnosis_id := c.GetString("diagnosis")
  7070. sick_type, _ := c.GetInt64("sick_type")
  7071. reg_type, _ := c.GetInt64("p_type")
  7072. begin_time := c.GetString("begin_time")
  7073. id_str := c.GetString("ids")
  7074. ids_arr := strings.Split(id_str, ",")
  7075. timeLayout := "2006-01-02"
  7076. loc, _ := time.LoadLocation("Local")
  7077. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7078. if err != nil {
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7080. return
  7081. }
  7082. recordDateTime := theTime.Unix()
  7083. adminUser := c.GetAdminUserInfo()
  7084. var tempOrder models.HisOrder
  7085. tempOrder, _ = service.GetHisOrderByID(order_id)
  7086. var prescriptions []*models.HisPrescription
  7087. var start_time int64
  7088. var end_time int64
  7089. //押金模块
  7090. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7091. tmp_decimal := c.GetString("tmp_decimal")
  7092. var decimal float64 //本次使用的押金
  7093. var errmsg error
  7094. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7095. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7096. return
  7097. }
  7098. if len(tmp_decimal) > 0 {
  7099. if tmp_decimal[0] == 45 {
  7100. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7101. return
  7102. }
  7103. }
  7104. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7105. fmt.Println(errs)
  7106. decimal = tt
  7107. //if adminUser.CurrentOrgId == 10106{
  7108. // if len(fapiao_code) == 0{
  7109. // fapiao_code = "144072080589"
  7110. // }
  7111. // if len(fapiao_number) == 0{
  7112. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7113. // if order.ID == 0{
  7114. // fapiao_number = "00001520"
  7115. // }else{
  7116. // //fapiao_code = "00001520"
  7117. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7118. // var zero string
  7119. // if fpNumber >= 1000{
  7120. // zero = "0000" + strconv.Itoa(fpNumber)
  7121. // }else if fpNumber >= 10000{
  7122. // zero = "000" + strconv.Itoa(fpNumber)
  7123. // } else if fpNumber >= 100000{
  7124. // zero = "00" + strconv.Itoa(fpNumber)
  7125. // } else if fpNumber >= 1000000{
  7126. // zero = "0" + strconv.Itoa(fpNumber)
  7127. // }else {
  7128. // zero = strconv.Itoa(fpNumber)
  7129. // }
  7130. // fapiao_number = zero
  7131. // }
  7132. // }
  7133. //}
  7134. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7135. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7136. var patientPrescription models.HisPrescriptionInfo
  7137. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7138. if patientPrescription.ID == 0 {
  7139. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7140. }
  7141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7142. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7143. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7144. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7145. var config []*models.HisXtDiagnoseConfig
  7146. for _, item := range diagnosis_ids {
  7147. id, _ := strconv.ParseInt(item, 10, 64)
  7148. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7149. config = append(config, &diagnosisConfig)
  7150. }
  7151. sickConfig, _ := service.FindSickById(sick_type)
  7152. //if tempOrder.ID == 0 {
  7153. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7154. //}
  7155. if tempOrder.ID == 0 {
  7156. var result string
  7157. var requestLog string
  7158. var res2 ResultSix
  7159. var ressix10265 ResultSix10265
  7160. if miConfig.MdtrtareaAdmvs == "421300" {
  7161. data := make(map[string]interface{})
  7162. client := &http.Client{}
  7163. data["psn_no"] = his.PsnNo
  7164. data["mdtrt_id"] = his.Number
  7165. data["opter"] = roles.UserName
  7166. data["org_name"] = miConfig.OrgName
  7167. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7168. data["doctor_id"] = doctor_info.DoctorNumber
  7169. data["doctor_name"] = doctor_info.UserName
  7170. data["department"] = department.Name
  7171. data["fixmedins_code"] = miConfig.Code
  7172. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7174. data["secret_key"] = miConfig.SecretKey
  7175. data["sick_code"] = sickConfig.CountryCode
  7176. data["sick_name"] = sickConfig.ClassName
  7177. data["dept"] = strconv.FormatInt(department.ID, 10)
  7178. data["config"] = config
  7179. data["begin_time"] = begin_time
  7180. bytesData, _ := json.Marshal(data)
  7181. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7182. resp, _ := client.Do(req)
  7183. defer resp.Body.Close()
  7184. body, ioErr := ioutil.ReadAll(resp.Body)
  7185. if ioErr != nil {
  7186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7188. return
  7189. }
  7190. var respJSON map[string]interface{}
  7191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7194. return
  7195. }
  7196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7197. userJSONBytes, _ := json.Marshal(respJSON)
  7198. fmt.Println("log")
  7199. fmt.Println(string(userJSONBytes))
  7200. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7201. utils.ErrorLog("解析失败:%v", err)
  7202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7203. return
  7204. }
  7205. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7206. data := make(map[string]interface{})
  7207. client := &http.Client{}
  7208. data["psn_no"] = his.PsnNo
  7209. data["mdtrt_id"] = his.Number
  7210. data["doctor"] = roles.UserName
  7211. data["department"] = department.Name
  7212. data["org_name"] = miConfig.OrgName
  7213. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7214. data["doctor_id"] = doctor_info.DoctorNumber
  7215. data["new_doctor_name"] = doctor_info.UserName
  7216. data["fixmedins_code"] = miConfig.Code
  7217. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7218. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7219. data["secret_key"] = miConfig.SecretKey
  7220. data["sick_code"] = sickConfig.CountryCode
  7221. data["sick_name"] = sickConfig.ClassName
  7222. data["url"] = miConfig.Url
  7223. data["ak"] = miConfig.AccessKey
  7224. data["begin_time"] = begin_time
  7225. data["cainfo"] = miConfig.Cainfo
  7226. data["dept"] = strconv.FormatInt(department.ID, 10)
  7227. data["config"] = config
  7228. bytesData, _ := json.Marshal(data)
  7229. var req *http.Request
  7230. if miConfig.MdtrtareaAdmvs == "320921" {
  7231. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7232. //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 +
  7233. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7234. } else {
  7235. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7236. }
  7237. resp, _ := client.Do(req)
  7238. defer resp.Body.Close()
  7239. body, ioErr := ioutil.ReadAll(resp.Body)
  7240. if ioErr != nil {
  7241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. return
  7244. }
  7245. var respJSON map[string]interface{}
  7246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7252. userJSONBytes, _ := json.Marshal(respJSON)
  7253. fmt.Println("log")
  7254. fmt.Println(string(userJSONBytes))
  7255. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7256. utils.ErrorLog("解析失败:%v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7261. res2.Output = ressix10265.Output
  7262. res2.ErrMsg = ressix10265.ErrMsg
  7263. res2.Cainfo = ressix10265.Cainfo
  7264. res2.WarnMsg = ressix10265.WarnMsg
  7265. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7266. res2.Infcode = infocode
  7267. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7268. 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)
  7269. saveLog(result, requestLog, "2203", "上传就诊信息")
  7270. var respJSON2 map[string]interface{}
  7271. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7274. return
  7275. }
  7276. userJSONBytes2, _ := json.Marshal(respJSON2)
  7277. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7278. utils.ErrorLog("解析失败:%v", err)
  7279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7280. return
  7281. }
  7282. } else {
  7283. if miConfig.MdtrtareaAdmvs == "440781" { //
  7284. 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)
  7285. } else {
  7286. if miConfig.Code == "H15049901371" {
  7287. //赤峰地区国家医保医疗类别
  7288. //职工透析:医疗类别选特殊情况门诊990502
  7289. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7290. var med_type string
  7291. if his.Insutype == "390" {
  7292. if reg_type == 14 {
  7293. med_type = "9933"
  7294. } else if reg_type == 11 {
  7295. med_type = "11"
  7296. }
  7297. } else if his.Insutype == "310" {
  7298. if reg_type == 14 {
  7299. med_type = "990502"
  7300. } else if reg_type == 11 {
  7301. med_type = "11"
  7302. }
  7303. }
  7304. 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)
  7305. } else {
  7306. 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)
  7307. }
  7308. }
  7309. saveLog(result, requestLog, "2203", "上传就诊信息")
  7310. var respJSON2 map[string]interface{}
  7311. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7314. return
  7315. }
  7316. userJSONBytes2, _ := json.Marshal(respJSON2)
  7317. if miConfig.Code == "H15049901371" {
  7318. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7319. utils.ErrorLog("解析失败:%v", err)
  7320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7321. return
  7322. }
  7323. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7324. res2.Output = ressix10265.Output
  7325. res2.ErrMsg = ressix10265.ErrMsg
  7326. res2.Cainfo = ressix10265.Cainfo
  7327. res2.WarnMsg = ressix10265.WarnMsg
  7328. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7329. res2.Infcode = infocode
  7330. } else {
  7331. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. }
  7337. }
  7338. if res2.Infcode != 0 {
  7339. adminUser := c.GetAdminUserInfo()
  7340. errlog := &models.HisOrderError{
  7341. UserOrgId: adminUser.CurrentOrgId,
  7342. Ctime: time.Now().Unix(),
  7343. Mtime: time.Now().Unix(),
  7344. ErrMsg: res2.ErrMsg,
  7345. Status: 1,
  7346. PatientId: id,
  7347. RecordTime: recordDateTime,
  7348. Stage: 3,
  7349. }
  7350. service.CreateErrMsgLog(errlog)
  7351. c.ServeSuccessJSON(map[string]interface{}{
  7352. "failed_code": -10,
  7353. "msg": res2.ErrMsg,
  7354. })
  7355. return
  7356. } else {
  7357. his.Diagnosis = diagnosis_id
  7358. his.SickType = sickConfig.ID
  7359. //var p_type int64
  7360. //if reg_type == 1111 || reg_type == 1112 {
  7361. // p_type = 11
  7362. //
  7363. //}
  7364. his.PType = fmt.Sprintf("%d", reg_type)
  7365. service.UpdateHisPatientThree(&his)
  7366. data := make(map[string]interface{})
  7367. if settle_accounts_type == 1 { //日结
  7368. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7369. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7370. } else {
  7371. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7372. }
  7373. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7374. data["pre"] = prescriptions
  7375. } else { //月结
  7376. start_time_str := c.GetString("start_time")
  7377. end_time_str := c.GetString("end_time")
  7378. timeLayout := "2006-01-02"
  7379. loc, _ := time.LoadLocation("Local")
  7380. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7381. if err != nil {
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7383. return
  7384. }
  7385. recordStartTime := theStartTime.Unix()
  7386. start_time = recordStartTime
  7387. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7388. if err != nil {
  7389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7390. return
  7391. }
  7392. recordEndTime := theEndTime.Unix()
  7393. end_time = recordEndTime
  7394. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7395. data["pre"] = prescriptions
  7396. }
  7397. timestamp := time.Now().Unix()
  7398. tempTime := time.Unix(timestamp, 0)
  7399. timeFormat := tempTime.Format("20060102150405")
  7400. chrgBchno := rand.Intn(100000) + 10000
  7401. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7402. strconv.FormatInt(his.PatientId, 10)
  7403. client := &http.Client{}
  7404. data["psn_no"] = his.PsnNo
  7405. data["mdtrt_id"] = his.Number
  7406. data["chrg_bchno"] = chrg_bchno
  7407. data["org_name"] = miConfig.OrgName
  7408. data["doctor"] = doctor_info.UserName
  7409. data["doctor_id"] = doctor_info.DoctorNumber
  7410. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7411. data["fixmedins_code"] = miConfig.Code
  7412. data["opter"] = roles.UserName
  7413. data["dept_code"] = department.Number
  7414. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7415. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7416. data["secret_key"] = miConfig.SecretKey
  7417. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7418. data["url"] = miConfig.Url
  7419. data["ak"] = miConfig.AccessKey
  7420. data["new_doctor_name"] = patientPrescription.Doctor
  7421. data["diag_code"] = sickConfig.CountryCode
  7422. data["cainfo"] = miConfig.Cainfo
  7423. data["opter"] = roles.UserName
  7424. var ids []int64
  7425. for _, item := range prescriptions {
  7426. ids = append(ids, item.ID)
  7427. }
  7428. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7429. if config.IsOpen == 1 { //对接了医保,走医保流程
  7430. var res ResultFour
  7431. var resFour10265 ResultFour10265
  7432. if miConfig.MdtrtareaAdmvs == "421300" {
  7433. bytesData, _ := json.Marshal(data)
  7434. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7435. resp, _ := client.Do(req)
  7436. defer resp.Body.Close()
  7437. body, ioErr := ioutil.ReadAll(resp.Body)
  7438. if ioErr != nil {
  7439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7441. return
  7442. }
  7443. var respJSON map[string]interface{}
  7444. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7450. userJSONBytes, _ := json.Marshal(respJSON)
  7451. fmt.Println("log")
  7452. fmt.Println(string(userJSONBytes))
  7453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7454. utils.ErrorLog("解析失败:%v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7459. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7460. if result3101.Infcode == "0" {
  7461. if len(result3101.Output.Result) > 0 {
  7462. var errMsgs []string
  7463. for _, item := range result3101.Output.Result {
  7464. errMsgs = append(errMsgs, item.VolaCont)
  7465. }
  7466. c.ServeSuccessJSON(map[string]interface{}{
  7467. "failed_code": -10,
  7468. "msg": errMsgs,
  7469. })
  7470. return
  7471. }
  7472. }
  7473. if miConfig.MdtrtareaAdmvs == "320921" {
  7474. data["doctor_id"] = "D320923012139"
  7475. } else {
  7476. data["doctor_id"] = "D371621008686"
  7477. }
  7478. bytesData, _ := json.Marshal(data)
  7479. var req *http.Request
  7480. if miConfig.MdtrtareaAdmvs == "320921" {
  7481. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7482. } else {
  7483. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7484. }
  7485. resp, _ := client.Do(req)
  7486. defer resp.Body.Close()
  7487. body, ioErr := ioutil.ReadAll(resp.Body)
  7488. if ioErr != nil {
  7489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7491. return
  7492. }
  7493. var respJSON map[string]interface{}
  7494. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7500. userJSONBytes, _ := json.Marshal(respJSON)
  7501. fmt.Println("log")
  7502. fmt.Println(string(userJSONBytes))
  7503. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7504. utils.ErrorLog("解析失败:%v", err)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. res.InfRefmsgid = resFour10265.InfRefmsgid
  7509. res.Output = resFour10265.Output
  7510. res.ErrMsg = resFour10265.ErrMsg
  7511. res.Cainfo = resFour10265.Cainfo
  7512. res.WarnMsg = resFour10265.WarnMsg
  7513. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7514. res.Infcode = infocode
  7515. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7516. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  7517. var dat map[string]interface{}
  7518. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7519. fmt.Println(dat)
  7520. } else {
  7521. fmt.Println(err)
  7522. }
  7523. saveLog(result, request_log, "2204", "上传费用明细")
  7524. userJSONBytes, _ := json.Marshal(dat)
  7525. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7526. utils.ErrorLog("解析失败:%v", err)
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7528. return
  7529. }
  7530. res.InfRefmsgid = resFour10265.InfRefmsgid
  7531. res.Output = resFour10265.Output
  7532. res.ErrMsg = resFour10265.ErrMsg
  7533. res.Cainfo = resFour10265.Cainfo
  7534. res.WarnMsg = resFour10265.WarnMsg
  7535. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7536. res.Infcode = infocode
  7537. } else {
  7538. if miConfig.Code == "H15049901371" {
  7539. 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)
  7540. var dat map[string]interface{}
  7541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7542. fmt.Println(dat)
  7543. } else {
  7544. fmt.Println(err)
  7545. }
  7546. saveLog(result, request_log, "2204", "上传费用明细")
  7547. userJSONBytes, _ := json.Marshal(dat)
  7548. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7549. utils.ErrorLog("解析失败:%v", err)
  7550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7551. return
  7552. }
  7553. res.InfRefmsgid = resFour10265.InfRefmsgid
  7554. res.Output = resFour10265.Output
  7555. res.ErrMsg = resFour10265.ErrMsg
  7556. res.Cainfo = resFour10265.Cainfo
  7557. res.WarnMsg = resFour10265.WarnMsg
  7558. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7559. res.Infcode = infocode
  7560. } else {
  7561. 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)
  7562. var dat map[string]interface{}
  7563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7564. fmt.Println(dat)
  7565. } else {
  7566. fmt.Println(err)
  7567. }
  7568. saveLog(result, request_log, "2204", "上传费用明细")
  7569. userJSONBytes, _ := json.Marshal(dat)
  7570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7571. utils.ErrorLog("解析失败:%v", err)
  7572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7573. return
  7574. }
  7575. }
  7576. }
  7577. if res.Infcode == 0 {
  7578. order := &models.HisOrder{
  7579. UserOrgId: adminUser.CurrentOrgId,
  7580. HisPatientId: his.ID,
  7581. PatientId: his.PatientId,
  7582. SettleAccountsDate: recordDateTime,
  7583. MdtrtId: his.Number,
  7584. PsnNo: his.PsnNo,
  7585. MedType: strconv.FormatInt(reg_type, 10),
  7586. Ctime: time.Now().Unix(),
  7587. Mtime: time.Now().Unix(),
  7588. Status: 1,
  7589. Number: chrg_bchno,
  7590. Infcode: res.Infcode,
  7591. WarnMsg: res.WarnMsg,
  7592. Cainfo: res.Cainfo,
  7593. ErrMsg: res.ErrMsg,
  7594. RespondTime: res.RefmsgTime,
  7595. InfRefmsgid: res.InfRefmsgid,
  7596. OrderStatus: 1,
  7597. PayWay: pay_way,
  7598. PayPrice: pay_price,
  7599. PayCardNo: pay_card_no,
  7600. DiscountPrice: discount_price,
  7601. PreferentialPrice: preferential_price,
  7602. RealityPrice: reality_price,
  7603. FoundPrice: found_price,
  7604. MedicalInsurancePrice: medical_insurance_price,
  7605. PrivatePrice: private_price,
  7606. IsMedicineInsurance: 1,
  7607. SettleType: settle_accounts_type,
  7608. SettleStartTime: start_time,
  7609. SettleEndTime: end_time,
  7610. Creator: roles.AdminUserId,
  7611. Modify: roles.AdminUserId,
  7612. FaPiaoNumber: fapiao_number,
  7613. FaPiaoCode: fapiao_code,
  7614. PType: 2,
  7615. Diagnosis: diagnosis_id,
  7616. }
  7617. err = service.CreateOrder(order)
  7618. if err != nil {
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7620. return
  7621. }
  7622. for _, item := range res.Output.Result {
  7623. temp := strings.Split(item.FeedetlSn, "-")
  7624. var advice_id int64 = 0
  7625. var project_id int64 = 0
  7626. var types int64 = 0
  7627. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7628. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7629. if temp[1] == "1" {
  7630. advice_id = id
  7631. project_id = 0
  7632. } else if temp[1] == "2" {
  7633. advice_id = 0
  7634. project_id = id
  7635. }
  7636. if item.MedChrgitmType == "9" {
  7637. item.MedChrgitmType = "09"
  7638. }
  7639. info := &models.HisOrderInfo{
  7640. OrderNumber: order.Number,
  7641. FeedetlSn: item.FeedetlSn,
  7642. UploadDate: time.Now().Unix(),
  7643. AdviceId: advice_id,
  7644. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7645. Cnt: item.Cnt,
  7646. Pric: float64(item.Pric),
  7647. PatientId: his.PatientId,
  7648. PricUplmtAmt: item.PricUplmtAmt,
  7649. SelfpayProp: item.SelfpayProp,
  7650. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7651. OverlmtAmt: item.OverlmtAmt,
  7652. PreselfpayAmt: item.PreselfpayAmt,
  7653. BasMednFlag: item.BasMednFlag,
  7654. MedChrgitmType: item.MedChrgitmType,
  7655. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7656. Status: 1,
  7657. Memo: item.Memo,
  7658. Mtime: time.Now().Unix(),
  7659. InscpScpAmt: item.InscpScpAmt,
  7660. DrtReimFlag: item.DrtReimFlag,
  7661. Ctime: time.Now().Unix(),
  7662. ListSpItemFlag: item.ListSpItemFlag,
  7663. ChldMedcFlag: item.ChldMedcFlag,
  7664. LmtUsedFlag: item.LmtUsedFlag,
  7665. ChrgitmLv: item.ChrgitmLv,
  7666. UserOrgId: adminUser.CurrentOrgId,
  7667. HisPatientId: his.ID,
  7668. OrderId: order.ID,
  7669. ProjectId: project_id,
  7670. Type: types,
  7671. }
  7672. service.CreateOrderInfo(info)
  7673. }
  7674. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7675. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7676. var total float64
  7677. for _, item := range prescriptions {
  7678. if item.Type == 1 { //药品
  7679. for _, subItem := range item.HisDoctorAdviceInfo {
  7680. total = total + (subItem.Price * subItem.PrescribingNumber)
  7681. }
  7682. }
  7683. if item.Type == 2 { //项目
  7684. for _, subItem := range item.HisPrescriptionProject {
  7685. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7686. total = total + (subItem.Price * cnt)
  7687. }
  7688. }
  7689. }
  7690. for _, item := range prescriptions {
  7691. for _, subItem := range item.HisAdditionalCharge {
  7692. total = total + (subItem.Price * float64(subItem.Count))
  7693. }
  7694. }
  7695. var allTotal string
  7696. if adminUser.CurrentOrgId == 9919 {
  7697. allTotal = fmt.Sprintf("%.4f", total)
  7698. } else {
  7699. allTotal = fmt.Sprintf("%.4f", total)
  7700. }
  7701. if res.Infcode == 0 {
  7702. var rf []*ResultFive
  7703. json.Unmarshal([]byte(his.Iinfo), &rf)
  7704. chrg_bchno := chrg_bchno
  7705. cert_no := his.Certno
  7706. var insutypes []string
  7707. var insutype string
  7708. var is390 int = 0
  7709. var is310 int = 0
  7710. for _, item := range rf {
  7711. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7712. insutypes = append(insutypes, item.Insutype)
  7713. }
  7714. }
  7715. if len(insutypes) == 1 {
  7716. insutype = insutypes[0]
  7717. } else {
  7718. for _, i := range insutypes {
  7719. if i == "390" {
  7720. is390 = 1
  7721. }
  7722. if i == "310" {
  7723. is310 = 1
  7724. }
  7725. }
  7726. }
  7727. if is390 == 1 {
  7728. insutype = "390"
  7729. }
  7730. if is310 == 1 {
  7731. insutype = "310"
  7732. }
  7733. if len(insutypes) == 0 {
  7734. insutype = "310"
  7735. }
  7736. if len(insutypes) == 2 {
  7737. insutype = strconv.FormatInt(his.SocialType, 10)
  7738. }
  7739. insutype = strconv.FormatInt(his.SocialType, 10)
  7740. //insutype = "390"
  7741. if his.IdCardType == 1 {
  7742. // cert_no = his.MedicalInsuranceNumber
  7743. cert_no = his.Certno
  7744. } else {
  7745. cert_no = his.Certno
  7746. }
  7747. var res ResultSeven
  7748. var resSeven10265 ResultSeven10265
  7749. var src_resquest string
  7750. var result2 string
  7751. var acct_used_flag string
  7752. fmt.Println("pay_way")
  7753. fmt.Println(pay_way)
  7754. fmt.Println("pay_way")
  7755. if pay_way == 4 {
  7756. acct_used_flag = "1"
  7757. } else {
  7758. acct_used_flag = "0"
  7759. }
  7760. if miConfig.MdtrtareaAdmvs == "421300" {
  7761. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7762. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7763. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7765. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7766. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7767. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7768. resp, requestErr := http.Get(api)
  7769. if requestErr != nil {
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. body, ioErr := ioutil.ReadAll(resp.Body)
  7774. if ioErr != nil {
  7775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. var respJSON map[string]interface{}
  7780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. return
  7784. }
  7785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7786. result, _ := json.Marshal(respJSON)
  7787. if miConfig.Code == "H15049901371" {
  7788. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7789. utils.ErrorLog("解析失败:%v", err)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7794. res.Output = resSeven10265.Output
  7795. res.ErrMsg = resSeven10265.ErrMsg
  7796. res.Cainfo = resSeven10265.Cainfo
  7797. res.WarnMsg = resSeven10265.WarnMsg
  7798. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7799. res.Infcode = infocode
  7800. } else {
  7801. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7802. utils.ErrorLog("解析失败:%v", err)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. }
  7807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7808. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7809. if result3101.Infcode == "0" {
  7810. if len(result3101.Output.Result) > 0 {
  7811. var errMsgs []string
  7812. for _, item := range result3101.Output.Result {
  7813. errMsgs = append(errMsgs, item.VolaCont)
  7814. }
  7815. c.ServeSuccessJSON(map[string]interface{}{
  7816. "failed_code": -10,
  7817. "msg": errMsgs,
  7818. })
  7819. return
  7820. } else {
  7821. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7822. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7823. bas := strings.Split(psn_info.CardInfo, "|")
  7824. if his.IdCardType == 1 {
  7825. cert_no = bas[2]
  7826. } else if his.IdCardType == 3 {
  7827. cert_no = his.Certno
  7828. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7829. } else if his.IdCardType == 4 {
  7830. cert_no = his.Certno
  7831. psn_info.VerifyNumber = psn_info.VerifyNumber
  7832. }
  7833. var api string
  7834. if miConfig.MdtrtareaAdmvs == "320921" {
  7835. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7836. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7837. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7838. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7839. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7840. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7841. "&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
  7842. } else {
  7843. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7844. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7845. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7847. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7848. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7849. "&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
  7850. }
  7851. resp, requestErr := http.Get(api)
  7852. if requestErr != nil {
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. body, ioErr := ioutil.ReadAll(resp.Body)
  7857. if ioErr != nil {
  7858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. var respJSON map[string]interface{}
  7863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7869. result, _ := json.Marshal(respJSON)
  7870. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7871. utils.ErrorLog("解析失败:%v", err)
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7876. res.Output = resSeven10265.Output
  7877. res.ErrMsg = resSeven10265.ErrMsg
  7878. res.Cainfo = resSeven10265.Cainfo
  7879. res.WarnMsg = resSeven10265.WarnMsg
  7880. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7881. res.Infcode = infocode
  7882. }
  7883. }
  7884. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7885. var cert_no string
  7886. if his.IdCardType == 4 {
  7887. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7888. cert_no = psn_info.VerifyNumber
  7889. 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)
  7890. } else if his.IdCardType == 1 {
  7891. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7892. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7893. 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)
  7894. }
  7895. //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)
  7896. var dat map[string]interface{}
  7897. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7898. fmt.Println(dat)
  7899. } else {
  7900. fmt.Println(err)
  7901. }
  7902. saveLog(result2, src_resquest, "2207", "结算")
  7903. userJSONBytes, _ := json.Marshal(dat)
  7904. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7910. res.Output = resSeven10265.Output
  7911. res.ErrMsg = resSeven10265.ErrMsg
  7912. res.Cainfo = resSeven10265.Cainfo
  7913. res.WarnMsg = resSeven10265.WarnMsg
  7914. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7915. res.Infcode = infocode
  7916. } else {
  7917. if miConfig.Code == "H15049901371" {
  7918. //赤峰地区国家医保医疗类别
  7919. //职工透析:医疗类别选特殊情况门诊990502
  7920. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7921. var med_type string
  7922. if his.Insutype == "390" {
  7923. if reg_type == 14 {
  7924. med_type = "9933"
  7925. } else if reg_type == 11 {
  7926. med_type = "11"
  7927. }
  7928. } else if his.Insutype == "310" {
  7929. if reg_type == 14 {
  7930. med_type = "990502"
  7931. } else if reg_type == 11 {
  7932. med_type = "11"
  7933. }
  7934. }
  7935. 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, "")
  7936. } else {
  7937. if his.IdCardType == 4 {
  7938. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7939. var token string
  7940. token = psn_info.VerifyNumber
  7941. 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)
  7942. } else {
  7943. 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, "")
  7944. }
  7945. }
  7946. //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)
  7947. var dat map[string]interface{}
  7948. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7949. fmt.Println(dat)
  7950. } else {
  7951. fmt.Println(err)
  7952. }
  7953. saveLog(result2, src_resquest, "2207", "结算")
  7954. userJSONBytes, _ := json.Marshal(dat)
  7955. if miConfig.Code == "H15049901371" {
  7956. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7957. utils.ErrorLog("解析失败:%v", err)
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7959. return
  7960. }
  7961. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7962. res.Output = resSeven10265.Output
  7963. res.ErrMsg = resSeven10265.ErrMsg
  7964. res.Cainfo = resSeven10265.Cainfo
  7965. res.WarnMsg = resSeven10265.WarnMsg
  7966. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7967. res.Infcode = infocode
  7968. } else {
  7969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7970. utils.ErrorLog("解析失败:%v", err)
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. }
  7975. }
  7976. if res.Infcode != 0 {
  7977. errlog := &models.HisOrderError{
  7978. UserOrgId: adminUser.CurrentOrgId,
  7979. Ctime: time.Now().Unix(),
  7980. Mtime: time.Now().Unix(),
  7981. Number: chrg_bchno,
  7982. ErrMsg: res.ErrMsg,
  7983. Status: 1,
  7984. PatientId: id,
  7985. RecordTime: recordDateTime,
  7986. Stage: 6,
  7987. }
  7988. service.CreateErrMsgLog(errlog)
  7989. c.ServeSuccessJSON(map[string]interface{}{
  7990. "failed_code": -10,
  7991. "msg": res.ErrMsg,
  7992. })
  7993. return
  7994. } else {
  7995. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7996. order.OrderStatus = 2
  7997. order.Status = 1
  7998. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7999. order.SetlId = res.Output.Setlinfo.SetlID
  8000. order.PsnNo = res.Output.Setlinfo.PsnNo
  8001. order.PsnName = res.Output.Setlinfo.PsnName
  8002. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8003. order.Certno = res.Output.Setlinfo.Certno
  8004. order.Gend = res.Output.Setlinfo.Gend
  8005. order.Naty = res.Output.Setlinfo.Naty
  8006. order.Age = res.Output.Setlinfo.Age
  8007. order.Insutype = res.Output.Setlinfo.Insutype
  8008. order.PsnType = res.Output.Setlinfo.PsnType
  8009. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8010. order.SetlTime = res.Output.Setlinfo.SetlTime
  8011. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8012. if res.Output.Setlinfo.MedType == "140101" {
  8013. order.MedType = "14"
  8014. } else {
  8015. order.MedType = res.Output.Setlinfo.MedType
  8016. }
  8017. if reg_type == 1112 {
  8018. order.MedType = "1112"
  8019. }
  8020. if reg_type == 1111 {
  8021. order.MedType = "1111"
  8022. }
  8023. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8024. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8025. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8026. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8027. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8028. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8029. order.HifpPay = res.Output.Setlinfo.HifpPay
  8030. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8031. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8032. order.HifesPay = res.Output.Setlinfo.HifesPay
  8033. order.HifobPay = res.Output.Setlinfo.HifobPay
  8034. order.MafPay = res.Output.Setlinfo.MafPay
  8035. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8036. order.OthPay = res.Output.Setlinfo.OthPay
  8037. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8038. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8039. order.AcctPay = res.Output.Setlinfo.AcctPay
  8040. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8041. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8042. order.Balc = res.Output.Setlinfo.Balc
  8043. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8044. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8045. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8046. order.ClrType = res.Output.Setlinfo.ClrType
  8047. order.ClrWay = res.Output.Setlinfo.ClrWay
  8048. order.Creator = order.Creator
  8049. order.Modify = roles.AdminUserId
  8050. order.RequestLog = src_resquest
  8051. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8052. detailStr := string(setlDetail)
  8053. order.SetlDetail = detailStr
  8054. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8055. err = service.UpDateOrder(order)
  8056. if err == nil {
  8057. //判断是否使用了押金
  8058. if dec_way == "true" {
  8059. tmpstring := strconv.FormatInt(order.ID, 10)
  8060. order.Decimal = decimal
  8061. service.UpDateOrder(order)
  8062. //扣押金
  8063. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8064. if errmsg != nil {
  8065. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8066. return
  8067. }
  8068. }
  8069. c.ServeSuccessJSON(map[string]interface{}{
  8070. "msg": "结算成功",
  8071. })
  8072. } else {
  8073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8074. return
  8075. }
  8076. }
  8077. } else {
  8078. adminUser := c.GetAdminUserInfo()
  8079. errlog := &models.HisOrderError{
  8080. UserOrgId: adminUser.CurrentOrgId,
  8081. Ctime: time.Now().Unix(),
  8082. Mtime: time.Now().Unix(),
  8083. ErrMsg: res.ErrMsg,
  8084. Status: 1,
  8085. PatientId: id,
  8086. RecordTime: recordDateTime,
  8087. Stage: 4,
  8088. }
  8089. service.CreateErrMsgLog(errlog)
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8091. return
  8092. }
  8093. } else {
  8094. adminUser := c.GetAdminUserInfo()
  8095. errlog := &models.HisOrderError{
  8096. UserOrgId: adminUser.CurrentOrgId,
  8097. Ctime: time.Now().Unix(),
  8098. Mtime: time.Now().Unix(),
  8099. ErrMsg: res.ErrMsg,
  8100. Status: 1,
  8101. PatientId: id,
  8102. RecordTime: recordDateTime,
  8103. Stage: 4,
  8104. }
  8105. service.CreateErrMsgLog(errlog)
  8106. c.ServeSuccessJSON(map[string]interface{}{
  8107. "failed_code": -10,
  8108. "msg": res.ErrMsg,
  8109. })
  8110. return
  8111. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8112. //return
  8113. }
  8114. }
  8115. }
  8116. } else if tempOrder.ID > 0 {
  8117. if tempOrder.IsPre == 1 {
  8118. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8119. var rf []*ResultFive
  8120. json.Unmarshal([]byte(his.Iinfo), &rf)
  8121. chrg_bchno := tempOrder.Number
  8122. cert_no := his.Certno
  8123. var insutypes []string
  8124. var insutype string
  8125. var is390 int = 0
  8126. var is310 int = 0
  8127. for _, item := range rf {
  8128. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8129. insutypes = append(insutypes, item.Insutype)
  8130. }
  8131. }
  8132. if len(insutypes) == 1 {
  8133. insutype = insutypes[0]
  8134. } else {
  8135. for _, i := range insutypes {
  8136. if i == "390" {
  8137. is390 = 1
  8138. }
  8139. if i == "310" {
  8140. is310 = 1
  8141. }
  8142. }
  8143. }
  8144. if is390 == 1 {
  8145. insutype = "390"
  8146. }
  8147. if is310 == 1 {
  8148. insutype = "310"
  8149. }
  8150. if len(insutypes) == 0 {
  8151. insutype = "310"
  8152. }
  8153. if len(insutypes) == 2 {
  8154. insutype = strconv.FormatInt(his.SocialType, 64)
  8155. }
  8156. //insutype = "390"
  8157. if his.IdCardType == 1 {
  8158. // cert_no = his.MedicalInsuranceNumber
  8159. cert_no = his.Certno
  8160. } else {
  8161. cert_no = his.Certno
  8162. }
  8163. var res ResultSeven
  8164. var resSeven10265 ResultSeven10265
  8165. var src_resquest string
  8166. var result2 string
  8167. var acct_used_flag string
  8168. fmt.Println("pay_way")
  8169. fmt.Println(pay_way)
  8170. fmt.Println("pay_way")
  8171. if pay_way == 4 {
  8172. acct_used_flag = "1"
  8173. } else {
  8174. acct_used_flag = "0"
  8175. }
  8176. if miConfig.MdtrtareaAdmvs == "421300" {
  8177. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8178. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8179. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8181. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8182. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8183. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8184. resp, requestErr := http.Get(api)
  8185. if requestErr != nil {
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8187. return
  8188. }
  8189. body, ioErr := ioutil.ReadAll(resp.Body)
  8190. if ioErr != nil {
  8191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8193. return
  8194. }
  8195. var respJSON map[string]interface{}
  8196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8202. result, _ := json.Marshal(respJSON)
  8203. fmt.Println("log")
  8204. fmt.Println(string(result))
  8205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8206. utils.ErrorLog("解析失败:%v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8211. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8212. if result3101.Infcode == "0" {
  8213. if len(result3101.Output.Result) > 0 {
  8214. var errMsgs []string
  8215. for _, item := range result3101.Output.Result {
  8216. errMsgs = append(errMsgs, item.VolaCont)
  8217. }
  8218. c.ServeSuccessJSON(map[string]interface{}{
  8219. "failed_code": -10,
  8220. "msg": errMsgs,
  8221. })
  8222. return
  8223. } else {
  8224. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8225. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8226. bas := strings.Split(psn_info.CardInfo, "|")
  8227. if his.IdCardType == 1 {
  8228. cert_no = bas[2]
  8229. } else if his.IdCardType == 3 {
  8230. cert_no = his.Certno
  8231. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8232. } else if his.IdCardType == 4 {
  8233. cert_no = his.Certno
  8234. psn_info.VerifyNumber = psn_info.VerifyNumber
  8235. }
  8236. //江苏地区国家医保医疗类别
  8237. //职工透析:医疗类别选特殊情况门诊9933
  8238. //居民血透门慢: 医疗类别选门诊慢病1402
  8239. //var med_type string
  8240. //if his.Insutype == "310" {
  8241. // if reg_type == 14 {
  8242. // med_type = "9933"
  8243. // } else if reg_type == 11 {
  8244. // med_type = "11"
  8245. //
  8246. // }
  8247. //} else if his.Insutype == "390" {
  8248. // if reg_type == 14 {
  8249. // med_type = "1402"
  8250. // } else if reg_type == 11 {
  8251. // med_type = "11"
  8252. // }
  8253. //}
  8254. var api string
  8255. if miConfig.MdtrtareaAdmvs == "320921" {
  8256. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8257. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8262. "&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
  8263. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8264. } else {
  8265. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8266. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8267. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8268. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8270. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8271. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8272. "&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
  8273. }
  8274. resp, requestErr := http.Get(api)
  8275. if requestErr != nil {
  8276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. return
  8278. }
  8279. body, ioErr := ioutil.ReadAll(resp.Body)
  8280. if ioErr != nil {
  8281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8283. return
  8284. }
  8285. var respJSON map[string]interface{}
  8286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8292. result, _ := json.Marshal(respJSON)
  8293. fmt.Println("log")
  8294. fmt.Println(string(result))
  8295. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8296. utils.ErrorLog("解析失败:%v", err)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8301. res.Output = resSeven10265.Output
  8302. res.ErrMsg = resSeven10265.ErrMsg
  8303. res.Cainfo = resSeven10265.Cainfo
  8304. res.WarnMsg = resSeven10265.WarnMsg
  8305. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8306. res.Infcode = infocode
  8307. }
  8308. }
  8309. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8310. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8311. var cert_no string
  8312. if his.IdCardType == 1 {
  8313. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8314. } else {
  8315. cert_no = psn_info.VerifyNumber
  8316. }
  8317. 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)
  8318. var dat map[string]interface{}
  8319. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8320. fmt.Println(dat)
  8321. } else {
  8322. fmt.Println(err)
  8323. }
  8324. saveLog(result2, src_resquest, "2207", "结算")
  8325. userJSONBytes, _ := json.Marshal(dat)
  8326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8327. utils.ErrorLog("解析失败:%v", err)
  8328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8329. return
  8330. }
  8331. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8332. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8333. var cert_no string
  8334. if his.IdCardType == 1 {
  8335. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8336. } else if his.IdCardType == 2 {
  8337. cert_no = his.IdCardNo
  8338. } else {
  8339. cert_no = psn_info.VerifyNumber
  8340. }
  8341. 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, "")
  8342. var dat map[string]interface{}
  8343. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8344. fmt.Println(dat)
  8345. } else {
  8346. fmt.Println(err)
  8347. }
  8348. saveLog(result2, src_resquest, "2207", "结算")
  8349. userJSONBytes, _ := json.Marshal(dat)
  8350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8351. utils.ErrorLog("解析失败:%v", err)
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8356. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8357. var cert_no string
  8358. if his.IdCardType == 1 {
  8359. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8360. } else if his.IdCardType == 2 {
  8361. cert_no = his.IdCardNo
  8362. } else {
  8363. cert_no = psn_info.VerifyNumber
  8364. }
  8365. 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, "")
  8366. var dat map[string]interface{}
  8367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8368. fmt.Println(dat)
  8369. } else {
  8370. fmt.Println(err)
  8371. }
  8372. saveLog(result2, src_resquest, "2207", "结算")
  8373. userJSONBytes, _ := json.Marshal(dat)
  8374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8375. utils.ErrorLog("解析失败:%v", err)
  8376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8377. return
  8378. }
  8379. } else {
  8380. var src_resquest string
  8381. if miConfig.Code == "H15049901371" {
  8382. //赤峰地区国家医保医疗类别
  8383. //职工透析:医疗类别选特殊情况门诊990502
  8384. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8385. var med_type string
  8386. if his.Insutype == "390" {
  8387. if reg_type == 14 {
  8388. med_type = "9933"
  8389. } else if reg_type == 11 {
  8390. med_type = "11"
  8391. }
  8392. } else if his.Insutype == "310" {
  8393. if reg_type == 14 {
  8394. med_type = "990502"
  8395. } else if reg_type == 11 {
  8396. med_type = "11"
  8397. }
  8398. }
  8399. 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, "")
  8400. } else {
  8401. if his.IdCardType == 4 {
  8402. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8403. token := psn_info.VerifyNumber
  8404. 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)
  8405. } else {
  8406. 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, "")
  8407. }
  8408. }
  8409. var dat map[string]interface{}
  8410. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8411. fmt.Println(dat)
  8412. } else {
  8413. fmt.Println(err)
  8414. }
  8415. saveLog(result2, src_resquest, "2207", "结算")
  8416. userJSONBytes, _ := json.Marshal(dat)
  8417. if miConfig.Code == "H15049901371" {
  8418. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8419. utils.ErrorLog("解析失败:%v", err)
  8420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8421. return
  8422. }
  8423. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8424. res.Output = resSeven10265.Output
  8425. res.ErrMsg = resSeven10265.ErrMsg
  8426. res.Cainfo = resSeven10265.Cainfo
  8427. res.WarnMsg = resSeven10265.WarnMsg
  8428. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8429. res.Infcode = infocode
  8430. } else {
  8431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. }
  8437. }
  8438. if res.Infcode != 0 {
  8439. errlog := &models.HisOrderError{
  8440. UserOrgId: adminUser.CurrentOrgId,
  8441. Ctime: time.Now().Unix(),
  8442. Mtime: time.Now().Unix(),
  8443. Number: chrg_bchno,
  8444. ErrMsg: res.ErrMsg,
  8445. Status: 1,
  8446. PatientId: id,
  8447. RecordTime: recordDateTime,
  8448. Stage: 6,
  8449. }
  8450. service.CreateErrMsgLog(errlog)
  8451. c.ServeSuccessJSON(map[string]interface{}{
  8452. "failed_code": -10,
  8453. "msg": res.ErrMsg,
  8454. })
  8455. return
  8456. } else {
  8457. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8458. order.OrderStatus = 2
  8459. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8460. order.SetlId = res.Output.Setlinfo.SetlID
  8461. order.PsnNo = res.Output.Setlinfo.PsnNo
  8462. order.PsnName = res.Output.Setlinfo.PsnName
  8463. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8464. order.Certno = res.Output.Setlinfo.Certno
  8465. order.Gend = res.Output.Setlinfo.Gend
  8466. order.Naty = res.Output.Setlinfo.Naty
  8467. order.Age = res.Output.Setlinfo.Age
  8468. order.Insutype = res.Output.Setlinfo.Insutype
  8469. order.PsnType = res.Output.Setlinfo.PsnType
  8470. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8471. order.SetlTime = res.Output.Setlinfo.SetlTime
  8472. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8473. //order.MedType = res.Output.Setlinfo.MedType
  8474. if reg_type == 1112 {
  8475. order.MedType = "1112"
  8476. }
  8477. if reg_type == 1111 {
  8478. order.MedType = "1111"
  8479. }
  8480. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8481. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8482. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8483. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8484. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8485. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8486. order.HifpPay = res.Output.Setlinfo.HifpPay
  8487. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8488. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8489. order.HifesPay = res.Output.Setlinfo.HifesPay
  8490. order.HifobPay = res.Output.Setlinfo.HifobPay
  8491. order.MafPay = res.Output.Setlinfo.MafPay
  8492. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8493. order.OthPay = res.Output.Setlinfo.OthPay
  8494. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8495. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8496. order.AcctPay = res.Output.Setlinfo.AcctPay
  8497. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8498. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8499. order.Balc = res.Output.Setlinfo.Balc
  8500. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8501. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8502. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8503. order.ClrWay = res.Output.Setlinfo.ClrWay
  8504. order.Creator = order.Creator
  8505. order.Modify = roles.AdminUserId
  8506. order.RequestLog = src_resquest
  8507. order.Diagnosis = diagnosis_id
  8508. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8509. detailStr := string(setlDetail)
  8510. order.SetlDetail = detailStr
  8511. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8512. err = service.UpDateOrder(order)
  8513. if err == nil {
  8514. //判断是否使用了押金
  8515. if dec_way == "true" {
  8516. tmpstring := strconv.FormatInt(order.ID, 10)
  8517. //扣押金
  8518. order.Decimal = decimal
  8519. service.UpDateOrder(order)
  8520. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8521. if errmsg != nil {
  8522. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8523. return
  8524. }
  8525. }
  8526. c.ServeSuccessJSON(map[string]interface{}{
  8527. "msg": "结算成功",
  8528. })
  8529. } else {
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8531. return
  8532. }
  8533. }
  8534. }
  8535. }
  8536. }
  8537. //func (c *HisApiController) GetPreUploadInfo() {
  8538. // id, _ := c.GetInt64("id")
  8539. // record_time := c.GetString("record_time")
  8540. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8541. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8542. //
  8543. // timeLayout := "2006-01-02"
  8544. // loc, _ := time.LoadLocation("Local")
  8545. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8546. // if err != nil {
  8547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8548. // return
  8549. // }
  8550. // recordDateTime := theTime.Unix()
  8551. // adminUser := c.GetAdminUserInfo()
  8552. //
  8553. // var prescriptions []*models.HisPrescription
  8554. //
  8555. // var start_time int64
  8556. // var end_time int64
  8557. //
  8558. // data := make(map[string]interface{})
  8559. // if settle_accounts_type == 1 { //日结
  8560. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8561. // data["pre"] = prescriptions
  8562. //
  8563. // } else { //月结
  8564. // start_time_str := c.GetString("start_time")
  8565. // end_time_str := c.GetString("end_time")
  8566. // timeLayout := "2006-01-02"
  8567. // loc, _ := time.LoadLocation("Local")
  8568. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8569. // if err != nil {
  8570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8571. // return
  8572. // }
  8573. // recordStartTime := theStartTime.Unix()
  8574. // start_time = recordStartTime
  8575. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8576. // if err != nil {
  8577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8578. // return
  8579. // }
  8580. // recordEndTime := theEndTime.Unix()
  8581. // end_time = recordEndTime
  8582. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8583. // data["pre"] = prescriptions
  8584. //
  8585. // }
  8586. //
  8587. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8588. //
  8589. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8590. // timestamp := time.Now().Unix()
  8591. // tempTime := time.Unix(timestamp, 0)
  8592. // timeFormat := tempTime.Format("20060102150405")
  8593. // chrgBchno := rand.Intn(100000) + 10000
  8594. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8595. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8596. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8597. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8598. // strconv.FormatInt(his.PatientId, 10)
  8599. // client := &http.Client{}
  8600. // data["psn_no"] = his.PsnNo
  8601. // data["mdtrt_id"] = his.Number
  8602. // data["chrg_bchno"] = chrg_bchno
  8603. // data["org_name"] = miConfig.OrgName
  8604. // data["doctor"] = roles.UserName
  8605. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8606. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8607. // data["fixmedins_code"] = miConfig.Code
  8608. // data["dept_code"] = department.Number
  8609. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8610. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8611. // data["secret_key"] = miConfig.SecretKey
  8612. // var ids []int64
  8613. //
  8614. // for _, item := range prescriptions {
  8615. // ids = append(ids, item.ID)
  8616. // }
  8617. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8618. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8619. // bytesData, _ := json.Marshal(data)
  8620. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8621. // resp, _ := client.Do(req)
  8622. // defer resp.Body.Close()
  8623. // body, ioErr := ioutil.ReadAll(resp.Body)
  8624. // if ioErr != nil {
  8625. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. // return
  8628. // }
  8629. // var respJSON map[string]interface{}
  8630. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8631. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. // return
  8634. // }
  8635. //
  8636. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8637. // userJSONBytes, _ := json.Marshal(respJSON)
  8638. // var res ResultFour
  8639. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8640. // utils.ErrorLog("解析失败:%v", err)
  8641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. // return
  8643. // }
  8644. //
  8645. // if res.Infcode == 0 {
  8646. // order := &models.HisOrder{
  8647. // UserOrgId: adminUser.CurrentOrgId,
  8648. // HisPatientId: his.ID,
  8649. // PatientId: his.PatientId,
  8650. // SettleAccountsDate: recordDateTime,
  8651. // Ctime: time.Now().Unix(),
  8652. // Mtime: time.Now().Unix(),
  8653. // Status: 1,
  8654. // Number: chrg_bchno,
  8655. // Infcode: res.Infcode,
  8656. // WarnMsg: res.WarnMsg,
  8657. // Cainfo: res.Cainfo,
  8658. // ErrMsg: res.ErrMsg,
  8659. // RespondTime: res.RefmsgTime,
  8660. // InfRefmsgid: res.InfRefmsgid,
  8661. // OrderStatus: 1,
  8662. // IsMedicineInsurance: 1,
  8663. // SettleType: settle_accounts_type,
  8664. // SettleStartTime: start_time,
  8665. // SettleEndTime: end_time,
  8666. // Creator: roles.ID,
  8667. // Modify: roles.ID,
  8668. // PType: 2,
  8669. // }
  8670. // err = service.CreateOrder(order)
  8671. // if err != nil {
  8672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8673. // return
  8674. // }
  8675. //
  8676. // for _, item := range res.Output.Result {
  8677. // temp := strings.Split(item.FeedetlSn, "-")
  8678. // var advice_id int64 = 0
  8679. // var project_id int64 = 0
  8680. // var types int64 = 0
  8681. //
  8682. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8683. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8684. //
  8685. // if temp[1] == "1" {
  8686. // advice_id = id
  8687. // project_id = 0
  8688. // } else if temp[1] == "2" {
  8689. // advice_id = 0
  8690. // project_id = id
  8691. // }
  8692. //
  8693. // info := &models.HisOrderInfo{
  8694. // OrderNumber: order.Number,
  8695. // FeedetlSn: item.FeedetlSn,
  8696. // UploadDate: time.Now().Unix(),
  8697. // AdviceId: advice_id,
  8698. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8699. // Cnt: item.Cnt,
  8700. // Pric: float64(item.Pric),
  8701. // PatientId: his.PatientId,
  8702. // PricUplmtAmt: item.PricUplmtAmt,
  8703. // SelfpayProp: item.SelfpayProp,
  8704. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8705. // OverlmtAmt: item.OverlmtAmt,
  8706. // PreselfpayAmt: item.PreselfpayAmt,
  8707. // BasMednFlag: item.BasMednFlag,
  8708. // MedChrgitmType: item.MedChrgitmType,
  8709. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8710. // Status: 1,
  8711. // Memo: item.Memo,
  8712. // Mtime: time.Now().Unix(),
  8713. // InscpScpAmt: item.InscpScpAmt,
  8714. // DrtReimFlag: item.DrtReimFlag,
  8715. // Ctime: time.Now().Unix(),
  8716. // ListSpItemFlag: item.ListSpItemFlag,
  8717. // ChldMedcFlag: item.ChldMedcFlag,
  8718. // LmtUsedFlag: item.LmtUsedFlag,
  8719. // ChrgitmLv: item.ChrgitmLv,
  8720. // UserOrgId: adminUser.CurrentOrgId,
  8721. // HisPatientId: his.ID,
  8722. // OrderId: order.ID,
  8723. // ProjectId: project_id,
  8724. // Type: types,
  8725. // }
  8726. // service.CreateOrderInfo(info)
  8727. //
  8728. // }
  8729. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8730. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8731. //
  8732. // var total float64
  8733. // for _, item := range prescriptions {
  8734. // if item.Type == 1 { //药品
  8735. // for _, subItem := range item.HisDoctorAdviceInfo {
  8736. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8737. // }
  8738. // }
  8739. // if item.Type == 2 { //项目
  8740. // for _, subItem := range item.HisPrescriptionProject {
  8741. // total = total + (subItem.Price * float64(subItem.Count))
  8742. // }
  8743. // }
  8744. // }
  8745. //
  8746. // for _, item := range prescriptions {
  8747. // for _, subItem := range item.HisAdditionalCharge {
  8748. // total = total + (subItem.Price * float64(subItem.Count))
  8749. // }
  8750. // }
  8751. //
  8752. // allTotal := fmt.Sprintf("%.2f", total)
  8753. // if res.Infcode == 0 {
  8754. // var rf []*ResultFive
  8755. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8756. // psn_no := his.PsnNo
  8757. // mdtrt_id := his.Number
  8758. // chrg_bchno := chrg_bchno
  8759. // cert_no := his.Certno
  8760. // insutype := rf[0].Insutype
  8761. //
  8762. // if his.IdCardType == 1 {
  8763. // cert_no = his.MedicalInsuranceNumber
  8764. //
  8765. // } else {
  8766. //
  8767. // cert_no = his.Certno
  8768. //
  8769. // }
  8770. //
  8771. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8772. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8773. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8774. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8775. // resp, requestErr := http.Get(api)
  8776. // if requestErr != nil {
  8777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. // return
  8779. // }
  8780. // defer resp.Body.Close()
  8781. // body, ioErr := ioutil.ReadAll(resp.Body)
  8782. // if ioErr != nil {
  8783. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8785. // return
  8786. // }
  8787. // var respJSON map[string]interface{}
  8788. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8789. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. // return
  8792. // }
  8793. // fmt.Println(respJSON)
  8794. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8795. // userJSONBytes, _ := json.Marshal(respJSON)
  8796. // var res ResultSeven
  8797. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8798. // utils.ErrorLog("解析失败:%v", err)
  8799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8800. // return
  8801. // }
  8802. // if res.Infcode != 0 {
  8803. // errlog := &models.HisOrderError{
  8804. // UserOrgId: adminUser.CurrentOrgId,
  8805. // Ctime: time.Now().Unix(),
  8806. // Mtime: time.Now().Unix(),
  8807. // Number: chrg_bchno,
  8808. // ErrMsg: res.ErrMsg,
  8809. // Status: 1,
  8810. // PatientId: id,
  8811. // RecordTime: recordDateTime,
  8812. // Stage: 7,
  8813. // }
  8814. // service.CreateErrMsgLog(errlog)
  8815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8816. // return
  8817. // } else {
  8818. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8819. // order.OrderStatus = 1
  8820. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8821. // order.SetlId = res.Output.Setlinfo.SetlID
  8822. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8823. // order.PsnName = res.Output.Setlinfo.PsnName
  8824. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8825. // order.Certno = res.Output.Setlinfo.Certno
  8826. // order.Gend = res.Output.Setlinfo.Gend
  8827. // order.Naty = res.Output.Setlinfo.Naty
  8828. // order.Age = res.Output.Setlinfo.Age
  8829. // order.Insutype = res.Output.Setlinfo.Insutype
  8830. // order.PsnType = res.Output.Setlinfo.PsnType
  8831. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8832. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8833. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8834. // order.MedType = res.Output.Setlinfo.MedType
  8835. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8836. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8837. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8838. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8839. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8840. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8841. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8842. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8843. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8844. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8845. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8846. // order.MafPay = res.Output.Setlinfo.MafPay
  8847. // order.OthPay = res.Output.Setlinfo.OthPay
  8848. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8849. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8850. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8851. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8852. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8853. // order.Balc = res.Output.Setlinfo.Balc
  8854. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8855. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8856. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8857. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8858. // order.Creator = order.Creator
  8859. // order.Modify = roles.ID
  8860. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8861. // detailStr := string(setlDetail)
  8862. // order.SetlDetail = detailStr
  8863. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8864. // err = service.UpDateOrder(order)
  8865. // if err == nil {
  8866. // c.ServeSuccessJSON(map[string]interface{}{
  8867. // "msg": "预结算成功",
  8868. // })
  8869. // } else {
  8870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8871. // return
  8872. // }
  8873. // }
  8874. // } else {
  8875. // adminUser := c.GetAdminUserInfo()
  8876. // errlog := &models.HisOrderError{
  8877. // UserOrgId: adminUser.CurrentOrgId,
  8878. // Ctime: time.Now().Unix(),
  8879. // Mtime: time.Now().Unix(),
  8880. // ErrMsg: res.ErrMsg,
  8881. // Status: 1,
  8882. // PatientId: id,
  8883. // RecordTime: recordDateTime,
  8884. // Stage: 4,
  8885. // }
  8886. // service.CreateErrMsgLog(errlog)
  8887. //
  8888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8889. // return
  8890. // }
  8891. // } else {
  8892. // adminUser := c.GetAdminUserInfo()
  8893. // errlog := &models.HisOrderError{
  8894. // UserOrgId: adminUser.CurrentOrgId,
  8895. // Ctime: time.Now().Unix(),
  8896. // Mtime: time.Now().Unix(),
  8897. // ErrMsg: res.ErrMsg,
  8898. // Status: 1,
  8899. // PatientId: id,
  8900. // RecordTime: recordDateTime,
  8901. // Stage: 4,
  8902. // }
  8903. // service.CreateErrMsgLog(errlog)
  8904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8905. // return
  8906. // }
  8907. //
  8908. // } else {
  8909. // var total float64
  8910. // for _, item := range prescriptions {
  8911. // if item.Type == 1 { //药品
  8912. // for _, subItem := range item.HisDoctorAdviceInfo {
  8913. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8914. // }
  8915. // }
  8916. // if item.Type == 2 { //项目
  8917. // for _, subItem := range item.HisPrescriptionProject {
  8918. // total = total + (subItem.Price * float64(subItem.Count))
  8919. // }
  8920. // }
  8921. //
  8922. // for _, subItem := range item.HisAdditionalCharge {
  8923. // total = total + (subItem.Price * float64(subItem.Count))
  8924. // }
  8925. // }
  8926. //
  8927. // allTotal := fmt.Sprintf("%.2f", total)
  8928. // totals, _ := strconv.ParseFloat(allTotal, 64)
  8929. // order := &models.HisOrder{
  8930. // UserOrgId: adminUser.CurrentOrgId,
  8931. // HisPatientId: his.ID,
  8932. // PatientId: id,
  8933. // SettleAccountsDate: recordDateTime,
  8934. // Ctime: time.Now().Unix(),
  8935. // Mtime: time.Now().Unix(),
  8936. // Status: 1,
  8937. // OrderStatus: 2,
  8938. // Number: chrg_bchno,
  8939. // MedfeeSumamt: totals,
  8940. // }
  8941. // err = service.CreateOrder(order)
  8942. // if err != nil {
  8943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8944. // return
  8945. // }
  8946. //
  8947. // var customs []*Custom
  8948. // for _, item := range prescriptions {
  8949. //
  8950. // if item.Type == 1 { //药品
  8951. // for _, subItem := range item.HisDoctorAdviceInfo {
  8952. // cus := &Custom{
  8953. // AdviceId: subItem.ID,
  8954. // ProjectId: 0,
  8955. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  8956. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  8957. // FeedetlSn: subItem.FeedetlSn,
  8958. // Price: fmt.Sprintf("%.2f", subItem.Price),
  8959. // MedListCodg: subItem.MedListCodg,
  8960. // Type: 1,
  8961. // }
  8962. // customs = append(customs, cus)
  8963. // }
  8964. // }
  8965. //
  8966. // if item.Type == 2 { //项目
  8967. // for _, subItem := range item.HisPrescriptionProject {
  8968. //
  8969. // cus := &Custom{
  8970. // AdviceId: 0,
  8971. // ProjectId: subItem.ID,
  8972. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  8973. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  8974. // FeedetlSn: subItem.FeedetlSn,
  8975. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  8976. // MedListCodg: subItem.MedListCodg,
  8977. // Type: 2,
  8978. // }
  8979. //
  8980. // customs = append(customs, cus)
  8981. // }
  8982. // }
  8983. //
  8984. // for _, item := range item.HisAdditionalCharge {
  8985. // cus := &Custom{
  8986. // ItemId: item.ID,
  8987. // AdviceId: 0,
  8988. // ProjectId: 0,
  8989. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  8990. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  8991. // FeedetlSn: item.FeedetlSn,
  8992. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  8993. // MedListCodg: item.XtHisAddtionConfig.Code,
  8994. // Type: 3,
  8995. // }
  8996. //
  8997. // customs = append(customs, cus)
  8998. // }
  8999. //
  9000. // }
  9001. //
  9002. // for _, item := range customs {
  9003. // var advice_id int64 = 0
  9004. // var project_id int64 = 0
  9005. // var item_id int64 = 0
  9006. //
  9007. // var types int64 = 0
  9008. //
  9009. // if item.Type == 1 {
  9010. // advice_id = item.AdviceId
  9011. // project_id = 0
  9012. // item_id = 0
  9013. // } else if item.Type == 2 {
  9014. // advice_id = 0
  9015. // item_id = 0
  9016. //
  9017. // project_id = item.ProjectId
  9018. // } else if item.Type == 3 {
  9019. // advice_id = 0
  9020. // item_id = item.ItemId
  9021. // project_id = 0
  9022. // }
  9023. //
  9024. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9025. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9026. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9027. //
  9028. // info := &models.HisOrderInfo{
  9029. // OrderNumber: order.Number,
  9030. // UploadDate: time.Now().Unix(),
  9031. // AdviceId: advice_id,
  9032. // DetItemFeeSumamt: detItemFeeSumamt,
  9033. // Cnt: cut,
  9034. // Pric: pric,
  9035. // PatientId: id,
  9036. // Status: 1,
  9037. // Mtime: time.Now().Unix(),
  9038. // Ctime: time.Now().Unix(),
  9039. // UserOrgId: adminUser.CurrentOrgId,
  9040. // HisPatientId: his.ID,
  9041. // OrderId: order.ID,
  9042. // ProjectId: project_id,
  9043. // Type: types,
  9044. // ItemId: item_id,
  9045. // }
  9046. // service.CreateOrderInfo(info)
  9047. // }
  9048. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9049. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9050. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9051. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9052. // if err == nil {
  9053. // c.ServeSuccessJSON(map[string]interface{}{
  9054. // "msg": "结算成功",
  9055. // })
  9056. // } else {
  9057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9058. // return
  9059. // }
  9060. // }
  9061. //}
  9062. //上传明细-预结算-
  9063. func (c *HisApiController) GetPreUploadInfo() {
  9064. id, _ := c.GetInt64("id")
  9065. record_time := c.GetString("record_time")
  9066. his_patient_id, _ := c.GetInt64("his_patient_id")
  9067. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9068. admin_user_id, _ := c.GetInt64("admin_user_id")
  9069. diagnosis_id := c.GetString("diagnosis")
  9070. sick_type, _ := c.GetInt64("sick_type")
  9071. reg_type, _ := c.GetInt64("p_type")
  9072. begin_time := c.GetString("begin_time")
  9073. id_str := c.GetString("ids")
  9074. ids_arr := strings.Split(id_str, ",")
  9075. timeLayout := "2006-01-02"
  9076. loc, _ := time.LoadLocation("Local")
  9077. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9078. if err != nil {
  9079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9080. return
  9081. }
  9082. recordDateTime := theTime.Unix()
  9083. adminUser := c.GetAdminUserInfo()
  9084. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9085. var config []*models.HisXtDiagnoseConfig
  9086. for _, item := range diagnosis_ids {
  9087. id, _ := strconv.ParseInt(item, 10, 64)
  9088. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9089. config = append(config, &diagnosisConfig)
  9090. }
  9091. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9092. sickConfig, _ := service.FindSickById(sick_type)
  9093. var prescriptions []*models.HisPrescription
  9094. var start_time int64
  9095. var end_time int64
  9096. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9097. fmt.Println(his_patient_id)
  9098. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9099. timestamp := time.Now().Unix()
  9100. tempTime := time.Unix(timestamp, 0)
  9101. timeFormat := tempTime.Format("20060102150405")
  9102. chrgBchno := rand.Intn(100000) + 10000
  9103. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9105. var patientPrescription models.HisPrescriptionInfo
  9106. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9107. if patientPrescription.ID == 0 {
  9108. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9109. }
  9110. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9111. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9112. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9113. strconv.FormatInt(his.PatientId, 10)
  9114. var res2 ResultSix
  9115. var resSix10265 ResultSix10265
  9116. //var time_stamp string
  9117. if miConfig.MdtrtareaAdmvs == "421300" {
  9118. data := make(map[string]interface{})
  9119. client := &http.Client{}
  9120. data["psn_no"] = his.PsnNo
  9121. data["mdtrt_id"] = his.Number
  9122. data["department"] = department.Name
  9123. data["org_name"] = miConfig.OrgName
  9124. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9125. data["doctor_id"] = doctor_info.DoctorNumber
  9126. data["doctor_name"] = roles.UserName
  9127. data["fixmedins_code"] = miConfig.Code
  9128. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9129. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9130. data["secret_key"] = miConfig.SecretKey
  9131. data["sick_code"] = sickConfig.CountryCode
  9132. data["sick_name"] = sickConfig.ClassName
  9133. data["begin_time"] = begin_time
  9134. data["dept"] = strconv.FormatInt(department.ID, 10)
  9135. data["config"] = config
  9136. data["opter"] = roles.UserName
  9137. fmt.Println(data)
  9138. bytesData, _ := json.Marshal(data)
  9139. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9140. resp, _ := client.Do(req)
  9141. defer resp.Body.Close()
  9142. body, ioErr := ioutil.ReadAll(resp.Body)
  9143. if ioErr != nil {
  9144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. return
  9147. }
  9148. var respJSON map[string]interface{}
  9149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9155. userJSONBytes, _ := json.Marshal(respJSON)
  9156. fmt.Println("log")
  9157. fmt.Println(string(userJSONBytes))
  9158. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9159. utils.ErrorLog("解析失败:%v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9164. data := make(map[string]interface{})
  9165. client := &http.Client{}
  9166. data["psn_no"] = his.PsnNo
  9167. data["mdtrt_id"] = his.Number
  9168. data["doctor"] = roles.UserName
  9169. data["department"] = department.Name
  9170. data["org_name"] = miConfig.OrgName
  9171. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9172. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9173. data["fixmedins_code"] = miConfig.Code
  9174. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9175. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9176. data["secret_key"] = miConfig.SecretKey
  9177. data["sick_code"] = sickConfig.CountryCode
  9178. data["sick_name"] = sickConfig.ClassName
  9179. data["begin_time"] = begin_time
  9180. data["dept"] = strconv.FormatInt(department.ID, 10)
  9181. data["config"] = config
  9182. data["url"] = miConfig.Url
  9183. data["ak"] = miConfig.AccessKey
  9184. data["cainfo"] = miConfig.Cainfo
  9185. bytesData, _ := json.Marshal(data)
  9186. var req *http.Request
  9187. if miConfig.MdtrtareaAdmvs == "320921" {
  9188. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9189. } else {
  9190. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9191. }
  9192. resp, _ := client.Do(req)
  9193. defer resp.Body.Close()
  9194. body, ioErr := ioutil.ReadAll(resp.Body)
  9195. if ioErr != nil {
  9196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9198. return
  9199. }
  9200. var respJSON map[string]interface{}
  9201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9207. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9208. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9210. userJSONBytes, _ := json.Marshal(respJSON)
  9211. fmt.Println("log")
  9212. fmt.Println(string(userJSONBytes))
  9213. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9214. utils.ErrorLog("解析失败:%v", err)
  9215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9216. return
  9217. }
  9218. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9219. res2.Output = resSix10265.Output
  9220. res2.ErrMsg = resSix10265.ErrMsg
  9221. res2.Cainfo = resSix10265.Cainfo
  9222. res2.WarnMsg = resSix10265.WarnMsg
  9223. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9224. res2.Infcode = infocode
  9225. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9226. 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)
  9227. saveLog(result, requestLog, "2203", "上传就诊信息")
  9228. var respJSON2 map[string]interface{}
  9229. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9232. return
  9233. }
  9234. userJSONBytes2, _ := json.Marshal(respJSON2)
  9235. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9236. utils.ErrorLog("解析失败:%v", err)
  9237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9238. return
  9239. }
  9240. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9241. var result string
  9242. var requestLog string
  9243. 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, "")
  9244. saveLog(result, requestLog, "2203", "上传就诊信息")
  9245. var respJSON2 map[string]interface{}
  9246. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. return
  9250. }
  9251. userJSONBytes2, _ := json.Marshal(respJSON2)
  9252. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9253. utils.ErrorLog("解析失败:%v", err)
  9254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9255. return
  9256. }
  9257. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9258. var result string
  9259. var requestLog string
  9260. 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, "")
  9261. saveLog(result, requestLog, "2203", "上传就诊信息")
  9262. var respJSON2 map[string]interface{}
  9263. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. userJSONBytes2, _ := json.Marshal(respJSON2)
  9269. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9270. utils.ErrorLog("解析失败:%v", err)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. } else {
  9275. var result string
  9276. var requestLog string
  9277. if miConfig.MdtrtareaAdmvs == "440781" { //
  9278. 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)
  9279. } else {
  9280. if miConfig.Code == "H15049901371" {
  9281. //赤峰地区国家医保医疗类别
  9282. //职工透析:医疗类别选特殊情况门诊990502
  9283. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9284. var med_type string
  9285. if his.Insutype == "390" {
  9286. if reg_type == 14 {
  9287. med_type = "9933"
  9288. } else if reg_type == 11 {
  9289. med_type = "11"
  9290. }
  9291. } else if his.Insutype == "310" {
  9292. if reg_type == 14 {
  9293. med_type = "990502"
  9294. } else if reg_type == 11 {
  9295. med_type = "11"
  9296. }
  9297. }
  9298. 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)
  9299. } else {
  9300. 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)
  9301. }
  9302. saveLog(result, requestLog, "2203", "上传就诊信息")
  9303. var respJSON2 map[string]interface{}
  9304. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. userJSONBytes2, _ := json.Marshal(respJSON2)
  9310. if miConfig.Code == "H15049901371" {
  9311. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9312. utils.ErrorLog("解析失败:%v", err)
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9314. return
  9315. }
  9316. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9317. res2.Output = resSix10265.Output
  9318. res2.ErrMsg = resSix10265.ErrMsg
  9319. res2.Cainfo = resSix10265.Cainfo
  9320. res2.WarnMsg = resSix10265.WarnMsg
  9321. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9322. res2.Infcode = infocode
  9323. } else {
  9324. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9325. utils.ErrorLog("解析失败:%v", err)
  9326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9327. return
  9328. }
  9329. }
  9330. }
  9331. }
  9332. if res2.Infcode != 0 {
  9333. adminUser := c.GetAdminUserInfo()
  9334. errlog := &models.HisOrderError{
  9335. UserOrgId: adminUser.CurrentOrgId,
  9336. Ctime: time.Now().Unix(),
  9337. Mtime: time.Now().Unix(),
  9338. ErrMsg: res2.ErrMsg,
  9339. Status: 1,
  9340. PatientId: id,
  9341. RecordTime: recordDateTime,
  9342. Stage: 3,
  9343. }
  9344. service.CreateErrMsgLog(errlog)
  9345. c.ServeSuccessJSON(map[string]interface{}{
  9346. "failed_code": -10,
  9347. "msg": res2.ErrMsg,
  9348. })
  9349. return
  9350. } else {
  9351. his.Diagnosis = diagnosis_id
  9352. his.SickType = sickConfig.ID
  9353. his.PType = fmt.Sprintf("%d", reg_type)
  9354. service.UpdateHisPatientThree(&his)
  9355. data := make(map[string]interface{})
  9356. if settle_accounts_type == 1 { //日结
  9357. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9358. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9359. } else {
  9360. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9361. }
  9362. data["pre"] = prescriptions
  9363. } else { //月结
  9364. start_time_str := c.GetString("start_time")
  9365. end_time_str := c.GetString("end_time")
  9366. timeLayout := "2006-01-02"
  9367. loc, _ := time.LoadLocation("Local")
  9368. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9369. if err != nil {
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9371. return
  9372. }
  9373. recordStartTime := theStartTime.Unix()
  9374. start_time = recordStartTime
  9375. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9376. if err != nil {
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9378. return
  9379. }
  9380. recordEndTime := theEndTime.Unix()
  9381. end_time = recordEndTime
  9382. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9383. data["pre"] = prescriptions
  9384. }
  9385. client := &http.Client{}
  9386. data["psn_no"] = his.PsnNo
  9387. data["mdtrt_id"] = his.Number
  9388. data["chrg_bchno"] = chrg_bchno
  9389. data["org_name"] = miConfig.OrgName
  9390. data["doctor"] = doctor_info.UserName
  9391. data["doctor_id"] = doctor_info.DoctorNumber
  9392. data["dept"] = department.Name
  9393. data["fixmedins_code"] = miConfig.Code
  9394. data["opter"] = roles.UserName
  9395. data["dept_code"] = department.Number
  9396. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9397. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9398. data["secret_key"] = miConfig.SecretKey
  9399. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9400. data["url"] = miConfig.Url
  9401. data["ak"] = miConfig.AccessKey
  9402. data["new_doctor_name"] = patientPrescription.Doctor
  9403. data["diag_code"] = sickConfig.CountryCode
  9404. data["cainfo"] = miConfig.Cainfo
  9405. data["opter"] = roles.UserName
  9406. var ids []int64
  9407. for _, item := range prescriptions {
  9408. ids = append(ids, item.ID)
  9409. }
  9410. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9411. if config.IsOpen == 1 { //对接了医保,走医保流程
  9412. var res ResultFour
  9413. var resFour10265 ResultFour10265
  9414. if miConfig.MdtrtareaAdmvs == "421300" {
  9415. bytesData, _ := json.Marshal(data)
  9416. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9417. resp, _ := client.Do(req)
  9418. defer resp.Body.Close()
  9419. body, ioErr := ioutil.ReadAll(resp.Body)
  9420. if ioErr != nil {
  9421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. var respJSON map[string]interface{}
  9426. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9429. return
  9430. }
  9431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9432. userJSONBytes, _ := json.Marshal(respJSON)
  9433. fmt.Println("log")
  9434. fmt.Println(string(userJSONBytes))
  9435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9436. utils.ErrorLog("解析失败:%v", err)
  9437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9438. return
  9439. }
  9440. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9441. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9442. if result3101.Infcode == "0" {
  9443. if len(result3101.Output.Result) > 0 {
  9444. var errMsgs []string
  9445. for _, item := range result3101.Output.Result {
  9446. errMsgs = append(errMsgs, item.VolaCont)
  9447. }
  9448. c.ServeSuccessJSON(map[string]interface{}{
  9449. "failed_code": -10,
  9450. "msg": errMsgs,
  9451. })
  9452. return
  9453. } else {
  9454. if miConfig.MdtrtareaAdmvs == "320921" {
  9455. data["doctor_id"] = "D320923012139"
  9456. } else {
  9457. data["doctor_id"] = "D371621008686"
  9458. }
  9459. bytesData, _ := json.Marshal(data)
  9460. var req *http.Request
  9461. if miConfig.MdtrtareaAdmvs == "320921" {
  9462. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9463. } else {
  9464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9465. }
  9466. resp, _ := client.Do(req)
  9467. defer resp.Body.Close()
  9468. body, ioErr := ioutil.ReadAll(resp.Body)
  9469. if ioErr != nil {
  9470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. var respJSON map[string]interface{}
  9475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9481. userJSONBytes, _ := json.Marshal(respJSON)
  9482. fmt.Println("log")
  9483. fmt.Println(string(userJSONBytes))
  9484. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9485. utils.ErrorLog("解析失败:%v", err)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. res.InfRefmsgid = resFour10265.InfRefmsgid
  9490. res.Output = resFour10265.Output
  9491. res.ErrMsg = resFour10265.ErrMsg
  9492. res.Cainfo = resFour10265.Cainfo
  9493. res.WarnMsg = resFour10265.WarnMsg
  9494. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9495. res.Infcode = infocode
  9496. }
  9497. }
  9498. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9499. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  9500. var dat map[string]interface{}
  9501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9502. fmt.Println(dat)
  9503. } else {
  9504. fmt.Println(err)
  9505. }
  9506. saveLog(result, request_log, "2204", "上传费用明细")
  9507. userJSONBytes, _ := json.Marshal(dat)
  9508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9509. utils.ErrorLog("解析失败:%v", err)
  9510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. return
  9512. }
  9513. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9514. 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, "", "")
  9515. var dat map[string]interface{}
  9516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9517. fmt.Println(dat)
  9518. } else {
  9519. fmt.Println(err)
  9520. }
  9521. saveLog(result, request_log, "2204", "上传费用明细")
  9522. userJSONBytes, _ := json.Marshal(dat)
  9523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9524. utils.ErrorLog("解析失败:%v", err)
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9526. return
  9527. }
  9528. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9529. 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, "", "")
  9530. var dat map[string]interface{}
  9531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9532. fmt.Println(dat)
  9533. } else {
  9534. fmt.Println(err)
  9535. }
  9536. saveLog(result, request_log, "2204", "上传费用明细")
  9537. userJSONBytes, _ := json.Marshal(dat)
  9538. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9539. utils.ErrorLog("解析失败:%v", err)
  9540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9541. return
  9542. }
  9543. } else {
  9544. if miConfig.Code == "H15049901371" {
  9545. 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)
  9546. var dat map[string]interface{}
  9547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9548. fmt.Println(dat)
  9549. } else {
  9550. fmt.Println(err)
  9551. }
  9552. saveLog(result, request_log, "2204", "上传费用明细")
  9553. userJSONBytes, _ := json.Marshal(dat)
  9554. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. res.InfRefmsgid = resFour10265.InfRefmsgid
  9560. res.Output = resFour10265.Output
  9561. res.ErrMsg = resFour10265.ErrMsg
  9562. res.Cainfo = resFour10265.Cainfo
  9563. res.WarnMsg = resFour10265.WarnMsg
  9564. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9565. res.Infcode = infocode
  9566. } else {
  9567. 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)
  9568. var dat map[string]interface{}
  9569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9570. fmt.Println(dat)
  9571. } else {
  9572. fmt.Println(err)
  9573. }
  9574. saveLog(result, request_log, "2204", "上传费用明细")
  9575. userJSONBytes, _ := json.Marshal(dat)
  9576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9577. utils.ErrorLog("解析失败:%v", err)
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9579. return
  9580. }
  9581. }
  9582. }
  9583. if res.Infcode == 0 {
  9584. order := &models.HisOrder{
  9585. UserOrgId: adminUser.CurrentOrgId,
  9586. HisPatientId: his.ID,
  9587. PatientId: his.PatientId,
  9588. SettleAccountsDate: recordDateTime,
  9589. Ctime: time.Now().Unix(),
  9590. Mtime: time.Now().Unix(),
  9591. MdtrtId: his.Number,
  9592. PsnNo: his.PsnNo,
  9593. MedType: strconv.FormatInt(reg_type, 10),
  9594. Status: 1,
  9595. Number: chrg_bchno,
  9596. Infcode: res.Infcode,
  9597. WarnMsg: res.WarnMsg,
  9598. Cainfo: res.Cainfo,
  9599. ErrMsg: res.ErrMsg,
  9600. RespondTime: res.RefmsgTime,
  9601. InfRefmsgid: res.InfRefmsgid,
  9602. OrderStatus: 1,
  9603. IsMedicineInsurance: 1,
  9604. SettleType: settle_accounts_type,
  9605. SettleStartTime: start_time,
  9606. SettleEndTime: end_time,
  9607. Creator: roles.AdminUserId,
  9608. Modify: roles.AdminUserId,
  9609. PType: 2,
  9610. Diagnosis: diagnosis_id,
  9611. }
  9612. err = service.CreateOrder(order)
  9613. if err != nil {
  9614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9615. return
  9616. }
  9617. for _, item := range res.Output.Result {
  9618. temp := strings.Split(item.FeedetlSn, "-")
  9619. var advice_id int64 = 0
  9620. var project_id int64 = 0
  9621. var types int64 = 0
  9622. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9623. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9624. if temp[1] == "1" {
  9625. advice_id = id
  9626. project_id = 0
  9627. } else if temp[1] == "2" {
  9628. advice_id = 0
  9629. project_id = id
  9630. }
  9631. info := &models.HisOrderInfo{
  9632. OrderNumber: order.Number,
  9633. FeedetlSn: item.FeedetlSn,
  9634. UploadDate: time.Now().Unix(),
  9635. AdviceId: advice_id,
  9636. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9637. Cnt: item.Cnt,
  9638. Pric: float64(item.Pric),
  9639. PatientId: his.PatientId,
  9640. PricUplmtAmt: item.PricUplmtAmt,
  9641. SelfpayProp: item.SelfpayProp,
  9642. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9643. OverlmtAmt: item.OverlmtAmt,
  9644. PreselfpayAmt: item.PreselfpayAmt,
  9645. BasMednFlag: item.BasMednFlag,
  9646. MedChrgitmType: item.MedChrgitmType,
  9647. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9648. Status: 1,
  9649. Memo: item.Memo,
  9650. Mtime: time.Now().Unix(),
  9651. InscpScpAmt: item.InscpScpAmt,
  9652. DrtReimFlag: item.DrtReimFlag,
  9653. Ctime: time.Now().Unix(),
  9654. ListSpItemFlag: item.ListSpItemFlag,
  9655. ChldMedcFlag: item.ChldMedcFlag,
  9656. LmtUsedFlag: item.LmtUsedFlag,
  9657. ChrgitmLv: item.ChrgitmLv,
  9658. UserOrgId: adminUser.CurrentOrgId,
  9659. HisPatientId: his.ID,
  9660. OrderId: order.ID,
  9661. ProjectId: project_id,
  9662. Type: types,
  9663. }
  9664. service.CreateOrderInfo(info)
  9665. }
  9666. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9667. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9668. var total float64
  9669. for _, item := range prescriptions {
  9670. if item.Type == 1 { //药品
  9671. for _, subItem := range item.HisDoctorAdviceInfo {
  9672. total = total + (subItem.Price * subItem.PrescribingNumber)
  9673. }
  9674. }
  9675. if item.Type == 2 { //项目
  9676. for _, subItem := range item.HisPrescriptionProject {
  9677. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9678. total = total + (subItem.Price * cnt)
  9679. }
  9680. }
  9681. }
  9682. for _, item := range prescriptions {
  9683. for _, subItem := range item.HisAdditionalCharge {
  9684. total = total + (subItem.Price * float64(subItem.Count))
  9685. }
  9686. }
  9687. allTotal := fmt.Sprintf("%.4f", total)
  9688. if res.Infcode == 0 {
  9689. var rf []*ResultFive
  9690. json.Unmarshal([]byte(his.Iinfo), &rf)
  9691. chrg_bchno := chrg_bchno
  9692. cert_no := his.Certno
  9693. var insutypes []string
  9694. var insutype string
  9695. var is390 int = 0
  9696. var is310 int = 0
  9697. for _, item := range rf {
  9698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9699. insutypes = append(insutypes, item.Insutype)
  9700. }
  9701. }
  9702. if len(insutypes) == 1 {
  9703. insutype = insutypes[0]
  9704. } else {
  9705. for _, i := range insutypes {
  9706. if i == "390" {
  9707. is390 = 1
  9708. }
  9709. if i == "310" {
  9710. is310 = 1
  9711. }
  9712. }
  9713. }
  9714. if is390 == 1 {
  9715. insutype = "390"
  9716. }
  9717. if is310 == 1 {
  9718. insutype = "310"
  9719. }
  9720. if len(insutypes) == 0 {
  9721. insutype = "310"
  9722. }
  9723. if len(insutypes) == 2 {
  9724. insutype = strconv.FormatInt(his.SocialType, 64)
  9725. }
  9726. //insutype = "390"
  9727. if his.IdCardType == 1 {
  9728. cert_no = his.MedicalInsuranceNumber
  9729. } else {
  9730. cert_no = his.Certno
  9731. }
  9732. var res ResultSeven
  9733. var resSeven10265 ResultSeven10265
  9734. if miConfig.MdtrtareaAdmvs == "421300" {
  9735. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9736. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9737. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9738. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9739. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9740. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9741. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9742. resp, requestErr := http.Get(api)
  9743. if requestErr != nil {
  9744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9745. return
  9746. }
  9747. body, ioErr := ioutil.ReadAll(resp.Body)
  9748. if ioErr != nil {
  9749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9751. return
  9752. }
  9753. var respJSON map[string]interface{}
  9754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9757. return
  9758. }
  9759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9760. result, _ := json.Marshal(respJSON)
  9761. fmt.Println("log")
  9762. fmt.Println(string(result))
  9763. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9764. utils.ErrorLog("解析失败:%v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9769. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9770. if result3101.Infcode == "0" {
  9771. if len(result3101.Output.Result) > 0 {
  9772. var errMsgs []string
  9773. for _, item := range result3101.Output.Result {
  9774. errMsgs = append(errMsgs, item.VolaCont)
  9775. }
  9776. c.ServeSuccessJSON(map[string]interface{}{
  9777. "failed_code": -10,
  9778. "msg": errMsgs,
  9779. })
  9780. return
  9781. } else {
  9782. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9783. if his.IdCardType != 4 {
  9784. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9785. bas := strings.Split(psn_info.CardInfo, "|")
  9786. if his.IdCardType == 1 {
  9787. cert_no = bas[2]
  9788. } else {
  9789. cert_no = bas[1]
  9790. }
  9791. } else {
  9792. cert_no = his.Certno
  9793. }
  9794. //江苏地区国家医保医疗类别
  9795. //职工透析:医疗类别选特殊情况门诊9933
  9796. //居民血透门慢: 医疗类别选门诊慢病1402
  9797. //var med_type string
  9798. //if his.Insutype == "310" {
  9799. // if reg_type == 14 {
  9800. // med_type = "9933"
  9801. // } else if reg_type == 11 {
  9802. // med_type = "11"
  9803. //
  9804. // }
  9805. //} else if his.Insutype == "390" {
  9806. // if reg_type == 14 {
  9807. // med_type = "1402"
  9808. // } else if reg_type == 11 {
  9809. // med_type = "11"
  9810. // }
  9811. //}
  9812. var api string
  9813. if miConfig.MdtrtareaAdmvs == "320921" {
  9814. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9815. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9816. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9818. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9819. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9820. "&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
  9821. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9822. } else {
  9823. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9824. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9825. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9826. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9828. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9829. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9830. "&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
  9831. }
  9832. resp, requestErr := http.Get(api)
  9833. if requestErr != nil {
  9834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9835. return
  9836. }
  9837. body, ioErr := ioutil.ReadAll(resp.Body)
  9838. if ioErr != nil {
  9839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9841. return
  9842. }
  9843. var respJSON map[string]interface{}
  9844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9847. return
  9848. }
  9849. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9850. result, _ := json.Marshal(respJSON)
  9851. fmt.Println("log")
  9852. fmt.Println(string(result))
  9853. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9854. utils.ErrorLog("解析失败:%v", err)
  9855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9856. return
  9857. }
  9858. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9859. res.Output = resSeven10265.Output
  9860. res.ErrMsg = resSeven10265.ErrMsg
  9861. res.Cainfo = resSeven10265.Cainfo
  9862. res.WarnMsg = resSeven10265.WarnMsg
  9863. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9864. res.Infcode = infocode
  9865. }
  9866. }
  9867. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9868. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9869. var result string
  9870. var request_log string
  9871. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  9872. 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)
  9873. } else {
  9874. 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)
  9875. }
  9876. var dat map[string]interface{}
  9877. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9878. fmt.Println(dat)
  9879. } else {
  9880. fmt.Println(err)
  9881. }
  9882. saveLog(result, request_log, "2206", "预结算")
  9883. userJSONBytes, _ := json.Marshal(dat)
  9884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9885. utils.ErrorLog("解析失败:%v", err)
  9886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9887. return
  9888. }
  9889. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9890. var result string
  9891. var request_log string
  9892. if his.IdCardType == 2 {
  9893. 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, "")
  9894. } else if his.IdCardType == 1 {
  9895. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9896. bas := strings.Split(psn_info.CardInfo, "|")
  9897. basNumber := bas[2]
  9898. card_sn := bas[3]
  9899. 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)
  9900. } else {
  9901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9902. 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, "")
  9903. }
  9904. var dat map[string]interface{}
  9905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9906. fmt.Println(dat)
  9907. } else {
  9908. fmt.Println(err)
  9909. }
  9910. saveLog(result, request_log, "2206", "预结算")
  9911. userJSONBytes, _ := json.Marshal(dat)
  9912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9913. utils.ErrorLog("解析失败:%v", err)
  9914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9915. return
  9916. }
  9917. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9918. var result string
  9919. var request_log string
  9920. if his.IdCardType == 2 {
  9921. 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, "")
  9922. } else if his.IdCardType == 1 {
  9923. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9924. bas := strings.Split(psn_info.CardInfo, "|")
  9925. basNumber := bas[2]
  9926. card_sn := bas[3]
  9927. 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)
  9928. } else {
  9929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9930. 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, "")
  9931. }
  9932. var dat map[string]interface{}
  9933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9934. fmt.Println(dat)
  9935. } else {
  9936. fmt.Println(err)
  9937. }
  9938. saveLog(result, request_log, "2206", "预结算")
  9939. userJSONBytes, _ := json.Marshal(dat)
  9940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9941. utils.ErrorLog("解析失败:%v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. } else {
  9946. var result string
  9947. var request_log string
  9948. if miConfig.Code == "H15049901371" {
  9949. //赤峰地区国家医保医疗类别
  9950. //职工透析:医疗类别选特殊情况门诊990502
  9951. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9952. var med_type string
  9953. if his.Insutype == "390" {
  9954. if reg_type == 14 {
  9955. med_type = "9933"
  9956. } else if reg_type == 11 {
  9957. med_type = "11"
  9958. }
  9959. } else if his.Insutype == "310" {
  9960. if reg_type == 14 {
  9961. med_type = "990502"
  9962. } else if reg_type == 11 {
  9963. med_type = "11"
  9964. }
  9965. }
  9966. 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)
  9967. } else {
  9968. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9969. if his.IdCardType == 4 {
  9970. 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)
  9971. } else {
  9972. 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)
  9973. }
  9974. }
  9975. var dat map[string]interface{}
  9976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9977. fmt.Println(dat)
  9978. } else {
  9979. fmt.Println(err)
  9980. }
  9981. saveLog(result, request_log, "2206", "预结算")
  9982. //userJSONBytes, _ := json.Marshal(dat)
  9983. //
  9984. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9985. // utils.ErrorLog("解析失败:%v", err)
  9986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9987. // return
  9988. //}
  9989. userJSONBytes, _ := json.Marshal(dat)
  9990. if miConfig.Code == "H15049901371" {
  9991. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9992. utils.ErrorLog("解析失败:%v", err)
  9993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9994. return
  9995. }
  9996. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9997. res.Output = resSeven10265.Output
  9998. res.ErrMsg = resSeven10265.ErrMsg
  9999. res.Cainfo = resSeven10265.Cainfo
  10000. res.WarnMsg = resSeven10265.WarnMsg
  10001. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10002. res.Infcode = infocode
  10003. } else {
  10004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10005. utils.ErrorLog("解析失败:%v", err)
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. }
  10010. }
  10011. if res.Infcode != 0 {
  10012. errlog := &models.HisOrderError{
  10013. UserOrgId: adminUser.CurrentOrgId,
  10014. Ctime: time.Now().Unix(),
  10015. Mtime: time.Now().Unix(),
  10016. Number: chrg_bchno,
  10017. ErrMsg: res.ErrMsg,
  10018. Status: 1,
  10019. PatientId: id,
  10020. RecordTime: recordDateTime,
  10021. Stage: 20,
  10022. }
  10023. service.CreateErrMsgLog(errlog)
  10024. c.ServeSuccessJSON(map[string]interface{}{
  10025. "failed_code": -10,
  10026. "msg": res.ErrMsg,
  10027. })
  10028. return
  10029. } else {
  10030. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10031. order.OrderStatus = 1
  10032. order.IsPre = 1
  10033. order.Status = 1
  10034. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10035. order.SetlId = res.Output.Setlinfo.SetlID
  10036. order.PsnNo = res.Output.Setlinfo.PsnNo
  10037. order.PsnName = res.Output.Setlinfo.PsnName
  10038. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10039. order.Certno = res.Output.Setlinfo.Certno
  10040. order.Gend = res.Output.Setlinfo.Gend
  10041. order.Naty = res.Output.Setlinfo.Naty
  10042. order.Age = res.Output.Setlinfo.Age
  10043. order.Insutype = res.Output.Setlinfo.Insutype
  10044. order.PsnType = res.Output.Setlinfo.PsnType
  10045. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10046. order.SetlTime = res.Output.Setlinfo.SetlTime
  10047. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10048. if res.Output.Setlinfo.MedType == "140101" {
  10049. order.MedType = "14"
  10050. } else {
  10051. order.MedType = res.Output.Setlinfo.MedType
  10052. }
  10053. if reg_type == 1112 {
  10054. order.MedType = "1112"
  10055. }
  10056. if reg_type == 1111 {
  10057. order.MedType = "1111"
  10058. }
  10059. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10060. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10061. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10062. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10063. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10064. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10065. order.HifpPay = res.Output.Setlinfo.HifpPay
  10066. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10067. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10068. order.HifesPay = res.Output.Setlinfo.HifesPay
  10069. order.HifobPay = res.Output.Setlinfo.HifobPay
  10070. order.MafPay = res.Output.Setlinfo.MafPay
  10071. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10072. order.OthPay = res.Output.Setlinfo.OthPay
  10073. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10074. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10075. order.AcctPay = res.Output.Setlinfo.AcctPay
  10076. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10077. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10078. order.Balc = res.Output.Setlinfo.Balc
  10079. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10080. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10081. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10082. order.ClrWay = res.Output.Setlinfo.ClrWay
  10083. order.Creator = order.Creator
  10084. order.Modify = roles.AdminUserId
  10085. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10086. detailStr := string(setlDetail)
  10087. order.SetlDetail = detailStr
  10088. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10089. err = service.UpDateOrder(order)
  10090. if err == nil {
  10091. c.ServeSuccessJSON(map[string]interface{}{
  10092. "msg": "预结算成功",
  10093. })
  10094. } else {
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10096. return
  10097. }
  10098. }
  10099. } else {
  10100. adminUser := c.GetAdminUserInfo()
  10101. errlog := &models.HisOrderError{
  10102. UserOrgId: adminUser.CurrentOrgId,
  10103. Ctime: time.Now().Unix(),
  10104. Mtime: time.Now().Unix(),
  10105. ErrMsg: res.ErrMsg,
  10106. Status: 1,
  10107. PatientId: id,
  10108. RecordTime: recordDateTime,
  10109. Stage: 4,
  10110. }
  10111. service.CreateErrMsgLog(errlog)
  10112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10113. return
  10114. }
  10115. } else {
  10116. adminUser := c.GetAdminUserInfo()
  10117. errlog := &models.HisOrderError{
  10118. UserOrgId: adminUser.CurrentOrgId,
  10119. Ctime: time.Now().Unix(),
  10120. Mtime: time.Now().Unix(),
  10121. ErrMsg: res.ErrMsg,
  10122. Status: 1,
  10123. PatientId: id,
  10124. RecordTime: recordDateTime,
  10125. Stage: 4,
  10126. }
  10127. service.CreateErrMsgLog(errlog)
  10128. c.ServeSuccessJSON(map[string]interface{}{
  10129. "failed_code": -10,
  10130. "msg": res.ErrMsg,
  10131. })
  10132. return
  10133. }
  10134. }
  10135. }
  10136. }
  10137. //退款
  10138. func (c *HisApiController) Refund() {
  10139. order_id, _ := c.GetInt64("order_id")
  10140. admin_user_id, _ := c.GetInt64("admin_user_id")
  10141. adminUser := c.GetAdminUserInfo()
  10142. var order models.HisOrder
  10143. order, _ = service.GetHisOrderByID(order_id)
  10144. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10145. if order.ID == 0 {
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10147. return
  10148. }
  10149. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10150. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10151. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10152. if config.IsOpen == 1 { //对接了医保,走医保流程
  10153. var res ResultSixteen
  10154. var resSixteen10265 ResultSixteen10265
  10155. var src_resquest string
  10156. var result string
  10157. if miConfig.MdtrtareaAdmvs == "421300" {
  10158. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10159. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10161. resp3, requestErr3 := http.Get(api3)
  10162. if requestErr3 != nil {
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10167. if ioErr3 != nil {
  10168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10170. return
  10171. }
  10172. var respJSON3 map[string]interface{}
  10173. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10179. userJSONBytes3, _ := json.Marshal(respJSON3)
  10180. fmt.Println("log")
  10181. fmt.Println(string(userJSONBytes3))
  10182. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10183. utils.ErrorLog("解析失败:%v", err)
  10184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10185. return
  10186. }
  10187. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10188. var api3 string
  10189. if miConfig.MdtrtareaAdmvs == "320921" {
  10190. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10191. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10193. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10194. } else {
  10195. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10196. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10197. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10199. }
  10200. resp3, requestErr3 := http.Get(api3)
  10201. if requestErr3 != nil {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10203. return
  10204. }
  10205. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10206. if ioErr3 != nil {
  10207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. return
  10210. }
  10211. var respJSON3 map[string]interface{}
  10212. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10215. return
  10216. }
  10217. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10218. userJSONBytes3, _ := json.Marshal(respJSON3)
  10219. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10220. utils.ErrorLog("解析失败:%v", err)
  10221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10222. return
  10223. }
  10224. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10225. res.Output = resSixteen10265.Output
  10226. res.ErrMsg = resSixteen10265.ErrMsg
  10227. res.Cainfo = resSixteen10265.Cainfo
  10228. res.WarnMsg = resSixteen10265.WarnMsg
  10229. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10230. res.Infcode = infocode
  10231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10232. 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)
  10233. var dat map[string]interface{}
  10234. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10235. fmt.Println(dat)
  10236. } else {
  10237. fmt.Println(err)
  10238. }
  10239. saveLog(result, src_resquest, "2208", "退费")
  10240. userJSONBytes, _ := json.Marshal(dat)
  10241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10242. utils.ErrorLog("解析失败:%v", err)
  10243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10244. return
  10245. }
  10246. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10247. 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, "")
  10248. var dat map[string]interface{}
  10249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10250. fmt.Println(dat)
  10251. } else {
  10252. fmt.Println(err)
  10253. }
  10254. saveLog(result, src_resquest, "2208", "退费")
  10255. userJSONBytes, _ := json.Marshal(dat)
  10256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10257. utils.ErrorLog("解析失败:%v", err)
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10259. return
  10260. }
  10261. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10262. 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, "")
  10263. var dat map[string]interface{}
  10264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10265. fmt.Println(dat)
  10266. } else {
  10267. fmt.Println(err)
  10268. }
  10269. saveLog(result, src_resquest, "2208", "退费")
  10270. userJSONBytes, _ := json.Marshal(dat)
  10271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10272. utils.ErrorLog("解析失败:%v", err)
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10274. return
  10275. }
  10276. } else {
  10277. if miConfig.Code == "H15049901371" {
  10278. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10279. var dat map[string]interface{}
  10280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10281. fmt.Println(dat)
  10282. } else {
  10283. fmt.Println(err)
  10284. }
  10285. saveLog(result, src_resquest, "2208", "退费")
  10286. userJSONBytes, _ := json.Marshal(dat)
  10287. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10288. utils.ErrorLog("解析失败:%v", err)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. return
  10291. }
  10292. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10293. res.Output = resSixteen10265.Output
  10294. res.ErrMsg = resSixteen10265.ErrMsg
  10295. res.Cainfo = resSixteen10265.Cainfo
  10296. res.WarnMsg = resSixteen10265.WarnMsg
  10297. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10298. res.Infcode = infocode
  10299. } else {
  10300. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10301. var dat map[string]interface{}
  10302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10303. fmt.Println(dat)
  10304. } else {
  10305. fmt.Println(err)
  10306. }
  10307. saveLog(result, src_resquest, "2208", "退费")
  10308. userJSONBytes, _ := json.Marshal(dat)
  10309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. }
  10315. }
  10316. if res.Infcode == 0 {
  10317. var res2 ResultSix
  10318. var resSix10265 ResultSix10265
  10319. if miConfig.MdtrtareaAdmvs == "421300" {
  10320. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10321. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10323. resp3, requestErr3 := http.Get(api3)
  10324. if requestErr3 != nil {
  10325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10326. return
  10327. }
  10328. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10329. if ioErr3 != nil {
  10330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. return
  10333. }
  10334. var respJSON3 map[string]interface{}
  10335. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10338. return
  10339. }
  10340. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10341. userJSONBytes3, _ := json.Marshal(respJSON3)
  10342. fmt.Println("log")
  10343. fmt.Println(string(userJSONBytes3))
  10344. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10345. utils.ErrorLog("解析失败:%v", err)
  10346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10347. return
  10348. }
  10349. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10350. var api3 string
  10351. if miConfig.MdtrtareaAdmvs == "320921" {
  10352. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10353. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10355. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10356. } else {
  10357. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10358. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10359. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10361. }
  10362. resp3, requestErr3 := http.Get(api3)
  10363. if requestErr3 != nil {
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10365. return
  10366. }
  10367. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10368. if ioErr3 != nil {
  10369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. var respJSON3 map[string]interface{}
  10374. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10377. return
  10378. }
  10379. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10380. userJSONBytes3, _ := json.Marshal(respJSON3)
  10381. fmt.Println("log")
  10382. fmt.Println(string(userJSONBytes3))
  10383. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10384. utils.ErrorLog("解析失败:%v", err)
  10385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10386. return
  10387. }
  10388. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10389. res2.Output = resSix10265.Output
  10390. res2.ErrMsg = resSix10265.ErrMsg
  10391. res2.Cainfo = resSix10265.Cainfo
  10392. res2.WarnMsg = resSix10265.WarnMsg
  10393. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10394. res2.Infcode = infocode
  10395. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10396. 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)
  10397. var dat map[string]interface{}
  10398. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10399. fmt.Println(dat)
  10400. } else {
  10401. fmt.Println(err)
  10402. }
  10403. saveLog(result2, src_request, "2205", "撤销明细")
  10404. userJSONBytes, _ := json.Marshal(dat)
  10405. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10406. utils.ErrorLog("解析失败:%v", err)
  10407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10408. return
  10409. }
  10410. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10411. 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, "")
  10412. var dat map[string]interface{}
  10413. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10414. fmt.Println(dat)
  10415. } else {
  10416. fmt.Println(err)
  10417. }
  10418. saveLog(result2, src_request, "2205", "撤销明细")
  10419. userJSONBytes, _ := json.Marshal(dat)
  10420. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10421. utils.ErrorLog("解析失败:%v", err)
  10422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10423. return
  10424. }
  10425. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10426. 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, "")
  10427. var dat map[string]interface{}
  10428. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10429. fmt.Println(dat)
  10430. } else {
  10431. fmt.Println(err)
  10432. }
  10433. saveLog(result2, src_request, "2205", "撤销明细")
  10434. userJSONBytes, _ := json.Marshal(dat)
  10435. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10436. utils.ErrorLog("解析失败:%v", err)
  10437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10438. return
  10439. }
  10440. } else {
  10441. if miConfig.Code == "H15049901371" {
  10442. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10443. var dat map[string]interface{}
  10444. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10445. fmt.Println(dat)
  10446. } else {
  10447. fmt.Println(err)
  10448. }
  10449. saveLog(result2, src_request, "2205", "撤销明细")
  10450. userJSONBytes, _ := json.Marshal(dat)
  10451. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10452. utils.ErrorLog("解析失败:%v", err)
  10453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10454. return
  10455. }
  10456. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10457. res2.Output = resSix10265.Output
  10458. res2.ErrMsg = resSix10265.ErrMsg
  10459. res2.Cainfo = resSix10265.Cainfo
  10460. res2.WarnMsg = resSix10265.WarnMsg
  10461. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10462. res2.Infcode = infocode
  10463. } else {
  10464. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10465. var dat map[string]interface{}
  10466. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10467. fmt.Println(dat)
  10468. } else {
  10469. fmt.Println(err)
  10470. }
  10471. saveLog(result2, src_request, "2205", "撤销明细")
  10472. userJSONBytes, _ := json.Marshal(dat)
  10473. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10474. utils.ErrorLog("解析失败:%v", err)
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10476. return
  10477. }
  10478. }
  10479. }
  10480. if res2.Infcode == 0 {
  10481. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10482. if err == nil {
  10483. //当押金不为零时产生退费记录
  10484. if order.Decimal != 0 {
  10485. tmp := strconv.FormatInt(order.ID, 10)
  10486. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10487. if err != nil {
  10488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10489. return
  10490. }
  10491. }
  10492. c.ServeSuccessJSON(map[string]interface{}{
  10493. "msg": "退费成功",
  10494. })
  10495. } else {
  10496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10497. return
  10498. }
  10499. } else {
  10500. c.ServeSuccessJSON(map[string]interface{}{
  10501. "code": -10,
  10502. "msg": res2.ErrMsg,
  10503. })
  10504. }
  10505. } else {
  10506. c.ServeSuccessJSON(map[string]interface{}{
  10507. "code": -10,
  10508. "msg": res.ErrMsg,
  10509. })
  10510. }
  10511. }
  10512. }
  10513. func (c *HisApiController) RefundNumber() {
  10514. record_time := c.GetString("record_time")
  10515. //patient_id, _ := c.GetInt64("patient_id")
  10516. admin_user_id, _ := c.GetInt64("admin_user_id")
  10517. his_patient_id, _ := c.GetInt64("id")
  10518. timeLayout := "2006-01-02"
  10519. loc, _ := time.LoadLocation("Local")
  10520. adminUser := c.GetAdminUserInfo()
  10521. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10522. fmt.Println(err)
  10523. if err != nil {
  10524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10525. return
  10526. }
  10527. recordDateTime := theTime.Unix()
  10528. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10529. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10530. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10531. //order, _ := service.GetHisOrderByID(order_id)
  10532. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10533. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10534. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10535. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10536. if count > 0 {
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10538. return
  10539. }
  10540. if config.IsOpen == 1 { //对接了医保,走医保流程
  10541. var res2 ResultSix
  10542. var resSix10265 ResultSix10265
  10543. if miConfig.MdtrtareaAdmvs == "421300" {
  10544. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10545. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  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. fmt.Println("log")
  10567. fmt.Println(string(userJSONBytes3))
  10568. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10569. utils.ErrorLog("解析失败:%v", err)
  10570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10571. return
  10572. }
  10573. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10574. var api3 string
  10575. if miConfig.MdtrtareaAdmvs == "320921" {
  10576. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10577. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10579. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10580. } else {
  10581. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10582. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10583. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10585. }
  10586. resp3, requestErr3 := http.Get(api3)
  10587. if requestErr3 != nil {
  10588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10589. return
  10590. }
  10591. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10592. if ioErr3 != nil {
  10593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. var respJSON3 map[string]interface{}
  10598. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10601. return
  10602. }
  10603. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10604. userJSONBytes3, _ := json.Marshal(respJSON3)
  10605. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10606. utils.ErrorLog("解析失败:%v", err)
  10607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10608. return
  10609. }
  10610. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10611. res2.Output = resSix10265.Output
  10612. res2.ErrMsg = resSix10265.ErrMsg
  10613. res2.Cainfo = resSix10265.Cainfo
  10614. res2.WarnMsg = resSix10265.WarnMsg
  10615. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10616. res2.Infcode = infocode
  10617. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10618. 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)
  10619. var dat map[string]interface{}
  10620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10621. fmt.Println(dat)
  10622. } else {
  10623. fmt.Println(err)
  10624. }
  10625. saveLog(result, request, "2202", "退号")
  10626. userJSONBytes, _ := json.Marshal(dat)
  10627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10628. utils.ErrorLog("解析失败:%v", err)
  10629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10630. return
  10631. }
  10632. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10633. 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, "")
  10634. var dat map[string]interface{}
  10635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10636. fmt.Println(dat)
  10637. } else {
  10638. fmt.Println(err)
  10639. }
  10640. saveLog(result, request, "2202", "退号")
  10641. userJSONBytes, _ := json.Marshal(dat)
  10642. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10643. utils.ErrorLog("解析失败:%v", err)
  10644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10645. return
  10646. }
  10647. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10648. 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, "")
  10649. var dat map[string]interface{}
  10650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10651. fmt.Println(dat)
  10652. } else {
  10653. fmt.Println(err)
  10654. }
  10655. saveLog(result, request, "2202", "退号")
  10656. userJSONBytes, _ := json.Marshal(dat)
  10657. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10658. utils.ErrorLog("解析失败:%v", err)
  10659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10660. return
  10661. }
  10662. } else {
  10663. var api3 string
  10664. if miConfig.Code == "H15049901371" {
  10665. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10666. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10668. } else {
  10669. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10670. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10671. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10672. }
  10673. resp3, requestErr3 := http.Get(api3)
  10674. if requestErr3 != nil {
  10675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10676. return
  10677. }
  10678. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10679. if ioErr3 != nil {
  10680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10682. return
  10683. }
  10684. var respJSON3 map[string]interface{}
  10685. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10688. return
  10689. }
  10690. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10691. userJSONBytes3, _ := json.Marshal(respJSON3)
  10692. if miConfig.Code == "H15049901371" {
  10693. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10694. utils.ErrorLog("解析失败:%v", err)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10699. res2.Output = resSix10265.Output
  10700. res2.ErrMsg = resSix10265.ErrMsg
  10701. res2.Cainfo = resSix10265.Cainfo
  10702. res2.WarnMsg = resSix10265.WarnMsg
  10703. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10704. res2.Infcode = infocode
  10705. } else {
  10706. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10707. utils.ErrorLog("解析失败:%v", err)
  10708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10709. return
  10710. }
  10711. }
  10712. }
  10713. if res2.Infcode == 0 {
  10714. if err == nil {
  10715. c.ServeSuccessJSON(map[string]interface{}{
  10716. "msg": "退号成功",
  10717. })
  10718. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10719. } else {
  10720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10721. return
  10722. }
  10723. } else {
  10724. c.ServeSuccessJSON(map[string]interface{}{
  10725. "code": -10,
  10726. "msg": res2.ErrMsg,
  10727. })
  10728. }
  10729. } else {
  10730. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10731. //if err == nil {
  10732. // c.ServeSuccessJSON(map[string]interface{}{
  10733. // "msg": "退费成功",
  10734. // })
  10735. //} else {
  10736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10737. // return
  10738. //}
  10739. }
  10740. }
  10741. func (c *HisApiController) RefundDetail() {
  10742. order_id, _ := c.GetInt64("order_id")
  10743. admin_user_id, _ := c.GetInt64("admin_user_id")
  10744. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10745. number := c.GetString("number")
  10746. record_time := c.GetString("record_time")
  10747. patient_id, _ := c.GetInt64("patient_id")
  10748. //med_type, _ := c.GetInt64("med_type")
  10749. timeLayout := "2006-01-02"
  10750. loc, _ := time.LoadLocation("Local")
  10751. adminUser := c.GetAdminUserInfo()
  10752. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10753. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10754. fmt.Println(err)
  10755. if err != nil {
  10756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10757. return
  10758. }
  10759. recordDateTime := theTime.Unix()
  10760. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10761. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10763. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10764. var order models.HisOrder
  10765. order, _ = service.GetHisOrderByID(order_id)
  10766. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10767. if config.IsOpen == 1 { //对接了医保,走医保流程
  10768. var res2 ResultSix
  10769. if miConfig.MdtrtareaAdmvs == "421300" {
  10770. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10771. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10772. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10773. resp3, requestErr3 := http.Get(api3)
  10774. if requestErr3 != nil {
  10775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. return
  10777. }
  10778. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10779. if ioErr3 != nil {
  10780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. var respJSON3 map[string]interface{}
  10785. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10791. userJSONBytes3, _ := json.Marshal(respJSON3)
  10792. fmt.Println("log")
  10793. fmt.Println(string(userJSONBytes3))
  10794. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10795. utils.ErrorLog("解析失败:%v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return
  10798. }
  10799. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10800. if err == nil {
  10801. c.ServeSuccessJSON(map[string]interface{}{
  10802. "msg": "撤销明细成功",
  10803. })
  10804. return
  10805. } else {
  10806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10807. return
  10808. }
  10809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10810. var resSix10265 ResultSix10265
  10811. var api3 string
  10812. if miConfig.MdtrtareaAdmvs == "320921" {
  10813. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10814. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10815. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10816. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10817. } else {
  10818. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10819. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10820. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10822. }
  10823. resp3, requestErr3 := http.Get(api3)
  10824. if requestErr3 != nil {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10826. return
  10827. }
  10828. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10829. if ioErr3 != nil {
  10830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10832. return
  10833. }
  10834. var respJSON3 map[string]interface{}
  10835. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10838. return
  10839. }
  10840. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10841. userJSONBytes3, _ := json.Marshal(respJSON3)
  10842. fmt.Println("log")
  10843. fmt.Println(string(userJSONBytes3))
  10844. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10845. utils.ErrorLog("解析失败:%v", err)
  10846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10847. return
  10848. }
  10849. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10850. res2.Output = resSix10265.Output
  10851. res2.ErrMsg = resSix10265.ErrMsg
  10852. res2.Cainfo = resSix10265.Cainfo
  10853. res2.WarnMsg = resSix10265.WarnMsg
  10854. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10855. res2.Infcode = infocode
  10856. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10857. if err == nil {
  10858. c.ServeSuccessJSON(map[string]interface{}{
  10859. "msg": "撤销明细成功",
  10860. })
  10861. return
  10862. } else {
  10863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10864. return
  10865. }
  10866. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10867. 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)
  10868. var dat map[string]interface{}
  10869. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10870. fmt.Println(dat)
  10871. } else {
  10872. fmt.Println(err)
  10873. }
  10874. saveLog(result2, src_request, "2205", "撤销明细")
  10875. userJSONBytes, _ := json.Marshal(dat)
  10876. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10877. utils.ErrorLog("解析失败:%v", err)
  10878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10879. return
  10880. }
  10881. if res2.Infcode == 0 {
  10882. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10883. if err == nil {
  10884. c.ServeSuccessJSON(map[string]interface{}{
  10885. "msg": "撤销明细成功",
  10886. })
  10887. return
  10888. } else {
  10889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10890. return
  10891. }
  10892. } else {
  10893. c.ServeSuccessJSON(map[string]interface{}{
  10894. "code": -10,
  10895. "msg": res2.ErrMsg,
  10896. })
  10897. }
  10898. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10899. 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, "")
  10900. var dat map[string]interface{}
  10901. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10902. fmt.Println(dat)
  10903. } else {
  10904. fmt.Println(err)
  10905. }
  10906. saveLog(result2, src_request, "2205", "撤销明细")
  10907. userJSONBytes, _ := json.Marshal(dat)
  10908. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10909. utils.ErrorLog("解析失败:%v", err)
  10910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10911. return
  10912. }
  10913. if res2.Infcode == 0 {
  10914. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10915. if err == nil {
  10916. c.ServeSuccessJSON(map[string]interface{}{
  10917. "msg": "撤销明细成功",
  10918. })
  10919. return
  10920. } else {
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. return
  10923. }
  10924. } else {
  10925. c.ServeSuccessJSON(map[string]interface{}{
  10926. "code": -10,
  10927. "msg": res2.ErrMsg,
  10928. })
  10929. }
  10930. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10931. 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, "")
  10932. var dat map[string]interface{}
  10933. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10934. fmt.Println(dat)
  10935. } else {
  10936. fmt.Println(err)
  10937. }
  10938. saveLog(result2, src_request, "2205", "撤销明细")
  10939. userJSONBytes, _ := json.Marshal(dat)
  10940. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10941. utils.ErrorLog("解析失败:%v", err)
  10942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10943. return
  10944. }
  10945. if res2.Infcode == 0 {
  10946. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10947. if err == nil {
  10948. c.ServeSuccessJSON(map[string]interface{}{
  10949. "msg": "撤销明细成功",
  10950. })
  10951. return
  10952. } else {
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. } else {
  10957. c.ServeSuccessJSON(map[string]interface{}{
  10958. "code": -10,
  10959. "msg": res2.ErrMsg,
  10960. })
  10961. }
  10962. } else {
  10963. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  10964. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10966. resp2, requestErr2 := http.Get(api2)
  10967. if requestErr2 != nil {
  10968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10969. return
  10970. }
  10971. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10972. if ioErr2 != nil {
  10973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10975. return
  10976. }
  10977. var respJSON2 map[string]interface{}
  10978. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10981. return
  10982. }
  10983. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10984. if err == nil {
  10985. c.ServeSuccessJSON(map[string]interface{}{
  10986. "msg": "撤销明细成功",
  10987. })
  10988. return
  10989. } else {
  10990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10991. return
  10992. }
  10993. }
  10994. } else {
  10995. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10996. if err == nil {
  10997. c.ServeSuccessJSON(map[string]interface{}{
  10998. "msg": "退费成功",
  10999. })
  11000. } else {
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. }
  11005. }
  11006. //对账
  11007. func (c *HisApiController) GetCheckAccount() {
  11008. start_time := c.GetString("start_time")
  11009. end_time := c.GetString("end_time")
  11010. insutype := c.GetString("insutype")
  11011. clr_type := c.GetString("clr_type")
  11012. clr_org := c.GetString("clr_optins")
  11013. admin_user_id, _ := c.GetInt64("admin_user_id")
  11014. adminUser := c.GetAdminUserInfo()
  11015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11017. if len(clr_org) == 0 {
  11018. clr_org = miConfig.MdtrtareaAdmvs
  11019. }
  11020. timeLayout := "2006-01-02"
  11021. loc, _ := time.LoadLocation("Local")
  11022. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11023. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11024. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11025. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11026. fixmedins_setl_cnt := int64(len(orders))
  11027. var medfee_sumamt float64
  11028. var acct_pay float64
  11029. var fund_pay_sumamt float64
  11030. for _, item := range orders {
  11031. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11032. acct_pay = acct_pay + item.AcctPay
  11033. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11034. }
  11035. var user_name string
  11036. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11037. if role.ID == 0 {
  11038. user_name = "xxx"
  11039. } else {
  11040. user_name = role.UserName
  11041. }
  11042. var res ResultEight
  11043. var res10188 ResultEightFor10188
  11044. if config.IsOpen == 1 {
  11045. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11046. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11047. "insutype=" + insutype +
  11048. "&clr_type=" + clr_type +
  11049. "&setl_optins=" + clr_org +
  11050. "&stmt_begndate=" + start_time +
  11051. "&stm_enddate=" + end_time +
  11052. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11053. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11054. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11055. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11056. "&fixmedins_code=" + miConfig.Code +
  11057. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11058. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11059. "&secret_key=" + miConfig.SecretKey +
  11060. "&org_name=" + miConfig.OrgName +
  11061. "&doctor=" + user_name +
  11062. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11063. fmt.Println(api)
  11064. resp, requestErr := http.Get(api)
  11065. if requestErr != nil {
  11066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11067. return
  11068. }
  11069. body, ioErr := ioutil.ReadAll(resp.Body)
  11070. fmt.Println(body)
  11071. if ioErr != nil {
  11072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11074. return
  11075. }
  11076. var respJSON map[string]interface{}
  11077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return
  11081. }
  11082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11083. userJSONBytes, _ := json.Marshal(respJSON)
  11084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11085. utils.ErrorLog("解析失败:%v", err)
  11086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11087. return
  11088. }
  11089. res.InfRefmsgid = res10188.InfRefmsgid
  11090. res.Output = res10188.Output
  11091. res.ErrMsg = res10188.ErrMsg
  11092. res.Cainfo = res10188.Cainfo
  11093. res.WarnMsg = res10188.WarnMsg
  11094. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11095. res.Infcode = infocode
  11096. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11097. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11098. "insutype=" + insutype +
  11099. "&clr_type=" + "21" +
  11100. "&setl_optins=" + clr_org +
  11101. "&stmt_begndate=" + start_time +
  11102. "&stm_enddate=" + end_time +
  11103. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11104. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11105. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11106. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11107. "&fixmedins_code=" + miConfig.Code +
  11108. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11109. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11110. "&secret_key=" + miConfig.SecretKey +
  11111. "&org_name=" + miConfig.OrgName +
  11112. "&doctor=" + user_name
  11113. resp, requestErr := http.Get(api)
  11114. if requestErr != nil {
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. return
  11117. }
  11118. body, ioErr := ioutil.ReadAll(resp.Body)
  11119. if ioErr != nil {
  11120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11122. return
  11123. }
  11124. var respJSON map[string]interface{}
  11125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11128. return
  11129. }
  11130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11131. result, _ := json.Marshal(respJSON)
  11132. fmt.Println("log")
  11133. fmt.Println(string(result))
  11134. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11135. utils.ErrorLog("解析失败:%v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. res.InfRefmsgid = res10188.InfRefmsgid
  11140. res.Output = res10188.Output
  11141. res.ErrMsg = res10188.ErrMsg
  11142. res.Cainfo = res10188.Cainfo
  11143. res.WarnMsg = res10188.WarnMsg
  11144. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11145. res.Infcode = infocode
  11146. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11147. var baseParams models.BaseParams
  11148. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11149. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11150. baseParams.SecretKey = miConfig.SecretKey
  11151. baseParams.OrgName = miConfig.OrgName
  11152. baseParams.FixmedinsCode = miConfig.Code
  11153. baseParams.EncKey = miConfig.EncKey
  11154. baseParams.AppSecret = miConfig.AppSecret
  11155. baseParams.SignKey = miConfig.SignKey
  11156. baseParams.AppID = miConfig.Code
  11157. baseParams.Doctor = role.UserName
  11158. baseParams.RequestUrl = miConfig.Url
  11159. businessParams := models.BusinessParams{
  11160. Insutype: insutype,
  11161. ClrType: clr_type,
  11162. SetlOptins: clr_org,
  11163. StmtBegndate: start_time,
  11164. StmtEnddate: end_time,
  11165. MedfeeSumamt: medfee_sumamt,
  11166. FundPaySumamt: fund_pay_sumamt,
  11167. AcctPay: acct_pay,
  11168. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11169. }
  11170. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11171. fmt.Println(requestLog)
  11172. fmt.Println(result)
  11173. fmt.Println(err_msg)
  11174. var dat map[string]interface{}
  11175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11176. fmt.Println(dat)
  11177. } else {
  11178. fmt.Println(err)
  11179. }
  11180. userJSONBytes, _ := json.Marshal(dat)
  11181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11182. utils.ErrorLog("解析失败:%v", err)
  11183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11184. return
  11185. }
  11186. } else if miConfig.MdtrtareaAdmvs == "" {
  11187. var baseParams models.BaseParams
  11188. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11189. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11190. baseParams.SecretKey = miConfig.SecretKey
  11191. baseParams.OrgName = miConfig.OrgName
  11192. baseParams.FixmedinsCode = miConfig.Code
  11193. baseParams.EncKey = miConfig.EncKey
  11194. baseParams.AppSecret = miConfig.AppSecret
  11195. baseParams.SignKey = miConfig.SignKey
  11196. baseParams.AppID = miConfig.Code
  11197. baseParams.Doctor = role.UserName
  11198. baseParams.RequestUrl = miConfig.Url
  11199. businessParams := models.BusinessParams{
  11200. Insutype: insutype,
  11201. ClrType: clr_type,
  11202. SetlOptins: clr_org,
  11203. StmtBegndate: start_time,
  11204. StmtEnddate: end_time,
  11205. MedfeeSumamt: medfee_sumamt,
  11206. FundPaySumamt: fund_pay_sumamt,
  11207. AcctPay: acct_pay,
  11208. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11209. }
  11210. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11211. fmt.Println(requestLog)
  11212. fmt.Println(result)
  11213. fmt.Println(err_msg)
  11214. var dat map[string]interface{}
  11215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11216. fmt.Println(dat)
  11217. } else {
  11218. fmt.Println(err)
  11219. }
  11220. userJSONBytes, _ := json.Marshal(dat)
  11221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11222. utils.ErrorLog("解析失败:%v", err)
  11223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11224. return
  11225. }
  11226. } else {
  11227. if len(clr_type) == 0 {
  11228. clr_type = "11"
  11229. }
  11230. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11231. "insutype=" + insutype +
  11232. "&clr_type=" + clr_type +
  11233. "&setl_optins=" + clr_org +
  11234. "&stmt_begndate=" + start_time +
  11235. "&stm_enddate=" + end_time +
  11236. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11237. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11238. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11239. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11240. "&fixmedins_code=" + miConfig.Code +
  11241. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11242. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11243. "&secret_key=" + miConfig.SecretKey +
  11244. "&org_name=" + miConfig.OrgName +
  11245. "&doctor=" + user_name
  11246. fmt.Println(api)
  11247. resp, requestErr := http.Get(api)
  11248. if requestErr != nil {
  11249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11250. return
  11251. }
  11252. body, ioErr := ioutil.ReadAll(resp.Body)
  11253. fmt.Println(body)
  11254. if ioErr != nil {
  11255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11257. return
  11258. }
  11259. var respJSON map[string]interface{}
  11260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11263. return
  11264. }
  11265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11266. userJSONBytes, _ := json.Marshal(respJSON)
  11267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11268. utils.ErrorLog("解析失败:%v", err)
  11269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11270. return
  11271. }
  11272. }
  11273. if res.Infcode == 0 {
  11274. if res.Output.Stmtinfo.StmtRslt == "0" {
  11275. micc := &models.MedicalInsuranceCostCompare{
  11276. StartTime: startime.Unix(),
  11277. EndTime: endtime.Unix(),
  11278. Insutype: insutype,
  11279. CheckType: 1,
  11280. Num: fixmedins_setl_cnt,
  11281. Mtime: time.Now().Unix(),
  11282. Status: 1,
  11283. UserOrgId: adminUser.CurrentOrgId,
  11284. CostTotal: medfee_sumamt,
  11285. FuncTotal: fund_pay_sumamt,
  11286. PsnPay: acct_pay,
  11287. Creator: admin_user_id,
  11288. Ctime: time.Now().Unix(),
  11289. ClrType: clr_type,
  11290. }
  11291. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11292. if err == nil {
  11293. c.ServeSuccessJSON(map[string]interface{}{
  11294. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11295. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11296. })
  11297. } else {
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. }
  11300. } else {
  11301. c.ServeSuccessJSON(map[string]interface{}{
  11302. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11303. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11304. })
  11305. }
  11306. } else {
  11307. c.ServeSuccessJSON(map[string]interface{}{
  11308. "code": -10,
  11309. "msg": res.ErrMsg,
  11310. })
  11311. }
  11312. }
  11313. }
  11314. func (c *HisApiController) Check310() {
  11315. adminUser := c.GetAdminUserInfo()
  11316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11317. var user_name string
  11318. user_name = "高慧裕"
  11319. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11320. "insutype=" + "310" +
  11321. "&clr_type=" + "" +
  11322. "&setl_optins=" + "441202" +
  11323. "&stmt_begndate=" + "2022-03-01" +
  11324. "&stm_enddate=" + "2022-03-31" +
  11325. "&medfee_sumamt=" + "194930.12" +
  11326. "&fund_pay_sumamt=" + "188741.46" +
  11327. "&acct_pay=" + "0" +
  11328. "&fixmedins_setl_cnt=" + "452" +
  11329. "&fixmedins_code=" + miConfig.Code +
  11330. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11331. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11332. "&secret_key=" + miConfig.SecretKey +
  11333. "&org_name=" + miConfig.OrgName +
  11334. "&doctor=" + user_name
  11335. fmt.Println(api)
  11336. resp, requestErr := http.Get(api)
  11337. if requestErr != nil {
  11338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11339. return
  11340. }
  11341. body, ioErr := ioutil.ReadAll(resp.Body)
  11342. fmt.Println(body)
  11343. if ioErr != nil {
  11344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11346. return
  11347. }
  11348. var respJSON map[string]interface{}
  11349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11352. return
  11353. }
  11354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11355. userJSONBytes, _ := json.Marshal(respJSON)
  11356. var res ResultEight
  11357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11358. utils.ErrorLog("解析失败:%v", err)
  11359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11360. return
  11361. }
  11362. }
  11363. func (c *HisApiController) Check390() {
  11364. adminUser := c.GetAdminUserInfo()
  11365. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11366. var user_name string
  11367. user_name = "高慧裕"
  11368. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11369. "insutype=" + "390" +
  11370. "&clr_type=" + "" +
  11371. "&setl_optins=" + "441202" +
  11372. "&stmt_begndate=" + "2022-03-01" +
  11373. "&stm_enddate=" + "2022-03-31" +
  11374. "&medfee_sumamt=" + "1068448.89" +
  11375. "&fund_pay_sumamt=" + "1014677.62" +
  11376. "&acct_pay=" + "0" +
  11377. "&fixmedins_setl_cnt=" + "1950" +
  11378. "&fixmedins_code=" + miConfig.Code +
  11379. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11380. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11381. "&secret_key=" + miConfig.SecretKey +
  11382. "&org_name=" + miConfig.OrgName +
  11383. "&doctor=" + user_name
  11384. fmt.Println(api)
  11385. resp, requestErr := http.Get(api)
  11386. if requestErr != nil {
  11387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11388. return
  11389. }
  11390. body, ioErr := ioutil.ReadAll(resp.Body)
  11391. fmt.Println(body)
  11392. if ioErr != nil {
  11393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11395. return
  11396. }
  11397. var respJSON map[string]interface{}
  11398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11401. return
  11402. }
  11403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11404. userJSONBytes, _ := json.Marshal(respJSON)
  11405. var res ResultEight
  11406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11407. utils.ErrorLog("解析失败:%v", err)
  11408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11409. return
  11410. }
  11411. }
  11412. //对账明细
  11413. func (c *HisApiController) GetCheckDetailAccount() {
  11414. start_time := c.GetString("start_time")
  11415. end_time := c.GetString("end_time")
  11416. admin_user_id, _ := c.GetInt64("admin_user_id")
  11417. adminUser := c.GetAdminUserInfo()
  11418. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11419. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11420. timeLayout := "2006-01-02"
  11421. loc, _ := time.LoadLocation("Local")
  11422. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11423. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11424. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11425. rand.Seed(time.Now().UnixNano())
  11426. num := rand.Intn(30000)
  11427. Mkdir(miConfig.OrgName)
  11428. file := strconv.FormatInt(int64(num), 10)
  11429. file_name := file + ".txt"
  11430. zip_name := file + ".zip"
  11431. zip_path := miConfig.OrgName + "/" + zip_name
  11432. file_path := miConfig.OrgName + "/" + file_name
  11433. decimal.DivisionPrecision = 2
  11434. var medfee_sumamt float64
  11435. var psn_cash_pay float64
  11436. var fund_pay_sumamt float64
  11437. fixmedins_setl_cnt := int64(len(orders))
  11438. for _, item := range orders {
  11439. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11440. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11441. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11442. }
  11443. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11444. defer f.Close()
  11445. if err != nil {
  11446. fmt.Println(err.Error())
  11447. } else {
  11448. for _, item := range orders {
  11449. var refd_setl_flag string
  11450. if item.OrderStatus == 2 {
  11451. refd_setl_flag = "0"
  11452. var str string
  11453. str = item.SetlId + " " +
  11454. item.MdtrtId + " " +
  11455. item.PsnNo + " " +
  11456. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11457. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11458. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11459. _, err = f.Write([]byte(str))
  11460. }
  11461. if item.OrderStatus == 3 {
  11462. var str string
  11463. str = item.SetlId + " " +
  11464. item.MdtrtId + " " +
  11465. item.PsnNo + " " +
  11466. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11467. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11468. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11469. _, err = f.Write([]byte(str))
  11470. var str2 string
  11471. str2 = item.SetlId + " " +
  11472. item.MdtrtId + " " +
  11473. item.PsnNo + " " +
  11474. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11475. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11476. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11477. _, err = f.Write([]byte(str2))
  11478. }
  11479. }
  11480. }
  11481. Zip(file_path, zip_path)
  11482. fmt.Println(ReadFile(zip_path))
  11483. fmt.Println(string(ReadFile(zip_path)))
  11484. if config.IsOpen == 1 {
  11485. var user_name string
  11486. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11487. if role.ID == 0 {
  11488. user_name = "管理员"
  11489. } else {
  11490. user_name = role.UserName
  11491. }
  11492. baseParams := models.BaseParams{
  11493. SecretKey: miConfig.SecretKey,
  11494. FixmedinsCode: miConfig.Code,
  11495. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11496. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11497. OrgName: miConfig.OrgName,
  11498. Doctor: user_name,
  11499. }
  11500. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11501. var dat map[string]interface{}
  11502. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11503. fmt.Println(dat)
  11504. } else {
  11505. fmt.Println(err)
  11506. }
  11507. userJSONBytes, _ := json.Marshal(dat)
  11508. var res ResultNine
  11509. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11510. utils.ErrorLog("解析失败:%v", err)
  11511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11512. return
  11513. }
  11514. if res.Infcode == 0 {
  11515. fileNo := res.Output.FileQuryNo
  11516. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11517. "file_qury_no=" + fileNo +
  11518. "&setl_optins=" + "定点医保中心" +
  11519. "&stmt_begndate=" + start_time +
  11520. "&stm_enddate=" + end_time +
  11521. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11522. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11523. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11524. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11525. "&fixmedins_code=" + miConfig.Code +
  11526. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11527. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11528. "&secret_key=" + miConfig.SecretKey +
  11529. "&org_name=" + miConfig.OrgName +
  11530. "&doctor=" + user_name
  11531. resp, requestErr := http.Get(api)
  11532. if requestErr != nil {
  11533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11534. return
  11535. }
  11536. body, ioErr := ioutil.ReadAll(resp.Body)
  11537. if ioErr != nil {
  11538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11540. return
  11541. }
  11542. var respJSON map[string]interface{}
  11543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11549. userJSONBytes, _ := json.Marshal(respJSON)
  11550. var res ResultTen
  11551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11552. utils.ErrorLog("解析失败:%v", err)
  11553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11554. return
  11555. }
  11556. if res.Infcode == 0 {
  11557. service.Gdyb9102(baseParams, zip_name, fileNo)
  11558. micc := &models.MedicalInsuranceCostCompare{
  11559. StartTime: startime.Unix(),
  11560. EndTime: endtime.Unix(),
  11561. Insutype: "0",
  11562. CheckType: 2,
  11563. Num: fixmedins_setl_cnt,
  11564. Mtime: time.Now().Unix(),
  11565. Status: 1,
  11566. UserOrgId: adminUser.CurrentOrgId,
  11567. CostTotal: medfee_sumamt,
  11568. FuncTotal: fund_pay_sumamt,
  11569. PsnPay: psn_cash_pay,
  11570. Creator: admin_user_id,
  11571. Ctime: time.Now().Unix(),
  11572. }
  11573. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11574. c.ServeSuccessJSON(map[string]interface{}{
  11575. "msg": "明细对账成功",
  11576. })
  11577. }
  11578. } else {
  11579. }
  11580. }
  11581. }
  11582. type CustomOrderInfo struct {
  11583. Name string
  11584. Spec string
  11585. Unit string
  11586. Count float64
  11587. Price float64
  11588. Total float64
  11589. }
  11590. func (c *HisApiController) GetSettleAccounts() {
  11591. //id, _ := c.GetInt64("id")
  11592. //record_time := c.GetString("record_time")
  11593. order_id, _ := c.GetInt64("order_id")
  11594. admin_user_id, _ := c.GetInt64("admin_user_id")
  11595. //timeLayout := "2006-01-02"
  11596. //loc, _ := time.LoadLocation("Local")
  11597. //
  11598. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11599. //if err != nil {
  11600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11601. // return
  11602. //}
  11603. //recordDateTime := theTime.Unix()
  11604. adminUser := c.GetAdminUserInfo()
  11605. order, _ := service.GetHisOrderByID(order_id)
  11606. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11607. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11608. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11609. orderInfos = append(orderInfos, orderInfos_two...)
  11610. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11611. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11612. var diagnosis_ids []string
  11613. if his.ID > 0 {
  11614. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11615. } else {
  11616. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11617. }
  11618. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11619. var dia_config []*models.HisXtDiagnoseConfig
  11620. var name string
  11621. for _, item := range diagnosis_ids {
  11622. id, _ := strconv.ParseInt(item, 10, 64)
  11623. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11624. dia_config = append(dia_config, &diagnosisConfig)
  11625. if len(name) == 0 {
  11626. name = diagnosisConfig.ClassName
  11627. } else {
  11628. name = name + "," + diagnosisConfig.ClassName
  11629. }
  11630. }
  11631. var bedCostTotal float64 = 0 //床位总费
  11632. var bedCostSelfTotal float64 = 0 //床位自费
  11633. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11634. var operationCostTotal float64 = 0 //手术费
  11635. var operationCostSelfTotal float64 = 0 //手术费
  11636. var operationCostPartSelfTotal float64 = 0 //手术费
  11637. var otherCostTotal float64 = 0 //其他费用
  11638. var otherCostSelfTotal float64 = 0 //其他费用
  11639. var otherCostPartSelfTotal float64 = 0 //其他费用
  11640. var materialCostTotal float64 = 0 //材料费
  11641. var materialCostSelfTotal float64 = 0 //材料费
  11642. var materialCostPartSelfTotal float64 = 0 //材料费
  11643. var westernMedicineCostTotal float64 = 0 //西药费
  11644. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11645. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11646. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11647. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11648. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11649. var checkCostTotal float64 = 0 //检查费
  11650. var checkCostSelfTotal float64 = 0 //检查费
  11651. var checkCostPartSelfTotal float64 = 0 //检查费
  11652. var laboratoryCostTotal float64 = 0 //化验费
  11653. var laboratoryCostSelfTotal float64 = 0 //化验费
  11654. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11655. var treatCostTotal float64 = 0 //治疗费用
  11656. var treatCostSelfTotal float64 = 0 //治疗费用
  11657. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11658. decimal.DivisionPrecision = 2
  11659. for _, item := range orderInfos {
  11660. if item.MedChrgitmType == "01" { //床位费
  11661. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11662. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11663. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11664. }
  11665. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11666. if item.MedChrgitmType == "03" { //检查费
  11667. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11668. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11669. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11670. }
  11671. } else {
  11672. if item.MedChrgitmType == "03" { //检查费
  11673. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11674. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11675. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11676. }
  11677. }
  11678. if item.MedChrgitmType == "04" { //化验费
  11679. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11680. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11681. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11682. }
  11683. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11684. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11685. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11686. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11687. }
  11688. if item.MedChrgitmType == "06" { //手术费
  11689. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11690. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11691. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11692. }
  11693. if item.MedChrgitmType == "08" { //材料费
  11694. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11695. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11696. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11697. }
  11698. if item.MedChrgitmType == "09" { //西药费
  11699. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11700. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11701. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11702. }
  11703. if item.MedChrgitmType == "11" { //中成费
  11704. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11705. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11706. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11707. }
  11708. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11709. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11710. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11711. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11712. }
  11713. }
  11714. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11715. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11716. var user_name string
  11717. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11718. if role.ID == 0 {
  11719. user_name = "管理员"
  11720. } else {
  11721. user_name = role.UserName
  11722. }
  11723. baseParams := models.BaseParams{
  11724. SecretKey: miConfig.SecretKey,
  11725. FixmedinsCode: miConfig.Code,
  11726. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11727. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11728. OrgName: miConfig.OrgName,
  11729. Doctor: user_name,
  11730. RequestUrl: miConfig.Url,
  11731. AccessKey: miConfig.AccessKey,
  11732. }
  11733. businessParams := models.BusinessParams{
  11734. PsnNo: order.PsnNo,
  11735. MdtrtId: order.MdtrtId,
  11736. SetlId: order.SetlId,
  11737. }
  11738. var res ResultEleven
  11739. var resEleven10265 ResultEleven10265
  11740. if config.IsOpen == 1 {
  11741. if miConfig.MdtrtareaAdmvs == "421300" {
  11742. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11743. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11745. resp, requestErr := http.Get(api)
  11746. if requestErr != nil {
  11747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11748. return
  11749. }
  11750. body, ioErr := ioutil.ReadAll(resp.Body)
  11751. if ioErr != nil {
  11752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11754. return
  11755. }
  11756. var respJSON map[string]interface{}
  11757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11760. return
  11761. }
  11762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11763. result, _ := json.Marshal(respJSON)
  11764. fmt.Println("log")
  11765. fmt.Println(string(result))
  11766. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11767. utils.ErrorLog("解析失败:%v", err)
  11768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11769. return
  11770. }
  11771. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11772. var api string
  11773. if miConfig.MdtrtareaAdmvs == "320921" {
  11774. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11775. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11776. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11777. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11778. } else {
  11779. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11780. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11781. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11782. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11783. }
  11784. resp, requestErr := http.Get(api)
  11785. if requestErr != nil {
  11786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11787. return
  11788. }
  11789. body, ioErr := ioutil.ReadAll(resp.Body)
  11790. if ioErr != nil {
  11791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11793. return
  11794. }
  11795. var respJSON map[string]interface{}
  11796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return
  11800. }
  11801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11802. result, _ := json.Marshal(respJSON)
  11803. fmt.Println("log")
  11804. fmt.Println(string(result))
  11805. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11806. utils.ErrorLog("解析失败:%v", err)
  11807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11808. return
  11809. }
  11810. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11811. res.Output = resEleven10265.Output
  11812. res.ErrMsg = resEleven10265.ErrMsg
  11813. res.Cainfo = resEleven10265.Cainfo
  11814. res.WarnMsg = resEleven10265.WarnMsg
  11815. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11816. res.Infcode = infocode
  11817. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11818. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11819. saveLog(result, requestLog, "5203", "结算单")
  11820. var dat map[string]interface{}
  11821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11822. fmt.Println(dat)
  11823. } else {
  11824. fmt.Println(err)
  11825. }
  11826. userJSONBytes, _ := json.Marshal(dat)
  11827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11828. utils.ErrorLog("解析失败:%v", err)
  11829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11830. return
  11831. }
  11832. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11833. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  11834. saveLog(result, requestLog, "5203", "结算单")
  11835. var dat map[string]interface{}
  11836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11837. fmt.Println(dat)
  11838. } else {
  11839. fmt.Println(err)
  11840. }
  11841. userJSONBytes, _ := json.Marshal(dat)
  11842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11843. utils.ErrorLog("解析失败:%v", err)
  11844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11845. return
  11846. }
  11847. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11848. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  11849. saveLog(result, requestLog, "5203", "结算单")
  11850. var dat map[string]interface{}
  11851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11852. fmt.Println(dat)
  11853. } else {
  11854. fmt.Println(err)
  11855. }
  11856. userJSONBytes, _ := json.Marshal(dat)
  11857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11858. utils.ErrorLog("解析失败:%v", err)
  11859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11860. return
  11861. }
  11862. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11863. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11864. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11865. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11866. resp, requestErr := http.Get(api)
  11867. if requestErr != nil {
  11868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11869. return
  11870. }
  11871. body, ioErr := ioutil.ReadAll(resp.Body)
  11872. if ioErr != nil {
  11873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11875. return
  11876. }
  11877. var respJSON map[string]interface{}
  11878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. return
  11882. }
  11883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11884. result, _ := json.Marshal(respJSON)
  11885. fmt.Println("log")
  11886. fmt.Println(string(result))
  11887. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11888. utils.ErrorLog("解析失败:%v", err)
  11889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11890. return
  11891. }
  11892. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11893. res.Output = resEleven10265.Output
  11894. res.ErrMsg = resEleven10265.ErrMsg
  11895. res.Cainfo = resEleven10265.Cainfo
  11896. res.WarnMsg = resEleven10265.WarnMsg
  11897. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11898. res.Infcode = infocode
  11899. } else {
  11900. result := service.Gdyb5203(baseParams, businessParams)
  11901. //service.Gdyb5204(baseParams, businessParams)
  11902. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  11903. var dat map[string]interface{}
  11904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11905. fmt.Println(dat)
  11906. } else {
  11907. fmt.Println(err)
  11908. }
  11909. userJSONBytes, _ := json.Marshal(dat)
  11910. if miConfig.Code == "H15049901371" {
  11911. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  11912. utils.ErrorLog("解析失败:%v", err)
  11913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11914. return
  11915. }
  11916. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11917. res.Output = resEleven10265.Output
  11918. res.ErrMsg = resEleven10265.ErrMsg
  11919. res.Cainfo = resEleven10265.Cainfo
  11920. res.WarnMsg = resEleven10265.WarnMsg
  11921. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11922. res.Infcode = infocode
  11923. } else {
  11924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11925. utils.ErrorLog("解析失败:%v", err)
  11926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11927. return
  11928. }
  11929. }
  11930. }
  11931. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11932. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  11933. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  11934. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11935. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  11936. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11937. var doctor_name string
  11938. if roles.ID == 0 {
  11939. doctor_name = "管理员"
  11940. } else {
  11941. doctor_name = roles.UserName
  11942. }
  11943. yiliao_leibie := ""
  11944. switch order.MedType {
  11945. case "11":
  11946. yiliao_leibie = "普通门诊"
  11947. break
  11948. case "12":
  11949. yiliao_leibie = "门诊挂号"
  11950. break
  11951. case "13":
  11952. yiliao_leibie = "急诊"
  11953. break
  11954. case "14":
  11955. yiliao_leibie = "门诊特殊病"
  11956. break
  11957. case "15":
  11958. yiliao_leibie = "门诊统筹"
  11959. break
  11960. case "16":
  11961. yiliao_leibie = "门诊慢性病"
  11962. break
  11963. case "21":
  11964. yiliao_leibie = "普通住院"
  11965. break
  11966. }
  11967. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11968. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  11969. if res.Infcode == 0 {
  11970. c.ServeSuccessJSON(map[string]interface{}{
  11971. "diagnosis": name,
  11972. "order_infos": orderInfos,
  11973. "number": order.MdtrtId,
  11974. "date": order.SettleAccountsDate,
  11975. "charge_admin": charge_admin,
  11976. "printor_admin": printor_admin,
  11977. "info": res.Output.Setlinfo,
  11978. "order": order,
  11979. "bedCostTotal": bedCostTotal,
  11980. "bedCostSelfTotal": bedCostSelfTotal,
  11981. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  11982. "operationCostTotal": operationCostTotal,
  11983. "operationCostSelfTotal": operationCostSelfTotal,
  11984. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  11985. "otherCostTotal": otherCostTotal,
  11986. "otherCostSelfTotal": otherCostSelfTotal,
  11987. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  11988. "materialCostTotal": materialCostTotal,
  11989. "materialCostSelfTotal": materialCostSelfTotal,
  11990. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  11991. "westernMedicineCostTotal": westernMedicineCostTotal,
  11992. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  11993. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  11994. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  11995. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  11996. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  11997. "checkCostTotal": checkCostTotal,
  11998. "checkCostSelfTotal": checkCostSelfTotal,
  11999. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12000. "laboratoryCostTotal": laboratoryCostTotal,
  12001. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12002. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12003. "treatCostTotal": treatCostTotal,
  12004. "treatCostSelfTotal": treatCostSelfTotal,
  12005. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12006. "doctor_info": doctor_info,
  12007. "doctor_code": adminRole_two.DoctorCode,
  12008. "doctor_name": doctor_name,
  12009. "health_card_no": order.PsnNo,
  12010. "department": departments.Name,
  12011. "yiliao_leibie": yiliao_leibie,
  12012. "after_money": order.AccountPrice,
  12013. "patient": patient,
  12014. "org_name": miConfig.OrgName,
  12015. "org_code": miConfig.Code,
  12016. "order_number": order.Number,
  12017. "his_hospital": his_hospital,
  12018. "his": his,
  12019. "dia_config": dia_config,
  12020. //"check_order_info": cus_slice,
  12021. })
  12022. }
  12023. }
  12024. }
  12025. func (c *HisApiController) CheckTreatment() {
  12026. patient_id, _ := c.GetInt64("patient_id")
  12027. id_card_no := c.GetString("id_card_no")
  12028. insutype := c.GetString("insutype")
  12029. med_type := c.GetString("med_type")
  12030. admin_user_id, _ := c.GetInt64("admin_user_id")
  12031. adminUser := c.GetAdminUserInfo()
  12032. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12033. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12034. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12035. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12036. if miConfig.MdtrtareaAdmvs == "421300" {
  12037. var res ResultTwo
  12038. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12039. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12040. "&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)
  12041. resp, requestErr := http.Get(api)
  12042. if requestErr != nil {
  12043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12044. return
  12045. }
  12046. body, ioErr := ioutil.ReadAll(resp.Body)
  12047. if ioErr != nil {
  12048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12050. return
  12051. }
  12052. var respJSON map[string]interface{}
  12053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12059. result, _ := json.Marshal(respJSON)
  12060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12061. utils.ErrorLog("解析失败:%v", err)
  12062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12063. return
  12064. }
  12065. if res.Infcode == 0 {
  12066. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12067. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12069. resp, requestErr := http.Get(api)
  12070. if requestErr != nil {
  12071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12072. return
  12073. }
  12074. body, ioErr := ioutil.ReadAll(resp.Body)
  12075. if ioErr != nil {
  12076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12078. return
  12079. }
  12080. var respJSON map[string]interface{}
  12081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12084. return
  12085. }
  12086. var res Result2001
  12087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12088. result2, _ := json.Marshal(respJSON)
  12089. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12090. utils.ErrorLog("解析失败:%v", err)
  12091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12092. return
  12093. }
  12094. if res.Infcode == 0 {
  12095. c.ServeSuccessJSON(map[string]interface{}{
  12096. "msg": res.Output.Trtinfo,
  12097. })
  12098. }
  12099. } else {
  12100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12101. return
  12102. }
  12103. } else {
  12104. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12105. var dat map[string]interface{}
  12106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12107. fmt.Println(dat)
  12108. } else {
  12109. fmt.Println(err)
  12110. }
  12111. userJSONBytes, _ := json.Marshal(dat)
  12112. var res ResultTwo
  12113. var res10265 ResultTwo10265
  12114. if miConfig.Code == "H15049901371" {
  12115. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12116. utils.ErrorLog("解析失败:%v", err)
  12117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12118. return
  12119. }
  12120. res.ErrMsg = res10265.ErrMsg
  12121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12122. res.Infcode = infocode
  12123. res.Output = res10265.Output
  12124. res.InfRefmsgid = res10265.InfRefmsgid
  12125. } else {
  12126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12127. utils.ErrorLog("解析失败:%v", err)
  12128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12129. return
  12130. }
  12131. }
  12132. var user_name string
  12133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12134. if role.ID == 0 {
  12135. user_name = "xxx"
  12136. } else {
  12137. user_name = role.UserName
  12138. }
  12139. baseParams := models.BaseParams{
  12140. SecretKey: miConfig.SecretKey,
  12141. FixmedinsCode: miConfig.Code,
  12142. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12143. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12144. OrgName: miConfig.OrgName,
  12145. Doctor: user_name,
  12146. }
  12147. if config.IsOpen == 1 {
  12148. if miConfig.Code == "H15049901371" {
  12149. if med_type == "14" {
  12150. if insutype == "390" {
  12151. med_type = "9933"
  12152. } else if insutype == "310" {
  12153. med_type = "990502"
  12154. }
  12155. } else if med_type == "11" {
  12156. med_type = "11"
  12157. }
  12158. }
  12159. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12160. var dat map[string]interface{}
  12161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12162. fmt.Println(dat)
  12163. } else {
  12164. fmt.Println(err)
  12165. }
  12166. var res Result2001
  12167. var res10265 Result2001Org10265
  12168. if miConfig.Code == "H15049901371" {
  12169. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12170. utils.ErrorLog("解析失败:%v", err)
  12171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12172. return
  12173. }
  12174. res.ErrMsg = res10265.ErrMsg
  12175. res.Output = res10265.Output
  12176. res.InfRefmsgid = res10265.InfRefmsgid
  12177. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12178. res.Infcode = infocode
  12179. } else {
  12180. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12181. utils.ErrorLog("解析失败:%v", err)
  12182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12183. return
  12184. }
  12185. }
  12186. if res.Infcode == 0 {
  12187. c.ServeSuccessJSON(map[string]interface{}{
  12188. "msg": res.Output.Trtinfo,
  12189. })
  12190. }
  12191. }
  12192. }
  12193. }
  12194. //func (c *HisApiController) PutRecord() {
  12195. // id, _ := c.GetInt64("id")
  12196. // record_time := c.GetString("record_time")
  12197. // timeLayout := "2006-01-02"
  12198. // loc, _ := time.LoadLocation("Local")
  12199. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12200. // if err != nil {
  12201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12202. // return
  12203. // }
  12204. // recordDateTime := theTime.Unix()
  12205. //
  12206. // adminInfo := c.GetAdminUserInfo()
  12207. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12208. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12209. //
  12210. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12211. //
  12212. // fmt.Println(miConfig.SecretKey)
  12213. //
  12214. // if patient == nil {
  12215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12216. // return
  12217. // }
  12218. // if len(patient.IdCardNo) == 0 {
  12219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12220. // return
  12221. // }
  12222. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12223. // if config.IsOpen == 1 {
  12224. // 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
  12225. // resp, requestErr := http.Get(api)
  12226. // if requestErr != nil {
  12227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12228. // return
  12229. // }
  12230. // defer resp.Body.Close()
  12231. // body, ioErr := ioutil.ReadAll(resp.Body)
  12232. // if ioErr != nil {
  12233. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. // return
  12236. // }
  12237. // var respJSON map[string]interface{}
  12238. //
  12239. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12240. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. // return
  12243. // }
  12244. //
  12245. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12246. // userJSONBytes, _ := json.Marshal(userJSON)
  12247. // var res ResultTwo
  12248. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12249. // utils.ErrorLog("解析失败:%v", err)
  12250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. // return
  12252. // }
  12253. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12254. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12255. // infoStr := string(Iinfos)
  12256. // idetinfoStr := string(Idetinfos)
  12257. //
  12258. // if res.Infcode == 0 {
  12259. // his := models.VMHisPatient{
  12260. // Status: 1,
  12261. // Ctime: time.Now().Unix(),
  12262. // Mtime: time.Now().Unix(),
  12263. // PsnNo: res.Output.Baseinfo.PsnNo,
  12264. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12265. // Certno: res.Output.Baseinfo.Certno,
  12266. // PsnName: res.Output.Baseinfo.PsnName,
  12267. // Gend: res.Output.Baseinfo.Gend,
  12268. // Naty: res.Output.Baseinfo.Naty,
  12269. // Brdy: res.Output.Baseinfo.Brdy,
  12270. // Age: res.Output.Baseinfo.Age,
  12271. // Iinfo: infoStr,
  12272. // Idetinfo: idetinfoStr,
  12273. // PatientId: patient.ID,
  12274. // RecordDate: theTime.Unix(),
  12275. // UserOrgId: adminInfo.CurrentOrgId,
  12276. // AdminUserId: adminInfo.AdminUser.Id,
  12277. // IsReturn: 1,
  12278. // }
  12279. //
  12280. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12281. // //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")
  12282. // //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")
  12283. //
  12284. // //var dat map[string]interface{}
  12285. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12286. // // fmt.Println(dat)
  12287. // //} else {
  12288. // // fmt.Println(err)
  12289. // //}
  12290. //
  12291. // var dat2 map[string]interface{}
  12292. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12293. // fmt.Println(dat2)
  12294. // } else {
  12295. // fmt.Println(err)
  12296. // }
  12297. //
  12298. // } else {
  12299. // adminUser := c.GetAdminUserInfo()
  12300. // errlog := &models.HisOrderError{
  12301. // UserOrgId: adminUser.CurrentOrgId,
  12302. // Ctime: time.Now().Unix(),
  12303. // Mtime: time.Now().Unix(),
  12304. // ErrMsg: res.ErrMsg,
  12305. // Status: 1,
  12306. // PatientId: id,
  12307. // RecordTime: recordDateTime,
  12308. // Stage: 1,
  12309. // }
  12310. // service.CreateErrMsgLog(errlog)
  12311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12312. // return
  12313. // }
  12314. // }
  12315. //
  12316. //}
  12317. //func (c *HisApiController) GetUploadDiag() {
  12318. // id, _ := c.GetInt64("id")
  12319. // record_time := c.GetString("record_time")
  12320. //
  12321. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12322. // sick_type, _ := c.GetInt64("sick_type")
  12323. // reg_type, _ := c.GetInt64("reg_type")
  12324. //
  12325. // timeLayout := "2006-01-02"
  12326. // loc, _ := time.LoadLocation("Local")
  12327. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12328. // if err != nil {
  12329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12330. // return
  12331. // }
  12332. //
  12333. // var patientPrescription models.HisPrescriptionInfo
  12334. // recordDateTime := theTime.Unix()
  12335. // adminInfo := c.GetAdminUserInfo()
  12336. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12337. //
  12338. // if patientPrescription.ID == 0 {
  12339. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12340. // }
  12341. //
  12342. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12343. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12344. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12345. // sickConfig, _ := service.FindSickById(sick_type)
  12346. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12347. //
  12348. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12349. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12350. // "&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 +
  12351. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12352. // resp2, requestErr2 := http.Get(api2)
  12353. // if requestErr2 != nil {
  12354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12355. // return
  12356. // }
  12357. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12358. // if ioErr2 != nil {
  12359. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. // return
  12362. // }
  12363. // var respJSON2 map[string]interface{}
  12364. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12365. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. // return
  12368. // }
  12369. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12370. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12371. //
  12372. // var res2 ResultSix
  12373. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12374. // utils.ErrorLog("解析失败:%v", err)
  12375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. // return
  12377. // }
  12378. // if res2.Infcode != 0 {
  12379. // adminUser := c.GetAdminUserInfo()
  12380. // errlog := &models.HisOrderError{
  12381. // UserOrgId: adminUser.CurrentOrgId,
  12382. // Ctime: time.Now().Unix(),
  12383. // Mtime: time.Now().Unix(),
  12384. // ErrMsg: res2.ErrMsg,
  12385. // Status: 1,
  12386. // PatientId: id,
  12387. // RecordTime: recordDateTime,
  12388. // Stage: 3,
  12389. // }
  12390. // service.CreateErrMsgLog(errlog)
  12391. //
  12392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12393. // return
  12394. // }
  12395. //
  12396. // c.ServeSuccessJSON(map[string]interface{}{
  12397. // "msg": "上传成功",
  12398. // })
  12399. //
  12400. //}
  12401. type QueryResult struct {
  12402. ID int64
  12403. Name string
  12404. Code string
  12405. List_type_code string
  12406. }
  12407. func (c *HisApiController) GetCheckCode() {
  12408. ids_str := c.GetString("ids")
  12409. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12410. ids_arr := strings.Split(ids_str, ",")
  12411. var queryResult []QueryResult
  12412. ids := make([]int64, 0)
  12413. for _, item := range ids_arr {
  12414. id, _ := strconv.ParseInt(item, 10, 64)
  12415. ids = append(ids, id)
  12416. }
  12417. if record_type == 1 {
  12418. drugs, _ := service.GetBatchDrugList(ids)
  12419. for _, item := range drugs {
  12420. result := QueryResult{
  12421. ID: item.ID,
  12422. Name: item.DrugName,
  12423. Code: item.MedicalInsuranceNumber,
  12424. List_type_code: "101",
  12425. }
  12426. queryResult = append(queryResult, result)
  12427. }
  12428. } else if record_type == 2 {
  12429. goods, _ := service.GetBatchGoodInformationList(ids)
  12430. for _, item := range goods {
  12431. result := QueryResult{
  12432. ID: item.ID,
  12433. Name: item.GoodName,
  12434. Code: item.MedicalInsuranceNumber,
  12435. List_type_code: "301",
  12436. }
  12437. queryResult = append(queryResult, result)
  12438. }
  12439. } else if record_type == 3 {
  12440. projects, _ := service.GetBathchMyPorjecgList(ids)
  12441. for _, item := range projects {
  12442. result := QueryResult{
  12443. ID: item.ID,
  12444. Name: item.ProjectName,
  12445. Code: item.MedicalCode,
  12446. List_type_code: "201",
  12447. }
  12448. queryResult = append(queryResult, result)
  12449. }
  12450. }
  12451. admin_user_id, _ := c.GetInt64("admin_user_id")
  12452. adminUser := c.GetAdminUserInfo()
  12453. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12454. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12455. var user_name string
  12456. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12457. if role.ID == 0 {
  12458. user_name = "xxx"
  12459. } else {
  12460. user_name = role.UserName
  12461. }
  12462. baseParams := &models.BaseParams{
  12463. SecretKey: miConfig.SecretKey,
  12464. FixmedinsCode: miConfig.Code,
  12465. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12466. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12467. OrgName: miConfig.OrgName,
  12468. Doctor: user_name,
  12469. }
  12470. if config.IsOpen == 1 {
  12471. for _, item := range queryResult {
  12472. var result string
  12473. if record_type == 1 {
  12474. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12475. } else if record_type == 2 {
  12476. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12477. } else if record_type == 3 {
  12478. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12479. }
  12480. var dat map[string]interface{}
  12481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12482. fmt.Println(dat)
  12483. } else {
  12484. fmt.Println(err)
  12485. }
  12486. userJSONBytes, _ := json.Marshal(dat)
  12487. var res ResultSix
  12488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12489. utils.ErrorLog("解析失败:%v", err)
  12490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12491. return
  12492. }
  12493. if res.Infcode == 0 {
  12494. if record_type == 1 {
  12495. service.UpdateBaseDrugById(item.ID)
  12496. } else if record_type == 2 {
  12497. service.UpdateGoodInformaitonByDetail(item.ID)
  12498. } else if record_type == 3 {
  12499. service.UpdateProjectById(item.ID)
  12500. }
  12501. c.ServeSuccessJSON(map[string]interface{}{
  12502. "failed_code": 0,
  12503. "msg": "目录对照成功",
  12504. })
  12505. } else {
  12506. c.ServeSuccessJSON(map[string]interface{}{
  12507. "failed_code": -10,
  12508. "msg": res.ErrMsg,
  12509. })
  12510. }
  12511. }
  12512. }
  12513. }
  12514. func (c *HisApiController) UnCheckCode() {
  12515. ids_str := c.GetString("ids")
  12516. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12517. admin_user_id, _ := c.GetInt64("admin_user_id")
  12518. ids_arr := strings.Split(ids_str, ",")
  12519. var queryResult []QueryResult
  12520. ids := make([]int64, 0)
  12521. for _, item := range ids_arr {
  12522. id, _ := strconv.ParseInt(item, 10, 64)
  12523. ids = append(ids, id)
  12524. }
  12525. if record_type == 1 {
  12526. drugs, _ := service.GetBatchDrugList(ids)
  12527. for _, item := range drugs {
  12528. result := QueryResult{
  12529. ID: item.ID,
  12530. Name: item.DrugName,
  12531. Code: item.MedicalInsuranceNumber,
  12532. List_type_code: "101",
  12533. }
  12534. queryResult = append(queryResult, result)
  12535. }
  12536. } else if record_type == 2 {
  12537. goods, _ := service.GetBatchGoodInformationList(ids)
  12538. for _, item := range goods {
  12539. result := QueryResult{
  12540. ID: item.ID,
  12541. Name: item.GoodName,
  12542. Code: item.MedicalInsuranceNumber,
  12543. List_type_code: "301",
  12544. }
  12545. queryResult = append(queryResult, result)
  12546. }
  12547. } else if record_type == 3 {
  12548. projects, _ := service.GetBathchMyPorjecgList(ids)
  12549. for _, item := range projects {
  12550. result := QueryResult{
  12551. ID: item.ID,
  12552. Name: item.ProjectName,
  12553. Code: item.MedicalCode,
  12554. List_type_code: "201",
  12555. }
  12556. queryResult = append(queryResult, result)
  12557. }
  12558. }
  12559. adminUser := c.GetAdminUserInfo()
  12560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12561. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12562. var user_name string
  12563. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12564. if role.ID == 0 {
  12565. user_name = "xxx"
  12566. } else {
  12567. user_name = role.UserName
  12568. }
  12569. baseParams := &models.BaseParams{
  12570. SecretKey: miConfig.SecretKey,
  12571. FixmedinsCode: miConfig.Code,
  12572. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12573. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12574. OrgName: miConfig.OrgName,
  12575. Doctor: user_name,
  12576. }
  12577. if config.IsOpen == 1 {
  12578. for _, item := range queryResult {
  12579. var result string
  12580. if record_type == 1 {
  12581. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12582. } else if record_type == 2 {
  12583. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12584. } else if record_type == 3 {
  12585. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12586. }
  12587. var dat2 map[string]interface{}
  12588. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12589. fmt.Println(dat2)
  12590. } else {
  12591. fmt.Println(err)
  12592. }
  12593. userJSONBytes, _ := json.Marshal(dat2)
  12594. var res ResultSix
  12595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12596. utils.ErrorLog("解析失败:%v", err)
  12597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12598. return
  12599. }
  12600. if res.Infcode == 0 {
  12601. if record_type == 1 {
  12602. service.UpdateDrugByIdDetail(item.ID)
  12603. } else if record_type == 2 {
  12604. service.UpdateGoodInfoById(item.ID)
  12605. } else if record_type == 3 {
  12606. service.UpdateMyProjectById(item.ID)
  12607. }
  12608. c.ServeSuccessJSON(map[string]interface{}{
  12609. "failed_code": 0,
  12610. "msg": "撤销目录对照成功",
  12611. })
  12612. } else {
  12613. c.ServeSuccessJSON(map[string]interface{}{
  12614. "failed_code": -10,
  12615. "msg": res.ErrMsg,
  12616. })
  12617. }
  12618. }
  12619. }
  12620. }
  12621. func (c *HisApiController) GetPatientInfo() {
  12622. id_card_no := c.GetString("id_card_no")
  12623. admin_user_id, _ := c.GetInt64("admin_user_id")
  12624. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12625. if patient.ID == 0 {
  12626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12627. return
  12628. }
  12629. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12630. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12631. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12632. if config.IsOpen == 1 {
  12633. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12634. var dat map[string]interface{}
  12635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12636. fmt.Println(dat)
  12637. } else {
  12638. fmt.Println(err)
  12639. }
  12640. userJSONBytes, _ := json.Marshal(dat)
  12641. var res ResultTwo
  12642. var res10265 ResultTwo10265
  12643. if miConfig.Code == "H15049901371" {
  12644. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12645. utils.ErrorLog("解析失败:%v", err)
  12646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12647. return
  12648. }
  12649. res.ErrMsg = res10265.ErrMsg
  12650. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12651. res.Infcode = infocode
  12652. res.Output = res10265.Output
  12653. res.InfRefmsgid = res10265.InfRefmsgid
  12654. } else {
  12655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12656. utils.ErrorLog("解析失败:%v", err)
  12657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12658. return
  12659. }
  12660. }
  12661. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12662. // utils.ErrorLog("解析失败:%v", err)
  12663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. // return
  12665. //}
  12666. if res.Infcode != 0 {
  12667. c.ServeSuccessJSON(map[string]interface{}{
  12668. "failed_code": -10,
  12669. "msg": res.ErrMsg,
  12670. })
  12671. } else {
  12672. c.ServeSuccessJSON(map[string]interface{}{
  12673. "failed_code": 0,
  12674. "info": res,
  12675. })
  12676. }
  12677. }
  12678. }
  12679. func (c *HisApiController) PsnPutOnRecord() {
  12680. record_type, _ := c.GetInt64("type")
  12681. patient_id, _ := c.GetInt64("patient_id")
  12682. admin_user_id, _ := c.GetInt64("admin_user_id")
  12683. start_time := c.GetString("start_time")
  12684. end_time := c.GetString("end_time")
  12685. adminUser := c.GetAdminUserInfo()
  12686. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12688. var patients []*models.Patients
  12689. if record_type == 1 { //全部备案
  12690. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12691. patients = append(patients, patient...)
  12692. } else { //单个备案
  12693. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12694. patients = append(patients, patient)
  12695. }
  12696. var user_name string
  12697. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12698. if role.ID == 0 {
  12699. user_name = "xxx"
  12700. } else {
  12701. user_name = role.UserName
  12702. }
  12703. if config.IsOpen == 1 {
  12704. for _, item := range patients {
  12705. 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
  12706. resp, requestErr := http.Get(api)
  12707. if requestErr != nil {
  12708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12709. return
  12710. }
  12711. defer resp.Body.Close()
  12712. body, ioErr := ioutil.ReadAll(resp.Body)
  12713. if ioErr != nil {
  12714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12716. return
  12717. }
  12718. var respJSON map[string]interface{}
  12719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12722. return
  12723. }
  12724. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12725. userJSONBytes, _ := json.Marshal(userJSON)
  12726. var res ResultTwo
  12727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12728. utils.ErrorLog("解析失败:%v", err)
  12729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12730. return
  12731. }
  12732. if res.Infcode == 0 {
  12733. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12734. var dat map[string]interface{}
  12735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12736. fmt.Println(dat)
  12737. } else {
  12738. fmt.Println(err)
  12739. }
  12740. userJSONBytes, _ := json.Marshal(dat)
  12741. var res2 ResultThirteen
  12742. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12743. utils.ErrorLog("解析失败:%v", err)
  12744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12745. return
  12746. }
  12747. if res2.Infcode == 0 {
  12748. psnResult := &models.GdybPsnRecord{
  12749. UserOrgId: adminUser.CurrentOrgId,
  12750. PatientId: item.ID,
  12751. PsnNo: res.Output.Baseinfo.PsnNo,
  12752. Ctime: time.Now().Unix(),
  12753. Mtime: time.Now().Unix(),
  12754. Status: 1,
  12755. IsCancel: 1,
  12756. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12757. }
  12758. service.CreatePsnRecord(psnResult)
  12759. } else {
  12760. c.ServeSuccessJSON(map[string]interface{}{
  12761. "failed_code": -10,
  12762. "msg": res2.ErrMsg,
  12763. })
  12764. return
  12765. }
  12766. }
  12767. }
  12768. }
  12769. }
  12770. func (c *HisApiController) PsnUnPutOnRecord() {
  12771. id, _ := c.GetInt64("id")
  12772. //record_type, _ := c.GetInt64("type")
  12773. admin_user_id, _ := c.GetInt64("admin_user_id")
  12774. adminUser := c.GetAdminUserInfo()
  12775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12776. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12777. var user_name string
  12778. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12779. if role.ID == 0 {
  12780. user_name = "xxx"
  12781. } else {
  12782. user_name = role.UserName
  12783. }
  12784. psn_record, _ := service.GetPsnRecordById(id)
  12785. if psn_record.ID == 0 {
  12786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12787. return
  12788. }
  12789. if config.IsOpen == 1 {
  12790. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12791. var dat map[string]interface{}
  12792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12793. fmt.Println(dat)
  12794. } else {
  12795. fmt.Println(err)
  12796. }
  12797. userJSONBytes, _ := json.Marshal(dat)
  12798. var res ResultFourteen
  12799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12800. utils.ErrorLog("解析失败:%v", err)
  12801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12802. return
  12803. }
  12804. if res.Infcode == 0 {
  12805. psn_record.IsCancel = 2
  12806. service.CreatePsnRecord(&psn_record)
  12807. } else {
  12808. c.ServeSuccessJSON(map[string]interface{}{
  12809. "failed_code": -10,
  12810. "msg": res.ErrMsg,
  12811. })
  12812. return
  12813. }
  12814. }
  12815. }
  12816. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12817. patient_id, _ := c.GetInt64("patient_id")
  12818. insutype_two := c.GetString("insutype")
  12819. psn_no := c.GetString("psn_no")
  12820. doctor_id, _ := c.GetInt64("doctor_id")
  12821. sick_id, _ := c.GetInt64("sick_id")
  12822. department_id, _ := c.GetInt64("department_id")
  12823. start_time := c.GetString("start_time")
  12824. end_time := c.GetString("end_time")
  12825. check_time := c.GetString("check_time")
  12826. adminUser := c.GetAdminUserInfo()
  12827. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12830. sick, _ := service.FindSickById(sick_id)
  12831. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12832. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12833. var res ResultTwo
  12834. var res10265 ResultTwo10265
  12835. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12836. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  12837. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  12838. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12839. "&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
  12840. resp, requestErr := http.Get(api)
  12841. if requestErr != nil {
  12842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12843. return
  12844. }
  12845. body, ioErr := ioutil.ReadAll(resp.Body)
  12846. if ioErr != nil {
  12847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12849. return
  12850. }
  12851. var respJSON map[string]interface{}
  12852. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return
  12856. }
  12857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12858. result, _ := json.Marshal(respJSON)
  12859. fmt.Println("log")
  12860. fmt.Println(string(result))
  12861. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12862. utils.ErrorLog("解析失败:%v", err)
  12863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12864. return
  12865. }
  12866. res.ErrMsg = res10265.ErrMsg
  12867. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12868. res.Infcode = infocode
  12869. res.Output = res10265.Output
  12870. res.InfRefmsgid = res10265.InfRefmsgid
  12871. } else {
  12872. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12873. if miConfig.Code == "H15049901371" {
  12874. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12875. utils.ErrorLog("解析失败:%v", err)
  12876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12877. return
  12878. }
  12879. res.ErrMsg = res10265.ErrMsg
  12880. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12881. res.Infcode = infocode
  12882. res.Output = res10265.Output
  12883. res.InfRefmsgid = res10265.InfRefmsgid
  12884. } else {
  12885. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12886. utils.ErrorLog("解析失败:%v", err)
  12887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12888. return
  12889. }
  12890. }
  12891. }
  12892. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12893. infoStr := string(Iinfos)
  12894. var rf []*ResultFive
  12895. json.Unmarshal([]byte(infoStr), &rf)
  12896. var insuplc_admdvs string
  12897. var insutype string
  12898. var is390 int = 0
  12899. var is310 int = 0
  12900. var insutypes []*ResultFive
  12901. for _, item := range rf {
  12902. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12903. insutypes = append(insutypes, item)
  12904. }
  12905. }
  12906. if len(insutypes) == 1 {
  12907. insutype = insutypes[0].Insutype
  12908. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12909. } else {
  12910. for _, i := range insutypes {
  12911. if i.Insutype == "390" {
  12912. is390 = 1
  12913. }
  12914. if i.Insutype == "310" {
  12915. is310 = 1
  12916. }
  12917. }
  12918. }
  12919. if is390 == 1 {
  12920. insutype = "390"
  12921. }
  12922. if is310 == 1 {
  12923. insutype = "310"
  12924. }
  12925. if len(insutypes) == 2 {
  12926. insutype = insutype_two
  12927. }
  12928. if len(insutypes) == 0 {
  12929. insutype = "310"
  12930. }
  12931. insutype = insutype_two
  12932. fmt.Println(insutype)
  12933. for _, item := range rf {
  12934. fmt.Println(item.Insutype)
  12935. fmt.Println(insutype)
  12936. if item.Insutype == insutype {
  12937. fmt.Println(item.Insutype)
  12938. fmt.Println(insutype)
  12939. insuplc_admdvs = item.InsuplcAdmdvs
  12940. }
  12941. }
  12942. fmt.Println(insuplc_admdvs)
  12943. var res2 ResultThirteen
  12944. var res10265_2 ResultThirteen10265
  12945. if config.IsOpen == 1 {
  12946. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12947. } else {
  12948. 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)
  12949. var dat map[string]interface{}
  12950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12951. fmt.Println(dat)
  12952. } else {
  12953. fmt.Println(err)
  12954. }
  12955. userJSONBytes, _ := json.Marshal(dat)
  12956. if miConfig.Code == "H15049901371" {
  12957. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  12958. utils.ErrorLog("解析失败:%v", err)
  12959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12960. return
  12961. }
  12962. res2.ErrMsg = res10265_2.ErrMsg
  12963. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  12964. res2.Infcode = infocode
  12965. res2.Output = res10265_2.Output
  12966. res2.InfRefmsgid = res10265_2.InfRefmsgid
  12967. } else {
  12968. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12969. utils.ErrorLog("解析失败:%v", err)
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12971. return
  12972. }
  12973. }
  12974. }
  12975. if res2.Infcode == 0 {
  12976. psnResult := &models.GdybPsnNcdsRecord{
  12977. UserOrgId: adminUser.CurrentOrgId,
  12978. PatientId: patient.ID,
  12979. PsnNo: psn_no,
  12980. DoctorId: doctor.AdminUserId,
  12981. DepartmentId: department_id,
  12982. SickType: sick_id,
  12983. Insutype: insutype,
  12984. Ctime: time.Now().Unix(),
  12985. Mtime: time.Now().Unix(),
  12986. Status: 1,
  12987. IsCancel: 1,
  12988. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12989. }
  12990. service.CreatePsnNCDSRecord(psnResult)
  12991. c.ServeSuccessJSON(map[string]interface{}{
  12992. "failed_code": 0,
  12993. "msg": "备案成功",
  12994. "result": psnResult,
  12995. })
  12996. } else {
  12997. c.ServeSuccessJSON(map[string]interface{}{
  12998. "failed_code": -10,
  12999. "msg": res2.ErrMsg,
  13000. })
  13001. return
  13002. }
  13003. }
  13004. }
  13005. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13006. id, _ := c.GetInt64("id")
  13007. admin_user_id, _ := c.GetInt64("admin_user_id")
  13008. adminUser := c.GetAdminUserInfo()
  13009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13010. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13011. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13012. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13013. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13014. //var user_name string
  13015. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13016. //if role.ID == 0 {
  13017. // user_name = "xxx"
  13018. //} else {
  13019. // user_name = role.UserName
  13020. //}
  13021. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13022. if psn_record.ID == 0 {
  13023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13024. return
  13025. }
  13026. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13027. var res ResultTwo
  13028. var res10265 ResultTwo10265
  13029. if miConfig.Code == "H15049901371" {
  13030. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13031. utils.ErrorLog("解析失败:%v", err)
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13033. return
  13034. }
  13035. res.ErrMsg = res10265.ErrMsg
  13036. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13037. res.Infcode = infocode
  13038. res.Output = res10265.Output
  13039. res.InfRefmsgid = res10265.InfRefmsgid
  13040. } else {
  13041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13042. utils.ErrorLog("解析失败:%v", err)
  13043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13044. return
  13045. }
  13046. }
  13047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13048. infoStr := string(Iinfos)
  13049. var rf []*ResultFive
  13050. json.Unmarshal([]byte(infoStr), &rf)
  13051. var insuplc_admdvs string
  13052. var insutype string
  13053. var is390 int = 0
  13054. var is310 int = 0
  13055. var insutypes []*ResultFive
  13056. for _, item := range rf {
  13057. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13058. insutypes = append(insutypes, item)
  13059. }
  13060. }
  13061. if len(insutypes) == 1 {
  13062. insutype = insutypes[0].Insutype
  13063. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13064. } else {
  13065. for _, i := range insutypes {
  13066. if i.Insutype == "390" {
  13067. is390 = 1
  13068. }
  13069. if i.Insutype == "310" {
  13070. is310 = 1
  13071. }
  13072. }
  13073. }
  13074. if is390 == 1 {
  13075. insutype = "390"
  13076. }
  13077. if is310 == 1 {
  13078. insutype = "310"
  13079. }
  13080. if len(insutypes) == 0 {
  13081. insutype = "310"
  13082. }
  13083. insutype = psn_record.Insutype
  13084. for _, item := range rf {
  13085. if item.Insutype == insutype {
  13086. insuplc_admdvs = item.InsuplcAdmdvs
  13087. }
  13088. }
  13089. if config.IsOpen == 1 {
  13090. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13091. var dat map[string]interface{}
  13092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13093. fmt.Println(dat)
  13094. } else {
  13095. fmt.Println(err)
  13096. }
  13097. userJSONBytes, _ := json.Marshal(dat)
  13098. var res ResultFourteen
  13099. var res10265 ResultFourteen10265
  13100. if miConfig.Code == "H15049901371" {
  13101. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13102. utils.ErrorLog("解析失败:%v", err)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. res.ErrMsg = res10265.ErrMsg
  13107. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13108. res.Infcode = infocode
  13109. res.Output = res10265.Output
  13110. res.InfRefmsgid = res10265.InfRefmsgid
  13111. } else {
  13112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13113. utils.ErrorLog("解析失败:%v", err)
  13114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13115. return
  13116. }
  13117. }
  13118. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13119. // utils.ErrorLog("解析失败:%v", err)
  13120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. // return
  13122. //}
  13123. if res.Infcode == 0 {
  13124. psn_record.IsCancel = 2
  13125. service.CreatePsnNCDSRecord(&psn_record)
  13126. c.ServeSuccessJSON(map[string]interface{}{
  13127. "failed_code": 0,
  13128. "msg": "撤销备案成功",
  13129. })
  13130. } else {
  13131. c.ServeSuccessJSON(map[string]interface{}{
  13132. "failed_code": -10,
  13133. "msg": res.ErrMsg,
  13134. })
  13135. return
  13136. }
  13137. }
  13138. }
  13139. func (c *HisApiController) TestTest() {
  13140. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13141. fmt.Println(patient.Iinfo)
  13142. }
  13143. type CustomData struct {
  13144. MsgId string
  13145. PsnNo string
  13146. Info string
  13147. }
  13148. func (c *HisApiController) ReversalData() {
  13149. var customData []*CustomData
  13150. custom := &CustomData{
  13151. MsgId: "H44022900158202103301714472004",
  13152. PsnNo: "44020000001101329945",
  13153. Info: "2207",
  13154. }
  13155. customData = append(customData, custom)
  13156. custom1 := &CustomData{
  13157. MsgId: "H4402290015820210330172057803",
  13158. PsnNo: "44020000001101161813",
  13159. Info: "2207",
  13160. }
  13161. customData = append(customData, custom1)
  13162. custom2 := &CustomData{
  13163. MsgId: "H44022900158202103301705198813",
  13164. PsnNo: "44190000133097375417",
  13165. Info: "2207",
  13166. }
  13167. customData = append(customData, custom2)
  13168. custom3 := &CustomData{
  13169. MsgId: "H44022900158202103301715524756",
  13170. PsnNo: "44020000001100187221",
  13171. Info: "2207",
  13172. }
  13173. customData = append(customData, custom3)
  13174. custom4 := &CustomData{
  13175. MsgId: "H44022900158202103301730376224",
  13176. PsnNo: "44020000001101959155",
  13177. Info: "2207",
  13178. }
  13179. customData = append(customData, custom4)
  13180. custom5 := &CustomData{
  13181. MsgId: "H44022900158202103301748008725",
  13182. PsnNo: "44020000001104246641",
  13183. Info: "2207",
  13184. }
  13185. customData = append(customData, custom5)
  13186. custom6 := &CustomData{
  13187. MsgId: "H44022900158202103301718096755",
  13188. PsnNo: "44020000001102211860",
  13189. Info: "2207",
  13190. }
  13191. customData = append(customData, custom6)
  13192. custom7 := &CustomData{
  13193. MsgId: "H44022900158202103301736551640",
  13194. PsnNo: "44020000001102687718",
  13195. Info: "2207",
  13196. }
  13197. customData = append(customData, custom7)
  13198. custom8 := &CustomData{
  13199. MsgId: "H44022900158202103301743097676",
  13200. PsnNo: "44020000001102127785",
  13201. Info: "2207",
  13202. }
  13203. customData = append(customData, custom8)
  13204. custom9 := &CustomData{
  13205. MsgId: "H44022900158202103301712304203",
  13206. PsnNo: "44020000001101518097",
  13207. Info: "2207",
  13208. }
  13209. customData = append(customData, custom9)
  13210. custom10 := &CustomData{
  13211. MsgId: "H44022900158202103301738448785",
  13212. PsnNo: "44020000001100500813",
  13213. Info: "2207",
  13214. }
  13215. customData = append(customData, custom10)
  13216. custom11 := &CustomData{
  13217. MsgId: "H44022900158202103301732455843",
  13218. PsnNo: "44020000001102690557",
  13219. Info: "2207",
  13220. }
  13221. customData = append(customData, custom11)
  13222. custom12 := &CustomData{
  13223. MsgId: "H44022900158202103301745421708",
  13224. PsnNo: "44020000001102211928",
  13225. Info: "2207",
  13226. }
  13227. customData = append(customData, custom12)
  13228. custom1212 := &CustomData{
  13229. MsgId: "H440229001582021033017351627",
  13230. PsnNo: "44020000001102481733",
  13231. Info: "2207",
  13232. }
  13233. customData = append(customData, custom1212)
  13234. custom13 := &CustomData{
  13235. MsgId: "H44022900158202103301740327951",
  13236. PsnNo: "44020000001103174866",
  13237. Info: "2207",
  13238. }
  13239. customData = append(customData, custom13)
  13240. custom14 := &CustomData{
  13241. MsgId: "H4402290015820210330174922668",
  13242. PsnNo: "44020000001102927272",
  13243. Info: "2207",
  13244. }
  13245. customData = append(customData, custom14)
  13246. custom15 := &CustomData{
  13247. MsgId: "H44022900158202103301752362273",
  13248. PsnNo: "44020000001102942890",
  13249. Info: "2207",
  13250. }
  13251. customData = append(customData, custom15)
  13252. custom16 := &CustomData{
  13253. MsgId: "H44022900158202103301751082917",
  13254. PsnNo: "44020000001101662162",
  13255. Info: "2207",
  13256. }
  13257. customData = append(customData, custom16)
  13258. custom17 := &CustomData{
  13259. MsgId: "H44022900158202103301754147728",
  13260. PsnNo: "44020000000229014511",
  13261. Info: "2207",
  13262. }
  13263. customData = append(customData, custom17)
  13264. adminUser := c.GetAdminUserInfo()
  13265. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13266. for _, item := range customData {
  13267. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13268. fmt.Println(result)
  13269. }
  13270. }
  13271. //func (c *HisApiController) GetAllopatry() {
  13272. // year := c.GetString("year")
  13273. // month := c.GetString("month")
  13274. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13275. // adminUser := c.GetAdminUserInfo()
  13276. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13277. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13278. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13279. //
  13280. // var dat map[string]interface{}
  13281. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13282. // fmt.Println(dat)
  13283. // } else {
  13284. // fmt.Println(err)
  13285. // }
  13286. // userJSONBytes, _ := json.Marshal(dat)
  13287. // var res models.Result9001
  13288. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13289. // utils.ErrorLog("解析失败:%v", err)
  13290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13291. // return
  13292. // }
  13293. //
  13294. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13295. // var dat2 map[string]interface{}
  13296. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13297. // fmt.Println(dat)
  13298. // } else {
  13299. // fmt.Println(err)
  13300. // }
  13301. // userJSONBytes2, _ := json.Marshal(dat2)
  13302. // var res2 models.Result3260
  13303. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13304. // utils.ErrorLog("解析失败:%v", err)
  13305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13306. // return
  13307. // }
  13308. // if res2.Infcode == 0 {
  13309. // c.ServeSuccessJSON(map[string]interface{}{
  13310. // "list": res2.Output.Data,
  13311. // })
  13312. // return
  13313. // } else {
  13314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13315. // return
  13316. // }
  13317. //
  13318. //}
  13319. //func (c *HisApiController) ComfirmAllopatry() {
  13320. // year := c.GetString("year")
  13321. // month := c.GetString("month")
  13322. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13323. // adminUser := c.GetAdminUserInfo()
  13324. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13325. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13326. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13327. // var dat map[string]interface{}
  13328. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13329. // fmt.Println(dat)
  13330. // } else {
  13331. // fmt.Println(err)
  13332. // }
  13333. // userJSONBytes, _ := json.Marshal(dat)
  13334. // var res models.Result9001
  13335. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13336. // utils.ErrorLog("解析失败:%v", err)
  13337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13338. // return
  13339. // }
  13340. //
  13341. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13342. // var dat2 map[string]interface{}
  13343. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13344. // fmt.Println(dat)
  13345. // } else {
  13346. // fmt.Println(err)
  13347. // }
  13348. // userJSONBytes2, _ := json.Marshal(dat2)
  13349. // var res2 models.Result3260
  13350. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13351. // utils.ErrorLog("解析失败:%v", err)
  13352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13353. // return
  13354. // }
  13355. //
  13356. // if res2.Infcode == 0 {
  13357. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13358. // var dat map[string]interface{}
  13359. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13360. // fmt.Println(dat)
  13361. // } else {
  13362. // fmt.Println(err)
  13363. // }
  13364. // userJSONBytes, _ := json.Marshal(dat)
  13365. // var res3 models.Result3261
  13366. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13367. // utils.ErrorLog("解析失败:%v", err)
  13368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13369. // return
  13370. // }
  13371. //
  13372. // if res3.Infcode == 0 {
  13373. // record := &models.HisYidiClearRecord{
  13374. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13375. // Ctime: time.Now().Unix(),
  13376. // Mtime: time.Now().Unix(),
  13377. // Status: 1,
  13378. // MsgId: msgId,
  13379. // }
  13380. // service.SaveClearRecord(record)
  13381. // c.ServeSuccessJSON(map[string]interface{}{
  13382. // "msg": "提取成功",
  13383. // })
  13384. // }
  13385. // }
  13386. //}
  13387. func (c *HisApiController) RefundAllopatry() {
  13388. year := c.GetString("year")
  13389. month := c.GetString("month")
  13390. id, _ := c.GetInt64("id")
  13391. admin_user_id, _ := c.GetInt64("admin_user_id")
  13392. adminUser := c.GetAdminUserInfo()
  13393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13394. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13395. record, _ := service.GetClearRecordById(id)
  13396. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13397. var dat map[string]interface{}
  13398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13399. fmt.Println(dat)
  13400. } else {
  13401. fmt.Println(err)
  13402. }
  13403. userJSONBytes, _ := json.Marshal(dat)
  13404. var empty ResultFourteen
  13405. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13406. utils.ErrorLog("解析失败:%v", err)
  13407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13408. return
  13409. }
  13410. if empty.Infcode == 0 {
  13411. c.ServeSuccessJSON(map[string]interface{}{
  13412. "msg": "撤销成功",
  13413. })
  13414. return
  13415. }
  13416. }
  13417. func (c *HisApiController) ReversalOtherData() {
  13418. var customData []*CustomData
  13419. custom := &CustomData{
  13420. MsgId: "H44022900158202103301714472004",
  13421. PsnNo: "44020000001101329945",
  13422. Info: "2208",
  13423. }
  13424. customData = append(customData, custom)
  13425. custom1 := &CustomData{
  13426. MsgId: "H4402290015820210330172057803",
  13427. PsnNo: "44020000001101161813",
  13428. Info: "2208",
  13429. }
  13430. customData = append(customData, custom1)
  13431. custom2 := &CustomData{
  13432. MsgId: "H44022900158202103301705198813",
  13433. PsnNo: "44190000133097375417",
  13434. Info: "2208",
  13435. }
  13436. customData = append(customData, custom2)
  13437. custom3 := &CustomData{
  13438. MsgId: "H44022900158202103301715524756",
  13439. PsnNo: "44020000001100187221",
  13440. Info: "2208",
  13441. }
  13442. customData = append(customData, custom3)
  13443. custom4 := &CustomData{
  13444. MsgId: "H44022900158202103301730376224",
  13445. PsnNo: "44020000001101959155",
  13446. Info: "2208",
  13447. }
  13448. customData = append(customData, custom4)
  13449. custom5 := &CustomData{
  13450. MsgId: "H44022900158202103301748008725",
  13451. PsnNo: "44020000001104246641",
  13452. Info: "2208",
  13453. }
  13454. customData = append(customData, custom5)
  13455. custom6 := &CustomData{
  13456. MsgId: "H44022900158202103301718096755",
  13457. PsnNo: "44020000001102211860",
  13458. Info: "2208",
  13459. }
  13460. customData = append(customData, custom6)
  13461. custom7 := &CustomData{
  13462. MsgId: "H44022900158202103301736551640",
  13463. PsnNo: "44020000001102687718",
  13464. Info: "2208",
  13465. }
  13466. customData = append(customData, custom7)
  13467. custom8 := &CustomData{
  13468. MsgId: "H44022900158202103301743097676",
  13469. PsnNo: "44020000001102127785",
  13470. Info: "2208",
  13471. }
  13472. customData = append(customData, custom8)
  13473. custom9 := &CustomData{
  13474. MsgId: "H44022900158202103301712304203",
  13475. PsnNo: "44020000001101518097",
  13476. Info: "2208",
  13477. }
  13478. customData = append(customData, custom9)
  13479. custom10 := &CustomData{
  13480. MsgId: "H44022900158202103301738448785",
  13481. PsnNo: "44020000001100500813",
  13482. Info: "2208",
  13483. }
  13484. customData = append(customData, custom10)
  13485. custom11 := &CustomData{
  13486. MsgId: "H44022900158202103301732455843",
  13487. PsnNo: "44020000001102690557",
  13488. Info: "2208",
  13489. }
  13490. customData = append(customData, custom11)
  13491. custom12 := &CustomData{
  13492. MsgId: "H44022900158202103301745421708",
  13493. PsnNo: "44020000001102211928",
  13494. Info: "2208",
  13495. }
  13496. customData = append(customData, custom12)
  13497. custom1212 := &CustomData{
  13498. MsgId: "H440229001582021033017351627",
  13499. PsnNo: "44020000001102481733",
  13500. Info: "2208",
  13501. }
  13502. customData = append(customData, custom1212)
  13503. custom13 := &CustomData{
  13504. MsgId: "H44022900158202103301740327951",
  13505. PsnNo: "44020000001103174866",
  13506. Info: "2208",
  13507. }
  13508. customData = append(customData, custom13)
  13509. custom14 := &CustomData{
  13510. MsgId: "H4402290015820210330174922668",
  13511. PsnNo: "44020000001102927272",
  13512. Info: "2208",
  13513. }
  13514. customData = append(customData, custom14)
  13515. custom15 := &CustomData{
  13516. MsgId: "H44022900158202103301752362273",
  13517. PsnNo: "44020000001102942890",
  13518. Info: "2208",
  13519. }
  13520. customData = append(customData, custom15)
  13521. custom16 := &CustomData{
  13522. MsgId: "H44022900158202103301751082917",
  13523. PsnNo: "44020000001101662162",
  13524. Info: "2208",
  13525. }
  13526. customData = append(customData, custom16)
  13527. custom17 := &CustomData{
  13528. MsgId: "H44022900158202103301754147728",
  13529. PsnNo: "44020000000229014511",
  13530. Info: "2208",
  13531. }
  13532. customData = append(customData, custom17)
  13533. adminUser := c.GetAdminUserInfo()
  13534. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13535. for _, item := range customData {
  13536. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13537. fmt.Println(result)
  13538. }
  13539. }
  13540. func PathExists(path string) (bool, error) {
  13541. _, err := os.Stat(path)
  13542. if err == nil {
  13543. return true, nil
  13544. }
  13545. if os.IsNotExist(err) {
  13546. return false, nil
  13547. }
  13548. return false, err
  13549. }
  13550. //创建文件夹
  13551. func Mkdir(dir string) {
  13552. // 创建文件夹
  13553. exist, err := PathExists(dir)
  13554. if err != nil {
  13555. fmt.Println(err.Error())
  13556. } else {
  13557. if exist {
  13558. fmt.Println(dir + "文件夹已存在!")
  13559. } else {
  13560. // 文件夹名称,权限
  13561. err := os.Mkdir(dir, os.ModePerm)
  13562. if err != nil {
  13563. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13564. } else {
  13565. fmt.Println(dir + "文件夹创建成功!")
  13566. }
  13567. }
  13568. }
  13569. }
  13570. //压缩文件
  13571. func Zip(srcFile string, destZip string) error {
  13572. zipfile, err := os.Create(destZip)
  13573. if err != nil {
  13574. return err
  13575. }
  13576. defer zipfile.Close()
  13577. archive := zip.NewWriter(zipfile)
  13578. defer archive.Close()
  13579. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13580. if err != nil {
  13581. return err
  13582. }
  13583. header, err := zip.FileInfoHeader(info)
  13584. if err != nil {
  13585. return err
  13586. }
  13587. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13588. // header.Name = path
  13589. if info.IsDir() {
  13590. header.Name += "/"
  13591. } else {
  13592. header.Method = zip.Deflate
  13593. }
  13594. writer, err := archive.CreateHeader(header)
  13595. if err != nil {
  13596. return err
  13597. }
  13598. if !info.IsDir() {
  13599. file, err := os.Open(path)
  13600. if err != nil {
  13601. return err
  13602. }
  13603. defer file.Close()
  13604. _, err = io.Copy(writer, file)
  13605. }
  13606. return err
  13607. })
  13608. return err
  13609. }
  13610. func ReadFile(filePath string) []byte {
  13611. f, err := os.Open(filePath)
  13612. if err != nil {
  13613. fmt.Println("read file fail", err)
  13614. return nil
  13615. }
  13616. defer f.Close()
  13617. fd, err := ioutil.ReadAll(f)
  13618. if err != nil {
  13619. fmt.Println("read to fd fail", err)
  13620. return nil
  13621. }
  13622. return fd
  13623. }
  13624. func saveLog(result string, request string, infno string, desc string) {
  13625. org_id, _ := beego.AppConfig.Int64("org_id")
  13626. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13627. dir := miConfig.OrgName + "日志"
  13628. utils.Mkdir(dir)
  13629. month := time.Unix(1557042972, 0).Format("1")
  13630. year := time.Now().Format("2006")
  13631. month = time.Now().Format("01")
  13632. day := time.Now().Format("02")
  13633. hour := time.Now().Format("15")
  13634. min := time.Now().Format("04")
  13635. sec := time.Now().Format("05")
  13636. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13637. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13638. file_name := file + ".txt"
  13639. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13640. exist, _ := utils.PathExists(file_path)
  13641. if exist { //存在
  13642. fmt.Println("存在")
  13643. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13644. if err != nil {
  13645. fmt.Println("read fail")
  13646. }
  13647. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13648. n, _ := f.Seek(0, 2)
  13649. _, err = f.WriteAt([]byte(content), n)
  13650. } else { //不存在
  13651. fmt.Println("文件不存在,创建文件")
  13652. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13653. defer f.Close()
  13654. if err != nil {
  13655. } else {
  13656. _, err = f.Write([]byte("记录日志"))
  13657. }
  13658. }
  13659. }
  13660. type Charset string
  13661. const (
  13662. UTF8 = Charset("UTF-8")
  13663. GB18030 = Charset("GB18030")
  13664. )
  13665. func ConvertToString(src string, srcCode string, tagCode string) string {
  13666. srcCoder := mahonia.NewDecoder(srcCode)
  13667. srcResult := srcCoder.ConvertString(src)
  13668. tagCoder := mahonia.NewDecoder(tagCode)
  13669. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13670. result := string(cdata)
  13671. return result
  13672. }
  13673. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13674. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13675. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13676. var token string
  13677. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13678. var api string
  13679. if miConfig.MdtrtareaAdmvs == "320921" {
  13680. 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 +
  13681. "&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
  13682. fmt.Println(api)
  13683. } else {
  13684. 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 +
  13685. "&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
  13686. }
  13687. resp, requestErr := http.Get(api)
  13688. if requestErr != nil {
  13689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13690. return ""
  13691. }
  13692. body, ioErr := ioutil.ReadAll(resp.Body)
  13693. if ioErr != nil {
  13694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13696. return ""
  13697. }
  13698. var respJSON map[string]interface{}
  13699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13702. return ""
  13703. }
  13704. var status string
  13705. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13706. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13707. var res ResultTwo //1101结果
  13708. var res10265 ResultTwo10265 //1101结果
  13709. if status == "0" { //读卡成功
  13710. var card_info string //卡信息
  13711. var busi_card_info string
  13712. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13713. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13714. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13715. fmt.Println(card_info)
  13716. fmt.Println(busi_card_info)
  13717. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13718. result, _ := json.Marshal(respJSON)
  13719. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13720. utils.ErrorLog("解析失败:%v", err)
  13721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13722. return ""
  13723. }
  13724. res.ErrMsg = res10265.ErrMsg
  13725. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13726. res.Infcode = infocode
  13727. res.Output = res10265.Output
  13728. res.InfRefmsgid = res10265.InfRefmsgid
  13729. if res.Infcode == 0 {
  13730. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13731. if err == gorm.ErrRecordNotFound {
  13732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13733. return ""
  13734. } else if err != nil {
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13736. return ""
  13737. } else {
  13738. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13739. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13740. infoStr := string(Iinfos)
  13741. idetinfoStr := string(Idetinfos)
  13742. psn := &models.HisPsn{
  13743. PsnNo: res.Output.Baseinfo.PsnNo,
  13744. Age: res.Output.Baseinfo.Age,
  13745. PatientId: patient.ID,
  13746. Certno: res.Output.Baseinfo.Certno,
  13747. Brdy: res.Output.Baseinfo.Brdy,
  13748. Gend: res.Output.Baseinfo.Gend,
  13749. Naty: res.Output.Baseinfo.Naty,
  13750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13751. PsnName: res.Output.Baseinfo.PsnName,
  13752. Idetinfo: idetinfoStr,
  13753. Insuinfo: infoStr,
  13754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13755. CardInfo: card_info,
  13756. VerifyNumber: token,
  13757. }
  13758. service.CreateHisPsn(psn)
  13759. return token
  13760. }
  13761. }
  13762. } else {
  13763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13764. return ""
  13765. }
  13766. } else { //读卡失败
  13767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13768. return ""
  13769. }
  13770. return token
  13771. }
  13772. func DeleteExtraSpaceTwo(s string) string {
  13773. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13774. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13775. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13776. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13777. s2 := make([]byte, len(s1)) //定义字符数组切片
  13778. copy(s2, s1) //将字符串复制到切片
  13779. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13780. for len(spc_index) > 0 { //找到适配项
  13781. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13782. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13783. }
  13784. return string(s2)
  13785. }
  13786. func Remove0000(s string) string {
  13787. str := make([]rune, 0, len(s))
  13788. for _, v := range []rune(s) {
  13789. if v == 0 {
  13790. continue
  13791. }
  13792. str = append(str, v)
  13793. }
  13794. return string(str)
  13795. }
  13796. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13797. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13798. readCard := DllDef.MustFindProc("EcQuery")
  13799. pCardInfo := make([]byte, 8192)
  13800. pBusiCardInfo := make([]byte, 8192)
  13801. data := make(map[string]interface{})
  13802. //pData := make(map[string]interface{})
  13803. inputData := make(map[string]interface{})
  13804. inputData["orgId"] = code
  13805. inputData["businessType"] = "01101"
  13806. inputData["operatorId"] = operator_id
  13807. inputData["operatorName"] = operator_name
  13808. inputData["officeId"] = "001"
  13809. inputData["officeName"] = "血透室"
  13810. //
  13811. data["data"] = inputData
  13812. data["transType"] = "ec.query"
  13813. data["orgId"] = code
  13814. bytesData, _ := json.Marshal(data)
  13815. pCardInfo = bytesData
  13816. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13817. fmt.Println(ret2)
  13818. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13819. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13820. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13821. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13822. if ret2 != 0 {
  13823. return "", ""
  13824. }
  13825. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13826. }
  13827. func DeleteExtraSpace(s string) string {
  13828. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13829. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13830. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13831. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13832. s2 := make([]byte, len(s1)) //定义字符数组切片
  13833. copy(s2, s1) //将字符串复制到切片
  13834. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13835. for len(spc_index) > 0 { //找到适配项
  13836. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13837. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13838. }
  13839. return string(s2)
  13840. }
  13841. //对账
  13842. func (c *HisApiController) Post3202() {
  13843. start_time := c.GetString("start_time")
  13844. end_time := c.GetString("end_time")
  13845. //insutype := c.GetString("insutype")
  13846. clr_type := c.GetString("clr_type")
  13847. clr_org := c.GetString("clr_optins")
  13848. admin_user_id, _ := c.GetInt64("admin_user_id")
  13849. adminUser := c.GetAdminUserInfo()
  13850. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13851. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13852. if len(clr_org) == 0 {
  13853. clr_org = miConfig.MdtrtareaAdmvs
  13854. }
  13855. timeLayout := "2006-01-02"
  13856. loc, _ := time.LoadLocation("Local")
  13857. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13858. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13859. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13860. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  13861. //fixmedins_setl_cnt := int64(len(orders))
  13862. var medfee_sumamt float64
  13863. var acct_pay float64
  13864. var fund_pay_sumamt float64
  13865. for _, item := range orders {
  13866. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13867. acct_pay = acct_pay + item.AcctPay
  13868. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13869. }
  13870. //var medfee_sumamt_two float64
  13871. //var acct_pay_two float64
  13872. //var fund_pay_sumamt_two float64
  13873. //for _, item := range orders_two {
  13874. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  13875. // acct_pay_two = acct_pay_two + item.AcctPay
  13876. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  13877. //}
  13878. //var user_name string
  13879. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13880. //if role.ID == 0 {
  13881. // user_name = "xxx"
  13882. //} else {
  13883. // user_name = role.UserName
  13884. //}
  13885. var res ResultSix
  13886. if config.IsOpen == 1 {
  13887. var bps []*models.BusinessParamsTwo
  13888. var bp models.BusinessParamsTwo
  13889. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  13890. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  13891. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  13892. bp.MedfeeSumamt = medfee_sumamt_str
  13893. bp.AcctPay = acct_pay_str
  13894. bp.FundPaySumamt = fund_pay_sumamt_str
  13895. bp.Insutype = "390"
  13896. bp.StmtBegndate = start_time
  13897. bp.ClrType = clr_type
  13898. bp.SetlOptins = clr_org
  13899. bp.StmtEnddate = end_time
  13900. bps = append(bps, &bp)
  13901. data := make(map[string]interface{})
  13902. data["bps"] = bps
  13903. data["org_name"] = miConfig.OrgName
  13904. data["doctor"] = role.UserName
  13905. data["fixmedins_code"] = miConfig.Code
  13906. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13908. if miConfig.MdtrtareaAdmvs == "421300" {
  13909. client := &http.Client{}
  13910. bytesData, _ := json.Marshal(data)
  13911. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  13912. resp, _ := client.Do(req)
  13913. defer resp.Body.Close()
  13914. body, ioErr := ioutil.ReadAll(resp.Body)
  13915. if ioErr != nil {
  13916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13918. return
  13919. }
  13920. var respJSON map[string]interface{}
  13921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13924. return
  13925. }
  13926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13927. userJSONBytes, _ := json.Marshal(respJSON)
  13928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13929. utils.ErrorLog("解析失败:%v", err)
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13931. return
  13932. }
  13933. }
  13934. if res.Infcode == 0 {
  13935. c.ServeSuccessJSON(map[string]interface{}{
  13936. "msg": "发起成功",
  13937. })
  13938. } else {
  13939. c.ServeSuccessJSON(map[string]interface{}{
  13940. "code": -10,
  13941. "msg": res.ErrMsg,
  13942. })
  13943. }
  13944. }
  13945. }
  13946. func (c *HisApiController) Post3501() {
  13947. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13948. data := make(map[string]interface{})
  13949. var struct3501s []models.Struct3501
  13950. var struct3501 models.Struct3501
  13951. struct3501.OrgName = miConfig.OrgName
  13952. struct3501.AccessKey = miConfig.AccessKey
  13953. struct3501.RequestUrl = miConfig.Url
  13954. struct3501.SecretKey = miConfig.SecretKey
  13955. struct3501.ManuDate = "2022-08-17"
  13956. struct3501.FixmedinsBchno = ""
  13957. struct3501.ManuLotnum = ""
  13958. struct3501.RxFlag = "0"
  13959. struct3501.ExpyEnd = "2022-08-17"
  13960. struct3501.Invdate = "2022-08-17"
  13961. struct3501.InvCnt = "20.25"
  13962. struct3501.Memo = ""
  13963. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13964. struct3501.FixmedinsHilistId = miConfig.Code
  13965. struct3501.FixmedinsHilistName = miConfig.OrgName
  13966. struct3501s = append(struct3501s, struct3501)
  13967. data["struct_3501s"] = struct3501s
  13968. client := &http.Client{}
  13969. bytesData, _ := json.Marshal(data)
  13970. var req *http.Request
  13971. if miConfig.MdtrtareaAdmvs == "320921" {
  13972. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13973. } else {
  13974. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13975. }
  13976. resp, _ := client.Do(req)
  13977. defer resp.Body.Close()
  13978. body, ioErr := ioutil.ReadAll(resp.Body)
  13979. if ioErr != nil {
  13980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13982. return
  13983. }
  13984. var respJSON map[string]interface{}
  13985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13988. return
  13989. }
  13990. var res ResultSix
  13991. var resSix10265 ResultSix10265 //1101结果
  13992. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13993. result, _ := json.Marshal(respJSON)
  13994. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13995. utils.ErrorLog("解析失败:%v", err)
  13996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13997. return
  13998. }
  13999. res.InfRefmsgid = resSix10265.InfRefmsgid
  14000. res.Output = resSix10265.Output
  14001. res.ErrMsg = resSix10265.ErrMsg
  14002. res.Cainfo = resSix10265.Cainfo
  14003. res.WarnMsg = resSix10265.WarnMsg
  14004. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14005. res.Infcode = infocode
  14006. if infocode == 0 {
  14007. c.ServeSuccessJSON(map[string]interface{}{
  14008. "msg": "上传成功",
  14009. })
  14010. return
  14011. } else {
  14012. c.ServeSuccessJSON(map[string]interface{}{
  14013. "failed_code": -10,
  14014. "msg": res.ErrMsg,
  14015. })
  14016. return
  14017. }
  14018. }
  14019. func (c *HisApiController) Post3502() {
  14020. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14021. data := make(map[string]interface{})
  14022. var struct3502s []models.Struct3502
  14023. var struct3502 models.Struct3502
  14024. struct3502.OrgName = miConfig.OrgName
  14025. struct3502.AccessKey = miConfig.AccessKey
  14026. struct3502.RequestUrl = miConfig.Url
  14027. struct3502.SecretKey = miConfig.SecretKey
  14028. struct3502.ManuDate = "2022-08-15"
  14029. struct3502.FixmedinsBchno = ""
  14030. struct3502.ManuLotnum = ""
  14031. struct3502.RxFlag = "0"
  14032. struct3502.ExpyEnd = "2022-08-15"
  14033. struct3502.Invdate = "2022-08-15"
  14034. struct3502.InvCnt = "20.25"
  14035. struct3502.Memo = ""
  14036. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14037. struct3502.FixmedinsHilistId = miConfig.Code
  14038. struct3502.FixmedinsHilistName = miConfig.OrgName
  14039. struct3502s = append(struct3502s, struct3502)
  14040. data["struct_3502s"] = struct3502s
  14041. client := &http.Client{}
  14042. bytesData, _ := json.Marshal(data)
  14043. var req *http.Request
  14044. if miConfig.MdtrtareaAdmvs == "320921" {
  14045. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14046. } else {
  14047. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14048. }
  14049. resp, _ := client.Do(req)
  14050. defer resp.Body.Close()
  14051. body, ioErr := ioutil.ReadAll(resp.Body)
  14052. if ioErr != nil {
  14053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14055. return
  14056. }
  14057. var respJSON map[string]interface{}
  14058. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14061. return
  14062. }
  14063. var res ResultSix
  14064. var resSix10265 ResultSix10265 //1101结果
  14065. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14066. result, _ := json.Marshal(respJSON)
  14067. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14068. utils.ErrorLog("解析失败:%v", err)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. res.InfRefmsgid = resSix10265.InfRefmsgid
  14073. res.Output = resSix10265.Output
  14074. res.ErrMsg = resSix10265.ErrMsg
  14075. res.Cainfo = resSix10265.Cainfo
  14076. res.WarnMsg = resSix10265.WarnMsg
  14077. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14078. res.Infcode = infocode
  14079. if infocode == 0 {
  14080. c.ServeSuccessJSON(map[string]interface{}{
  14081. "msg": "上传成功",
  14082. })
  14083. return
  14084. } else {
  14085. c.ServeSuccessJSON(map[string]interface{}{
  14086. "failed_code": -10,
  14087. "msg": res.ErrMsg,
  14088. })
  14089. return
  14090. }
  14091. }
  14092. func (c *HisApiController) Post3503() {
  14093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14094. data := make(map[string]interface{})
  14095. var struct3501s []models.Struct3501
  14096. var struct3501 models.Struct3501
  14097. struct3501.OrgName = miConfig.OrgName
  14098. struct3501.AccessKey = miConfig.AccessKey
  14099. struct3501.RequestUrl = miConfig.Url
  14100. struct3501.SecretKey = miConfig.SecretKey
  14101. struct3501.ManuDate = "2022-08-15"
  14102. struct3501.FixmedinsBchno = ""
  14103. struct3501.ManuLotnum = ""
  14104. struct3501.RxFlag = "0"
  14105. struct3501.ExpyEnd = "2022-08-15"
  14106. struct3501.Invdate = "2022-08-15"
  14107. struct3501.InvCnt = "20.25"
  14108. struct3501.Memo = ""
  14109. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14110. struct3501.FixmedinsHilistId = miConfig.Code
  14111. struct3501.FixmedinsHilistName = miConfig.OrgName
  14112. struct3501s = append(struct3501s, struct3501)
  14113. data["struct_3501s"] = struct3501s
  14114. client := &http.Client{}
  14115. bytesData, _ := json.Marshal(data)
  14116. var req *http.Request
  14117. if miConfig.MdtrtareaAdmvs == "320921" {
  14118. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14119. } else {
  14120. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14121. }
  14122. resp, _ := client.Do(req)
  14123. defer resp.Body.Close()
  14124. body, ioErr := ioutil.ReadAll(resp.Body)
  14125. if ioErr != nil {
  14126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14128. return
  14129. }
  14130. var respJSON map[string]interface{}
  14131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14134. return
  14135. }
  14136. var res ResultSix
  14137. var resSix10265 ResultSix10265 //1101结果
  14138. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14139. result, _ := json.Marshal(respJSON)
  14140. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14141. utils.ErrorLog("解析失败:%v", err)
  14142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14143. return
  14144. }
  14145. res.InfRefmsgid = resSix10265.InfRefmsgid
  14146. res.Output = resSix10265.Output
  14147. res.ErrMsg = resSix10265.ErrMsg
  14148. res.Cainfo = resSix10265.Cainfo
  14149. res.WarnMsg = resSix10265.WarnMsg
  14150. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14151. res.Infcode = infocode
  14152. if infocode == 0 {
  14153. c.ServeSuccessJSON(map[string]interface{}{
  14154. "msg": "上传成功",
  14155. })
  14156. return
  14157. } else {
  14158. c.ServeSuccessJSON(map[string]interface{}{
  14159. "failed_code": -10,
  14160. "msg": res.ErrMsg,
  14161. })
  14162. return
  14163. }
  14164. }
  14165. func (c *HisApiController) Post3504() {
  14166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14167. data := make(map[string]interface{})
  14168. var struct3501s []models.Struct3501
  14169. var struct3501 models.Struct3501
  14170. struct3501.OrgName = miConfig.OrgName
  14171. struct3501.AccessKey = miConfig.AccessKey
  14172. struct3501.RequestUrl = miConfig.Url
  14173. struct3501.SecretKey = miConfig.SecretKey
  14174. struct3501.ManuDate = "2022-08-15"
  14175. struct3501.FixmedinsBchno = ""
  14176. struct3501.ManuLotnum = ""
  14177. struct3501.RxFlag = "0"
  14178. struct3501.ExpyEnd = "2022-08-15"
  14179. struct3501.Invdate = "2022-08-15"
  14180. struct3501.InvCnt = "20.25"
  14181. struct3501.Memo = ""
  14182. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14183. struct3501.FixmedinsHilistId = miConfig.Code
  14184. struct3501.FixmedinsHilistName = miConfig.OrgName
  14185. struct3501s = append(struct3501s, struct3501)
  14186. data["struct_3501s"] = struct3501s
  14187. client := &http.Client{}
  14188. bytesData, _ := json.Marshal(data)
  14189. var req *http.Request
  14190. if miConfig.MdtrtareaAdmvs == "320921" {
  14191. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14192. } else {
  14193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14194. }
  14195. resp, _ := client.Do(req)
  14196. defer resp.Body.Close()
  14197. body, ioErr := ioutil.ReadAll(resp.Body)
  14198. if ioErr != nil {
  14199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14201. return
  14202. }
  14203. var respJSON map[string]interface{}
  14204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14207. return
  14208. }
  14209. var res ResultSix
  14210. var resSix10265 ResultSix10265 //1101结果
  14211. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14212. result, _ := json.Marshal(respJSON)
  14213. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14214. utils.ErrorLog("解析失败:%v", err)
  14215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14216. return
  14217. }
  14218. res.InfRefmsgid = resSix10265.InfRefmsgid
  14219. res.Output = resSix10265.Output
  14220. res.ErrMsg = resSix10265.ErrMsg
  14221. res.Cainfo = resSix10265.Cainfo
  14222. res.WarnMsg = resSix10265.WarnMsg
  14223. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14224. res.Infcode = infocode
  14225. if infocode == 0 {
  14226. c.ServeSuccessJSON(map[string]interface{}{
  14227. "msg": "上传成功",
  14228. })
  14229. return
  14230. } else {
  14231. c.ServeSuccessJSON(map[string]interface{}{
  14232. "failed_code": -10,
  14233. "msg": res.ErrMsg,
  14234. })
  14235. return
  14236. }
  14237. }
  14238. func (c *HisApiController) Post3505() {
  14239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14240. data := make(map[string]interface{})
  14241. var struct3501s []models.Struct3501
  14242. var struct3501 models.Struct3501
  14243. struct3501.OrgName = miConfig.OrgName
  14244. struct3501.AccessKey = miConfig.AccessKey
  14245. struct3501.RequestUrl = miConfig.Url
  14246. struct3501.SecretKey = miConfig.SecretKey
  14247. struct3501.ManuDate = "2022-08-15"
  14248. struct3501.FixmedinsBchno = ""
  14249. struct3501.ManuLotnum = ""
  14250. struct3501.RxFlag = "0"
  14251. struct3501.ExpyEnd = "2022-08-15"
  14252. struct3501.Invdate = "2022-08-15"
  14253. struct3501.InvCnt = "20.25"
  14254. struct3501.Memo = ""
  14255. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14256. struct3501.FixmedinsHilistId = miConfig.Code
  14257. struct3501.FixmedinsHilistName = miConfig.OrgName
  14258. struct3501s = append(struct3501s, struct3501)
  14259. data["struct_3501s"] = struct3501s
  14260. client := &http.Client{}
  14261. bytesData, _ := json.Marshal(data)
  14262. var req *http.Request
  14263. if miConfig.MdtrtareaAdmvs == "320921" {
  14264. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14265. } else {
  14266. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14267. }
  14268. resp, _ := client.Do(req)
  14269. defer resp.Body.Close()
  14270. body, ioErr := ioutil.ReadAll(resp.Body)
  14271. if ioErr != nil {
  14272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14274. return
  14275. }
  14276. var respJSON map[string]interface{}
  14277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14280. return
  14281. }
  14282. var res ResultSix
  14283. var resSix10265 ResultSix10265 //1101结果
  14284. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14285. result, _ := json.Marshal(respJSON)
  14286. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14287. utils.ErrorLog("解析失败:%v", err)
  14288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14289. return
  14290. }
  14291. res.InfRefmsgid = resSix10265.InfRefmsgid
  14292. res.Output = resSix10265.Output
  14293. res.ErrMsg = resSix10265.ErrMsg
  14294. res.Cainfo = resSix10265.Cainfo
  14295. res.WarnMsg = resSix10265.WarnMsg
  14296. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14297. res.Infcode = infocode
  14298. if infocode == 0 {
  14299. c.ServeSuccessJSON(map[string]interface{}{
  14300. "msg": "上传成功",
  14301. })
  14302. return
  14303. } else {
  14304. c.ServeSuccessJSON(map[string]interface{}{
  14305. "failed_code": -10,
  14306. "msg": res.ErrMsg,
  14307. })
  14308. return
  14309. }
  14310. }
  14311. func (c *HisApiController) Post3506() {
  14312. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14313. data := make(map[string]interface{})
  14314. var struct3501s []models.Struct3501
  14315. var struct3501 models.Struct3501
  14316. struct3501.OrgName = miConfig.OrgName
  14317. struct3501.AccessKey = miConfig.AccessKey
  14318. struct3501.RequestUrl = miConfig.Url
  14319. struct3501.SecretKey = miConfig.SecretKey
  14320. struct3501.ManuDate = "2022-08-15"
  14321. struct3501.FixmedinsBchno = ""
  14322. struct3501.ManuLotnum = ""
  14323. struct3501.RxFlag = "0"
  14324. struct3501.ExpyEnd = "2022-08-15"
  14325. struct3501.Invdate = "2022-08-15"
  14326. struct3501.InvCnt = "20.25"
  14327. struct3501.Memo = ""
  14328. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14329. struct3501.FixmedinsHilistId = miConfig.Code
  14330. struct3501.FixmedinsHilistName = miConfig.OrgName
  14331. struct3501s = append(struct3501s, struct3501)
  14332. data["struct_3501s"] = struct3501s
  14333. client := &http.Client{}
  14334. bytesData, _ := json.Marshal(data)
  14335. var req *http.Request
  14336. if miConfig.MdtrtareaAdmvs == "320921" {
  14337. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14338. } else {
  14339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14340. }
  14341. resp, _ := client.Do(req)
  14342. defer resp.Body.Close()
  14343. body, ioErr := ioutil.ReadAll(resp.Body)
  14344. if ioErr != nil {
  14345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14347. return
  14348. }
  14349. var respJSON map[string]interface{}
  14350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14353. return
  14354. }
  14355. var res ResultSix
  14356. var resSix10265 ResultSix10265 //1101结果
  14357. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14358. result, _ := json.Marshal(respJSON)
  14359. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14360. utils.ErrorLog("解析失败:%v", err)
  14361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14362. return
  14363. }
  14364. res.InfRefmsgid = resSix10265.InfRefmsgid
  14365. res.Output = resSix10265.Output
  14366. res.ErrMsg = resSix10265.ErrMsg
  14367. res.Cainfo = resSix10265.Cainfo
  14368. res.WarnMsg = resSix10265.WarnMsg
  14369. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14370. res.Infcode = infocode
  14371. if infocode == 0 {
  14372. c.ServeSuccessJSON(map[string]interface{}{
  14373. "msg": "上传成功",
  14374. })
  14375. return
  14376. } else {
  14377. c.ServeSuccessJSON(map[string]interface{}{
  14378. "failed_code": -10,
  14379. "msg": res.ErrMsg,
  14380. })
  14381. return
  14382. }
  14383. }
  14384. func (c *HisApiController) Post3507() {
  14385. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14386. data := make(map[string]interface{})
  14387. var struct3501s []models.Struct3501
  14388. var struct3501 models.Struct3501
  14389. struct3501.OrgName = miConfig.OrgName
  14390. struct3501.AccessKey = miConfig.AccessKey
  14391. struct3501.RequestUrl = miConfig.Url
  14392. struct3501.SecretKey = miConfig.SecretKey
  14393. struct3501.ManuDate = "2022-08-15"
  14394. struct3501.FixmedinsBchno = ""
  14395. struct3501.ManuLotnum = ""
  14396. struct3501.RxFlag = "0"
  14397. struct3501.ExpyEnd = "2022-08-15"
  14398. struct3501.Invdate = "2022-08-15"
  14399. struct3501.InvCnt = "20.25"
  14400. struct3501.Memo = ""
  14401. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14402. struct3501.FixmedinsHilistId = miConfig.Code
  14403. struct3501.FixmedinsHilistName = miConfig.OrgName
  14404. struct3501s = append(struct3501s, struct3501)
  14405. data["struct_3501s"] = struct3501s
  14406. client := &http.Client{}
  14407. bytesData, _ := json.Marshal(data)
  14408. var req *http.Request
  14409. if miConfig.MdtrtareaAdmvs == "320921" {
  14410. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14411. } else {
  14412. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14413. }
  14414. resp, _ := client.Do(req)
  14415. defer resp.Body.Close()
  14416. body, ioErr := ioutil.ReadAll(resp.Body)
  14417. if ioErr != nil {
  14418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14420. return
  14421. }
  14422. var respJSON map[string]interface{}
  14423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14426. return
  14427. }
  14428. var res ResultSix
  14429. var resSix10265 ResultSix10265 //1101结果
  14430. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14431. result, _ := json.Marshal(respJSON)
  14432. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14433. utils.ErrorLog("解析失败:%v", err)
  14434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14435. return
  14436. }
  14437. res.InfRefmsgid = resSix10265.InfRefmsgid
  14438. res.Output = resSix10265.Output
  14439. res.ErrMsg = resSix10265.ErrMsg
  14440. res.Cainfo = resSix10265.Cainfo
  14441. res.WarnMsg = resSix10265.WarnMsg
  14442. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14443. res.Infcode = infocode
  14444. if infocode == 0 {
  14445. c.ServeSuccessJSON(map[string]interface{}{
  14446. "msg": "上传成功",
  14447. })
  14448. return
  14449. } else {
  14450. c.ServeSuccessJSON(map[string]interface{}{
  14451. "failed_code": -10,
  14452. "msg": res.ErrMsg,
  14453. })
  14454. return
  14455. }
  14456. }