his_api_controller.go 572KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741
  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" {
  134. if initFlag == 0 {
  135. c.TestGetBasBaseInit()
  136. }
  137. token := c.GetEleBaseInfo()
  138. token = Remove0000(token)
  139. if len(token) > 0 {
  140. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  142. var res ResultTwo
  143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. if res.Infcode == 0 {
  149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  150. if err == gorm.ErrRecordNotFound {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  152. return
  153. } else if err != nil {
  154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  155. return
  156. } else {
  157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  159. infoStr := string(Iinfos)
  160. idetinfoStr := string(Idetinfos)
  161. psn := &models.HisPsn{
  162. PsnNo: res.Output.Baseinfo.PsnNo,
  163. Age: res.Output.Baseinfo.Age,
  164. PatientId: patient.ID,
  165. Certno: res.Output.Baseinfo.Certno,
  166. Brdy: res.Output.Baseinfo.Brdy,
  167. Gend: res.Output.Baseinfo.Gend,
  168. Naty: res.Output.Baseinfo.Naty,
  169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  170. PsnName: res.Output.Baseinfo.PsnName,
  171. Idetinfo: idetinfoStr,
  172. Insuinfo: infoStr,
  173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  174. CardInfo: "",
  175. VerifyNumber: token,
  176. }
  177. service.CreateHisPsn(psn)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "msg": "读取成功",
  180. })
  181. }
  182. } else {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  184. return
  185. }
  186. } else {
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "failed_code": -10,
  189. "msg": "读取失败",
  190. })
  191. }
  192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  193. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  194. if len(errMsg) == 0 {
  195. type ELeData struct {
  196. Data struct {
  197. IdNo string `json:"idNo"`
  198. IdType string `json:"idType"`
  199. UserName string `json:"userName"`
  200. EcToken string `json:"ecToken"`
  201. InsuOrg string `json:"insuOrg"`
  202. Gender string `json:"gender"`
  203. Birthday string `json:"birthday"`
  204. Nationality string `json:"nationality"`
  205. Email string `json:"email"`
  206. Extra string `json:"extra"`
  207. } `json:"data"`
  208. Code int `json:"code"`
  209. Message string `json:"message"`
  210. }
  211. var ele ELeData
  212. err := json.Unmarshal([]byte(outPutInfo), &ele)
  213. if err != nil {
  214. utils.ErrorLog("解析失败:%v", err)
  215. }
  216. token := ele.Data.EcToken
  217. if len(token) > 0 {
  218. psn := &models.HisPsn{
  219. PsnNo: his.PsnNo,
  220. Age: 0,
  221. PatientId: his.PatientId,
  222. Certno: his.Certno,
  223. Brdy: his.Brdy,
  224. Gend: his.Gend,
  225. Naty: his.Naty,
  226. PsnCertType: his.PsnCertType,
  227. PsnName: his.PsnName,
  228. Idetinfo: his.Idetinfo,
  229. Insuinfo: his.Iinfo,
  230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  231. CardInfo: outPutInfo,
  232. VerifyNumber: token,
  233. }
  234. service.CreateHisPsn(psn)
  235. }
  236. if len(token) > 0 {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "读取成功",
  239. })
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": "读取失败",
  244. })
  245. }
  246. }
  247. } else if miConfig.MdtrtareaAdmvs == "360399" {
  248. if initFlag == 0 {
  249. c.TestGetJiangXiBasBaseInit()
  250. }
  251. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  252. type ELeData struct {
  253. Data struct {
  254. IdNo string `json:"idNo"`
  255. IdType string `json:"idType"`
  256. UserName string `json:"userName"`
  257. EcToken string `json:"ecToken"`
  258. InsuOrg string `json:"insuOrg"`
  259. Gender string `json:"gender"`
  260. Birthday string `json:"birthday"`
  261. Nationality string `json:"nationality"`
  262. Email string `json:"email"`
  263. Extra string `json:"extra"`
  264. } `json:"data"`
  265. Code int `json:"code"`
  266. Message string `json:"message"`
  267. }
  268. var ele ELeData
  269. err := json.Unmarshal([]byte(json_result), &ele)
  270. if err != nil {
  271. utils.ErrorLog("解析失败:%v", err)
  272. }
  273. token := ele.Data.EcToken
  274. token = Remove0000(token)
  275. fmt.Println(ele.Data.UserName)
  276. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  277. saveLog(result2, requestLog2, "1101", "获取人员信息")
  278. var res ResultTwo
  279. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  280. utils.ErrorLog("解析失败:%v", err)
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. if res.Infcode == 0 {
  285. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  286. if err == gorm.ErrRecordNotFound {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  288. return
  289. } else if err != nil {
  290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  291. return
  292. } else {
  293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  295. infoStr := string(Iinfos)
  296. idetinfoStr := string(Idetinfos)
  297. psn := &models.HisPsn{
  298. PsnNo: res.Output.Baseinfo.PsnNo,
  299. Age: res.Output.Baseinfo.Age,
  300. PatientId: patient.ID,
  301. Certno: res.Output.Baseinfo.Certno,
  302. Brdy: res.Output.Baseinfo.Brdy,
  303. Gend: res.Output.Baseinfo.Gend,
  304. Naty: res.Output.Baseinfo.Naty,
  305. PsnCertType: res.Output.Baseinfo.PsnCertType,
  306. PsnName: res.Output.Baseinfo.PsnName,
  307. Idetinfo: idetinfoStr,
  308. Insuinfo: infoStr,
  309. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  310. CardInfo: "",
  311. VerifyNumber: token,
  312. }
  313. service.CreateHisPsn(psn)
  314. c.ServeSuccessJSON(map[string]interface{}{
  315. "patient": patient,
  316. "number": token,
  317. })
  318. }
  319. } else {
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  321. return
  322. }
  323. } else if miConfig.MdtrtareaAdmvs == "430800" {
  324. if initFlag == 0 {
  325. c.TestGetJiangXiBasBaseInit()
  326. }
  327. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. type ELeData struct {
  329. Data struct {
  330. IdNo string `json:"idNo"`
  331. IdType string `json:"idType"`
  332. UserName string `json:"userName"`
  333. EcToken string `json:"ecToken"`
  334. InsuOrg string `json:"insuOrg"`
  335. Gender string `json:"gender"`
  336. Birthday string `json:"birthday"`
  337. Nationality string `json:"nationality"`
  338. Email string `json:"email"`
  339. Extra string `json:"extra"`
  340. } `json:"data"`
  341. Code int `json:"code"`
  342. Message string `json:"message"`
  343. }
  344. var ele ELeData
  345. err := json.Unmarshal([]byte(json_result), &ele)
  346. if err != nil {
  347. utils.ErrorLog("解析失败:%v", err)
  348. }
  349. token := ele.Data.EcToken
  350. token = Remove0000(token)
  351. fmt.Println(ele.Data.UserName)
  352. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  353. saveLog(result2, requestLog2, "1101", "获取人员信息")
  354. var res ResultTwo
  355. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  356. utils.ErrorLog("解析失败:%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. if res.Infcode == 0 {
  361. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  362. if err == gorm.ErrRecordNotFound {
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  364. return
  365. } else if err != nil {
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  367. return
  368. } else {
  369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  371. infoStr := string(Iinfos)
  372. idetinfoStr := string(Idetinfos)
  373. psn := &models.HisPsn{
  374. PsnNo: res.Output.Baseinfo.PsnNo,
  375. Age: res.Output.Baseinfo.Age,
  376. PatientId: patient.ID,
  377. Certno: res.Output.Baseinfo.Certno,
  378. Brdy: res.Output.Baseinfo.Brdy,
  379. Gend: res.Output.Baseinfo.Gend,
  380. Naty: res.Output.Baseinfo.Naty,
  381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  382. PsnName: res.Output.Baseinfo.PsnName,
  383. Idetinfo: idetinfoStr,
  384. Insuinfo: infoStr,
  385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  386. CardInfo: "",
  387. VerifyNumber: token,
  388. }
  389. service.CreateHisPsn(psn)
  390. c.ServeSuccessJSON(map[string]interface{}{
  391. "patient": patient,
  392. "number": token,
  393. })
  394. }
  395. } else {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  397. return
  398. }
  399. }
  400. }
  401. func (c *HisApiController) Get9001() {
  402. adminUser := c.GetAdminUserInfo()
  403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  405. if miConfig.MdtrtareaAdmvs == "350500" {
  406. service.GetFjAuthorizationInfo(miConfig.Code)
  407. } else {
  408. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  409. var dat map[string]interface{}
  410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  411. fmt.Println(dat)
  412. } else {
  413. fmt.Println(err)
  414. }
  415. userJSONBytes, _ := json.Marshal(dat)
  416. var res models.Result9001
  417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  418. utils.ErrorLog("解析失败:%v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. }
  423. }
  424. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  425. var res Result3101
  426. adminUser := c.GetAdminUserInfo()
  427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  428. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  430. //record_time := c.GetString("record_time")
  431. //trig_scen := c.GetString("trig_scen")
  432. timeLayout := "2006-01-02"
  433. loc, _ := time.LoadLocation("Local")
  434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  435. if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  437. return res
  438. }
  439. recordDateTime := theTime.Unix()
  440. var patientPrescription models.HisPrescriptionInfo
  441. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  442. //if patientPrescription.ID == 0 {
  443. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  444. //}
  445. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  446. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  447. //
  448. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  449. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  450. var pp models.PublicParams
  451. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  452. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  453. pp.FixmedinsName = miConfig.OrgName
  454. pp.FixmedinsCode = miConfig.Code
  455. pp.RequestUrl = miConfig.Url
  456. pp.Cainfo = miConfig.Cainfo
  457. pp.SecretKey = miConfig.SecretKey
  458. pp.AccessKey = miConfig.AccessKey
  459. pp.OpterName = roles.UserName
  460. var config []*models.HisXtDiagnoseConfig
  461. for _, item := range diagnosis_ids {
  462. id, _ := strconv.ParseInt(item, 10, 64)
  463. diagnosisConfig, _ := service.FindDiagnoseById(id)
  464. config = append(config, &diagnosisConfig)
  465. }
  466. var pd models.PatientDtos
  467. pd.PatnID = his.PsnNo
  468. pd.PatnName = his.Name
  469. pd.Gend = his.Gend
  470. pd.Brdy = his.Brdy
  471. pd.Poolarea = miConfig.MdtrtareaAdmvs
  472. pd.CurrMdtrtID = his.Number
  473. var fed models.FsiEncounterDtos
  474. fed.MdtrtID = his.Number
  475. fed.MedinsID = miConfig.Code
  476. fed.MedinsName = miConfig.OrgName
  477. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  478. fed.MedMdtrtType = "1"
  479. fed.MedinsType = "1"
  480. fed.MedinsLv = "11"
  481. tm := time.Unix(his.RecordDate, 0)
  482. s_tm := tm.Format("2006-01-02 15:04:05")
  483. fed.AdmDate = s_tm
  484. fed.DscgDate = s_tm
  485. fed.DscgMainDiseCodg = config[0].CountryCode
  486. fed.DscgMainDiseName = config[0].CountryContentName
  487. //诊断信息
  488. var fdds []*models.FsiDiagnoseDtos
  489. for index, item := range config {
  490. if index == 0 {
  491. var fdd models.FsiDiagnoseDtos
  492. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  493. fdd.InoutDiseType = "1"
  494. fdd.MaindiseFlag = "1"
  495. fdd.DiseDate = s_tm
  496. fdd.DiasSrtNo = "1"
  497. fdd.DiseName = item.CountryContentName
  498. fdd.DiseCodg = item.CountryCode
  499. fdds = append(fdds, &fdd)
  500. } else {
  501. var fdd models.FsiDiagnoseDtos
  502. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  503. fdd.InoutDiseType = "1"
  504. fdd.MaindiseFlag = "1"
  505. fdd.DiseDate = s_tm
  506. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  507. fdd.DiseName = item.CountryContentName
  508. fdd.DiseCodg = item.CountryCode
  509. fdds = append(fdds, &fdd)
  510. }
  511. }
  512. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  513. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  514. fed.AdmDeptName = department.Name
  515. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  516. fed.DscgDeptName = department.Name
  517. fed.MedMdtrtType = "1"
  518. fed.MedType = "11"
  519. //if his.Insutype == "390" {
  520. // fed.MedType = "1402"
  521. //} else {
  522. // fed.MedType = "9933"
  523. //}
  524. var orders []*models.FsiOrderDtos
  525. if trig_scen == "2" {
  526. //处方医嘱信息
  527. for _, item := range prescriptions {
  528. for _, subItem := range item.HisDoctorAdviceInfo {
  529. var order models.FsiOrderDtos
  530. order.RxID = strconv.FormatInt(item.ID, 10)
  531. order.Rxno = strconv.FormatInt(item.ID, 10)
  532. order.LongDrordFlag = "0"
  533. order.HilistType = "1"
  534. order.ChrgType = "1"
  535. order.DrordBhvr = "-"
  536. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  537. order.HosplistName = subItem.BaseDrugLib.DrugName
  538. order.HilistLv = "1"
  539. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  540. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  541. order.HosplistName = subItem.BaseDrugLib.DrugName
  542. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  543. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  544. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  545. order.OwnpayAmt = ""
  546. order.SelfpayAmt = ""
  547. order.Spec = ""
  548. order.SpecUnt = ""
  549. order.DrordBegnDate = s_tm
  550. order.DrordStopDate = ""
  551. order.DrordDrCodg = "1"
  552. order.DrordDeptName = department.Name
  553. order.DrordDrCodg = "1"
  554. order.DrordDrName = doctor_info.UserName
  555. order.DrordDrProfttl = ""
  556. order.CurrDrordFlag = "1"
  557. orders = append(orders, &order)
  558. }
  559. for _, subItem := range item.HisPrescriptionProject {
  560. if subItem.Type == 2 {
  561. var order models.FsiOrderDtos
  562. order.RxID = strconv.FormatInt(item.ID, 10)
  563. order.Rxno = strconv.FormatInt(item.ID, 10)
  564. order.LongDrordFlag = "0"
  565. order.HilistType = "1"
  566. order.ChrgType = "1"
  567. order.DrordBhvr = "-"
  568. order.HilistCode = subItem.HisProject.MedicalCode
  569. order.HosplistName = subItem.HisProject.ProjectName
  570. order.HilistLv = "1"
  571. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  572. order.HosplistCode = subItem.HisProject.MedicalCode
  573. order.HosplistName = subItem.HisProject.ProjectName
  574. order.Cnt = subItem.Count
  575. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  576. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  578. order.OwnpayAmt = ""
  579. order.SelfpayAmt = ""
  580. order.Spec = ""
  581. order.SpecUnt = ""
  582. order.DrordBegnDate = s_tm
  583. order.DrordStopDate = ""
  584. order.DrordDrCodg = "1"
  585. order.DrordDeptName = department.Name
  586. order.DrordDrCodg = "1"
  587. order.DrordDrName = doctor_info.UserName
  588. order.DrordDrProfttl = ""
  589. order.CurrDrordFlag = "1"
  590. orders = append(orders, &order)
  591. }
  592. if subItem.Type == 3 {
  593. var order models.FsiOrderDtos
  594. order.RxID = strconv.FormatInt(item.ID, 10)
  595. order.Rxno = strconv.FormatInt(item.ID, 10)
  596. order.LongDrordFlag = "0"
  597. order.HilistType = "1"
  598. order.ChrgType = "1"
  599. order.DrordBhvr = "-"
  600. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  601. order.HosplistName = subItem.GoodInfo.GoodName
  602. order.HilistLv = "1"
  603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  604. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  605. order.HosplistName = subItem.GoodInfo.GoodName
  606. order.Cnt = subItem.Count
  607. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  608. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  610. order.OwnpayAmt = ""
  611. order.SelfpayAmt = ""
  612. order.Spec = ""
  613. order.SpecUnt = ""
  614. order.DrordBegnDate = s_tm
  615. order.DrordStopDate = ""
  616. order.DrordDrCodg = "1"
  617. order.DrordDeptName = department.Name
  618. order.DrordDrCodg = "1"
  619. order.DrordDrName = doctor_info.UserName
  620. order.DrordDrProfttl = ""
  621. order.CurrDrordFlag = "1"
  622. orders = append(orders, &order)
  623. }
  624. }
  625. }
  626. //处方医嘱信息
  627. }
  628. fed.MatnStas = "0"
  629. fed.MedfeeSumamt = "0"
  630. fed.OwnpayAmt = "0"
  631. fed.SelfpayAmt = "0"
  632. fed.AcctPayamt = "0"
  633. fed.MaAmt = "0"
  634. fed.HifpPayamt = "0"
  635. fed.SetlTotlnum = "1"
  636. fed.Insutype = his.Insutype
  637. fed.ReimFlag = "0"
  638. fed.OutSetlFlag = "0"
  639. var fopd []*models.FsiOperationDtosData
  640. data := make(map[string]interface{})
  641. data["fed"] = fed
  642. data["fdd"] = fdds
  643. data["fod"] = orders
  644. data["pd"] = pd
  645. data["pp"] = pp
  646. data["fopd"] = fopd
  647. data["trig_scen"] = trig_scen
  648. fmt.Println(data)
  649. fmt.Println(fed)
  650. fmt.Println(fdds)
  651. fmt.Println(orders)
  652. fmt.Println(pd)
  653. fmt.Println(pp)
  654. fmt.Println(fopd)
  655. client := &http.Client{}
  656. bytesData, _ := json.Marshal(data)
  657. var req *http.Request
  658. if miConfig.MdtrtareaAdmvs == "320921" {
  659. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  660. } else {
  661. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  662. }
  663. resp, _ := client.Do(req)
  664. defer resp.Body.Close()
  665. body, ioErr := ioutil.ReadAll(resp.Body)
  666. if ioErr != nil {
  667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return res
  670. }
  671. var respJSON map[string]interface{}
  672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  675. return res
  676. }
  677. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  678. fmt.Println(respJSON)
  679. result, _ := json.Marshal(respJSON)
  680. fmt.Println(result)
  681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  682. utils.ErrorLog("解析失败:%v", err)
  683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. return res
  685. }
  686. return res
  687. }
  688. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  689. adminUser := c.GetAdminUserInfo()
  690. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  691. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  693. //record_time := c.GetString("record_time")
  694. //trig_scen := c.GetString("trig_scen")
  695. timeLayout := "2006-01-02"
  696. loc, _ := time.LoadLocation("Local")
  697. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  698. if err != nil {
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. return res
  701. }
  702. recordDateTime := theTime.Unix()
  703. var patientPrescription models.HisPrescriptionInfo
  704. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  705. if patientPrescription.ID == 0 {
  706. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  707. }
  708. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  709. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  710. //
  711. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  712. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  713. var pp models.PublicParams
  714. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  715. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  716. pp.FixmedinsName = miConfig.OrgName
  717. pp.FixmedinsCode = miConfig.Code
  718. pp.RequestUrl = miConfig.Url
  719. pp.Cainfo = miConfig.Cainfo
  720. pp.SecretKey = miConfig.SecretKey
  721. pp.AccessKey = miConfig.AccessKey
  722. pp.OpterName = roles.UserName
  723. var config []*models.HisXtDiagnoseConfig
  724. for _, item := range diagnosis_ids {
  725. id, _ := strconv.ParseInt(item, 10, 64)
  726. diagnosisConfig, _ := service.FindDiagnoseById(id)
  727. config = append(config, &diagnosisConfig)
  728. }
  729. var pd models.PatientDtos
  730. pd.PatnID = his.PsnNo
  731. pd.PatnName = his.Name
  732. pd.Gend = his.Gend
  733. pd.Brdy = his.Brdy
  734. pd.Poolarea = his.InsuplcAdmdvs
  735. pd.CurrMdtrtID = his.Number
  736. var fed models.FsiEncounterDtos
  737. fed.MdtrtID = his.Number
  738. fed.MedinsID = miConfig.Code
  739. fed.MedinsName = miConfig.OrgName
  740. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  741. fed.MedMdtrtType = "1"
  742. fed.MedinsType = "1"
  743. fed.MedinsLv = "11"
  744. tm := time.Unix(his.RecordDate, 0)
  745. s_tm := tm.Format("2006-01-02 15:04:05")
  746. fed.AdmDate = s_tm
  747. fed.DscgDate = s_tm
  748. fed.DscgMainDiseCodg = config[0].CountryCode
  749. fed.DscgMainDiseName = config[0].CountryContentName
  750. //诊断信息
  751. var fdds []*models.FsiDiagnoseDtos
  752. for index, item := range config {
  753. if index == 0 {
  754. var fdd models.FsiDiagnoseDtos
  755. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  756. fdd.InoutDiseType = "1"
  757. fdd.MaindiseFlag = "1"
  758. fdd.DiseDate = s_tm
  759. fdd.DiasSrtNo = "1"
  760. fdd.DiseName = item.CountryContentName
  761. fdd.DiseCodg = item.CountryCode
  762. fdds = append(fdds, &fdd)
  763. } else {
  764. var fdd models.FsiDiagnoseDtos
  765. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  766. fdd.InoutDiseType = "1"
  767. fdd.MaindiseFlag = "1"
  768. fdd.DiseDate = s_tm
  769. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  770. fdd.DiseName = item.CountryContentName
  771. fdd.DiseCodg = item.CountryCode
  772. fdds = append(fdds, &fdd)
  773. }
  774. }
  775. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  776. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  777. fed.AdmDeptName = department.Name
  778. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  779. fed.DscgDeptName = department.Name
  780. fed.MedMdtrtType = "1"
  781. fed.MedType = "11"
  782. //if his.Insutype == "390" {
  783. // fed.MedType = "1402"
  784. //} else {
  785. // fed.MedType = "9933"
  786. //}
  787. var orders []*models.FsiOrderDtos
  788. if trig_scen == "2" {
  789. //处方医嘱信息
  790. for _, item := range prescriptions {
  791. for _, subItem := range item.HisDoctorAdviceInfo {
  792. var order models.FsiOrderDtos
  793. order.RxID = strconv.FormatInt(item.ID, 10)
  794. order.Rxno = strconv.FormatInt(item.ID, 10)
  795. order.LongDrordFlag = "0"
  796. order.HilistType = "1"
  797. order.ChrgType = "1"
  798. order.DrordBhvr = "-"
  799. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  800. order.HosplistName = subItem.BaseDrugLib.DrugName
  801. order.HilistLv = "1"
  802. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  803. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  804. order.HosplistName = subItem.BaseDrugLib.DrugName
  805. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  807. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  808. order.OwnpayAmt = ""
  809. order.SelfpayAmt = ""
  810. order.Spec = ""
  811. order.SpecUnt = ""
  812. order.DrordBegnDate = s_tm
  813. order.DrordStopDate = ""
  814. order.DrordDrCodg = "1"
  815. order.DrordDeptName = department.Name
  816. order.DrordDrCodg = "1"
  817. order.DrordDrName = doctor_info.UserName
  818. order.DrordDrProfttl = ""
  819. order.CurrDrordFlag = "1"
  820. orders = append(orders, &order)
  821. }
  822. for _, subItem := range item.HisPrescriptionProject {
  823. if subItem.Type == 2 {
  824. var order models.FsiOrderDtos
  825. order.RxID = strconv.FormatInt(item.ID, 10)
  826. order.Rxno = strconv.FormatInt(item.ID, 10)
  827. order.LongDrordFlag = "0"
  828. order.HilistType = "1"
  829. order.ChrgType = "1"
  830. order.DrordBhvr = "-"
  831. order.HilistCode = subItem.HisProject.MedicalCode
  832. order.HosplistName = subItem.HisProject.ProjectName
  833. order.HilistLv = "1"
  834. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  835. order.HosplistCode = subItem.HisProject.MedicalCode
  836. order.HosplistName = subItem.HisProject.ProjectName
  837. order.Cnt = subItem.Count
  838. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  839. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  840. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  841. order.OwnpayAmt = ""
  842. order.SelfpayAmt = ""
  843. order.Spec = ""
  844. order.SpecUnt = ""
  845. order.DrordBegnDate = s_tm
  846. order.DrordStopDate = ""
  847. order.DrordDrCodg = "1"
  848. order.DrordDeptName = department.Name
  849. order.DrordDrCodg = "1"
  850. order.DrordDrName = doctor_info.UserName
  851. order.DrordDrProfttl = ""
  852. order.CurrDrordFlag = "1"
  853. orders = append(orders, &order)
  854. }
  855. if subItem.Type == 3 {
  856. var order models.FsiOrderDtos
  857. order.RxID = strconv.FormatInt(item.ID, 10)
  858. order.Rxno = strconv.FormatInt(item.ID, 10)
  859. order.LongDrordFlag = "0"
  860. order.HilistType = "1"
  861. order.ChrgType = "1"
  862. order.DrordBhvr = "-"
  863. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  864. order.HosplistName = subItem.GoodInfo.GoodName
  865. order.HilistLv = "1"
  866. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  867. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  868. order.HosplistName = subItem.GoodInfo.GoodName
  869. order.Cnt = subItem.Count
  870. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  871. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  872. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  873. order.OwnpayAmt = ""
  874. order.SelfpayAmt = ""
  875. order.Spec = ""
  876. order.SpecUnt = ""
  877. order.DrordBegnDate = s_tm
  878. order.DrordStopDate = ""
  879. order.DrordDrCodg = "1"
  880. order.DrordDeptName = department.Name
  881. order.DrordDrCodg = "1"
  882. order.DrordDrName = doctor_info.UserName
  883. order.DrordDrProfttl = ""
  884. order.CurrDrordFlag = "1"
  885. orders = append(orders, &order)
  886. }
  887. }
  888. }
  889. //处方医嘱信息
  890. }
  891. fed.MatnStas = "0"
  892. fed.MedfeeSumamt = "0"
  893. fed.OwnpayAmt = "0"
  894. fed.SelfpayAmt = "0"
  895. fed.AcctPayamt = "0"
  896. fed.MaAmt = "0"
  897. fed.HifpPayamt = "0"
  898. fed.SetlTotlnum = "1"
  899. fed.Insutype = his.Insutype
  900. fed.ReimFlag = "0"
  901. fed.OutSetlFlag = "0"
  902. var fopd []*models.FsiOperationDtosData
  903. data := make(map[string]interface{})
  904. data["fed"] = fed
  905. data["fdd"] = fdds
  906. data["fod"] = orders
  907. data["pd"] = pd
  908. data["pp"] = pp
  909. data["fopd"] = fopd
  910. data["trig_scen"] = trig_scen
  911. fmt.Println(data)
  912. fmt.Println(fed)
  913. fmt.Println(fdds)
  914. fmt.Println(orders)
  915. fmt.Println(pd)
  916. fmt.Println(pp)
  917. fmt.Println(fopd)
  918. client := &http.Client{}
  919. bytesData, _ := json.Marshal(data)
  920. var req *http.Request
  921. if miConfig.MdtrtareaAdmvs == "320921" {
  922. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  923. } else {
  924. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  925. }
  926. resp, _ := client.Do(req)
  927. defer resp.Body.Close()
  928. body, ioErr := ioutil.ReadAll(resp.Body)
  929. if ioErr != nil {
  930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return res
  933. }
  934. var respJSON map[string]interface{}
  935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return res
  939. }
  940. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  941. result, _ := json.Marshal(respJSON)
  942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  943. utils.ErrorLog("解析失败:%v", err)
  944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  945. return res
  946. }
  947. return res
  948. }
  949. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  950. ////patient_id, _ := c.GetInt64("patient_id")
  951. //order_id, _ := c.GetInt64("order_id")
  952. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  953. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  954. //trig_scen := c.GetString("trig_scen")
  955. adminUser := c.GetAdminUserInfo()
  956. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  957. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  959. record_time := c.GetString("record_time")
  960. order, _ := service.GetHisOrderByID(order_id)
  961. timeLayout := "2006-01-02"
  962. loc, _ := time.LoadLocation("Local")
  963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  964. if err != nil {
  965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  966. return
  967. }
  968. recordDateTime := theTime.Unix()
  969. var patientPrescription models.HisPrescriptionInfo
  970. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  971. if patientPrescription.ID == 0 {
  972. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  973. }
  974. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  975. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  976. //
  977. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  978. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  979. var pp models.PublicParams
  980. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  981. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  982. pp.FixmedinsName = miConfig.OrgName
  983. pp.FixmedinsCode = miConfig.Code
  984. pp.RequestUrl = miConfig.Url
  985. pp.Cainfo = miConfig.Cainfo
  986. pp.SecretKey = miConfig.SecretKey
  987. pp.AccessKey = miConfig.AccessKey
  988. pp.OpterName = roles.UserName
  989. var config []*models.HisXtDiagnoseConfig
  990. for _, item := range diagnosis_ids {
  991. id, _ := strconv.ParseInt(item, 10, 64)
  992. diagnosisConfig, _ := service.FindDiagnoseById(id)
  993. config = append(config, &diagnosisConfig)
  994. }
  995. var pd models.PatientDtos
  996. pd.PatnID = his.PsnNo
  997. pd.PatnName = his.Name
  998. pd.Gend = his.Gend
  999. pd.Brdy = his.Brdy
  1000. pd.Poolarea = his.InsuplcAdmdvs
  1001. pd.CurrMdtrtID = his.Number
  1002. var fed models.FsiEncounterDtos
  1003. fed.MdtrtID = his.Number
  1004. fed.MedinsID = miConfig.Code
  1005. fed.MedinsName = miConfig.OrgName
  1006. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1007. fed.MedMdtrtType = "1"
  1008. fed.MedinsType = "1"
  1009. fed.MedinsLv = "11"
  1010. tm := time.Unix(his.RecordDate, 0)
  1011. s_tm := tm.Format("2006-01-02 15:04:05")
  1012. fed.AdmDate = s_tm
  1013. fed.DscgDate = s_tm
  1014. fed.DscgMainDiseCodg = config[0].CountryCode
  1015. fed.DscgMainDiseName = config[0].CountryContentName
  1016. //诊断信息
  1017. var fdds []*models.FsiDiagnoseDtos
  1018. for index, item := range config {
  1019. if index == 0 {
  1020. var fdd models.FsiDiagnoseDtos
  1021. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1022. fdd.InoutDiseType = "1"
  1023. fdd.MaindiseFlag = "1"
  1024. fdd.DiseDate = s_tm
  1025. fdd.DiasSrtNo = "1"
  1026. fdd.DiseName = item.CountryContentName
  1027. fdd.DiseCodg = item.CountryCode
  1028. fdds = append(fdds, &fdd)
  1029. } else {
  1030. var fdd models.FsiDiagnoseDtos
  1031. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1032. fdd.InoutDiseType = "1"
  1033. fdd.MaindiseFlag = "1"
  1034. fdd.DiseDate = s_tm
  1035. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1036. fdd.DiseName = item.CountryContentName
  1037. fdd.DiseCodg = item.CountryCode
  1038. fdds = append(fdds, &fdd)
  1039. }
  1040. }
  1041. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1042. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1043. fed.AdmDeptName = department.Name
  1044. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1045. fed.DscgDeptName = department.Name
  1046. fed.MedType = order.MedType
  1047. //处方医嘱信息
  1048. var orders []*models.FsiOrderDtos
  1049. //for _, item := range prescriptions {
  1050. // for _, subItem := range item.HisDoctorAdviceInfo {
  1051. // var order models.FsiOrderDtos
  1052. // order.RxID = strconv.FormatInt(item.ID, 10)
  1053. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1054. // order.LongDrordFlag = "0"
  1055. // order.HilistType = "1"
  1056. // order.ChrgType = "1"
  1057. // order.DrordBhvr = "-"
  1058. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1059. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1060. // order.HilistLv = "1"
  1061. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1062. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1063. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1064. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1065. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1066. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1067. // order.OwnpayAmt = ""
  1068. // order.SelfpayAmt = ""
  1069. // order.Spec = ""
  1070. // order.SpecUnt = ""
  1071. // order.DrordBegnDate = s_tm
  1072. // order.DrordStopDate = ""
  1073. // order.DrordDrCodg = "1"
  1074. // order.DrordDeptName = department.Name
  1075. // order.DrordDrCodg = "1"
  1076. // order.DrordDrName = doctor_info.UserName
  1077. // order.DrordDrProfttl = ""
  1078. // order.CurrDrordFlag = "1"
  1079. // orders = append(orders, &order)
  1080. // }
  1081. // for _, subItem := range item.HisPrescriptionProject {
  1082. // if subItem.Type == 2 {
  1083. // var order models.FsiOrderDtos
  1084. // order.RxID = strconv.FormatInt(item.ID, 10)
  1085. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1086. // order.LongDrordFlag = "0"
  1087. // order.HilistType = "1"
  1088. // order.ChrgType = "1"
  1089. // order.DrordBhvr = "-"
  1090. // order.HilistCode = subItem.HisProject.MedicalCode
  1091. // order.HosplistName = subItem.HisProject.ProjectName
  1092. // order.HilistLv = "1"
  1093. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1094. // order.HosplistCode = subItem.HisProject.MedicalCode
  1095. // order.HosplistName = subItem.HisProject.ProjectName
  1096. // order.Cnt = subItem.Count
  1097. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1098. //
  1099. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1100. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1101. // order.OwnpayAmt = ""
  1102. // order.SelfpayAmt = ""
  1103. // order.Spec = ""
  1104. // order.SpecUnt = ""
  1105. // order.DrordBegnDate = s_tm
  1106. // order.DrordStopDate = ""
  1107. // order.DrordDrCodg = "1"
  1108. // order.DrordDeptName = department.Name
  1109. // order.DrordDrCodg = "1"
  1110. // order.DrordDrName = doctor_info.UserName
  1111. // order.DrordDrProfttl = ""
  1112. // order.CurrDrordFlag = "1"
  1113. // orders = append(orders, &order)
  1114. //
  1115. // }
  1116. // if subItem.Type == 3 {
  1117. //
  1118. // var order models.FsiOrderDtos
  1119. // order.RxID = strconv.FormatInt(item.ID, 10)
  1120. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1121. // order.LongDrordFlag = "0"
  1122. // order.HilistType = "1"
  1123. // order.ChrgType = "1"
  1124. // order.DrordBhvr = "-"
  1125. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1126. // order.HosplistName = subItem.GoodInfo.GoodName
  1127. // order.HilistLv = "1"
  1128. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1129. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1130. // order.HosplistName = subItem.GoodInfo.GoodName
  1131. // order.Cnt = subItem.Count
  1132. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1133. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1134. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1135. // order.OwnpayAmt = ""
  1136. // order.SelfpayAmt = ""
  1137. // order.Spec = ""
  1138. // order.SpecUnt = ""
  1139. // order.DrordBegnDate = s_tm
  1140. // order.DrordStopDate = ""
  1141. // order.DrordDrCodg = "1"
  1142. // order.DrordDeptName = department.Name
  1143. // order.DrordDrCodg = "1"
  1144. // order.DrordDrName = doctor_info.UserName
  1145. // order.DrordDrProfttl = ""
  1146. // order.CurrDrordFlag = "1"
  1147. // orders = append(orders, &order)
  1148. //
  1149. // }
  1150. // }
  1151. //}
  1152. for _, item := range prescriptions {
  1153. for _, subItem := range item.HisDoctorAdviceInfo {
  1154. var order models.FsiOrderDtos
  1155. order.RxID = strconv.FormatInt(item.ID, 10)
  1156. order.Rxno = strconv.FormatInt(item.ID, 10)
  1157. order.LongDrordFlag = "0"
  1158. order.HilistType = "1"
  1159. order.ChrgType = "1"
  1160. order.DrordBhvr = "-"
  1161. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1162. order.HosplistName = subItem.BaseDrugLib.DrugName
  1163. order.HilistLv = "1"
  1164. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1165. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1166. order.HosplistName = subItem.BaseDrugLib.DrugName
  1167. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1169. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1170. order.OwnpayAmt = ""
  1171. order.SelfpayAmt = ""
  1172. order.Spec = ""
  1173. order.SpecUnt = ""
  1174. order.DrordBegnDate = s_tm
  1175. order.DrordStopDate = ""
  1176. order.DrordDrCodg = "1"
  1177. order.DrordDeptName = department.Name
  1178. order.DrordDrCodg = "1"
  1179. order.DrordDrName = doctor_info.UserName
  1180. order.DrordDrProfttl = ""
  1181. order.CurrDrordFlag = "1"
  1182. orders = append(orders, &order)
  1183. }
  1184. for _, subItem := range item.HisPrescriptionProject {
  1185. if subItem.Type == 2 {
  1186. var order models.FsiOrderDtos
  1187. order.RxID = strconv.FormatInt(item.ID, 10)
  1188. order.Rxno = strconv.FormatInt(item.ID, 10)
  1189. order.LongDrordFlag = "0"
  1190. order.HilistType = "1"
  1191. order.ChrgType = "1"
  1192. order.DrordBhvr = "-"
  1193. order.HilistCode = subItem.HisProject.MedicalCode
  1194. order.HosplistName = subItem.HisProject.ProjectName
  1195. order.HilistLv = "1"
  1196. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1197. order.HosplistCode = subItem.HisProject.MedicalCode
  1198. order.HosplistName = subItem.HisProject.ProjectName
  1199. order.Cnt = subItem.Count
  1200. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1201. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1202. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1203. order.OwnpayAmt = ""
  1204. order.SelfpayAmt = ""
  1205. order.Spec = ""
  1206. order.SpecUnt = ""
  1207. order.DrordBegnDate = s_tm
  1208. order.DrordStopDate = ""
  1209. order.DrordDrCodg = "1"
  1210. order.DrordDeptName = department.Name
  1211. order.DrordDrCodg = "1"
  1212. order.DrordDrName = doctor_info.UserName
  1213. order.DrordDrProfttl = ""
  1214. order.CurrDrordFlag = "1"
  1215. orders = append(orders, &order)
  1216. }
  1217. if subItem.Type == 3 {
  1218. var order models.FsiOrderDtos
  1219. order.RxID = strconv.FormatInt(item.ID, 10)
  1220. order.Rxno = strconv.FormatInt(item.ID, 10)
  1221. order.LongDrordFlag = "0"
  1222. order.HilistType = "1"
  1223. order.ChrgType = "1"
  1224. order.DrordBhvr = "-"
  1225. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1226. order.HosplistName = subItem.GoodInfo.GoodName
  1227. order.HilistLv = "1"
  1228. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1229. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1230. order.HosplistName = subItem.GoodInfo.GoodName
  1231. order.Cnt = subItem.Count
  1232. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1233. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1234. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1235. order.OwnpayAmt = ""
  1236. order.SelfpayAmt = ""
  1237. order.Spec = ""
  1238. order.SpecUnt = ""
  1239. order.DrordBegnDate = s_tm
  1240. order.DrordStopDate = ""
  1241. order.DrordDrCodg = "1"
  1242. order.DrordDeptName = department.Name
  1243. order.DrordDrCodg = "1"
  1244. order.DrordDrName = doctor_info.UserName
  1245. order.DrordDrProfttl = ""
  1246. order.CurrDrordFlag = "1"
  1247. orders = append(orders, &order)
  1248. }
  1249. }
  1250. }
  1251. //处方医嘱信息
  1252. fed.MatnStas = "0"
  1253. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1254. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1255. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1256. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1257. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1258. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1259. fed.SetlTotlnum = "1"
  1260. fed.Insutype = his.Insutype
  1261. fed.ReimFlag = "0"
  1262. fed.OutSetlFlag = "0"
  1263. var fopd []*models.FsiOperationDtosData
  1264. data := make(map[string]interface{})
  1265. data["fed"] = fed
  1266. data["fdd"] = fdds
  1267. data["fod"] = orders
  1268. data["pd"] = pd
  1269. data["pp"] = pp
  1270. data["fopd"] = fopd
  1271. data["trig_scen"] = trig_scen
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return res
  1287. }
  1288. var respJSON map[string]interface{}
  1289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return res
  1293. }
  1294. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1295. result, _ := json.Marshal(respJSON)
  1296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return res
  1300. }
  1301. return res
  1302. //手术操作集合
  1303. //手术操作集合
  1304. }
  1305. func (c *HisApiController) Check() {
  1306. psn_no := c.GetString("psn_no")
  1307. in := c.GetString("in")
  1308. mt := c.GetString("mt")
  1309. baseParams := models.BaseParams{
  1310. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1311. FixmedinsCode: "H15049901371",
  1312. InsuplcAdmdvs: "150499",
  1313. MdtrtareaAdmvs: "150499",
  1314. OrgName: "赤峰费森血液透析中心",
  1315. Doctor: "1111",
  1316. }
  1317. service.Gdyb2001(baseParams, psn_no, in, mt)
  1318. }
  1319. func (c *HisApiController) GetPsnNcdsInfo() {
  1320. admin_user_id, _ := c.GetInt64("admin_user_id")
  1321. patient_id, _ := c.GetInt64("patient_id")
  1322. id, _ := c.GetInt64("id")
  1323. adminUser := c.GetAdminUserInfo()
  1324. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1325. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1326. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1327. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1328. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1329. //
  1330. //if psn_record.ID == 0 {
  1331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1332. // return
  1333. //}
  1334. var res Result5301
  1335. var res10265 Result5301For10265
  1336. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1337. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1338. var api string
  1339. if miConfig.MdtrtareaAdmvs == "320921" {
  1340. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1342. } else {
  1343. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1345. }
  1346. resp, requestErr := http.Get(api)
  1347. if requestErr != nil {
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. body, ioErr := ioutil.ReadAll(resp.Body)
  1352. if ioErr != nil {
  1353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. var respJSON map[string]interface{}
  1358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1364. result, _ := json.Marshal(respJSON)
  1365. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1366. utils.ErrorLog("解析失败:%v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. res.ErrMsg = res10265.ErrMsg
  1371. res.Output = res10265.Output
  1372. res.InfRefmsgid = res10265.InfRefmsgid
  1373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1374. res.Infcode = infocode
  1375. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1376. p, _ := service.GetHisPatientById(patient_id)
  1377. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1378. var dat map[string]interface{}
  1379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1380. fmt.Println(dat)
  1381. } else {
  1382. fmt.Println(err)
  1383. }
  1384. userJSONBytes, _ := json.Marshal(dat)
  1385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1386. utils.ErrorLog("解析失败:%v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1391. p, _ := service.GetHisPatientById(patient_id)
  1392. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1393. var dat map[string]interface{}
  1394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1395. fmt.Println(dat)
  1396. } else {
  1397. fmt.Println(err)
  1398. }
  1399. userJSONBytes, _ := json.Marshal(dat)
  1400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1401. utils.ErrorLog("解析失败:%v", err)
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1403. return
  1404. }
  1405. } else {
  1406. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1407. var dat map[string]interface{}
  1408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1409. fmt.Println(dat)
  1410. } else {
  1411. fmt.Println(err)
  1412. }
  1413. userJSONBytes, _ := json.Marshal(dat)
  1414. if miConfig.Code == "H15049901371" {
  1415. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. res.InfRefmsgid = res10265.InfRefmsgid
  1421. res.Output = res10265.Output
  1422. res.ErrMsg = res10265.ErrMsg
  1423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1424. res.Infcode = infocode
  1425. } else {
  1426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1427. utils.ErrorLog("解析失败:%v", err)
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1429. return
  1430. }
  1431. }
  1432. }
  1433. if res.Infcode == 0 {
  1434. c.ServeSuccessJSON(map[string]interface{}{
  1435. "result": res.Output.Result,
  1436. })
  1437. }
  1438. }
  1439. func (c *HisApiController) CheckInsutype() {
  1440. his_patient_id, _ := c.GetInt64("his_patient_id")
  1441. admin_user_id, _ := c.GetInt64("admin_user_id")
  1442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1445. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res Result90100
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. if res.Infcode != 0 {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "failed_code": -10,
  1462. "msg": res.ErrMsg,
  1463. })
  1464. return
  1465. } else {
  1466. fmt.Println(res)
  1467. }
  1468. }
  1469. func (c *HisApiController) CheckCardPWD() {
  1470. card_pwd := c.GetString("card_pwd")
  1471. his_patient_id, _ := c.GetInt64("his_patient_id")
  1472. admin_user_id, _ := c.GetInt64("admin_user_id")
  1473. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1475. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1476. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1477. bas := strings.Split(psn.CardInfo, "|")
  1478. basNumber := bas[2]
  1479. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1480. var dat map[string]interface{}
  1481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1482. fmt.Println(dat)
  1483. } else {
  1484. fmt.Println(err)
  1485. }
  1486. userJSONBytes, _ := json.Marshal(dat)
  1487. var res Result90991
  1488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1489. utils.ErrorLog("解析失败:%v", err)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. if res.Infcode != 0 {
  1494. c.ServeSuccessJSON(map[string]interface{}{
  1495. "failed_code": -10,
  1496. "msg": res.ErrMsg,
  1497. })
  1498. return
  1499. } else {
  1500. if res.Output.Result.SscnoCheckStat == "0" {
  1501. var msg string
  1502. switch res.Output.Result.CardStat {
  1503. case "00":
  1504. msg = "未激活"
  1505. break
  1506. case "10":
  1507. msg = "激活"
  1508. break
  1509. case "20":
  1510. msg = "窗口挂失"
  1511. break
  1512. case "21":
  1513. msg = "电话挂失"
  1514. break
  1515. case "22":
  1516. msg = "单位网上申报挂失"
  1517. break
  1518. case "23":
  1519. msg = "保健办挂失"
  1520. break
  1521. case "24":
  1522. msg = "个人网上挂失"
  1523. break
  1524. case "25":
  1525. msg = "网上服务大厅挂失"
  1526. break
  1527. case "30":
  1528. msg = "注销"
  1529. break
  1530. case "40":
  1531. msg = "回收"
  1532. break
  1533. case "99":
  1534. msg = "制卡中(无效卡)"
  1535. break
  1536. }
  1537. c.ServeSuccessJSON(map[string]interface{}{
  1538. "failed_code": -10,
  1539. "msg": msg,
  1540. })
  1541. return
  1542. } else {
  1543. c.ServeSuccessJSON(map[string]interface{}{
  1544. "msg": "校验成功",
  1545. })
  1546. return
  1547. }
  1548. }
  1549. }
  1550. func (c *HisApiController) CheckCardPWDTwo() {
  1551. //card_pwd := c.GetString("card_pwd")
  1552. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1553. admin_user_id, _ := c.GetInt64("admin_user_id")
  1554. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1556. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1557. var dat map[string]interface{}
  1558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1559. fmt.Println(dat)
  1560. } else {
  1561. fmt.Println(err)
  1562. }
  1563. userJSONBytes, _ := json.Marshal(dat)
  1564. var res Result90991
  1565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1566. utils.ErrorLog("解析失败:%v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. if res.Infcode != 0 {
  1571. c.ServeSuccessJSON(map[string]interface{}{
  1572. "failed_code": -10,
  1573. "msg": res.ErrMsg,
  1574. })
  1575. return
  1576. } else {
  1577. if res.Output.Result.SscnoCheckStat == "0" {
  1578. var msg string
  1579. switch res.Output.Result.CardStat {
  1580. case "00":
  1581. msg = "未激活"
  1582. break
  1583. case "10":
  1584. msg = "激活"
  1585. break
  1586. case "20":
  1587. msg = "窗口挂失"
  1588. break
  1589. case "21":
  1590. msg = "电话挂失"
  1591. break
  1592. case "22":
  1593. msg = "单位网上申报挂失"
  1594. break
  1595. case "23":
  1596. msg = "保健办挂失"
  1597. break
  1598. case "24":
  1599. msg = "个人网上挂失"
  1600. break
  1601. case "25":
  1602. msg = "网上服务大厅挂失"
  1603. break
  1604. case "30":
  1605. msg = "注销"
  1606. break
  1607. case "40":
  1608. msg = "回收"
  1609. break
  1610. case "99":
  1611. msg = "制卡中(无效卡)"
  1612. break
  1613. }
  1614. c.ServeSuccessJSON(map[string]interface{}{
  1615. "failed_code": -10,
  1616. "msg": msg,
  1617. })
  1618. return
  1619. } else {
  1620. c.ServeSuccessJSON(map[string]interface{}{
  1621. "msg": "校验成功",
  1622. })
  1623. return
  1624. }
  1625. }
  1626. }
  1627. type ELeCertData struct {
  1628. Data struct {
  1629. Extra string `json:"extra"`
  1630. IDNo string `json:"idNo"`
  1631. IDType string `json:"idType"`
  1632. EcToken string `json:"ecToken"`
  1633. InsuOrg string `json:"insuOrg"`
  1634. UserName string `json:"userName"`
  1635. EcIndexNo string `json:"ecIndexNo"`
  1636. Gender string `json:"gender"`
  1637. Birthday string `json:"birthday"`
  1638. Nationality string `json:"nationality"`
  1639. Email string `json:"email"`
  1640. } `json:"OutData"`
  1641. }
  1642. func (c *HisApiController) ReadCard() {
  1643. id_card_type, _ := c.GetInt64("id_card_type")
  1644. admin_user_id, _ := c.GetInt64("admin_user_id")
  1645. certificates, _ := c.GetInt64("certificates")
  1646. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1648. switch id_card_type {
  1649. case 1:
  1650. if miConfig.MdtrtareaAdmvs == "421300" {
  1651. var res ResultTwo
  1652. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1653. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1655. resp, requestErr := http.Get(api)
  1656. if requestErr != nil {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. var respJSON map[string]interface{}
  1667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. fmt.Println("log")
  1675. fmt.Println(string(result))
  1676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1677. utils.ErrorLog("解析失败:%v", err)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. if res.Infcode == 0 {
  1682. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1683. if err == gorm.ErrRecordNotFound {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1685. return
  1686. } else if err != nil {
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1688. return
  1689. } else {
  1690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1692. infoStr := string(Iinfos)
  1693. idetinfoStr := string(Idetinfos)
  1694. psn := &models.HisPsn{
  1695. PsnNo: res.Output.Baseinfo.PsnNo,
  1696. Age: res.Output.Baseinfo.Age,
  1697. PatientId: patient.ID,
  1698. Certno: res.Output.Baseinfo.Certno,
  1699. Brdy: res.Output.Baseinfo.Brdy,
  1700. Gend: res.Output.Baseinfo.Gend,
  1701. Naty: res.Output.Baseinfo.Naty,
  1702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1703. PsnName: res.Output.Baseinfo.PsnName,
  1704. Idetinfo: idetinfoStr,
  1705. Insuinfo: infoStr,
  1706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1707. }
  1708. service.CreateHisPsn(psn)
  1709. c.ServeSuccessJSON(map[string]interface{}{
  1710. "patient": patient,
  1711. "number": res.Output.Baseinfo.Certno,
  1712. })
  1713. }
  1714. } else {
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1716. return
  1717. }
  1718. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1719. var api string
  1720. if miConfig.MdtrtareaAdmvs == "320921" {
  1721. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1722. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1723. fmt.Println(api)
  1724. } else {
  1725. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1726. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1727. }
  1728. resp, requestErr := http.Get(api)
  1729. if requestErr != nil {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. body, ioErr := ioutil.ReadAll(resp.Body)
  1734. if ioErr != nil {
  1735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1737. return
  1738. }
  1739. var respJSON map[string]interface{}
  1740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1743. return
  1744. }
  1745. var status string
  1746. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1747. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1748. //console.log()
  1749. fmt.Println("type===")
  1750. fmt.Println(card_type)
  1751. var token string
  1752. var res ResultTwo //1101结果
  1753. var res10265 ResultTwo10265 //1101结果
  1754. var card_info string //卡信息
  1755. var busi_card_info string
  1756. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1757. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1758. if status == "0" { //读卡成功
  1759. if card_type == "1" {
  1760. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1761. result, _ := json.Marshal(respJSON)
  1762. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1763. utils.ErrorLog("解析失败:%v", err)
  1764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1765. return
  1766. }
  1767. res.ErrMsg = res10265.ErrMsg
  1768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1769. res.Infcode = infocode
  1770. res.Output = res10265.Output
  1771. res.InfRefmsgid = res10265.InfRefmsgid
  1772. } else {
  1773. //var card_info string //卡信息
  1774. //var busi_card_info string
  1775. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1776. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1777. //fmt.Println(card_info)
  1778. //fmt.Println(busi_card_info)
  1779. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1780. result, _ := json.Marshal(respJSON)
  1781. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1782. utils.ErrorLog("解析失败:%v", err)
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1784. return
  1785. }
  1786. res.ErrMsg = res10265.ErrMsg
  1787. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1788. res.Infcode = infocode
  1789. res.Output = res10265.Output
  1790. res.InfRefmsgid = res10265.InfRefmsgid
  1791. }
  1792. if res.Infcode == 0 {
  1793. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1794. if err == gorm.ErrRecordNotFound {
  1795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1796. return
  1797. } else if err != nil {
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1799. return
  1800. } else {
  1801. if card_type == "1" {
  1802. bas := strings.Split(card_info, "|")
  1803. basNumber := bas[2]
  1804. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1805. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1806. infoStr := string(Iinfos)
  1807. idetinfoStr := string(Idetinfos)
  1808. psn := &models.HisPsn{
  1809. PsnNo: res.Output.Baseinfo.PsnNo,
  1810. Age: res.Output.Baseinfo.Age,
  1811. PatientId: patient.ID,
  1812. Certno: res.Output.Baseinfo.Certno,
  1813. Brdy: res.Output.Baseinfo.Brdy,
  1814. Gend: res.Output.Baseinfo.Gend,
  1815. Naty: res.Output.Baseinfo.Naty,
  1816. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1817. PsnName: res.Output.Baseinfo.PsnName,
  1818. Idetinfo: idetinfoStr,
  1819. Insuinfo: infoStr,
  1820. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1821. CardInfo: card_info,
  1822. VerifyNumber: busi_card_info,
  1823. }
  1824. service.CreateHisPsn(psn)
  1825. var rf []*ResultFive
  1826. json.Unmarshal([]byte(infoStr), &rf)
  1827. var insutypes []*ResultFive
  1828. var insutype string
  1829. var is390 int = 0
  1830. var is310 int = 0
  1831. for _, item := range rf {
  1832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1833. insutypes = append(insutypes, item)
  1834. }
  1835. }
  1836. if len(insutypes) == 1 {
  1837. insutype = insutypes[0].Insutype
  1838. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1839. } else {
  1840. for _, i := range insutypes {
  1841. if i.Insutype == "390" {
  1842. is390 = 1
  1843. }
  1844. if i.Insutype == "310" {
  1845. is310 = 1
  1846. }
  1847. }
  1848. }
  1849. if is390 == 1 {
  1850. insutype = "390"
  1851. }
  1852. if is310 == 1 {
  1853. insutype = "310"
  1854. }
  1855. if len(insutypes) == 0 {
  1856. insutype = "310"
  1857. }
  1858. c.ServeSuccessJSON(map[string]interface{}{
  1859. "patient": patient,
  1860. "number": basNumber,
  1861. "insutype": insutype,
  1862. })
  1863. } else {
  1864. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1865. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1866. infoStr := string(Iinfos)
  1867. idetinfoStr := string(Idetinfos)
  1868. psn := &models.HisPsn{
  1869. PsnNo: res.Output.Baseinfo.PsnNo,
  1870. Age: res.Output.Baseinfo.Age,
  1871. PatientId: patient.ID,
  1872. Certno: res.Output.Baseinfo.Certno,
  1873. Brdy: res.Output.Baseinfo.Brdy,
  1874. Gend: res.Output.Baseinfo.Gend,
  1875. Naty: res.Output.Baseinfo.Naty,
  1876. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1877. PsnName: res.Output.Baseinfo.PsnName,
  1878. Idetinfo: idetinfoStr,
  1879. Insuinfo: infoStr,
  1880. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1881. CardInfo: card_info,
  1882. VerifyNumber: token,
  1883. }
  1884. service.CreateHisPsn(psn)
  1885. c.ServeSuccessJSON(map[string]interface{}{
  1886. "patient": patient,
  1887. "number": token,
  1888. })
  1889. }
  1890. }
  1891. } else {
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1893. return
  1894. }
  1895. } else { //读卡失败
  1896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1897. return
  1898. }
  1899. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1900. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1901. cardnum = DeleteExtraSpaceTwo(cardnum)
  1902. cardCode = DeleteExtraSpaceTwo(cardCode)
  1903. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1904. name = DeleteExtraSpaceTwo(name)
  1905. errmsg = DeleteExtraSpaceTwo(errmsg)
  1906. cardnum = Remove0000(cardnum)
  1907. cardCode = Remove0000(cardCode)
  1908. id_card_no = Remove0000(id_card_no)
  1909. name = Remove0000(name)
  1910. errmsg = Remove0000(errmsg)
  1911. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1912. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1913. saveLog(result, requestLog, "1101", "获取人员信息")
  1914. fmt.Println(errMsgLog)
  1915. if len(errMsgLog) > 0 {
  1916. } else {
  1917. var dat map[string]interface{}
  1918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1919. fmt.Println(dat)
  1920. } else {
  1921. fmt.Println(err)
  1922. }
  1923. userJSONBytes, _ := json.Marshal(dat)
  1924. var res ResultTwo
  1925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1926. utils.ErrorLog("解析失败:%v", err)
  1927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. return
  1929. }
  1930. res.ErrMsg = errMsgLog
  1931. if res.Infcode == 0 {
  1932. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1933. if err == gorm.ErrRecordNotFound {
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1935. return
  1936. } else if err != nil {
  1937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1938. return
  1939. } else {
  1940. fmt.Println(res)
  1941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1943. infoStr := string(Iinfos)
  1944. idetinfoStr := string(Idetinfos)
  1945. psn := &models.HisPsn{
  1946. PsnNo: res.Output.Baseinfo.PsnNo,
  1947. Age: res.Output.Baseinfo.Age,
  1948. PatientId: patient.ID,
  1949. Certno: res.Output.Baseinfo.Certno,
  1950. Brdy: res.Output.Baseinfo.Brdy,
  1951. Gend: res.Output.Baseinfo.Gend,
  1952. Naty: res.Output.Baseinfo.Naty,
  1953. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1954. PsnName: res.Output.Baseinfo.PsnName,
  1955. Idetinfo: idetinfoStr,
  1956. Insuinfo: infoStr,
  1957. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1958. CardInfo: basStr,
  1959. VerifyNumber: "",
  1960. }
  1961. service.CreateHisPsn(psn)
  1962. var rf []*ResultFive
  1963. json.Unmarshal([]byte(infoStr), &rf)
  1964. var insutypes []*ResultFive
  1965. var insutype string
  1966. var is390 int = 0
  1967. var is310 int = 0
  1968. for _, item := range rf {
  1969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1970. insutypes = append(insutypes, item)
  1971. }
  1972. }
  1973. if len(insutypes) == 1 {
  1974. insutype = insutypes[0].Insutype
  1975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1976. } else {
  1977. for _, i := range insutypes {
  1978. if i.Insutype == "390" {
  1979. is390 = 1
  1980. }
  1981. if i.Insutype == "310" {
  1982. is310 = 1
  1983. }
  1984. }
  1985. }
  1986. if is390 == 1 {
  1987. insutype = "390"
  1988. }
  1989. if is310 == 1 {
  1990. insutype = "310"
  1991. }
  1992. if len(insutypes) == 0 {
  1993. insutype = "310"
  1994. }
  1995. c.ServeSuccessJSON(map[string]interface{}{
  1996. "patient": patient,
  1997. "number": cardnum,
  1998. "insutype": insutype,
  1999. })
  2000. }
  2001. } else {
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2003. return
  2004. }
  2005. }
  2006. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2007. fmt.Println(initFlag)
  2008. fmt.Println("initFlag")
  2009. if initFlag == 0 {
  2010. c.TestGetJiangXiBasBaseInit()
  2011. }
  2012. basStr := c.GetBasBaseInfo()
  2013. if len(basStr) == 0 {
  2014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2015. return
  2016. }
  2017. fmt.Println(basStr)
  2018. bas := strings.Split(basStr, "|")
  2019. basNumber := bas[1]
  2020. fmt.Println(basNumber)
  2021. card_sn := bas[3]
  2022. fmt.Println(card_sn)
  2023. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2024. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2025. var dat map[string]interface{}
  2026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2027. fmt.Println(dat)
  2028. } else {
  2029. fmt.Println(err)
  2030. }
  2031. userJSONBytes, _ := json.Marshal(dat)
  2032. var res ResultTwo
  2033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2034. utils.ErrorLog("解析失败:%v", err)
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. return
  2037. }
  2038. if res.Infcode == 0 {
  2039. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2040. if err == gorm.ErrRecordNotFound {
  2041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2042. return
  2043. } else if err != nil {
  2044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2045. return
  2046. } else {
  2047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2048. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2049. infoStr := string(Iinfos)
  2050. idetinfoStr := string(Idetinfos)
  2051. psn := &models.HisPsn{
  2052. PsnNo: res.Output.Baseinfo.PsnNo,
  2053. Age: res.Output.Baseinfo.Age,
  2054. PatientId: patient.ID,
  2055. Certno: res.Output.Baseinfo.Certno,
  2056. Brdy: res.Output.Baseinfo.Brdy,
  2057. Gend: res.Output.Baseinfo.Gend,
  2058. Naty: res.Output.Baseinfo.Naty,
  2059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2060. PsnName: res.Output.Baseinfo.PsnName,
  2061. Idetinfo: idetinfoStr,
  2062. Insuinfo: infoStr,
  2063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2064. CardInfo: basStr,
  2065. VerifyNumber: "",
  2066. }
  2067. service.CreateHisPsn(psn)
  2068. var rf []*ResultFive
  2069. json.Unmarshal([]byte(infoStr), &rf)
  2070. var insutypes []*ResultFive
  2071. var insutype string
  2072. var is390 int = 0
  2073. var is310 int = 0
  2074. for _, item := range rf {
  2075. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2076. insutypes = append(insutypes, item)
  2077. }
  2078. }
  2079. if len(insutypes) == 1 {
  2080. insutype = insutypes[0].Insutype
  2081. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2082. } else {
  2083. for _, i := range insutypes {
  2084. if i.Insutype == "390" {
  2085. is390 = 1
  2086. }
  2087. if i.Insutype == "310" {
  2088. is310 = 1
  2089. }
  2090. }
  2091. }
  2092. if is390 == 1 {
  2093. insutype = "390"
  2094. }
  2095. if is310 == 1 {
  2096. insutype = "310"
  2097. }
  2098. if len(insutypes) == 0 {
  2099. insutype = "310"
  2100. }
  2101. c.ServeSuccessJSON(map[string]interface{}{
  2102. "patient": patient,
  2103. "number": basNumber,
  2104. "insutype": insutype,
  2105. })
  2106. }
  2107. } else {
  2108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2109. return
  2110. }
  2111. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2112. fmt.Println(initFlag)
  2113. fmt.Println("initFlag")
  2114. if initFlag == 0 {
  2115. c.TestGetJiangXiBasBaseInit()
  2116. }
  2117. basStr := c.GetBasBaseInfo()
  2118. if len(basStr) == 0 {
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2120. return
  2121. }
  2122. fmt.Println(basStr)
  2123. bas := strings.Split(basStr, "|")
  2124. basNumber := bas[1]
  2125. fmt.Println(basNumber)
  2126. card_sn := bas[3]
  2127. fmt.Println(card_sn)
  2128. 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, "")
  2129. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2130. var dat map[string]interface{}
  2131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2132. fmt.Println(dat)
  2133. } else {
  2134. fmt.Println(err)
  2135. }
  2136. userJSONBytes, _ := json.Marshal(dat)
  2137. var res ResultTwo
  2138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2139. utils.ErrorLog("解析失败:%v", err)
  2140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. return
  2142. }
  2143. if res.Infcode == 0 {
  2144. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2145. if err == gorm.ErrRecordNotFound {
  2146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2147. return
  2148. } else if err != nil {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2150. return
  2151. } else {
  2152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2154. infoStr := string(Iinfos)
  2155. idetinfoStr := string(Idetinfos)
  2156. psn := &models.HisPsn{
  2157. PsnNo: res.Output.Baseinfo.PsnNo,
  2158. Age: res.Output.Baseinfo.Age,
  2159. PatientId: patient.ID,
  2160. Certno: res.Output.Baseinfo.Certno,
  2161. Brdy: res.Output.Baseinfo.Brdy,
  2162. Gend: res.Output.Baseinfo.Gend,
  2163. Naty: res.Output.Baseinfo.Naty,
  2164. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2165. PsnName: res.Output.Baseinfo.PsnName,
  2166. Idetinfo: idetinfoStr,
  2167. Insuinfo: infoStr,
  2168. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2169. CardInfo: basStr,
  2170. VerifyNumber: "",
  2171. }
  2172. service.CreateHisPsn(psn)
  2173. var rf []*ResultFive
  2174. json.Unmarshal([]byte(infoStr), &rf)
  2175. var insutypes []*ResultFive
  2176. var insutype string
  2177. var is390 int = 0
  2178. var is310 int = 0
  2179. for _, item := range rf {
  2180. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2181. insutypes = append(insutypes, item)
  2182. }
  2183. }
  2184. if len(insutypes) == 1 {
  2185. insutype = insutypes[0].Insutype
  2186. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2187. } else {
  2188. for _, i := range insutypes {
  2189. if i.Insutype == "390" {
  2190. is390 = 1
  2191. }
  2192. if i.Insutype == "310" {
  2193. is310 = 1
  2194. }
  2195. }
  2196. }
  2197. if is390 == 1 {
  2198. insutype = "390"
  2199. }
  2200. if is310 == 1 {
  2201. insutype = "310"
  2202. }
  2203. if len(insutypes) == 0 {
  2204. insutype = "310"
  2205. }
  2206. c.ServeSuccessJSON(map[string]interface{}{
  2207. "patient": patient,
  2208. "number": basNumber,
  2209. "insutype": insutype,
  2210. })
  2211. }
  2212. } else {
  2213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2214. return
  2215. }
  2216. } else {
  2217. if initFlag == 0 {
  2218. c.TestGetBasBaseInit()
  2219. }
  2220. basStr := c.GetBasBaseInfo()
  2221. if len(basStr) == 0 {
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2223. return
  2224. }
  2225. fmt.Println(basStr)
  2226. bas := strings.Split(basStr, "|")
  2227. basNumber := bas[1]
  2228. fmt.Println(basNumber)
  2229. card_sn := bas[3]
  2230. fmt.Println(card_sn)
  2231. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2232. var dat map[string]interface{}
  2233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2234. fmt.Println(dat)
  2235. } else {
  2236. fmt.Println(err)
  2237. }
  2238. userJSONBytes, _ := json.Marshal(dat)
  2239. var res ResultTwo
  2240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. if res.Infcode == 0 {
  2246. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2247. if err == gorm.ErrRecordNotFound {
  2248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2249. return
  2250. } else if err != nil {
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2252. return
  2253. } else {
  2254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2256. infoStr := string(Iinfos)
  2257. idetinfoStr := string(Idetinfos)
  2258. psn := &models.HisPsn{
  2259. PsnNo: res.Output.Baseinfo.PsnNo,
  2260. Age: res.Output.Baseinfo.Age,
  2261. PatientId: patient.ID,
  2262. Certno: res.Output.Baseinfo.Certno,
  2263. Brdy: res.Output.Baseinfo.Brdy,
  2264. Gend: res.Output.Baseinfo.Gend,
  2265. Naty: res.Output.Baseinfo.Naty,
  2266. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2267. PsnName: res.Output.Baseinfo.PsnName,
  2268. Idetinfo: idetinfoStr,
  2269. Insuinfo: infoStr,
  2270. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2271. CardInfo: basStr,
  2272. VerifyNumber: "",
  2273. }
  2274. service.CreateHisPsn(psn)
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "patient": patient,
  2277. "number": basNumber,
  2278. })
  2279. }
  2280. } else {
  2281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2282. return
  2283. }
  2284. break
  2285. }
  2286. case 2:
  2287. SFZStr := c.GetSFZBaseInfo()
  2288. id_card_str := strings.Split(SFZStr, "^")
  2289. id_card_number := id_card_str[0]
  2290. card_sn := ""
  2291. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2292. var dat map[string]interface{}
  2293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2294. fmt.Println(dat)
  2295. } else {
  2296. fmt.Println(err)
  2297. }
  2298. userJSONBytes, _ := json.Marshal(dat)
  2299. var res ResultTwo
  2300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2301. utils.ErrorLog("解析失败:%v", err)
  2302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2303. return
  2304. }
  2305. if res.Infcode == 0 {
  2306. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2307. if err == gorm.ErrRecordNotFound {
  2308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2309. return
  2310. } else if err != nil {
  2311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2312. return
  2313. } else {
  2314. c.ServeSuccessJSON(map[string]interface{}{
  2315. "patient": patient,
  2316. "number": id_card_number,
  2317. })
  2318. }
  2319. } else {
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2321. return
  2322. }
  2323. break
  2324. case 3:
  2325. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2326. var api string
  2327. if miConfig.MdtrtareaAdmvs == "320921" {
  2328. 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 +
  2329. "&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
  2330. fmt.Println(api)
  2331. } else {
  2332. 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 +
  2333. "&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)
  2334. }
  2335. resp, requestErr := http.Get(api)
  2336. if requestErr != nil {
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. return
  2339. }
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. var respJSON map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. var status string
  2353. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2354. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2355. var token string
  2356. var res ResultTwo //1101结果
  2357. var res10265 ResultTwo10265 //1101结果
  2358. var card_info string //卡信息
  2359. var busi_card_info string
  2360. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2361. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2362. if status == "0" { //读卡成功
  2363. if card_type == "1" {
  2364. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2365. result, _ := json.Marshal(respJSON)
  2366. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2367. utils.ErrorLog("解析失败:%v", err)
  2368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2369. return
  2370. }
  2371. res.ErrMsg = res10265.ErrMsg
  2372. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2373. res.Infcode = infocode
  2374. res.Output = res10265.Output
  2375. res.InfRefmsgid = res10265.InfRefmsgid
  2376. } else {
  2377. //var card_info string //卡信息
  2378. //var busi_card_info string
  2379. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2380. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2381. //fmt.Println(card_info)
  2382. //fmt.Println(busi_card_info)
  2383. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2384. result, _ := json.Marshal(respJSON)
  2385. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2386. utils.ErrorLog("解析失败:%v", err)
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. return
  2389. }
  2390. res.ErrMsg = res10265.ErrMsg
  2391. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2392. res.Infcode = infocode
  2393. res.Output = res10265.Output
  2394. res.InfRefmsgid = res10265.InfRefmsgid
  2395. }
  2396. if res.Infcode == 0 {
  2397. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2398. if err == gorm.ErrRecordNotFound {
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2400. return
  2401. } else if err != nil {
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2403. return
  2404. } else {
  2405. if card_type == "1" {
  2406. bas := strings.Split(card_info, "|")
  2407. basNumber := bas[2]
  2408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2410. infoStr := string(Iinfos)
  2411. idetinfoStr := string(Idetinfos)
  2412. psn := &models.HisPsn{
  2413. PsnNo: res.Output.Baseinfo.PsnNo,
  2414. Age: res.Output.Baseinfo.Age,
  2415. PatientId: patient.ID,
  2416. Certno: res.Output.Baseinfo.Certno,
  2417. Brdy: res.Output.Baseinfo.Brdy,
  2418. Gend: res.Output.Baseinfo.Gend,
  2419. Naty: res.Output.Baseinfo.Naty,
  2420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2421. PsnName: res.Output.Baseinfo.PsnName,
  2422. Idetinfo: idetinfoStr,
  2423. Insuinfo: infoStr,
  2424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2425. CardInfo: card_info,
  2426. VerifyNumber: busi_card_info,
  2427. }
  2428. service.CreateHisPsn(psn)
  2429. c.ServeSuccessJSON(map[string]interface{}{
  2430. "patient": patient,
  2431. "number": basNumber,
  2432. })
  2433. } else {
  2434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2436. infoStr := string(Iinfos)
  2437. idetinfoStr := string(Idetinfos)
  2438. psn := &models.HisPsn{
  2439. PsnNo: res.Output.Baseinfo.PsnNo,
  2440. Age: res.Output.Baseinfo.Age,
  2441. PatientId: patient.ID,
  2442. Certno: res.Output.Baseinfo.Certno,
  2443. Brdy: res.Output.Baseinfo.Brdy,
  2444. Gend: res.Output.Baseinfo.Gend,
  2445. Naty: res.Output.Baseinfo.Naty,
  2446. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2447. PsnName: res.Output.Baseinfo.PsnName,
  2448. Idetinfo: idetinfoStr,
  2449. Insuinfo: infoStr,
  2450. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2451. CardInfo: card_info,
  2452. VerifyNumber: token,
  2453. }
  2454. service.CreateHisPsn(psn)
  2455. var rf []*ResultFive
  2456. json.Unmarshal([]byte(infoStr), &rf)
  2457. var insutypes []*ResultFive
  2458. var insutype string
  2459. var is390 int = 0
  2460. var is310 int = 0
  2461. for _, item := range rf {
  2462. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2463. insutypes = append(insutypes, item)
  2464. }
  2465. }
  2466. if len(insutypes) == 1 {
  2467. insutype = insutypes[0].Insutype
  2468. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2469. } else {
  2470. for _, i := range insutypes {
  2471. if i.Insutype == "390" {
  2472. is390 = 1
  2473. }
  2474. if i.Insutype == "310" {
  2475. is310 = 1
  2476. }
  2477. }
  2478. }
  2479. if is390 == 1 {
  2480. insutype = "390"
  2481. }
  2482. if is310 == 1 {
  2483. insutype = "310"
  2484. }
  2485. if len(insutypes) == 0 {
  2486. insutype = "310"
  2487. }
  2488. c.ServeSuccessJSON(map[string]interface{}{
  2489. "patient": patient,
  2490. "number": token,
  2491. "insutype": insutype,
  2492. })
  2493. }
  2494. }
  2495. } else {
  2496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2497. return
  2498. }
  2499. } else { //读卡失败
  2500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2501. return
  2502. }
  2503. }
  2504. break
  2505. case 4:
  2506. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2507. var api string
  2508. if miConfig.MdtrtareaAdmvs == "320921" {
  2509. 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 +
  2510. "&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
  2511. fmt.Println(api)
  2512. } else {
  2513. 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 +
  2514. "&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)
  2515. }
  2516. resp, requestErr := http.Get(api)
  2517. if requestErr != nil {
  2518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2519. return
  2520. }
  2521. body, ioErr := ioutil.ReadAll(resp.Body)
  2522. if ioErr != nil {
  2523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. return
  2526. }
  2527. var respJSON map[string]interface{}
  2528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2531. return
  2532. }
  2533. var status string
  2534. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2535. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2536. var token string
  2537. var res ResultTwo //1101结果
  2538. var res10265 ResultTwo10265 //1101结果
  2539. if status == "0" { //读卡成功
  2540. var card_info string //卡信息
  2541. var busi_card_info string
  2542. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2543. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2544. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2545. fmt.Println(card_info)
  2546. fmt.Println(busi_card_info)
  2547. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2548. result, _ := json.Marshal(respJSON)
  2549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2550. utils.ErrorLog("解析失败:%v", err)
  2551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2552. return
  2553. }
  2554. res.ErrMsg = res10265.ErrMsg
  2555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2556. res.Infcode = infocode
  2557. res.Output = res10265.Output
  2558. res.InfRefmsgid = res10265.InfRefmsgid
  2559. if res.Infcode == 0 {
  2560. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2561. if err == gorm.ErrRecordNotFound {
  2562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2563. return
  2564. } else if err != nil {
  2565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2566. return
  2567. } else {
  2568. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2569. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2570. infoStr := string(Iinfos)
  2571. idetinfoStr := string(Idetinfos)
  2572. psn := &models.HisPsn{
  2573. PsnNo: res.Output.Baseinfo.PsnNo,
  2574. Age: res.Output.Baseinfo.Age,
  2575. PatientId: patient.ID,
  2576. Certno: res.Output.Baseinfo.Certno,
  2577. Brdy: res.Output.Baseinfo.Brdy,
  2578. Gend: res.Output.Baseinfo.Gend,
  2579. Naty: res.Output.Baseinfo.Naty,
  2580. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2581. PsnName: res.Output.Baseinfo.PsnName,
  2582. Idetinfo: idetinfoStr,
  2583. Insuinfo: infoStr,
  2584. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2585. CardInfo: card_info,
  2586. VerifyNumber: token,
  2587. }
  2588. var rf []*ResultFive
  2589. json.Unmarshal([]byte(infoStr), &rf)
  2590. var insutypes []*ResultFive
  2591. var insutype string
  2592. var is390 int = 0
  2593. var is310 int = 0
  2594. for _, item := range rf {
  2595. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2596. insutypes = append(insutypes, item)
  2597. }
  2598. }
  2599. if len(insutypes) == 1 {
  2600. insutype = insutypes[0].Insutype
  2601. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2602. } else {
  2603. for _, i := range insutypes {
  2604. if i.Insutype == "390" {
  2605. is390 = 1
  2606. }
  2607. if i.Insutype == "310" {
  2608. is310 = 1
  2609. }
  2610. }
  2611. }
  2612. if is390 == 1 {
  2613. insutype = "390"
  2614. }
  2615. if is310 == 1 {
  2616. insutype = "310"
  2617. }
  2618. if len(insutypes) == 0 {
  2619. insutype = "310"
  2620. }
  2621. service.CreateHisPsn(psn)
  2622. c.ServeSuccessJSON(map[string]interface{}{
  2623. "patient": patient,
  2624. "number": token,
  2625. "insutype": insutype,
  2626. })
  2627. }
  2628. } else {
  2629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2630. return
  2631. }
  2632. } else { //读卡失败
  2633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2634. return
  2635. }
  2636. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2637. if initFlag == 0 {
  2638. c.TestGetBasBaseInit()
  2639. }
  2640. token := c.GetEleBaseInfo()
  2641. token = Remove0000(token)
  2642. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2643. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2644. //
  2645. var res ResultTwo
  2646. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. if res.Infcode == 0 {
  2652. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2653. if err == gorm.ErrRecordNotFound {
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2655. return
  2656. } else if err != nil {
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2658. return
  2659. } else {
  2660. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2661. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2662. infoStr := string(Iinfos)
  2663. idetinfoStr := string(Idetinfos)
  2664. psn := &models.HisPsn{
  2665. PsnNo: res.Output.Baseinfo.PsnNo,
  2666. Age: res.Output.Baseinfo.Age,
  2667. PatientId: patient.ID,
  2668. Certno: res.Output.Baseinfo.Certno,
  2669. Brdy: res.Output.Baseinfo.Brdy,
  2670. Gend: res.Output.Baseinfo.Gend,
  2671. Naty: res.Output.Baseinfo.Naty,
  2672. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2673. PsnName: res.Output.Baseinfo.PsnName,
  2674. Idetinfo: idetinfoStr,
  2675. Insuinfo: infoStr,
  2676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2677. CardInfo: "",
  2678. VerifyNumber: token,
  2679. }
  2680. service.CreateHisPsn(psn)
  2681. c.ServeSuccessJSON(map[string]interface{}{
  2682. "patient": patient,
  2683. "number": token,
  2684. })
  2685. }
  2686. } else {
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2688. return
  2689. }
  2690. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2691. //if initFlag == 0 {
  2692. c.TestGetJiangXiBasBaseInit()
  2693. //}
  2694. //if initEleFlag == 0 {
  2695. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2696. //}
  2697. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2698. type ELeData struct {
  2699. Data struct {
  2700. IdNo string `json:"idNo"`
  2701. IdType string `json:"idType"`
  2702. UserName string `json:"userName"`
  2703. EcToken string `json:"ecToken"`
  2704. InsuOrg string `json:"insuOrg"`
  2705. Gender string `json:"gender"`
  2706. Birthday string `json:"birthday"`
  2707. Nationality string `json:"nationality"`
  2708. Email string `json:"email"`
  2709. Extra string `json:"extra"`
  2710. } `json:"data"`
  2711. Code int `json:"code"`
  2712. Message string `json:"message"`
  2713. }
  2714. var ele ELeData
  2715. err := json.Unmarshal([]byte(json_result), &ele)
  2716. if err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. }
  2719. token := ele.Data.EcToken
  2720. token = Remove0000(token)
  2721. 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)
  2722. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2723. var res ResultTwo
  2724. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2725. utils.ErrorLog("解析失败:%v", err)
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2727. return
  2728. }
  2729. if res.Infcode == 0 {
  2730. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2731. if err == gorm.ErrRecordNotFound {
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2733. return
  2734. } else if err != nil {
  2735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2736. return
  2737. } else {
  2738. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2739. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2740. infoStr := string(Iinfos)
  2741. idetinfoStr := string(Idetinfos)
  2742. psn := &models.HisPsn{
  2743. PsnNo: res.Output.Baseinfo.PsnNo,
  2744. Age: res.Output.Baseinfo.Age,
  2745. PatientId: patient.ID,
  2746. Certno: res.Output.Baseinfo.Certno,
  2747. Brdy: res.Output.Baseinfo.Brdy,
  2748. Gend: res.Output.Baseinfo.Gend,
  2749. Naty: res.Output.Baseinfo.Naty,
  2750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2751. PsnName: res.Output.Baseinfo.PsnName,
  2752. Idetinfo: idetinfoStr,
  2753. Insuinfo: infoStr,
  2754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2755. CardInfo: "",
  2756. VerifyNumber: token,
  2757. }
  2758. service.CreateHisPsn(psn)
  2759. var rf []*ResultFive
  2760. json.Unmarshal([]byte(infoStr), &rf)
  2761. var insutypes []*ResultFive
  2762. var insutype string
  2763. var is390 int = 0
  2764. var is310 int = 0
  2765. for _, item := range rf {
  2766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2767. insutypes = append(insutypes, item)
  2768. }
  2769. }
  2770. if len(insutypes) == 1 {
  2771. insutype = insutypes[0].Insutype
  2772. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2773. } else {
  2774. for _, i := range insutypes {
  2775. if i.Insutype == "390" {
  2776. is390 = 1
  2777. }
  2778. if i.Insutype == "310" {
  2779. is310 = 1
  2780. }
  2781. }
  2782. }
  2783. if is390 == 1 {
  2784. insutype = "390"
  2785. }
  2786. if is310 == 1 {
  2787. insutype = "310"
  2788. }
  2789. if len(insutypes) == 0 {
  2790. insutype = "310"
  2791. }
  2792. c.ServeSuccessJSON(map[string]interface{}{
  2793. "patient": patient,
  2794. "number": token,
  2795. "insutype": insutype,
  2796. })
  2797. }
  2798. } else {
  2799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2800. return
  2801. }
  2802. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2803. //if initFlag == 0 {
  2804. c.TestGetJiangXiBasBaseInit()
  2805. //}
  2806. //if initEleFlag == 0 {
  2807. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2808. //}
  2809. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2810. type ELeData struct {
  2811. Data struct {
  2812. IdNo string `json:"idNo"`
  2813. IdType string `json:"idType"`
  2814. UserName string `json:"userName"`
  2815. EcToken string `json:"ecToken"`
  2816. InsuOrg string `json:"insuOrg"`
  2817. Gender string `json:"gender"`
  2818. Birthday string `json:"birthday"`
  2819. Nationality string `json:"nationality"`
  2820. Email string `json:"email"`
  2821. Extra string `json:"extra"`
  2822. } `json:"data"`
  2823. Code int `json:"code"`
  2824. Message string `json:"message"`
  2825. }
  2826. var ele ELeData
  2827. err := json.Unmarshal([]byte(json_result), &ele)
  2828. if err != nil {
  2829. utils.ErrorLog("解析失败:%v", err)
  2830. }
  2831. token := ele.Data.EcToken
  2832. token = Remove0000(token)
  2833. 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)
  2834. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2835. var res ResultTwo
  2836. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2837. utils.ErrorLog("解析失败:%v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. return
  2840. }
  2841. if res.Infcode == 0 {
  2842. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2843. if err == gorm.ErrRecordNotFound {
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2845. return
  2846. } else if err != nil {
  2847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2848. return
  2849. } else {
  2850. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2851. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2852. infoStr := string(Iinfos)
  2853. idetinfoStr := string(Idetinfos)
  2854. psn := &models.HisPsn{
  2855. PsnNo: res.Output.Baseinfo.PsnNo,
  2856. Age: res.Output.Baseinfo.Age,
  2857. PatientId: patient.ID,
  2858. Certno: res.Output.Baseinfo.Certno,
  2859. Brdy: res.Output.Baseinfo.Brdy,
  2860. Gend: res.Output.Baseinfo.Gend,
  2861. Naty: res.Output.Baseinfo.Naty,
  2862. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2863. PsnName: res.Output.Baseinfo.PsnName,
  2864. Idetinfo: idetinfoStr,
  2865. Insuinfo: infoStr,
  2866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2867. CardInfo: "",
  2868. VerifyNumber: token,
  2869. }
  2870. service.CreateHisPsn(psn)
  2871. var rf []*ResultFive
  2872. json.Unmarshal([]byte(infoStr), &rf)
  2873. var insutypes []*ResultFive
  2874. var insutype string
  2875. var is390 int = 0
  2876. var is310 int = 0
  2877. for _, item := range rf {
  2878. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2879. insutypes = append(insutypes, item)
  2880. }
  2881. }
  2882. if len(insutypes) == 1 {
  2883. insutype = insutypes[0].Insutype
  2884. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2885. } else {
  2886. for _, i := range insutypes {
  2887. if i.Insutype == "390" {
  2888. is390 = 1
  2889. }
  2890. if i.Insutype == "310" {
  2891. is310 = 1
  2892. }
  2893. }
  2894. }
  2895. if is390 == 1 {
  2896. insutype = "390"
  2897. }
  2898. if is310 == 1 {
  2899. insutype = "310"
  2900. }
  2901. if len(insutypes) == 0 {
  2902. insutype = "310"
  2903. }
  2904. c.ServeSuccessJSON(map[string]interface{}{
  2905. "patient": patient,
  2906. "number": token,
  2907. "insutype": insutype,
  2908. })
  2909. }
  2910. } else {
  2911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2912. return
  2913. }
  2914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2915. type ELeData struct {
  2916. Code string `json:"code"`
  2917. Data struct {
  2918. Aac002 string `json:"aac002"`
  2919. Aaz500 string `json:"aaz500"`
  2920. ActCardNo string `json:"actCardNo"`
  2921. Bab520 string `json:"bab520"`
  2922. Bkz543 string `json:"bkz543"`
  2923. BusinessType string `json:"businessType"`
  2924. CertfCodg string `json:"certfCodg"`
  2925. EcIndexNo string `json:"ecIndexNo"`
  2926. EcToken string `json:"ecToken"`
  2927. ID0000 string `json:"id0000"`
  2928. IDNo string `json:"idNo"`
  2929. IDType string `json:"idType"`
  2930. Idcode string `json:"idcode"`
  2931. IdentityToken string `json:"identity_token"`
  2932. InsuOrg string `json:"insuOrg"`
  2933. OfficeID string `json:"officeId"`
  2934. OfficeName string `json:"officeName"`
  2935. OperatorID string `json:"operatorId"`
  2936. OperatorName string `json:"operatorName"`
  2937. OrgID string `json:"orgId"`
  2938. UserName string `json:"userName"`
  2939. } `json:"data"`
  2940. Infno interface{} `json:"infno"`
  2941. Message string `json:"message"`
  2942. OrgID string `json:"orgId"`
  2943. TransType string `json:"transType"`
  2944. }
  2945. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  2946. outPutInfo = Remove0000(outPutInfo)
  2947. if len(outPutInfo) > 0 {
  2948. var ele ELeData
  2949. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2950. if err != nil {
  2951. utils.ErrorLog("解析失败:%v", err)
  2952. }
  2953. token := ele.Data.EcToken
  2954. fmt.Println(inputInfo)
  2955. fmt.Println(outPutInfo)
  2956. 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)
  2957. saveLog(result, requestLog, "1101", "获取人员信息")
  2958. var dat map[string]interface{}
  2959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2960. fmt.Println(dat)
  2961. } else {
  2962. fmt.Println(err)
  2963. }
  2964. userJSONBytes, _ := json.Marshal(dat)
  2965. var res ResultTwo
  2966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2967. utils.ErrorLog("解析失败:%v", err)
  2968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2969. return
  2970. }
  2971. res.ErrMsg = errMsgLog
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. fmt.Println(res)
  2982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2984. infoStr := string(Iinfos)
  2985. idetinfoStr := string(Idetinfos)
  2986. psn := &models.HisPsn{
  2987. PsnNo: res.Output.Baseinfo.PsnNo,
  2988. Age: res.Output.Baseinfo.Age,
  2989. PatientId: patient.ID,
  2990. Certno: res.Output.Baseinfo.Certno,
  2991. Brdy: res.Output.Baseinfo.Brdy,
  2992. Gend: res.Output.Baseinfo.Gend,
  2993. Naty: res.Output.Baseinfo.Naty,
  2994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2995. PsnName: res.Output.Baseinfo.PsnName,
  2996. Idetinfo: idetinfoStr,
  2997. Insuinfo: infoStr,
  2998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2999. CardInfo: outPutInfo,
  3000. VerifyNumber: token,
  3001. }
  3002. service.CreateHisPsn(psn)
  3003. var rf []*ResultFive
  3004. json.Unmarshal([]byte(infoStr), &rf)
  3005. var insutypes []*ResultFive
  3006. var insutype string
  3007. var is390 int = 0
  3008. var is310 int = 0
  3009. for _, item := range rf {
  3010. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3011. insutypes = append(insutypes, item)
  3012. }
  3013. }
  3014. if len(insutypes) == 1 {
  3015. insutype = insutypes[0].Insutype
  3016. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3017. } else {
  3018. for _, i := range insutypes {
  3019. if i.Insutype == "390" {
  3020. is390 = 1
  3021. }
  3022. if i.Insutype == "310" {
  3023. is310 = 1
  3024. }
  3025. }
  3026. }
  3027. if is390 == 1 {
  3028. insutype = "390"
  3029. }
  3030. if is310 == 1 {
  3031. insutype = "310"
  3032. }
  3033. if len(insutypes) == 0 {
  3034. insutype = "310"
  3035. }
  3036. c.ServeSuccessJSON(map[string]interface{}{
  3037. "patient": patient,
  3038. "number": token,
  3039. "insutype": insutype,
  3040. })
  3041. }
  3042. } else {
  3043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3044. return
  3045. }
  3046. }
  3047. }
  3048. break
  3049. }
  3050. }
  3051. var initFlag int64 = 0
  3052. var initEleFlag int64 = 0
  3053. func (c *HisApiController) TestGetBasBaseInit() {
  3054. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3055. Iinit := DllDef.MustFindProc("Init")
  3056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3057. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3058. if ret != 0 {
  3059. fmt.Println("SSCard的报错原因:", err)
  3060. fmt.Println("SSCard的运算结果为:", ret)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3062. return
  3063. }
  3064. result := int(ret)
  3065. fmt.Println("SSCard的运算结果为1:", result)
  3066. initFlag = 1
  3067. return
  3068. }
  3069. func (c *HisApiController) HandleJiangXiReadCard() {
  3070. fmt.Println("~~~~~~")
  3071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3072. admin_user_id, _ := c.GetInt64("admin_user_id")
  3073. id_card_type, _ := c.GetInt64("id_card_type")
  3074. //certificates, _ := c.GetInt64("certificates")
  3075. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3076. if initFlag == 0 {
  3077. c.TestGetJiangXiBasBaseInit()
  3078. }
  3079. basStr := c.GetBasBaseInfo()
  3080. if len(basStr) == 0 {
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3082. return
  3083. }
  3084. fmt.Println(basStr)
  3085. bas := strings.Split(basStr, "|")
  3086. basNumber := bas[1]
  3087. fmt.Println(basNumber)
  3088. card_sn := bas[3]
  3089. fmt.Println(card_sn)
  3090. 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, "")
  3091. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3092. var dat map[string]interface{}
  3093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3094. fmt.Println(dat)
  3095. } else {
  3096. fmt.Println(err)
  3097. }
  3098. userJSONBytes, _ := json.Marshal(dat)
  3099. var res ResultTwo
  3100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3101. utils.ErrorLog("解析失败:%v", err)
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3103. return
  3104. }
  3105. if res.Infcode == 0 {
  3106. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3107. if err == gorm.ErrRecordNotFound {
  3108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3109. return
  3110. } else if err != nil {
  3111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3112. return
  3113. } else {
  3114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3116. infoStr := string(Iinfos)
  3117. idetinfoStr := string(Idetinfos)
  3118. psn := &models.HisPsn{
  3119. PsnNo: res.Output.Baseinfo.PsnNo,
  3120. Age: res.Output.Baseinfo.Age,
  3121. PatientId: patient.ID,
  3122. Certno: res.Output.Baseinfo.Certno,
  3123. Brdy: res.Output.Baseinfo.Brdy,
  3124. Gend: res.Output.Baseinfo.Gend,
  3125. Naty: res.Output.Baseinfo.Naty,
  3126. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3127. PsnName: res.Output.Baseinfo.PsnName,
  3128. Idetinfo: idetinfoStr,
  3129. Insuinfo: infoStr,
  3130. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3131. CardInfo: basStr,
  3132. VerifyNumber: "",
  3133. }
  3134. service.CreateHisPsn(psn)
  3135. c.ServeSuccessJSON(map[string]interface{}{
  3136. "patient": patient,
  3137. "number": basNumber,
  3138. })
  3139. }
  3140. } else {
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3142. return
  3143. }
  3144. }
  3145. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3146. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3147. Iinit := DllDef.MustFindProc("Init")
  3148. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3149. //http://10.77.211.236/CSB/hsa-fsi-1303
  3150. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3151. if ret != 0 {
  3152. fmt.Println("SSCard的报错原因:", err)
  3153. fmt.Println("SSCard的运算结果为:", ret)
  3154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3155. return
  3156. }
  3157. result := int(ret)
  3158. fmt.Println("SSCard的运算结果为1:", result)
  3159. initFlag = 1
  3160. return
  3161. }
  3162. func (c *HisApiController) GetSFZBaseInfo() string {
  3163. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3164. readCard := DllDef.MustFindProc("ReadSFZ")
  3165. if readCard == nil {
  3166. fmt.Println("readcard is nil")
  3167. readCard = DllDef.MustFindProc("ReadSFZ")
  3168. }
  3169. str := make([]byte, 256)
  3170. str1 := make([]byte, 256)
  3171. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3172. fmt.Println(r)
  3173. return string(str)
  3174. }
  3175. func (c *HisApiController) GetEleBaseInfo() string {
  3176. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3177. readCard := DllDef.MustFindProc("GetQRBase")
  3178. fmt.Println(readCard)
  3179. if readCard == nil {
  3180. fmt.Println("readcard is nil")
  3181. readCard = DllDef.MustFindProc("GetQRBase")
  3182. }
  3183. str := make([]byte, 1024)
  3184. str1 := make([]byte, 1024)
  3185. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3186. fmt.Println(ret2)
  3187. fmt.Println(string(str1))
  3188. fmt.Println(string(str))
  3189. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3190. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3191. if ret2 != 0 {
  3192. return ""
  3193. }
  3194. return string(str)
  3195. }
  3196. func GetJxEleBaseInfo(org_id int64) string {
  3197. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3198. readCard := DllDef.MustFindProc("NationEcTrans")
  3199. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3200. if readCard == nil {
  3201. fmt.Println("readcard is nil")
  3202. readCard = DllDef.MustFindProc("NationEcTrans")
  3203. }
  3204. str1 := make([]byte, 1024)
  3205. data := make(map[string]interface{})
  3206. inputData := make(map[string]interface{})
  3207. inputData["orgId"] = miConfig.Code
  3208. inputData["businessType"] = "01101"
  3209. inputData["operatorId"] = "test001"
  3210. inputData["operatorName"] = "cn"
  3211. inputData["officeId"] = "32760"
  3212. inputData["officeName"] = "waike"
  3213. inputData["deviceType"] = ""
  3214. data["data"] = inputData
  3215. data["transType"] = "ec.query"
  3216. data["extra "] = ""
  3217. data["orgId"] = miConfig.Code
  3218. bytesData, _ := json.Marshal(data)
  3219. //bytesData, _ := json.Marshal(data)
  3220. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3221. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3222. fmt.Println(ret2)
  3223. fmt.Println(string(str1))
  3224. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3225. if ret2 != 0 {
  3226. return ""
  3227. }
  3228. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3229. }
  3230. func GetJxEleBaseInitInfo(org_id int64) string {
  3231. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3232. readCard := DllDef.MustFindProc("NationEcTrans")
  3233. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3234. if readCard == nil {
  3235. fmt.Println("readcard is nil")
  3236. readCard = DllDef.MustFindProc("NationEcTrans")
  3237. }
  3238. str1 := make([]byte, 2048)
  3239. data := make(map[string]interface{})
  3240. inputData := make(map[string]interface{})
  3241. inputData["orgId"] = miConfig.Code
  3242. inputData["businessType"] = "01101"
  3243. inputData["operatorId"] = "1"
  3244. inputData["operatorName"] = "huangchuang"
  3245. inputData["officeId"] = "101"
  3246. inputData["officeName"] = "xuetou"
  3247. inputData["deviceType"] = ""
  3248. data["data"] = inputData
  3249. data["transType"] = "ec.query"
  3250. data["orgId"] = miConfig.Code
  3251. bytesData, _ := json.Marshal(data)
  3252. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3253. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3254. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3255. fmt.Println(ret2)
  3256. fmt.Println(string(str1))
  3257. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3258. if ret2 != 0 {
  3259. return ""
  3260. }
  3261. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3262. initEleFlag = 1
  3263. }
  3264. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3265. }
  3266. func (c *HisApiController) GetBasBaseInfo() string {
  3267. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3268. readCard := DllDef.MustFindProc("ReadCardBas")
  3269. if readCard == nil {
  3270. fmt.Println("readcard is nil")
  3271. readCard = DllDef.MustFindProc("ReadCardBas")
  3272. }
  3273. str := make([]byte, 1024)
  3274. str1 := make([]byte, 1024)
  3275. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3276. fmt.Println(string(str1))
  3277. fmt.Println(string(str))
  3278. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3279. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3280. if ret2 != 0 {
  3281. return ""
  3282. }
  3283. return string(str)
  3284. }
  3285. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3286. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3287. readCard := DllDef.MustFindProc("read_cardinfo")
  3288. if readCard == nil {
  3289. fmt.Println("readcard is nil")
  3290. readCard = DllDef.MustFindProc("read_cardinfo")
  3291. }
  3292. str := make([]byte, 1024) //卡号
  3293. str1 := make([]byte, 1024) //卡识别码
  3294. str2 := make([]byte, 1024) //身份证号
  3295. str3 := make([]byte, 1024) //姓名
  3296. str4 := make([]byte, 1024) //错误信息
  3297. 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])))
  3298. fmt.Println(string(str1))
  3299. fmt.Println(string(str))
  3300. fmt.Println(string(str2))
  3301. fmt.Println(string(str3))
  3302. fmt.Println(string(str4))
  3303. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3304. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3305. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3306. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3307. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3308. if ret2 != 0 {
  3309. return "", "", "", "", ""
  3310. }
  3311. return string(str), string(str1), string(str2), string(str3), string(str4)
  3312. }
  3313. type CustomFundPay struct {
  3314. FundPayType string `json:"fund_pay_type"`
  3315. FundPayamt float64 `json:"fund_payamt"`
  3316. }
  3317. func (c *HisApiController) GetSettleList() {
  3318. order_id, _ := c.GetInt64("order_id")
  3319. admin_user_id, _ := c.GetInt64("admin_user_id")
  3320. order, _ := service.GetHisOrderByIDTwo(order_id)
  3321. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3322. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3323. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3324. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3325. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3327. if order.ID == 0 {
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3329. return
  3330. }
  3331. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3332. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3333. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3334. fmt.Println(count)
  3335. var zero string
  3336. number := count + 1
  3337. if number >= 1000 {
  3338. zero = "0000" + strconv.FormatInt(number, 10)
  3339. } else if number >= 10000 {
  3340. zero = "000" + strconv.FormatInt(number, 10)
  3341. } else if number >= 100000 {
  3342. zero = "00" + strconv.FormatInt(number, 10)
  3343. } else if number >= 1000000 {
  3344. zero = "0" + strconv.FormatInt(number, 10)
  3345. } else {
  3346. zero = strconv.FormatInt(number, 10)
  3347. }
  3348. fmt.Println(zero)
  3349. struct4101 := service.Struct4101{
  3350. PsnNo: order.PsnNo,
  3351. MdtrtId: order.MdtrtId,
  3352. SetlId: order.SetlId,
  3353. PsnName: order.PsnName,
  3354. Gend: order.Gend,
  3355. Brdy: his.Brdy,
  3356. Age: his.Age,
  3357. Naty: order.Naty,
  3358. PatnCertType: "01",
  3359. Certno: order.Certno,
  3360. Prfs: "90",
  3361. ConerName: roles[0].UserName,
  3362. PatnRlts: "99",
  3363. ConerAddr: miConfig.OrgName,
  3364. ConerTel: admin.Mobile,
  3365. HiType: order.Insutype,
  3366. Insuplc: miConfig.InsuplcAdmdvs,
  3367. MaindiagFlag: "1",
  3368. BillCode: order.SetlId,
  3369. BillNo: order.SetlId,
  3370. BizSn: order.Number,
  3371. PsnSelfPay: order.PsnPartAmt,
  3372. PsnOwnPay: order.PsnPartAmt,
  3373. AcctPay: order.AcctPay,
  3374. PsnCashpay: order.PsnCashPay,
  3375. HiPaymtd: "1",
  3376. Hsorg: miConfig.InsuplcAdmdvs,
  3377. HsorgOpter: miConfig.InsuplcAdmdvs,
  3378. MedinsFillPsn: curRoles.UserName,
  3379. MedinsFillDept: depart.Name,
  3380. IptMedType: "2",
  3381. }
  3382. struct4101.SetlBegnDate = order.SetlTime
  3383. struct4101.SetlEndDate = order.SetlTime
  3384. time_arr := strings.Split(order.SetlTime, " ")
  3385. struct4101.AdmTime = time_arr[0]
  3386. struct4101.AdmEndTime = time_arr[0]
  3387. var rf []CustomFundPay
  3388. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3389. var tempFunPays []service.CustomStruct
  3390. for _, item := range rf {
  3391. var tempFunPay service.CustomStruct
  3392. tempFunPay.FundPayamt = item.FundPayamt
  3393. tempFunPay.FundPayType = item.FundPayType
  3394. tempFunPays = append(tempFunPays, tempFunPay)
  3395. }
  3396. struct4101.CustomStruct = tempFunPays
  3397. var tempDiaginfos []service.DiaginfoStructTwo
  3398. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3399. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3400. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3401. var config []*models.HisXtDiagnoseConfig
  3402. for _, item := range diagnosis_ids {
  3403. id, _ := strconv.ParseInt(item, 10, 64)
  3404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3405. config = append(config, &diagnosisConfig)
  3406. }
  3407. for index, item := range config {
  3408. if index == 0 {
  3409. var tempDiaginfo service.DiaginfoStructTwo
  3410. tempDiaginfo.DiagCode = item.CountryCode
  3411. tempDiaginfo.DiagName = item.CountryContentName
  3412. tempDiaginfo.DiagType = "1"
  3413. tempDiaginfo.MaindiagFlag = "1"
  3414. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3415. } else {
  3416. var tempDiaginfo service.DiaginfoStructTwo
  3417. tempDiaginfo.DiagCode = item.CountryCode
  3418. tempDiaginfo.DiagName = item.CountryContentName
  3419. tempDiaginfo.DiagType = "2"
  3420. tempDiaginfo.MaindiagFlag = "0"
  3421. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3422. }
  3423. }
  3424. struct4101.Diseinfo = tempDiaginfos
  3425. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3426. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3427. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3428. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3429. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3430. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3431. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3432. var iteminfo service.IteminfoStruct
  3433. var bedCostTotal float64 = 0 //床位总费
  3434. var bedCostSelfTotal float64 = 0 //床位自费
  3435. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3436. var operationCostTotal float64 = 0 //手术费
  3437. var operationCostSelfTotal float64 = 0 //手术费
  3438. var operationCostPartSelfTotal float64 = 0 //手术费
  3439. var otherCostTotal float64 = 0 //其他费用
  3440. var otherCostSelfTotal float64 = 0 //其他费用
  3441. var otherCostPartSelfTotal float64 = 0 //其他费用
  3442. var materialCostTotal float64 = 0 //材料费
  3443. var materialCostSelfTotal float64 = 0 //材料费
  3444. var materialCostPartSelfTotal float64 = 0 //材料费
  3445. var westernMedicineCostTotal float64 = 0 //西药费
  3446. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3447. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3448. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3449. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3450. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3451. var checkCostTotal float64 = 0 //检查费
  3452. var checkCostSelfTotal float64 = 0 //检查费
  3453. var checkCostPartSelfTotal float64 = 0 //检查费
  3454. var laboratoryCostTotal float64 = 0 //化验费
  3455. var laboratoryCostSelfTotal float64 = 0 //化验费
  3456. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3457. var treatCostTotal float64 = 0 //治疗费用
  3458. var treatCostSelfTotal float64 = 0 //治疗费用
  3459. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3460. decimal.DivisionPrecision = 2
  3461. var bed_fulamt_ownpay_amt float64 = 0
  3462. var operation_fulamt_ownpay_amt float64 = 0
  3463. var other_fulamt_ownpay_amt float64 = 0
  3464. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3465. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3466. var check_fulamt_ownpay_amt float64 = 0
  3467. var material_fulamt_ownpay_amt float64 = 0
  3468. var laboratory_fulamt_ownpay_amt float64 = 0
  3469. var treat_fulamt_ownpay_amt float64 = 0
  3470. var bed_claa_sunmfee float64 = 0
  3471. var bed_clab_amt float64 = 0
  3472. var bed_other_amt float64 = 0
  3473. var operation_claa_sunmfee float64 = 0
  3474. var operation_clab_amt float64 = 0
  3475. var operation_other_amt float64 = 0
  3476. var other_claa_sunmfee float64 = 0
  3477. var other_clab_amt float64 = 0
  3478. var other_other_amt float64 = 0
  3479. var westernMedicine_claa_sunmfee float64 = 0
  3480. var westernMedicine_clab_amt float64 = 0
  3481. var westernMedicine_other_amt float64 = 0
  3482. var chineseTraditional_claa_sunmfee float64 = 0
  3483. var chineseTraditional_clab_amt float64 = 0
  3484. var chineseTraditional_other_amt float64 = 0
  3485. var check_claa_sunmfee float64 = 0
  3486. var check_clab_amt float64 = 0
  3487. var check_other_amt float64 = 0
  3488. var material_claa_sunmfee float64 = 0
  3489. var material_clab_amt float64 = 0
  3490. var material_other_amt float64 = 0
  3491. var laboratory_claa_sunmfee float64 = 0
  3492. var laboratory_clab_amt float64 = 0
  3493. var laboratory_other_amt float64 = 0
  3494. var treat_claa_sunmfee float64 = 0
  3495. var treat_clab_amt float64 = 0
  3496. var treat_other_amt float64 = 0
  3497. for _, item := range order.HisOrderInfo {
  3498. if item.MedChrgitmType == "01" { //床位费
  3499. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3500. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3501. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3502. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3503. if item.ChrgitmLv == "1" {
  3504. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3505. }
  3506. if item.ChrgitmLv == "2" {
  3507. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3508. }
  3509. if item.ChrgitmLv == "3" {
  3510. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3511. }
  3512. }
  3513. if item.MedChrgitmType == "03" { //检查费
  3514. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3515. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3516. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3517. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3518. if item.ChrgitmLv == "1" {
  3519. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3520. }
  3521. if item.ChrgitmLv == "2" {
  3522. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3523. }
  3524. if item.ChrgitmLv == "3" {
  3525. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3526. }
  3527. }
  3528. if item.MedChrgitmType == "04" { //化验费
  3529. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3530. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3531. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3532. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3533. if item.ChrgitmLv == "1" {
  3534. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3535. }
  3536. if item.ChrgitmLv == "2" {
  3537. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3538. }
  3539. if item.ChrgitmLv == "3" {
  3540. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3541. }
  3542. }
  3543. if item.MedChrgitmType == "05" { //治疗费
  3544. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3545. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3546. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3547. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3548. if item.ChrgitmLv == "1" {
  3549. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3550. }
  3551. if item.ChrgitmLv == "2" {
  3552. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3553. }
  3554. if item.ChrgitmLv == "3" {
  3555. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3556. }
  3557. }
  3558. if item.MedChrgitmType == "06" { //手术费
  3559. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3560. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3561. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3562. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3563. if item.ChrgitmLv == "1" {
  3564. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3565. }
  3566. if item.ChrgitmLv == "2" {
  3567. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3568. }
  3569. if item.ChrgitmLv == "3" {
  3570. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3571. }
  3572. }
  3573. if item.MedChrgitmType == "08" { //材料费
  3574. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3575. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3576. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3577. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3578. if item.ChrgitmLv == "1" {
  3579. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3580. }
  3581. if item.ChrgitmLv == "2" {
  3582. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3583. }
  3584. if item.ChrgitmLv == "3" {
  3585. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3586. }
  3587. }
  3588. if item.MedChrgitmType == "09" { //西药费
  3589. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3590. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3591. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3592. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3593. if item.ChrgitmLv == "1" {
  3594. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3595. }
  3596. if item.ChrgitmLv == "2" {
  3597. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3598. }
  3599. if item.ChrgitmLv == "3" {
  3600. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3601. }
  3602. }
  3603. if item.MedChrgitmType == "11" { //中成费
  3604. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3605. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3606. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3607. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3608. if item.ChrgitmLv == "1" {
  3609. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3610. }
  3611. if item.ChrgitmLv == "2" {
  3612. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3613. }
  3614. if item.ChrgitmLv == "3" {
  3615. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3616. }
  3617. }
  3618. if item.MedChrgitmType == "14" { //其他费
  3619. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3620. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3621. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3622. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3623. if item.ChrgitmLv == "1" {
  3624. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3625. }
  3626. if item.ChrgitmLv == "2" {
  3627. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3628. }
  3629. if item.ChrgitmLv == "3" {
  3630. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3631. }
  3632. }
  3633. }
  3634. var iteminfoStructs []service.IteminfoStruct
  3635. if bedCostTotal != 0 {
  3636. iteminfo.MedChrgitm = "01"
  3637. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3638. iteminfo.Amt = bedCostTotal
  3639. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3640. iteminfo.ClabAmt = bed_clab_amt
  3641. iteminfo.OthAmt = bed_other_amt
  3642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3643. }
  3644. if checkCostTotal != 0 {
  3645. iteminfo.MedChrgitm = "03"
  3646. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3647. iteminfo.Amt = checkCostTotal
  3648. iteminfo.ClaaSumfee = check_claa_sunmfee
  3649. iteminfo.ClabAmt = check_clab_amt
  3650. iteminfo.OthAmt = check_other_amt
  3651. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3652. }
  3653. if laboratoryCostTotal != 0 {
  3654. iteminfo.MedChrgitm = "04"
  3655. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3656. iteminfo.Amt = laboratoryCostTotal
  3657. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3658. iteminfo.ClabAmt = laboratory_clab_amt
  3659. iteminfo.OthAmt = laboratory_other_amt
  3660. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3661. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3662. }
  3663. if treatCostTotal != 0 {
  3664. iteminfo.MedChrgitm = "05"
  3665. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3666. iteminfo.Amt = treatCostTotal
  3667. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3668. iteminfo.ClabAmt = treat_clab_amt
  3669. iteminfo.OthAmt = treat_other_amt
  3670. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3671. //(struct4101.IteminfoStruct, iteminfo)
  3672. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3673. }
  3674. if operationCostTotal != 0 {
  3675. iteminfo.MedChrgitm = "06"
  3676. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3677. iteminfo.Amt = operationCostTotal
  3678. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3679. iteminfo.ClabAmt = operation_clab_amt
  3680. iteminfo.OthAmt = operation_other_amt
  3681. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3682. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3683. }
  3684. if materialCostTotal != 0 {
  3685. iteminfo.MedChrgitm = "08"
  3686. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3687. iteminfo.Amt = materialCostTotal
  3688. iteminfo.ClaaSumfee = material_claa_sunmfee
  3689. iteminfo.ClabAmt = material_clab_amt
  3690. iteminfo.OthAmt = material_other_amt
  3691. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3692. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3693. }
  3694. if westernMedicineCostTotal != 0 {
  3695. iteminfo.MedChrgitm = "09"
  3696. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3697. iteminfo.Amt = westernMedicineCostTotal
  3698. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3699. iteminfo.ClabAmt = westernMedicine_clab_amt
  3700. iteminfo.OthAmt = westernMedicine_other_amt
  3701. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3702. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3703. }
  3704. if chineseTraditionalMedicineCostTotal != 0 {
  3705. iteminfo.MedChrgitm = "11"
  3706. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3707. iteminfo.Amt = westernMedicineCostTotal
  3708. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3709. iteminfo.ClabAmt = westernMedicine_clab_amt
  3710. iteminfo.OthAmt = westernMedicine_other_amt
  3711. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3712. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3713. }
  3714. if otherCostTotal != 0 {
  3715. iteminfo.MedChrgitm = "14"
  3716. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3717. iteminfo.Amt = otherCostTotal
  3718. iteminfo.ClaaSumfee = other_claa_sunmfee
  3719. iteminfo.ClabAmt = other_clab_amt
  3720. iteminfo.OthAmt = other_other_amt
  3721. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3722. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3723. }
  3724. struct4101.IteminfoStruct = iteminfoStructs
  3725. struct4101.Ntly = "中国"
  3726. struct4101.AdmCaty = "A03.06"
  3727. var res ResultSeventeen
  3728. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3729. struct4101.BillCode = order.Number
  3730. struct4101.BillNo = order.SetlId
  3731. var resOther ResultSeventeenOther
  3732. var pp models.PublicParams
  3733. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3734. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3735. pp.FixmedinsName = miConfig.OrgName
  3736. pp.FixmedinsCode = miConfig.Code
  3737. pp.RequestUrl = miConfig.Url
  3738. pp.Cainfo = miConfig.Cainfo
  3739. pp.SecretKey = miConfig.SecretKey
  3740. pp.AccessKey = miConfig.AccessKey
  3741. pp.OpterName = curRoles.UserName
  3742. client := &http.Client{}
  3743. var req *http.Request
  3744. data := make(map[string]interface{})
  3745. data["struct4101"] = struct4101
  3746. data["pp"] = pp
  3747. bytesData, _ := json.Marshal(data)
  3748. if miConfig.MdtrtareaAdmvs == "320921" {
  3749. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3750. } else {
  3751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3752. }
  3753. resp, _ := client.Do(req)
  3754. defer resp.Body.Close()
  3755. body, ioErr := ioutil.ReadAll(resp.Body)
  3756. if ioErr != nil {
  3757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3759. return
  3760. }
  3761. var respJSON map[string]interface{}
  3762. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3765. return
  3766. }
  3767. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3768. userJSONBytes, _ := json.Marshal(respJSON)
  3769. fmt.Println("log")
  3770. fmt.Println(string(userJSONBytes))
  3771. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3772. utils.ErrorLog("解析失败:%v", err)
  3773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3774. return
  3775. }
  3776. res.InfRefmsgid = resOther.InfRefmsgid
  3777. res.Output = resOther.Output
  3778. res.ErrMsg = resOther.ErrMsg
  3779. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3780. res.Infcode = infocode
  3781. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3782. var pp models.PublicParams
  3783. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3784. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3785. pp.FixmedinsName = miConfig.OrgName
  3786. pp.FixmedinsCode = miConfig.Code
  3787. pp.RequestUrl = miConfig.Url
  3788. pp.Cainfo = miConfig.Cainfo
  3789. pp.SecretKey = miConfig.SecretKey
  3790. pp.AccessKey = miConfig.AccessKey
  3791. pp.OpterName = curRoles.UserName
  3792. result, _ := service.Jxyb4101(struct4101, pp)
  3793. var dat map[string]interface{}
  3794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3795. fmt.Println(dat)
  3796. } else {
  3797. fmt.Println(err)
  3798. }
  3799. userJSONBytes, _ := json.Marshal(dat)
  3800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3806. var pp models.PublicParams
  3807. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3808. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3809. pp.FixmedinsName = miConfig.OrgName
  3810. pp.FixmedinsCode = miConfig.Code
  3811. pp.RequestUrl = miConfig.Url
  3812. pp.Cainfo = miConfig.Cainfo
  3813. pp.SecretKey = miConfig.SecretKey
  3814. pp.AccessKey = miConfig.AccessKey
  3815. pp.OpterName = curRoles.UserName
  3816. result, _ := service.Hnyb4101(struct4101, pp)
  3817. var dat map[string]interface{}
  3818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3819. fmt.Println(dat)
  3820. } else {
  3821. fmt.Println(err)
  3822. }
  3823. userJSONBytes, _ := json.Marshal(dat)
  3824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3825. utils.ErrorLog("解析失败:%v", err)
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. } else {
  3830. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3831. var dat map[string]interface{}
  3832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3833. fmt.Println(dat)
  3834. } else {
  3835. fmt.Println(err)
  3836. }
  3837. userJSONBytes, _ := json.Marshal(dat)
  3838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3839. utils.ErrorLog("解析失败:%v", err)
  3840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3841. return
  3842. }
  3843. }
  3844. if res.Infcode != 0 {
  3845. c.ServeSuccessJSON(map[string]interface{}{
  3846. "failed_code": -10,
  3847. "msg": res.ErrMsg,
  3848. })
  3849. return
  3850. } else {
  3851. order.FaPiaoNumber = zero
  3852. order.FaPiaoCode = last_order.FaPiaoCode
  3853. service.UpdateOrder(order)
  3854. hisFundSettleListResult := &models.HisFundSettleListResult{
  3855. Number: res.Output.SetlListId,
  3856. Status: 1,
  3857. Ctime: time.Now().Unix(),
  3858. Mtime: time.Now().Unix(),
  3859. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3860. IsUpload: 1,
  3861. OrderId: order_id,
  3862. }
  3863. service.CreateUploadRecord(hisFundSettleListResult)
  3864. c.ServeSuccessJSON(map[string]interface{}{
  3865. "msg": "上传成功",
  3866. "result": hisFundSettleListResult,
  3867. })
  3868. return
  3869. }
  3870. }
  3871. func (c *HisApiController) GetSettleListHospital() {
  3872. order_id, _ := c.GetInt64("order_id")
  3873. admin_user_id, _ := c.GetInt64("admin_user_id")
  3874. order, _ := service.GetHisOrderByIDTwo(order_id)
  3875. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3876. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3877. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3878. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3879. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3880. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3881. if order.ID == 0 {
  3882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3883. return
  3884. }
  3885. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3886. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3887. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3888. fmt.Println(count)
  3889. var zero string
  3890. number := count + 1
  3891. if number >= 1000 {
  3892. zero = "0000" + strconv.FormatInt(number, 10)
  3893. } else if number >= 10000 {
  3894. zero = "000" + strconv.FormatInt(number, 10)
  3895. } else if number >= 100000 {
  3896. zero = "00" + strconv.FormatInt(number, 10)
  3897. } else if number >= 1000000 {
  3898. zero = "0" + strconv.FormatInt(number, 10)
  3899. } else {
  3900. zero = strconv.FormatInt(number, 10)
  3901. }
  3902. fmt.Println(zero)
  3903. struct4101 := service.Struct4101{
  3904. PsnNo: order.PsnNo,
  3905. MdtrtId: order.MdtrtId,
  3906. SetlId: order.SetlId,
  3907. PsnName: order.PsnName,
  3908. Gend: order.Gend,
  3909. Brdy: his.Brdy,
  3910. Age: int64(order.Age),
  3911. Naty: order.Naty,
  3912. PatnCertType: "01",
  3913. Certno: order.Certno,
  3914. Prfs: "90",
  3915. ConerName: roles[0].UserName,
  3916. PatnRlts: "99",
  3917. ConerAddr: miConfig.OrgName,
  3918. ConerTel: admin.Mobile,
  3919. HiType: order.Insutype,
  3920. Insuplc: miConfig.InsuplcAdmdvs,
  3921. MaindiagFlag: "1",
  3922. BillCode: order.SetlId,
  3923. BillNo: order.SetlId,
  3924. BizSn: order.Number,
  3925. PsnSelfPay: order.PsnPartAmt,
  3926. PsnOwnPay: order.PsnPartAmt,
  3927. AcctPay: order.AcctPay,
  3928. PsnCashpay: order.PsnCashPay,
  3929. HiPaymtd: "1",
  3930. Hsorg: miConfig.InsuplcAdmdvs,
  3931. HsorgOpter: miConfig.InsuplcAdmdvs,
  3932. MedinsFillPsn: curRoles.UserName,
  3933. MedinsFillDept: depart.Name,
  3934. IptMedType: "2",
  3935. AdmTime: his.InHosptialTime,
  3936. AdmEndTime: his.OutHosptialTime,
  3937. }
  3938. struct4101.SetlBegnDate = order.SetlTime
  3939. struct4101.SetlEndDate = order.SetlTime
  3940. var rf []CustomFundPay
  3941. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3942. var tempFunPays []service.CustomStruct
  3943. for _, item := range rf {
  3944. var tempFunPay service.CustomStruct
  3945. tempFunPay.FundPayamt = item.FundPayamt
  3946. tempFunPay.FundPayType = item.FundPayType
  3947. tempFunPays = append(tempFunPays, tempFunPay)
  3948. }
  3949. struct4101.CustomStruct = tempFunPays
  3950. var tempDiaginfos []service.DiaginfoStructTwo
  3951. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3952. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3953. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3954. var config []*models.HisXtDiagnoseConfig
  3955. for _, item := range diagnosis_ids {
  3956. id, _ := strconv.ParseInt(item, 10, 64)
  3957. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3958. config = append(config, &diagnosisConfig)
  3959. }
  3960. for index, item := range config {
  3961. if index == 0 {
  3962. var tempDiaginfo service.DiaginfoStructTwo
  3963. tempDiaginfo.DiagCode = item.CountryCode
  3964. tempDiaginfo.DiagName = item.CountryContentName
  3965. tempDiaginfo.DiagType = "1"
  3966. tempDiaginfo.MaindiagFlag = "1"
  3967. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3968. } else {
  3969. var tempDiaginfo service.DiaginfoStructTwo
  3970. tempDiaginfo.DiagCode = item.CountryCode
  3971. tempDiaginfo.DiagName = item.CountryContentName
  3972. tempDiaginfo.DiagType = "2"
  3973. tempDiaginfo.MaindiagFlag = "0"
  3974. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3975. }
  3976. }
  3977. struct4101.Diseinfo = tempDiaginfos
  3978. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3979. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3980. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3981. tempOpspdiseinfo2.OprnOprtCode = ""
  3982. tempOpspdiseinfo2.OprnOprtName = ""
  3983. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3984. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3985. var iteminfo service.IteminfoStruct
  3986. var bedCostTotal float64 = 0 //床位总费
  3987. var bedCostSelfTotal float64 = 0 //床位自费
  3988. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3989. var operationCostTotal float64 = 0 //手术费
  3990. var operationCostSelfTotal float64 = 0 //手术费
  3991. var operationCostPartSelfTotal float64 = 0 //手术费
  3992. var otherCostTotal float64 = 0 //其他费用
  3993. var otherCostSelfTotal float64 = 0 //其他费用
  3994. var otherCostPartSelfTotal float64 = 0 //其他费用
  3995. var materialCostTotal float64 = 0 //材料费
  3996. var materialCostSelfTotal float64 = 0 //材料费
  3997. var materialCostPartSelfTotal float64 = 0 //材料费
  3998. var westernMedicineCostTotal float64 = 0 //西药费
  3999. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4000. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4001. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4002. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4003. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4004. var checkCostTotal float64 = 0 //检查费
  4005. var checkCostSelfTotal float64 = 0 //检查费
  4006. var checkCostPartSelfTotal float64 = 0 //检查费
  4007. var laboratoryCostTotal float64 = 0 //化验费
  4008. var laboratoryCostSelfTotal float64 = 0 //化验费
  4009. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4010. var treatCostTotal float64 = 0 //治疗费用
  4011. var treatCostSelfTotal float64 = 0 //治疗费用
  4012. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4013. decimal.DivisionPrecision = 2
  4014. var bed_fulamt_ownpay_amt float64 = 0
  4015. var operation_fulamt_ownpay_amt float64 = 0
  4016. var other_fulamt_ownpay_amt float64 = 0
  4017. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4018. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4019. var check_fulamt_ownpay_amt float64 = 0
  4020. var material_fulamt_ownpay_amt float64 = 0
  4021. var laboratory_fulamt_ownpay_amt float64 = 0
  4022. var treat_fulamt_ownpay_amt float64 = 0
  4023. var bed_claa_sunmfee float64 = 0
  4024. var bed_clab_amt float64 = 0
  4025. var bed_other_amt float64 = 0
  4026. var operation_claa_sunmfee float64 = 0
  4027. var operation_clab_amt float64 = 0
  4028. var operation_other_amt float64 = 0
  4029. var other_claa_sunmfee float64 = 0
  4030. var other_clab_amt float64 = 0
  4031. var other_other_amt float64 = 0
  4032. var westernMedicine_claa_sunmfee float64 = 0
  4033. var westernMedicine_clab_amt float64 = 0
  4034. var westernMedicine_other_amt float64 = 0
  4035. var chineseTraditional_claa_sunmfee float64 = 0
  4036. var chineseTraditional_clab_amt float64 = 0
  4037. var chineseTraditional_other_amt float64 = 0
  4038. var check_claa_sunmfee float64 = 0
  4039. var check_clab_amt float64 = 0
  4040. var check_other_amt float64 = 0
  4041. var material_claa_sunmfee float64 = 0
  4042. var material_clab_amt float64 = 0
  4043. var material_other_amt float64 = 0
  4044. var laboratory_claa_sunmfee float64 = 0
  4045. var laboratory_clab_amt float64 = 0
  4046. var laboratory_other_amt float64 = 0
  4047. var treat_claa_sunmfee float64 = 0
  4048. var treat_clab_amt float64 = 0
  4049. var treat_other_amt float64 = 0
  4050. for _, item := range order.HisOrderInfo {
  4051. if item.MedChrgitmType == "01" { //床位费
  4052. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4053. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4054. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4055. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4056. if item.ChrgitmLv == "1" {
  4057. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4058. }
  4059. if item.ChrgitmLv == "2" {
  4060. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4061. }
  4062. if item.ChrgitmLv == "3" {
  4063. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4064. }
  4065. }
  4066. if item.MedChrgitmType == "03" { //检查费
  4067. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4068. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4069. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4070. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4071. if item.ChrgitmLv == "1" {
  4072. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4073. }
  4074. if item.ChrgitmLv == "2" {
  4075. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4076. }
  4077. if item.ChrgitmLv == "3" {
  4078. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4079. }
  4080. }
  4081. if item.MedChrgitmType == "04" { //化验费
  4082. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4083. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4084. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4085. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4086. if item.ChrgitmLv == "1" {
  4087. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4088. }
  4089. if item.ChrgitmLv == "2" {
  4090. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4091. }
  4092. if item.ChrgitmLv == "3" {
  4093. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4094. }
  4095. }
  4096. if item.MedChrgitmType == "05" { //治疗费
  4097. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4098. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4099. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4100. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4101. if item.ChrgitmLv == "1" {
  4102. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4103. }
  4104. if item.ChrgitmLv == "2" {
  4105. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4106. }
  4107. if item.ChrgitmLv == "3" {
  4108. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4109. }
  4110. }
  4111. if item.MedChrgitmType == "06" { //手术费
  4112. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4113. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4114. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4115. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4116. if item.ChrgitmLv == "1" {
  4117. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4118. }
  4119. if item.ChrgitmLv == "2" {
  4120. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4121. }
  4122. if item.ChrgitmLv == "3" {
  4123. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4124. }
  4125. }
  4126. if item.MedChrgitmType == "08" { //材料费
  4127. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4128. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4129. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4130. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4131. if item.ChrgitmLv == "1" {
  4132. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4133. }
  4134. if item.ChrgitmLv == "2" {
  4135. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4136. }
  4137. if item.ChrgitmLv == "3" {
  4138. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4139. }
  4140. }
  4141. if item.MedChrgitmType == "09" { //西药费
  4142. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4143. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4144. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4145. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4146. if item.ChrgitmLv == "1" {
  4147. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4148. }
  4149. if item.ChrgitmLv == "2" {
  4150. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4151. }
  4152. if item.ChrgitmLv == "3" {
  4153. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4154. }
  4155. }
  4156. if item.MedChrgitmType == "11" { //中成费
  4157. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4158. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4159. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4160. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4161. if item.ChrgitmLv == "1" {
  4162. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4163. }
  4164. if item.ChrgitmLv == "2" {
  4165. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4166. }
  4167. if item.ChrgitmLv == "3" {
  4168. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4169. }
  4170. }
  4171. if item.MedChrgitmType == "14" { //其他费
  4172. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4173. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4174. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4175. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4176. if item.ChrgitmLv == "1" {
  4177. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4178. }
  4179. if item.ChrgitmLv == "2" {
  4180. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4181. }
  4182. if item.ChrgitmLv == "3" {
  4183. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4184. }
  4185. }
  4186. }
  4187. var iteminfoStructs []service.IteminfoStruct
  4188. if bedCostTotal != 0 {
  4189. iteminfo.MedChrgitm = "01"
  4190. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4191. iteminfo.Amt = bedCostTotal
  4192. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4193. iteminfo.ClabAmt = bed_clab_amt
  4194. iteminfo.OthAmt = bed_other_amt
  4195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4196. }
  4197. if checkCostTotal != 0 {
  4198. iteminfo.MedChrgitm = "03"
  4199. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4200. iteminfo.Amt = checkCostTotal
  4201. iteminfo.ClaaSumfee = check_claa_sunmfee
  4202. iteminfo.ClabAmt = check_clab_amt
  4203. iteminfo.OthAmt = check_other_amt
  4204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4205. }
  4206. if laboratoryCostTotal != 0 {
  4207. iteminfo.MedChrgitm = "04"
  4208. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4209. iteminfo.Amt = laboratoryCostTotal
  4210. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4211. iteminfo.ClabAmt = laboratory_clab_amt
  4212. iteminfo.OthAmt = laboratory_other_amt
  4213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4215. }
  4216. if treatCostTotal != 0 {
  4217. iteminfo.MedChrgitm = "05"
  4218. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4219. iteminfo.Amt = treatCostTotal
  4220. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4221. iteminfo.ClabAmt = treat_clab_amt
  4222. iteminfo.OthAmt = treat_other_amt
  4223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4224. //(struct4101.IteminfoStruct, iteminfo)
  4225. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4226. }
  4227. if operationCostTotal != 0 {
  4228. iteminfo.MedChrgitm = "06"
  4229. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4230. iteminfo.Amt = operationCostTotal
  4231. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4232. iteminfo.ClabAmt = operation_clab_amt
  4233. iteminfo.OthAmt = operation_other_amt
  4234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4236. }
  4237. if materialCostTotal != 0 {
  4238. iteminfo.MedChrgitm = "08"
  4239. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4240. iteminfo.Amt = materialCostTotal
  4241. iteminfo.ClaaSumfee = material_claa_sunmfee
  4242. iteminfo.ClabAmt = material_clab_amt
  4243. iteminfo.OthAmt = material_other_amt
  4244. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4246. }
  4247. if westernMedicineCostTotal != 0 {
  4248. iteminfo.MedChrgitm = "09"
  4249. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4250. iteminfo.Amt = westernMedicineCostTotal
  4251. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4252. iteminfo.ClabAmt = westernMedicine_clab_amt
  4253. iteminfo.OthAmt = westernMedicine_other_amt
  4254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4255. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4256. }
  4257. if chineseTraditionalMedicineCostTotal != 0 {
  4258. iteminfo.MedChrgitm = "11"
  4259. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4260. iteminfo.Amt = westernMedicineCostTotal
  4261. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4262. iteminfo.ClabAmt = westernMedicine_clab_amt
  4263. iteminfo.OthAmt = westernMedicine_other_amt
  4264. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4265. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4266. }
  4267. if otherCostTotal != 0 {
  4268. iteminfo.MedChrgitm = "14"
  4269. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4270. iteminfo.Amt = otherCostTotal
  4271. iteminfo.ClaaSumfee = other_claa_sunmfee
  4272. iteminfo.ClabAmt = other_clab_amt
  4273. iteminfo.OthAmt = other_other_amt
  4274. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4275. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4276. }
  4277. struct4101.IteminfoStruct = iteminfoStructs
  4278. struct4101.Ntly = "中国"
  4279. struct4101.AdmCaty = "A03.06"
  4280. var resOther ResultSeventeenOther
  4281. var res ResultSeventeen
  4282. if miConfig.MdtrtareaAdmvs == "150499" {
  4283. var pp models.PublicParams
  4284. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4285. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4286. pp.FixmedinsName = miConfig.OrgName
  4287. pp.FixmedinsCode = miConfig.Code
  4288. pp.RequestUrl = miConfig.Url
  4289. pp.Cainfo = miConfig.Cainfo
  4290. pp.SecretKey = miConfig.SecretKey
  4291. pp.AccessKey = miConfig.AccessKey
  4292. pp.OpterName = curRoles.UserName
  4293. client := &http.Client{}
  4294. var req *http.Request
  4295. data := make(map[string]interface{})
  4296. data["struct4101"] = struct4101
  4297. data["pp"] = pp
  4298. bytesData, _ := json.Marshal(data)
  4299. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4300. resp, _ := client.Do(req)
  4301. defer resp.Body.Close()
  4302. body, ioErr := ioutil.ReadAll(resp.Body)
  4303. if ioErr != nil {
  4304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4306. return
  4307. }
  4308. var respJSON map[string]interface{}
  4309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4312. return
  4313. }
  4314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4315. userJSONBytes, _ := json.Marshal(respJSON)
  4316. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4317. utils.ErrorLog("解析失败:%v", err)
  4318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4319. return
  4320. }
  4321. res.InfRefmsgid = resOther.InfRefmsgid
  4322. res.Output = resOther.Output
  4323. res.ErrMsg = resOther.ErrMsg
  4324. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4325. res.Infcode = infocode
  4326. } else {
  4327. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4328. var dat map[string]interface{}
  4329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4330. fmt.Println(dat)
  4331. } else {
  4332. fmt.Println(err)
  4333. }
  4334. userJSONBytes, _ := json.Marshal(dat)
  4335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4336. utils.ErrorLog("解析失败:%v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. }
  4341. if res.Infcode != 0 {
  4342. c.ServeSuccessJSON(map[string]interface{}{
  4343. "failed_code": -10,
  4344. "msg": res.ErrMsg,
  4345. })
  4346. return
  4347. } else {
  4348. if miConfig.MdtrtareaAdmvs != "150499" {
  4349. order.FaPiaoNumber = zero
  4350. order.FaPiaoCode = last_order.FaPiaoCode
  4351. service.UpdateOrder(order)
  4352. }
  4353. hisFundSettleListResult := &models.HisFundSettleListResult{
  4354. Number: res.Output.SetlListId,
  4355. Status: 1,
  4356. Ctime: time.Now().Unix(),
  4357. Mtime: time.Now().Unix(),
  4358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4359. IsUpload: 1,
  4360. OrderId: order_id,
  4361. }
  4362. service.CreateUploadRecord(hisFundSettleListResult)
  4363. c.ServeSuccessJSON(map[string]interface{}{
  4364. "msg": "上传成功",
  4365. "result": hisFundSettleListResult,
  4366. })
  4367. return
  4368. }
  4369. }
  4370. func (c *HisApiController) GetBatchSettleList() {
  4371. orders, _ := service.GetAllHisOrder(10138)
  4372. for _, item := range orders {
  4373. order_id := item.ID
  4374. order, _ := service.GetHisOrderByIDTwo(order_id)
  4375. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4376. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4377. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4378. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  4379. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4381. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4382. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4383. if order.ID == 0 {
  4384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4385. return
  4386. }
  4387. if his.BalanceAccountsType == 2 {
  4388. continue
  4389. }
  4390. struct4101 := service.Struct4101{
  4391. PsnNo: order.PsnNo,
  4392. MdtrtId: order.MdtrtId,
  4393. SetlId: order.SetlId,
  4394. PsnName: order.PsnName,
  4395. Gend: order.Gend,
  4396. Brdy: his.Brdy,
  4397. Age: his.Age,
  4398. Naty: order.Naty,
  4399. PatnCertType: "01",
  4400. Certno: order.Certno,
  4401. Prfs: "90",
  4402. ConerName: roles[0].UserName,
  4403. PatnRlts: "99",
  4404. ConerAddr: miConfig.OrgName,
  4405. ConerTel: admin.Mobile,
  4406. HiType: order.Insutype,
  4407. Insuplc: his.InsuplcAdmdvs,
  4408. MaindiagFlag: "1",
  4409. BillCode: order.SetlId,
  4410. BillNo: order.SetlId,
  4411. BizSn: order.Number,
  4412. PsnSelfPay: order.PsnPartAmt,
  4413. PsnOwnPay: order.PsnPartAmt,
  4414. AcctPay: order.AcctPay,
  4415. PsnCashpay: order.PsnCashPay,
  4416. HiPaymtd: "1",
  4417. Hsorg: his.InsuplcAdmdvs,
  4418. HsorgOpter: his.InsuplcAdmdvs,
  4419. MedinsFillPsn: curRoles.UserName,
  4420. MedinsFillDept: depart.Name,
  4421. IptMedType: "2",
  4422. }
  4423. struct4101.SetlBegnDate = order.SetlTime
  4424. struct4101.SetlEndDate = order.SetlTime
  4425. //if order.SettleType == 1 {
  4426. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4427. // dateStr := t.Format("2006-01-02")
  4428. // struct4101.SetlBegnDate = dateStr
  4429. // struct4101.SetlEndDate = dateStr
  4430. //} else {
  4431. // t := time.Unix(int64(order.SettleStartTime), 0)
  4432. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4433. // dateStartStr := t.Format("2006-01-02")
  4434. // dateEndStr := t2.Format("2006-01-02")
  4435. // struct4101.SetlBegnDate = dateStartStr
  4436. // struct4101.SetlEndDate = dateEndStr
  4437. //}
  4438. var rf []CustomFundPay
  4439. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4440. var tempFunPays []service.CustomStruct
  4441. var tempFunPay610100 service.CustomStruct
  4442. for _, item := range rf {
  4443. if item.FundPayType == "610100" {
  4444. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4445. tempFunPay610100.FundPayType = item.FundPayType
  4446. } else {
  4447. var tempFunPay service.CustomStruct
  4448. tempFunPay.FundPayamt = item.FundPayamt
  4449. tempFunPay.FundPayType = item.FundPayType
  4450. tempFunPays = append(tempFunPays, tempFunPay)
  4451. }
  4452. }
  4453. tempFunPays = append(tempFunPays, tempFunPay610100)
  4454. struct4101.CustomStruct = tempFunPays
  4455. var tempDiaginfos []service.DiaginfoStructTwo
  4456. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4457. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4458. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4459. var config []*models.HisXtDiagnoseConfig
  4460. for _, item := range diagnosis_ids {
  4461. id, _ := strconv.ParseInt(item, 10, 64)
  4462. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4463. config = append(config, &diagnosisConfig)
  4464. }
  4465. for index, item := range config {
  4466. if index == 0 {
  4467. var tempDiaginfo service.DiaginfoStructTwo
  4468. tempDiaginfo.DiagCode = item.CountryCode
  4469. tempDiaginfo.DiagName = item.CountryContentName
  4470. tempDiaginfo.DiagType = "1"
  4471. tempDiaginfo.MaindiagFlag = "1"
  4472. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4473. } else {
  4474. var tempDiaginfo service.DiaginfoStructTwo
  4475. tempDiaginfo.DiagCode = item.CountryCode
  4476. tempDiaginfo.DiagName = item.CountryContentName
  4477. tempDiaginfo.DiagType = "2"
  4478. tempDiaginfo.MaindiagFlag = "0"
  4479. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4480. }
  4481. }
  4482. struct4101.Diseinfo = tempDiaginfos
  4483. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4484. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4485. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4486. tempOpspdiseinfo2.OprnOprtCode = ""
  4487. tempOpspdiseinfo2.OprnOprtName = ""
  4488. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4489. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4490. var iteminfo service.IteminfoStruct
  4491. var bedCostTotal float64 = 0 //床位总费
  4492. var bedCostSelfTotal float64 = 0 //床位自费
  4493. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4494. var examineCostTotal float64 = 0 //诊查总费
  4495. var examineCostSelfTotal float64 = 0 //诊查自费
  4496. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4497. var nursingCostTotal float64 = 0 //护理总费
  4498. var nursingCostSelfTotal float64 = 0 //护理自费
  4499. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4500. var chineseMedicineCostTotal float64 = 0 //中成药
  4501. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4502. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4503. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4504. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4505. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4506. var registerCostTotal float64 = 0 //一般诊疗费
  4507. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4508. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4509. var operationCostTotal float64 = 0 //手术费
  4510. var operationCostSelfTotal float64 = 0 //手术费
  4511. var operationCostPartSelfTotal float64 = 0 //手术费
  4512. var otherCostTotal float64 = 0 //其他费用
  4513. var otherCostSelfTotal float64 = 0 //其他费用
  4514. var otherCostPartSelfTotal float64 = 0 //其他费用
  4515. var materialCostTotal float64 = 0 //材料费
  4516. var materialCostSelfTotal float64 = 0 //材料费
  4517. var materialCostPartSelfTotal float64 = 0 //材料费
  4518. var westernMedicineCostTotal float64 = 0 //西药费
  4519. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4520. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4521. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4522. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4523. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4524. var checkCostTotal float64 = 0 //检查费
  4525. var checkCostSelfTotal float64 = 0 //检查费
  4526. var checkCostPartSelfTotal float64 = 0 //检查费
  4527. var laboratoryCostTotal float64 = 0 //化验费
  4528. var laboratoryCostSelfTotal float64 = 0 //化验费
  4529. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4530. var treatCostTotal float64 = 0 //治疗费用
  4531. var treatCostSelfTotal float64 = 0 //治疗费用
  4532. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4533. decimal.DivisionPrecision = 2
  4534. var bed_fulamt_ownpay_amt float64 = 0
  4535. var examine_fulamt_ownpay_amt float64 = 0
  4536. var nursing_fulamt_ownpay_amt float64 = 0
  4537. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4538. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4539. var register_fulamt_ownpay_amt float64 = 0
  4540. var operation_fulamt_ownpay_amt float64 = 0
  4541. var other_fulamt_ownpay_amt float64 = 0
  4542. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4543. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4544. var check_fulamt_ownpay_amt float64 = 0
  4545. var material_fulamt_ownpay_amt float64 = 0
  4546. var laboratory_fulamt_ownpay_amt float64 = 0
  4547. var treat_fulamt_ownpay_amt float64 = 0
  4548. var bed_claa_sunmfee float64 = 0
  4549. var bed_clab_amt float64 = 0
  4550. var bed_other_amt float64 = 0
  4551. var examine_claa_sunmfee float64 = 0
  4552. var examine_clab_amt float64 = 0
  4553. var examine_other_amt float64 = 0
  4554. var nursing_claa_sunmfee float64 = 0
  4555. var nursing_clab_amt float64 = 0
  4556. var nursing_other_amt float64 = 0
  4557. var chinese_medicine_claa_sunmfee float64 = 0
  4558. var chinese_medicine_clab_amt float64 = 0
  4559. var chinese_medicine_other_amt float64 = 0
  4560. var commonly_treatment_claa_sunmfee float64 = 0
  4561. var commonly_treatment_clab_amt float64 = 0
  4562. var commonly_treatment_other_amt float64 = 0
  4563. var operation_claa_sunmfee float64 = 0
  4564. var operation_clab_amt float64 = 0
  4565. var operation_other_amt float64 = 0
  4566. var other_claa_sunmfee float64 = 0
  4567. var other_clab_amt float64 = 0
  4568. var other_other_amt float64 = 0
  4569. var westernMedicine_claa_sunmfee float64 = 0
  4570. var westernMedicine_clab_amt float64 = 0
  4571. var westernMedicine_other_amt float64 = 0
  4572. var chineseTraditional_claa_sunmfee float64 = 0
  4573. var chineseTraditional_clab_amt float64 = 0
  4574. var chineseTraditional_other_amt float64 = 0
  4575. var check_claa_sunmfee float64 = 0
  4576. var check_clab_amt float64 = 0
  4577. var check_other_amt float64 = 0
  4578. var material_claa_sunmfee float64 = 0
  4579. var material_clab_amt float64 = 0
  4580. var material_other_amt float64 = 0
  4581. var laboratory_claa_sunmfee float64 = 0
  4582. var laboratory_clab_amt float64 = 0
  4583. var laboratory_other_amt float64 = 0
  4584. var treat_claa_sunmfee float64 = 0
  4585. var treat_clab_amt float64 = 0
  4586. var treat_other_amt float64 = 0
  4587. var register_claa_sunmfee float64 = 0
  4588. var register_clab_amt float64 = 0
  4589. var register_other_amt float64 = 0
  4590. for _, item := range order.HisOrderInfo {
  4591. if item.MedChrgitmType == "01" { //床位费
  4592. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4593. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4594. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4595. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4596. if item.ChrgitmLv == "1" {
  4597. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4598. }
  4599. if item.ChrgitmLv == "2" {
  4600. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4601. }
  4602. if item.ChrgitmLv == "3" {
  4603. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4604. }
  4605. }
  4606. if item.MedChrgitmType == "02" { //诊查
  4607. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4608. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4609. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4610. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4611. if item.ChrgitmLv == "1" {
  4612. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4613. }
  4614. if item.ChrgitmLv == "2" {
  4615. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4616. }
  4617. if item.ChrgitmLv == "3" {
  4618. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4619. }
  4620. }
  4621. if item.MedChrgitmType == "03" { //检查费
  4622. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4623. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4624. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4625. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4626. if item.ChrgitmLv == "1" {
  4627. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4628. }
  4629. if item.ChrgitmLv == "2" {
  4630. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4631. }
  4632. if item.ChrgitmLv == "3" {
  4633. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4634. }
  4635. }
  4636. if item.MedChrgitmType == "04" { //化验费
  4637. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4638. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4639. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4640. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4641. if item.ChrgitmLv == "1" {
  4642. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4643. }
  4644. if item.ChrgitmLv == "2" {
  4645. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4646. }
  4647. if item.ChrgitmLv == "3" {
  4648. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4649. }
  4650. }
  4651. if item.MedChrgitmType == "05" { //治疗费
  4652. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4653. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4654. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4655. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4656. if item.ChrgitmLv == "1" {
  4657. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4658. }
  4659. if item.ChrgitmLv == "2" {
  4660. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4661. }
  4662. if item.ChrgitmLv == "3" {
  4663. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4664. }
  4665. }
  4666. if item.MedChrgitmType == "06" { //手术费
  4667. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4668. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4669. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4670. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4671. if item.ChrgitmLv == "1" {
  4672. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4673. }
  4674. if item.ChrgitmLv == "2" {
  4675. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4676. }
  4677. if item.ChrgitmLv == "3" {
  4678. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4679. }
  4680. }
  4681. if item.MedChrgitmType == "07" { //手术费
  4682. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4683. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4684. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4685. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4686. if item.ChrgitmLv == "1" {
  4687. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4688. }
  4689. if item.ChrgitmLv == "2" {
  4690. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4691. }
  4692. if item.ChrgitmLv == "3" {
  4693. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4694. }
  4695. }
  4696. if item.MedChrgitmType == "08" { //材料费
  4697. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4698. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4699. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4700. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4701. if item.ChrgitmLv == "1" {
  4702. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4703. }
  4704. if item.ChrgitmLv == "2" {
  4705. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4706. }
  4707. if item.ChrgitmLv == "3" {
  4708. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4709. }
  4710. }
  4711. if item.MedChrgitmType == "09" { //西药费
  4712. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4713. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4714. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4715. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4716. if item.ChrgitmLv == "1" {
  4717. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4718. }
  4719. if item.ChrgitmLv == "2" {
  4720. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4721. }
  4722. if item.ChrgitmLv == "3" {
  4723. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4724. }
  4725. }
  4726. if item.MedChrgitmType == "10" { //中药饮片
  4727. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4728. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4729. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4730. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4731. if item.ChrgitmLv == "1" {
  4732. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4733. }
  4734. if item.ChrgitmLv == "2" {
  4735. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4736. }
  4737. if item.ChrgitmLv == "3" {
  4738. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4739. }
  4740. }
  4741. if item.MedChrgitmType == "11" { //中成费
  4742. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4743. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4744. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4745. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4746. if item.ChrgitmLv == "1" {
  4747. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4748. }
  4749. if item.ChrgitmLv == "2" {
  4750. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4751. }
  4752. if item.ChrgitmLv == "3" {
  4753. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4754. }
  4755. }
  4756. if item.MedChrgitmType == "12" { //中成费
  4757. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4758. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4759. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4760. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4761. if item.ChrgitmLv == "1" {
  4762. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4763. }
  4764. if item.ChrgitmLv == "2" {
  4765. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4766. }
  4767. if item.ChrgitmLv == "3" {
  4768. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4769. }
  4770. }
  4771. if item.MedChrgitmType == "13" { //中成费
  4772. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4773. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4774. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4775. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4776. if item.ChrgitmLv == "1" {
  4777. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4778. }
  4779. if item.ChrgitmLv == "2" {
  4780. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4781. }
  4782. if item.ChrgitmLv == "3" {
  4783. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4784. }
  4785. }
  4786. if item.MedChrgitmType == "14" { //其他费
  4787. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4788. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4789. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4790. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4791. if item.ChrgitmLv == "1" {
  4792. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4793. }
  4794. if item.ChrgitmLv == "2" {
  4795. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4796. }
  4797. if item.ChrgitmLv == "3" {
  4798. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4799. }
  4800. }
  4801. }
  4802. var iteminfoStructs []service.IteminfoStruct
  4803. if bedCostTotal != 0 {
  4804. iteminfo.MedChrgitm = "01"
  4805. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4806. iteminfo.Amt = bedCostTotal
  4807. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4808. iteminfo.ClabAmt = bed_clab_amt
  4809. iteminfo.OthAmt = bed_other_amt
  4810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4811. }
  4812. if examineCostTotal != 0 {
  4813. iteminfo.MedChrgitm = "02"
  4814. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  4815. iteminfo.Amt = examineCostTotal
  4816. iteminfo.ClaaSumfee = examine_claa_sunmfee
  4817. iteminfo.ClabAmt = examine_clab_amt
  4818. iteminfo.OthAmt = examine_other_amt
  4819. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4821. }
  4822. if checkCostTotal != 0 {
  4823. iteminfo.MedChrgitm = "03"
  4824. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4825. iteminfo.Amt = checkCostTotal
  4826. iteminfo.ClaaSumfee = check_claa_sunmfee
  4827. iteminfo.ClabAmt = check_clab_amt
  4828. iteminfo.OthAmt = check_other_amt
  4829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4830. }
  4831. if laboratoryCostTotal != 0 {
  4832. iteminfo.MedChrgitm = "04"
  4833. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4834. iteminfo.Amt = laboratoryCostTotal
  4835. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4836. iteminfo.ClabAmt = laboratory_clab_amt
  4837. iteminfo.OthAmt = laboratory_other_amt
  4838. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4839. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4840. }
  4841. if treatCostTotal != 0 {
  4842. iteminfo.MedChrgitm = "05"
  4843. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4844. iteminfo.Amt = treatCostTotal
  4845. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4846. iteminfo.ClabAmt = treat_clab_amt
  4847. iteminfo.OthAmt = treat_other_amt
  4848. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4849. //(struct4101.IteminfoStruct, iteminfo)
  4850. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4851. }
  4852. if operationCostTotal != 0 {
  4853. iteminfo.MedChrgitm = "06"
  4854. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4855. iteminfo.Amt = operationCostTotal
  4856. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4857. iteminfo.ClabAmt = operation_clab_amt
  4858. iteminfo.OthAmt = operation_other_amt
  4859. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4860. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4861. }
  4862. if nursingCostTotal != 0 {
  4863. iteminfo.MedChrgitm = "07"
  4864. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  4865. iteminfo.Amt = nursingCostTotal
  4866. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  4867. iteminfo.ClabAmt = nursing_clab_amt
  4868. iteminfo.OthAmt = nursing_other_amt
  4869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4870. }
  4871. if materialCostTotal != 0 {
  4872. iteminfo.MedChrgitm = "08"
  4873. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4874. iteminfo.Amt = materialCostTotal
  4875. iteminfo.ClaaSumfee = material_claa_sunmfee
  4876. iteminfo.ClabAmt = material_clab_amt
  4877. iteminfo.OthAmt = material_other_amt
  4878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4880. }
  4881. if westernMedicineCostTotal != 0 {
  4882. iteminfo.MedChrgitm = "09"
  4883. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4884. iteminfo.Amt = westernMedicineCostTotal
  4885. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4886. iteminfo.ClabAmt = westernMedicine_clab_amt
  4887. iteminfo.OthAmt = westernMedicine_other_amt
  4888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4890. }
  4891. if chineseMedicineCostTotal != 0 {
  4892. iteminfo.MedChrgitm = "10"
  4893. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  4894. iteminfo.Amt = chineseMedicineCostTotal
  4895. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  4896. iteminfo.ClabAmt = chinese_medicine_clab_amt
  4897. iteminfo.OthAmt = chinese_medicine_other_amt
  4898. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4900. }
  4901. if chineseTraditionalMedicineCostTotal != 0 {
  4902. iteminfo.MedChrgitm = "11"
  4903. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4904. iteminfo.Amt = westernMedicineCostTotal
  4905. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4906. iteminfo.ClabAmt = westernMedicine_clab_amt
  4907. iteminfo.OthAmt = westernMedicine_other_amt
  4908. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4910. }
  4911. if commonlyTreatmentCostTotal != 0 {
  4912. iteminfo.MedChrgitm = "12"
  4913. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  4914. iteminfo.Amt = commonlyTreatmentCostTotal
  4915. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  4916. iteminfo.ClabAmt = commonly_treatment_clab_amt
  4917. iteminfo.OthAmt = commonly_treatment_other_amt
  4918. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4920. }
  4921. if registerCostTotal != 0 {
  4922. iteminfo.MedChrgitm = "13"
  4923. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  4924. iteminfo.Amt = registerCostTotal
  4925. iteminfo.ClaaSumfee = register_claa_sunmfee
  4926. iteminfo.ClabAmt = register_clab_amt
  4927. iteminfo.OthAmt = register_other_amt
  4928. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4930. }
  4931. if otherCostTotal != 0 {
  4932. iteminfo.MedChrgitm = "14"
  4933. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4934. iteminfo.Amt = otherCostTotal
  4935. iteminfo.ClaaSumfee = other_claa_sunmfee
  4936. iteminfo.ClabAmt = other_clab_amt
  4937. iteminfo.OthAmt = other_other_amt
  4938. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4939. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4940. }
  4941. struct4101.IteminfoStruct = iteminfoStructs
  4942. time_arr := strings.Split(order.SetlTime, " ")
  4943. struct4101.AdmTime = time_arr[0]
  4944. struct4101.AdmEndTime = time_arr[0]
  4945. struct4101.DoctorName = doctor.UserName
  4946. struct4101.DoctorCode = doctor.DoctorNumber
  4947. struct4101.Ntly = "中国"
  4948. struct4101.AdmCaty = "A03.06"
  4949. var res ResultSeventeen
  4950. if miConfig.MdtrtareaAdmvs == "421300" {
  4951. data := make(map[string]interface{})
  4952. data["struct4101"] = struct4101
  4953. data["secret_key"] = miConfig.SecretKey
  4954. data["org_name"] = miConfig.OrgName
  4955. data["opera"] = curRoles.UserName
  4956. data["code"] = miConfig.Code
  4957. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4958. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4959. client := &http.Client{}
  4960. bytesData, _ := json.Marshal(data)
  4961. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  4962. resp, _ := client.Do(req)
  4963. defer resp.Body.Close()
  4964. body, ioErr := ioutil.ReadAll(resp.Body)
  4965. if ioErr != nil {
  4966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. return
  4969. }
  4970. var respJSON map[string]interface{}
  4971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4974. return
  4975. }
  4976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4977. userJSONBytes, _ := json.Marshal(respJSON)
  4978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4979. utils.ErrorLog("解析失败:%v", err)
  4980. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4981. adminUser := c.GetAdminUserInfo()
  4982. errlog := &models.HisOrderError{
  4983. UserOrgId: adminUser.CurrentOrgId,
  4984. Ctime: time.Now().Unix(),
  4985. Mtime: time.Now().Unix(),
  4986. ErrMsg: res.ErrMsg + "解析失败",
  4987. Status: 1,
  4988. PatientId: order_id,
  4989. Stage: 10088,
  4990. }
  4991. service.CreateErrMsgLog(errlog)
  4992. continue
  4993. }
  4994. } else {
  4995. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  4996. fmt.Println(result)
  4997. var dat map[string]interface{}
  4998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4999. fmt.Println(dat)
  5000. } else {
  5001. fmt.Println(err)
  5002. }
  5003. userJSONBytes, _ := json.Marshal(dat)
  5004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5005. utils.ErrorLog("解析失败:%v", err)
  5006. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5007. adminUser := c.GetAdminUserInfo()
  5008. errlog := &models.HisOrderError{
  5009. UserOrgId: adminUser.CurrentOrgId,
  5010. Ctime: time.Now().Unix(),
  5011. Mtime: time.Now().Unix(),
  5012. ErrMsg: res.ErrMsg + "解析失败",
  5013. Status: 1,
  5014. PatientId: order_id,
  5015. Stage: 10106,
  5016. }
  5017. service.CreateErrMsgLog(errlog)
  5018. continue
  5019. }
  5020. }
  5021. if res.Infcode != 0 {
  5022. adminUser := c.GetAdminUserInfo()
  5023. errlog := &models.HisOrderError{
  5024. UserOrgId: adminUser.CurrentOrgId,
  5025. Ctime: time.Now().Unix(),
  5026. Mtime: time.Now().Unix(),
  5027. ErrMsg: res.ErrMsg,
  5028. Status: 1,
  5029. PatientId: order_id,
  5030. Stage: 10106,
  5031. }
  5032. service.CreateErrMsgLog(errlog)
  5033. continue
  5034. } else {
  5035. hisFundSettleListResult := &models.HisFundSettleListResult{
  5036. Number: res.Output.SetlListId,
  5037. Status: 1,
  5038. Ctime: time.Now().Unix(),
  5039. Mtime: time.Now().Unix(),
  5040. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5041. IsUpload: 1,
  5042. OrderId: order_id,
  5043. }
  5044. service.CreateUploadRecord(hisFundSettleListResult)
  5045. continue
  5046. }
  5047. }
  5048. }
  5049. func (c *HisApiController) GetOrgInfo() {
  5050. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5051. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5052. }
  5053. func (c *HisApiController) GetHisPatientInfo() {
  5054. medical_insurance_card := c.GetString("medical_insurance_card")
  5055. id_card_type, _ := c.GetInt64("id_card_type")
  5056. id_card := c.GetString("id_card")
  5057. adminInfo := c.GetAdminUserInfo()
  5058. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5059. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5060. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5061. IdCardNo := ""
  5062. if id_card_type == 1 {
  5063. IdCardNo = medical_insurance_card
  5064. } else if id_card_type == 2 {
  5065. IdCardNo = id_card
  5066. }
  5067. if config.IsOpen == 1 {
  5068. 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
  5069. resp, requestErr := http.Get(api)
  5070. if requestErr != nil {
  5071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5072. return
  5073. }
  5074. defer resp.Body.Close()
  5075. body, ioErr := ioutil.ReadAll(resp.Body)
  5076. if ioErr != nil {
  5077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. return
  5080. }
  5081. var respJSON map[string]interface{}
  5082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5085. return
  5086. }
  5087. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5088. userJSONBytes, _ := json.Marshal(userJSON)
  5089. var res ResultTwo
  5090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5091. utils.ErrorLog("解析失败:%v", err)
  5092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5093. return
  5094. }
  5095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5097. infoStr := string(Iinfos)
  5098. idetinfoStr := string(Idetinfos)
  5099. if res.Infcode == 0 {
  5100. his := models.VMHisPatient{
  5101. Status: 1,
  5102. Ctime: time.Now().Unix(),
  5103. Mtime: time.Now().Unix(),
  5104. PsnNo: res.Output.Baseinfo.PsnNo,
  5105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5106. Certno: res.Output.Baseinfo.Certno,
  5107. PsnName: res.Output.Baseinfo.PsnName,
  5108. Gend: res.Output.Baseinfo.Gend,
  5109. Naty: res.Output.Baseinfo.Naty,
  5110. Brdy: res.Output.Baseinfo.Brdy,
  5111. Age: res.Output.Baseinfo.Age,
  5112. Iinfo: infoStr,
  5113. Idetinfo: idetinfoStr,
  5114. UserOrgId: adminInfo.CurrentOrgId,
  5115. IsReturn: 1,
  5116. IdCardType: id_card_type,
  5117. }
  5118. c.ServeSuccessJSON(map[string]interface{}{
  5119. "info": his,
  5120. })
  5121. } else {
  5122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5123. return
  5124. }
  5125. }
  5126. }
  5127. //func GetBasBaseInfo() (jsonStr string, err error) {
  5128. //
  5129. // handle := syscall.NewLazyDLL("SSCard.dll")
  5130. // add := handle.NewProc("ReadCardBas")
  5131. // str := make([]byte, 1024)
  5132. // str1 := make([]byte, 1024)
  5133. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5134. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5135. //
  5136. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5137. //
  5138. // fmt.Println("> Add(4,5)的结果为:", ret)
  5139. // handle.Release()
  5140. //
  5141. // return "", nil
  5142. //
  5143. //}
  5144. //func GetQRBaseInfo() (jsonStr string, err error) {
  5145. // handle := syscall.LoadDLL("SSCard.dll")
  5146. // ReadCardBas := handle.FindProc("GetQRBase")
  5147. //
  5148. // str := make([]byte, 256)
  5149. // str1 := make([]byte, 256)
  5150. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5151. //
  5152. // fmt.Println(string(str))
  5153. // fmt.Println(r)
  5154. // return string(str), nil
  5155. //}
  5156. //func CardInit() int {
  5157. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5158. // add := DllTestDef.MustFindProc("Init")
  5159. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5160. // if err != nil {
  5161. // fmt.Println("SSCard的运算结果为:", ret)
  5162. // }
  5163. // result := int(ret)
  5164. // return result
  5165. //}
  5166. //func CardInit() int {
  5167. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5168. // if err != nil {
  5169. // fmt.Println("SSCard的运算结果为:", ret)
  5170. // }
  5171. // fmt.Println(err)
  5172. // result := int(ret)
  5173. // return result
  5174. //}
  5175. func IntPtr(n int) uintptr {
  5176. return uintptr(n)
  5177. }
  5178. func StrPtr(s string) uintptr {
  5179. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5180. }
  5181. type Result2001 struct {
  5182. Cainfo interface{} `json:"cainfo"`
  5183. ErrMsg string `json:"err_msg"`
  5184. InfRefmsgid string `json:"inf_refmsgid"`
  5185. Infcode int64 `json:"infcode"`
  5186. Output struct {
  5187. Trtinfo struct {
  5188. PsnNo string `json:"psn_no"`
  5189. TrtChkType string `json:"trt_chk_type"`
  5190. FundPayType string `json:"fund_pay_type"`
  5191. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5192. Begndate string `json:"begndate"`
  5193. Enddate string `json:"enddate"`
  5194. TrtChkRslt string `json:"trt_chk_rslt"`
  5195. } `json:"trtinfo"`
  5196. } `json:"output"`
  5197. RefmsgTime string `json:"refmsg_time"`
  5198. RespondTime string `json:"respond_time"`
  5199. Signtype interface{} `json:"signtype"`
  5200. WarnMsg interface{} `json:"warn_msg"`
  5201. }
  5202. type Result2001Org10265 struct {
  5203. Cainfo interface{} `json:"cainfo"`
  5204. ErrMsg string `json:"err_msg"`
  5205. InfRefmsgid string `json:"inf_refmsgid"`
  5206. Infcode string `json:"infcode"`
  5207. Output struct {
  5208. Trtinfo struct {
  5209. PsnNo string `json:"psn_no"`
  5210. TrtChkType string `json:"trt_chk_type"`
  5211. FundPayType string `json:"fund_pay_type"`
  5212. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5213. Begndate string `json:"begndate"`
  5214. Enddate string `json:"enddate"`
  5215. TrtChkRslt string `json:"trt_chk_rslt"`
  5216. } `json:"trtinfo"`
  5217. } `json:"output"`
  5218. RefmsgTime string `json:"refmsg_time"`
  5219. RespondTime string `json:"respond_time"`
  5220. Signtype interface{} `json:"signtype"`
  5221. WarnMsg interface{} `json:"warn_msg"`
  5222. }
  5223. type ResultTwo struct {
  5224. ErrMsg string `json:"err_msg"`
  5225. InfRefmsgid string `json:"inf_refmsgid"`
  5226. Infcode int64 `json:"infcode"`
  5227. Output struct {
  5228. Baseinfo struct {
  5229. Age float64 `json:"age"`
  5230. Brdy string `json:"brdy"`
  5231. Certno string `json:"certno"`
  5232. Gend string `json:"gend"`
  5233. Naty string `json:"naty"`
  5234. PsnCertType string `json:"psn_cert_type"`
  5235. PsnName string `json:"psn_name"`
  5236. PsnNo string `json:"psn_no"`
  5237. } `json:"baseinfo"`
  5238. Idetinfo []interface{} `json:"idetinfo"`
  5239. Iinfo []struct {
  5240. Balc float64 `json:"balc"`
  5241. CvlservFlag string `json:"cvlserv_flag"`
  5242. EmpName string `json:"emp_name"`
  5243. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5244. Insutype string `json:"insutype"`
  5245. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5246. PausInsuDate string `json:"paus_insu_date"`
  5247. PsnInsuDate string `json:"psn_insu_date"`
  5248. PsnInsuStas string `json:"psn_insu_stas"`
  5249. PsnType string `json:"psn_type"`
  5250. } `json:"insuinfo"`
  5251. } `json:"output"`
  5252. RefmsgTime string `json:"refmsg_time"`
  5253. RespondTime string `json:"respond_time"`
  5254. Signtype interface{} `json:"signtype"`
  5255. WarnInfo interface{} `json:"warn_info"`
  5256. }
  5257. type ResultTwo10265 struct {
  5258. ErrMsg string `json:"err_msg"`
  5259. InfRefmsgid string `json:"inf_refmsgid"`
  5260. Infcode string `json:"infcode"`
  5261. Output struct {
  5262. Baseinfo struct {
  5263. Age float64 `json:"age"`
  5264. Brdy string `json:"brdy"`
  5265. Certno string `json:"certno"`
  5266. Gend string `json:"gend"`
  5267. Naty string `json:"naty"`
  5268. PsnCertType string `json:"psn_cert_type"`
  5269. PsnName string `json:"psn_name"`
  5270. PsnNo string `json:"psn_no"`
  5271. } `json:"baseinfo"`
  5272. Idetinfo []interface{} `json:"idetinfo"`
  5273. Iinfo []struct {
  5274. Balc float64 `json:"balc"`
  5275. CvlservFlag string `json:"cvlserv_flag"`
  5276. EmpName string `json:"emp_name"`
  5277. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5278. Insutype string `json:"insutype"`
  5279. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5280. PausInsuDate string `json:"paus_insu_date"`
  5281. PsnInsuDate string `json:"psn_insu_date"`
  5282. PsnInsuStas string `json:"psn_insu_stas"`
  5283. PsnType string `json:"psn_type"`
  5284. } `json:"insuinfo"`
  5285. } `json:"output"`
  5286. RefmsgTime string `json:"refmsg_time"`
  5287. RespondTime string `json:"respond_time"`
  5288. Signtype interface{} `json:"signtype"`
  5289. WarnInfo interface{} `json:"warn_info"`
  5290. }
  5291. type ResultThree struct {
  5292. Cainfo interface{} `json:"cainfo"`
  5293. ErrMsg string `json:"err_msg"`
  5294. InfRefmsgid string `json:"inf_refmsgid"`
  5295. Infcode int64 `json:"infcode"`
  5296. Output struct {
  5297. Data struct {
  5298. IptOtpNo string `json:"ipt_otp_no"`
  5299. MdtrtID string `json:"mdtrt_id"`
  5300. PsnNo string `json:"psn_no"`
  5301. } `json:"data"`
  5302. } `json:"output"`
  5303. RefmsgTime string `json:"refmsg_time"`
  5304. RespondTime string `json:"respond_time"`
  5305. Signtype interface{} `json:"signtype"`
  5306. WarnMsg interface{} `json:"warn_msg"`
  5307. }
  5308. type ResultThree10265 struct {
  5309. Cainfo interface{} `json:"cainfo"`
  5310. ErrMsg string `json:"err_msg"`
  5311. InfRefmsgid string `json:"inf_refmsgid"`
  5312. Infcode string `json:"infcode"`
  5313. Output struct {
  5314. Data struct {
  5315. IptOtpNo string `json:"ipt_otp_no"`
  5316. MdtrtID string `json:"mdtrt_id"`
  5317. PsnNo string `json:"psn_no"`
  5318. } `json:"data"`
  5319. } `json:"output"`
  5320. RefmsgTime string `json:"refmsg_time"`
  5321. RespondTime string `json:"respond_time"`
  5322. Signtype interface{} `json:"signtype"`
  5323. WarnMsg interface{} `json:"warn_msg"`
  5324. }
  5325. type ResultFour struct {
  5326. Cainfo string `json:"cainfo"`
  5327. ErrMsg string `json:"err_msg"`
  5328. InfRefmsgid string `json:"inf_refmsgid"`
  5329. Infcode int64 `json:"infcode"`
  5330. Output struct {
  5331. Result []struct {
  5332. BasMednFlag string `json:"bas_medn_flag"`
  5333. ChldMedcFlag string `json:"chld_medc_flag"`
  5334. ChrgitmLv string `json:"chrgitm_lv"`
  5335. Cnt float64 `json:"cnt"`
  5336. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5337. DrtReimFlag string `json:"drt_reim_flag"`
  5338. FeedetlSn string `json:"feedetl_sn"`
  5339. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5340. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5341. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5342. ListSpItemFlag string `json:"list_sp_item_flag"`
  5343. LmtUsedFlag string `json:"lmt_used_flag"`
  5344. MedChrgitmType string `json:"med_chrgitm_type"`
  5345. Memo string `json:"memo"`
  5346. OverlmtAmt float64 `json:"overlmt_amt"`
  5347. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5348. Pric float64 `json:"pric"`
  5349. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5350. SelfpayProp float64 `json:"selfpay_prop"`
  5351. } `json:"result"`
  5352. } `json:"output"`
  5353. RefmsgTime string `json:"refmsg_time"`
  5354. RespondTime string `json:"respond_time"`
  5355. Signtype string `json:"signtype"`
  5356. WarnMsg string `json:"warn_msg"`
  5357. }
  5358. type ResultFour10265 struct {
  5359. Cainfo string `json:"cainfo"`
  5360. ErrMsg string `json:"err_msg"`
  5361. InfRefmsgid string `json:"inf_refmsgid"`
  5362. Infcode string `json:"infcode"`
  5363. Output struct {
  5364. Result []struct {
  5365. BasMednFlag string `json:"bas_medn_flag"`
  5366. ChldMedcFlag string `json:"chld_medc_flag"`
  5367. ChrgitmLv string `json:"chrgitm_lv"`
  5368. Cnt float64 `json:"cnt"`
  5369. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5370. DrtReimFlag string `json:"drt_reim_flag"`
  5371. FeedetlSn string `json:"feedetl_sn"`
  5372. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5373. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5374. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5375. ListSpItemFlag string `json:"list_sp_item_flag"`
  5376. LmtUsedFlag string `json:"lmt_used_flag"`
  5377. MedChrgitmType string `json:"med_chrgitm_type"`
  5378. Memo string `json:"memo"`
  5379. OverlmtAmt float64 `json:"overlmt_amt"`
  5380. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5381. Pric float64 `json:"pric"`
  5382. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5383. SelfpayProp float64 `json:"selfpay_prop"`
  5384. } `json:"result"`
  5385. } `json:"output"`
  5386. RefmsgTime string `json:"refmsg_time"`
  5387. RespondTime string `json:"respond_time"`
  5388. Signtype string `json:"signtype"`
  5389. WarnMsg string `json:"warn_msg"`
  5390. }
  5391. type ResultFive struct {
  5392. Balc float64 `json:"balc"`
  5393. CvlservFlag string `json:"cvlserv_flag"`
  5394. EmpName string `json:"emp_name"`
  5395. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5396. Insutype string `json:"insutype"`
  5397. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5398. PausInsuDate string `json:"paus_insu_date"`
  5399. PsnInsuDate string `json:"psn_insu_date"`
  5400. PsnInsuStas string `json:"psn_insu_stas"`
  5401. PsnType string `json:"psn_type"`
  5402. }
  5403. type ResultSix struct {
  5404. Cainfo interface{} `json:"cainfo"`
  5405. ErrMsg string `json:"err_msg"`
  5406. InfRefmsgid string `json:"inf_refmsgid"`
  5407. Infcode int64 `json:"infcode"`
  5408. Output struct {
  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 ResultSix10265 struct {
  5416. Cainfo interface{} `json:"cainfo"`
  5417. ErrMsg string `json:"err_msg"`
  5418. InfRefmsgid string `json:"inf_refmsgid"`
  5419. Infcode string `json:"infcode"`
  5420. Output struct {
  5421. } `json:"output"`
  5422. RefmsgTime string `json:"refmsg_time"`
  5423. RespondTime string `json:"respond_time"`
  5424. Signtype interface{} `json:"signtype"`
  5425. WarnMsg interface{} `json:"warn_msg"`
  5426. }
  5427. type ResultSeven struct {
  5428. Cainfo string `json:"cainfo"`
  5429. ErrMsg string `json:"err_msg"`
  5430. InfRefmsgid string `json:"inf_refmsgid"`
  5431. Infcode int64 `json:"infcode"`
  5432. Output struct {
  5433. Setldetail []interface{} `json:"setldetail"`
  5434. Setlinfo struct {
  5435. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5436. AcctPay float64 `json:"acct_pay"`
  5437. ActPayDedc float64 `json:"act_pay_dedc"`
  5438. Age float64 `json:"age"`
  5439. Balc float64 `json:"balc"`
  5440. Brdy string `json:"brdy"`
  5441. Certno string `json:"certno"`
  5442. ClrOptins string `json:"clr_optins"`
  5443. ClrType string `json:"clr_type"`
  5444. ClrWay string `json:"clr_way"`
  5445. CvlservFlag string `json:"cvlserv_flag"`
  5446. CvlservPay float64 `json:"cvlserv_pay"`
  5447. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5448. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5449. Gend string `json:"gend"`
  5450. HifesPay float64 `json:"hifes_pay"`
  5451. HifmiPay float64 `json:"hifmi_pay"`
  5452. HifpPay float64 `json:"hifp_pay"`
  5453. HospPartAmt float64 `json:"hosp_part_amt"`
  5454. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5455. Insutype string `json:"insutype"`
  5456. MafPay float64 `json:"maf_pay"`
  5457. MdtrtCertType string `json:"mdtrt_cert_type"`
  5458. HifobPay float64 `json:"hifob_pay"`
  5459. MdtrtID string `json:"mdtrt_id"`
  5460. MedType string `json:"med_type"`
  5461. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5462. MedinsSetlID string `json:"medins_setl_id"`
  5463. Naty string `json:"naty"`
  5464. OthPay float64 `json:"oth_pay"`
  5465. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5466. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5467. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5468. PsnCashPay float64 `json:"psn_cash_pay"`
  5469. PsnCertType string `json:"psn_cert_type"`
  5470. PsnName string `json:"psn_name"`
  5471. PsnNo string `json:"psn_no"`
  5472. PsnPartAmt float64 `json:"psn_part_amt"`
  5473. PsnType string `json:"psn_type"`
  5474. SetlID string `json:"setl_id"`
  5475. SetlTime string `json:"setl_time"`
  5476. } `json:"setlinfo"`
  5477. } `json:"output"`
  5478. RefmsgTime string `json:"refmsg_time"`
  5479. RespondTime string `json:"respond_time"`
  5480. Signtype interface{} `json:"signtype"`
  5481. WarnMsg interface{} `json:"warn_msg"`
  5482. }
  5483. type ResultSeven10265 struct {
  5484. Cainfo string `json:"cainfo"`
  5485. ErrMsg string `json:"err_msg"`
  5486. InfRefmsgid string `json:"inf_refmsgid"`
  5487. Infcode string `json:"infcode"`
  5488. Output struct {
  5489. Setldetail []interface{} `json:"setldetail"`
  5490. Setlinfo struct {
  5491. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5492. AcctPay float64 `json:"acct_pay"`
  5493. ActPayDedc float64 `json:"act_pay_dedc"`
  5494. Age float64 `json:"age"`
  5495. Balc float64 `json:"balc"`
  5496. Brdy string `json:"brdy"`
  5497. Certno string `json:"certno"`
  5498. ClrOptins string `json:"clr_optins"`
  5499. ClrType string `json:"clr_type"`
  5500. ClrWay string `json:"clr_way"`
  5501. CvlservFlag string `json:"cvlserv_flag"`
  5502. CvlservPay float64 `json:"cvlserv_pay"`
  5503. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5504. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5505. Gend string `json:"gend"`
  5506. HifesPay float64 `json:"hifes_pay"`
  5507. HifmiPay float64 `json:"hifmi_pay"`
  5508. HifpPay float64 `json:"hifp_pay"`
  5509. HospPartAmt float64 `json:"hosp_part_amt"`
  5510. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5511. Insutype string `json:"insutype"`
  5512. MafPay float64 `json:"maf_pay"`
  5513. MdtrtCertType string `json:"mdtrt_cert_type"`
  5514. HifobPay float64 `json:"hifob_pay"`
  5515. MdtrtID string `json:"mdtrt_id"`
  5516. MedType string `json:"med_type"`
  5517. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5518. MedinsSetlID string `json:"medins_setl_id"`
  5519. Naty string `json:"naty"`
  5520. OthPay float64 `json:"oth_pay"`
  5521. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5522. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5523. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5524. PsnCashPay float64 `json:"psn_cash_pay"`
  5525. PsnCertType string `json:"psn_cert_type"`
  5526. PsnName string `json:"psn_name"`
  5527. PsnNo string `json:"psn_no"`
  5528. PsnPartAmt float64 `json:"psn_part_amt"`
  5529. PsnType string `json:"psn_type"`
  5530. SetlID string `json:"setl_id"`
  5531. SetlTime string `json:"setl_time"`
  5532. } `json:"setlinfo"`
  5533. } `json:"output"`
  5534. RefmsgTime string `json:"refmsg_time"`
  5535. RespondTime string `json:"respond_time"`
  5536. Signtype interface{} `json:"signtype"`
  5537. WarnMsg interface{} `json:"warn_msg"`
  5538. }
  5539. type ResultEight struct {
  5540. Cainfo string `json:"cainfo"`
  5541. ErrMsg string `json:"err_msg"`
  5542. InfRefmsgid string `json:"inf_refmsgid"`
  5543. Infcode int64 `json:"infcode"`
  5544. Output struct {
  5545. Stmtinfo struct {
  5546. SetlOptins string `json:"setl_optins"`
  5547. StmtRslt string `json:"stmt_rslt"`
  5548. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5549. } `json:"stmtinfo"`
  5550. } `json:"output"`
  5551. RefmsgTime string `json:"refmsg_time"`
  5552. RespondTime string `json:"respond_time"`
  5553. Signtype interface{} `json:"signtype"`
  5554. WarnMsg interface{} `json:"warn_msg"`
  5555. }
  5556. type ResultEightFor10188 struct {
  5557. Cainfo string `json:"cainfo"`
  5558. ErrMsg string `json:"err_msg"`
  5559. InfRefmsgid string `json:"inf_refmsgid"`
  5560. Infcode string `json:"infcode"`
  5561. Output struct {
  5562. Stmtinfo struct {
  5563. SetlOptins string `json:"setl_optins"`
  5564. StmtRslt string `json:"stmt_rslt"`
  5565. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5566. } `json:"stmtinfo"`
  5567. } `json:"output"`
  5568. RefmsgTime string `json:"refmsg_time"`
  5569. RespondTime string `json:"respond_time"`
  5570. Signtype interface{} `json:"signtype"`
  5571. WarnMsg interface{} `json:"warn_msg"`
  5572. }
  5573. type ResultNine struct {
  5574. Cainfo string `json:"cainfo"`
  5575. ErrMsg string `json:"err_msg"`
  5576. InfRefmsgid string `json:"inf_refmsgid"`
  5577. Infcode int64 `json:"infcode"`
  5578. Output struct {
  5579. FileQuryNo string `json:"file_qury_no"`
  5580. } `json:"output"`
  5581. RefmsgTime string `json:"refmsg_time"`
  5582. RespondTime string `json:"respond_time"`
  5583. Signtype interface{} `json:"signtype"`
  5584. WarnMsg interface{} `json:"warn_msg"`
  5585. }
  5586. type ResultTen struct {
  5587. Cainfo string `json:"cainfo"`
  5588. ErrMsg string `json:"err_msg"`
  5589. InfRefmsgid string `json:"inf_refmsgid"`
  5590. Infcode int64 `json:"infcode"`
  5591. Output struct {
  5592. DldEndtime string `json:"dld_endtime"`
  5593. FileQuryNo string `json:"file_qury_no"`
  5594. Filename string `json:"filename"`
  5595. } `json:"output"`
  5596. RefmsgTime string `json:"refmsg_time"`
  5597. RespondTime string `json:"respond_time"`
  5598. Signtype interface{} `json:"signtype"`
  5599. WarnMsg interface{} `json:"warn_msg"`
  5600. }
  5601. //type Autogenerated struct {
  5602. // Output struct {
  5603. // Setlinfo struct {
  5604. // SetlTime string `json:"setl_time"`
  5605. // CvlservPay float64 `json:"cvlserv_pay"`
  5606. // Year string `json:"year"`
  5607. // MedType string `json:"med_type"`
  5608. // PsnPay float64 `json:"psn_pay"`
  5609. // OpterID string `json:"opter_id"`
  5610. // Begndate string `json:"begndate"`
  5611. // FlxempeFlag string `json:"flxempe_flag"`
  5612. // HifmiPay float64 `json:"hifmi_pay"`
  5613. // PsnNo string `json:"psn_no"`
  5614. // ActPayDedc float64 `json:"act_pay_dedc"`
  5615. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5616. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5617. // ClrWay string `json:"clr_way"`
  5618. // OthPay float64 `json:"oth_pay"`
  5619. // Gend string `json:"gend"`
  5620. // MdtrtID string `json:"mdtrt_id"`
  5621. // AcctPay float64 `json:"acct_pay"`
  5622. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5623. // Insutype string `json:"insutype"`
  5624. // Invono interface{} `json:"invono"`
  5625. // Enddate string `json:"enddate"`
  5626. // CashPayamt float64 `json:"cash_payamt"`
  5627. // PsnType string `json:"psn_type"`
  5628. // FixmedinsName string `json:"fixmedins_name"`
  5629. // HifpPay float64 `json:"hifp_pay"`
  5630. // NewFlag interface{} `json:"new_flag"`
  5631. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5632. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5633. // PayLoc string `json:"pay_loc"`
  5634. // ClrType string `json:"clr_type"`
  5635. // RefdSetlFlag string `json:"refd_setl_flag"`
  5636. // CvlservFlag string `json:"cvlserv_flag"`
  5637. // EmpName string `json:"emp_name"`
  5638. // Brdy string `json:"brdy"`
  5639. // Naty string `json:"naty"`
  5640. // Certno string `json:"certno"`
  5641. // DiseCode string `json:"dise_code"`
  5642. // FixmedinsCode string `json:"fixmedins_code"`
  5643. // DedcHospLv string `json:"dedc_hosp_lv"`
  5644. // OpterName string `json:"opter_name"`
  5645. // Balc float64 `json:"balc"`
  5646. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5647. // PsnCertType string `json:"psn_cert_type"`
  5648. // HifobPay float64 `json:"hifob_pay"`
  5649. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5650. // HifesPay float64 `json:"hifes_pay"`
  5651. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5652. // OptTime string `json:"opt_time"`
  5653. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5654. // SetlID string `json:"setl_id"`
  5655. // MafPay float64 `json:"maf_pay"`
  5656. // PsnName string `json:"psn_name"`
  5657. // InsuOptins interface{} `json:"insu_optins"`
  5658. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5659. // ClrOptins string `json:"clr_optins"`
  5660. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5661. // DiseName string `json:"dise_name"`
  5662. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5663. // Age float64 `json:"age"`
  5664. // DtrtCertType string `json:"dtrt_cert_type"`
  5665. // HospLv string `json:"hosp_lv"`
  5666. // } `json:"setlinfo"`
  5667. // Setldetail []struct {
  5668. // FundPayType string `json:"fund_pay_type"`
  5669. // FundPayamt float64 `json:"fund_payamt"`
  5670. // SetlProcInfo interface{} `json:"setl_proc_info"`
  5671. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  5672. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  5673. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  5674. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5675. // } `json:"setldetail"`
  5676. // } `json:"output"`
  5677. // Infcode int `json:"infcode"`
  5678. // WarnMsg interface{} `json:"warn_msg"`
  5679. // Cainfo interface{} `json:"cainfo"`
  5680. // ErrMsg interface{} `json:"err_msg"`
  5681. // RefmsgTime string `json:"refmsg_time"`
  5682. // Signtype interface{} `json:"signtype"`
  5683. // RespondTime string `json:"respond_time"`
  5684. // InfRefmsgid string `json:"inf_refmsgid"`
  5685. //}
  5686. type ResultEleven struct {
  5687. Cainfo string `json:"cainfo"`
  5688. ErrMsg string `json:"err_msg"`
  5689. InfRefmsgid string `json:"inf_refmsgid"`
  5690. Infcode int64 `json:"infcode"`
  5691. Output struct {
  5692. Setlinfo struct {
  5693. SetlTime string `json:"setl_time"`
  5694. CvlservPay float64 `json:"cvlserv_pay"`
  5695. Year string `json:"year"`
  5696. MedType string `json:"med_type"`
  5697. PsnPay float64 `json:"psn_pay"`
  5698. OpterID string `json:"opter_id"`
  5699. Begndate string `json:"begndate"`
  5700. FlxempeFlag string `json:"flxempe_flag"`
  5701. HifmiPay float64 `json:"hifmi_pay"`
  5702. PsnNo string `json:"psn_no"`
  5703. ActPayDedc float64 `json:"act_pay_dedc"`
  5704. MedinsSetlID interface{} `json:"medins_setl_id"`
  5705. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5706. ClrWay string `json:"clr_way"`
  5707. OthPay float64 `json:"oth_pay"`
  5708. Gend string `json:"gend"`
  5709. MdtrtID string `json:"mdtrt_id"`
  5710. AcctPay float64 `json:"acct_pay"`
  5711. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5712. Insutype string `json:"insutype"`
  5713. Invono interface{} `json:"invono"`
  5714. Enddate string `json:"enddate"`
  5715. CashPayamt float64 `json:"cash_payamt"`
  5716. PsnType string `json:"psn_type"`
  5717. FixmedinsName string `json:"fixmedins_name"`
  5718. HifpPay float64 `json:"hifp_pay"`
  5719. NewFlag interface{} `json:"new_flag"`
  5720. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5721. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5722. PayLoc string `json:"pay_loc"`
  5723. ClrType string `json:"clr_type"`
  5724. RefdSetlFlag string `json:"refd_setl_flag"`
  5725. CvlservFlag string `json:"cvlserv_flag"`
  5726. EmpName string `json:"emp_name"`
  5727. Brdy string `json:"brdy"`
  5728. Naty string `json:"naty"`
  5729. Certno string `json:"certno"`
  5730. DiseCode string `json:"dise_code"`
  5731. FixmedinsCode string `json:"fixmedins_code"`
  5732. DedcHospLv string `json:"dedc_hosp_lv"`
  5733. OpterName string `json:"opter_name"`
  5734. Balc float64 `json:"balc"`
  5735. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5736. PsnCertType string `json:"psn_cert_type"`
  5737. HifobPay float64 `json:"hifob_pay"`
  5738. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5739. HifesPay float64 `json:"hifes_pay"`
  5740. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5741. OptTime string `json:"opt_time"`
  5742. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5743. SetlID string `json:"setl_id"`
  5744. MafPay float64 `json:"maf_pay"`
  5745. PsnName string `json:"psn_name"`
  5746. InsuOptins interface{} `json:"insu_optins"`
  5747. PrefFundPay interface{} `json:"pref_fund_pay"`
  5748. ClrOptins string `json:"clr_optins"`
  5749. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5750. DiseName string `json:"dise_name"`
  5751. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5752. Age float64 `json:"age"`
  5753. DtrtCertType string `json:"dtrt_cert_type"`
  5754. HospLv string `json:"hosp_lv"`
  5755. PsnCashPay float64
  5756. } `json:"setlinfo"`
  5757. } `json:"output"`
  5758. RefmsgTime string `json:"refmsg_time"`
  5759. RespondTime string `json:"respond_time"`
  5760. Signtype interface{} `json:"signtype"`
  5761. WarnMsg interface{} `json:"warn_msg"`
  5762. }
  5763. type ResultEleven10265 struct {
  5764. Cainfo string `json:"cainfo"`
  5765. ErrMsg string `json:"err_msg"`
  5766. InfRefmsgid string `json:"inf_refmsgid"`
  5767. Infcode string `json:"infcode"`
  5768. Output struct {
  5769. Setlinfo struct {
  5770. SetlTime string `json:"setl_time"`
  5771. CvlservPay float64 `json:"cvlserv_pay"`
  5772. Year string `json:"year"`
  5773. MedType string `json:"med_type"`
  5774. PsnPay float64 `json:"psn_pay"`
  5775. OpterID string `json:"opter_id"`
  5776. Begndate string `json:"begndate"`
  5777. FlxempeFlag string `json:"flxempe_flag"`
  5778. HifmiPay float64 `json:"hifmi_pay"`
  5779. PsnNo string `json:"psn_no"`
  5780. ActPayDedc float64 `json:"act_pay_dedc"`
  5781. MedinsSetlID interface{} `json:"medins_setl_id"`
  5782. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5783. ClrWay string `json:"clr_way"`
  5784. OthPay float64 `json:"oth_pay"`
  5785. Gend string `json:"gend"`
  5786. MdtrtID string `json:"mdtrt_id"`
  5787. AcctPay float64 `json:"acct_pay"`
  5788. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5789. Insutype string `json:"insutype"`
  5790. Invono interface{} `json:"invono"`
  5791. Enddate string `json:"enddate"`
  5792. CashPayamt float64 `json:"cash_payamt"`
  5793. PsnType string `json:"psn_type"`
  5794. FixmedinsName string `json:"fixmedins_name"`
  5795. HifpPay float64 `json:"hifp_pay"`
  5796. NewFlag interface{} `json:"new_flag"`
  5797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5799. PayLoc string `json:"pay_loc"`
  5800. ClrType string `json:"clr_type"`
  5801. RefdSetlFlag string `json:"refd_setl_flag"`
  5802. CvlservFlag string `json:"cvlserv_flag"`
  5803. EmpName string `json:"emp_name"`
  5804. Brdy string `json:"brdy"`
  5805. Naty string `json:"naty"`
  5806. Certno string `json:"certno"`
  5807. DiseCode string `json:"dise_code"`
  5808. FixmedinsCode string `json:"fixmedins_code"`
  5809. DedcHospLv string `json:"dedc_hosp_lv"`
  5810. OpterName string `json:"opter_name"`
  5811. Balc float64 `json:"balc"`
  5812. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5813. PsnCertType string `json:"psn_cert_type"`
  5814. HifobPay float64 `json:"hifob_pay"`
  5815. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5816. HifesPay float64 `json:"hifes_pay"`
  5817. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5818. OptTime string `json:"opt_time"`
  5819. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5820. SetlID string `json:"setl_id"`
  5821. MafPay float64 `json:"maf_pay"`
  5822. PsnName string `json:"psn_name"`
  5823. InsuOptins interface{} `json:"insu_optins"`
  5824. PrefFundPay interface{} `json:"pref_fund_pay"`
  5825. ClrOptins string `json:"clr_optins"`
  5826. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5827. DiseName string `json:"dise_name"`
  5828. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5829. Age float64 `json:"age"`
  5830. DtrtCertType string `json:"dtrt_cert_type"`
  5831. HospLv string `json:"hosp_lv"`
  5832. PsnCashPay float64
  5833. } `json:"setlinfo"`
  5834. } `json:"output"`
  5835. RefmsgTime string `json:"refmsg_time"`
  5836. RespondTime string `json:"respond_time"`
  5837. Signtype interface{} `json:"signtype"`
  5838. WarnMsg interface{} `json:"warn_msg"`
  5839. }
  5840. type ResultTwelve struct {
  5841. Cainfo string `json:"cainfo"`
  5842. ErrMsg string `json:"err_msg"`
  5843. InfRefmsgid string `json:"inf_refmsgid"`
  5844. Infcode int64 `json:"infcode"`
  5845. Output struct {
  5846. MdtrtId string `json:"mdtrt_id"`
  5847. ChrgBchno string `json:"chrg_bchno"`
  5848. PsnNo string `json:"psn_no"`
  5849. } `json:"output"`
  5850. RefmsgTime string `json:"refmsg_time"`
  5851. RespondTime string `json:"respond_time"`
  5852. Signtype interface{} `json:"signtype"`
  5853. WarnMsg interface{} `json:"warn_msg"`
  5854. }
  5855. type ResultThirteen struct {
  5856. ErrMsg string `json:"err_msg"`
  5857. InfRefmsgid string `json:"inf_refmsgid"`
  5858. Infcode int64 `json:"infcode"`
  5859. Output struct {
  5860. Result struct {
  5861. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  5862. } `json:"result"`
  5863. } `json:"output"`
  5864. RefmsgTime string `json:"refmsg_time"`
  5865. RespondTime string `json:"respond_time"`
  5866. Signtype interface{} `json:"signtype"`
  5867. WarnInfo interface{} `json:"warn_info"`
  5868. }
  5869. type ResultThirteen10265 struct {
  5870. ErrMsg string `json:"err_msg"`
  5871. InfRefmsgid string `json:"inf_refmsgid"`
  5872. Infcode string `json:"infcode"`
  5873. Output struct {
  5874. Result struct {
  5875. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  5876. } `json:"result"`
  5877. } `json:"output"`
  5878. RefmsgTime string `json:"refmsg_time"`
  5879. RespondTime string `json:"respond_time"`
  5880. Signtype interface{} `json:"signtype"`
  5881. WarnInfo interface{} `json:"warn_info"`
  5882. }
  5883. type ResultFourteen struct {
  5884. ErrMsg string `json:"err_msg"`
  5885. InfRefmsgid string `json:"inf_refmsgid"`
  5886. Infcode int64 `json:"infcode"`
  5887. Output struct {
  5888. } `json:"output"`
  5889. RefmsgTime string `json:"refmsg_time"`
  5890. RespondTime string `json:"respond_time"`
  5891. Signtype interface{} `json:"signtype"`
  5892. WarnInfo interface{} `json:"warn_info"`
  5893. }
  5894. type ResultFourteen10265 struct {
  5895. ErrMsg string `json:"err_msg"`
  5896. InfRefmsgid string `json:"inf_refmsgid"`
  5897. Infcode string `json:"infcode"`
  5898. Output struct {
  5899. } `json:"output"`
  5900. RefmsgTime string `json:"refmsg_time"`
  5901. RespondTime string `json:"respond_time"`
  5902. Signtype interface{} `json:"signtype"`
  5903. WarnInfo interface{} `json:"warn_info"`
  5904. }
  5905. type ResultSixteen struct {
  5906. Cainfo string `json:"cainfo"`
  5907. ErrMsg string `json:"err_msg"`
  5908. InfRefmsgid string `json:"inf_refmsgid"`
  5909. Infcode int64 `json:"infcode"`
  5910. Output struct {
  5911. Setldetail []interface{} `json:"setldetail"`
  5912. Setlinfo struct {
  5913. MdtrtID string `json:"mdtrt_id"`
  5914. SetlID string `json:"setl_id"`
  5915. ClrOptins string `json:"clr_optins"`
  5916. SetlTime string `json:"setl_time"`
  5917. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5918. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5919. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5920. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5921. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5922. ActPayDedc float64 `json:"act_pay_dedc"`
  5923. HifpPay float64 `json:"hifp_pay"`
  5924. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5925. Lfpay float64 `json:"selfpay"`
  5926. CvlservPay float64 `json:"cvlserv_pay"`
  5927. HifesPay float64 `json:"hifes_pay"`
  5928. HifmiPay float64 `json:"hifmi_pay"`
  5929. HifobPay float64 `json:"hifob_pay"`
  5930. MafPay float64 `json:"maf_pay"`
  5931. OthPay float64 `json:"oth_pay"`
  5932. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5933. PsnPartAmt float64 `json:"psn_part_amt"`
  5934. AcctPay float64 `json:"acct_pay"`
  5935. Balc float64 `json:"balc"`
  5936. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5937. HospPartAmt float64 `json:"hosp_part_amt"`
  5938. MedinsSetlID string `json:"medins_setl_id"`
  5939. PdnCashPay string `json:"pdn_cash_pay"`
  5940. } `json:"setlinfo"`
  5941. } `json:"output"`
  5942. RefmsgTime string `json:"refmsg_time"`
  5943. RespondTime string `json:"respond_time"`
  5944. Signtype interface{} `json:"signtype"`
  5945. WarnMsg interface{} `json:"warn_msg"`
  5946. }
  5947. type ResultSixteen10265 struct {
  5948. Cainfo string `json:"cainfo"`
  5949. ErrMsg string `json:"err_msg"`
  5950. InfRefmsgid string `json:"inf_refmsgid"`
  5951. Infcode string `json:"infcode"`
  5952. Output struct {
  5953. Setldetail []interface{} `json:"setldetail"`
  5954. Setlinfo struct {
  5955. MdtrtID string `json:"mdtrt_id"`
  5956. SetlID string `json:"setl_id"`
  5957. ClrOptins string `json:"clr_optins"`
  5958. SetlTime string `json:"setl_time"`
  5959. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5960. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5961. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5962. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5964. ActPayDedc float64 `json:"act_pay_dedc"`
  5965. HifpPay float64 `json:"hifp_pay"`
  5966. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5967. Lfpay float64 `json:"selfpay"`
  5968. CvlservPay float64 `json:"cvlserv_pay"`
  5969. HifesPay float64 `json:"hifes_pay"`
  5970. HifmiPay float64 `json:"hifmi_pay"`
  5971. HifobPay float64 `json:"hifob_pay"`
  5972. MafPay float64 `json:"maf_pay"`
  5973. OthPay float64 `json:"oth_pay"`
  5974. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5975. PsnPartAmt float64 `json:"psn_part_amt"`
  5976. AcctPay float64 `json:"acct_pay"`
  5977. Balc float64 `json:"balc"`
  5978. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5979. HospPartAmt float64 `json:"hosp_part_amt"`
  5980. MedinsSetlID string `json:"medins_setl_id"`
  5981. PdnCashPay string `json:"pdn_cash_pay"`
  5982. } `json:"setlinfo"`
  5983. } `json:"output"`
  5984. RefmsgTime string `json:"refmsg_time"`
  5985. RespondTime string `json:"respond_time"`
  5986. Signtype interface{} `json:"signtype"`
  5987. WarnMsg interface{} `json:"warn_msg"`
  5988. }
  5989. type ResultSeventeen struct {
  5990. ErrMsg string `json:"err_msg"`
  5991. InfRefmsgid string `json:"inf_refmsgid"`
  5992. Infcode int64 `json:"infcode"`
  5993. Output struct {
  5994. SetlListId string `json:"setl_list_id"`
  5995. } `json:"output"`
  5996. RefmsgTime string `json:"refmsg_time"`
  5997. RespondTime string `json:"respond_time"`
  5998. Signtype string `json:"signtype"`
  5999. WarnInfo string `json:"warn_info"`
  6000. }
  6001. type ResultSeventeenOther struct {
  6002. ErrMsg string `json:"err_msg"`
  6003. InfRefmsgid string `json:"inf_refmsgid"`
  6004. Infcode string `json:"infcode"`
  6005. Output struct {
  6006. SetlListId string `json:"setl_list_id"`
  6007. } `json:"output"`
  6008. RefmsgTime string `json:"refmsg_time"`
  6009. RespondTime string `json:"respond_time"`
  6010. Signtype string `json:"signtype"`
  6011. WarnInfo string `json:"warn_info"`
  6012. }
  6013. type Result90991 struct {
  6014. ErrMsg string `json:"err_msg"`
  6015. InfRefmsgid string `json:"inf_refmsgid"`
  6016. Infcode int64 `json:"infcode"`
  6017. Output struct {
  6018. Result struct {
  6019. PsnNo string `json:"psn_no"`
  6020. CardStat string `json:"card_stat"`
  6021. Certno string `json:"certno"`
  6022. PsnName string `json:"psn_name"`
  6023. CheckStat string `json:"check_stat"`
  6024. SscnoCheckStat string `json:"sscno_check_stat"`
  6025. } `json:"result"`
  6026. } `json:"output"`
  6027. RefmsgTime string `json:"refmsg_time"`
  6028. RespondTime string `json:"respond_time"`
  6029. Signtype interface{} `json:"signtype"`
  6030. WarnInfo interface{} `json:"warn_info"`
  6031. }
  6032. type Result90100 struct {
  6033. ErrMsg string `json:"err_msg"`
  6034. InfRefmsgid string `json:"inf_refmsgid"`
  6035. Infcode int64 `json:"infcode"`
  6036. Output struct {
  6037. PoolareaNo string `json:"poolarea_no"`
  6038. PoolareaNoName string `json:"poolarea_no_name"`
  6039. Insutype string `json:"insutype"`
  6040. InsutypeName string `json:"insutype_name"`
  6041. ClctType string `json:"clct_type"`
  6042. ClctTypeName string `json:"clct_type_name"`
  6043. ClctFlag string `json:"clct_flag"`
  6044. ClctFlagName string `json:"clct_flag_name"`
  6045. AccrymBegn string `json:"accrym_begn"`
  6046. AccrymEnd string `json:"accrym_end"`
  6047. ClctTime string `json:"clct_time"`
  6048. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6049. } `json:"output"`
  6050. RefmsgTime string `json:"refmsg_time"`
  6051. RespondTime string `json:"respond_time"`
  6052. Signtype interface{} `json:"signtype"`
  6053. WarnInfo interface{} `json:"warn_info"`
  6054. }
  6055. type Custom struct {
  6056. DetItemFeeSumamt string
  6057. Cut string
  6058. FeedetlSn string
  6059. Price string
  6060. MedListCodg string
  6061. Type int64
  6062. AdviceId int64
  6063. ProjectId int64
  6064. ItemId int64
  6065. }
  6066. type Result5301 struct {
  6067. ErrMsg string `json:"err_msg"`
  6068. InfRefmsgid string `json:"inf_refmsgid"`
  6069. Infcode int64 `json:"infcode"`
  6070. Output struct {
  6071. Result []struct {
  6072. OpspDiseCode string `json:"opsp_dise_code"`
  6073. OpspDiseName string `json:"opsp_dise_name"`
  6074. Begndate string `json:"begndate"`
  6075. Enddate string `json:"enddate"`
  6076. } `json:"feedetail"`
  6077. } `json:"output"`
  6078. RefmsgTime string `json:"refmsg_time"`
  6079. RespondTime string `json:"respond_time"`
  6080. Signtype interface{} `json:"signtype"`
  6081. WarnInfo interface{} `json:"warn_info"`
  6082. }
  6083. type Result5301For10265 struct {
  6084. ErrMsg string `json:"err_msg"`
  6085. InfRefmsgid string `json:"inf_refmsgid"`
  6086. Infcode string `json:"infcode"`
  6087. Output struct {
  6088. Result []struct {
  6089. OpspDiseCode string `json:"opsp_dise_code"`
  6090. OpspDiseName string `json:"opsp_dise_name"`
  6091. Begndate string `json:"begndate"`
  6092. Enddate string `json:"enddate"`
  6093. } `json:"feedetail"`
  6094. } `json:"output"`
  6095. RefmsgTime string `json:"refmsg_time"`
  6096. RespondTime string `json:"respond_time"`
  6097. Signtype interface{} `json:"signtype"`
  6098. WarnInfo interface{} `json:"warn_info"`
  6099. }
  6100. //获取个人信息----挂号-----上传就诊信息
  6101. func (c *HisApiController) GetRegisterInfo() {
  6102. id, _ := c.GetInt64("id")
  6103. record_time := c.GetString("record_time")
  6104. settlementValue, _ := c.GetInt64("settlement_value")
  6105. medical_insurance_card := c.GetString("medical_insurance_card")
  6106. name := c.GetString("name")
  6107. id_card_type, _ := c.GetInt64("id_card_type")
  6108. certificates, _ := c.GetInt64("certificates")
  6109. medical_care, _ := c.GetInt64("medical_care")
  6110. birthday := c.GetString("birthday")
  6111. id_card := c.GetString("id_card")
  6112. register_type, _ := c.GetInt64("register")
  6113. doctor, _ := c.GetInt64("doctor")
  6114. department, _ := c.GetInt64("department")
  6115. gender, _ := c.GetInt64("sex")
  6116. registration_fee, _ := c.GetFloat("registration_fee")
  6117. medical_expenses, _ := c.GetFloat("medical_expenses")
  6118. social_type, _ := c.GetInt64("social_type")
  6119. med_type := c.GetString("social_type")
  6120. admin_user_id, _ := c.GetInt64("admin_user_id")
  6121. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6122. timeLayout := "2006-01-02"
  6123. loc, _ := time.LoadLocation("Local")
  6124. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6125. birthUnix := birthdays.Unix()
  6126. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6127. if err != nil {
  6128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6129. return
  6130. }
  6131. recordDateTime := theTime.Unix()
  6132. adminInfo := c.GetAdminUserInfo()
  6133. var patient service.Patients
  6134. if id == 0 {
  6135. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6136. } else {
  6137. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6138. }
  6139. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6140. if patientPrescription.ID == 0 {
  6141. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6142. }
  6143. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6144. if patient.ID == 0 {
  6145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6146. return
  6147. }
  6148. if len(patient.IdCardNo) == 0 {
  6149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6150. return
  6151. }
  6152. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6153. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6154. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6155. //就诊结算未完成,不能进行二次挂号
  6156. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6157. if len(his) >= 1 {
  6158. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6159. if len(his) >= 1 && order.ID == 0 {
  6160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6161. return
  6162. }
  6163. }
  6164. //var register_log string
  6165. if config.IsOpen == 1 {
  6166. var res ResultTwo
  6167. var res10265 ResultTwo10265
  6168. var PsnNo string
  6169. var PsnCertType string
  6170. var Certno string
  6171. var PsnName string
  6172. var Gend string
  6173. var Naty string
  6174. var Brdy string
  6175. var Age float64
  6176. var infoStr string
  6177. var idetinfoStr string
  6178. var infocode int64
  6179. var verify_number string
  6180. fmt.Println(verify_number)
  6181. if miConfig.MdtrtareaAdmvs == "421300" {
  6182. psn_info, _ := service.GetPsnByPatientId(id)
  6183. PsnNo = psn_info.PsnNo
  6184. PsnCertType = psn_info.PsnCertType
  6185. Certno = psn_info.Certno
  6186. PsnName = psn_info.PsnName
  6187. Gend = psn_info.Gend
  6188. Naty = psn_info.Naty
  6189. Brdy = psn_info.Brdy
  6190. Age = psn_info.Age
  6191. infoStr = psn_info.Insuinfo
  6192. idetinfoStr = psn_info.Idetinfo
  6193. infocode = 0
  6194. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6195. psn_info, _ := service.GetPsnByPatientId(id)
  6196. PsnNo = psn_info.PsnNo
  6197. PsnCertType = psn_info.PsnCertType
  6198. Certno = psn_info.Certno
  6199. PsnName = psn_info.PsnName
  6200. Gend = psn_info.Gend
  6201. Naty = psn_info.Naty
  6202. Brdy = psn_info.Brdy
  6203. Age = psn_info.Age
  6204. infoStr = psn_info.Insuinfo
  6205. idetinfoStr = psn_info.Idetinfo
  6206. infocode = 0
  6207. verify_number = psn_info.VerifyNumber
  6208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6209. if id_card_type == 1 {
  6210. psn_info, _ := service.GetPsnByPatientId(id)
  6211. PsnNo = psn_info.PsnNo
  6212. PsnCertType = psn_info.PsnCertType
  6213. Certno = psn_info.Certno
  6214. PsnName = psn_info.PsnName
  6215. Gend = psn_info.Gend
  6216. Naty = psn_info.Naty
  6217. Brdy = psn_info.Brdy
  6218. Age = psn_info.Age
  6219. infoStr = psn_info.Insuinfo
  6220. idetinfoStr = psn_info.Idetinfo
  6221. infocode = 0
  6222. verify_number = psn_info.VerifyNumber
  6223. } else if id_card_type == 2 {
  6224. 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)
  6225. fmt.Println(errMsgLog)
  6226. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6227. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6228. utils.ErrorLog("解析失败:%v", err)
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. return
  6231. }
  6232. PsnNo = res.Output.Baseinfo.PsnNo
  6233. PsnCertType = res.Output.Baseinfo.PsnCertType
  6234. Certno = res.Output.Baseinfo.Certno
  6235. PsnName = res.Output.Baseinfo.PsnName
  6236. Gend = res.Output.Baseinfo.Gend
  6237. Naty = res.Output.Baseinfo.Naty
  6238. Brdy = res.Output.Baseinfo.Brdy
  6239. Age = res.Output.Baseinfo.Age
  6240. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6241. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6242. infoStr = string(Iinfos)
  6243. idetinfoStr = string(Idetinfos)
  6244. infocode = res.Infcode
  6245. }
  6246. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6247. if id_card_type == 1 {
  6248. psn_info, _ := service.GetPsnByPatientId(id)
  6249. PsnNo = psn_info.PsnNo
  6250. PsnCertType = psn_info.PsnCertType
  6251. Certno = psn_info.Certno
  6252. PsnName = psn_info.PsnName
  6253. Gend = psn_info.Gend
  6254. Naty = psn_info.Naty
  6255. Brdy = psn_info.Brdy
  6256. Age = psn_info.Age
  6257. infoStr = psn_info.Insuinfo
  6258. idetinfoStr = psn_info.Idetinfo
  6259. infocode = 0
  6260. verify_number = psn_info.VerifyNumber
  6261. } else if id_card_type == 2 {
  6262. 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, "")
  6263. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6264. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6265. utils.ErrorLog("解析失败:%v", err)
  6266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6267. return
  6268. }
  6269. PsnNo = res.Output.Baseinfo.PsnNo
  6270. PsnCertType = res.Output.Baseinfo.PsnCertType
  6271. Certno = res.Output.Baseinfo.Certno
  6272. PsnName = res.Output.Baseinfo.PsnName
  6273. Gend = res.Output.Baseinfo.Gend
  6274. Naty = res.Output.Baseinfo.Naty
  6275. Brdy = res.Output.Baseinfo.Brdy
  6276. Age = res.Output.Baseinfo.Age
  6277. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6278. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6279. infoStr = string(Iinfos)
  6280. idetinfoStr = string(Idetinfos)
  6281. infocode = res.Infcode
  6282. }
  6283. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6284. if id_card_type == 1 {
  6285. psn_info, _ := service.GetPsnByPatientId(id)
  6286. PsnNo = psn_info.PsnNo
  6287. PsnCertType = psn_info.PsnCertType
  6288. Certno = psn_info.Certno
  6289. PsnName = psn_info.PsnName
  6290. Gend = psn_info.Gend
  6291. Naty = psn_info.Naty
  6292. Brdy = psn_info.Brdy
  6293. Age = psn_info.Age
  6294. infoStr = psn_info.Insuinfo
  6295. idetinfoStr = psn_info.Idetinfo
  6296. infocode = 0
  6297. verify_number = psn_info.VerifyNumber
  6298. } else if id_card_type == 2 {
  6299. 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, "")
  6300. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6302. utils.ErrorLog("解析失败:%v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. return
  6305. }
  6306. PsnNo = res.Output.Baseinfo.PsnNo
  6307. PsnCertType = res.Output.Baseinfo.PsnCertType
  6308. Certno = res.Output.Baseinfo.Certno
  6309. PsnName = res.Output.Baseinfo.PsnName
  6310. Gend = res.Output.Baseinfo.Gend
  6311. Naty = res.Output.Baseinfo.Naty
  6312. Brdy = res.Output.Baseinfo.Brdy
  6313. Age = res.Output.Baseinfo.Age
  6314. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6315. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6316. infoStr = string(Iinfos)
  6317. idetinfoStr = string(Idetinfos)
  6318. infocode = res.Infcode
  6319. }
  6320. } else {
  6321. var result string
  6322. var requestLog string
  6323. if miConfig.UserOrgId == 10138 {
  6324. if id_card_type != 4 {
  6325. //psn_info, _ := service.GetPsnByPatientId(id)
  6326. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6327. 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)
  6328. }
  6329. } else {
  6330. 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)
  6331. }
  6332. if id_card_type == 4 {
  6333. psn_info, _ := service.GetPsnByPatientId(id)
  6334. PsnNo = psn_info.PsnNo
  6335. PsnCertType = psn_info.PsnCertType
  6336. Certno = psn_info.Certno
  6337. PsnName = psn_info.PsnName
  6338. Gend = psn_info.Gend
  6339. Naty = psn_info.Naty
  6340. Brdy = psn_info.Brdy
  6341. Age = psn_info.Age
  6342. infoStr = psn_info.Insuinfo
  6343. idetinfoStr = psn_info.Idetinfo
  6344. infocode = 0
  6345. verify_number = psn_info.VerifyNumber
  6346. } else {
  6347. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6348. if miConfig.Code == "H15049901371" {
  6349. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6350. utils.ErrorLog("解析失败:%v", err)
  6351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6352. return
  6353. }
  6354. res.ErrMsg = res10265.ErrMsg
  6355. res.Output = res10265.Output
  6356. res.InfRefmsgid = res10265.InfRefmsgid
  6357. } else {
  6358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6359. utils.ErrorLog("解析失败:%v", err)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. }
  6364. PsnNo = res.Output.Baseinfo.PsnNo
  6365. PsnCertType = res.Output.Baseinfo.PsnCertType
  6366. Certno = res.Output.Baseinfo.Certno
  6367. PsnName = res.Output.Baseinfo.PsnName
  6368. Gend = res.Output.Baseinfo.Gend
  6369. Naty = res.Output.Baseinfo.Naty
  6370. Brdy = res.Output.Baseinfo.Brdy
  6371. Age = res.Output.Baseinfo.Age
  6372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6374. infoStr = string(Iinfos)
  6375. idetinfoStr = string(Idetinfos)
  6376. if miConfig.Code == "H15049901371" {
  6377. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6378. } else {
  6379. infocode = res.Infcode
  6380. }
  6381. }
  6382. }
  6383. if infocode == 0 {
  6384. his := models.VMHisPatient{
  6385. Name: name,
  6386. Gender: gender,
  6387. Birthday: birthUnix,
  6388. MedicalTreatmentType: medical_care,
  6389. IdType: certificates,
  6390. IdCardNo: id_card,
  6391. BalanceAccountsType: settlementValue,
  6392. SocialType: social_type,
  6393. MedicalInsuranceNumber: medical_insurance_card,
  6394. RegisterType: register_type,
  6395. RegisterCost: registration_fee,
  6396. TreatmentCost: medical_expenses,
  6397. Status: 1,
  6398. Ctime: time.Now().Unix(),
  6399. Mtime: time.Now().Unix(),
  6400. PsnNo: PsnNo,
  6401. PsnCertType: PsnCertType,
  6402. Certno: Certno,
  6403. PsnName: PsnName,
  6404. Gend: Gend,
  6405. Naty: Naty,
  6406. Brdy: Brdy,
  6407. Age: Age,
  6408. Iinfo: infoStr,
  6409. Idetinfo: idetinfoStr,
  6410. PatientId: patient.ID,
  6411. RecordDate: theTime.Unix(),
  6412. UserOrgId: adminInfo.CurrentOrgId,
  6413. AdminUserId: admin_user_id,
  6414. IsReturn: 1,
  6415. IdCardType: id_card_type,
  6416. Doctor: doctor,
  6417. Departments: department,
  6418. }
  6419. timestamp := time.Now().Unix()
  6420. tempTime := time.Unix(timestamp, 0)
  6421. timeFormat := tempTime.Format("20060102150405")
  6422. chrgBchno := rand.Intn(100000) + 10000
  6423. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6424. his.Number = ipt_otp_no
  6425. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6426. department, _ := service.GetDepartMentDetail(department)
  6427. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6428. IdCardNo := ""
  6429. if id_card_type == 1 {
  6430. // IdCardNo = medical_insurance_card
  6431. IdCardNo = patient.IdCardNo
  6432. } else {
  6433. IdCardNo = patient.IdCardNo
  6434. }
  6435. var rf []*ResultFive
  6436. json.Unmarshal([]byte(his.Iinfo), &rf)
  6437. var insutypes []*ResultFive
  6438. var insutype string
  6439. var insuplc_admdvs_temp string
  6440. var is390 int = 0
  6441. var is310 int = 0
  6442. for _, item := range rf {
  6443. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6444. insutypes = append(insutypes, item)
  6445. }
  6446. }
  6447. if len(insutypes) == 1 {
  6448. insutype = insutypes[0].Insutype
  6449. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6450. } else {
  6451. for _, i := range insutypes {
  6452. if i.Insutype == "390" {
  6453. is390 = 1
  6454. }
  6455. if i.Insutype == "310" {
  6456. is310 = 1
  6457. }
  6458. }
  6459. }
  6460. if is390 == 1 {
  6461. insutype = "390"
  6462. }
  6463. if is310 == 1 {
  6464. insutype = "310"
  6465. }
  6466. if len(insutypes) == 0 {
  6467. insutype = "310"
  6468. }
  6469. if len(insutypes) == 2 {
  6470. insutype = med_type
  6471. }
  6472. if len(med_type) > 0 {
  6473. insutype = med_type
  6474. }
  6475. var infocode int64
  6476. var resThree ResultThree
  6477. var resThree10265 ResultThree10265
  6478. if len(insuplc_admdvs) == 0 {
  6479. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6480. } else {
  6481. insuplc_admdvs_temp = insuplc_admdvs
  6482. }
  6483. if miConfig.MdtrtareaAdmvs == "421300" {
  6484. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6485. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6486. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6487. "&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
  6488. resp, requestErr := http.Get(api)
  6489. if requestErr != nil {
  6490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6491. return
  6492. }
  6493. body, ioErr := ioutil.ReadAll(resp.Body)
  6494. if ioErr != nil {
  6495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6497. return
  6498. }
  6499. var respJSON map[string]interface{}
  6500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. return
  6504. }
  6505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6506. result, _ := json.Marshal(respJSON)
  6507. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6508. utils.ErrorLog("解析失败:%v", err)
  6509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6510. return
  6511. }
  6512. infocode = resThree.Infcode
  6513. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6514. psn_info, _ := service.GetPsnByPatientId(id)
  6515. his.PsnNo = psn_info.PsnNo
  6516. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6517. var cert_no string
  6518. if id_card_type == 3 {
  6519. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6520. cert_no = IdCardNo
  6521. } else if id_card_type == 4 {
  6522. cert_no = IdCardNo
  6523. psn_info.VerifyNumber = psn_info.VerifyNumber
  6524. } else {
  6525. bas := strings.Split(psn_info.CardInfo, "|")
  6526. cert_no = bas[2]
  6527. }
  6528. var hisPrescription []*models.HisPrescription
  6529. for _, item := range rf {
  6530. if item.Insutype == insutype {
  6531. //insuplc_admdvs = item.InsuplcAdmdvs
  6532. his.InsuplcAdmdvs = insuplc_admdvs
  6533. }
  6534. }
  6535. his.Insutype = insutype
  6536. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6537. fmt.Println(res3101)
  6538. fmt.Println(res3101.Infcode)
  6539. if res3101.Infcode == "0" {
  6540. fmt.Println("33333333")
  6541. if len(res3101.Output.Result) > 0 {
  6542. fmt.Println("222222")
  6543. for _, item := range res3101.Output.Result {
  6544. if len(res3101.ErrMsg) == 0 {
  6545. res3101.ErrMsg = item.VolaCont
  6546. } else {
  6547. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6548. }
  6549. }
  6550. c.ServeSuccessJSON(map[string]interface{}{
  6551. "failed_code": -10,
  6552. "msg": res3101.ErrMsg,
  6553. })
  6554. return
  6555. } else {
  6556. fmt.Println("11111")
  6557. var api string
  6558. if miConfig.MdtrtareaAdmvs == "320921" {
  6559. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6560. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6561. "&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
  6562. } else {
  6563. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6564. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6565. "&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
  6566. }
  6567. resp, requestErr := http.Get(api)
  6568. if requestErr != nil {
  6569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6570. return
  6571. }
  6572. body, ioErr := ioutil.ReadAll(resp.Body)
  6573. if ioErr != nil {
  6574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. return
  6577. }
  6578. var respJSON map[string]interface{}
  6579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6582. return
  6583. }
  6584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6585. result, _ := json.Marshal(respJSON)
  6586. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6587. utils.ErrorLog("解析失败:%v", err)
  6588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6589. return
  6590. }
  6591. resThree.ErrMsg = resThree10265.ErrMsg
  6592. resThree.Output = resThree10265.Output
  6593. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6594. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6595. }
  6596. } else if res3101.Infcode != "0" {
  6597. c.ServeSuccessJSON(map[string]interface{}{
  6598. "failed_code": -10,
  6599. "msg": res3101.ErrMsg,
  6600. })
  6601. return
  6602. }
  6603. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6604. psn_info, _ := service.GetPsnByPatientId(id)
  6605. var cert_no string
  6606. if id_card_type == 1 {
  6607. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6608. } else if id_card_type == 4 {
  6609. cert_no = psn_info.VerifyNumber
  6610. } else {
  6611. cert_no = psn_info.VerifyNumber
  6612. }
  6613. 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)
  6614. saveLog(result, requestLog, "2201", "挂号")
  6615. if miConfig.Code == "H15049901371" {
  6616. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6617. utils.ErrorLog("解析失败:%v", err)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. return
  6620. }
  6621. resThree.ErrMsg = resThree10265.ErrMsg
  6622. resThree.Output = resThree10265.Output
  6623. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6624. } else {
  6625. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6626. utils.ErrorLog("解析失败:%v", err)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. return
  6629. }
  6630. }
  6631. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6632. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  6633. psn_info, _ := service.GetPsnByPatientId(id)
  6634. var result string
  6635. var requestLog string
  6636. if id_card_type == 1 {
  6637. bas := strings.Split(psn_info.CardInfo, "|")
  6638. basNumber := bas[2]
  6639. card_sn := bas[3]
  6640. 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)
  6641. saveLog(result, requestLog, "2201A", "挂号")
  6642. } else if id_card_type == 2 {
  6643. 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, "", "")
  6644. saveLog(result, requestLog, "2201A", "挂号")
  6645. } else {
  6646. 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, "", "")
  6647. saveLog(result, requestLog, "2201A", "挂号")
  6648. }
  6649. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6650. utils.ErrorLog("解析失败:%v", err)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. return
  6653. }
  6654. infocode = resThree.Infcode
  6655. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  6656. psn_info, _ := service.GetPsnByPatientId(id)
  6657. var result string
  6658. var requestLog string
  6659. if id_card_type == 1 {
  6660. bas := strings.Split(psn_info.CardInfo, "|")
  6661. basNumber := bas[2]
  6662. card_sn := bas[3]
  6663. 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)
  6664. saveLog(result, requestLog, "2201A", "挂号")
  6665. } else if id_card_type == 2 {
  6666. 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, "", "")
  6667. saveLog(result, requestLog, "2201A", "挂号")
  6668. } else {
  6669. 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, "", "")
  6670. saveLog(result, requestLog, "2201A", "挂号")
  6671. }
  6672. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6673. utils.ErrorLog("解析失败:%v", err)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return
  6676. }
  6677. infocode = resThree.Infcode
  6678. } else {
  6679. psn_info, _ := service.GetPsnByPatientId(id)
  6680. 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)
  6681. saveLog(result, requestLog, "2201A", "挂号")
  6682. if miConfig.Code == "H15049901371" {
  6683. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6684. utils.ErrorLog("解析失败:%v", err)
  6685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6686. return
  6687. }
  6688. resThree.ErrMsg = resThree10265.ErrMsg
  6689. resThree.Output = resThree10265.Output
  6690. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6691. } else {
  6692. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6693. utils.ErrorLog("解析失败:%v", err)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. }
  6698. if miConfig.Code == "H15049901371" {
  6699. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6700. } else {
  6701. infocode = resThree.Infcode
  6702. }
  6703. }
  6704. if infocode != 0 {
  6705. adminUser := c.GetAdminUserInfo()
  6706. errlog := &models.HisOrderError{
  6707. UserOrgId: adminUser.CurrentOrgId,
  6708. Ctime: time.Now().Unix(),
  6709. Mtime: time.Now().Unix(),
  6710. ErrMsg: resThree.ErrMsg,
  6711. Status: 1,
  6712. PatientId: id,
  6713. RecordTime: recordDateTime,
  6714. Stage: 2,
  6715. }
  6716. service.CreateErrMsgLog(errlog)
  6717. c.ServeSuccessJSON(map[string]interface{}{
  6718. "failed_code": -10,
  6719. "msg": resThree.ErrMsg,
  6720. })
  6721. return
  6722. }
  6723. his.Number = resThree.Output.Data.MdtrtID
  6724. his.PsnNo = resThree.Output.Data.PsnNo
  6725. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  6726. his.IdCardNo = patient.IdCardNo
  6727. his.PhoneNumber = patient.Phone
  6728. his.UserOrgId = adminInfo.CurrentOrgId
  6729. his.Insutype = insutype
  6730. his.Ctime = time.Now().Unix()
  6731. his.Mtime = time.Now().Unix()
  6732. his.InsuplcAdmdvs = insuplc_admdvs_temp
  6733. his.Status = 1
  6734. service.UpdateHisPatientStatus(&his)
  6735. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  6736. c.ServeSuccessJSON(map[string]interface{}{
  6737. "his_info": his,
  6738. })
  6739. } else {
  6740. adminUser := c.GetAdminUserInfo()
  6741. errlog := &models.HisOrderError{
  6742. UserOrgId: adminUser.CurrentOrgId,
  6743. Ctime: time.Now().Unix(),
  6744. Mtime: time.Now().Unix(),
  6745. ErrMsg: res.ErrMsg,
  6746. Status: 1,
  6747. PatientId: id,
  6748. RecordTime: recordDateTime,
  6749. Stage: 1,
  6750. }
  6751. service.CreateErrMsgLog(errlog)
  6752. c.ServeSuccessJSON(map[string]interface{}{
  6753. "failed_code": -10,
  6754. "msg": res.ErrMsg,
  6755. })
  6756. return
  6757. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6758. }
  6759. }
  6760. }
  6761. //上传明细----预结算----确认订单
  6762. func (c *HisApiController) GetUploadInfo() {
  6763. id, _ := c.GetInt64("id")
  6764. record_time := c.GetString("record_time")
  6765. his_patient_id, _ := c.GetInt64("his_patient_id")
  6766. order_id, _ := c.GetInt64("order_id")
  6767. pay_way, _ := c.GetInt64("pay_way")
  6768. pay_price, _ := c.GetFloat("pay_price")
  6769. pay_card_no := c.GetString("pay_card_no")
  6770. discount_price, _ := c.GetFloat("discount_price")
  6771. preferential_price, _ := c.GetFloat("preferential_price")
  6772. reality_price, _ := c.GetFloat("reality_price")
  6773. found_price, _ := c.GetFloat("found_price")
  6774. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6775. private_price, _ := c.GetFloat("private_price")
  6776. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6777. admin_user_id, _ := c.GetInt64("admin_user_id")
  6778. fapiao_code := c.GetString("fapiao_code")
  6779. fapiao_number := c.GetString("fapiao_number")
  6780. diagnosis_id := c.GetString("diagnosis")
  6781. sick_type, _ := c.GetInt64("sick_type")
  6782. reg_type, _ := c.GetInt64("p_type")
  6783. begin_time := c.GetString("begin_time")
  6784. id_str := c.GetString("ids")
  6785. ids_arr := strings.Split(id_str, ",")
  6786. timeLayout := "2006-01-02"
  6787. loc, _ := time.LoadLocation("Local")
  6788. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6789. if err != nil {
  6790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6791. return
  6792. }
  6793. recordDateTime := theTime.Unix()
  6794. adminUser := c.GetAdminUserInfo()
  6795. var tempOrder models.HisOrder
  6796. tempOrder, _ = service.GetHisOrderByID(order_id)
  6797. var prescriptions []*models.HisPrescription
  6798. var start_time int64
  6799. var end_time int64
  6800. //押金模块
  6801. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  6802. tmp_decimal := c.GetString("tmp_decimal")
  6803. var decimal float64 //本次使用的押金
  6804. var errmsg error
  6805. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  6806. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  6807. return
  6808. }
  6809. if len(tmp_decimal) > 0 {
  6810. if tmp_decimal[0] == 45 {
  6811. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  6812. return
  6813. }
  6814. }
  6815. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  6816. fmt.Println(errs)
  6817. decimal = tt
  6818. //if adminUser.CurrentOrgId == 10106{
  6819. // if len(fapiao_code) == 0{
  6820. // fapiao_code = "144072080589"
  6821. // }
  6822. // if len(fapiao_number) == 0{
  6823. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  6824. // if order.ID == 0{
  6825. // fapiao_number = "00001520"
  6826. // }else{
  6827. // //fapiao_code = "00001520"
  6828. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  6829. // var zero string
  6830. // if fpNumber >= 1000{
  6831. // zero = "0000" + strconv.Itoa(fpNumber)
  6832. // }else if fpNumber >= 10000{
  6833. // zero = "000" + strconv.Itoa(fpNumber)
  6834. // } else if fpNumber >= 100000{
  6835. // zero = "00" + strconv.Itoa(fpNumber)
  6836. // } else if fpNumber >= 1000000{
  6837. // zero = "0" + strconv.Itoa(fpNumber)
  6838. // }else {
  6839. // zero = strconv.Itoa(fpNumber)
  6840. // }
  6841. // fapiao_number = zero
  6842. // }
  6843. // }
  6844. //}
  6845. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6846. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6847. var patientPrescription models.HisPrescriptionInfo
  6848. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6849. if patientPrescription.ID == 0 {
  6850. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6851. }
  6852. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6853. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6854. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6855. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6856. var config []*models.HisXtDiagnoseConfig
  6857. for _, item := range diagnosis_ids {
  6858. id, _ := strconv.ParseInt(item, 10, 64)
  6859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6860. config = append(config, &diagnosisConfig)
  6861. }
  6862. sickConfig, _ := service.FindSickById(sick_type)
  6863. //if tempOrder.ID == 0 {
  6864. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  6865. //}
  6866. if tempOrder.ID == 0 {
  6867. var result string
  6868. var requestLog string
  6869. var res2 ResultSix
  6870. var ressix10265 ResultSix10265
  6871. if miConfig.MdtrtareaAdmvs == "421300" {
  6872. data := make(map[string]interface{})
  6873. client := &http.Client{}
  6874. data["psn_no"] = his.PsnNo
  6875. data["mdtrt_id"] = his.Number
  6876. data["opter"] = roles.UserName
  6877. data["org_name"] = miConfig.OrgName
  6878. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6879. data["doctor_id"] = doctor_info.DoctorNumber
  6880. data["doctor_name"] = doctor_info.UserName
  6881. data["department"] = department.Name
  6882. data["fixmedins_code"] = miConfig.Code
  6883. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6884. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6885. data["secret_key"] = miConfig.SecretKey
  6886. data["sick_code"] = sickConfig.CountryCode
  6887. data["sick_name"] = sickConfig.ClassName
  6888. data["dept"] = strconv.FormatInt(department.ID, 10)
  6889. data["config"] = config
  6890. data["begin_time"] = begin_time
  6891. bytesData, _ := json.Marshal(data)
  6892. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6893. resp, _ := client.Do(req)
  6894. defer resp.Body.Close()
  6895. body, ioErr := ioutil.ReadAll(resp.Body)
  6896. if ioErr != nil {
  6897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6899. return
  6900. }
  6901. var respJSON map[string]interface{}
  6902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6905. return
  6906. }
  6907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6908. userJSONBytes, _ := json.Marshal(respJSON)
  6909. fmt.Println("log")
  6910. fmt.Println(string(userJSONBytes))
  6911. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6912. utils.ErrorLog("解析失败:%v", err)
  6913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6914. return
  6915. }
  6916. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6917. data := make(map[string]interface{})
  6918. client := &http.Client{}
  6919. data["psn_no"] = his.PsnNo
  6920. data["mdtrt_id"] = his.Number
  6921. data["doctor"] = roles.UserName
  6922. data["department"] = department.Name
  6923. data["org_name"] = miConfig.OrgName
  6924. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6925. data["doctor_id"] = doctor_info.DoctorNumber
  6926. data["new_doctor_name"] = doctor_info.UserName
  6927. data["fixmedins_code"] = miConfig.Code
  6928. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6929. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6930. data["secret_key"] = miConfig.SecretKey
  6931. data["sick_code"] = sickConfig.CountryCode
  6932. data["sick_name"] = sickConfig.ClassName
  6933. data["url"] = miConfig.Url
  6934. data["ak"] = miConfig.AccessKey
  6935. data["begin_time"] = begin_time
  6936. data["cainfo"] = miConfig.Cainfo
  6937. data["dept"] = strconv.FormatInt(department.ID, 10)
  6938. data["config"] = config
  6939. bytesData, _ := json.Marshal(data)
  6940. var req *http.Request
  6941. if miConfig.MdtrtareaAdmvs == "320921" {
  6942. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6943. //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 +
  6944. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6945. } else {
  6946. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6947. }
  6948. resp, _ := client.Do(req)
  6949. defer resp.Body.Close()
  6950. body, ioErr := ioutil.ReadAll(resp.Body)
  6951. if ioErr != nil {
  6952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. var respJSON map[string]interface{}
  6957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6960. return
  6961. }
  6962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6963. userJSONBytes, _ := json.Marshal(respJSON)
  6964. fmt.Println("log")
  6965. fmt.Println(string(userJSONBytes))
  6966. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6967. utils.ErrorLog("解析失败:%v", err)
  6968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6969. return
  6970. }
  6971. res2.InfRefmsgid = ressix10265.InfRefmsgid
  6972. res2.Output = ressix10265.Output
  6973. res2.ErrMsg = ressix10265.ErrMsg
  6974. res2.Cainfo = ressix10265.Cainfo
  6975. res2.WarnMsg = ressix10265.WarnMsg
  6976. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6977. res2.Infcode = infocode
  6978. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6979. 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)
  6980. saveLog(result, requestLog, "2203", "上传就诊信息")
  6981. var respJSON2 map[string]interface{}
  6982. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. userJSONBytes2, _ := json.Marshal(respJSON2)
  6988. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6989. utils.ErrorLog("解析失败:%v", err)
  6990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6991. return
  6992. }
  6993. } else {
  6994. if miConfig.MdtrtareaAdmvs == "440781" { //
  6995. 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)
  6996. } else {
  6997. if miConfig.Code == "H15049901371" {
  6998. //赤峰地区国家医保医疗类别
  6999. //职工透析:医疗类别选特殊情况门诊990502
  7000. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7001. var med_type string
  7002. if his.Insutype == "390" {
  7003. if reg_type == 14 {
  7004. med_type = "9933"
  7005. } else if reg_type == 11 {
  7006. med_type = "11"
  7007. }
  7008. } else if his.Insutype == "310" {
  7009. if reg_type == 14 {
  7010. med_type = "990502"
  7011. } else if reg_type == 11 {
  7012. med_type = "11"
  7013. }
  7014. }
  7015. 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)
  7016. } else {
  7017. 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)
  7018. }
  7019. }
  7020. saveLog(result, requestLog, "2203", "上传就诊信息")
  7021. var respJSON2 map[string]interface{}
  7022. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. return
  7026. }
  7027. userJSONBytes2, _ := json.Marshal(respJSON2)
  7028. if miConfig.Code == "H15049901371" {
  7029. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7030. utils.ErrorLog("解析失败:%v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7035. res2.Output = ressix10265.Output
  7036. res2.ErrMsg = ressix10265.ErrMsg
  7037. res2.Cainfo = ressix10265.Cainfo
  7038. res2.WarnMsg = ressix10265.WarnMsg
  7039. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7040. res2.Infcode = infocode
  7041. } else {
  7042. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7043. utils.ErrorLog("解析失败:%v", err)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. return
  7046. }
  7047. }
  7048. }
  7049. if res2.Infcode != 0 {
  7050. adminUser := c.GetAdminUserInfo()
  7051. errlog := &models.HisOrderError{
  7052. UserOrgId: adminUser.CurrentOrgId,
  7053. Ctime: time.Now().Unix(),
  7054. Mtime: time.Now().Unix(),
  7055. ErrMsg: res2.ErrMsg,
  7056. Status: 1,
  7057. PatientId: id,
  7058. RecordTime: recordDateTime,
  7059. Stage: 3,
  7060. }
  7061. service.CreateErrMsgLog(errlog)
  7062. c.ServeSuccessJSON(map[string]interface{}{
  7063. "failed_code": -10,
  7064. "msg": res2.ErrMsg,
  7065. })
  7066. return
  7067. } else {
  7068. his.Diagnosis = diagnosis_id
  7069. his.SickType = sickConfig.ID
  7070. //var p_type int64
  7071. //if reg_type == 1111 || reg_type == 1112 {
  7072. // p_type = 11
  7073. //
  7074. //}
  7075. his.PType = fmt.Sprintf("%d", reg_type)
  7076. service.UpdateHisPatientThree(&his)
  7077. data := make(map[string]interface{})
  7078. if settle_accounts_type == 1 { //日结
  7079. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7080. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7081. } else {
  7082. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7083. }
  7084. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7085. data["pre"] = prescriptions
  7086. } else { //月结
  7087. start_time_str := c.GetString("start_time")
  7088. end_time_str := c.GetString("end_time")
  7089. timeLayout := "2006-01-02"
  7090. loc, _ := time.LoadLocation("Local")
  7091. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7092. if err != nil {
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7094. return
  7095. }
  7096. recordStartTime := theStartTime.Unix()
  7097. start_time = recordStartTime
  7098. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7099. if err != nil {
  7100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7101. return
  7102. }
  7103. recordEndTime := theEndTime.Unix()
  7104. end_time = recordEndTime
  7105. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7106. data["pre"] = prescriptions
  7107. }
  7108. timestamp := time.Now().Unix()
  7109. tempTime := time.Unix(timestamp, 0)
  7110. timeFormat := tempTime.Format("20060102150405")
  7111. chrgBchno := rand.Intn(100000) + 10000
  7112. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7113. strconv.FormatInt(his.PatientId, 10)
  7114. client := &http.Client{}
  7115. data["psn_no"] = his.PsnNo
  7116. data["mdtrt_id"] = his.Number
  7117. data["chrg_bchno"] = chrg_bchno
  7118. data["org_name"] = miConfig.OrgName
  7119. data["doctor"] = doctor_info.UserName
  7120. data["doctor_id"] = doctor_info.DoctorNumber
  7121. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7122. data["fixmedins_code"] = miConfig.Code
  7123. data["opter"] = roles.UserName
  7124. data["dept_code"] = department.Number
  7125. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7127. data["secret_key"] = miConfig.SecretKey
  7128. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7129. data["url"] = miConfig.Url
  7130. data["ak"] = miConfig.AccessKey
  7131. data["new_doctor_name"] = patientPrescription.Doctor
  7132. data["diag_code"] = sickConfig.CountryCode
  7133. data["cainfo"] = miConfig.Cainfo
  7134. data["opter"] = roles.UserName
  7135. var ids []int64
  7136. for _, item := range prescriptions {
  7137. ids = append(ids, item.ID)
  7138. }
  7139. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7140. if config.IsOpen == 1 { //对接了医保,走医保流程
  7141. var res ResultFour
  7142. var resFour10265 ResultFour10265
  7143. if miConfig.MdtrtareaAdmvs == "421300" {
  7144. bytesData, _ := json.Marshal(data)
  7145. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7146. resp, _ := client.Do(req)
  7147. defer resp.Body.Close()
  7148. body, ioErr := ioutil.ReadAll(resp.Body)
  7149. if ioErr != nil {
  7150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. var respJSON map[string]interface{}
  7155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7161. userJSONBytes, _ := json.Marshal(respJSON)
  7162. fmt.Println("log")
  7163. fmt.Println(string(userJSONBytes))
  7164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7165. utils.ErrorLog("解析失败:%v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7170. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7171. if result3101.Infcode == "0" {
  7172. if len(result3101.Output.Result) > 0 {
  7173. var errMsgs []string
  7174. for _, item := range result3101.Output.Result {
  7175. errMsgs = append(errMsgs, item.VolaCont)
  7176. }
  7177. c.ServeSuccessJSON(map[string]interface{}{
  7178. "failed_code": -10,
  7179. "msg": errMsgs,
  7180. })
  7181. return
  7182. }
  7183. }
  7184. bytesData, _ := json.Marshal(data)
  7185. var req *http.Request
  7186. if miConfig.MdtrtareaAdmvs == "320921" {
  7187. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7188. } else {
  7189. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7190. }
  7191. resp, _ := client.Do(req)
  7192. defer resp.Body.Close()
  7193. body, ioErr := ioutil.ReadAll(resp.Body)
  7194. if ioErr != nil {
  7195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. var respJSON map[string]interface{}
  7200. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7203. return
  7204. }
  7205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7206. userJSONBytes, _ := json.Marshal(respJSON)
  7207. fmt.Println("log")
  7208. fmt.Println(string(userJSONBytes))
  7209. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7210. utils.ErrorLog("解析失败:%v", err)
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. res.InfRefmsgid = resFour10265.InfRefmsgid
  7215. res.Output = resFour10265.Output
  7216. res.ErrMsg = resFour10265.ErrMsg
  7217. res.Cainfo = resFour10265.Cainfo
  7218. res.WarnMsg = resFour10265.WarnMsg
  7219. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7220. res.Infcode = infocode
  7221. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7222. 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)
  7223. var dat map[string]interface{}
  7224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7225. fmt.Println(dat)
  7226. } else {
  7227. fmt.Println(err)
  7228. }
  7229. saveLog(result, request_log, "2204", "上传费用明细")
  7230. userJSONBytes, _ := json.Marshal(dat)
  7231. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7232. utils.ErrorLog("解析失败:%v", err)
  7233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. return
  7235. }
  7236. res.InfRefmsgid = resFour10265.InfRefmsgid
  7237. res.Output = resFour10265.Output
  7238. res.ErrMsg = resFour10265.ErrMsg
  7239. res.Cainfo = resFour10265.Cainfo
  7240. res.WarnMsg = resFour10265.WarnMsg
  7241. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7242. res.Infcode = infocode
  7243. } else {
  7244. if miConfig.Code == "H15049901371" {
  7245. 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)
  7246. var dat map[string]interface{}
  7247. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7248. fmt.Println(dat)
  7249. } else {
  7250. fmt.Println(err)
  7251. }
  7252. saveLog(result, request_log, "2204", "上传费用明细")
  7253. userJSONBytes, _ := json.Marshal(dat)
  7254. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7255. utils.ErrorLog("解析失败:%v", err)
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7257. return
  7258. }
  7259. res.InfRefmsgid = resFour10265.InfRefmsgid
  7260. res.Output = resFour10265.Output
  7261. res.ErrMsg = resFour10265.ErrMsg
  7262. res.Cainfo = resFour10265.Cainfo
  7263. res.WarnMsg = resFour10265.WarnMsg
  7264. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7265. res.Infcode = infocode
  7266. } else {
  7267. 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)
  7268. var dat map[string]interface{}
  7269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7270. fmt.Println(dat)
  7271. } else {
  7272. fmt.Println(err)
  7273. }
  7274. saveLog(result, request_log, "2204", "上传费用明细")
  7275. userJSONBytes, _ := json.Marshal(dat)
  7276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7277. utils.ErrorLog("解析失败:%v", err)
  7278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7279. return
  7280. }
  7281. }
  7282. }
  7283. if res.Infcode == 0 {
  7284. order := &models.HisOrder{
  7285. UserOrgId: adminUser.CurrentOrgId,
  7286. HisPatientId: his.ID,
  7287. PatientId: his.PatientId,
  7288. SettleAccountsDate: recordDateTime,
  7289. MdtrtId: his.Number,
  7290. PsnNo: his.PsnNo,
  7291. MedType: strconv.FormatInt(reg_type, 10),
  7292. Ctime: time.Now().Unix(),
  7293. Mtime: time.Now().Unix(),
  7294. Status: 1,
  7295. Number: chrg_bchno,
  7296. Infcode: res.Infcode,
  7297. WarnMsg: res.WarnMsg,
  7298. Cainfo: res.Cainfo,
  7299. ErrMsg: res.ErrMsg,
  7300. RespondTime: res.RefmsgTime,
  7301. InfRefmsgid: res.InfRefmsgid,
  7302. OrderStatus: 1,
  7303. PayWay: pay_way,
  7304. PayPrice: pay_price,
  7305. PayCardNo: pay_card_no,
  7306. DiscountPrice: discount_price,
  7307. PreferentialPrice: preferential_price,
  7308. RealityPrice: reality_price,
  7309. FoundPrice: found_price,
  7310. MedicalInsurancePrice: medical_insurance_price,
  7311. PrivatePrice: private_price,
  7312. IsMedicineInsurance: 1,
  7313. SettleType: settle_accounts_type,
  7314. SettleStartTime: start_time,
  7315. SettleEndTime: end_time,
  7316. Creator: roles.AdminUserId,
  7317. Modify: roles.AdminUserId,
  7318. FaPiaoNumber: fapiao_number,
  7319. FaPiaoCode: fapiao_code,
  7320. PType: 2,
  7321. Diagnosis: diagnosis_id,
  7322. }
  7323. err = service.CreateOrder(order)
  7324. if err != nil {
  7325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7326. return
  7327. }
  7328. for _, item := range res.Output.Result {
  7329. temp := strings.Split(item.FeedetlSn, "-")
  7330. var advice_id int64 = 0
  7331. var project_id int64 = 0
  7332. var types int64 = 0
  7333. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7334. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7335. if temp[1] == "1" {
  7336. advice_id = id
  7337. project_id = 0
  7338. } else if temp[1] == "2" {
  7339. advice_id = 0
  7340. project_id = id
  7341. }
  7342. info := &models.HisOrderInfo{
  7343. OrderNumber: order.Number,
  7344. FeedetlSn: item.FeedetlSn,
  7345. UploadDate: time.Now().Unix(),
  7346. AdviceId: advice_id,
  7347. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7348. Cnt: item.Cnt,
  7349. Pric: float64(item.Pric),
  7350. PatientId: his.PatientId,
  7351. PricUplmtAmt: item.PricUplmtAmt,
  7352. SelfpayProp: item.SelfpayProp,
  7353. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7354. OverlmtAmt: item.OverlmtAmt,
  7355. PreselfpayAmt: item.PreselfpayAmt,
  7356. BasMednFlag: item.BasMednFlag,
  7357. MedChrgitmType: item.MedChrgitmType,
  7358. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7359. Status: 1,
  7360. Memo: item.Memo,
  7361. Mtime: time.Now().Unix(),
  7362. InscpScpAmt: item.InscpScpAmt,
  7363. DrtReimFlag: item.DrtReimFlag,
  7364. Ctime: time.Now().Unix(),
  7365. ListSpItemFlag: item.ListSpItemFlag,
  7366. ChldMedcFlag: item.ChldMedcFlag,
  7367. LmtUsedFlag: item.LmtUsedFlag,
  7368. ChrgitmLv: item.ChrgitmLv,
  7369. UserOrgId: adminUser.CurrentOrgId,
  7370. HisPatientId: his.ID,
  7371. OrderId: order.ID,
  7372. ProjectId: project_id,
  7373. Type: types,
  7374. }
  7375. service.CreateOrderInfo(info)
  7376. }
  7377. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7378. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7379. var total float64
  7380. for _, item := range prescriptions {
  7381. if item.Type == 1 { //药品
  7382. for _, subItem := range item.HisDoctorAdviceInfo {
  7383. total = total + (subItem.Price * subItem.PrescribingNumber)
  7384. }
  7385. }
  7386. if item.Type == 2 { //项目
  7387. for _, subItem := range item.HisPrescriptionProject {
  7388. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7389. total = total + (subItem.Price * cnt)
  7390. }
  7391. }
  7392. }
  7393. for _, item := range prescriptions {
  7394. for _, subItem := range item.HisAdditionalCharge {
  7395. total = total + (subItem.Price * float64(subItem.Count))
  7396. }
  7397. }
  7398. var allTotal string
  7399. if adminUser.CurrentOrgId == 9919 {
  7400. allTotal = fmt.Sprintf("%.4f", total)
  7401. } else {
  7402. allTotal = fmt.Sprintf("%.4f", total)
  7403. }
  7404. if res.Infcode == 0 {
  7405. var rf []*ResultFive
  7406. json.Unmarshal([]byte(his.Iinfo), &rf)
  7407. chrg_bchno := chrg_bchno
  7408. cert_no := his.Certno
  7409. var insutypes []string
  7410. var insutype string
  7411. var is390 int = 0
  7412. var is310 int = 0
  7413. for _, item := range rf {
  7414. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7415. insutypes = append(insutypes, item.Insutype)
  7416. }
  7417. }
  7418. if len(insutypes) == 1 {
  7419. insutype = insutypes[0]
  7420. } else {
  7421. for _, i := range insutypes {
  7422. if i == "390" {
  7423. is390 = 1
  7424. }
  7425. if i == "310" {
  7426. is310 = 1
  7427. }
  7428. }
  7429. }
  7430. if is390 == 1 {
  7431. insutype = "390"
  7432. }
  7433. if is310 == 1 {
  7434. insutype = "310"
  7435. }
  7436. if len(insutypes) == 0 {
  7437. insutype = "310"
  7438. }
  7439. if len(insutypes) == 2 {
  7440. insutype = strconv.FormatInt(his.SocialType, 10)
  7441. }
  7442. insutype = strconv.FormatInt(his.SocialType, 10)
  7443. //insutype = "390"
  7444. if his.IdCardType == 1 {
  7445. // cert_no = his.MedicalInsuranceNumber
  7446. cert_no = his.Certno
  7447. } else {
  7448. cert_no = his.Certno
  7449. }
  7450. var res ResultSeven
  7451. var resSeven10265 ResultSeven10265
  7452. var src_resquest string
  7453. var result2 string
  7454. var acct_used_flag string
  7455. fmt.Println("pay_way")
  7456. fmt.Println(pay_way)
  7457. fmt.Println("pay_way")
  7458. if pay_way == 4 {
  7459. acct_used_flag = "1"
  7460. } else {
  7461. acct_used_flag = "0"
  7462. }
  7463. if miConfig.MdtrtareaAdmvs == "421300" {
  7464. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7470. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7471. resp, requestErr := http.Get(api)
  7472. if requestErr != nil {
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. return
  7475. }
  7476. body, ioErr := ioutil.ReadAll(resp.Body)
  7477. if ioErr != nil {
  7478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. var respJSON map[string]interface{}
  7483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7486. return
  7487. }
  7488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7489. result, _ := json.Marshal(respJSON)
  7490. if miConfig.Code == "H15049901371" {
  7491. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7492. utils.ErrorLog("解析失败:%v", err)
  7493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7494. return
  7495. }
  7496. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7497. res.Output = resSeven10265.Output
  7498. res.ErrMsg = resSeven10265.ErrMsg
  7499. res.Cainfo = resSeven10265.Cainfo
  7500. res.WarnMsg = resSeven10265.WarnMsg
  7501. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7502. res.Infcode = infocode
  7503. } else {
  7504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7505. utils.ErrorLog("解析失败:%v", err)
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7507. return
  7508. }
  7509. }
  7510. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7511. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7512. if result3101.Infcode == "0" {
  7513. if len(result3101.Output.Result) > 0 {
  7514. var errMsgs []string
  7515. for _, item := range result3101.Output.Result {
  7516. errMsgs = append(errMsgs, item.VolaCont)
  7517. }
  7518. c.ServeSuccessJSON(map[string]interface{}{
  7519. "failed_code": -10,
  7520. "msg": errMsgs,
  7521. })
  7522. return
  7523. } else {
  7524. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7525. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7526. bas := strings.Split(psn_info.CardInfo, "|")
  7527. if his.IdCardType == 1 {
  7528. cert_no = bas[2]
  7529. } else if his.IdCardType == 3 {
  7530. cert_no = his.Certno
  7531. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7532. } else if his.IdCardType == 4 {
  7533. cert_no = his.Certno
  7534. psn_info.VerifyNumber = psn_info.VerifyNumber
  7535. }
  7536. var api string
  7537. if miConfig.MdtrtareaAdmvs == "320921" {
  7538. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7544. "&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
  7545. } else {
  7546. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7547. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7548. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7550. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7551. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7552. "&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
  7553. }
  7554. resp, requestErr := http.Get(api)
  7555. if requestErr != nil {
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. body, ioErr := ioutil.ReadAll(resp.Body)
  7560. if ioErr != nil {
  7561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7563. return
  7564. }
  7565. var respJSON map[string]interface{}
  7566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7572. result, _ := json.Marshal(respJSON)
  7573. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7574. utils.ErrorLog("解析失败:%v", err)
  7575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7576. return
  7577. }
  7578. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7579. res.Output = resSeven10265.Output
  7580. res.ErrMsg = resSeven10265.ErrMsg
  7581. res.Cainfo = resSeven10265.Cainfo
  7582. res.WarnMsg = resSeven10265.WarnMsg
  7583. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7584. res.Infcode = infocode
  7585. }
  7586. }
  7587. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7588. var cert_no string
  7589. if his.IdCardType == 4 {
  7590. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7591. cert_no = psn_info.VerifyNumber
  7592. 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)
  7593. } else if his.IdCardType == 1 {
  7594. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7595. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7596. 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)
  7597. }
  7598. //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)
  7599. var dat map[string]interface{}
  7600. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7601. fmt.Println(dat)
  7602. } else {
  7603. fmt.Println(err)
  7604. }
  7605. saveLog(result2, src_resquest, "2207", "结算")
  7606. userJSONBytes, _ := json.Marshal(dat)
  7607. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7608. utils.ErrorLog("解析失败:%v", err)
  7609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7610. return
  7611. }
  7612. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7613. res.Output = resSeven10265.Output
  7614. res.ErrMsg = resSeven10265.ErrMsg
  7615. res.Cainfo = resSeven10265.Cainfo
  7616. res.WarnMsg = resSeven10265.WarnMsg
  7617. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7618. res.Infcode = infocode
  7619. } else {
  7620. if miConfig.Code == "H15049901371" {
  7621. //赤峰地区国家医保医疗类别
  7622. //职工透析:医疗类别选特殊情况门诊990502
  7623. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7624. var med_type string
  7625. if his.Insutype == "390" {
  7626. if reg_type == 14 {
  7627. med_type = "9933"
  7628. } else if reg_type == 11 {
  7629. med_type = "11"
  7630. }
  7631. } else if his.Insutype == "310" {
  7632. if reg_type == 14 {
  7633. med_type = "990502"
  7634. } else if reg_type == 11 {
  7635. med_type = "11"
  7636. }
  7637. }
  7638. 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, "")
  7639. } else {
  7640. if his.IdCardType == 4 {
  7641. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7642. var token string
  7643. token = psn_info.VerifyNumber
  7644. 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)
  7645. } else {
  7646. 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, "")
  7647. }
  7648. }
  7649. //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)
  7650. var dat map[string]interface{}
  7651. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7652. fmt.Println(dat)
  7653. } else {
  7654. fmt.Println(err)
  7655. }
  7656. saveLog(result2, src_resquest, "2207", "结算")
  7657. userJSONBytes, _ := json.Marshal(dat)
  7658. if miConfig.Code == "H15049901371" {
  7659. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7660. utils.ErrorLog("解析失败:%v", err)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7665. res.Output = resSeven10265.Output
  7666. res.ErrMsg = resSeven10265.ErrMsg
  7667. res.Cainfo = resSeven10265.Cainfo
  7668. res.WarnMsg = resSeven10265.WarnMsg
  7669. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7670. res.Infcode = infocode
  7671. } else {
  7672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7673. utils.ErrorLog("解析失败:%v", err)
  7674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7675. return
  7676. }
  7677. }
  7678. }
  7679. if res.Infcode != 0 {
  7680. errlog := &models.HisOrderError{
  7681. UserOrgId: adminUser.CurrentOrgId,
  7682. Ctime: time.Now().Unix(),
  7683. Mtime: time.Now().Unix(),
  7684. Number: chrg_bchno,
  7685. ErrMsg: res.ErrMsg,
  7686. Status: 1,
  7687. PatientId: id,
  7688. RecordTime: recordDateTime,
  7689. Stage: 6,
  7690. }
  7691. service.CreateErrMsgLog(errlog)
  7692. c.ServeSuccessJSON(map[string]interface{}{
  7693. "failed_code": -10,
  7694. "msg": res.ErrMsg,
  7695. })
  7696. return
  7697. } else {
  7698. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7699. order.OrderStatus = 2
  7700. order.Status = 1
  7701. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7702. order.SetlId = res.Output.Setlinfo.SetlID
  7703. order.PsnNo = res.Output.Setlinfo.PsnNo
  7704. order.PsnName = res.Output.Setlinfo.PsnName
  7705. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7706. order.Certno = res.Output.Setlinfo.Certno
  7707. order.Gend = res.Output.Setlinfo.Gend
  7708. order.Naty = res.Output.Setlinfo.Naty
  7709. order.Age = res.Output.Setlinfo.Age
  7710. order.Insutype = res.Output.Setlinfo.Insutype
  7711. order.PsnType = res.Output.Setlinfo.PsnType
  7712. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7713. order.SetlTime = res.Output.Setlinfo.SetlTime
  7714. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7715. if res.Output.Setlinfo.MedType == "140101" {
  7716. order.MedType = "14"
  7717. } else {
  7718. order.MedType = res.Output.Setlinfo.MedType
  7719. }
  7720. if reg_type == 1112 {
  7721. order.MedType = "1112"
  7722. }
  7723. if reg_type == 1111 {
  7724. order.MedType = "1111"
  7725. }
  7726. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7727. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7728. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7729. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7730. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7731. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7732. order.HifpPay = res.Output.Setlinfo.HifpPay
  7733. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7734. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7735. order.HifesPay = res.Output.Setlinfo.HifesPay
  7736. order.HifobPay = res.Output.Setlinfo.HifobPay
  7737. order.MafPay = res.Output.Setlinfo.MafPay
  7738. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7739. order.OthPay = res.Output.Setlinfo.OthPay
  7740. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7741. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7742. order.AcctPay = res.Output.Setlinfo.AcctPay
  7743. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7744. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7745. order.Balc = res.Output.Setlinfo.Balc
  7746. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7747. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7748. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7749. order.ClrType = res.Output.Setlinfo.ClrType
  7750. order.ClrWay = res.Output.Setlinfo.ClrWay
  7751. order.Creator = order.Creator
  7752. order.Modify = roles.AdminUserId
  7753. order.RequestLog = src_resquest
  7754. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7755. detailStr := string(setlDetail)
  7756. order.SetlDetail = detailStr
  7757. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7758. err = service.UpDateOrder(order)
  7759. if err == nil {
  7760. //判断是否使用了押金
  7761. if dec_way == "true" {
  7762. tmpstring := strconv.FormatInt(order.ID, 10)
  7763. order.Decimal = decimal
  7764. service.UpDateOrder(order)
  7765. //扣押金
  7766. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  7767. if errmsg != nil {
  7768. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  7769. return
  7770. }
  7771. }
  7772. c.ServeSuccessJSON(map[string]interface{}{
  7773. "msg": "结算成功",
  7774. })
  7775. } else {
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7777. return
  7778. }
  7779. }
  7780. } else {
  7781. adminUser := c.GetAdminUserInfo()
  7782. errlog := &models.HisOrderError{
  7783. UserOrgId: adminUser.CurrentOrgId,
  7784. Ctime: time.Now().Unix(),
  7785. Mtime: time.Now().Unix(),
  7786. ErrMsg: res.ErrMsg,
  7787. Status: 1,
  7788. PatientId: id,
  7789. RecordTime: recordDateTime,
  7790. Stage: 4,
  7791. }
  7792. service.CreateErrMsgLog(errlog)
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7794. return
  7795. }
  7796. } else {
  7797. adminUser := c.GetAdminUserInfo()
  7798. errlog := &models.HisOrderError{
  7799. UserOrgId: adminUser.CurrentOrgId,
  7800. Ctime: time.Now().Unix(),
  7801. Mtime: time.Now().Unix(),
  7802. ErrMsg: res.ErrMsg,
  7803. Status: 1,
  7804. PatientId: id,
  7805. RecordTime: recordDateTime,
  7806. Stage: 4,
  7807. }
  7808. service.CreateErrMsgLog(errlog)
  7809. c.ServeSuccessJSON(map[string]interface{}{
  7810. "failed_code": -10,
  7811. "msg": res.ErrMsg,
  7812. })
  7813. return
  7814. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7815. //return
  7816. }
  7817. }
  7818. }
  7819. } else if tempOrder.ID > 0 {
  7820. if tempOrder.IsPre == 1 {
  7821. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  7822. var rf []*ResultFive
  7823. json.Unmarshal([]byte(his.Iinfo), &rf)
  7824. chrg_bchno := tempOrder.Number
  7825. cert_no := his.Certno
  7826. var insutypes []string
  7827. var insutype string
  7828. var is390 int = 0
  7829. var is310 int = 0
  7830. for _, item := range rf {
  7831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7832. insutypes = append(insutypes, item.Insutype)
  7833. }
  7834. }
  7835. if len(insutypes) == 1 {
  7836. insutype = insutypes[0]
  7837. } else {
  7838. for _, i := range insutypes {
  7839. if i == "390" {
  7840. is390 = 1
  7841. }
  7842. if i == "310" {
  7843. is310 = 1
  7844. }
  7845. }
  7846. }
  7847. if is390 == 1 {
  7848. insutype = "390"
  7849. }
  7850. if is310 == 1 {
  7851. insutype = "310"
  7852. }
  7853. if len(insutypes) == 0 {
  7854. insutype = "310"
  7855. }
  7856. if len(insutypes) == 2 {
  7857. insutype = strconv.FormatInt(his.SocialType, 64)
  7858. }
  7859. //insutype = "390"
  7860. if his.IdCardType == 1 {
  7861. // cert_no = his.MedicalInsuranceNumber
  7862. cert_no = his.Certno
  7863. } else {
  7864. cert_no = his.Certno
  7865. }
  7866. var res ResultSeven
  7867. var resSeven10265 ResultSeven10265
  7868. var src_resquest string
  7869. var result2 string
  7870. var acct_used_flag string
  7871. fmt.Println("pay_way")
  7872. fmt.Println(pay_way)
  7873. fmt.Println("pay_way")
  7874. if pay_way == 4 {
  7875. acct_used_flag = "1"
  7876. } else {
  7877. acct_used_flag = "0"
  7878. }
  7879. if miConfig.MdtrtareaAdmvs == "421300" {
  7880. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7881. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7882. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7883. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7884. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7885. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7886. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7887. resp, requestErr := http.Get(api)
  7888. if requestErr != nil {
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. body, ioErr := ioutil.ReadAll(resp.Body)
  7893. if ioErr != nil {
  7894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. var respJSON map[string]interface{}
  7899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. return
  7903. }
  7904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7905. result, _ := json.Marshal(respJSON)
  7906. fmt.Println("log")
  7907. fmt.Println(string(result))
  7908. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7909. utils.ErrorLog("解析失败:%v", err)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7914. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  7915. if result3101.Infcode == "0" {
  7916. if len(result3101.Output.Result) > 0 {
  7917. var errMsgs []string
  7918. for _, item := range result3101.Output.Result {
  7919. errMsgs = append(errMsgs, item.VolaCont)
  7920. }
  7921. c.ServeSuccessJSON(map[string]interface{}{
  7922. "failed_code": -10,
  7923. "msg": errMsgs,
  7924. })
  7925. return
  7926. } else {
  7927. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7928. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7929. bas := strings.Split(psn_info.CardInfo, "|")
  7930. if his.IdCardType == 1 {
  7931. cert_no = bas[2]
  7932. } else if his.IdCardType == 3 {
  7933. cert_no = his.Certno
  7934. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7935. } else if his.IdCardType == 4 {
  7936. cert_no = his.Certno
  7937. psn_info.VerifyNumber = psn_info.VerifyNumber
  7938. }
  7939. //江苏地区国家医保医疗类别
  7940. //职工透析:医疗类别选特殊情况门诊9933
  7941. //居民血透门慢: 医疗类别选门诊慢病1402
  7942. //var med_type string
  7943. //if his.Insutype == "310" {
  7944. // if reg_type == 14 {
  7945. // med_type = "9933"
  7946. // } else if reg_type == 11 {
  7947. // med_type = "11"
  7948. //
  7949. // }
  7950. //} else if his.Insutype == "390" {
  7951. // if reg_type == 14 {
  7952. // med_type = "1402"
  7953. // } else if reg_type == 11 {
  7954. // med_type = "11"
  7955. // }
  7956. //}
  7957. var api string
  7958. if miConfig.MdtrtareaAdmvs == "320921" {
  7959. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7960. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7961. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7963. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7964. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7965. "&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
  7966. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7967. } else {
  7968. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7969. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7970. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7971. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7973. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7974. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7975. "&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
  7976. }
  7977. resp, requestErr := http.Get(api)
  7978. if requestErr != nil {
  7979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7980. return
  7981. }
  7982. body, ioErr := ioutil.ReadAll(resp.Body)
  7983. if ioErr != nil {
  7984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. var respJSON map[string]interface{}
  7989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7992. return
  7993. }
  7994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7995. result, _ := json.Marshal(respJSON)
  7996. fmt.Println("log")
  7997. fmt.Println(string(result))
  7998. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7999. utils.ErrorLog("解析失败:%v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8004. res.Output = resSeven10265.Output
  8005. res.ErrMsg = resSeven10265.ErrMsg
  8006. res.Cainfo = resSeven10265.Cainfo
  8007. res.WarnMsg = resSeven10265.WarnMsg
  8008. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8009. res.Infcode = infocode
  8010. }
  8011. }
  8012. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8013. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8014. var cert_no string
  8015. if his.IdCardType == 1 {
  8016. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8017. } else {
  8018. cert_no = psn_info.VerifyNumber
  8019. }
  8020. 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)
  8021. var dat map[string]interface{}
  8022. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8023. fmt.Println(dat)
  8024. } else {
  8025. fmt.Println(err)
  8026. }
  8027. saveLog(result2, src_resquest, "2207", "结算")
  8028. userJSONBytes, _ := json.Marshal(dat)
  8029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8030. utils.ErrorLog("解析失败:%v", err)
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. return
  8033. }
  8034. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8035. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8036. var cert_no string
  8037. if his.IdCardType == 1 {
  8038. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8039. } else if his.IdCardType == 2 {
  8040. cert_no = his.IdCardNo
  8041. } else {
  8042. cert_no = psn_info.VerifyNumber
  8043. }
  8044. 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, "")
  8045. var dat map[string]interface{}
  8046. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8047. fmt.Println(dat)
  8048. } else {
  8049. fmt.Println(err)
  8050. }
  8051. saveLog(result2, src_resquest, "2207", "结算")
  8052. userJSONBytes, _ := json.Marshal(dat)
  8053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8054. utils.ErrorLog("解析失败:%v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8059. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8060. var cert_no string
  8061. if his.IdCardType == 1 {
  8062. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8063. } else if his.IdCardType == 2 {
  8064. cert_no = his.IdCardNo
  8065. } else {
  8066. cert_no = psn_info.VerifyNumber
  8067. }
  8068. 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, "")
  8069. var dat map[string]interface{}
  8070. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8071. fmt.Println(dat)
  8072. } else {
  8073. fmt.Println(err)
  8074. }
  8075. saveLog(result2, src_resquest, "2207", "结算")
  8076. userJSONBytes, _ := json.Marshal(dat)
  8077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8078. utils.ErrorLog("解析失败:%v", err)
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. return
  8081. }
  8082. } else {
  8083. var src_resquest string
  8084. if miConfig.Code == "H15049901371" {
  8085. //赤峰地区国家医保医疗类别
  8086. //职工透析:医疗类别选特殊情况门诊990502
  8087. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8088. var med_type string
  8089. if his.Insutype == "390" {
  8090. if reg_type == 14 {
  8091. med_type = "9933"
  8092. } else if reg_type == 11 {
  8093. med_type = "11"
  8094. }
  8095. } else if his.Insutype == "310" {
  8096. if reg_type == 14 {
  8097. med_type = "990502"
  8098. } else if reg_type == 11 {
  8099. med_type = "11"
  8100. }
  8101. }
  8102. 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, "")
  8103. } else {
  8104. if his.IdCardType == 4 {
  8105. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8106. token := psn_info.VerifyNumber
  8107. 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)
  8108. } else {
  8109. 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, "")
  8110. }
  8111. }
  8112. var dat map[string]interface{}
  8113. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8114. fmt.Println(dat)
  8115. } else {
  8116. fmt.Println(err)
  8117. }
  8118. saveLog(result2, src_resquest, "2207", "结算")
  8119. userJSONBytes, _ := json.Marshal(dat)
  8120. if miConfig.Code == "H15049901371" {
  8121. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8122. utils.ErrorLog("解析失败:%v", err)
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8124. return
  8125. }
  8126. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8127. res.Output = resSeven10265.Output
  8128. res.ErrMsg = resSeven10265.ErrMsg
  8129. res.Cainfo = resSeven10265.Cainfo
  8130. res.WarnMsg = resSeven10265.WarnMsg
  8131. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8132. res.Infcode = infocode
  8133. } else {
  8134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8135. utils.ErrorLog("解析失败:%v", err)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. }
  8140. }
  8141. if res.Infcode != 0 {
  8142. errlog := &models.HisOrderError{
  8143. UserOrgId: adminUser.CurrentOrgId,
  8144. Ctime: time.Now().Unix(),
  8145. Mtime: time.Now().Unix(),
  8146. Number: chrg_bchno,
  8147. ErrMsg: res.ErrMsg,
  8148. Status: 1,
  8149. PatientId: id,
  8150. RecordTime: recordDateTime,
  8151. Stage: 6,
  8152. }
  8153. service.CreateErrMsgLog(errlog)
  8154. c.ServeSuccessJSON(map[string]interface{}{
  8155. "failed_code": -10,
  8156. "msg": res.ErrMsg,
  8157. })
  8158. return
  8159. } else {
  8160. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8161. order.OrderStatus = 2
  8162. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8163. order.SetlId = res.Output.Setlinfo.SetlID
  8164. order.PsnNo = res.Output.Setlinfo.PsnNo
  8165. order.PsnName = res.Output.Setlinfo.PsnName
  8166. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8167. order.Certno = res.Output.Setlinfo.Certno
  8168. order.Gend = res.Output.Setlinfo.Gend
  8169. order.Naty = res.Output.Setlinfo.Naty
  8170. order.Age = res.Output.Setlinfo.Age
  8171. order.Insutype = res.Output.Setlinfo.Insutype
  8172. order.PsnType = res.Output.Setlinfo.PsnType
  8173. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8174. order.SetlTime = res.Output.Setlinfo.SetlTime
  8175. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8176. //order.MedType = res.Output.Setlinfo.MedType
  8177. if reg_type == 1112 {
  8178. order.MedType = "1112"
  8179. }
  8180. if reg_type == 1111 {
  8181. order.MedType = "1111"
  8182. }
  8183. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8184. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8185. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8186. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8187. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8188. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8189. order.HifpPay = res.Output.Setlinfo.HifpPay
  8190. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8191. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8192. order.HifesPay = res.Output.Setlinfo.HifesPay
  8193. order.HifobPay = res.Output.Setlinfo.HifobPay
  8194. order.MafPay = res.Output.Setlinfo.MafPay
  8195. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8196. order.OthPay = res.Output.Setlinfo.OthPay
  8197. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8198. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8199. order.AcctPay = res.Output.Setlinfo.AcctPay
  8200. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8201. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8202. order.Balc = res.Output.Setlinfo.Balc
  8203. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8204. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8205. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8206. order.ClrWay = res.Output.Setlinfo.ClrWay
  8207. order.Creator = order.Creator
  8208. order.Modify = roles.AdminUserId
  8209. order.RequestLog = src_resquest
  8210. order.Diagnosis = diagnosis_id
  8211. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8212. detailStr := string(setlDetail)
  8213. order.SetlDetail = detailStr
  8214. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8215. err = service.UpDateOrder(order)
  8216. if err == nil {
  8217. //判断是否使用了押金
  8218. if dec_way == "true" {
  8219. tmpstring := strconv.FormatInt(order.ID, 10)
  8220. //扣押金
  8221. order.Decimal = decimal
  8222. service.UpDateOrder(order)
  8223. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8224. if errmsg != nil {
  8225. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8226. return
  8227. }
  8228. }
  8229. c.ServeSuccessJSON(map[string]interface{}{
  8230. "msg": "结算成功",
  8231. })
  8232. } else {
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8234. return
  8235. }
  8236. }
  8237. }
  8238. }
  8239. }
  8240. //func (c *HisApiController) GetPreUploadInfo() {
  8241. // id, _ := c.GetInt64("id")
  8242. // record_time := c.GetString("record_time")
  8243. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8244. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8245. //
  8246. // timeLayout := "2006-01-02"
  8247. // loc, _ := time.LoadLocation("Local")
  8248. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8249. // if err != nil {
  8250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8251. // return
  8252. // }
  8253. // recordDateTime := theTime.Unix()
  8254. // adminUser := c.GetAdminUserInfo()
  8255. //
  8256. // var prescriptions []*models.HisPrescription
  8257. //
  8258. // var start_time int64
  8259. // var end_time int64
  8260. //
  8261. // data := make(map[string]interface{})
  8262. // if settle_accounts_type == 1 { //日结
  8263. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8264. // data["pre"] = prescriptions
  8265. //
  8266. // } else { //月结
  8267. // start_time_str := c.GetString("start_time")
  8268. // end_time_str := c.GetString("end_time")
  8269. // timeLayout := "2006-01-02"
  8270. // loc, _ := time.LoadLocation("Local")
  8271. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8272. // if err != nil {
  8273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8274. // return
  8275. // }
  8276. // recordStartTime := theStartTime.Unix()
  8277. // start_time = recordStartTime
  8278. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8279. // if err != nil {
  8280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8281. // return
  8282. // }
  8283. // recordEndTime := theEndTime.Unix()
  8284. // end_time = recordEndTime
  8285. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8286. // data["pre"] = prescriptions
  8287. //
  8288. // }
  8289. //
  8290. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8291. //
  8292. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8293. // timestamp := time.Now().Unix()
  8294. // tempTime := time.Unix(timestamp, 0)
  8295. // timeFormat := tempTime.Format("20060102150405")
  8296. // chrgBchno := rand.Intn(100000) + 10000
  8297. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8298. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8299. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8300. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8301. // strconv.FormatInt(his.PatientId, 10)
  8302. // client := &http.Client{}
  8303. // data["psn_no"] = his.PsnNo
  8304. // data["mdtrt_id"] = his.Number
  8305. // data["chrg_bchno"] = chrg_bchno
  8306. // data["org_name"] = miConfig.OrgName
  8307. // data["doctor"] = roles.UserName
  8308. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8309. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8310. // data["fixmedins_code"] = miConfig.Code
  8311. // data["dept_code"] = department.Number
  8312. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8313. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8314. // data["secret_key"] = miConfig.SecretKey
  8315. // var ids []int64
  8316. //
  8317. // for _, item := range prescriptions {
  8318. // ids = append(ids, item.ID)
  8319. // }
  8320. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8321. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8322. // bytesData, _ := json.Marshal(data)
  8323. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8324. // resp, _ := client.Do(req)
  8325. // defer resp.Body.Close()
  8326. // body, ioErr := ioutil.ReadAll(resp.Body)
  8327. // if ioErr != nil {
  8328. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8330. // return
  8331. // }
  8332. // var respJSON map[string]interface{}
  8333. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. // return
  8337. // }
  8338. //
  8339. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8340. // userJSONBytes, _ := json.Marshal(respJSON)
  8341. // var res ResultFour
  8342. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8343. // utils.ErrorLog("解析失败:%v", err)
  8344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8345. // return
  8346. // }
  8347. //
  8348. // if res.Infcode == 0 {
  8349. // order := &models.HisOrder{
  8350. // UserOrgId: adminUser.CurrentOrgId,
  8351. // HisPatientId: his.ID,
  8352. // PatientId: his.PatientId,
  8353. // SettleAccountsDate: recordDateTime,
  8354. // Ctime: time.Now().Unix(),
  8355. // Mtime: time.Now().Unix(),
  8356. // Status: 1,
  8357. // Number: chrg_bchno,
  8358. // Infcode: res.Infcode,
  8359. // WarnMsg: res.WarnMsg,
  8360. // Cainfo: res.Cainfo,
  8361. // ErrMsg: res.ErrMsg,
  8362. // RespondTime: res.RefmsgTime,
  8363. // InfRefmsgid: res.InfRefmsgid,
  8364. // OrderStatus: 1,
  8365. // IsMedicineInsurance: 1,
  8366. // SettleType: settle_accounts_type,
  8367. // SettleStartTime: start_time,
  8368. // SettleEndTime: end_time,
  8369. // Creator: roles.ID,
  8370. // Modify: roles.ID,
  8371. // PType: 2,
  8372. // }
  8373. // err = service.CreateOrder(order)
  8374. // if err != nil {
  8375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8376. // return
  8377. // }
  8378. //
  8379. // for _, item := range res.Output.Result {
  8380. // temp := strings.Split(item.FeedetlSn, "-")
  8381. // var advice_id int64 = 0
  8382. // var project_id int64 = 0
  8383. // var types int64 = 0
  8384. //
  8385. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8386. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8387. //
  8388. // if temp[1] == "1" {
  8389. // advice_id = id
  8390. // project_id = 0
  8391. // } else if temp[1] == "2" {
  8392. // advice_id = 0
  8393. // project_id = id
  8394. // }
  8395. //
  8396. // info := &models.HisOrderInfo{
  8397. // OrderNumber: order.Number,
  8398. // FeedetlSn: item.FeedetlSn,
  8399. // UploadDate: time.Now().Unix(),
  8400. // AdviceId: advice_id,
  8401. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8402. // Cnt: item.Cnt,
  8403. // Pric: float64(item.Pric),
  8404. // PatientId: his.PatientId,
  8405. // PricUplmtAmt: item.PricUplmtAmt,
  8406. // SelfpayProp: item.SelfpayProp,
  8407. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8408. // OverlmtAmt: item.OverlmtAmt,
  8409. // PreselfpayAmt: item.PreselfpayAmt,
  8410. // BasMednFlag: item.BasMednFlag,
  8411. // MedChrgitmType: item.MedChrgitmType,
  8412. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8413. // Status: 1,
  8414. // Memo: item.Memo,
  8415. // Mtime: time.Now().Unix(),
  8416. // InscpScpAmt: item.InscpScpAmt,
  8417. // DrtReimFlag: item.DrtReimFlag,
  8418. // Ctime: time.Now().Unix(),
  8419. // ListSpItemFlag: item.ListSpItemFlag,
  8420. // ChldMedcFlag: item.ChldMedcFlag,
  8421. // LmtUsedFlag: item.LmtUsedFlag,
  8422. // ChrgitmLv: item.ChrgitmLv,
  8423. // UserOrgId: adminUser.CurrentOrgId,
  8424. // HisPatientId: his.ID,
  8425. // OrderId: order.ID,
  8426. // ProjectId: project_id,
  8427. // Type: types,
  8428. // }
  8429. // service.CreateOrderInfo(info)
  8430. //
  8431. // }
  8432. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8433. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8434. //
  8435. // var total float64
  8436. // for _, item := range prescriptions {
  8437. // if item.Type == 1 { //药品
  8438. // for _, subItem := range item.HisDoctorAdviceInfo {
  8439. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8440. // }
  8441. // }
  8442. // if item.Type == 2 { //项目
  8443. // for _, subItem := range item.HisPrescriptionProject {
  8444. // total = total + (subItem.Price * float64(subItem.Count))
  8445. // }
  8446. // }
  8447. // }
  8448. //
  8449. // for _, item := range prescriptions {
  8450. // for _, subItem := range item.HisAdditionalCharge {
  8451. // total = total + (subItem.Price * float64(subItem.Count))
  8452. // }
  8453. // }
  8454. //
  8455. // allTotal := fmt.Sprintf("%.2f", total)
  8456. // if res.Infcode == 0 {
  8457. // var rf []*ResultFive
  8458. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8459. // psn_no := his.PsnNo
  8460. // mdtrt_id := his.Number
  8461. // chrg_bchno := chrg_bchno
  8462. // cert_no := his.Certno
  8463. // insutype := rf[0].Insutype
  8464. //
  8465. // if his.IdCardType == 1 {
  8466. // cert_no = his.MedicalInsuranceNumber
  8467. //
  8468. // } else {
  8469. //
  8470. // cert_no = his.Certno
  8471. //
  8472. // }
  8473. //
  8474. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8475. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8476. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8477. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8478. // resp, requestErr := http.Get(api)
  8479. // if requestErr != nil {
  8480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. // return
  8482. // }
  8483. // defer resp.Body.Close()
  8484. // body, ioErr := ioutil.ReadAll(resp.Body)
  8485. // if ioErr != nil {
  8486. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8488. // return
  8489. // }
  8490. // var respJSON map[string]interface{}
  8491. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8492. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8494. // return
  8495. // }
  8496. // fmt.Println(respJSON)
  8497. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8498. // userJSONBytes, _ := json.Marshal(respJSON)
  8499. // var res ResultSeven
  8500. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8501. // utils.ErrorLog("解析失败:%v", err)
  8502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. // return
  8504. // }
  8505. // if res.Infcode != 0 {
  8506. // errlog := &models.HisOrderError{
  8507. // UserOrgId: adminUser.CurrentOrgId,
  8508. // Ctime: time.Now().Unix(),
  8509. // Mtime: time.Now().Unix(),
  8510. // Number: chrg_bchno,
  8511. // ErrMsg: res.ErrMsg,
  8512. // Status: 1,
  8513. // PatientId: id,
  8514. // RecordTime: recordDateTime,
  8515. // Stage: 7,
  8516. // }
  8517. // service.CreateErrMsgLog(errlog)
  8518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8519. // return
  8520. // } else {
  8521. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8522. // order.OrderStatus = 1
  8523. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8524. // order.SetlId = res.Output.Setlinfo.SetlID
  8525. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8526. // order.PsnName = res.Output.Setlinfo.PsnName
  8527. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8528. // order.Certno = res.Output.Setlinfo.Certno
  8529. // order.Gend = res.Output.Setlinfo.Gend
  8530. // order.Naty = res.Output.Setlinfo.Naty
  8531. // order.Age = res.Output.Setlinfo.Age
  8532. // order.Insutype = res.Output.Setlinfo.Insutype
  8533. // order.PsnType = res.Output.Setlinfo.PsnType
  8534. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8535. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8536. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8537. // order.MedType = res.Output.Setlinfo.MedType
  8538. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8539. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8540. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8541. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8542. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8543. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8544. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8545. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8546. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8547. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8548. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8549. // order.MafPay = res.Output.Setlinfo.MafPay
  8550. // order.OthPay = res.Output.Setlinfo.OthPay
  8551. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8552. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8553. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8554. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8555. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8556. // order.Balc = res.Output.Setlinfo.Balc
  8557. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8558. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8559. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8560. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8561. // order.Creator = order.Creator
  8562. // order.Modify = roles.ID
  8563. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8564. // detailStr := string(setlDetail)
  8565. // order.SetlDetail = detailStr
  8566. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8567. // err = service.UpDateOrder(order)
  8568. // if err == nil {
  8569. // c.ServeSuccessJSON(map[string]interface{}{
  8570. // "msg": "预结算成功",
  8571. // })
  8572. // } else {
  8573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8574. // return
  8575. // }
  8576. // }
  8577. // } else {
  8578. // adminUser := c.GetAdminUserInfo()
  8579. // errlog := &models.HisOrderError{
  8580. // UserOrgId: adminUser.CurrentOrgId,
  8581. // Ctime: time.Now().Unix(),
  8582. // Mtime: time.Now().Unix(),
  8583. // ErrMsg: res.ErrMsg,
  8584. // Status: 1,
  8585. // PatientId: id,
  8586. // RecordTime: recordDateTime,
  8587. // Stage: 4,
  8588. // }
  8589. // service.CreateErrMsgLog(errlog)
  8590. //
  8591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8592. // return
  8593. // }
  8594. // } else {
  8595. // adminUser := c.GetAdminUserInfo()
  8596. // errlog := &models.HisOrderError{
  8597. // UserOrgId: adminUser.CurrentOrgId,
  8598. // Ctime: time.Now().Unix(),
  8599. // Mtime: time.Now().Unix(),
  8600. // ErrMsg: res.ErrMsg,
  8601. // Status: 1,
  8602. // PatientId: id,
  8603. // RecordTime: recordDateTime,
  8604. // Stage: 4,
  8605. // }
  8606. // service.CreateErrMsgLog(errlog)
  8607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8608. // return
  8609. // }
  8610. //
  8611. // } else {
  8612. // var total float64
  8613. // for _, item := range prescriptions {
  8614. // if item.Type == 1 { //药品
  8615. // for _, subItem := range item.HisDoctorAdviceInfo {
  8616. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8617. // }
  8618. // }
  8619. // if item.Type == 2 { //项目
  8620. // for _, subItem := range item.HisPrescriptionProject {
  8621. // total = total + (subItem.Price * float64(subItem.Count))
  8622. // }
  8623. // }
  8624. //
  8625. // for _, subItem := range item.HisAdditionalCharge {
  8626. // total = total + (subItem.Price * float64(subItem.Count))
  8627. // }
  8628. // }
  8629. //
  8630. // allTotal := fmt.Sprintf("%.2f", total)
  8631. // totals, _ := strconv.ParseFloat(allTotal, 64)
  8632. // order := &models.HisOrder{
  8633. // UserOrgId: adminUser.CurrentOrgId,
  8634. // HisPatientId: his.ID,
  8635. // PatientId: id,
  8636. // SettleAccountsDate: recordDateTime,
  8637. // Ctime: time.Now().Unix(),
  8638. // Mtime: time.Now().Unix(),
  8639. // Status: 1,
  8640. // OrderStatus: 2,
  8641. // Number: chrg_bchno,
  8642. // MedfeeSumamt: totals,
  8643. // }
  8644. // err = service.CreateOrder(order)
  8645. // if err != nil {
  8646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8647. // return
  8648. // }
  8649. //
  8650. // var customs []*Custom
  8651. // for _, item := range prescriptions {
  8652. //
  8653. // if item.Type == 1 { //药品
  8654. // for _, subItem := range item.HisDoctorAdviceInfo {
  8655. // cus := &Custom{
  8656. // AdviceId: subItem.ID,
  8657. // ProjectId: 0,
  8658. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  8659. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  8660. // FeedetlSn: subItem.FeedetlSn,
  8661. // Price: fmt.Sprintf("%.2f", subItem.Price),
  8662. // MedListCodg: subItem.MedListCodg,
  8663. // Type: 1,
  8664. // }
  8665. // customs = append(customs, cus)
  8666. // }
  8667. // }
  8668. //
  8669. // if item.Type == 2 { //项目
  8670. // for _, subItem := range item.HisPrescriptionProject {
  8671. //
  8672. // cus := &Custom{
  8673. // AdviceId: 0,
  8674. // ProjectId: subItem.ID,
  8675. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  8676. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  8677. // FeedetlSn: subItem.FeedetlSn,
  8678. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  8679. // MedListCodg: subItem.MedListCodg,
  8680. // Type: 2,
  8681. // }
  8682. //
  8683. // customs = append(customs, cus)
  8684. // }
  8685. // }
  8686. //
  8687. // for _, item := range item.HisAdditionalCharge {
  8688. // cus := &Custom{
  8689. // ItemId: item.ID,
  8690. // AdviceId: 0,
  8691. // ProjectId: 0,
  8692. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  8693. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  8694. // FeedetlSn: item.FeedetlSn,
  8695. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  8696. // MedListCodg: item.XtHisAddtionConfig.Code,
  8697. // Type: 3,
  8698. // }
  8699. //
  8700. // customs = append(customs, cus)
  8701. // }
  8702. //
  8703. // }
  8704. //
  8705. // for _, item := range customs {
  8706. // var advice_id int64 = 0
  8707. // var project_id int64 = 0
  8708. // var item_id int64 = 0
  8709. //
  8710. // var types int64 = 0
  8711. //
  8712. // if item.Type == 1 {
  8713. // advice_id = item.AdviceId
  8714. // project_id = 0
  8715. // item_id = 0
  8716. // } else if item.Type == 2 {
  8717. // advice_id = 0
  8718. // item_id = 0
  8719. //
  8720. // project_id = item.ProjectId
  8721. // } else if item.Type == 3 {
  8722. // advice_id = 0
  8723. // item_id = item.ItemId
  8724. // project_id = 0
  8725. // }
  8726. //
  8727. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  8728. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  8729. // pric, _ := strconv.ParseFloat(item.Price, 32)
  8730. //
  8731. // info := &models.HisOrderInfo{
  8732. // OrderNumber: order.Number,
  8733. // UploadDate: time.Now().Unix(),
  8734. // AdviceId: advice_id,
  8735. // DetItemFeeSumamt: detItemFeeSumamt,
  8736. // Cnt: cut,
  8737. // Pric: pric,
  8738. // PatientId: id,
  8739. // Status: 1,
  8740. // Mtime: time.Now().Unix(),
  8741. // Ctime: time.Now().Unix(),
  8742. // UserOrgId: adminUser.CurrentOrgId,
  8743. // HisPatientId: his.ID,
  8744. // OrderId: order.ID,
  8745. // ProjectId: project_id,
  8746. // Type: types,
  8747. // ItemId: item_id,
  8748. // }
  8749. // service.CreateOrderInfo(info)
  8750. // }
  8751. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8752. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8753. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  8754. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8755. // if err == nil {
  8756. // c.ServeSuccessJSON(map[string]interface{}{
  8757. // "msg": "结算成功",
  8758. // })
  8759. // } else {
  8760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8761. // return
  8762. // }
  8763. // }
  8764. //}
  8765. //上传明细-预结算-
  8766. func (c *HisApiController) GetPreUploadInfo() {
  8767. id, _ := c.GetInt64("id")
  8768. record_time := c.GetString("record_time")
  8769. his_patient_id, _ := c.GetInt64("his_patient_id")
  8770. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8771. admin_user_id, _ := c.GetInt64("admin_user_id")
  8772. diagnosis_id := c.GetString("diagnosis")
  8773. sick_type, _ := c.GetInt64("sick_type")
  8774. reg_type, _ := c.GetInt64("p_type")
  8775. begin_time := c.GetString("begin_time")
  8776. id_str := c.GetString("ids")
  8777. ids_arr := strings.Split(id_str, ",")
  8778. timeLayout := "2006-01-02"
  8779. loc, _ := time.LoadLocation("Local")
  8780. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8781. if err != nil {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8783. return
  8784. }
  8785. recordDateTime := theTime.Unix()
  8786. adminUser := c.GetAdminUserInfo()
  8787. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8788. var config []*models.HisXtDiagnoseConfig
  8789. for _, item := range diagnosis_ids {
  8790. id, _ := strconv.ParseInt(item, 10, 64)
  8791. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8792. config = append(config, &diagnosisConfig)
  8793. }
  8794. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8795. sickConfig, _ := service.FindSickById(sick_type)
  8796. var prescriptions []*models.HisPrescription
  8797. var start_time int64
  8798. var end_time int64
  8799. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8800. fmt.Println(his_patient_id)
  8801. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8802. timestamp := time.Now().Unix()
  8803. tempTime := time.Unix(timestamp, 0)
  8804. timeFormat := tempTime.Format("20060102150405")
  8805. chrgBchno := rand.Intn(100000) + 10000
  8806. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8808. var patientPrescription models.HisPrescriptionInfo
  8809. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8810. if patientPrescription.ID == 0 {
  8811. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8812. }
  8813. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8814. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8815. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8816. strconv.FormatInt(his.PatientId, 10)
  8817. var res2 ResultSix
  8818. var resSix10265 ResultSix10265
  8819. //var time_stamp string
  8820. if miConfig.MdtrtareaAdmvs == "421300" {
  8821. data := make(map[string]interface{})
  8822. client := &http.Client{}
  8823. data["psn_no"] = his.PsnNo
  8824. data["mdtrt_id"] = his.Number
  8825. data["department"] = department.Name
  8826. data["org_name"] = miConfig.OrgName
  8827. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8828. data["doctor_id"] = doctor_info.DoctorNumber
  8829. data["doctor_name"] = roles.UserName
  8830. data["fixmedins_code"] = miConfig.Code
  8831. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8832. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8833. data["secret_key"] = miConfig.SecretKey
  8834. data["sick_code"] = sickConfig.CountryCode
  8835. data["sick_name"] = sickConfig.ClassName
  8836. data["begin_time"] = begin_time
  8837. data["dept"] = strconv.FormatInt(department.ID, 10)
  8838. data["config"] = config
  8839. data["opter"] = roles.UserName
  8840. fmt.Println(data)
  8841. bytesData, _ := json.Marshal(data)
  8842. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8843. resp, _ := client.Do(req)
  8844. defer resp.Body.Close()
  8845. body, ioErr := ioutil.ReadAll(resp.Body)
  8846. if ioErr != nil {
  8847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. var respJSON map[string]interface{}
  8852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8855. return
  8856. }
  8857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8858. userJSONBytes, _ := json.Marshal(respJSON)
  8859. fmt.Println("log")
  8860. fmt.Println(string(userJSONBytes))
  8861. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8862. utils.ErrorLog("解析失败:%v", err)
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. return
  8865. }
  8866. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8867. data := make(map[string]interface{})
  8868. client := &http.Client{}
  8869. data["psn_no"] = his.PsnNo
  8870. data["mdtrt_id"] = his.Number
  8871. data["doctor"] = roles.UserName
  8872. data["department"] = department.Name
  8873. data["org_name"] = miConfig.OrgName
  8874. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8875. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  8876. data["fixmedins_code"] = miConfig.Code
  8877. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8878. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8879. data["secret_key"] = miConfig.SecretKey
  8880. data["sick_code"] = sickConfig.CountryCode
  8881. data["sick_name"] = sickConfig.ClassName
  8882. data["begin_time"] = begin_time
  8883. data["dept"] = strconv.FormatInt(department.ID, 10)
  8884. data["config"] = config
  8885. data["url"] = miConfig.Url
  8886. data["ak"] = miConfig.AccessKey
  8887. data["cainfo"] = miConfig.Cainfo
  8888. bytesData, _ := json.Marshal(data)
  8889. var req *http.Request
  8890. if miConfig.MdtrtareaAdmvs == "320921" {
  8891. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8892. } else {
  8893. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8894. }
  8895. resp, _ := client.Do(req)
  8896. defer resp.Body.Close()
  8897. body, ioErr := ioutil.ReadAll(resp.Body)
  8898. if ioErr != nil {
  8899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. var respJSON map[string]interface{}
  8904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  8910. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  8911. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  8912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8913. userJSONBytes, _ := json.Marshal(respJSON)
  8914. fmt.Println("log")
  8915. fmt.Println(string(userJSONBytes))
  8916. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8917. utils.ErrorLog("解析失败:%v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8922. res2.Output = resSix10265.Output
  8923. res2.ErrMsg = resSix10265.ErrMsg
  8924. res2.Cainfo = resSix10265.Cainfo
  8925. res2.WarnMsg = resSix10265.WarnMsg
  8926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8927. res2.Infcode = infocode
  8928. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8929. 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)
  8930. saveLog(result, requestLog, "2203", "上传就诊信息")
  8931. var respJSON2 map[string]interface{}
  8932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8935. return
  8936. }
  8937. userJSONBytes2, _ := json.Marshal(respJSON2)
  8938. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8939. utils.ErrorLog("解析失败:%v", err)
  8940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8941. return
  8942. }
  8943. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8944. var result string
  8945. var requestLog string
  8946. 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, "")
  8947. saveLog(result, requestLog, "2203", "上传就诊信息")
  8948. var respJSON2 map[string]interface{}
  8949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. userJSONBytes2, _ := json.Marshal(respJSON2)
  8955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8956. utils.ErrorLog("解析失败:%v", err)
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8958. return
  8959. }
  8960. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8961. var result string
  8962. var requestLog string
  8963. 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, "")
  8964. saveLog(result, requestLog, "2203", "上传就诊信息")
  8965. var respJSON2 map[string]interface{}
  8966. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8969. return
  8970. }
  8971. userJSONBytes2, _ := json.Marshal(respJSON2)
  8972. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8973. utils.ErrorLog("解析失败:%v", err)
  8974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8975. return
  8976. }
  8977. } else {
  8978. var result string
  8979. var requestLog string
  8980. if miConfig.MdtrtareaAdmvs == "440781" { //
  8981. 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)
  8982. } else {
  8983. if miConfig.Code == "H15049901371" {
  8984. //赤峰地区国家医保医疗类别
  8985. //职工透析:医疗类别选特殊情况门诊990502
  8986. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8987. var med_type string
  8988. if his.Insutype == "390" {
  8989. if reg_type == 14 {
  8990. med_type = "9933"
  8991. } else if reg_type == 11 {
  8992. med_type = "11"
  8993. }
  8994. } else if his.Insutype == "310" {
  8995. if reg_type == 14 {
  8996. med_type = "990502"
  8997. } else if reg_type == 11 {
  8998. med_type = "11"
  8999. }
  9000. }
  9001. 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)
  9002. } else {
  9003. 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)
  9004. }
  9005. saveLog(result, requestLog, "2203", "上传就诊信息")
  9006. var respJSON2 map[string]interface{}
  9007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. userJSONBytes2, _ := json.Marshal(respJSON2)
  9013. if miConfig.Code == "H15049901371" {
  9014. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9015. utils.ErrorLog("解析失败:%v", err)
  9016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9017. return
  9018. }
  9019. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9020. res2.Output = resSix10265.Output
  9021. res2.ErrMsg = resSix10265.ErrMsg
  9022. res2.Cainfo = resSix10265.Cainfo
  9023. res2.WarnMsg = resSix10265.WarnMsg
  9024. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9025. res2.Infcode = infocode
  9026. } else {
  9027. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9028. utils.ErrorLog("解析失败:%v", err)
  9029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9030. return
  9031. }
  9032. }
  9033. }
  9034. }
  9035. if res2.Infcode != 0 {
  9036. adminUser := c.GetAdminUserInfo()
  9037. errlog := &models.HisOrderError{
  9038. UserOrgId: adminUser.CurrentOrgId,
  9039. Ctime: time.Now().Unix(),
  9040. Mtime: time.Now().Unix(),
  9041. ErrMsg: res2.ErrMsg,
  9042. Status: 1,
  9043. PatientId: id,
  9044. RecordTime: recordDateTime,
  9045. Stage: 3,
  9046. }
  9047. service.CreateErrMsgLog(errlog)
  9048. c.ServeSuccessJSON(map[string]interface{}{
  9049. "failed_code": -10,
  9050. "msg": res2.ErrMsg,
  9051. })
  9052. return
  9053. } else {
  9054. his.Diagnosis = diagnosis_id
  9055. his.SickType = sickConfig.ID
  9056. his.PType = fmt.Sprintf("%d", reg_type)
  9057. service.UpdateHisPatientThree(&his)
  9058. data := make(map[string]interface{})
  9059. if settle_accounts_type == 1 { //日结
  9060. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9061. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9062. } else {
  9063. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9064. }
  9065. data["pre"] = prescriptions
  9066. } else { //月结
  9067. start_time_str := c.GetString("start_time")
  9068. end_time_str := c.GetString("end_time")
  9069. timeLayout := "2006-01-02"
  9070. loc, _ := time.LoadLocation("Local")
  9071. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9072. if err != nil {
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9074. return
  9075. }
  9076. recordStartTime := theStartTime.Unix()
  9077. start_time = recordStartTime
  9078. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9079. if err != nil {
  9080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9081. return
  9082. }
  9083. recordEndTime := theEndTime.Unix()
  9084. end_time = recordEndTime
  9085. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9086. data["pre"] = prescriptions
  9087. }
  9088. client := &http.Client{}
  9089. data["psn_no"] = his.PsnNo
  9090. data["mdtrt_id"] = his.Number
  9091. data["chrg_bchno"] = chrg_bchno
  9092. data["org_name"] = miConfig.OrgName
  9093. data["doctor"] = doctor_info.UserName
  9094. data["doctor_id"] = doctor_info.DoctorNumber
  9095. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9096. data["fixmedins_code"] = miConfig.Code
  9097. data["opter"] = roles.UserName
  9098. data["dept_code"] = department.Number
  9099. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9100. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9101. data["secret_key"] = miConfig.SecretKey
  9102. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9103. data["url"] = miConfig.Url
  9104. data["ak"] = miConfig.AccessKey
  9105. data["new_doctor_name"] = patientPrescription.Doctor
  9106. data["diag_code"] = sickConfig.CountryCode
  9107. data["cainfo"] = miConfig.Cainfo
  9108. data["opter"] = roles.UserName
  9109. var ids []int64
  9110. for _, item := range prescriptions {
  9111. ids = append(ids, item.ID)
  9112. }
  9113. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9114. if config.IsOpen == 1 { //对接了医保,走医保流程
  9115. var res ResultFour
  9116. var resFour10265 ResultFour10265
  9117. if miConfig.MdtrtareaAdmvs == "421300" {
  9118. bytesData, _ := json.Marshal(data)
  9119. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9120. resp, _ := client.Do(req)
  9121. defer resp.Body.Close()
  9122. body, ioErr := ioutil.ReadAll(resp.Body)
  9123. if ioErr != nil {
  9124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. var respJSON map[string]interface{}
  9129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9135. userJSONBytes, _ := json.Marshal(respJSON)
  9136. fmt.Println("log")
  9137. fmt.Println(string(userJSONBytes))
  9138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9139. utils.ErrorLog("解析失败:%v", err)
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. return
  9142. }
  9143. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9144. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9145. if result3101.Infcode == "0" {
  9146. if len(result3101.Output.Result) > 0 {
  9147. var errMsgs []string
  9148. for _, item := range result3101.Output.Result {
  9149. errMsgs = append(errMsgs, item.VolaCont)
  9150. }
  9151. c.ServeSuccessJSON(map[string]interface{}{
  9152. "failed_code": -10,
  9153. "msg": errMsgs,
  9154. })
  9155. return
  9156. } else {
  9157. bytesData, _ := json.Marshal(data)
  9158. var req *http.Request
  9159. if miConfig.MdtrtareaAdmvs == "320921" {
  9160. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9161. } else {
  9162. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9163. }
  9164. resp, _ := client.Do(req)
  9165. defer resp.Body.Close()
  9166. body, ioErr := ioutil.ReadAll(resp.Body)
  9167. if ioErr != nil {
  9168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. var respJSON map[string]interface{}
  9173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9179. userJSONBytes, _ := json.Marshal(respJSON)
  9180. fmt.Println("log")
  9181. fmt.Println(string(userJSONBytes))
  9182. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9183. utils.ErrorLog("解析失败:%v", err)
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9185. return
  9186. }
  9187. res.InfRefmsgid = resFour10265.InfRefmsgid
  9188. res.Output = resFour10265.Output
  9189. res.ErrMsg = resFour10265.ErrMsg
  9190. res.Cainfo = resFour10265.Cainfo
  9191. res.WarnMsg = resFour10265.WarnMsg
  9192. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9193. res.Infcode = infocode
  9194. }
  9195. }
  9196. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9197. 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)
  9198. var dat map[string]interface{}
  9199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9200. fmt.Println(dat)
  9201. } else {
  9202. fmt.Println(err)
  9203. }
  9204. saveLog(result, request_log, "2204", "上传费用明细")
  9205. userJSONBytes, _ := json.Marshal(dat)
  9206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9207. utils.ErrorLog("解析失败:%v", err)
  9208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9209. return
  9210. }
  9211. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9212. 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, "", "")
  9213. var dat map[string]interface{}
  9214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9215. fmt.Println(dat)
  9216. } else {
  9217. fmt.Println(err)
  9218. }
  9219. saveLog(result, request_log, "2204", "上传费用明细")
  9220. userJSONBytes, _ := json.Marshal(dat)
  9221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9227. 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, "", "")
  9228. var dat map[string]interface{}
  9229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9230. fmt.Println(dat)
  9231. } else {
  9232. fmt.Println(err)
  9233. }
  9234. saveLog(result, request_log, "2204", "上传费用明细")
  9235. userJSONBytes, _ := json.Marshal(dat)
  9236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9237. utils.ErrorLog("解析失败:%v", err)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. } else {
  9242. if miConfig.Code == "H15049901371" {
  9243. 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)
  9244. var dat map[string]interface{}
  9245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9246. fmt.Println(dat)
  9247. } else {
  9248. fmt.Println(err)
  9249. }
  9250. saveLog(result, request_log, "2204", "上传费用明细")
  9251. userJSONBytes, _ := json.Marshal(dat)
  9252. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9253. utils.ErrorLog("解析失败:%v", err)
  9254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9255. return
  9256. }
  9257. res.InfRefmsgid = resFour10265.InfRefmsgid
  9258. res.Output = resFour10265.Output
  9259. res.ErrMsg = resFour10265.ErrMsg
  9260. res.Cainfo = resFour10265.Cainfo
  9261. res.WarnMsg = resFour10265.WarnMsg
  9262. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9263. res.Infcode = infocode
  9264. } else {
  9265. 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)
  9266. var dat map[string]interface{}
  9267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9268. fmt.Println(dat)
  9269. } else {
  9270. fmt.Println(err)
  9271. }
  9272. saveLog(result, request_log, "2204", "上传费用明细")
  9273. userJSONBytes, _ := json.Marshal(dat)
  9274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9275. utils.ErrorLog("解析失败:%v", err)
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. }
  9280. }
  9281. if res.Infcode == 0 {
  9282. order := &models.HisOrder{
  9283. UserOrgId: adminUser.CurrentOrgId,
  9284. HisPatientId: his.ID,
  9285. PatientId: his.PatientId,
  9286. SettleAccountsDate: recordDateTime,
  9287. Ctime: time.Now().Unix(),
  9288. Mtime: time.Now().Unix(),
  9289. MdtrtId: his.Number,
  9290. PsnNo: his.PsnNo,
  9291. MedType: strconv.FormatInt(reg_type, 10),
  9292. Status: 1,
  9293. Number: chrg_bchno,
  9294. Infcode: res.Infcode,
  9295. WarnMsg: res.WarnMsg,
  9296. Cainfo: res.Cainfo,
  9297. ErrMsg: res.ErrMsg,
  9298. RespondTime: res.RefmsgTime,
  9299. InfRefmsgid: res.InfRefmsgid,
  9300. OrderStatus: 1,
  9301. IsMedicineInsurance: 1,
  9302. SettleType: settle_accounts_type,
  9303. SettleStartTime: start_time,
  9304. SettleEndTime: end_time,
  9305. Creator: roles.AdminUserId,
  9306. Modify: roles.AdminUserId,
  9307. PType: 2,
  9308. Diagnosis: diagnosis_id,
  9309. }
  9310. err = service.CreateOrder(order)
  9311. if err != nil {
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9313. return
  9314. }
  9315. for _, item := range res.Output.Result {
  9316. temp := strings.Split(item.FeedetlSn, "-")
  9317. var advice_id int64 = 0
  9318. var project_id int64 = 0
  9319. var types int64 = 0
  9320. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9321. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9322. if temp[1] == "1" {
  9323. advice_id = id
  9324. project_id = 0
  9325. } else if temp[1] == "2" {
  9326. advice_id = 0
  9327. project_id = id
  9328. }
  9329. info := &models.HisOrderInfo{
  9330. OrderNumber: order.Number,
  9331. FeedetlSn: item.FeedetlSn,
  9332. UploadDate: time.Now().Unix(),
  9333. AdviceId: advice_id,
  9334. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9335. Cnt: item.Cnt,
  9336. Pric: float64(item.Pric),
  9337. PatientId: his.PatientId,
  9338. PricUplmtAmt: item.PricUplmtAmt,
  9339. SelfpayProp: item.SelfpayProp,
  9340. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9341. OverlmtAmt: item.OverlmtAmt,
  9342. PreselfpayAmt: item.PreselfpayAmt,
  9343. BasMednFlag: item.BasMednFlag,
  9344. MedChrgitmType: item.MedChrgitmType,
  9345. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9346. Status: 1,
  9347. Memo: item.Memo,
  9348. Mtime: time.Now().Unix(),
  9349. InscpScpAmt: item.InscpScpAmt,
  9350. DrtReimFlag: item.DrtReimFlag,
  9351. Ctime: time.Now().Unix(),
  9352. ListSpItemFlag: item.ListSpItemFlag,
  9353. ChldMedcFlag: item.ChldMedcFlag,
  9354. LmtUsedFlag: item.LmtUsedFlag,
  9355. ChrgitmLv: item.ChrgitmLv,
  9356. UserOrgId: adminUser.CurrentOrgId,
  9357. HisPatientId: his.ID,
  9358. OrderId: order.ID,
  9359. ProjectId: project_id,
  9360. Type: types,
  9361. }
  9362. service.CreateOrderInfo(info)
  9363. }
  9364. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9365. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9366. var total float64
  9367. for _, item := range prescriptions {
  9368. if item.Type == 1 { //药品
  9369. for _, subItem := range item.HisDoctorAdviceInfo {
  9370. total = total + (subItem.Price * subItem.PrescribingNumber)
  9371. }
  9372. }
  9373. if item.Type == 2 { //项目
  9374. for _, subItem := range item.HisPrescriptionProject {
  9375. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9376. total = total + (subItem.Price * cnt)
  9377. }
  9378. }
  9379. }
  9380. for _, item := range prescriptions {
  9381. for _, subItem := range item.HisAdditionalCharge {
  9382. total = total + (subItem.Price * float64(subItem.Count))
  9383. }
  9384. }
  9385. allTotal := fmt.Sprintf("%.4f", total)
  9386. if res.Infcode == 0 {
  9387. var rf []*ResultFive
  9388. json.Unmarshal([]byte(his.Iinfo), &rf)
  9389. chrg_bchno := chrg_bchno
  9390. cert_no := his.Certno
  9391. var insutypes []string
  9392. var insutype string
  9393. var is390 int = 0
  9394. var is310 int = 0
  9395. for _, item := range rf {
  9396. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9397. insutypes = append(insutypes, item.Insutype)
  9398. }
  9399. }
  9400. if len(insutypes) == 1 {
  9401. insutype = insutypes[0]
  9402. } else {
  9403. for _, i := range insutypes {
  9404. if i == "390" {
  9405. is390 = 1
  9406. }
  9407. if i == "310" {
  9408. is310 = 1
  9409. }
  9410. }
  9411. }
  9412. if is390 == 1 {
  9413. insutype = "390"
  9414. }
  9415. if is310 == 1 {
  9416. insutype = "310"
  9417. }
  9418. if len(insutypes) == 0 {
  9419. insutype = "310"
  9420. }
  9421. if len(insutypes) == 2 {
  9422. insutype = strconv.FormatInt(his.SocialType, 64)
  9423. }
  9424. //insutype = "390"
  9425. if his.IdCardType == 1 {
  9426. cert_no = his.MedicalInsuranceNumber
  9427. } else {
  9428. cert_no = his.Certno
  9429. }
  9430. var res ResultSeven
  9431. var resSeven10265 ResultSeven10265
  9432. if miConfig.MdtrtareaAdmvs == "421300" {
  9433. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9434. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9435. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9436. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9437. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9438. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9439. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9440. resp, requestErr := http.Get(api)
  9441. if requestErr != nil {
  9442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9443. return
  9444. }
  9445. body, ioErr := ioutil.ReadAll(resp.Body)
  9446. if ioErr != nil {
  9447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9449. return
  9450. }
  9451. var respJSON map[string]interface{}
  9452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9455. return
  9456. }
  9457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9458. result, _ := json.Marshal(respJSON)
  9459. fmt.Println("log")
  9460. fmt.Println(string(result))
  9461. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9462. utils.ErrorLog("解析失败:%v", err)
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. return
  9465. }
  9466. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9467. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9468. if result3101.Infcode == "0" {
  9469. if len(result3101.Output.Result) > 0 {
  9470. var errMsgs []string
  9471. for _, item := range result3101.Output.Result {
  9472. errMsgs = append(errMsgs, item.VolaCont)
  9473. }
  9474. c.ServeSuccessJSON(map[string]interface{}{
  9475. "failed_code": -10,
  9476. "msg": errMsgs,
  9477. })
  9478. return
  9479. } else {
  9480. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9481. if his.IdCardType != 4 {
  9482. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9483. bas := strings.Split(psn_info.CardInfo, "|")
  9484. if his.IdCardType == 1 {
  9485. cert_no = bas[2]
  9486. } else {
  9487. cert_no = bas[1]
  9488. }
  9489. } else {
  9490. cert_no = his.Certno
  9491. }
  9492. //江苏地区国家医保医疗类别
  9493. //职工透析:医疗类别选特殊情况门诊9933
  9494. //居民血透门慢: 医疗类别选门诊慢病1402
  9495. //var med_type string
  9496. //if his.Insutype == "310" {
  9497. // if reg_type == 14 {
  9498. // med_type = "9933"
  9499. // } else if reg_type == 11 {
  9500. // med_type = "11"
  9501. //
  9502. // }
  9503. //} else if his.Insutype == "390" {
  9504. // if reg_type == 14 {
  9505. // med_type = "1402"
  9506. // } else if reg_type == 11 {
  9507. // med_type = "11"
  9508. // }
  9509. //}
  9510. var api string
  9511. if miConfig.MdtrtareaAdmvs == "320921" {
  9512. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9513. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9514. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9516. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9517. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9518. "&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
  9519. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9520. } else {
  9521. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9522. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9523. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9524. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9525. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9526. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9527. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9528. "&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
  9529. }
  9530. resp, requestErr := http.Get(api)
  9531. if requestErr != nil {
  9532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9533. return
  9534. }
  9535. body, ioErr := ioutil.ReadAll(resp.Body)
  9536. if ioErr != nil {
  9537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. var respJSON map[string]interface{}
  9542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9548. result, _ := json.Marshal(respJSON)
  9549. fmt.Println("log")
  9550. fmt.Println(string(result))
  9551. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9552. utils.ErrorLog("解析失败:%v", err)
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9554. return
  9555. }
  9556. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9557. res.Output = resSeven10265.Output
  9558. res.ErrMsg = resSeven10265.ErrMsg
  9559. res.Cainfo = resSeven10265.Cainfo
  9560. res.WarnMsg = resSeven10265.WarnMsg
  9561. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9562. res.Infcode = infocode
  9563. }
  9564. }
  9565. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9566. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9567. var result string
  9568. var request_log string
  9569. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  9570. 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)
  9571. } else {
  9572. 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)
  9573. }
  9574. var dat map[string]interface{}
  9575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9576. fmt.Println(dat)
  9577. } else {
  9578. fmt.Println(err)
  9579. }
  9580. saveLog(result, request_log, "2206", "预结算")
  9581. userJSONBytes, _ := json.Marshal(dat)
  9582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9583. utils.ErrorLog("解析失败:%v", err)
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9588. var result string
  9589. var request_log string
  9590. if his.IdCardType == 2 {
  9591. 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, "")
  9592. } else if his.IdCardType == 1 {
  9593. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9594. bas := strings.Split(psn_info.CardInfo, "|")
  9595. basNumber := bas[2]
  9596. card_sn := bas[3]
  9597. 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)
  9598. } else {
  9599. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9600. 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, "")
  9601. }
  9602. var dat map[string]interface{}
  9603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9604. fmt.Println(dat)
  9605. } else {
  9606. fmt.Println(err)
  9607. }
  9608. saveLog(result, request_log, "2206", "预结算")
  9609. userJSONBytes, _ := json.Marshal(dat)
  9610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9611. utils.ErrorLog("解析失败:%v", err)
  9612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9613. return
  9614. }
  9615. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9616. var result string
  9617. var request_log string
  9618. if his.IdCardType == 2 {
  9619. 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, "")
  9620. } else if his.IdCardType == 1 {
  9621. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9622. bas := strings.Split(psn_info.CardInfo, "|")
  9623. basNumber := bas[2]
  9624. card_sn := bas[3]
  9625. 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)
  9626. } else {
  9627. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9628. 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, "")
  9629. }
  9630. var dat map[string]interface{}
  9631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9632. fmt.Println(dat)
  9633. } else {
  9634. fmt.Println(err)
  9635. }
  9636. saveLog(result, request_log, "2206", "预结算")
  9637. userJSONBytes, _ := json.Marshal(dat)
  9638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9639. utils.ErrorLog("解析失败:%v", err)
  9640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9641. return
  9642. }
  9643. } else {
  9644. var result string
  9645. var request_log string
  9646. if miConfig.Code == "H15049901371" {
  9647. //赤峰地区国家医保医疗类别
  9648. //职工透析:医疗类别选特殊情况门诊990502
  9649. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9650. var med_type string
  9651. if his.Insutype == "390" {
  9652. if reg_type == 14 {
  9653. med_type = "9933"
  9654. } else if reg_type == 11 {
  9655. med_type = "11"
  9656. }
  9657. } else if his.Insutype == "310" {
  9658. if reg_type == 14 {
  9659. med_type = "990502"
  9660. } else if reg_type == 11 {
  9661. med_type = "11"
  9662. }
  9663. }
  9664. 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)
  9665. } else {
  9666. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9667. if his.IdCardType == 4 {
  9668. 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)
  9669. } else {
  9670. 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)
  9671. }
  9672. }
  9673. var dat map[string]interface{}
  9674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9675. fmt.Println(dat)
  9676. } else {
  9677. fmt.Println(err)
  9678. }
  9679. saveLog(result, request_log, "2206", "预结算")
  9680. //userJSONBytes, _ := json.Marshal(dat)
  9681. //
  9682. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9683. // utils.ErrorLog("解析失败:%v", err)
  9684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. // return
  9686. //}
  9687. userJSONBytes, _ := json.Marshal(dat)
  9688. if miConfig.Code == "H15049901371" {
  9689. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9690. utils.ErrorLog("解析失败:%v", err)
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9692. return
  9693. }
  9694. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9695. res.Output = resSeven10265.Output
  9696. res.ErrMsg = resSeven10265.ErrMsg
  9697. res.Cainfo = resSeven10265.Cainfo
  9698. res.WarnMsg = resSeven10265.WarnMsg
  9699. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9700. res.Infcode = infocode
  9701. } else {
  9702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9703. utils.ErrorLog("解析失败:%v", err)
  9704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9705. return
  9706. }
  9707. }
  9708. }
  9709. if res.Infcode != 0 {
  9710. errlog := &models.HisOrderError{
  9711. UserOrgId: adminUser.CurrentOrgId,
  9712. Ctime: time.Now().Unix(),
  9713. Mtime: time.Now().Unix(),
  9714. Number: chrg_bchno,
  9715. ErrMsg: res.ErrMsg,
  9716. Status: 1,
  9717. PatientId: id,
  9718. RecordTime: recordDateTime,
  9719. Stage: 20,
  9720. }
  9721. service.CreateErrMsgLog(errlog)
  9722. c.ServeSuccessJSON(map[string]interface{}{
  9723. "failed_code": -10,
  9724. "msg": res.ErrMsg,
  9725. })
  9726. return
  9727. } else {
  9728. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9729. order.OrderStatus = 1
  9730. order.IsPre = 1
  9731. order.Status = 1
  9732. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9733. order.SetlId = res.Output.Setlinfo.SetlID
  9734. order.PsnNo = res.Output.Setlinfo.PsnNo
  9735. order.PsnName = res.Output.Setlinfo.PsnName
  9736. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9737. order.Certno = res.Output.Setlinfo.Certno
  9738. order.Gend = res.Output.Setlinfo.Gend
  9739. order.Naty = res.Output.Setlinfo.Naty
  9740. order.Age = res.Output.Setlinfo.Age
  9741. order.Insutype = res.Output.Setlinfo.Insutype
  9742. order.PsnType = res.Output.Setlinfo.PsnType
  9743. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9744. order.SetlTime = res.Output.Setlinfo.SetlTime
  9745. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9746. if res.Output.Setlinfo.MedType == "140101" {
  9747. order.MedType = "14"
  9748. } else {
  9749. order.MedType = res.Output.Setlinfo.MedType
  9750. }
  9751. if reg_type == 1112 {
  9752. order.MedType = "1112"
  9753. }
  9754. if reg_type == 1111 {
  9755. order.MedType = "1111"
  9756. }
  9757. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9758. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9759. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9760. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9761. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9762. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9763. order.HifpPay = res.Output.Setlinfo.HifpPay
  9764. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9765. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9766. order.HifesPay = res.Output.Setlinfo.HifesPay
  9767. order.HifobPay = res.Output.Setlinfo.HifobPay
  9768. order.MafPay = res.Output.Setlinfo.MafPay
  9769. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9770. order.OthPay = res.Output.Setlinfo.OthPay
  9771. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9772. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9773. order.AcctPay = res.Output.Setlinfo.AcctPay
  9774. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9775. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9776. order.Balc = res.Output.Setlinfo.Balc
  9777. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9778. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9779. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9780. order.ClrWay = res.Output.Setlinfo.ClrWay
  9781. order.Creator = order.Creator
  9782. order.Modify = roles.AdminUserId
  9783. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9784. detailStr := string(setlDetail)
  9785. order.SetlDetail = detailStr
  9786. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9787. err = service.UpDateOrder(order)
  9788. if err == nil {
  9789. c.ServeSuccessJSON(map[string]interface{}{
  9790. "msg": "预结算成功",
  9791. })
  9792. } else {
  9793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9794. return
  9795. }
  9796. }
  9797. } else {
  9798. adminUser := c.GetAdminUserInfo()
  9799. errlog := &models.HisOrderError{
  9800. UserOrgId: adminUser.CurrentOrgId,
  9801. Ctime: time.Now().Unix(),
  9802. Mtime: time.Now().Unix(),
  9803. ErrMsg: res.ErrMsg,
  9804. Status: 1,
  9805. PatientId: id,
  9806. RecordTime: recordDateTime,
  9807. Stage: 4,
  9808. }
  9809. service.CreateErrMsgLog(errlog)
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9811. return
  9812. }
  9813. } else {
  9814. adminUser := c.GetAdminUserInfo()
  9815. errlog := &models.HisOrderError{
  9816. UserOrgId: adminUser.CurrentOrgId,
  9817. Ctime: time.Now().Unix(),
  9818. Mtime: time.Now().Unix(),
  9819. ErrMsg: res.ErrMsg,
  9820. Status: 1,
  9821. PatientId: id,
  9822. RecordTime: recordDateTime,
  9823. Stage: 4,
  9824. }
  9825. service.CreateErrMsgLog(errlog)
  9826. c.ServeSuccessJSON(map[string]interface{}{
  9827. "failed_code": -10,
  9828. "msg": res.ErrMsg,
  9829. })
  9830. return
  9831. }
  9832. }
  9833. }
  9834. }
  9835. //退款
  9836. func (c *HisApiController) Refund() {
  9837. order_id, _ := c.GetInt64("order_id")
  9838. admin_user_id, _ := c.GetInt64("admin_user_id")
  9839. adminUser := c.GetAdminUserInfo()
  9840. var order models.HisOrder
  9841. order, _ = service.GetHisOrderByID(order_id)
  9842. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9843. if order.ID == 0 {
  9844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9845. return
  9846. }
  9847. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9848. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9849. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9850. if config.IsOpen == 1 { //对接了医保,走医保流程
  9851. var res ResultSixteen
  9852. var resSixteen10265 ResultSixteen10265
  9853. var src_resquest string
  9854. var result string
  9855. if miConfig.MdtrtareaAdmvs == "421300" {
  9856. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  9857. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9858. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9859. resp3, requestErr3 := http.Get(api3)
  9860. if requestErr3 != nil {
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9862. return
  9863. }
  9864. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9865. if ioErr3 != nil {
  9866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9868. return
  9869. }
  9870. var respJSON3 map[string]interface{}
  9871. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9874. return
  9875. }
  9876. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9877. userJSONBytes3, _ := json.Marshal(respJSON3)
  9878. fmt.Println("log")
  9879. fmt.Println(string(userJSONBytes3))
  9880. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  9881. utils.ErrorLog("解析失败:%v", err)
  9882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9883. return
  9884. }
  9885. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9886. var api3 string
  9887. if miConfig.MdtrtareaAdmvs == "320921" {
  9888. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  9889. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9891. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9892. } else {
  9893. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9894. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  9895. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9897. }
  9898. resp3, requestErr3 := http.Get(api3)
  9899. if requestErr3 != nil {
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9901. return
  9902. }
  9903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9904. if ioErr3 != nil {
  9905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9907. return
  9908. }
  9909. var respJSON3 map[string]interface{}
  9910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9913. return
  9914. }
  9915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9916. userJSONBytes3, _ := json.Marshal(respJSON3)
  9917. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  9918. utils.ErrorLog("解析失败:%v", err)
  9919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9920. return
  9921. }
  9922. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  9923. res.Output = resSixteen10265.Output
  9924. res.ErrMsg = resSixteen10265.ErrMsg
  9925. res.Cainfo = resSixteen10265.Cainfo
  9926. res.WarnMsg = resSixteen10265.WarnMsg
  9927. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  9928. res.Infcode = infocode
  9929. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9930. 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)
  9931. var dat map[string]interface{}
  9932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9933. fmt.Println(dat)
  9934. } else {
  9935. fmt.Println(err)
  9936. }
  9937. saveLog(result, src_resquest, "2208", "退费")
  9938. userJSONBytes, _ := json.Marshal(dat)
  9939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9940. utils.ErrorLog("解析失败:%v", err)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9945. 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, "")
  9946. var dat map[string]interface{}
  9947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9948. fmt.Println(dat)
  9949. } else {
  9950. fmt.Println(err)
  9951. }
  9952. saveLog(result, src_resquest, "2208", "退费")
  9953. userJSONBytes, _ := json.Marshal(dat)
  9954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9955. utils.ErrorLog("解析失败:%v", err)
  9956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9957. return
  9958. }
  9959. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9960. 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, "")
  9961. var dat map[string]interface{}
  9962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9963. fmt.Println(dat)
  9964. } else {
  9965. fmt.Println(err)
  9966. }
  9967. saveLog(result, src_resquest, "2208", "退费")
  9968. userJSONBytes, _ := json.Marshal(dat)
  9969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9970. utils.ErrorLog("解析失败:%v", err)
  9971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9972. return
  9973. }
  9974. } else {
  9975. if miConfig.Code == "H15049901371" {
  9976. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  9977. var dat map[string]interface{}
  9978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9979. fmt.Println(dat)
  9980. } else {
  9981. fmt.Println(err)
  9982. }
  9983. saveLog(result, src_resquest, "2208", "退费")
  9984. userJSONBytes, _ := json.Marshal(dat)
  9985. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  9986. utils.ErrorLog("解析失败:%v", err)
  9987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9988. return
  9989. }
  9990. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  9991. res.Output = resSixteen10265.Output
  9992. res.ErrMsg = resSixteen10265.ErrMsg
  9993. res.Cainfo = resSixteen10265.Cainfo
  9994. res.WarnMsg = resSixteen10265.WarnMsg
  9995. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  9996. res.Infcode = infocode
  9997. } else {
  9998. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  9999. var dat map[string]interface{}
  10000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10001. fmt.Println(dat)
  10002. } else {
  10003. fmt.Println(err)
  10004. }
  10005. saveLog(result, src_resquest, "2208", "退费")
  10006. userJSONBytes, _ := json.Marshal(dat)
  10007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10008. utils.ErrorLog("解析失败:%v", err)
  10009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10010. return
  10011. }
  10012. }
  10013. }
  10014. if res.Infcode == 0 {
  10015. var res2 ResultSix
  10016. var resSix10265 ResultSix10265
  10017. if miConfig.MdtrtareaAdmvs == "421300" {
  10018. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10019. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10021. resp3, requestErr3 := http.Get(api3)
  10022. if requestErr3 != nil {
  10023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10024. return
  10025. }
  10026. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10027. if ioErr3 != nil {
  10028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10030. return
  10031. }
  10032. var respJSON3 map[string]interface{}
  10033. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10036. return
  10037. }
  10038. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10039. userJSONBytes3, _ := json.Marshal(respJSON3)
  10040. fmt.Println("log")
  10041. fmt.Println(string(userJSONBytes3))
  10042. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10043. utils.ErrorLog("解析失败:%v", err)
  10044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10045. return
  10046. }
  10047. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10048. var api3 string
  10049. if miConfig.MdtrtareaAdmvs == "320921" {
  10050. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10051. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10053. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10054. } else {
  10055. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10056. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10057. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10058. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10059. }
  10060. resp3, requestErr3 := http.Get(api3)
  10061. if requestErr3 != nil {
  10062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10063. return
  10064. }
  10065. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10066. if ioErr3 != nil {
  10067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10069. return
  10070. }
  10071. var respJSON3 map[string]interface{}
  10072. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10075. return
  10076. }
  10077. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10078. userJSONBytes3, _ := json.Marshal(respJSON3)
  10079. fmt.Println("log")
  10080. fmt.Println(string(userJSONBytes3))
  10081. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10082. utils.ErrorLog("解析失败:%v", err)
  10083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10084. return
  10085. }
  10086. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10087. res2.Output = resSix10265.Output
  10088. res2.ErrMsg = resSix10265.ErrMsg
  10089. res2.Cainfo = resSix10265.Cainfo
  10090. res2.WarnMsg = resSix10265.WarnMsg
  10091. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10092. res2.Infcode = infocode
  10093. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10094. 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)
  10095. var dat map[string]interface{}
  10096. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10097. fmt.Println(dat)
  10098. } else {
  10099. fmt.Println(err)
  10100. }
  10101. saveLog(result2, src_request, "2205", "撤销明细")
  10102. userJSONBytes, _ := json.Marshal(dat)
  10103. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10104. utils.ErrorLog("解析失败:%v", err)
  10105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10106. return
  10107. }
  10108. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10109. 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, "")
  10110. var dat map[string]interface{}
  10111. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10112. fmt.Println(dat)
  10113. } else {
  10114. fmt.Println(err)
  10115. }
  10116. saveLog(result2, src_request, "2205", "撤销明细")
  10117. userJSONBytes, _ := json.Marshal(dat)
  10118. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10119. utils.ErrorLog("解析失败:%v", err)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10124. 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, "")
  10125. var dat map[string]interface{}
  10126. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10127. fmt.Println(dat)
  10128. } else {
  10129. fmt.Println(err)
  10130. }
  10131. saveLog(result2, src_request, "2205", "撤销明细")
  10132. userJSONBytes, _ := json.Marshal(dat)
  10133. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10134. utils.ErrorLog("解析失败:%v", err)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. } else {
  10139. if miConfig.Code == "H15049901371" {
  10140. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10141. var dat map[string]interface{}
  10142. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10143. fmt.Println(dat)
  10144. } else {
  10145. fmt.Println(err)
  10146. }
  10147. saveLog(result2, src_request, "2205", "撤销明细")
  10148. userJSONBytes, _ := json.Marshal(dat)
  10149. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10150. utils.ErrorLog("解析失败:%v", err)
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10152. return
  10153. }
  10154. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10155. res2.Output = resSix10265.Output
  10156. res2.ErrMsg = resSix10265.ErrMsg
  10157. res2.Cainfo = resSix10265.Cainfo
  10158. res2.WarnMsg = resSix10265.WarnMsg
  10159. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10160. res2.Infcode = infocode
  10161. } else {
  10162. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10163. var dat map[string]interface{}
  10164. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10165. fmt.Println(dat)
  10166. } else {
  10167. fmt.Println(err)
  10168. }
  10169. saveLog(result2, src_request, "2205", "撤销明细")
  10170. userJSONBytes, _ := json.Marshal(dat)
  10171. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10172. utils.ErrorLog("解析失败:%v", err)
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10174. return
  10175. }
  10176. }
  10177. }
  10178. if res2.Infcode == 0 {
  10179. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10180. if err == nil {
  10181. //当押金不为零时产生退费记录
  10182. if order.Decimal != 0 {
  10183. tmp := strconv.FormatInt(order.ID, 10)
  10184. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10185. if err != nil {
  10186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10187. return
  10188. }
  10189. }
  10190. c.ServeSuccessJSON(map[string]interface{}{
  10191. "msg": "退费成功",
  10192. })
  10193. } else {
  10194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10195. return
  10196. }
  10197. } else {
  10198. c.ServeSuccessJSON(map[string]interface{}{
  10199. "code": -10,
  10200. "msg": res2.ErrMsg,
  10201. })
  10202. }
  10203. } else {
  10204. c.ServeSuccessJSON(map[string]interface{}{
  10205. "code": -10,
  10206. "msg": res.ErrMsg,
  10207. })
  10208. }
  10209. }
  10210. }
  10211. func (c *HisApiController) RefundNumber() {
  10212. record_time := c.GetString("record_time")
  10213. //patient_id, _ := c.GetInt64("patient_id")
  10214. admin_user_id, _ := c.GetInt64("admin_user_id")
  10215. his_patient_id, _ := c.GetInt64("id")
  10216. timeLayout := "2006-01-02"
  10217. loc, _ := time.LoadLocation("Local")
  10218. adminUser := c.GetAdminUserInfo()
  10219. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10220. fmt.Println(err)
  10221. if err != nil {
  10222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10223. return
  10224. }
  10225. recordDateTime := theTime.Unix()
  10226. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10227. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10228. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10229. //order, _ := service.GetHisOrderByID(order_id)
  10230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10231. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10232. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10233. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10234. if count > 0 {
  10235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10236. return
  10237. }
  10238. if config.IsOpen == 1 { //对接了医保,走医保流程
  10239. var res2 ResultSix
  10240. var resSix10265 ResultSix10265
  10241. if miConfig.MdtrtareaAdmvs == "421300" {
  10242. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10243. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10245. resp3, requestErr3 := http.Get(api3)
  10246. if requestErr3 != nil {
  10247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10248. return
  10249. }
  10250. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10251. if ioErr3 != nil {
  10252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10254. return
  10255. }
  10256. var respJSON3 map[string]interface{}
  10257. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10263. userJSONBytes3, _ := json.Marshal(respJSON3)
  10264. fmt.Println("log")
  10265. fmt.Println(string(userJSONBytes3))
  10266. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10267. utils.ErrorLog("解析失败:%v", err)
  10268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10269. return
  10270. }
  10271. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10272. var api3 string
  10273. if miConfig.MdtrtareaAdmvs == "320921" {
  10274. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10275. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10276. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10277. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10278. } else {
  10279. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10280. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10281. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10283. }
  10284. resp3, requestErr3 := http.Get(api3)
  10285. if requestErr3 != nil {
  10286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. return
  10288. }
  10289. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10290. if ioErr3 != nil {
  10291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. var respJSON3 map[string]interface{}
  10296. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10299. return
  10300. }
  10301. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10302. userJSONBytes3, _ := json.Marshal(respJSON3)
  10303. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10304. utils.ErrorLog("解析失败:%v", err)
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10306. return
  10307. }
  10308. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10309. res2.Output = resSix10265.Output
  10310. res2.ErrMsg = resSix10265.ErrMsg
  10311. res2.Cainfo = resSix10265.Cainfo
  10312. res2.WarnMsg = resSix10265.WarnMsg
  10313. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10314. res2.Infcode = infocode
  10315. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10316. 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)
  10317. var dat map[string]interface{}
  10318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10319. fmt.Println(dat)
  10320. } else {
  10321. fmt.Println(err)
  10322. }
  10323. saveLog(result, request, "2202", "退号")
  10324. userJSONBytes, _ := json.Marshal(dat)
  10325. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10326. utils.ErrorLog("解析失败:%v", err)
  10327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10328. return
  10329. }
  10330. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10331. 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, "")
  10332. var dat map[string]interface{}
  10333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10334. fmt.Println(dat)
  10335. } else {
  10336. fmt.Println(err)
  10337. }
  10338. saveLog(result, request, "2202", "退号")
  10339. userJSONBytes, _ := json.Marshal(dat)
  10340. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10341. utils.ErrorLog("解析失败:%v", err)
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10343. return
  10344. }
  10345. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10346. 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, "")
  10347. var dat map[string]interface{}
  10348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10349. fmt.Println(dat)
  10350. } else {
  10351. fmt.Println(err)
  10352. }
  10353. saveLog(result, request, "2202", "退号")
  10354. userJSONBytes, _ := json.Marshal(dat)
  10355. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10356. utils.ErrorLog("解析失败:%v", err)
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10358. return
  10359. }
  10360. } else {
  10361. var api3 string
  10362. if miConfig.Code == "H15049901371" {
  10363. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10364. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10366. } else {
  10367. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10368. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10369. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10370. }
  10371. resp3, requestErr3 := http.Get(api3)
  10372. if requestErr3 != nil {
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10374. return
  10375. }
  10376. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10377. if ioErr3 != nil {
  10378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10380. return
  10381. }
  10382. var respJSON3 map[string]interface{}
  10383. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10386. return
  10387. }
  10388. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10389. userJSONBytes3, _ := json.Marshal(respJSON3)
  10390. if miConfig.Code == "H15049901371" {
  10391. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10392. utils.ErrorLog("解析失败:%v", err)
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10394. return
  10395. }
  10396. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10397. res2.Output = resSix10265.Output
  10398. res2.ErrMsg = resSix10265.ErrMsg
  10399. res2.Cainfo = resSix10265.Cainfo
  10400. res2.WarnMsg = resSix10265.WarnMsg
  10401. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10402. res2.Infcode = infocode
  10403. } else {
  10404. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10405. utils.ErrorLog("解析失败:%v", err)
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10407. return
  10408. }
  10409. }
  10410. }
  10411. if res2.Infcode == 0 {
  10412. if err == nil {
  10413. c.ServeSuccessJSON(map[string]interface{}{
  10414. "msg": "退号成功",
  10415. })
  10416. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10417. } else {
  10418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10419. return
  10420. }
  10421. } else {
  10422. c.ServeSuccessJSON(map[string]interface{}{
  10423. "code": -10,
  10424. "msg": res2.ErrMsg,
  10425. })
  10426. }
  10427. } else {
  10428. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10429. //if err == nil {
  10430. // c.ServeSuccessJSON(map[string]interface{}{
  10431. // "msg": "退费成功",
  10432. // })
  10433. //} else {
  10434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10435. // return
  10436. //}
  10437. }
  10438. }
  10439. func (c *HisApiController) RefundDetail() {
  10440. order_id, _ := c.GetInt64("order_id")
  10441. admin_user_id, _ := c.GetInt64("admin_user_id")
  10442. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10443. number := c.GetString("number")
  10444. record_time := c.GetString("record_time")
  10445. patient_id, _ := c.GetInt64("patient_id")
  10446. //med_type, _ := c.GetInt64("med_type")
  10447. timeLayout := "2006-01-02"
  10448. loc, _ := time.LoadLocation("Local")
  10449. adminUser := c.GetAdminUserInfo()
  10450. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10451. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10452. fmt.Println(err)
  10453. if err != nil {
  10454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10455. return
  10456. }
  10457. recordDateTime := theTime.Unix()
  10458. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10459. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10461. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10462. var order models.HisOrder
  10463. order, _ = service.GetHisOrderByID(order_id)
  10464. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10465. if config.IsOpen == 1 { //对接了医保,走医保流程
  10466. var res2 ResultSix
  10467. if miConfig.MdtrtareaAdmvs == "421300" {
  10468. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10469. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10470. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10471. resp3, requestErr3 := http.Get(api3)
  10472. if requestErr3 != nil {
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10474. return
  10475. }
  10476. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10477. if ioErr3 != nil {
  10478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10480. return
  10481. }
  10482. var respJSON3 map[string]interface{}
  10483. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10486. return
  10487. }
  10488. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10489. userJSONBytes3, _ := json.Marshal(respJSON3)
  10490. fmt.Println("log")
  10491. fmt.Println(string(userJSONBytes3))
  10492. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10493. utils.ErrorLog("解析失败:%v", err)
  10494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10495. return
  10496. }
  10497. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10498. if err == nil {
  10499. c.ServeSuccessJSON(map[string]interface{}{
  10500. "msg": "撤销明细成功",
  10501. })
  10502. return
  10503. } else {
  10504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10505. return
  10506. }
  10507. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10508. var resSix10265 ResultSix10265
  10509. var api3 string
  10510. if miConfig.MdtrtareaAdmvs == "320921" {
  10511. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10512. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10514. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10515. } else {
  10516. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10517. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10518. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10519. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10520. }
  10521. resp3, requestErr3 := http.Get(api3)
  10522. if requestErr3 != nil {
  10523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10524. return
  10525. }
  10526. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10527. if ioErr3 != nil {
  10528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10530. return
  10531. }
  10532. var respJSON3 map[string]interface{}
  10533. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10536. return
  10537. }
  10538. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10539. userJSONBytes3, _ := json.Marshal(respJSON3)
  10540. fmt.Println("log")
  10541. fmt.Println(string(userJSONBytes3))
  10542. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10543. utils.ErrorLog("解析失败:%v", err)
  10544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10545. return
  10546. }
  10547. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10548. res2.Output = resSix10265.Output
  10549. res2.ErrMsg = resSix10265.ErrMsg
  10550. res2.Cainfo = resSix10265.Cainfo
  10551. res2.WarnMsg = resSix10265.WarnMsg
  10552. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10553. res2.Infcode = infocode
  10554. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10555. if err == nil {
  10556. c.ServeSuccessJSON(map[string]interface{}{
  10557. "msg": "撤销明细成功",
  10558. })
  10559. return
  10560. } else {
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10565. 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)
  10566. var dat map[string]interface{}
  10567. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10568. fmt.Println(dat)
  10569. } else {
  10570. fmt.Println(err)
  10571. }
  10572. saveLog(result2, src_request, "2205", "撤销明细")
  10573. userJSONBytes, _ := json.Marshal(dat)
  10574. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10575. utils.ErrorLog("解析失败:%v", err)
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10577. return
  10578. }
  10579. if res2.Infcode == 0 {
  10580. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10581. if err == nil {
  10582. c.ServeSuccessJSON(map[string]interface{}{
  10583. "msg": "撤销明细成功",
  10584. })
  10585. return
  10586. } else {
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10588. return
  10589. }
  10590. } else {
  10591. c.ServeSuccessJSON(map[string]interface{}{
  10592. "code": -10,
  10593. "msg": res2.ErrMsg,
  10594. })
  10595. }
  10596. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10597. 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, "")
  10598. var dat map[string]interface{}
  10599. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10600. fmt.Println(dat)
  10601. } else {
  10602. fmt.Println(err)
  10603. }
  10604. saveLog(result2, src_request, "2205", "撤销明细")
  10605. userJSONBytes, _ := json.Marshal(dat)
  10606. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10607. utils.ErrorLog("解析失败:%v", err)
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10609. return
  10610. }
  10611. if res2.Infcode == 0 {
  10612. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10613. if err == nil {
  10614. c.ServeSuccessJSON(map[string]interface{}{
  10615. "msg": "撤销明细成功",
  10616. })
  10617. return
  10618. } else {
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10620. return
  10621. }
  10622. } else {
  10623. c.ServeSuccessJSON(map[string]interface{}{
  10624. "code": -10,
  10625. "msg": res2.ErrMsg,
  10626. })
  10627. }
  10628. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10629. 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, "")
  10630. var dat map[string]interface{}
  10631. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10632. fmt.Println(dat)
  10633. } else {
  10634. fmt.Println(err)
  10635. }
  10636. saveLog(result2, src_request, "2205", "撤销明细")
  10637. userJSONBytes, _ := json.Marshal(dat)
  10638. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10639. utils.ErrorLog("解析失败:%v", err)
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10641. return
  10642. }
  10643. if res2.Infcode == 0 {
  10644. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10645. if err == nil {
  10646. c.ServeSuccessJSON(map[string]interface{}{
  10647. "msg": "撤销明细成功",
  10648. })
  10649. return
  10650. } else {
  10651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10652. return
  10653. }
  10654. } else {
  10655. c.ServeSuccessJSON(map[string]interface{}{
  10656. "code": -10,
  10657. "msg": res2.ErrMsg,
  10658. })
  10659. }
  10660. } else {
  10661. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  10662. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10664. resp2, requestErr2 := http.Get(api2)
  10665. if requestErr2 != nil {
  10666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10667. return
  10668. }
  10669. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10670. if ioErr2 != nil {
  10671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10673. return
  10674. }
  10675. var respJSON2 map[string]interface{}
  10676. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10679. return
  10680. }
  10681. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10682. if err == nil {
  10683. c.ServeSuccessJSON(map[string]interface{}{
  10684. "msg": "撤销明细成功",
  10685. })
  10686. return
  10687. } else {
  10688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10689. return
  10690. }
  10691. }
  10692. } else {
  10693. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10694. if err == nil {
  10695. c.ServeSuccessJSON(map[string]interface{}{
  10696. "msg": "退费成功",
  10697. })
  10698. } else {
  10699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10700. return
  10701. }
  10702. }
  10703. }
  10704. //对账
  10705. func (c *HisApiController) GetCheckAccount() {
  10706. start_time := c.GetString("start_time")
  10707. end_time := c.GetString("end_time")
  10708. insutype := c.GetString("insutype")
  10709. clr_type := c.GetString("clr_type")
  10710. clr_org := c.GetString("clr_optins")
  10711. admin_user_id, _ := c.GetInt64("admin_user_id")
  10712. adminUser := c.GetAdminUserInfo()
  10713. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10714. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10715. if len(clr_org) == 0 {
  10716. clr_org = miConfig.MdtrtareaAdmvs
  10717. }
  10718. timeLayout := "2006-01-02"
  10719. loc, _ := time.LoadLocation("Local")
  10720. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  10721. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  10722. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10723. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10724. fixmedins_setl_cnt := int64(len(orders))
  10725. var medfee_sumamt float64
  10726. var acct_pay float64
  10727. var fund_pay_sumamt float64
  10728. for _, item := range orders {
  10729. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  10730. acct_pay = acct_pay + item.AcctPay
  10731. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  10732. }
  10733. var user_name string
  10734. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10735. if role.ID == 0 {
  10736. user_name = "xxx"
  10737. } else {
  10738. user_name = role.UserName
  10739. }
  10740. var res ResultEight
  10741. var res10188 ResultEightFor10188
  10742. if config.IsOpen == 1 {
  10743. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10744. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  10745. "insutype=" + insutype +
  10746. "&clr_type=" + clr_type +
  10747. "&setl_optins=" + clr_org +
  10748. "&stmt_begndate=" + start_time +
  10749. "&stm_enddate=" + end_time +
  10750. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10751. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10752. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10753. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10754. "&fixmedins_code=" + miConfig.Code +
  10755. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10756. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10757. "&secret_key=" + miConfig.SecretKey +
  10758. "&org_name=" + miConfig.OrgName +
  10759. "&doctor=" + user_name +
  10760. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10761. fmt.Println(api)
  10762. resp, requestErr := http.Get(api)
  10763. if requestErr != nil {
  10764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10765. return
  10766. }
  10767. body, ioErr := ioutil.ReadAll(resp.Body)
  10768. fmt.Println(body)
  10769. if ioErr != nil {
  10770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. return
  10773. }
  10774. var respJSON map[string]interface{}
  10775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10778. return
  10779. }
  10780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10781. userJSONBytes, _ := json.Marshal(respJSON)
  10782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10783. utils.ErrorLog("解析失败:%v", err)
  10784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10785. return
  10786. }
  10787. res.InfRefmsgid = res10188.InfRefmsgid
  10788. res.Output = res10188.Output
  10789. res.ErrMsg = res10188.ErrMsg
  10790. res.Cainfo = res10188.Cainfo
  10791. res.WarnMsg = res10188.WarnMsg
  10792. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  10793. res.Infcode = infocode
  10794. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10795. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  10796. "insutype=" + insutype +
  10797. "&clr_type=" + "21" +
  10798. "&setl_optins=" + clr_org +
  10799. "&stmt_begndate=" + start_time +
  10800. "&stm_enddate=" + end_time +
  10801. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10802. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10803. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10804. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10805. "&fixmedins_code=" + miConfig.Code +
  10806. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10807. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10808. "&secret_key=" + miConfig.SecretKey +
  10809. "&org_name=" + miConfig.OrgName +
  10810. "&doctor=" + user_name
  10811. resp, requestErr := http.Get(api)
  10812. if requestErr != nil {
  10813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10814. return
  10815. }
  10816. body, ioErr := ioutil.ReadAll(resp.Body)
  10817. if ioErr != nil {
  10818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10820. return
  10821. }
  10822. var respJSON map[string]interface{}
  10823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10826. return
  10827. }
  10828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10829. result, _ := json.Marshal(respJSON)
  10830. fmt.Println("log")
  10831. fmt.Println(string(result))
  10832. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  10833. utils.ErrorLog("解析失败:%v", err)
  10834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10835. return
  10836. }
  10837. res.InfRefmsgid = res10188.InfRefmsgid
  10838. res.Output = res10188.Output
  10839. res.ErrMsg = res10188.ErrMsg
  10840. res.Cainfo = res10188.Cainfo
  10841. res.WarnMsg = res10188.WarnMsg
  10842. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  10843. res.Infcode = infocode
  10844. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10845. var baseParams models.BaseParams
  10846. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10847. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10848. baseParams.SecretKey = miConfig.SecretKey
  10849. baseParams.OrgName = miConfig.OrgName
  10850. baseParams.FixmedinsCode = miConfig.Code
  10851. baseParams.EncKey = miConfig.EncKey
  10852. baseParams.AppSecret = miConfig.AppSecret
  10853. baseParams.SignKey = miConfig.SignKey
  10854. baseParams.AppID = miConfig.Code
  10855. baseParams.Doctor = role.UserName
  10856. baseParams.RequestUrl = miConfig.Url
  10857. businessParams := models.BusinessParams{
  10858. Insutype: insutype,
  10859. ClrType: clr_type,
  10860. SetlOptins: clr_org,
  10861. StmtBegndate: start_time,
  10862. StmtEnddate: end_time,
  10863. MedfeeSumamt: medfee_sumamt,
  10864. FundPaySumamt: fund_pay_sumamt,
  10865. AcctPay: acct_pay,
  10866. FixmedinsSetlCnt: fixmedins_setl_cnt,
  10867. }
  10868. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  10869. fmt.Println(requestLog)
  10870. fmt.Println(result)
  10871. fmt.Println(err_msg)
  10872. var dat map[string]interface{}
  10873. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10874. fmt.Println(dat)
  10875. } else {
  10876. fmt.Println(err)
  10877. }
  10878. userJSONBytes, _ := json.Marshal(dat)
  10879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10880. utils.ErrorLog("解析失败:%v", err)
  10881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10882. return
  10883. }
  10884. } else if miConfig.MdtrtareaAdmvs == "" {
  10885. var baseParams models.BaseParams
  10886. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10887. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10888. baseParams.SecretKey = miConfig.SecretKey
  10889. baseParams.OrgName = miConfig.OrgName
  10890. baseParams.FixmedinsCode = miConfig.Code
  10891. baseParams.EncKey = miConfig.EncKey
  10892. baseParams.AppSecret = miConfig.AppSecret
  10893. baseParams.SignKey = miConfig.SignKey
  10894. baseParams.AppID = miConfig.Code
  10895. baseParams.Doctor = role.UserName
  10896. baseParams.RequestUrl = miConfig.Url
  10897. businessParams := models.BusinessParams{
  10898. Insutype: insutype,
  10899. ClrType: clr_type,
  10900. SetlOptins: clr_org,
  10901. StmtBegndate: start_time,
  10902. StmtEnddate: end_time,
  10903. MedfeeSumamt: medfee_sumamt,
  10904. FundPaySumamt: fund_pay_sumamt,
  10905. AcctPay: acct_pay,
  10906. FixmedinsSetlCnt: fixmedins_setl_cnt,
  10907. }
  10908. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  10909. fmt.Println(requestLog)
  10910. fmt.Println(result)
  10911. fmt.Println(err_msg)
  10912. var dat map[string]interface{}
  10913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10914. fmt.Println(dat)
  10915. } else {
  10916. fmt.Println(err)
  10917. }
  10918. userJSONBytes, _ := json.Marshal(dat)
  10919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10920. utils.ErrorLog("解析失败:%v", err)
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. return
  10923. }
  10924. } else {
  10925. if len(clr_type) == 0 {
  10926. clr_type = "11"
  10927. }
  10928. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  10929. "insutype=" + insutype +
  10930. "&clr_type=" + clr_type +
  10931. "&setl_optins=" + clr_org +
  10932. "&stmt_begndate=" + start_time +
  10933. "&stm_enddate=" + end_time +
  10934. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10935. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10936. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10937. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  10938. "&fixmedins_code=" + miConfig.Code +
  10939. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10940. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10941. "&secret_key=" + miConfig.SecretKey +
  10942. "&org_name=" + miConfig.OrgName +
  10943. "&doctor=" + user_name
  10944. fmt.Println(api)
  10945. resp, requestErr := http.Get(api)
  10946. if requestErr != nil {
  10947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10948. return
  10949. }
  10950. body, ioErr := ioutil.ReadAll(resp.Body)
  10951. fmt.Println(body)
  10952. if ioErr != nil {
  10953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10955. return
  10956. }
  10957. var respJSON map[string]interface{}
  10958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10961. return
  10962. }
  10963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10964. userJSONBytes, _ := json.Marshal(respJSON)
  10965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10966. utils.ErrorLog("解析失败:%v", err)
  10967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10968. return
  10969. }
  10970. }
  10971. if res.Infcode == 0 {
  10972. if res.Output.Stmtinfo.StmtRslt == "0" {
  10973. micc := &models.MedicalInsuranceCostCompare{
  10974. StartTime: startime.Unix(),
  10975. EndTime: endtime.Unix(),
  10976. Insutype: insutype,
  10977. CheckType: 1,
  10978. Num: fixmedins_setl_cnt,
  10979. Mtime: time.Now().Unix(),
  10980. Status: 1,
  10981. UserOrgId: adminUser.CurrentOrgId,
  10982. CostTotal: medfee_sumamt,
  10983. FuncTotal: fund_pay_sumamt,
  10984. PsnPay: acct_pay,
  10985. Creator: admin_user_id,
  10986. Ctime: time.Now().Unix(),
  10987. ClrType: clr_type,
  10988. }
  10989. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  10990. if err == nil {
  10991. c.ServeSuccessJSON(map[string]interface{}{
  10992. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  10993. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  10994. })
  10995. } else {
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. }
  10998. } else {
  10999. c.ServeSuccessJSON(map[string]interface{}{
  11000. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11001. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11002. })
  11003. }
  11004. } else {
  11005. c.ServeSuccessJSON(map[string]interface{}{
  11006. "code": -10,
  11007. "msg": res.ErrMsg,
  11008. })
  11009. }
  11010. }
  11011. }
  11012. func (c *HisApiController) Check310() {
  11013. adminUser := c.GetAdminUserInfo()
  11014. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11015. var user_name string
  11016. user_name = "高慧裕"
  11017. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11018. "insutype=" + "310" +
  11019. "&clr_type=" + "" +
  11020. "&setl_optins=" + "441202" +
  11021. "&stmt_begndate=" + "2022-03-01" +
  11022. "&stm_enddate=" + "2022-03-31" +
  11023. "&medfee_sumamt=" + "194930.12" +
  11024. "&fund_pay_sumamt=" + "188741.46" +
  11025. "&acct_pay=" + "0" +
  11026. "&fixmedins_setl_cnt=" + "452" +
  11027. "&fixmedins_code=" + miConfig.Code +
  11028. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11029. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11030. "&secret_key=" + miConfig.SecretKey +
  11031. "&org_name=" + miConfig.OrgName +
  11032. "&doctor=" + user_name
  11033. fmt.Println(api)
  11034. resp, requestErr := http.Get(api)
  11035. if requestErr != nil {
  11036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11037. return
  11038. }
  11039. body, ioErr := ioutil.ReadAll(resp.Body)
  11040. fmt.Println(body)
  11041. if ioErr != nil {
  11042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11044. return
  11045. }
  11046. var respJSON map[string]interface{}
  11047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11050. return
  11051. }
  11052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11053. userJSONBytes, _ := json.Marshal(respJSON)
  11054. var res ResultEight
  11055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11056. utils.ErrorLog("解析失败:%v", err)
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11058. return
  11059. }
  11060. }
  11061. func (c *HisApiController) Check390() {
  11062. adminUser := c.GetAdminUserInfo()
  11063. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11064. var user_name string
  11065. user_name = "高慧裕"
  11066. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11067. "insutype=" + "390" +
  11068. "&clr_type=" + "" +
  11069. "&setl_optins=" + "441202" +
  11070. "&stmt_begndate=" + "2022-03-01" +
  11071. "&stm_enddate=" + "2022-03-31" +
  11072. "&medfee_sumamt=" + "1068448.89" +
  11073. "&fund_pay_sumamt=" + "1014677.62" +
  11074. "&acct_pay=" + "0" +
  11075. "&fixmedins_setl_cnt=" + "1950" +
  11076. "&fixmedins_code=" + miConfig.Code +
  11077. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11078. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11079. "&secret_key=" + miConfig.SecretKey +
  11080. "&org_name=" + miConfig.OrgName +
  11081. "&doctor=" + user_name
  11082. fmt.Println(api)
  11083. resp, requestErr := http.Get(api)
  11084. if requestErr != nil {
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11086. return
  11087. }
  11088. body, ioErr := ioutil.ReadAll(resp.Body)
  11089. fmt.Println(body)
  11090. if ioErr != nil {
  11091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11093. return
  11094. }
  11095. var respJSON map[string]interface{}
  11096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11099. return
  11100. }
  11101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11102. userJSONBytes, _ := json.Marshal(respJSON)
  11103. var res ResultEight
  11104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11105. utils.ErrorLog("解析失败:%v", err)
  11106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11107. return
  11108. }
  11109. }
  11110. //对账明细
  11111. func (c *HisApiController) GetCheckDetailAccount() {
  11112. start_time := c.GetString("start_time")
  11113. end_time := c.GetString("end_time")
  11114. admin_user_id, _ := c.GetInt64("admin_user_id")
  11115. adminUser := c.GetAdminUserInfo()
  11116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11118. timeLayout := "2006-01-02"
  11119. loc, _ := time.LoadLocation("Local")
  11120. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11121. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11122. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11123. rand.Seed(time.Now().UnixNano())
  11124. num := rand.Intn(30000)
  11125. Mkdir(miConfig.OrgName)
  11126. file := strconv.FormatInt(int64(num), 10)
  11127. file_name := file + ".txt"
  11128. zip_name := file + ".zip"
  11129. zip_path := miConfig.OrgName + "/" + zip_name
  11130. file_path := miConfig.OrgName + "/" + file_name
  11131. decimal.DivisionPrecision = 2
  11132. var medfee_sumamt float64
  11133. var psn_cash_pay float64
  11134. var fund_pay_sumamt float64
  11135. fixmedins_setl_cnt := int64(len(orders))
  11136. for _, item := range orders {
  11137. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11138. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11139. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11140. }
  11141. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11142. defer f.Close()
  11143. if err != nil {
  11144. fmt.Println(err.Error())
  11145. } else {
  11146. for _, item := range orders {
  11147. var refd_setl_flag string
  11148. if item.OrderStatus == 2 {
  11149. refd_setl_flag = "0"
  11150. var str string
  11151. str = item.SetlId + " " +
  11152. item.MdtrtId + " " +
  11153. item.PsnNo + " " +
  11154. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11155. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11156. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11157. _, err = f.Write([]byte(str))
  11158. }
  11159. if item.OrderStatus == 3 {
  11160. var str string
  11161. str = item.SetlId + " " +
  11162. item.MdtrtId + " " +
  11163. item.PsnNo + " " +
  11164. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11165. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11166. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11167. _, err = f.Write([]byte(str))
  11168. var str2 string
  11169. str2 = item.SetlId + " " +
  11170. item.MdtrtId + " " +
  11171. item.PsnNo + " " +
  11172. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11173. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11174. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11175. _, err = f.Write([]byte(str2))
  11176. }
  11177. }
  11178. }
  11179. Zip(file_path, zip_path)
  11180. fmt.Println(ReadFile(zip_path))
  11181. fmt.Println(string(ReadFile(zip_path)))
  11182. if config.IsOpen == 1 {
  11183. var user_name string
  11184. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11185. if role.ID == 0 {
  11186. user_name = "管理员"
  11187. } else {
  11188. user_name = role.UserName
  11189. }
  11190. baseParams := models.BaseParams{
  11191. SecretKey: miConfig.SecretKey,
  11192. FixmedinsCode: miConfig.Code,
  11193. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11194. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11195. OrgName: miConfig.OrgName,
  11196. Doctor: user_name,
  11197. }
  11198. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11199. var dat map[string]interface{}
  11200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11201. fmt.Println(dat)
  11202. } else {
  11203. fmt.Println(err)
  11204. }
  11205. userJSONBytes, _ := json.Marshal(dat)
  11206. var res ResultNine
  11207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11208. utils.ErrorLog("解析失败:%v", err)
  11209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11210. return
  11211. }
  11212. if res.Infcode == 0 {
  11213. fileNo := res.Output.FileQuryNo
  11214. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11215. "file_qury_no=" + fileNo +
  11216. "&setl_optins=" + "定点医保中心" +
  11217. "&stmt_begndate=" + start_time +
  11218. "&stm_enddate=" + end_time +
  11219. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11220. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11221. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11222. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11223. "&fixmedins_code=" + miConfig.Code +
  11224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11225. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11226. "&secret_key=" + miConfig.SecretKey +
  11227. "&org_name=" + miConfig.OrgName +
  11228. "&doctor=" + user_name
  11229. resp, requestErr := http.Get(api)
  11230. if requestErr != nil {
  11231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11232. return
  11233. }
  11234. body, ioErr := ioutil.ReadAll(resp.Body)
  11235. if ioErr != nil {
  11236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11238. return
  11239. }
  11240. var respJSON map[string]interface{}
  11241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11244. return
  11245. }
  11246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11247. userJSONBytes, _ := json.Marshal(respJSON)
  11248. var res ResultTen
  11249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11250. utils.ErrorLog("解析失败:%v", err)
  11251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11252. return
  11253. }
  11254. if res.Infcode == 0 {
  11255. service.Gdyb9102(baseParams, zip_name, fileNo)
  11256. micc := &models.MedicalInsuranceCostCompare{
  11257. StartTime: startime.Unix(),
  11258. EndTime: endtime.Unix(),
  11259. Insutype: "0",
  11260. CheckType: 2,
  11261. Num: fixmedins_setl_cnt,
  11262. Mtime: time.Now().Unix(),
  11263. Status: 1,
  11264. UserOrgId: adminUser.CurrentOrgId,
  11265. CostTotal: medfee_sumamt,
  11266. FuncTotal: fund_pay_sumamt,
  11267. PsnPay: psn_cash_pay,
  11268. Creator: admin_user_id,
  11269. Ctime: time.Now().Unix(),
  11270. }
  11271. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11272. c.ServeSuccessJSON(map[string]interface{}{
  11273. "msg": "明细对账成功",
  11274. })
  11275. }
  11276. } else {
  11277. }
  11278. }
  11279. }
  11280. type CustomOrderInfo struct {
  11281. Name string
  11282. Spec string
  11283. Unit string
  11284. Count float64
  11285. Price float64
  11286. Total float64
  11287. }
  11288. func (c *HisApiController) GetSettleAccounts() {
  11289. //id, _ := c.GetInt64("id")
  11290. //record_time := c.GetString("record_time")
  11291. order_id, _ := c.GetInt64("order_id")
  11292. admin_user_id, _ := c.GetInt64("admin_user_id")
  11293. //timeLayout := "2006-01-02"
  11294. //loc, _ := time.LoadLocation("Local")
  11295. //
  11296. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11297. //if err != nil {
  11298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11299. // return
  11300. //}
  11301. //recordDateTime := theTime.Unix()
  11302. adminUser := c.GetAdminUserInfo()
  11303. order, _ := service.GetHisOrderByID(order_id)
  11304. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11305. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11306. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11307. orderInfos = append(orderInfos, orderInfos_two...)
  11308. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11309. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11310. var diagnosis_ids []string
  11311. if his.ID > 0 {
  11312. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11313. } else {
  11314. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11315. }
  11316. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11317. var dia_config []*models.HisXtDiagnoseConfig
  11318. var name string
  11319. for _, item := range diagnosis_ids {
  11320. id, _ := strconv.ParseInt(item, 10, 64)
  11321. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11322. dia_config = append(dia_config, &diagnosisConfig)
  11323. if len(name) == 0 {
  11324. name = diagnosisConfig.ClassName
  11325. } else {
  11326. name = name + "," + diagnosisConfig.ClassName
  11327. }
  11328. }
  11329. var bedCostTotal float64 = 0 //床位总费
  11330. var bedCostSelfTotal float64 = 0 //床位自费
  11331. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11332. var operationCostTotal float64 = 0 //手术费
  11333. var operationCostSelfTotal float64 = 0 //手术费
  11334. var operationCostPartSelfTotal float64 = 0 //手术费
  11335. var otherCostTotal float64 = 0 //其他费用
  11336. var otherCostSelfTotal float64 = 0 //其他费用
  11337. var otherCostPartSelfTotal float64 = 0 //其他费用
  11338. var materialCostTotal float64 = 0 //材料费
  11339. var materialCostSelfTotal float64 = 0 //材料费
  11340. var materialCostPartSelfTotal float64 = 0 //材料费
  11341. var westernMedicineCostTotal float64 = 0 //西药费
  11342. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11343. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11344. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11345. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11346. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11347. var checkCostTotal float64 = 0 //检查费
  11348. var checkCostSelfTotal float64 = 0 //检查费
  11349. var checkCostPartSelfTotal float64 = 0 //检查费
  11350. var laboratoryCostTotal float64 = 0 //化验费
  11351. var laboratoryCostSelfTotal float64 = 0 //化验费
  11352. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11353. var treatCostTotal float64 = 0 //治疗费用
  11354. var treatCostSelfTotal float64 = 0 //治疗费用
  11355. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11356. decimal.DivisionPrecision = 2
  11357. for _, item := range orderInfos {
  11358. if item.MedChrgitmType == "01" { //床位费
  11359. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11360. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11361. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11362. }
  11363. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11364. if item.MedChrgitmType == "03" { //检查费
  11365. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11366. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11367. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11368. }
  11369. } else {
  11370. if item.MedChrgitmType == "03" { //检查费
  11371. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11372. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11373. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11374. }
  11375. }
  11376. if item.MedChrgitmType == "04" { //化验费
  11377. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11378. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11379. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11380. }
  11381. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11382. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11383. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11384. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11385. }
  11386. if item.MedChrgitmType == "06" { //手术费
  11387. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11388. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11389. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11390. }
  11391. if item.MedChrgitmType == "08" { //材料费
  11392. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11393. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11394. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11395. }
  11396. if item.MedChrgitmType == "09" { //西药费
  11397. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11398. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11399. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11400. }
  11401. if item.MedChrgitmType == "11" { //中成费
  11402. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11403. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11404. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11405. }
  11406. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11407. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11408. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11409. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11410. }
  11411. }
  11412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11413. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11414. var user_name string
  11415. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11416. if role.ID == 0 {
  11417. user_name = "管理员"
  11418. } else {
  11419. user_name = role.UserName
  11420. }
  11421. baseParams := models.BaseParams{
  11422. SecretKey: miConfig.SecretKey,
  11423. FixmedinsCode: miConfig.Code,
  11424. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11425. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11426. OrgName: miConfig.OrgName,
  11427. Doctor: user_name,
  11428. RequestUrl: miConfig.Url,
  11429. AccessKey: miConfig.AccessKey,
  11430. }
  11431. businessParams := models.BusinessParams{
  11432. PsnNo: order.PsnNo,
  11433. MdtrtId: order.MdtrtId,
  11434. SetlId: order.SetlId,
  11435. }
  11436. var res ResultEleven
  11437. var resEleven10265 ResultEleven10265
  11438. if config.IsOpen == 1 {
  11439. if miConfig.MdtrtareaAdmvs == "421300" {
  11440. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11441. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11442. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11443. resp, requestErr := http.Get(api)
  11444. if requestErr != nil {
  11445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11446. return
  11447. }
  11448. body, ioErr := ioutil.ReadAll(resp.Body)
  11449. if ioErr != nil {
  11450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11452. return
  11453. }
  11454. var respJSON map[string]interface{}
  11455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11458. return
  11459. }
  11460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11461. result, _ := json.Marshal(respJSON)
  11462. fmt.Println("log")
  11463. fmt.Println(string(result))
  11464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11465. utils.ErrorLog("解析失败:%v", err)
  11466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11467. return
  11468. }
  11469. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11470. var api string
  11471. if miConfig.MdtrtareaAdmvs == "320921" {
  11472. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11473. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11474. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11475. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11476. } else {
  11477. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11478. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11479. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11480. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11481. }
  11482. resp, requestErr := http.Get(api)
  11483. if requestErr != nil {
  11484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11485. return
  11486. }
  11487. body, ioErr := ioutil.ReadAll(resp.Body)
  11488. if ioErr != nil {
  11489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11491. return
  11492. }
  11493. var respJSON map[string]interface{}
  11494. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11497. return
  11498. }
  11499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11500. result, _ := json.Marshal(respJSON)
  11501. fmt.Println("log")
  11502. fmt.Println(string(result))
  11503. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11504. utils.ErrorLog("解析失败:%v", err)
  11505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11506. return
  11507. }
  11508. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11509. res.Output = resEleven10265.Output
  11510. res.ErrMsg = resEleven10265.ErrMsg
  11511. res.Cainfo = resEleven10265.Cainfo
  11512. res.WarnMsg = resEleven10265.WarnMsg
  11513. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11514. res.Infcode = infocode
  11515. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11516. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11517. saveLog(result, requestLog, "5203", "结算单")
  11518. var dat map[string]interface{}
  11519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11520. fmt.Println(dat)
  11521. } else {
  11522. fmt.Println(err)
  11523. }
  11524. userJSONBytes, _ := json.Marshal(dat)
  11525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11526. utils.ErrorLog("解析失败:%v", err)
  11527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11528. return
  11529. }
  11530. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11531. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  11532. saveLog(result, requestLog, "5203", "结算单")
  11533. var dat map[string]interface{}
  11534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11535. fmt.Println(dat)
  11536. } else {
  11537. fmt.Println(err)
  11538. }
  11539. userJSONBytes, _ := json.Marshal(dat)
  11540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11541. utils.ErrorLog("解析失败:%v", err)
  11542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11543. return
  11544. }
  11545. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11546. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  11547. saveLog(result, requestLog, "5203", "结算单")
  11548. var dat map[string]interface{}
  11549. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11550. fmt.Println(dat)
  11551. } else {
  11552. fmt.Println(err)
  11553. }
  11554. userJSONBytes, _ := json.Marshal(dat)
  11555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11556. utils.ErrorLog("解析失败:%v", err)
  11557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11558. return
  11559. }
  11560. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11561. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11562. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11563. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11564. resp, requestErr := http.Get(api)
  11565. if requestErr != nil {
  11566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11567. return
  11568. }
  11569. body, ioErr := ioutil.ReadAll(resp.Body)
  11570. if ioErr != nil {
  11571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11573. return
  11574. }
  11575. var respJSON map[string]interface{}
  11576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11579. return
  11580. }
  11581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11582. result, _ := json.Marshal(respJSON)
  11583. fmt.Println("log")
  11584. fmt.Println(string(result))
  11585. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11586. utils.ErrorLog("解析失败:%v", err)
  11587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11588. return
  11589. }
  11590. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11591. res.Output = resEleven10265.Output
  11592. res.ErrMsg = resEleven10265.ErrMsg
  11593. res.Cainfo = resEleven10265.Cainfo
  11594. res.WarnMsg = resEleven10265.WarnMsg
  11595. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11596. res.Infcode = infocode
  11597. } else {
  11598. result := service.Gdyb5203(baseParams, businessParams)
  11599. //service.Gdyb5204(baseParams, businessParams)
  11600. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  11601. var dat map[string]interface{}
  11602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11603. fmt.Println(dat)
  11604. } else {
  11605. fmt.Println(err)
  11606. }
  11607. userJSONBytes, _ := json.Marshal(dat)
  11608. if miConfig.Code == "H15049901371" {
  11609. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  11610. utils.ErrorLog("解析失败:%v", err)
  11611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11612. return
  11613. }
  11614. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11615. res.Output = resEleven10265.Output
  11616. res.ErrMsg = resEleven10265.ErrMsg
  11617. res.Cainfo = resEleven10265.Cainfo
  11618. res.WarnMsg = resEleven10265.WarnMsg
  11619. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11620. res.Infcode = infocode
  11621. } else {
  11622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11623. utils.ErrorLog("解析失败:%v", err)
  11624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11625. return
  11626. }
  11627. }
  11628. }
  11629. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11630. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  11631. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  11632. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11633. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  11634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11635. var doctor_name string
  11636. if roles.ID == 0 {
  11637. doctor_name = "管理员"
  11638. } else {
  11639. doctor_name = roles.UserName
  11640. }
  11641. yiliao_leibie := ""
  11642. switch order.MedType {
  11643. case "11":
  11644. yiliao_leibie = "普通门诊"
  11645. break
  11646. case "12":
  11647. yiliao_leibie = "门诊挂号"
  11648. break
  11649. case "13":
  11650. yiliao_leibie = "急诊"
  11651. break
  11652. case "14":
  11653. yiliao_leibie = "门诊特殊病"
  11654. break
  11655. case "15":
  11656. yiliao_leibie = "门诊统筹"
  11657. break
  11658. case "16":
  11659. yiliao_leibie = "门诊慢性病"
  11660. break
  11661. case "21":
  11662. yiliao_leibie = "普通住院"
  11663. break
  11664. }
  11665. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11666. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  11667. if res.Infcode == 0 {
  11668. c.ServeSuccessJSON(map[string]interface{}{
  11669. "diagnosis": name,
  11670. "order_infos": orderInfos,
  11671. "number": order.MdtrtId,
  11672. "date": order.SettleAccountsDate,
  11673. "charge_admin": charge_admin,
  11674. "printor_admin": printor_admin,
  11675. "info": res.Output.Setlinfo,
  11676. "order": order,
  11677. "bedCostTotal": bedCostTotal,
  11678. "bedCostSelfTotal": bedCostSelfTotal,
  11679. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  11680. "operationCostTotal": operationCostTotal,
  11681. "operationCostSelfTotal": operationCostSelfTotal,
  11682. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  11683. "otherCostTotal": otherCostTotal,
  11684. "otherCostSelfTotal": otherCostSelfTotal,
  11685. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  11686. "materialCostTotal": materialCostTotal,
  11687. "materialCostSelfTotal": materialCostSelfTotal,
  11688. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  11689. "westernMedicineCostTotal": westernMedicineCostTotal,
  11690. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  11691. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  11692. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  11693. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  11694. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  11695. "checkCostTotal": checkCostTotal,
  11696. "checkCostSelfTotal": checkCostSelfTotal,
  11697. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  11698. "laboratoryCostTotal": laboratoryCostTotal,
  11699. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  11700. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  11701. "treatCostTotal": treatCostTotal,
  11702. "treatCostSelfTotal": treatCostSelfTotal,
  11703. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  11704. "doctor_info": doctor_info,
  11705. "doctor_code": adminRole_two.DoctorCode,
  11706. "doctor_name": doctor_name,
  11707. "health_card_no": order.PsnNo,
  11708. "department": departments.Name,
  11709. "yiliao_leibie": yiliao_leibie,
  11710. "after_money": order.AccountPrice,
  11711. "patient": patient,
  11712. "org_name": miConfig.OrgName,
  11713. "org_code": miConfig.Code,
  11714. "order_number": order.Number,
  11715. "his_hospital": his_hospital,
  11716. "his": his,
  11717. "dia_config": dia_config,
  11718. //"check_order_info": cus_slice,
  11719. })
  11720. }
  11721. }
  11722. }
  11723. func (c *HisApiController) CheckTreatment() {
  11724. patient_id, _ := c.GetInt64("patient_id")
  11725. id_card_no := c.GetString("id_card_no")
  11726. insutype := c.GetString("insutype")
  11727. med_type := c.GetString("med_type")
  11728. admin_user_id, _ := c.GetInt64("admin_user_id")
  11729. adminUser := c.GetAdminUserInfo()
  11730. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  11731. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11732. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11733. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11734. if miConfig.MdtrtareaAdmvs == "421300" {
  11735. var res ResultTwo
  11736. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11737. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11738. "&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)
  11739. resp, requestErr := http.Get(api)
  11740. if requestErr != nil {
  11741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11742. return
  11743. }
  11744. body, ioErr := ioutil.ReadAll(resp.Body)
  11745. if ioErr != nil {
  11746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11748. return
  11749. }
  11750. var respJSON map[string]interface{}
  11751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11754. return
  11755. }
  11756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11757. result, _ := json.Marshal(respJSON)
  11758. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11759. utils.ErrorLog("解析失败:%v", err)
  11760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11761. return
  11762. }
  11763. if res.Infcode == 0 {
  11764. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  11765. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  11767. resp, requestErr := http.Get(api)
  11768. if requestErr != nil {
  11769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11770. return
  11771. }
  11772. body, ioErr := ioutil.ReadAll(resp.Body)
  11773. if ioErr != nil {
  11774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11776. return
  11777. }
  11778. var respJSON map[string]interface{}
  11779. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11782. return
  11783. }
  11784. var res Result2001
  11785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11786. result2, _ := json.Marshal(respJSON)
  11787. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11788. utils.ErrorLog("解析失败:%v", err)
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return
  11791. }
  11792. if res.Infcode == 0 {
  11793. c.ServeSuccessJSON(map[string]interface{}{
  11794. "msg": res.Output.Trtinfo,
  11795. })
  11796. }
  11797. } else {
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11799. return
  11800. }
  11801. } else {
  11802. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  11803. var dat map[string]interface{}
  11804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11805. fmt.Println(dat)
  11806. } else {
  11807. fmt.Println(err)
  11808. }
  11809. userJSONBytes, _ := json.Marshal(dat)
  11810. var res ResultTwo
  11811. var res10265 ResultTwo10265
  11812. if miConfig.Code == "H15049901371" {
  11813. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11814. utils.ErrorLog("解析失败:%v", err)
  11815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11816. return
  11817. }
  11818. res.ErrMsg = res10265.ErrMsg
  11819. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11820. res.Infcode = infocode
  11821. res.Output = res10265.Output
  11822. res.InfRefmsgid = res10265.InfRefmsgid
  11823. } else {
  11824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11825. utils.ErrorLog("解析失败:%v", err)
  11826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11827. return
  11828. }
  11829. }
  11830. var user_name string
  11831. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  11832. if role.ID == 0 {
  11833. user_name = "xxx"
  11834. } else {
  11835. user_name = role.UserName
  11836. }
  11837. baseParams := models.BaseParams{
  11838. SecretKey: miConfig.SecretKey,
  11839. FixmedinsCode: miConfig.Code,
  11840. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11841. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11842. OrgName: miConfig.OrgName,
  11843. Doctor: user_name,
  11844. }
  11845. if config.IsOpen == 1 {
  11846. if miConfig.Code == "H15049901371" {
  11847. if med_type == "14" {
  11848. if insutype == "390" {
  11849. med_type = "9933"
  11850. } else if insutype == "310" {
  11851. med_type = "990502"
  11852. }
  11853. } else if med_type == "11" {
  11854. med_type = "11"
  11855. }
  11856. }
  11857. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  11858. var dat map[string]interface{}
  11859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11860. fmt.Println(dat)
  11861. } else {
  11862. fmt.Println(err)
  11863. }
  11864. var res Result2001
  11865. var res10265 Result2001Org10265
  11866. if miConfig.Code == "H15049901371" {
  11867. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11868. utils.ErrorLog("解析失败:%v", err)
  11869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11870. return
  11871. }
  11872. res.ErrMsg = res10265.ErrMsg
  11873. res.Output = res10265.Output
  11874. res.InfRefmsgid = res10265.InfRefmsgid
  11875. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11876. res.Infcode = infocode
  11877. } else {
  11878. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11879. utils.ErrorLog("解析失败:%v", err)
  11880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. return
  11882. }
  11883. }
  11884. if res.Infcode == 0 {
  11885. c.ServeSuccessJSON(map[string]interface{}{
  11886. "msg": res.Output.Trtinfo,
  11887. })
  11888. }
  11889. }
  11890. }
  11891. }
  11892. //func (c *HisApiController) PutRecord() {
  11893. // id, _ := c.GetInt64("id")
  11894. // record_time := c.GetString("record_time")
  11895. // timeLayout := "2006-01-02"
  11896. // loc, _ := time.LoadLocation("Local")
  11897. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11898. // if err != nil {
  11899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11900. // return
  11901. // }
  11902. // recordDateTime := theTime.Unix()
  11903. //
  11904. // adminInfo := c.GetAdminUserInfo()
  11905. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  11906. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  11907. //
  11908. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  11909. //
  11910. // fmt.Println(miConfig.SecretKey)
  11911. //
  11912. // if patient == nil {
  11913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  11914. // return
  11915. // }
  11916. // if len(patient.IdCardNo) == 0 {
  11917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  11918. // return
  11919. // }
  11920. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  11921. // if config.IsOpen == 1 {
  11922. // 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
  11923. // resp, requestErr := http.Get(api)
  11924. // if requestErr != nil {
  11925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11926. // return
  11927. // }
  11928. // defer resp.Body.Close()
  11929. // body, ioErr := ioutil.ReadAll(resp.Body)
  11930. // if ioErr != nil {
  11931. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11933. // return
  11934. // }
  11935. // var respJSON map[string]interface{}
  11936. //
  11937. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11938. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11940. // return
  11941. // }
  11942. //
  11943. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11944. // userJSONBytes, _ := json.Marshal(userJSON)
  11945. // var res ResultTwo
  11946. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11947. // utils.ErrorLog("解析失败:%v", err)
  11948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11949. // return
  11950. // }
  11951. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11952. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11953. // infoStr := string(Iinfos)
  11954. // idetinfoStr := string(Idetinfos)
  11955. //
  11956. // if res.Infcode == 0 {
  11957. // his := models.VMHisPatient{
  11958. // Status: 1,
  11959. // Ctime: time.Now().Unix(),
  11960. // Mtime: time.Now().Unix(),
  11961. // PsnNo: res.Output.Baseinfo.PsnNo,
  11962. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11963. // Certno: res.Output.Baseinfo.Certno,
  11964. // PsnName: res.Output.Baseinfo.PsnName,
  11965. // Gend: res.Output.Baseinfo.Gend,
  11966. // Naty: res.Output.Baseinfo.Naty,
  11967. // Brdy: res.Output.Baseinfo.Brdy,
  11968. // Age: res.Output.Baseinfo.Age,
  11969. // Iinfo: infoStr,
  11970. // Idetinfo: idetinfoStr,
  11971. // PatientId: patient.ID,
  11972. // RecordDate: theTime.Unix(),
  11973. // UserOrgId: adminInfo.CurrentOrgId,
  11974. // AdminUserId: adminInfo.AdminUser.Id,
  11975. // IsReturn: 1,
  11976. // }
  11977. //
  11978. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  11979. // //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")
  11980. // //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")
  11981. //
  11982. // //var dat map[string]interface{}
  11983. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11984. // // fmt.Println(dat)
  11985. // //} else {
  11986. // // fmt.Println(err)
  11987. // //}
  11988. //
  11989. // var dat2 map[string]interface{}
  11990. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11991. // fmt.Println(dat2)
  11992. // } else {
  11993. // fmt.Println(err)
  11994. // }
  11995. //
  11996. // } else {
  11997. // adminUser := c.GetAdminUserInfo()
  11998. // errlog := &models.HisOrderError{
  11999. // UserOrgId: adminUser.CurrentOrgId,
  12000. // Ctime: time.Now().Unix(),
  12001. // Mtime: time.Now().Unix(),
  12002. // ErrMsg: res.ErrMsg,
  12003. // Status: 1,
  12004. // PatientId: id,
  12005. // RecordTime: recordDateTime,
  12006. // Stage: 1,
  12007. // }
  12008. // service.CreateErrMsgLog(errlog)
  12009. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12010. // return
  12011. // }
  12012. // }
  12013. //
  12014. //}
  12015. //func (c *HisApiController) GetUploadDiag() {
  12016. // id, _ := c.GetInt64("id")
  12017. // record_time := c.GetString("record_time")
  12018. //
  12019. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12020. // sick_type, _ := c.GetInt64("sick_type")
  12021. // reg_type, _ := c.GetInt64("reg_type")
  12022. //
  12023. // timeLayout := "2006-01-02"
  12024. // loc, _ := time.LoadLocation("Local")
  12025. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12026. // if err != nil {
  12027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12028. // return
  12029. // }
  12030. //
  12031. // var patientPrescription models.HisPrescriptionInfo
  12032. // recordDateTime := theTime.Unix()
  12033. // adminInfo := c.GetAdminUserInfo()
  12034. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12035. //
  12036. // if patientPrescription.ID == 0 {
  12037. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12038. // }
  12039. //
  12040. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12041. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12042. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12043. // sickConfig, _ := service.FindSickById(sick_type)
  12044. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12045. //
  12046. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12047. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12048. // "&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 +
  12049. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12050. // resp2, requestErr2 := http.Get(api2)
  12051. // if requestErr2 != nil {
  12052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12053. // return
  12054. // }
  12055. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12056. // if ioErr2 != nil {
  12057. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12059. // return
  12060. // }
  12061. // var respJSON2 map[string]interface{}
  12062. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12063. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12065. // return
  12066. // }
  12067. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12069. //
  12070. // var res2 ResultSix
  12071. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12072. // utils.ErrorLog("解析失败:%v", err)
  12073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. // return
  12075. // }
  12076. // if res2.Infcode != 0 {
  12077. // adminUser := c.GetAdminUserInfo()
  12078. // errlog := &models.HisOrderError{
  12079. // UserOrgId: adminUser.CurrentOrgId,
  12080. // Ctime: time.Now().Unix(),
  12081. // Mtime: time.Now().Unix(),
  12082. // ErrMsg: res2.ErrMsg,
  12083. // Status: 1,
  12084. // PatientId: id,
  12085. // RecordTime: recordDateTime,
  12086. // Stage: 3,
  12087. // }
  12088. // service.CreateErrMsgLog(errlog)
  12089. //
  12090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12091. // return
  12092. // }
  12093. //
  12094. // c.ServeSuccessJSON(map[string]interface{}{
  12095. // "msg": "上传成功",
  12096. // })
  12097. //
  12098. //}
  12099. type QueryResult struct {
  12100. ID int64
  12101. Name string
  12102. Code string
  12103. List_type_code string
  12104. }
  12105. func (c *HisApiController) GetCheckCode() {
  12106. ids_str := c.GetString("ids")
  12107. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12108. ids_arr := strings.Split(ids_str, ",")
  12109. var queryResult []QueryResult
  12110. ids := make([]int64, 0)
  12111. for _, item := range ids_arr {
  12112. id, _ := strconv.ParseInt(item, 10, 64)
  12113. ids = append(ids, id)
  12114. }
  12115. if record_type == 1 {
  12116. drugs, _ := service.GetBatchDrugList(ids)
  12117. for _, item := range drugs {
  12118. result := QueryResult{
  12119. ID: item.ID,
  12120. Name: item.DrugName,
  12121. Code: item.MedicalInsuranceNumber,
  12122. List_type_code: "101",
  12123. }
  12124. queryResult = append(queryResult, result)
  12125. }
  12126. } else if record_type == 2 {
  12127. goods, _ := service.GetBatchGoodInformationList(ids)
  12128. for _, item := range goods {
  12129. result := QueryResult{
  12130. ID: item.ID,
  12131. Name: item.GoodName,
  12132. Code: item.MedicalInsuranceNumber,
  12133. List_type_code: "301",
  12134. }
  12135. queryResult = append(queryResult, result)
  12136. }
  12137. } else if record_type == 3 {
  12138. projects, _ := service.GetBathchMyPorjecgList(ids)
  12139. for _, item := range projects {
  12140. result := QueryResult{
  12141. ID: item.ID,
  12142. Name: item.ProjectName,
  12143. Code: item.MedicalCode,
  12144. List_type_code: "201",
  12145. }
  12146. queryResult = append(queryResult, result)
  12147. }
  12148. }
  12149. admin_user_id, _ := c.GetInt64("admin_user_id")
  12150. adminUser := c.GetAdminUserInfo()
  12151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12152. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12153. var user_name string
  12154. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12155. if role.ID == 0 {
  12156. user_name = "xxx"
  12157. } else {
  12158. user_name = role.UserName
  12159. }
  12160. baseParams := &models.BaseParams{
  12161. SecretKey: miConfig.SecretKey,
  12162. FixmedinsCode: miConfig.Code,
  12163. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12164. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12165. OrgName: miConfig.OrgName,
  12166. Doctor: user_name,
  12167. }
  12168. if config.IsOpen == 1 {
  12169. for _, item := range queryResult {
  12170. var result string
  12171. if record_type == 1 {
  12172. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12173. } else if record_type == 2 {
  12174. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12175. } else if record_type == 3 {
  12176. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12177. }
  12178. var dat map[string]interface{}
  12179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12180. fmt.Println(dat)
  12181. } else {
  12182. fmt.Println(err)
  12183. }
  12184. userJSONBytes, _ := json.Marshal(dat)
  12185. var res ResultSix
  12186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12187. utils.ErrorLog("解析失败:%v", err)
  12188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12189. return
  12190. }
  12191. if res.Infcode == 0 {
  12192. if record_type == 1 {
  12193. service.UpdateBaseDrugById(item.ID)
  12194. } else if record_type == 2 {
  12195. service.UpdateGoodInformaitonByDetail(item.ID)
  12196. } else if record_type == 3 {
  12197. service.UpdateProjectById(item.ID)
  12198. }
  12199. c.ServeSuccessJSON(map[string]interface{}{
  12200. "failed_code": 0,
  12201. "msg": "目录对照成功",
  12202. })
  12203. } else {
  12204. c.ServeSuccessJSON(map[string]interface{}{
  12205. "failed_code": -10,
  12206. "msg": res.ErrMsg,
  12207. })
  12208. }
  12209. }
  12210. }
  12211. }
  12212. func (c *HisApiController) UnCheckCode() {
  12213. ids_str := c.GetString("ids")
  12214. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12215. admin_user_id, _ := c.GetInt64("admin_user_id")
  12216. ids_arr := strings.Split(ids_str, ",")
  12217. var queryResult []QueryResult
  12218. ids := make([]int64, 0)
  12219. for _, item := range ids_arr {
  12220. id, _ := strconv.ParseInt(item, 10, 64)
  12221. ids = append(ids, id)
  12222. }
  12223. if record_type == 1 {
  12224. drugs, _ := service.GetBatchDrugList(ids)
  12225. for _, item := range drugs {
  12226. result := QueryResult{
  12227. ID: item.ID,
  12228. Name: item.DrugName,
  12229. Code: item.MedicalInsuranceNumber,
  12230. List_type_code: "101",
  12231. }
  12232. queryResult = append(queryResult, result)
  12233. }
  12234. } else if record_type == 2 {
  12235. goods, _ := service.GetBatchGoodInformationList(ids)
  12236. for _, item := range goods {
  12237. result := QueryResult{
  12238. ID: item.ID,
  12239. Name: item.GoodName,
  12240. Code: item.MedicalInsuranceNumber,
  12241. List_type_code: "301",
  12242. }
  12243. queryResult = append(queryResult, result)
  12244. }
  12245. } else if record_type == 3 {
  12246. projects, _ := service.GetBathchMyPorjecgList(ids)
  12247. for _, item := range projects {
  12248. result := QueryResult{
  12249. ID: item.ID,
  12250. Name: item.ProjectName,
  12251. Code: item.MedicalCode,
  12252. List_type_code: "201",
  12253. }
  12254. queryResult = append(queryResult, result)
  12255. }
  12256. }
  12257. adminUser := c.GetAdminUserInfo()
  12258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12260. var user_name string
  12261. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12262. if role.ID == 0 {
  12263. user_name = "xxx"
  12264. } else {
  12265. user_name = role.UserName
  12266. }
  12267. baseParams := &models.BaseParams{
  12268. SecretKey: miConfig.SecretKey,
  12269. FixmedinsCode: miConfig.Code,
  12270. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12271. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12272. OrgName: miConfig.OrgName,
  12273. Doctor: user_name,
  12274. }
  12275. if config.IsOpen == 1 {
  12276. for _, item := range queryResult {
  12277. var result string
  12278. if record_type == 1 {
  12279. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12280. } else if record_type == 2 {
  12281. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12282. } else if record_type == 3 {
  12283. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12284. }
  12285. var dat2 map[string]interface{}
  12286. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12287. fmt.Println(dat2)
  12288. } else {
  12289. fmt.Println(err)
  12290. }
  12291. userJSONBytes, _ := json.Marshal(dat2)
  12292. var res ResultSix
  12293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12294. utils.ErrorLog("解析失败:%v", err)
  12295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12296. return
  12297. }
  12298. if res.Infcode == 0 {
  12299. if record_type == 1 {
  12300. service.UpdateDrugByIdDetail(item.ID)
  12301. } else if record_type == 2 {
  12302. service.UpdateGoodInfoById(item.ID)
  12303. } else if record_type == 3 {
  12304. service.UpdateMyProjectById(item.ID)
  12305. }
  12306. c.ServeSuccessJSON(map[string]interface{}{
  12307. "failed_code": 0,
  12308. "msg": "撤销目录对照成功",
  12309. })
  12310. } else {
  12311. c.ServeSuccessJSON(map[string]interface{}{
  12312. "failed_code": -10,
  12313. "msg": res.ErrMsg,
  12314. })
  12315. }
  12316. }
  12317. }
  12318. }
  12319. func (c *HisApiController) GetPatientInfo() {
  12320. id_card_no := c.GetString("id_card_no")
  12321. admin_user_id, _ := c.GetInt64("admin_user_id")
  12322. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12323. if patient.ID == 0 {
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12325. return
  12326. }
  12327. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12328. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12329. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12330. if config.IsOpen == 1 {
  12331. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12332. var dat map[string]interface{}
  12333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12334. fmt.Println(dat)
  12335. } else {
  12336. fmt.Println(err)
  12337. }
  12338. userJSONBytes, _ := json.Marshal(dat)
  12339. var res ResultTwo
  12340. var res10265 ResultTwo10265
  12341. if miConfig.Code == "H15049901371" {
  12342. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12343. utils.ErrorLog("解析失败:%v", err)
  12344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12345. return
  12346. }
  12347. res.ErrMsg = res10265.ErrMsg
  12348. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12349. res.Infcode = infocode
  12350. res.Output = res10265.Output
  12351. res.InfRefmsgid = res10265.InfRefmsgid
  12352. } else {
  12353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12354. utils.ErrorLog("解析失败:%v", err)
  12355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12356. return
  12357. }
  12358. }
  12359. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12360. // utils.ErrorLog("解析失败:%v", err)
  12361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. // return
  12363. //}
  12364. if res.Infcode != 0 {
  12365. c.ServeSuccessJSON(map[string]interface{}{
  12366. "failed_code": -10,
  12367. "msg": res.ErrMsg,
  12368. })
  12369. } else {
  12370. c.ServeSuccessJSON(map[string]interface{}{
  12371. "failed_code": 0,
  12372. "info": res,
  12373. })
  12374. }
  12375. }
  12376. }
  12377. func (c *HisApiController) PsnPutOnRecord() {
  12378. record_type, _ := c.GetInt64("type")
  12379. patient_id, _ := c.GetInt64("patient_id")
  12380. admin_user_id, _ := c.GetInt64("admin_user_id")
  12381. start_time := c.GetString("start_time")
  12382. end_time := c.GetString("end_time")
  12383. adminUser := c.GetAdminUserInfo()
  12384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12385. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12386. var patients []*models.Patients
  12387. if record_type == 1 { //全部备案
  12388. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12389. patients = append(patients, patient...)
  12390. } else { //单个备案
  12391. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12392. patients = append(patients, patient)
  12393. }
  12394. var user_name string
  12395. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12396. if role.ID == 0 {
  12397. user_name = "xxx"
  12398. } else {
  12399. user_name = role.UserName
  12400. }
  12401. if config.IsOpen == 1 {
  12402. for _, item := range patients {
  12403. 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
  12404. resp, requestErr := http.Get(api)
  12405. if requestErr != nil {
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. defer resp.Body.Close()
  12410. body, ioErr := ioutil.ReadAll(resp.Body)
  12411. if ioErr != nil {
  12412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. var respJSON map[string]interface{}
  12417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12420. return
  12421. }
  12422. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12423. userJSONBytes, _ := json.Marshal(userJSON)
  12424. var res ResultTwo
  12425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12426. utils.ErrorLog("解析失败:%v", err)
  12427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12428. return
  12429. }
  12430. if res.Infcode == 0 {
  12431. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12432. var dat map[string]interface{}
  12433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12434. fmt.Println(dat)
  12435. } else {
  12436. fmt.Println(err)
  12437. }
  12438. userJSONBytes, _ := json.Marshal(dat)
  12439. var res2 ResultThirteen
  12440. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12441. utils.ErrorLog("解析失败:%v", err)
  12442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12443. return
  12444. }
  12445. if res2.Infcode == 0 {
  12446. psnResult := &models.GdybPsnRecord{
  12447. UserOrgId: adminUser.CurrentOrgId,
  12448. PatientId: item.ID,
  12449. PsnNo: res.Output.Baseinfo.PsnNo,
  12450. Ctime: time.Now().Unix(),
  12451. Mtime: time.Now().Unix(),
  12452. Status: 1,
  12453. IsCancel: 1,
  12454. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12455. }
  12456. service.CreatePsnRecord(psnResult)
  12457. } else {
  12458. c.ServeSuccessJSON(map[string]interface{}{
  12459. "failed_code": -10,
  12460. "msg": res2.ErrMsg,
  12461. })
  12462. return
  12463. }
  12464. }
  12465. }
  12466. }
  12467. }
  12468. func (c *HisApiController) PsnUnPutOnRecord() {
  12469. id, _ := c.GetInt64("id")
  12470. //record_type, _ := c.GetInt64("type")
  12471. admin_user_id, _ := c.GetInt64("admin_user_id")
  12472. adminUser := c.GetAdminUserInfo()
  12473. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12474. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12475. var user_name string
  12476. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12477. if role.ID == 0 {
  12478. user_name = "xxx"
  12479. } else {
  12480. user_name = role.UserName
  12481. }
  12482. psn_record, _ := service.GetPsnRecordById(id)
  12483. if psn_record.ID == 0 {
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12485. return
  12486. }
  12487. if config.IsOpen == 1 {
  12488. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12489. var dat map[string]interface{}
  12490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12491. fmt.Println(dat)
  12492. } else {
  12493. fmt.Println(err)
  12494. }
  12495. userJSONBytes, _ := json.Marshal(dat)
  12496. var res ResultFourteen
  12497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12498. utils.ErrorLog("解析失败:%v", err)
  12499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12500. return
  12501. }
  12502. if res.Infcode == 0 {
  12503. psn_record.IsCancel = 2
  12504. service.CreatePsnRecord(&psn_record)
  12505. } else {
  12506. c.ServeSuccessJSON(map[string]interface{}{
  12507. "failed_code": -10,
  12508. "msg": res.ErrMsg,
  12509. })
  12510. return
  12511. }
  12512. }
  12513. }
  12514. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12515. patient_id, _ := c.GetInt64("patient_id")
  12516. insutype_two := c.GetString("insutype")
  12517. psn_no := c.GetString("psn_no")
  12518. doctor_id, _ := c.GetInt64("doctor_id")
  12519. sick_id, _ := c.GetInt64("sick_id")
  12520. department_id, _ := c.GetInt64("department_id")
  12521. start_time := c.GetString("start_time")
  12522. end_time := c.GetString("end_time")
  12523. check_time := c.GetString("check_time")
  12524. adminUser := c.GetAdminUserInfo()
  12525. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12528. sick, _ := service.FindSickById(sick_id)
  12529. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12530. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12531. var res ResultTwo
  12532. var res10265 ResultTwo10265
  12533. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12534. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  12535. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  12536. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12537. "&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
  12538. resp, requestErr := http.Get(api)
  12539. if requestErr != nil {
  12540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. return
  12542. }
  12543. body, ioErr := ioutil.ReadAll(resp.Body)
  12544. if ioErr != nil {
  12545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. var respJSON map[string]interface{}
  12550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12553. return
  12554. }
  12555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12556. result, _ := json.Marshal(respJSON)
  12557. fmt.Println("log")
  12558. fmt.Println(string(result))
  12559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12560. utils.ErrorLog("解析失败:%v", err)
  12561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. return
  12563. }
  12564. res.ErrMsg = res10265.ErrMsg
  12565. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12566. res.Infcode = infocode
  12567. res.Output = res10265.Output
  12568. res.InfRefmsgid = res10265.InfRefmsgid
  12569. } else {
  12570. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12571. if miConfig.Code == "H15049901371" {
  12572. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12573. utils.ErrorLog("解析失败:%v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. res.ErrMsg = res10265.ErrMsg
  12578. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12579. res.Infcode = infocode
  12580. res.Output = res10265.Output
  12581. res.InfRefmsgid = res10265.InfRefmsgid
  12582. } else {
  12583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12584. utils.ErrorLog("解析失败:%v", err)
  12585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12586. return
  12587. }
  12588. }
  12589. }
  12590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12591. infoStr := string(Iinfos)
  12592. var rf []*ResultFive
  12593. json.Unmarshal([]byte(infoStr), &rf)
  12594. var insuplc_admdvs string
  12595. var insutype string
  12596. var is390 int = 0
  12597. var is310 int = 0
  12598. var insutypes []*ResultFive
  12599. for _, item := range rf {
  12600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12601. insutypes = append(insutypes, item)
  12602. }
  12603. }
  12604. if len(insutypes) == 1 {
  12605. insutype = insutypes[0].Insutype
  12606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12607. } else {
  12608. for _, i := range insutypes {
  12609. if i.Insutype == "390" {
  12610. is390 = 1
  12611. }
  12612. if i.Insutype == "310" {
  12613. is310 = 1
  12614. }
  12615. }
  12616. }
  12617. if is390 == 1 {
  12618. insutype = "390"
  12619. }
  12620. if is310 == 1 {
  12621. insutype = "310"
  12622. }
  12623. if len(insutypes) == 2 {
  12624. insutype = insutype_two
  12625. }
  12626. if len(insutypes) == 0 {
  12627. insutype = "310"
  12628. }
  12629. insutype = insutype_two
  12630. fmt.Println(insutype)
  12631. for _, item := range rf {
  12632. fmt.Println(item.Insutype)
  12633. fmt.Println(insutype)
  12634. if item.Insutype == insutype {
  12635. fmt.Println(item.Insutype)
  12636. fmt.Println(insutype)
  12637. insuplc_admdvs = item.InsuplcAdmdvs
  12638. }
  12639. }
  12640. fmt.Println(insuplc_admdvs)
  12641. var res2 ResultThirteen
  12642. var res10265_2 ResultThirteen10265
  12643. if config.IsOpen == 1 {
  12644. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12645. } else {
  12646. 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)
  12647. var dat map[string]interface{}
  12648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12649. fmt.Println(dat)
  12650. } else {
  12651. fmt.Println(err)
  12652. }
  12653. userJSONBytes, _ := json.Marshal(dat)
  12654. if miConfig.Code == "H15049901371" {
  12655. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  12656. utils.ErrorLog("解析失败:%v", err)
  12657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12658. return
  12659. }
  12660. res2.ErrMsg = res10265_2.ErrMsg
  12661. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  12662. res2.Infcode = infocode
  12663. res2.Output = res10265_2.Output
  12664. res2.InfRefmsgid = res10265_2.InfRefmsgid
  12665. } else {
  12666. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12667. utils.ErrorLog("解析失败:%v", err)
  12668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12669. return
  12670. }
  12671. }
  12672. }
  12673. if res2.Infcode == 0 {
  12674. psnResult := &models.GdybPsnNcdsRecord{
  12675. UserOrgId: adminUser.CurrentOrgId,
  12676. PatientId: patient.ID,
  12677. PsnNo: psn_no,
  12678. DoctorId: doctor.AdminUserId,
  12679. DepartmentId: department_id,
  12680. SickType: sick_id,
  12681. Insutype: insutype,
  12682. Ctime: time.Now().Unix(),
  12683. Mtime: time.Now().Unix(),
  12684. Status: 1,
  12685. IsCancel: 1,
  12686. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12687. }
  12688. service.CreatePsnNCDSRecord(psnResult)
  12689. c.ServeSuccessJSON(map[string]interface{}{
  12690. "failed_code": 0,
  12691. "msg": "备案成功",
  12692. "result": psnResult,
  12693. })
  12694. } else {
  12695. c.ServeSuccessJSON(map[string]interface{}{
  12696. "failed_code": -10,
  12697. "msg": res2.ErrMsg,
  12698. })
  12699. return
  12700. }
  12701. }
  12702. }
  12703. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  12704. id, _ := c.GetInt64("id")
  12705. admin_user_id, _ := c.GetInt64("admin_user_id")
  12706. adminUser := c.GetAdminUserInfo()
  12707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12709. //config, _ := service.Ge(adminUser.CurrentOrgId)
  12710. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12711. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12712. //var user_name string
  12713. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12714. //if role.ID == 0 {
  12715. // user_name = "xxx"
  12716. //} else {
  12717. // user_name = role.UserName
  12718. //}
  12719. psn_record, _ := service.GetPsnNCDSRecordById(id)
  12720. if psn_record.ID == 0 {
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12722. return
  12723. }
  12724. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12725. var res ResultTwo
  12726. var res10265 ResultTwo10265
  12727. if miConfig.Code == "H15049901371" {
  12728. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12729. utils.ErrorLog("解析失败:%v", err)
  12730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12731. return
  12732. }
  12733. res.ErrMsg = res10265.ErrMsg
  12734. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12735. res.Infcode = infocode
  12736. res.Output = res10265.Output
  12737. res.InfRefmsgid = res10265.InfRefmsgid
  12738. } else {
  12739. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12740. utils.ErrorLog("解析失败:%v", err)
  12741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12742. return
  12743. }
  12744. }
  12745. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12746. infoStr := string(Iinfos)
  12747. var rf []*ResultFive
  12748. json.Unmarshal([]byte(infoStr), &rf)
  12749. var insuplc_admdvs string
  12750. var insutype string
  12751. var is390 int = 0
  12752. var is310 int = 0
  12753. var insutypes []*ResultFive
  12754. for _, item := range rf {
  12755. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12756. insutypes = append(insutypes, item)
  12757. }
  12758. }
  12759. if len(insutypes) == 1 {
  12760. insutype = insutypes[0].Insutype
  12761. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12762. } else {
  12763. for _, i := range insutypes {
  12764. if i.Insutype == "390" {
  12765. is390 = 1
  12766. }
  12767. if i.Insutype == "310" {
  12768. is310 = 1
  12769. }
  12770. }
  12771. }
  12772. if is390 == 1 {
  12773. insutype = "390"
  12774. }
  12775. if is310 == 1 {
  12776. insutype = "310"
  12777. }
  12778. if len(insutypes) == 0 {
  12779. insutype = "310"
  12780. }
  12781. insutype = psn_record.Insutype
  12782. for _, item := range rf {
  12783. if item.Insutype == insutype {
  12784. insuplc_admdvs = item.InsuplcAdmdvs
  12785. }
  12786. }
  12787. if config.IsOpen == 1 {
  12788. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12789. var dat map[string]interface{}
  12790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12791. fmt.Println(dat)
  12792. } else {
  12793. fmt.Println(err)
  12794. }
  12795. userJSONBytes, _ := json.Marshal(dat)
  12796. var res ResultFourteen
  12797. var res10265 ResultFourteen10265
  12798. if miConfig.Code == "H15049901371" {
  12799. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12800. utils.ErrorLog("解析失败:%v", err)
  12801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12802. return
  12803. }
  12804. res.ErrMsg = res10265.ErrMsg
  12805. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12806. res.Infcode = infocode
  12807. res.Output = res10265.Output
  12808. res.InfRefmsgid = res10265.InfRefmsgid
  12809. } else {
  12810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12811. utils.ErrorLog("解析失败:%v", err)
  12812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12813. return
  12814. }
  12815. }
  12816. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12817. // utils.ErrorLog("解析失败:%v", err)
  12818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12819. // return
  12820. //}
  12821. if res.Infcode == 0 {
  12822. psn_record.IsCancel = 2
  12823. service.CreatePsnNCDSRecord(&psn_record)
  12824. c.ServeSuccessJSON(map[string]interface{}{
  12825. "failed_code": 0,
  12826. "msg": "撤销备案成功",
  12827. })
  12828. } else {
  12829. c.ServeSuccessJSON(map[string]interface{}{
  12830. "failed_code": -10,
  12831. "msg": res.ErrMsg,
  12832. })
  12833. return
  12834. }
  12835. }
  12836. }
  12837. func (c *HisApiController) TestTest() {
  12838. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  12839. fmt.Println(patient.Iinfo)
  12840. }
  12841. type CustomData struct {
  12842. MsgId string
  12843. PsnNo string
  12844. Info string
  12845. }
  12846. func (c *HisApiController) ReversalData() {
  12847. var customData []*CustomData
  12848. custom := &CustomData{
  12849. MsgId: "H44022900158202103301714472004",
  12850. PsnNo: "44020000001101329945",
  12851. Info: "2207",
  12852. }
  12853. customData = append(customData, custom)
  12854. custom1 := &CustomData{
  12855. MsgId: "H4402290015820210330172057803",
  12856. PsnNo: "44020000001101161813",
  12857. Info: "2207",
  12858. }
  12859. customData = append(customData, custom1)
  12860. custom2 := &CustomData{
  12861. MsgId: "H44022900158202103301705198813",
  12862. PsnNo: "44190000133097375417",
  12863. Info: "2207",
  12864. }
  12865. customData = append(customData, custom2)
  12866. custom3 := &CustomData{
  12867. MsgId: "H44022900158202103301715524756",
  12868. PsnNo: "44020000001100187221",
  12869. Info: "2207",
  12870. }
  12871. customData = append(customData, custom3)
  12872. custom4 := &CustomData{
  12873. MsgId: "H44022900158202103301730376224",
  12874. PsnNo: "44020000001101959155",
  12875. Info: "2207",
  12876. }
  12877. customData = append(customData, custom4)
  12878. custom5 := &CustomData{
  12879. MsgId: "H44022900158202103301748008725",
  12880. PsnNo: "44020000001104246641",
  12881. Info: "2207",
  12882. }
  12883. customData = append(customData, custom5)
  12884. custom6 := &CustomData{
  12885. MsgId: "H44022900158202103301718096755",
  12886. PsnNo: "44020000001102211860",
  12887. Info: "2207",
  12888. }
  12889. customData = append(customData, custom6)
  12890. custom7 := &CustomData{
  12891. MsgId: "H44022900158202103301736551640",
  12892. PsnNo: "44020000001102687718",
  12893. Info: "2207",
  12894. }
  12895. customData = append(customData, custom7)
  12896. custom8 := &CustomData{
  12897. MsgId: "H44022900158202103301743097676",
  12898. PsnNo: "44020000001102127785",
  12899. Info: "2207",
  12900. }
  12901. customData = append(customData, custom8)
  12902. custom9 := &CustomData{
  12903. MsgId: "H44022900158202103301712304203",
  12904. PsnNo: "44020000001101518097",
  12905. Info: "2207",
  12906. }
  12907. customData = append(customData, custom9)
  12908. custom10 := &CustomData{
  12909. MsgId: "H44022900158202103301738448785",
  12910. PsnNo: "44020000001100500813",
  12911. Info: "2207",
  12912. }
  12913. customData = append(customData, custom10)
  12914. custom11 := &CustomData{
  12915. MsgId: "H44022900158202103301732455843",
  12916. PsnNo: "44020000001102690557",
  12917. Info: "2207",
  12918. }
  12919. customData = append(customData, custom11)
  12920. custom12 := &CustomData{
  12921. MsgId: "H44022900158202103301745421708",
  12922. PsnNo: "44020000001102211928",
  12923. Info: "2207",
  12924. }
  12925. customData = append(customData, custom12)
  12926. custom1212 := &CustomData{
  12927. MsgId: "H440229001582021033017351627",
  12928. PsnNo: "44020000001102481733",
  12929. Info: "2207",
  12930. }
  12931. customData = append(customData, custom1212)
  12932. custom13 := &CustomData{
  12933. MsgId: "H44022900158202103301740327951",
  12934. PsnNo: "44020000001103174866",
  12935. Info: "2207",
  12936. }
  12937. customData = append(customData, custom13)
  12938. custom14 := &CustomData{
  12939. MsgId: "H4402290015820210330174922668",
  12940. PsnNo: "44020000001102927272",
  12941. Info: "2207",
  12942. }
  12943. customData = append(customData, custom14)
  12944. custom15 := &CustomData{
  12945. MsgId: "H44022900158202103301752362273",
  12946. PsnNo: "44020000001102942890",
  12947. Info: "2207",
  12948. }
  12949. customData = append(customData, custom15)
  12950. custom16 := &CustomData{
  12951. MsgId: "H44022900158202103301751082917",
  12952. PsnNo: "44020000001101662162",
  12953. Info: "2207",
  12954. }
  12955. customData = append(customData, custom16)
  12956. custom17 := &CustomData{
  12957. MsgId: "H44022900158202103301754147728",
  12958. PsnNo: "44020000000229014511",
  12959. Info: "2207",
  12960. }
  12961. customData = append(customData, custom17)
  12962. adminUser := c.GetAdminUserInfo()
  12963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12964. for _, item := range customData {
  12965. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12966. fmt.Println(result)
  12967. }
  12968. }
  12969. //func (c *HisApiController) GetAllopatry() {
  12970. // year := c.GetString("year")
  12971. // month := c.GetString("month")
  12972. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12973. // adminUser := c.GetAdminUserInfo()
  12974. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12975. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12976. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  12977. //
  12978. // var dat map[string]interface{}
  12979. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12980. // fmt.Println(dat)
  12981. // } else {
  12982. // fmt.Println(err)
  12983. // }
  12984. // userJSONBytes, _ := json.Marshal(dat)
  12985. // var res models.Result9001
  12986. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12987. // utils.ErrorLog("解析失败:%v", err)
  12988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. // return
  12990. // }
  12991. //
  12992. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  12993. // var dat2 map[string]interface{}
  12994. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12995. // fmt.Println(dat)
  12996. // } else {
  12997. // fmt.Println(err)
  12998. // }
  12999. // userJSONBytes2, _ := json.Marshal(dat2)
  13000. // var res2 models.Result3260
  13001. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13002. // utils.ErrorLog("解析失败:%v", err)
  13003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13004. // return
  13005. // }
  13006. // if res2.Infcode == 0 {
  13007. // c.ServeSuccessJSON(map[string]interface{}{
  13008. // "list": res2.Output.Data,
  13009. // })
  13010. // return
  13011. // } else {
  13012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13013. // return
  13014. // }
  13015. //
  13016. //}
  13017. //func (c *HisApiController) ComfirmAllopatry() {
  13018. // year := c.GetString("year")
  13019. // month := c.GetString("month")
  13020. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13021. // adminUser := c.GetAdminUserInfo()
  13022. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13023. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13024. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13025. // var dat map[string]interface{}
  13026. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13027. // fmt.Println(dat)
  13028. // } else {
  13029. // fmt.Println(err)
  13030. // }
  13031. // userJSONBytes, _ := json.Marshal(dat)
  13032. // var res models.Result9001
  13033. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13034. // utils.ErrorLog("解析失败:%v", err)
  13035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13036. // return
  13037. // }
  13038. //
  13039. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13040. // var dat2 map[string]interface{}
  13041. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13042. // fmt.Println(dat)
  13043. // } else {
  13044. // fmt.Println(err)
  13045. // }
  13046. // userJSONBytes2, _ := json.Marshal(dat2)
  13047. // var res2 models.Result3260
  13048. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13049. // utils.ErrorLog("解析失败:%v", err)
  13050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13051. // return
  13052. // }
  13053. //
  13054. // if res2.Infcode == 0 {
  13055. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13056. // var dat map[string]interface{}
  13057. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13058. // fmt.Println(dat)
  13059. // } else {
  13060. // fmt.Println(err)
  13061. // }
  13062. // userJSONBytes, _ := json.Marshal(dat)
  13063. // var res3 models.Result3261
  13064. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13065. // utils.ErrorLog("解析失败:%v", err)
  13066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13067. // return
  13068. // }
  13069. //
  13070. // if res3.Infcode == 0 {
  13071. // record := &models.HisYidiClearRecord{
  13072. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13073. // Ctime: time.Now().Unix(),
  13074. // Mtime: time.Now().Unix(),
  13075. // Status: 1,
  13076. // MsgId: msgId,
  13077. // }
  13078. // service.SaveClearRecord(record)
  13079. // c.ServeSuccessJSON(map[string]interface{}{
  13080. // "msg": "提取成功",
  13081. // })
  13082. // }
  13083. // }
  13084. //}
  13085. func (c *HisApiController) RefundAllopatry() {
  13086. year := c.GetString("year")
  13087. month := c.GetString("month")
  13088. id, _ := c.GetInt64("id")
  13089. admin_user_id, _ := c.GetInt64("admin_user_id")
  13090. adminUser := c.GetAdminUserInfo()
  13091. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13092. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13093. record, _ := service.GetClearRecordById(id)
  13094. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13095. var dat map[string]interface{}
  13096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13097. fmt.Println(dat)
  13098. } else {
  13099. fmt.Println(err)
  13100. }
  13101. userJSONBytes, _ := json.Marshal(dat)
  13102. var empty ResultFourteen
  13103. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13104. utils.ErrorLog("解析失败:%v", err)
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13106. return
  13107. }
  13108. if empty.Infcode == 0 {
  13109. c.ServeSuccessJSON(map[string]interface{}{
  13110. "msg": "撤销成功",
  13111. })
  13112. return
  13113. }
  13114. }
  13115. func (c *HisApiController) ReversalOtherData() {
  13116. var customData []*CustomData
  13117. custom := &CustomData{
  13118. MsgId: "H44022900158202103301714472004",
  13119. PsnNo: "44020000001101329945",
  13120. Info: "2208",
  13121. }
  13122. customData = append(customData, custom)
  13123. custom1 := &CustomData{
  13124. MsgId: "H4402290015820210330172057803",
  13125. PsnNo: "44020000001101161813",
  13126. Info: "2208",
  13127. }
  13128. customData = append(customData, custom1)
  13129. custom2 := &CustomData{
  13130. MsgId: "H44022900158202103301705198813",
  13131. PsnNo: "44190000133097375417",
  13132. Info: "2208",
  13133. }
  13134. customData = append(customData, custom2)
  13135. custom3 := &CustomData{
  13136. MsgId: "H44022900158202103301715524756",
  13137. PsnNo: "44020000001100187221",
  13138. Info: "2208",
  13139. }
  13140. customData = append(customData, custom3)
  13141. custom4 := &CustomData{
  13142. MsgId: "H44022900158202103301730376224",
  13143. PsnNo: "44020000001101959155",
  13144. Info: "2208",
  13145. }
  13146. customData = append(customData, custom4)
  13147. custom5 := &CustomData{
  13148. MsgId: "H44022900158202103301748008725",
  13149. PsnNo: "44020000001104246641",
  13150. Info: "2208",
  13151. }
  13152. customData = append(customData, custom5)
  13153. custom6 := &CustomData{
  13154. MsgId: "H44022900158202103301718096755",
  13155. PsnNo: "44020000001102211860",
  13156. Info: "2208",
  13157. }
  13158. customData = append(customData, custom6)
  13159. custom7 := &CustomData{
  13160. MsgId: "H44022900158202103301736551640",
  13161. PsnNo: "44020000001102687718",
  13162. Info: "2208",
  13163. }
  13164. customData = append(customData, custom7)
  13165. custom8 := &CustomData{
  13166. MsgId: "H44022900158202103301743097676",
  13167. PsnNo: "44020000001102127785",
  13168. Info: "2208",
  13169. }
  13170. customData = append(customData, custom8)
  13171. custom9 := &CustomData{
  13172. MsgId: "H44022900158202103301712304203",
  13173. PsnNo: "44020000001101518097",
  13174. Info: "2208",
  13175. }
  13176. customData = append(customData, custom9)
  13177. custom10 := &CustomData{
  13178. MsgId: "H44022900158202103301738448785",
  13179. PsnNo: "44020000001100500813",
  13180. Info: "2208",
  13181. }
  13182. customData = append(customData, custom10)
  13183. custom11 := &CustomData{
  13184. MsgId: "H44022900158202103301732455843",
  13185. PsnNo: "44020000001102690557",
  13186. Info: "2208",
  13187. }
  13188. customData = append(customData, custom11)
  13189. custom12 := &CustomData{
  13190. MsgId: "H44022900158202103301745421708",
  13191. PsnNo: "44020000001102211928",
  13192. Info: "2208",
  13193. }
  13194. customData = append(customData, custom12)
  13195. custom1212 := &CustomData{
  13196. MsgId: "H440229001582021033017351627",
  13197. PsnNo: "44020000001102481733",
  13198. Info: "2208",
  13199. }
  13200. customData = append(customData, custom1212)
  13201. custom13 := &CustomData{
  13202. MsgId: "H44022900158202103301740327951",
  13203. PsnNo: "44020000001103174866",
  13204. Info: "2208",
  13205. }
  13206. customData = append(customData, custom13)
  13207. custom14 := &CustomData{
  13208. MsgId: "H4402290015820210330174922668",
  13209. PsnNo: "44020000001102927272",
  13210. Info: "2208",
  13211. }
  13212. customData = append(customData, custom14)
  13213. custom15 := &CustomData{
  13214. MsgId: "H44022900158202103301752362273",
  13215. PsnNo: "44020000001102942890",
  13216. Info: "2208",
  13217. }
  13218. customData = append(customData, custom15)
  13219. custom16 := &CustomData{
  13220. MsgId: "H44022900158202103301751082917",
  13221. PsnNo: "44020000001101662162",
  13222. Info: "2208",
  13223. }
  13224. customData = append(customData, custom16)
  13225. custom17 := &CustomData{
  13226. MsgId: "H44022900158202103301754147728",
  13227. PsnNo: "44020000000229014511",
  13228. Info: "2208",
  13229. }
  13230. customData = append(customData, custom17)
  13231. adminUser := c.GetAdminUserInfo()
  13232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13233. for _, item := range customData {
  13234. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13235. fmt.Println(result)
  13236. }
  13237. }
  13238. func PathExists(path string) (bool, error) {
  13239. _, err := os.Stat(path)
  13240. if err == nil {
  13241. return true, nil
  13242. }
  13243. if os.IsNotExist(err) {
  13244. return false, nil
  13245. }
  13246. return false, err
  13247. }
  13248. //创建文件夹
  13249. func Mkdir(dir string) {
  13250. // 创建文件夹
  13251. exist, err := PathExists(dir)
  13252. if err != nil {
  13253. fmt.Println(err.Error())
  13254. } else {
  13255. if exist {
  13256. fmt.Println(dir + "文件夹已存在!")
  13257. } else {
  13258. // 文件夹名称,权限
  13259. err := os.Mkdir(dir, os.ModePerm)
  13260. if err != nil {
  13261. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13262. } else {
  13263. fmt.Println(dir + "文件夹创建成功!")
  13264. }
  13265. }
  13266. }
  13267. }
  13268. //压缩文件
  13269. func Zip(srcFile string, destZip string) error {
  13270. zipfile, err := os.Create(destZip)
  13271. if err != nil {
  13272. return err
  13273. }
  13274. defer zipfile.Close()
  13275. archive := zip.NewWriter(zipfile)
  13276. defer archive.Close()
  13277. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13278. if err != nil {
  13279. return err
  13280. }
  13281. header, err := zip.FileInfoHeader(info)
  13282. if err != nil {
  13283. return err
  13284. }
  13285. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13286. // header.Name = path
  13287. if info.IsDir() {
  13288. header.Name += "/"
  13289. } else {
  13290. header.Method = zip.Deflate
  13291. }
  13292. writer, err := archive.CreateHeader(header)
  13293. if err != nil {
  13294. return err
  13295. }
  13296. if !info.IsDir() {
  13297. file, err := os.Open(path)
  13298. if err != nil {
  13299. return err
  13300. }
  13301. defer file.Close()
  13302. _, err = io.Copy(writer, file)
  13303. }
  13304. return err
  13305. })
  13306. return err
  13307. }
  13308. func ReadFile(filePath string) []byte {
  13309. f, err := os.Open(filePath)
  13310. if err != nil {
  13311. fmt.Println("read file fail", err)
  13312. return nil
  13313. }
  13314. defer f.Close()
  13315. fd, err := ioutil.ReadAll(f)
  13316. if err != nil {
  13317. fmt.Println("read to fd fail", err)
  13318. return nil
  13319. }
  13320. return fd
  13321. }
  13322. func saveLog(result string, request string, infno string, desc string) {
  13323. org_id, _ := beego.AppConfig.Int64("org_id")
  13324. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13325. dir := miConfig.OrgName + "日志"
  13326. utils.Mkdir(dir)
  13327. month := time.Unix(1557042972, 0).Format("1")
  13328. year := time.Now().Format("2006")
  13329. month = time.Now().Format("01")
  13330. day := time.Now().Format("02")
  13331. hour := time.Now().Format("15")
  13332. min := time.Now().Format("04")
  13333. sec := time.Now().Format("05")
  13334. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13335. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13336. file_name := file + ".txt"
  13337. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13338. exist, _ := utils.PathExists(file_path)
  13339. if exist { //存在
  13340. fmt.Println("存在")
  13341. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13342. if err != nil {
  13343. fmt.Println("read fail")
  13344. }
  13345. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13346. n, _ := f.Seek(0, 2)
  13347. _, err = f.WriteAt([]byte(content), n)
  13348. } else { //不存在
  13349. fmt.Println("文件不存在,创建文件")
  13350. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13351. defer f.Close()
  13352. if err != nil {
  13353. } else {
  13354. _, err = f.Write([]byte("记录日志"))
  13355. }
  13356. }
  13357. }
  13358. type Charset string
  13359. const (
  13360. UTF8 = Charset("UTF-8")
  13361. GB18030 = Charset("GB18030")
  13362. )
  13363. func ConvertToString(src string, srcCode string, tagCode string) string {
  13364. srcCoder := mahonia.NewDecoder(srcCode)
  13365. srcResult := srcCoder.ConvertString(src)
  13366. tagCoder := mahonia.NewDecoder(tagCode)
  13367. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13368. result := string(cdata)
  13369. return result
  13370. }
  13371. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13372. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13373. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13374. var token string
  13375. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13376. var api string
  13377. if miConfig.MdtrtareaAdmvs == "320921" {
  13378. 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 +
  13379. "&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
  13380. fmt.Println(api)
  13381. } else {
  13382. 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 +
  13383. "&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
  13384. }
  13385. resp, requestErr := http.Get(api)
  13386. if requestErr != nil {
  13387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13388. return ""
  13389. }
  13390. body, ioErr := ioutil.ReadAll(resp.Body)
  13391. if ioErr != nil {
  13392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13394. return ""
  13395. }
  13396. var respJSON map[string]interface{}
  13397. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return ""
  13401. }
  13402. var status string
  13403. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13404. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13405. var res ResultTwo //1101结果
  13406. var res10265 ResultTwo10265 //1101结果
  13407. if status == "0" { //读卡成功
  13408. var card_info string //卡信息
  13409. var busi_card_info string
  13410. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13411. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13412. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13413. fmt.Println(card_info)
  13414. fmt.Println(busi_card_info)
  13415. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13416. result, _ := json.Marshal(respJSON)
  13417. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13418. utils.ErrorLog("解析失败:%v", err)
  13419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13420. return ""
  13421. }
  13422. res.ErrMsg = res10265.ErrMsg
  13423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13424. res.Infcode = infocode
  13425. res.Output = res10265.Output
  13426. res.InfRefmsgid = res10265.InfRefmsgid
  13427. if res.Infcode == 0 {
  13428. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13429. if err == gorm.ErrRecordNotFound {
  13430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13431. return ""
  13432. } else if err != nil {
  13433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13434. return ""
  13435. } else {
  13436. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13437. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13438. infoStr := string(Iinfos)
  13439. idetinfoStr := string(Idetinfos)
  13440. psn := &models.HisPsn{
  13441. PsnNo: res.Output.Baseinfo.PsnNo,
  13442. Age: res.Output.Baseinfo.Age,
  13443. PatientId: patient.ID,
  13444. Certno: res.Output.Baseinfo.Certno,
  13445. Brdy: res.Output.Baseinfo.Brdy,
  13446. Gend: res.Output.Baseinfo.Gend,
  13447. Naty: res.Output.Baseinfo.Naty,
  13448. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13449. PsnName: res.Output.Baseinfo.PsnName,
  13450. Idetinfo: idetinfoStr,
  13451. Insuinfo: infoStr,
  13452. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13453. CardInfo: card_info,
  13454. VerifyNumber: token,
  13455. }
  13456. service.CreateHisPsn(psn)
  13457. return token
  13458. }
  13459. }
  13460. } else {
  13461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13462. return ""
  13463. }
  13464. } else { //读卡失败
  13465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13466. return ""
  13467. }
  13468. return token
  13469. }
  13470. func DeleteExtraSpaceTwo(s string) string {
  13471. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13472. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13473. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13474. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13475. s2 := make([]byte, len(s1)) //定义字符数组切片
  13476. copy(s2, s1) //将字符串复制到切片
  13477. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13478. for len(spc_index) > 0 { //找到适配项
  13479. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13480. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13481. }
  13482. return string(s2)
  13483. }
  13484. func Remove0000(s string) string {
  13485. str := make([]rune, 0, len(s))
  13486. for _, v := range []rune(s) {
  13487. if v == 0 {
  13488. continue
  13489. }
  13490. str = append(str, v)
  13491. }
  13492. return string(str)
  13493. }
  13494. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13495. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13496. readCard := DllDef.MustFindProc("EcQuery")
  13497. pCardInfo := make([]byte, 8192)
  13498. pBusiCardInfo := make([]byte, 8192)
  13499. data := make(map[string]interface{})
  13500. //pData := make(map[string]interface{})
  13501. inputData := make(map[string]interface{})
  13502. inputData["orgId"] = code
  13503. inputData["businessType"] = "01101"
  13504. inputData["operatorId"] = operator_id
  13505. inputData["operatorName"] = operator_name
  13506. inputData["officeId"] = "001"
  13507. inputData["officeName"] = "血透室"
  13508. //
  13509. data["data"] = inputData
  13510. data["transType"] = "ec.query"
  13511. data["orgId"] = code
  13512. bytesData, _ := json.Marshal(data)
  13513. pCardInfo = bytesData
  13514. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13515. fmt.Println(ret2)
  13516. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13517. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13518. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13519. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13520. if ret2 != 0 {
  13521. return "", ""
  13522. }
  13523. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13524. }
  13525. func DeleteExtraSpace(s string) string {
  13526. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13527. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13528. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13529. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13530. s2 := make([]byte, len(s1)) //定义字符数组切片
  13531. copy(s2, s1) //将字符串复制到切片
  13532. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13533. for len(spc_index) > 0 { //找到适配项
  13534. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13535. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13536. }
  13537. return string(s2)
  13538. }
  13539. //对账
  13540. func (c *HisApiController) Post3202() {
  13541. start_time := c.GetString("start_time")
  13542. end_time := c.GetString("end_time")
  13543. //insutype := c.GetString("insutype")
  13544. clr_type := c.GetString("clr_type")
  13545. clr_org := c.GetString("clr_optins")
  13546. admin_user_id, _ := c.GetInt64("admin_user_id")
  13547. adminUser := c.GetAdminUserInfo()
  13548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13549. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13550. if len(clr_org) == 0 {
  13551. clr_org = miConfig.MdtrtareaAdmvs
  13552. }
  13553. timeLayout := "2006-01-02"
  13554. loc, _ := time.LoadLocation("Local")
  13555. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13556. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13557. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13558. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  13559. //fixmedins_setl_cnt := int64(len(orders))
  13560. var medfee_sumamt float64
  13561. var acct_pay float64
  13562. var fund_pay_sumamt float64
  13563. for _, item := range orders {
  13564. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13565. acct_pay = acct_pay + item.AcctPay
  13566. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13567. }
  13568. //var medfee_sumamt_two float64
  13569. //var acct_pay_two float64
  13570. //var fund_pay_sumamt_two float64
  13571. //for _, item := range orders_two {
  13572. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  13573. // acct_pay_two = acct_pay_two + item.AcctPay
  13574. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  13575. //}
  13576. //var user_name string
  13577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13578. //if role.ID == 0 {
  13579. // user_name = "xxx"
  13580. //} else {
  13581. // user_name = role.UserName
  13582. //}
  13583. var res ResultSix
  13584. if config.IsOpen == 1 {
  13585. var bps []*models.BusinessParamsTwo
  13586. var bp models.BusinessParamsTwo
  13587. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  13588. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  13589. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  13590. bp.MedfeeSumamt = medfee_sumamt_str
  13591. bp.AcctPay = acct_pay_str
  13592. bp.FundPaySumamt = fund_pay_sumamt_str
  13593. bp.Insutype = "390"
  13594. bp.StmtBegndate = start_time
  13595. bp.ClrType = clr_type
  13596. bp.SetlOptins = clr_org
  13597. bp.StmtEnddate = end_time
  13598. bps = append(bps, &bp)
  13599. data := make(map[string]interface{})
  13600. data["bps"] = bps
  13601. data["org_name"] = miConfig.OrgName
  13602. data["doctor"] = role.UserName
  13603. data["fixmedins_code"] = miConfig.Code
  13604. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13605. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13606. if miConfig.MdtrtareaAdmvs == "421300" {
  13607. client := &http.Client{}
  13608. bytesData, _ := json.Marshal(data)
  13609. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  13610. resp, _ := client.Do(req)
  13611. defer resp.Body.Close()
  13612. body, ioErr := ioutil.ReadAll(resp.Body)
  13613. if ioErr != nil {
  13614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13616. return
  13617. }
  13618. var respJSON map[string]interface{}
  13619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13622. return
  13623. }
  13624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13625. userJSONBytes, _ := json.Marshal(respJSON)
  13626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13627. utils.ErrorLog("解析失败:%v", err)
  13628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13629. return
  13630. }
  13631. }
  13632. if res.Infcode == 0 {
  13633. c.ServeSuccessJSON(map[string]interface{}{
  13634. "msg": "发起成功",
  13635. })
  13636. } else {
  13637. c.ServeSuccessJSON(map[string]interface{}{
  13638. "code": -10,
  13639. "msg": res.ErrMsg,
  13640. })
  13641. }
  13642. }
  13643. }
  13644. func (c *HisApiController) Post3501() {
  13645. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13646. data := make(map[string]interface{})
  13647. var struct3501s []models.Struct3501
  13648. var struct3501 models.Struct3501
  13649. struct3501.OrgName = miConfig.OrgName
  13650. struct3501.AccessKey = miConfig.AccessKey
  13651. struct3501.RequestUrl = miConfig.Url
  13652. struct3501.SecretKey = miConfig.SecretKey
  13653. struct3501.ManuDate = "2022-08-17"
  13654. struct3501.FixmedinsBchno = ""
  13655. struct3501.ManuLotnum = ""
  13656. struct3501.RxFlag = "0"
  13657. struct3501.ExpyEnd = "2022-08-17"
  13658. struct3501.Invdate = "2022-08-17"
  13659. struct3501.InvCnt = "20.25"
  13660. struct3501.Memo = ""
  13661. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13662. struct3501.FixmedinsHilistId = miConfig.Code
  13663. struct3501.FixmedinsHilistName = miConfig.OrgName
  13664. struct3501s = append(struct3501s, struct3501)
  13665. data["struct_3501s"] = struct3501s
  13666. client := &http.Client{}
  13667. bytesData, _ := json.Marshal(data)
  13668. var req *http.Request
  13669. if miConfig.MdtrtareaAdmvs == "320921" {
  13670. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13671. } else {
  13672. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13673. }
  13674. resp, _ := client.Do(req)
  13675. defer resp.Body.Close()
  13676. body, ioErr := ioutil.ReadAll(resp.Body)
  13677. if ioErr != nil {
  13678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13680. return
  13681. }
  13682. var respJSON map[string]interface{}
  13683. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13686. return
  13687. }
  13688. var res ResultSix
  13689. var resSix10265 ResultSix10265 //1101结果
  13690. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13691. result, _ := json.Marshal(respJSON)
  13692. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13693. utils.ErrorLog("解析失败:%v", err)
  13694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13695. return
  13696. }
  13697. res.InfRefmsgid = resSix10265.InfRefmsgid
  13698. res.Output = resSix10265.Output
  13699. res.ErrMsg = resSix10265.ErrMsg
  13700. res.Cainfo = resSix10265.Cainfo
  13701. res.WarnMsg = resSix10265.WarnMsg
  13702. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13703. res.Infcode = infocode
  13704. if infocode == 0 {
  13705. c.ServeSuccessJSON(map[string]interface{}{
  13706. "msg": "上传成功",
  13707. })
  13708. return
  13709. } else {
  13710. c.ServeSuccessJSON(map[string]interface{}{
  13711. "failed_code": -10,
  13712. "msg": res.ErrMsg,
  13713. })
  13714. return
  13715. }
  13716. }
  13717. func (c *HisApiController) Post3502() {
  13718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13719. data := make(map[string]interface{})
  13720. var struct3502s []models.Struct3502
  13721. var struct3502 models.Struct3502
  13722. struct3502.OrgName = miConfig.OrgName
  13723. struct3502.AccessKey = miConfig.AccessKey
  13724. struct3502.RequestUrl = miConfig.Url
  13725. struct3502.SecretKey = miConfig.SecretKey
  13726. struct3502.ManuDate = "2022-08-15"
  13727. struct3502.FixmedinsBchno = ""
  13728. struct3502.ManuLotnum = ""
  13729. struct3502.RxFlag = "0"
  13730. struct3502.ExpyEnd = "2022-08-15"
  13731. struct3502.Invdate = "2022-08-15"
  13732. struct3502.InvCnt = "20.25"
  13733. struct3502.Memo = ""
  13734. struct3502.MedListCodg = "XB01ABD056B002020200517"
  13735. struct3502.FixmedinsHilistId = miConfig.Code
  13736. struct3502.FixmedinsHilistName = miConfig.OrgName
  13737. struct3502s = append(struct3502s, struct3502)
  13738. data["struct_3502s"] = struct3502s
  13739. client := &http.Client{}
  13740. bytesData, _ := json.Marshal(data)
  13741. var req *http.Request
  13742. if miConfig.MdtrtareaAdmvs == "320921" {
  13743. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13744. } else {
  13745. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13746. }
  13747. resp, _ := client.Do(req)
  13748. defer resp.Body.Close()
  13749. body, ioErr := ioutil.ReadAll(resp.Body)
  13750. if ioErr != nil {
  13751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13753. return
  13754. }
  13755. var respJSON map[string]interface{}
  13756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13759. return
  13760. }
  13761. var res ResultSix
  13762. var resSix10265 ResultSix10265 //1101结果
  13763. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13764. result, _ := json.Marshal(respJSON)
  13765. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13766. utils.ErrorLog("解析失败:%v", err)
  13767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13768. return
  13769. }
  13770. res.InfRefmsgid = resSix10265.InfRefmsgid
  13771. res.Output = resSix10265.Output
  13772. res.ErrMsg = resSix10265.ErrMsg
  13773. res.Cainfo = resSix10265.Cainfo
  13774. res.WarnMsg = resSix10265.WarnMsg
  13775. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13776. res.Infcode = infocode
  13777. if infocode == 0 {
  13778. c.ServeSuccessJSON(map[string]interface{}{
  13779. "msg": "上传成功",
  13780. })
  13781. return
  13782. } else {
  13783. c.ServeSuccessJSON(map[string]interface{}{
  13784. "failed_code": -10,
  13785. "msg": res.ErrMsg,
  13786. })
  13787. return
  13788. }
  13789. }
  13790. func (c *HisApiController) Post3503() {
  13791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13792. data := make(map[string]interface{})
  13793. var struct3501s []models.Struct3501
  13794. var struct3501 models.Struct3501
  13795. struct3501.OrgName = miConfig.OrgName
  13796. struct3501.AccessKey = miConfig.AccessKey
  13797. struct3501.RequestUrl = miConfig.Url
  13798. struct3501.SecretKey = miConfig.SecretKey
  13799. struct3501.ManuDate = "2022-08-15"
  13800. struct3501.FixmedinsBchno = ""
  13801. struct3501.ManuLotnum = ""
  13802. struct3501.RxFlag = "0"
  13803. struct3501.ExpyEnd = "2022-08-15"
  13804. struct3501.Invdate = "2022-08-15"
  13805. struct3501.InvCnt = "20.25"
  13806. struct3501.Memo = ""
  13807. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13808. struct3501.FixmedinsHilistId = miConfig.Code
  13809. struct3501.FixmedinsHilistName = miConfig.OrgName
  13810. struct3501s = append(struct3501s, struct3501)
  13811. data["struct_3501s"] = struct3501s
  13812. client := &http.Client{}
  13813. bytesData, _ := json.Marshal(data)
  13814. var req *http.Request
  13815. if miConfig.MdtrtareaAdmvs == "320921" {
  13816. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13817. } else {
  13818. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13819. }
  13820. resp, _ := client.Do(req)
  13821. defer resp.Body.Close()
  13822. body, ioErr := ioutil.ReadAll(resp.Body)
  13823. if ioErr != nil {
  13824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13826. return
  13827. }
  13828. var respJSON map[string]interface{}
  13829. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13832. return
  13833. }
  13834. var res ResultSix
  13835. var resSix10265 ResultSix10265 //1101结果
  13836. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13837. result, _ := json.Marshal(respJSON)
  13838. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13839. utils.ErrorLog("解析失败:%v", err)
  13840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13841. return
  13842. }
  13843. res.InfRefmsgid = resSix10265.InfRefmsgid
  13844. res.Output = resSix10265.Output
  13845. res.ErrMsg = resSix10265.ErrMsg
  13846. res.Cainfo = resSix10265.Cainfo
  13847. res.WarnMsg = resSix10265.WarnMsg
  13848. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13849. res.Infcode = infocode
  13850. if infocode == 0 {
  13851. c.ServeSuccessJSON(map[string]interface{}{
  13852. "msg": "上传成功",
  13853. })
  13854. return
  13855. } else {
  13856. c.ServeSuccessJSON(map[string]interface{}{
  13857. "failed_code": -10,
  13858. "msg": res.ErrMsg,
  13859. })
  13860. return
  13861. }
  13862. }
  13863. func (c *HisApiController) Post3504() {
  13864. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13865. data := make(map[string]interface{})
  13866. var struct3501s []models.Struct3501
  13867. var struct3501 models.Struct3501
  13868. struct3501.OrgName = miConfig.OrgName
  13869. struct3501.AccessKey = miConfig.AccessKey
  13870. struct3501.RequestUrl = miConfig.Url
  13871. struct3501.SecretKey = miConfig.SecretKey
  13872. struct3501.ManuDate = "2022-08-15"
  13873. struct3501.FixmedinsBchno = ""
  13874. struct3501.ManuLotnum = ""
  13875. struct3501.RxFlag = "0"
  13876. struct3501.ExpyEnd = "2022-08-15"
  13877. struct3501.Invdate = "2022-08-15"
  13878. struct3501.InvCnt = "20.25"
  13879. struct3501.Memo = ""
  13880. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13881. struct3501.FixmedinsHilistId = miConfig.Code
  13882. struct3501.FixmedinsHilistName = miConfig.OrgName
  13883. struct3501s = append(struct3501s, struct3501)
  13884. data["struct_3501s"] = struct3501s
  13885. client := &http.Client{}
  13886. bytesData, _ := json.Marshal(data)
  13887. var req *http.Request
  13888. if miConfig.MdtrtareaAdmvs == "320921" {
  13889. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13890. } else {
  13891. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13892. }
  13893. resp, _ := client.Do(req)
  13894. defer resp.Body.Close()
  13895. body, ioErr := ioutil.ReadAll(resp.Body)
  13896. if ioErr != nil {
  13897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13899. return
  13900. }
  13901. var respJSON map[string]interface{}
  13902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13905. return
  13906. }
  13907. var res ResultSix
  13908. var resSix10265 ResultSix10265 //1101结果
  13909. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13910. result, _ := json.Marshal(respJSON)
  13911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13912. utils.ErrorLog("解析失败:%v", err)
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13914. return
  13915. }
  13916. res.InfRefmsgid = resSix10265.InfRefmsgid
  13917. res.Output = resSix10265.Output
  13918. res.ErrMsg = resSix10265.ErrMsg
  13919. res.Cainfo = resSix10265.Cainfo
  13920. res.WarnMsg = resSix10265.WarnMsg
  13921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13922. res.Infcode = infocode
  13923. if infocode == 0 {
  13924. c.ServeSuccessJSON(map[string]interface{}{
  13925. "msg": "上传成功",
  13926. })
  13927. return
  13928. } else {
  13929. c.ServeSuccessJSON(map[string]interface{}{
  13930. "failed_code": -10,
  13931. "msg": res.ErrMsg,
  13932. })
  13933. return
  13934. }
  13935. }
  13936. func (c *HisApiController) Post3505() {
  13937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13938. data := make(map[string]interface{})
  13939. var struct3501s []models.Struct3501
  13940. var struct3501 models.Struct3501
  13941. struct3501.OrgName = miConfig.OrgName
  13942. struct3501.AccessKey = miConfig.AccessKey
  13943. struct3501.RequestUrl = miConfig.Url
  13944. struct3501.SecretKey = miConfig.SecretKey
  13945. struct3501.ManuDate = "2022-08-15"
  13946. struct3501.FixmedinsBchno = ""
  13947. struct3501.ManuLotnum = ""
  13948. struct3501.RxFlag = "0"
  13949. struct3501.ExpyEnd = "2022-08-15"
  13950. struct3501.Invdate = "2022-08-15"
  13951. struct3501.InvCnt = "20.25"
  13952. struct3501.Memo = ""
  13953. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13954. struct3501.FixmedinsHilistId = miConfig.Code
  13955. struct3501.FixmedinsHilistName = miConfig.OrgName
  13956. struct3501s = append(struct3501s, struct3501)
  13957. data["struct_3501s"] = struct3501s
  13958. client := &http.Client{}
  13959. bytesData, _ := json.Marshal(data)
  13960. var req *http.Request
  13961. if miConfig.MdtrtareaAdmvs == "320921" {
  13962. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13963. } else {
  13964. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13965. }
  13966. resp, _ := client.Do(req)
  13967. defer resp.Body.Close()
  13968. body, ioErr := ioutil.ReadAll(resp.Body)
  13969. if ioErr != nil {
  13970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13972. return
  13973. }
  13974. var respJSON map[string]interface{}
  13975. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13978. return
  13979. }
  13980. var res ResultSix
  13981. var resSix10265 ResultSix10265 //1101结果
  13982. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13983. result, _ := json.Marshal(respJSON)
  13984. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13985. utils.ErrorLog("解析失败:%v", err)
  13986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13987. return
  13988. }
  13989. res.InfRefmsgid = resSix10265.InfRefmsgid
  13990. res.Output = resSix10265.Output
  13991. res.ErrMsg = resSix10265.ErrMsg
  13992. res.Cainfo = resSix10265.Cainfo
  13993. res.WarnMsg = resSix10265.WarnMsg
  13994. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13995. res.Infcode = infocode
  13996. if infocode == 0 {
  13997. c.ServeSuccessJSON(map[string]interface{}{
  13998. "msg": "上传成功",
  13999. })
  14000. return
  14001. } else {
  14002. c.ServeSuccessJSON(map[string]interface{}{
  14003. "failed_code": -10,
  14004. "msg": res.ErrMsg,
  14005. })
  14006. return
  14007. }
  14008. }
  14009. func (c *HisApiController) Post3506() {
  14010. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14011. data := make(map[string]interface{})
  14012. var struct3501s []models.Struct3501
  14013. var struct3501 models.Struct3501
  14014. struct3501.OrgName = miConfig.OrgName
  14015. struct3501.AccessKey = miConfig.AccessKey
  14016. struct3501.RequestUrl = miConfig.Url
  14017. struct3501.SecretKey = miConfig.SecretKey
  14018. struct3501.ManuDate = "2022-08-15"
  14019. struct3501.FixmedinsBchno = ""
  14020. struct3501.ManuLotnum = ""
  14021. struct3501.RxFlag = "0"
  14022. struct3501.ExpyEnd = "2022-08-15"
  14023. struct3501.Invdate = "2022-08-15"
  14024. struct3501.InvCnt = "20.25"
  14025. struct3501.Memo = ""
  14026. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14027. struct3501.FixmedinsHilistId = miConfig.Code
  14028. struct3501.FixmedinsHilistName = miConfig.OrgName
  14029. struct3501s = append(struct3501s, struct3501)
  14030. data["struct_3501s"] = struct3501s
  14031. client := &http.Client{}
  14032. bytesData, _ := json.Marshal(data)
  14033. var req *http.Request
  14034. if miConfig.MdtrtareaAdmvs == "320921" {
  14035. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14036. } else {
  14037. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14038. }
  14039. resp, _ := client.Do(req)
  14040. defer resp.Body.Close()
  14041. body, ioErr := ioutil.ReadAll(resp.Body)
  14042. if ioErr != nil {
  14043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14045. return
  14046. }
  14047. var respJSON map[string]interface{}
  14048. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14051. return
  14052. }
  14053. var res ResultSix
  14054. var resSix10265 ResultSix10265 //1101结果
  14055. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14056. result, _ := json.Marshal(respJSON)
  14057. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14058. utils.ErrorLog("解析失败:%v", err)
  14059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14060. return
  14061. }
  14062. res.InfRefmsgid = resSix10265.InfRefmsgid
  14063. res.Output = resSix10265.Output
  14064. res.ErrMsg = resSix10265.ErrMsg
  14065. res.Cainfo = resSix10265.Cainfo
  14066. res.WarnMsg = resSix10265.WarnMsg
  14067. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14068. res.Infcode = infocode
  14069. if infocode == 0 {
  14070. c.ServeSuccessJSON(map[string]interface{}{
  14071. "msg": "上传成功",
  14072. })
  14073. return
  14074. } else {
  14075. c.ServeSuccessJSON(map[string]interface{}{
  14076. "failed_code": -10,
  14077. "msg": res.ErrMsg,
  14078. })
  14079. return
  14080. }
  14081. }
  14082. func (c *HisApiController) Post3507() {
  14083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14084. data := make(map[string]interface{})
  14085. var struct3501s []models.Struct3501
  14086. var struct3501 models.Struct3501
  14087. struct3501.OrgName = miConfig.OrgName
  14088. struct3501.AccessKey = miConfig.AccessKey
  14089. struct3501.RequestUrl = miConfig.Url
  14090. struct3501.SecretKey = miConfig.SecretKey
  14091. struct3501.ManuDate = "2022-08-15"
  14092. struct3501.FixmedinsBchno = ""
  14093. struct3501.ManuLotnum = ""
  14094. struct3501.RxFlag = "0"
  14095. struct3501.ExpyEnd = "2022-08-15"
  14096. struct3501.Invdate = "2022-08-15"
  14097. struct3501.InvCnt = "20.25"
  14098. struct3501.Memo = ""
  14099. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14100. struct3501.FixmedinsHilistId = miConfig.Code
  14101. struct3501.FixmedinsHilistName = miConfig.OrgName
  14102. struct3501s = append(struct3501s, struct3501)
  14103. data["struct_3501s"] = struct3501s
  14104. client := &http.Client{}
  14105. bytesData, _ := json.Marshal(data)
  14106. var req *http.Request
  14107. if miConfig.MdtrtareaAdmvs == "320921" {
  14108. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14109. } else {
  14110. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14111. }
  14112. resp, _ := client.Do(req)
  14113. defer resp.Body.Close()
  14114. body, ioErr := ioutil.ReadAll(resp.Body)
  14115. if ioErr != nil {
  14116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14118. return
  14119. }
  14120. var respJSON map[string]interface{}
  14121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14124. return
  14125. }
  14126. var res ResultSix
  14127. var resSix10265 ResultSix10265 //1101结果
  14128. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14129. result, _ := json.Marshal(respJSON)
  14130. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14131. utils.ErrorLog("解析失败:%v", err)
  14132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14133. return
  14134. }
  14135. res.InfRefmsgid = resSix10265.InfRefmsgid
  14136. res.Output = resSix10265.Output
  14137. res.ErrMsg = resSix10265.ErrMsg
  14138. res.Cainfo = resSix10265.Cainfo
  14139. res.WarnMsg = resSix10265.WarnMsg
  14140. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14141. res.Infcode = infocode
  14142. if infocode == 0 {
  14143. c.ServeSuccessJSON(map[string]interface{}{
  14144. "msg": "上传成功",
  14145. })
  14146. return
  14147. } else {
  14148. c.ServeSuccessJSON(map[string]interface{}{
  14149. "failed_code": -10,
  14150. "msg": res.ErrMsg,
  14151. })
  14152. return
  14153. }
  14154. }