his_api_controller.go 627KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  94. }
  95. func (c *HisApiController) Get4201A() {
  96. order_id, _ := c.GetInt64("order_id")
  97. admin_user_id, _ := c.GetInt64("admin_user_id")
  98. order, _ := service.GetHisOrderByIDTwo(order_id)
  99. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  100. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  101. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  102. //order_info = append(order_info, order_info_two...)
  103. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. department, _ := service.GetDepartMentDetail(his.Departments)
  106. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  107. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  108. if order.ID == 0 {
  109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  110. return
  111. }
  112. var struct4201A models.Struct4201A
  113. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  114. for _, items := range order_info {
  115. memo := make(map[string]interface{})
  116. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  117. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  118. fsiOPFLD.MedType = "14"
  119. fsiOPFLD.BkkpSn = items.FeedetlSn
  120. fsiOPFLD.FixmedinsCode = miConfig.Code
  121. fsiOPFLD.FixmedinsName = miConfig.OrgName
  122. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  123. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  124. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  125. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  126. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  127. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  128. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  129. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  130. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  131. fsiOPFLD.BilgDeptName = department.Name
  132. fsiOPFLD.BilgDeptCodg = department.Number
  133. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  134. fsiOPFLD.BilgDrName = doctor.UserName
  135. fsiOPFLD.MedChrgitmType = "09"
  136. memo["hosp_appr_flag"] = "1"
  137. memo["invoice_no"] = order.MdtrtId
  138. memo["memo"] = "自费"
  139. bytesData, _ := json.Marshal(memo)
  140. fsiOPFLD.Memo = string(bytesData)
  141. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  142. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  143. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  144. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  145. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  146. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  147. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  148. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  149. fsiOPFLD.BilgDeptName = department.Name
  150. fsiOPFLD.BilgDeptCodg = department.Number
  151. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  152. fsiOPFLD.BilgDrName = doctor.UserName
  153. switch items.HisPrescriptionProject.HisProject.CostClassify {
  154. case 0:
  155. break
  156. case 1:
  157. fsiOPFLD.MedChrgitmType = "14"
  158. break
  159. case 2:
  160. fsiOPFLD.MedChrgitmType = "05"
  161. break
  162. case 3:
  163. fsiOPFLD.MedChrgitmType = "03"
  164. break
  165. case 4:
  166. fsiOPFLD.MedChrgitmType = "03"
  167. break
  168. case 5:
  169. fsiOPFLD.MedChrgitmType = "08"
  170. break
  171. case 6:
  172. fsiOPFLD.MedChrgitmType = "14"
  173. break
  174. case 7:
  175. fsiOPFLD.MedChrgitmType = "14"
  176. break
  177. case 8:
  178. fsiOPFLD.MedChrgitmType = "03"
  179. break
  180. case 9:
  181. fsiOPFLD.MedChrgitmType = "14"
  182. break
  183. case 10:
  184. fsiOPFLD.MedChrgitmType = "14"
  185. break
  186. case 11:
  187. fsiOPFLD.MedChrgitmType = "06"
  188. break
  189. case 12:
  190. fsiOPFLD.MedChrgitmType = "12"
  191. break
  192. case 13:
  193. fsiOPFLD.MedChrgitmType = "01"
  194. break
  195. case 14:
  196. fsiOPFLD.MedChrgitmType = "04"
  197. break
  198. case 15:
  199. fsiOPFLD.MedChrgitmType = "14"
  200. break
  201. }
  202. memo["hosp_appr_flag"] = "1"
  203. memo["invoice_no"] = order.MdtrtId
  204. memo["memo"] = "自费"
  205. bytesData, _ := json.Marshal(memo)
  206. fsiOPFLD.Memo = string(bytesData)
  207. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  208. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  209. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  210. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  211. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  212. fsiOPFLD.BilgDeptName = department.Name
  213. fsiOPFLD.BilgDeptCodg = department.Number
  214. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  215. fsiOPFLD.BilgDrName = doctor.UserName
  216. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  217. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  218. fsiOPFLD.MedChrgitmType = "08"
  219. memo["hosp_appr_flag"] = "1"
  220. memo["invoice_no"] = order.MdtrtId
  221. memo["memo"] = "自费"
  222. bytesData, _ := json.Marshal(memo)
  223. fsiOPFLD.Memo = string(bytesData)
  224. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  225. }
  226. }
  227. }
  228. for _, items := range order_info_two {
  229. memo := make(map[string]interface{})
  230. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  231. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  232. fsiOPFLD.MedType = "14"
  233. fsiOPFLD.BkkpSn = items.FeedetlSn
  234. fsiOPFLD.FixmedinsCode = miConfig.Code
  235. fsiOPFLD.FixmedinsName = miConfig.OrgName
  236. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  237. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  238. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  239. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  240. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  241. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  242. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  243. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  244. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  245. fsiOPFLD.BilgDeptName = department.Name
  246. fsiOPFLD.BilgDeptCodg = department.Number
  247. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  248. fsiOPFLD.BilgDrName = doctor.UserName
  249. fsiOPFLD.MedChrgitmType = "09"
  250. memo["hosp_appr_flag"] = "1"
  251. memo["invoice_no"] = order.MdtrtId
  252. memo["memo"] = "自费"
  253. bytesData, _ := json.Marshal(memo)
  254. fsiOPFLD.Memo = string(bytesData)
  255. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  256. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  257. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  258. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  259. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  260. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  261. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  262. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  263. fsiOPFLD.BilgDeptName = department.Name
  264. fsiOPFLD.BilgDeptCodg = department.Number
  265. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  266. fsiOPFLD.BilgDrName = doctor.UserName
  267. switch items.HisPrescriptionProject.HisProject.CostClassify {
  268. case 0:
  269. break
  270. case 1:
  271. fsiOPFLD.MedChrgitmType = "14"
  272. break
  273. case 2:
  274. fsiOPFLD.MedChrgitmType = "05"
  275. break
  276. case 3:
  277. fsiOPFLD.MedChrgitmType = "03"
  278. break
  279. case 4:
  280. fsiOPFLD.MedChrgitmType = "03"
  281. break
  282. case 5:
  283. fsiOPFLD.MedChrgitmType = "08"
  284. break
  285. case 6:
  286. fsiOPFLD.MedChrgitmType = "14"
  287. break
  288. case 7:
  289. fsiOPFLD.MedChrgitmType = "14"
  290. break
  291. case 8:
  292. fsiOPFLD.MedChrgitmType = "03"
  293. break
  294. case 9:
  295. fsiOPFLD.MedChrgitmType = "14"
  296. break
  297. case 10:
  298. fsiOPFLD.MedChrgitmType = "14"
  299. break
  300. case 11:
  301. fsiOPFLD.MedChrgitmType = "06"
  302. break
  303. case 12:
  304. fsiOPFLD.MedChrgitmType = "12"
  305. break
  306. case 13:
  307. fsiOPFLD.MedChrgitmType = "01"
  308. break
  309. case 14:
  310. fsiOPFLD.MedChrgitmType = "04"
  311. break
  312. case 15:
  313. fsiOPFLD.MedChrgitmType = "14"
  314. break
  315. }
  316. memo["hosp_appr_flag"] = "1"
  317. memo["invoice_no"] = order.MdtrtId
  318. memo["memo"] = "自费"
  319. bytesData, _ := json.Marshal(memo)
  320. fsiOPFLD.Memo = string(bytesData)
  321. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  322. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  323. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  324. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  325. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  326. fsiOPFLD.BilgDeptName = department.Name
  327. fsiOPFLD.BilgDeptCodg = department.Number
  328. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  329. fsiOPFLD.BilgDrName = doctor.UserName
  330. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  331. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  332. fsiOPFLD.MedChrgitmType = "08"
  333. memo["hosp_appr_flag"] = "1"
  334. memo["invoice_no"] = order.MdtrtId
  335. memo["memo"] = "自费"
  336. bytesData, _ := json.Marshal(memo)
  337. fsiOPFLD.Memo = string(bytesData)
  338. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  339. }
  340. }
  341. }
  342. fmt.Println(fsiOPFLDs)
  343. struct4201A.Fopfd = fsiOPFLDs
  344. fmt.Println(struct4201A.Fopfd)
  345. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  346. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  347. var res2 ResultSix
  348. var respJSON2 map[string]interface{}
  349. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  352. return
  353. }
  354. userJSONBytes2, _ := json.Marshal(respJSON2)
  355. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  356. utils.ErrorLog("解析失败:%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. if res2.Infcode != 0 {
  361. c.ServeSuccessJSON(map[string]interface{}{
  362. "failed_code": -10,
  363. "msg": res2.ErrMsg,
  364. })
  365. return
  366. } else {
  367. c.ServeSuccessJSON(map[string]interface{}{
  368. "msg": "上传成功",
  369. })
  370. }
  371. }
  372. func (c *HisApiController) Get4202() {
  373. order_id, _ := c.GetInt64("order_id")
  374. admin_user_id, _ := c.GetInt64("admin_user_id")
  375. order, _ := service.GetHisOrderByIDTwo(order_id)
  376. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  377. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  378. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  379. if order.ID == 0 {
  380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  381. return
  382. }
  383. var struct4202 models.Struct4202
  384. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  385. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  386. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  387. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  388. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  389. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  390. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  391. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  392. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  393. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  394. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  395. var config []*models.HisXtDiagnoseConfig
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := service.FindDiagnoseById(id)
  399. config = append(config, &diagnosisConfig)
  400. }
  401. var tempDiaginfos []models.OwnPayPatnDiagListD
  402. for index, item := range config {
  403. if index == 0 {
  404. var tempDiaginfo models.OwnPayPatnDiagListD
  405. tempDiaginfo.InoutDiagType = "1"
  406. tempDiaginfo.DiagCode = item.CountryCode
  407. tempDiaginfo.DiagName = item.CountryContentName
  408. tempDiaginfo.DiagType = "1"
  409. tempDiaginfo.DiagSrtNo = "1"
  410. tempDiaginfo.MaindiagFlag = "1"
  411. tempDiaginfo.ValiFlag = "1"
  412. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  413. } else {
  414. var tempDiaginfo models.OwnPayPatnDiagListD
  415. tempDiaginfo.DiagCode = item.CountryCode
  416. tempDiaginfo.DiagName = item.CountryContentName
  417. tempDiaginfo.DiagType = "2"
  418. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  419. tempDiaginfo.MaindiagFlag = "0"
  420. tempDiaginfo.ValiFlag = "1"
  421. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  422. }
  423. }
  424. struct4202.ODiagListD = tempDiaginfos
  425. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  426. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  427. var res2 ResultSix
  428. var respJSON2 map[string]interface{}
  429. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  432. return
  433. }
  434. userJSONBytes2, _ := json.Marshal(respJSON2)
  435. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  436. utils.ErrorLog("解析失败:%v", err)
  437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  438. return
  439. }
  440. if res2.Infcode != 0 {
  441. c.ServeSuccessJSON(map[string]interface{}{
  442. "failed_code": -10,
  443. "msg": res2.ErrMsg,
  444. })
  445. return
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "msg": "上传成功",
  449. })
  450. }
  451. }
  452. func (c *HisApiController) Get4203() {
  453. admin_user_id, _ := c.GetInt64("admin_user_id")
  454. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  455. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  456. order_id, _ := c.GetInt64("order_id")
  457. order, _ := service.GetHisOrderByIDTwo(order_id)
  458. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  459. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  460. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  461. var res2 ResultSix
  462. var respJSON2 map[string]interface{}
  463. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  466. return
  467. }
  468. userJSONBytes2, _ := json.Marshal(respJSON2)
  469. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  470. utils.ErrorLog("解析失败:%v", err)
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  472. return
  473. }
  474. if res2.Infcode != 0 {
  475. c.ServeSuccessJSON(map[string]interface{}{
  476. "failed_code": -10,
  477. "msg": res2.ErrMsg,
  478. })
  479. return
  480. } else {
  481. c.ServeSuccessJSON(map[string]interface{}{
  482. "msg": "上传成功",
  483. })
  484. }
  485. }
  486. func (c *HisApiController) Get4205() {
  487. order_id, _ := c.GetInt64("order_id")
  488. admin_user_id, _ := c.GetInt64("admin_user_id")
  489. order, _ := service.GetHisOrderByIDTwo(order_id)
  490. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  491. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  492. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  493. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  494. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  495. //order_info = append(order_info, order_info_two...)
  496. department, _ := service.GetDepartMentDetail(his.Departments)
  497. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  498. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  499. if order.ID == 0 {
  500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  501. return
  502. }
  503. var struct4201A models.Struct4201A
  504. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  505. for _, items := range order_info {
  506. memo := make(map[string]interface{})
  507. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  508. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  509. fsiOPFLD.MedType = "14"
  510. fsiOPFLD.BkkpSn = items.FeedetlSn
  511. fsiOPFLD.FixmedinsCode = miConfig.Code
  512. fsiOPFLD.FixmedinsName = miConfig.OrgName
  513. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  514. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  515. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  516. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  517. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  518. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  519. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  520. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  521. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  522. fsiOPFLD.BilgDeptName = department.Name
  523. fsiOPFLD.BilgDeptCodg = department.Number
  524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  525. fsiOPFLD.BilgDrName = doctor.UserName
  526. fsiOPFLD.MedChrgitmType = "09"
  527. memo["hosp_appr_flag"] = "1"
  528. memo["invoice_no"] = order.MdtrtId
  529. memo["memo"] = "自费"
  530. bytesData, _ := json.Marshal(memo)
  531. fsiOPFLD.Memo = string(bytesData)
  532. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  533. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  534. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  535. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  536. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  537. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  538. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  539. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  540. fsiOPFLD.BilgDeptName = department.Name
  541. fsiOPFLD.BilgDeptCodg = department.Number
  542. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  543. fsiOPFLD.BilgDrName = doctor.UserName
  544. switch items.HisPrescriptionProject.HisProject.CostClassify {
  545. case 0:
  546. break
  547. case 1:
  548. fsiOPFLD.MedChrgitmType = "14"
  549. break
  550. case 2:
  551. fsiOPFLD.MedChrgitmType = "05"
  552. break
  553. case 3:
  554. fsiOPFLD.MedChrgitmType = "03"
  555. break
  556. case 4:
  557. fsiOPFLD.MedChrgitmType = "03"
  558. break
  559. case 5:
  560. fsiOPFLD.MedChrgitmType = "08"
  561. break
  562. case 6:
  563. fsiOPFLD.MedChrgitmType = "14"
  564. break
  565. case 7:
  566. fsiOPFLD.MedChrgitmType = "14"
  567. break
  568. case 8:
  569. fsiOPFLD.MedChrgitmType = "03"
  570. break
  571. case 9:
  572. fsiOPFLD.MedChrgitmType = "14"
  573. break
  574. case 10:
  575. fsiOPFLD.MedChrgitmType = "14"
  576. break
  577. case 11:
  578. fsiOPFLD.MedChrgitmType = "06"
  579. break
  580. case 12:
  581. fsiOPFLD.MedChrgitmType = "12"
  582. break
  583. case 13:
  584. fsiOPFLD.MedChrgitmType = "01"
  585. break
  586. case 14:
  587. fsiOPFLD.MedChrgitmType = "04"
  588. break
  589. case 15:
  590. fsiOPFLD.MedChrgitmType = "14"
  591. break
  592. }
  593. memo["hosp_appr_flag"] = "1"
  594. memo["invoice_no"] = order.MdtrtId
  595. memo["memo"] = "自费"
  596. bytesData, _ := json.Marshal(memo)
  597. fsiOPFLD.Memo = string(bytesData)
  598. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  599. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  600. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  601. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  602. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  603. fsiOPFLD.BilgDeptName = department.Name
  604. fsiOPFLD.BilgDeptCodg = department.Number
  605. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  606. fsiOPFLD.BilgDrName = doctor.UserName
  607. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  608. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  609. fsiOPFLD.MedChrgitmType = "08"
  610. memo["hosp_appr_flag"] = "1"
  611. memo["invoice_no"] = order.MdtrtId
  612. memo["memo"] = "自费"
  613. bytesData, _ := json.Marshal(memo)
  614. fsiOPFLD.Memo = string(bytesData)
  615. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  616. }
  617. }
  618. }
  619. for _, items := range order_info_two {
  620. memo := make(map[string]interface{})
  621. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  622. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  623. fsiOPFLD.MedType = "14"
  624. fsiOPFLD.BkkpSn = items.FeedetlSn
  625. fsiOPFLD.FixmedinsCode = miConfig.Code
  626. fsiOPFLD.FixmedinsName = miConfig.OrgName
  627. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  628. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  629. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  630. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  631. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  632. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  633. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  634. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  635. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  636. fsiOPFLD.BilgDeptName = department.Name
  637. fsiOPFLD.BilgDeptCodg = department.Number
  638. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  639. fsiOPFLD.BilgDrName = doctor.UserName
  640. fsiOPFLD.MedChrgitmType = "09"
  641. memo["hosp_appr_flag"] = "1"
  642. memo["invoice_no"] = order.MdtrtId
  643. memo["memo"] = "自费"
  644. bytesData, _ := json.Marshal(memo)
  645. fsiOPFLD.Memo = string(bytesData)
  646. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  647. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  648. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  650. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  651. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  652. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  653. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  654. fsiOPFLD.BilgDeptName = department.Name
  655. fsiOPFLD.BilgDeptCodg = department.Number
  656. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  657. fsiOPFLD.BilgDrName = doctor.UserName
  658. switch items.HisPrescriptionProject.HisProject.CostClassify {
  659. case 0:
  660. break
  661. case 1:
  662. fsiOPFLD.MedChrgitmType = "14"
  663. break
  664. case 2:
  665. fsiOPFLD.MedChrgitmType = "05"
  666. break
  667. case 3:
  668. fsiOPFLD.MedChrgitmType = "03"
  669. break
  670. case 4:
  671. fsiOPFLD.MedChrgitmType = "03"
  672. break
  673. case 5:
  674. fsiOPFLD.MedChrgitmType = "08"
  675. break
  676. case 6:
  677. fsiOPFLD.MedChrgitmType = "14"
  678. break
  679. case 7:
  680. fsiOPFLD.MedChrgitmType = "14"
  681. break
  682. case 8:
  683. fsiOPFLD.MedChrgitmType = "03"
  684. break
  685. case 9:
  686. fsiOPFLD.MedChrgitmType = "14"
  687. break
  688. case 10:
  689. fsiOPFLD.MedChrgitmType = "14"
  690. break
  691. case 11:
  692. fsiOPFLD.MedChrgitmType = "06"
  693. break
  694. case 12:
  695. fsiOPFLD.MedChrgitmType = "12"
  696. break
  697. case 13:
  698. fsiOPFLD.MedChrgitmType = "01"
  699. break
  700. case 14:
  701. fsiOPFLD.MedChrgitmType = "04"
  702. break
  703. case 15:
  704. fsiOPFLD.MedChrgitmType = "14"
  705. break
  706. }
  707. memo["hosp_appr_flag"] = "1"
  708. memo["invoice_no"] = order.MdtrtId
  709. memo["memo"] = "自费"
  710. bytesData, _ := json.Marshal(memo)
  711. fsiOPFLD.Memo = string(bytesData)
  712. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  713. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  714. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  715. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  716. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  717. fsiOPFLD.BilgDeptName = department.Name
  718. fsiOPFLD.BilgDeptCodg = department.Number
  719. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  720. fsiOPFLD.BilgDrName = doctor.UserName
  721. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  722. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  723. fsiOPFLD.MedChrgitmType = "08"
  724. memo["hosp_appr_flag"] = "1"
  725. memo["invoice_no"] = order.MdtrtId
  726. memo["memo"] = "自费"
  727. bytesData, _ := json.Marshal(memo)
  728. fsiOPFLD.Memo = string(bytesData)
  729. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  730. }
  731. }
  732. }
  733. fmt.Println(fsiOPFLDs)
  734. struct4201A.Fopfd = fsiOPFLDs
  735. fmt.Println(struct4201A.Fopfd)
  736. var struct4202 models.Struct4202
  737. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  738. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  739. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  740. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  741. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  742. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  743. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  744. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  745. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  746. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  747. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  748. var config []*models.HisXtDiagnoseConfig
  749. for _, item := range diagnosis_ids {
  750. id, _ := strconv.ParseInt(item, 10, 64)
  751. diagnosisConfig, _ := service.FindDiagnoseById(id)
  752. config = append(config, &diagnosisConfig)
  753. }
  754. var tempDiaginfos []models.OwnPayPatnDiagListD
  755. for index, item := range config {
  756. if index == 0 {
  757. var tempDiaginfo models.OwnPayPatnDiagListD
  758. tempDiaginfo.InoutDiagType = "1"
  759. tempDiaginfo.DiagCode = item.CountryCode
  760. tempDiaginfo.DiagName = item.CountryContentName
  761. tempDiaginfo.DiagType = "1"
  762. tempDiaginfo.DiagSrtNo = "1"
  763. tempDiaginfo.MaindiagFlag = "1"
  764. tempDiaginfo.ValiFlag = "1"
  765. tempDiaginfo.DiagDrName = doctor.UserName
  766. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  767. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  768. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  769. } else {
  770. var tempDiaginfo models.OwnPayPatnDiagListD
  771. tempDiaginfo.DiagCode = item.CountryCode
  772. tempDiaginfo.DiagName = item.CountryContentName
  773. tempDiaginfo.DiagType = "2"
  774. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  775. tempDiaginfo.MaindiagFlag = "0"
  776. tempDiaginfo.ValiFlag = "1"
  777. tempDiaginfo.DiagDrName = doctor.UserName
  778. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  779. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  780. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  781. }
  782. }
  783. struct4202.ODiagListD = tempDiaginfos
  784. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  785. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  786. var res2 ResultSix
  787. var respJSON2 map[string]interface{}
  788. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  791. return
  792. }
  793. userJSONBytes2, _ := json.Marshal(respJSON2)
  794. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  795. utils.ErrorLog("解析失败:%v", err)
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  797. return
  798. }
  799. if res2.Infcode != 0 {
  800. c.ServeSuccessJSON(map[string]interface{}{
  801. "failed_code": -10,
  802. "msg": res2.ErrMsg,
  803. })
  804. return
  805. } else {
  806. c.ServeSuccessJSON(map[string]interface{}{
  807. "msg": "上传成功",
  808. })
  809. }
  810. }
  811. func (c *HisApiController) Get4207() {
  812. admin_user_id, _ := c.GetInt64("admin_user_id")
  813. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  814. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  815. order_id, _ := c.GetInt64("order_id")
  816. order, _ := service.GetHisOrderByIDTwo(order_id)
  817. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  818. var struct4207 models.Struct4207
  819. struct4207.PageNum = "1"
  820. struct4207.PageSize = "1000"
  821. struct4207.FixmedinsCode = miConfig.Code
  822. struct4207.FixmedinsMdtrtID = order.Number
  823. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  824. saveLog(result, requestLog, "4207", "查询")
  825. var res2 ResultSix
  826. var respJSON2 map[string]interface{}
  827. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. userJSONBytes2, _ := json.Marshal(respJSON2)
  833. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  834. utils.ErrorLog("解析失败:%v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return
  837. }
  838. if res2.Infcode != 0 {
  839. c.ServeSuccessJSON(map[string]interface{}{
  840. "failed_code": -10,
  841. "msg": res2.ErrMsg,
  842. })
  843. return
  844. } else {
  845. c.ServeSuccessJSON(map[string]interface{}{
  846. "msg": "查询成功",
  847. })
  848. }
  849. }
  850. func (c *HisApiController) Get4208() {
  851. admin_user_id, _ := c.GetInt64("admin_user_id")
  852. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  854. order_id, _ := c.GetInt64("order_id")
  855. order, _ := service.GetHisOrderByIDTwo(order_id)
  856. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  857. var struct4208 models.Struct4208
  858. struct4208.PageNum = "1"
  859. struct4208.PageSize = "1000"
  860. struct4208.PsnCertType = "01"
  861. struct4208.Certno = his.Certno
  862. struct4208.MedType = order.MedType
  863. struct4208.PsnName = his.Name
  864. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  865. saveLog(result, requestLog, "4208", "查询")
  866. var res2 ResultSix
  867. var respJSON2 map[string]interface{}
  868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  871. return
  872. }
  873. userJSONBytes2, _ := json.Marshal(respJSON2)
  874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  875. utils.ErrorLog("解析失败:%v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. if res2.Infcode != 0 {
  880. c.ServeSuccessJSON(map[string]interface{}{
  881. "failed_code": -10,
  882. "msg": res2.ErrMsg,
  883. })
  884. return
  885. } else {
  886. c.ServeSuccessJSON(map[string]interface{}{
  887. "msg": "查询成功",
  888. })
  889. }
  890. }
  891. func (c *HisApiController) Get4209() {
  892. admin_user_id, _ := c.GetInt64("admin_user_id")
  893. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  895. order_id, _ := c.GetInt64("order_id")
  896. order, _ := service.GetHisOrderByIDTwo(order_id)
  897. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  898. var struct4209 models.Struct4209
  899. struct4209.FixmedinsMdtrtID = order.Number
  900. struct4209.FixmedinsCode = miConfig.Code
  901. struct4209.PageSize = "1000"
  902. struct4209.PageNum = "1"
  903. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  904. saveLog(result, requestLog, "4209", "查询")
  905. var res2 ResultSix
  906. var respJSON2 map[string]interface{}
  907. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. userJSONBytes2, _ := json.Marshal(respJSON2)
  913. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  914. utils.ErrorLog("解析失败:%v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. if res2.Infcode != 0 {
  919. c.ServeSuccessJSON(map[string]interface{}{
  920. "failed_code": -10,
  921. "msg": res2.ErrMsg,
  922. })
  923. return
  924. } else {
  925. c.ServeSuccessJSON(map[string]interface{}{
  926. "msg": "查询成功",
  927. })
  928. }
  929. }
  930. type Result3101 struct {
  931. Infcode string `json:"infcode"`
  932. InfRefmsgid string `json:"inf_refmsgid"`
  933. RefmsgTime string `json:"refmsg_time"`
  934. RespondTime string `json:"respond_time"`
  935. Enctype string `json:"enctype"`
  936. Signtype string `json:"signtype"`
  937. ErrMsg string `json:"err_msg"`
  938. Output struct {
  939. Result []struct {
  940. JudgeResultDetailDtos []struct {
  941. VolaItemType string `json:"vola_item_type"`
  942. MdtrtID string `json:"mdtrt_id"`
  943. JrdID string `json:"jrd_id"`
  944. PatnID string `json:"patn_id"`
  945. RxID string `json:"rx_id"`
  946. VolaAmt interface{} `json:"vola_amt"`
  947. } `json:"judge_result_detail_dtos"`
  948. RuleID string `json:"rule_id"`
  949. VolaEvid string `json:"vola_evid"`
  950. MdtrtID string `json:"mdtrt_id"`
  951. RuleName string `json:"rule_name"`
  952. VolaAmtStas string `json:"vola_amt_stas"`
  953. JrID string `json:"jr_id"`
  954. PatnID string `json:"patn_id"`
  955. SevDeg string `json:"sev_deg"`
  956. VolaAmt float64 `json:"vola_amt"`
  957. VolaBhvrType string `json:"vola_bhvr_type"`
  958. VolaCont string `json:"vola_cont"`
  959. } `json:"result"`
  960. } `json:"output"`
  961. }
  962. func (c *HisApiController) ReadEleToken() {
  963. admin_user_id, _ := c.GetInt64("admin_user_id")
  964. his_patient_id, _ := c.GetInt64("his_patient_id")
  965. adminUser := c.GetAdminUserInfo()
  966. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  967. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  968. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  969. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  970. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  971. if len(tokens) > 0 {
  972. c.ServeSuccessJSON(map[string]interface{}{
  973. "msg": "读取成功",
  974. })
  975. } else {
  976. c.ServeSuccessJSON(map[string]interface{}{
  977. "failed_code": -10,
  978. "msg": "读取失败",
  979. })
  980. }
  981. } else if miConfig.MdtrtareaAdmvs == "350500" {
  982. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  983. if len(errMsg) == 0 {
  984. type ELeData struct {
  985. Data struct {
  986. IdNo string `json:"idNo"`
  987. IdType string `json:"idType"`
  988. UserName string `json:"userName"`
  989. EcToken string `json:"ecToken"`
  990. InsuOrg string `json:"insuOrg"`
  991. Gender string `json:"gender"`
  992. Birthday string `json:"birthday"`
  993. Nationality string `json:"nationality"`
  994. Email string `json:"email"`
  995. Extra string `json:"extra"`
  996. } `json:"data"`
  997. Code int `json:"code"`
  998. Message string `json:"message"`
  999. }
  1000. var ele ELeData
  1001. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1002. if err != nil {
  1003. utils.ErrorLog("解析失败:%v", err)
  1004. }
  1005. token := ele.Data.EcToken
  1006. if len(token) > 0 {
  1007. psn := &models.HisPsn{
  1008. PsnNo: his.PsnNo,
  1009. Age: 0,
  1010. PatientId: his.PatientId,
  1011. Certno: his.Certno,
  1012. Brdy: his.Brdy,
  1013. Gend: his.Gend,
  1014. Naty: his.Naty,
  1015. PsnCertType: his.PsnCertType,
  1016. PsnName: his.PsnName,
  1017. Idetinfo: his.Idetinfo,
  1018. Insuinfo: his.Iinfo,
  1019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1020. CardInfo: outPutInfo,
  1021. VerifyNumber: token,
  1022. }
  1023. service.CreateHisPsn(psn)
  1024. }
  1025. if len(token) > 0 {
  1026. c.ServeSuccessJSON(map[string]interface{}{
  1027. "msg": "读取成功",
  1028. })
  1029. } else {
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "failed_code": -10,
  1032. "msg": "读取失败",
  1033. })
  1034. }
  1035. }
  1036. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1037. if initFlag == 0 {
  1038. c.TestGetJiangXiBasBaseInit()
  1039. }
  1040. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1041. type ELeData struct {
  1042. Data struct {
  1043. IdNo string `json:"idNo"`
  1044. IdType string `json:"idType"`
  1045. UserName string `json:"userName"`
  1046. EcToken string `json:"ecToken"`
  1047. InsuOrg string `json:"insuOrg"`
  1048. Gender string `json:"gender"`
  1049. Birthday string `json:"birthday"`
  1050. Nationality string `json:"nationality"`
  1051. Email string `json:"email"`
  1052. Extra string `json:"extra"`
  1053. } `json:"data"`
  1054. Code int `json:"code"`
  1055. Message string `json:"message"`
  1056. }
  1057. var ele ELeData
  1058. err := json.Unmarshal([]byte(json_result), &ele)
  1059. if err != nil {
  1060. utils.ErrorLog("解析失败:%v", err)
  1061. }
  1062. token := ele.Data.EcToken
  1063. token = Remove0000(token)
  1064. fmt.Println(ele.Data.UserName)
  1065. 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)
  1066. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1067. var res ResultTwo
  1068. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1069. utils.ErrorLog("解析失败:%v", err)
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1071. return
  1072. }
  1073. if res.Infcode == 0 {
  1074. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1075. if err == gorm.ErrRecordNotFound {
  1076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1077. return
  1078. } else if err != nil {
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1080. return
  1081. } else {
  1082. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1083. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1084. infoStr := string(Iinfos)
  1085. idetinfoStr := string(Idetinfos)
  1086. psn := &models.HisPsn{
  1087. PsnNo: res.Output.Baseinfo.PsnNo,
  1088. Age: res.Output.Baseinfo.Age,
  1089. PatientId: patient.ID,
  1090. Certno: res.Output.Baseinfo.Certno,
  1091. Brdy: res.Output.Baseinfo.Brdy,
  1092. Gend: res.Output.Baseinfo.Gend,
  1093. Naty: res.Output.Baseinfo.Naty,
  1094. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1095. PsnName: res.Output.Baseinfo.PsnName,
  1096. Idetinfo: idetinfoStr,
  1097. Insuinfo: infoStr,
  1098. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1099. CardInfo: "",
  1100. VerifyNumber: token,
  1101. }
  1102. service.CreateHisPsn(psn)
  1103. c.ServeSuccessJSON(map[string]interface{}{
  1104. "patient": patient,
  1105. "number": token,
  1106. })
  1107. }
  1108. } else {
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1110. return
  1111. }
  1112. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1113. if initFlag == 0 {
  1114. c.TestGetJiangXiBasBaseInit()
  1115. }
  1116. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1117. type ELeData struct {
  1118. Data struct {
  1119. IdNo string `json:"idNo"`
  1120. IdType string `json:"idType"`
  1121. UserName string `json:"userName"`
  1122. EcToken string `json:"ecToken"`
  1123. InsuOrg string `json:"insuOrg"`
  1124. Gender string `json:"gender"`
  1125. Birthday string `json:"birthday"`
  1126. Nationality string `json:"nationality"`
  1127. Email string `json:"email"`
  1128. Extra string `json:"extra"`
  1129. } `json:"data"`
  1130. Code int `json:"code"`
  1131. Message string `json:"message"`
  1132. }
  1133. var ele ELeData
  1134. err := json.Unmarshal([]byte(json_result), &ele)
  1135. if err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. }
  1138. token := ele.Data.EcToken
  1139. token = Remove0000(token)
  1140. fmt.Println(ele.Data.UserName)
  1141. 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)
  1142. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1143. var res ResultTwo
  1144. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1145. utils.ErrorLog("解析失败:%v", err)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return
  1148. }
  1149. if res.Infcode == 0 {
  1150. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1151. if err == gorm.ErrRecordNotFound {
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1153. return
  1154. } else if err != nil {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1156. return
  1157. } else {
  1158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1160. infoStr := string(Iinfos)
  1161. idetinfoStr := string(Idetinfos)
  1162. psn := &models.HisPsn{
  1163. PsnNo: res.Output.Baseinfo.PsnNo,
  1164. Age: res.Output.Baseinfo.Age,
  1165. PatientId: patient.ID,
  1166. Certno: res.Output.Baseinfo.Certno,
  1167. Brdy: res.Output.Baseinfo.Brdy,
  1168. Gend: res.Output.Baseinfo.Gend,
  1169. Naty: res.Output.Baseinfo.Naty,
  1170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1171. PsnName: res.Output.Baseinfo.PsnName,
  1172. Idetinfo: idetinfoStr,
  1173. Insuinfo: infoStr,
  1174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1175. CardInfo: "",
  1176. VerifyNumber: token,
  1177. }
  1178. service.CreateHisPsn(psn)
  1179. c.ServeSuccessJSON(map[string]interface{}{
  1180. "patient": patient,
  1181. "number": token,
  1182. })
  1183. }
  1184. } else {
  1185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1186. return
  1187. }
  1188. } else {
  1189. if initFlag == 0 {
  1190. c.TestGetBasBaseInit()
  1191. }
  1192. token := c.GetEleBaseInfo()
  1193. token = Remove0000(token)
  1194. if len(token) > 0 {
  1195. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  1196. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1197. var res ResultTwo
  1198. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1199. utils.ErrorLog("解析失败:%v", err)
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1201. return
  1202. }
  1203. if res.Infcode == 0 {
  1204. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1205. if err == gorm.ErrRecordNotFound {
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1207. return
  1208. } else if err != nil {
  1209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1210. return
  1211. } else {
  1212. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1213. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1214. infoStr := string(Iinfos)
  1215. idetinfoStr := string(Idetinfos)
  1216. psn := &models.HisPsn{
  1217. PsnNo: res.Output.Baseinfo.PsnNo,
  1218. Age: res.Output.Baseinfo.Age,
  1219. PatientId: patient.ID,
  1220. Certno: res.Output.Baseinfo.Certno,
  1221. Brdy: res.Output.Baseinfo.Brdy,
  1222. Gend: res.Output.Baseinfo.Gend,
  1223. Naty: res.Output.Baseinfo.Naty,
  1224. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1225. PsnName: res.Output.Baseinfo.PsnName,
  1226. Idetinfo: idetinfoStr,
  1227. Insuinfo: infoStr,
  1228. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1229. CardInfo: "",
  1230. VerifyNumber: token,
  1231. }
  1232. service.CreateHisPsn(psn)
  1233. c.ServeSuccessJSON(map[string]interface{}{
  1234. "msg": "读取成功",
  1235. })
  1236. }
  1237. } else {
  1238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1239. return
  1240. }
  1241. } else {
  1242. c.ServeSuccessJSON(map[string]interface{}{
  1243. "failed_code": -10,
  1244. "msg": "读取失败",
  1245. })
  1246. }
  1247. }
  1248. }
  1249. func (c *HisApiController) Get9001() {
  1250. adminUser := c.GetAdminUserInfo()
  1251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1252. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. service.GetFjAuthorizationInfo(miConfig.Code)
  1255. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1256. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1257. var dat map[string]interface{}
  1258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1259. fmt.Println(dat)
  1260. } else {
  1261. fmt.Println(err)
  1262. }
  1263. userJSONBytes, _ := json.Marshal(dat)
  1264. var res models.Result9001
  1265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1266. utils.ErrorLog("解析失败:%v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. } else {
  1271. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1272. var dat map[string]interface{}
  1273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1274. fmt.Println(dat)
  1275. } else {
  1276. fmt.Println(err)
  1277. }
  1278. userJSONBytes, _ := json.Marshal(dat)
  1279. var res models.Result9001
  1280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1281. utils.ErrorLog("解析失败:%v", err)
  1282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1283. return
  1284. }
  1285. }
  1286. }
  1287. 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) {
  1288. var res Result3101
  1289. adminUser := c.GetAdminUserInfo()
  1290. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1291. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1293. //record_time := c.GetString("record_time")
  1294. //trig_scen := c.GetString("trig_scen")
  1295. timeLayout := "2006-01-02"
  1296. loc, _ := time.LoadLocation("Local")
  1297. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1298. if err != nil {
  1299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1300. return res
  1301. }
  1302. recordDateTime := theTime.Unix()
  1303. var patientPrescription models.HisPrescriptionInfo
  1304. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1305. //if patientPrescription.ID == 0 {
  1306. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1307. //}
  1308. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1309. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1310. //
  1311. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1312. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1313. var pp models.PublicParams
  1314. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1315. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1316. pp.FixmedinsName = miConfig.OrgName
  1317. pp.FixmedinsCode = miConfig.Code
  1318. pp.RequestUrl = miConfig.Url
  1319. pp.Cainfo = miConfig.Cainfo
  1320. pp.SecretKey = miConfig.SecretKey
  1321. pp.AccessKey = miConfig.AccessKey
  1322. pp.OpterName = roles.UserName
  1323. var config []*models.HisXtDiagnoseConfig
  1324. for _, item := range diagnosis_ids {
  1325. id, _ := strconv.ParseInt(item, 10, 64)
  1326. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1327. config = append(config, &diagnosisConfig)
  1328. }
  1329. var pd models.PatientDtos
  1330. pd.PatnID = his.PsnNo
  1331. pd.PatnName = his.Name
  1332. pd.Gend = his.Gend
  1333. pd.Brdy = his.Brdy
  1334. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1335. pd.CurrMdtrtID = his.Number
  1336. var fed models.FsiEncounterDtos
  1337. fed.MdtrtID = his.Number
  1338. fed.MedinsID = miConfig.Code
  1339. fed.MedinsName = miConfig.OrgName
  1340. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1341. fed.MedMdtrtType = "1"
  1342. fed.MedinsType = "1"
  1343. fed.MedinsLv = "11"
  1344. tm := time.Unix(his.RecordDate, 0)
  1345. s_tm := tm.Format("2006-01-02 15:04:05")
  1346. fed.AdmDate = s_tm
  1347. fed.DscgDate = s_tm
  1348. fed.DscgMainDiseCodg = config[0].CountryCode
  1349. fed.DscgMainDiseName = config[0].CountryContentName
  1350. //诊断信息
  1351. var fdds []*models.FsiDiagnoseDtos
  1352. for index, item := range config {
  1353. if index == 0 {
  1354. var fdd models.FsiDiagnoseDtos
  1355. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1356. fdd.InoutDiseType = "1"
  1357. fdd.MaindiseFlag = "1"
  1358. fdd.DiseDate = s_tm
  1359. fdd.DiasSrtNo = "1"
  1360. fdd.DiseName = item.CountryContentName
  1361. fdd.DiseCodg = item.CountryCode
  1362. fdds = append(fdds, &fdd)
  1363. } else {
  1364. var fdd models.FsiDiagnoseDtos
  1365. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1366. fdd.InoutDiseType = "1"
  1367. fdd.MaindiseFlag = "1"
  1368. fdd.DiseDate = s_tm
  1369. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1370. fdd.DiseName = item.CountryContentName
  1371. fdd.DiseCodg = item.CountryCode
  1372. fdds = append(fdds, &fdd)
  1373. }
  1374. }
  1375. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1376. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1377. fed.AdmDeptName = department.Name
  1378. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1379. fed.DscgDeptName = department.Name
  1380. fed.MedMdtrtType = "1"
  1381. fed.MedType = "11"
  1382. //if his.Insutype == "390" {
  1383. // fed.MedType = "1402"
  1384. //} else {
  1385. // fed.MedType = "9933"
  1386. //}
  1387. var orders []*models.FsiOrderDtos
  1388. if trig_scen == "2" {
  1389. //处方医嘱信息
  1390. for _, item := range prescriptions {
  1391. for _, subItem := range item.HisDoctorAdviceInfo {
  1392. var order models.FsiOrderDtos
  1393. order.RxID = strconv.FormatInt(item.ID, 10)
  1394. order.Rxno = strconv.FormatInt(item.ID, 10)
  1395. order.LongDrordFlag = "0"
  1396. order.HilistType = "1"
  1397. order.ChrgType = "1"
  1398. order.DrordBhvr = "-"
  1399. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1400. order.HosplistName = subItem.BaseDrugLib.DrugName
  1401. order.HilistLv = "1"
  1402. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1403. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1404. order.HosplistName = subItem.BaseDrugLib.DrugName
  1405. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1406. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1407. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1408. order.OwnpayAmt = ""
  1409. order.SelfpayAmt = ""
  1410. order.Spec = ""
  1411. order.SpecUnt = ""
  1412. order.DrordBegnDate = s_tm
  1413. order.DrordStopDate = ""
  1414. order.DrordDrCodg = "1"
  1415. order.DrordDeptName = department.Name
  1416. order.DrordDrCodg = "1"
  1417. order.DrordDrName = doctor_info.UserName
  1418. order.DrordDrProfttl = ""
  1419. order.CurrDrordFlag = "1"
  1420. orders = append(orders, &order)
  1421. }
  1422. for _, subItem := range item.HisPrescriptionProject {
  1423. if subItem.Type == 2 {
  1424. var order models.FsiOrderDtos
  1425. order.RxID = strconv.FormatInt(item.ID, 10)
  1426. order.Rxno = strconv.FormatInt(item.ID, 10)
  1427. order.LongDrordFlag = "0"
  1428. order.HilistType = "1"
  1429. order.ChrgType = "1"
  1430. order.DrordBhvr = "-"
  1431. order.HilistCode = subItem.HisProject.MedicalCode
  1432. order.HosplistName = subItem.HisProject.ProjectName
  1433. order.HilistLv = "1"
  1434. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1435. order.HosplistCode = subItem.HisProject.MedicalCode
  1436. order.HosplistName = subItem.HisProject.ProjectName
  1437. order.Cnt = subItem.Count
  1438. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1439. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1440. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1441. order.OwnpayAmt = ""
  1442. order.SelfpayAmt = ""
  1443. order.Spec = ""
  1444. order.SpecUnt = ""
  1445. order.DrordBegnDate = s_tm
  1446. order.DrordStopDate = ""
  1447. order.DrordDrCodg = "1"
  1448. order.DrordDeptName = department.Name
  1449. order.DrordDrCodg = "1"
  1450. order.DrordDrName = doctor_info.UserName
  1451. order.DrordDrProfttl = ""
  1452. order.CurrDrordFlag = "1"
  1453. orders = append(orders, &order)
  1454. }
  1455. if subItem.Type == 3 {
  1456. var order models.FsiOrderDtos
  1457. order.RxID = strconv.FormatInt(item.ID, 10)
  1458. order.Rxno = strconv.FormatInt(item.ID, 10)
  1459. order.LongDrordFlag = "0"
  1460. order.HilistType = "1"
  1461. order.ChrgType = "1"
  1462. order.DrordBhvr = "-"
  1463. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1464. order.HosplistName = subItem.GoodInfo.GoodName
  1465. order.HilistLv = "1"
  1466. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1467. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1468. order.HosplistName = subItem.GoodInfo.GoodName
  1469. order.Cnt = subItem.Count
  1470. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1471. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1472. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1473. order.OwnpayAmt = ""
  1474. order.SelfpayAmt = ""
  1475. order.Spec = ""
  1476. order.SpecUnt = ""
  1477. order.DrordBegnDate = s_tm
  1478. order.DrordStopDate = ""
  1479. order.DrordDrCodg = "1"
  1480. order.DrordDeptName = department.Name
  1481. order.DrordDrCodg = "1"
  1482. order.DrordDrName = doctor_info.UserName
  1483. order.DrordDrProfttl = ""
  1484. order.CurrDrordFlag = "1"
  1485. orders = append(orders, &order)
  1486. }
  1487. }
  1488. }
  1489. //处方医嘱信息
  1490. }
  1491. fed.MatnStas = "0"
  1492. fed.MedfeeSumamt = "0"
  1493. fed.OwnpayAmt = "0"
  1494. fed.SelfpayAmt = "0"
  1495. fed.AcctPayamt = "0"
  1496. fed.MaAmt = "0"
  1497. fed.HifpPayamt = "0"
  1498. fed.SetlTotlnum = "1"
  1499. fed.Insutype = his.Insutype
  1500. fed.ReimFlag = "0"
  1501. fed.OutSetlFlag = "0"
  1502. var fopd []*models.FsiOperationDtosData
  1503. data := make(map[string]interface{})
  1504. data["fed"] = fed
  1505. data["fdd"] = fdds
  1506. data["fod"] = orders
  1507. data["pd"] = pd
  1508. data["pp"] = pp
  1509. data["fopd"] = fopd
  1510. data["trig_scen"] = trig_scen
  1511. fmt.Println(data)
  1512. fmt.Println(fed)
  1513. fmt.Println(fdds)
  1514. fmt.Println(orders)
  1515. fmt.Println(pd)
  1516. fmt.Println(pp)
  1517. fmt.Println(fopd)
  1518. client := &http.Client{}
  1519. bytesData, _ := json.Marshal(data)
  1520. var req *http.Request
  1521. if miConfig.MdtrtareaAdmvs == "320921" {
  1522. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1523. } else {
  1524. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1525. }
  1526. resp, _ := client.Do(req)
  1527. defer resp.Body.Close()
  1528. body, ioErr := ioutil.ReadAll(resp.Body)
  1529. if ioErr != nil {
  1530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. return res
  1533. }
  1534. var respJSON map[string]interface{}
  1535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. return res
  1539. }
  1540. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1541. fmt.Println(respJSON)
  1542. result, _ := json.Marshal(respJSON)
  1543. fmt.Println(result)
  1544. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1545. utils.ErrorLog("解析失败:%v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return res
  1548. }
  1549. return res
  1550. }
  1551. 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) {
  1552. adminUser := c.GetAdminUserInfo()
  1553. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1554. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1556. //record_time := c.GetString("record_time")
  1557. //trig_scen := c.GetString("trig_scen")
  1558. timeLayout := "2006-01-02"
  1559. loc, _ := time.LoadLocation("Local")
  1560. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1561. if err != nil {
  1562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1563. return res
  1564. }
  1565. recordDateTime := theTime.Unix()
  1566. var patientPrescription models.HisPrescriptionInfo
  1567. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1568. if patientPrescription.ID == 0 {
  1569. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1570. }
  1571. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1572. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1573. //
  1574. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1575. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1576. var pp models.PublicParams
  1577. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1578. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1579. pp.FixmedinsName = miConfig.OrgName
  1580. pp.FixmedinsCode = miConfig.Code
  1581. pp.RequestUrl = miConfig.Url
  1582. pp.Cainfo = miConfig.Cainfo
  1583. pp.SecretKey = miConfig.SecretKey
  1584. pp.AccessKey = miConfig.AccessKey
  1585. pp.OpterName = roles.UserName
  1586. var config []*models.HisXtDiagnoseConfig
  1587. for _, item := range diagnosis_ids {
  1588. id, _ := strconv.ParseInt(item, 10, 64)
  1589. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1590. config = append(config, &diagnosisConfig)
  1591. }
  1592. var pd models.PatientDtos
  1593. pd.PatnID = his.PsnNo
  1594. pd.PatnName = his.Name
  1595. pd.Gend = his.Gend
  1596. pd.Brdy = his.Brdy
  1597. pd.Poolarea = his.InsuplcAdmdvs
  1598. pd.CurrMdtrtID = his.Number
  1599. var fed models.FsiEncounterDtos
  1600. fed.MdtrtID = his.Number
  1601. fed.MedinsID = miConfig.Code
  1602. fed.MedinsName = miConfig.OrgName
  1603. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1604. fed.MedMdtrtType = "1"
  1605. fed.MedinsType = "1"
  1606. fed.MedinsLv = "11"
  1607. tm := time.Unix(his.RecordDate, 0)
  1608. s_tm := tm.Format("2006-01-02 15:04:05")
  1609. fed.AdmDate = s_tm
  1610. fed.DscgDate = s_tm
  1611. fed.DscgMainDiseCodg = config[0].CountryCode
  1612. fed.DscgMainDiseName = config[0].CountryContentName
  1613. //诊断信息
  1614. var fdds []*models.FsiDiagnoseDtos
  1615. for index, item := range config {
  1616. if index == 0 {
  1617. var fdd models.FsiDiagnoseDtos
  1618. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1619. fdd.InoutDiseType = "1"
  1620. fdd.MaindiseFlag = "1"
  1621. fdd.DiseDate = s_tm
  1622. fdd.DiasSrtNo = "1"
  1623. fdd.DiseName = item.CountryContentName
  1624. fdd.DiseCodg = item.CountryCode
  1625. fdds = append(fdds, &fdd)
  1626. } else {
  1627. var fdd models.FsiDiagnoseDtos
  1628. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1629. fdd.InoutDiseType = "1"
  1630. fdd.MaindiseFlag = "1"
  1631. fdd.DiseDate = s_tm
  1632. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1633. fdd.DiseName = item.CountryContentName
  1634. fdd.DiseCodg = item.CountryCode
  1635. fdds = append(fdds, &fdd)
  1636. }
  1637. }
  1638. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1639. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1640. fed.AdmDeptName = department.Name
  1641. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1642. fed.DscgDeptName = department.Name
  1643. fed.MedMdtrtType = "1"
  1644. fed.MedType = "11"
  1645. //if his.Insutype == "390" {
  1646. // fed.MedType = "1402"
  1647. //} else {
  1648. // fed.MedType = "9933"
  1649. //}
  1650. var orders []*models.FsiOrderDtos
  1651. if trig_scen == "2" {
  1652. //处方医嘱信息
  1653. for _, item := range prescriptions {
  1654. for _, subItem := range item.HisDoctorAdviceInfo {
  1655. var order models.FsiOrderDtos
  1656. order.RxID = strconv.FormatInt(item.ID, 10)
  1657. order.Rxno = strconv.FormatInt(item.ID, 10)
  1658. order.LongDrordFlag = "0"
  1659. order.HilistType = "1"
  1660. order.ChrgType = "1"
  1661. order.DrordBhvr = "-"
  1662. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1663. order.HosplistName = subItem.BaseDrugLib.DrugName
  1664. order.HilistLv = "1"
  1665. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1666. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1667. order.HosplistName = subItem.BaseDrugLib.DrugName
  1668. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1669. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1670. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1671. order.OwnpayAmt = ""
  1672. order.SelfpayAmt = ""
  1673. order.Spec = ""
  1674. order.SpecUnt = ""
  1675. order.DrordBegnDate = s_tm
  1676. order.DrordStopDate = ""
  1677. order.DrordDrCodg = "1"
  1678. order.DrordDeptName = department.Name
  1679. order.DrordDrCodg = "1"
  1680. order.DrordDrName = doctor_info.UserName
  1681. order.DrordDrProfttl = ""
  1682. order.CurrDrordFlag = "1"
  1683. orders = append(orders, &order)
  1684. }
  1685. for _, subItem := range item.HisPrescriptionProject {
  1686. if subItem.Type == 2 {
  1687. var order models.FsiOrderDtos
  1688. order.RxID = strconv.FormatInt(item.ID, 10)
  1689. order.Rxno = strconv.FormatInt(item.ID, 10)
  1690. order.LongDrordFlag = "0"
  1691. order.HilistType = "1"
  1692. order.ChrgType = "1"
  1693. order.DrordBhvr = "-"
  1694. order.HilistCode = subItem.HisProject.MedicalCode
  1695. order.HosplistName = subItem.HisProject.ProjectName
  1696. order.HilistLv = "1"
  1697. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1698. order.HosplistCode = subItem.HisProject.MedicalCode
  1699. order.HosplistName = subItem.HisProject.ProjectName
  1700. order.Cnt = subItem.Count
  1701. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1702. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1703. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1704. order.OwnpayAmt = ""
  1705. order.SelfpayAmt = ""
  1706. order.Spec = ""
  1707. order.SpecUnt = ""
  1708. order.DrordBegnDate = s_tm
  1709. order.DrordStopDate = ""
  1710. order.DrordDrCodg = "1"
  1711. order.DrordDeptName = department.Name
  1712. order.DrordDrCodg = "1"
  1713. order.DrordDrName = doctor_info.UserName
  1714. order.DrordDrProfttl = ""
  1715. order.CurrDrordFlag = "1"
  1716. orders = append(orders, &order)
  1717. }
  1718. if subItem.Type == 3 {
  1719. var order models.FsiOrderDtos
  1720. order.RxID = strconv.FormatInt(item.ID, 10)
  1721. order.Rxno = strconv.FormatInt(item.ID, 10)
  1722. order.LongDrordFlag = "0"
  1723. order.HilistType = "1"
  1724. order.ChrgType = "1"
  1725. order.DrordBhvr = "-"
  1726. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1727. order.HosplistName = subItem.GoodInfo.GoodName
  1728. order.HilistLv = "1"
  1729. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1730. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1731. order.HosplistName = subItem.GoodInfo.GoodName
  1732. order.Cnt = subItem.Count
  1733. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1734. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1735. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1736. order.OwnpayAmt = ""
  1737. order.SelfpayAmt = ""
  1738. order.Spec = ""
  1739. order.SpecUnt = ""
  1740. order.DrordBegnDate = s_tm
  1741. order.DrordStopDate = ""
  1742. order.DrordDrCodg = "1"
  1743. order.DrordDeptName = department.Name
  1744. order.DrordDrCodg = "1"
  1745. order.DrordDrName = doctor_info.UserName
  1746. order.DrordDrProfttl = ""
  1747. order.CurrDrordFlag = "1"
  1748. orders = append(orders, &order)
  1749. }
  1750. }
  1751. }
  1752. //处方医嘱信息
  1753. }
  1754. fed.MatnStas = "0"
  1755. fed.MedfeeSumamt = "0"
  1756. fed.OwnpayAmt = "0"
  1757. fed.SelfpayAmt = "0"
  1758. fed.AcctPayamt = "0"
  1759. fed.MaAmt = "0"
  1760. fed.HifpPayamt = "0"
  1761. fed.SetlTotlnum = "1"
  1762. fed.Insutype = his.Insutype
  1763. fed.ReimFlag = "0"
  1764. fed.OutSetlFlag = "0"
  1765. var fopd []*models.FsiOperationDtosData
  1766. data := make(map[string]interface{})
  1767. data["fed"] = fed
  1768. data["fdd"] = fdds
  1769. data["fod"] = orders
  1770. data["pd"] = pd
  1771. data["pp"] = pp
  1772. data["fopd"] = fopd
  1773. data["trig_scen"] = trig_scen
  1774. fmt.Println(data)
  1775. fmt.Println(fed)
  1776. fmt.Println(fdds)
  1777. fmt.Println(orders)
  1778. fmt.Println(pd)
  1779. fmt.Println(pp)
  1780. fmt.Println(fopd)
  1781. client := &http.Client{}
  1782. bytesData, _ := json.Marshal(data)
  1783. var req *http.Request
  1784. if miConfig.MdtrtareaAdmvs == "320921" {
  1785. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1786. } else {
  1787. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1788. }
  1789. resp, _ := client.Do(req)
  1790. defer resp.Body.Close()
  1791. body, ioErr := ioutil.ReadAll(resp.Body)
  1792. if ioErr != nil {
  1793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1795. return res
  1796. }
  1797. var respJSON map[string]interface{}
  1798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1801. return res
  1802. }
  1803. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1804. result, _ := json.Marshal(respJSON)
  1805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1806. utils.ErrorLog("解析失败:%v", err)
  1807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1808. return res
  1809. }
  1810. return res
  1811. }
  1812. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1813. ////patient_id, _ := c.GetInt64("patient_id")
  1814. //order_id, _ := c.GetInt64("order_id")
  1815. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1816. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1817. //trig_scen := c.GetString("trig_scen")
  1818. adminUser := c.GetAdminUserInfo()
  1819. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1820. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1822. record_time := c.GetString("record_time")
  1823. order, _ := service.GetHisOrderByID(order_id)
  1824. timeLayout := "2006-01-02"
  1825. loc, _ := time.LoadLocation("Local")
  1826. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1827. if err != nil {
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1829. return
  1830. }
  1831. recordDateTime := theTime.Unix()
  1832. var patientPrescription models.HisPrescriptionInfo
  1833. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1834. if patientPrescription.ID == 0 {
  1835. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1836. }
  1837. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1838. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1839. //
  1840. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1841. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1842. var pp models.PublicParams
  1843. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1844. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1845. pp.FixmedinsName = miConfig.OrgName
  1846. pp.FixmedinsCode = miConfig.Code
  1847. pp.RequestUrl = miConfig.Url
  1848. pp.Cainfo = miConfig.Cainfo
  1849. pp.SecretKey = miConfig.SecretKey
  1850. pp.AccessKey = miConfig.AccessKey
  1851. pp.OpterName = roles.UserName
  1852. var config []*models.HisXtDiagnoseConfig
  1853. for _, item := range diagnosis_ids {
  1854. id, _ := strconv.ParseInt(item, 10, 64)
  1855. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1856. config = append(config, &diagnosisConfig)
  1857. }
  1858. var pd models.PatientDtos
  1859. pd.PatnID = his.PsnNo
  1860. pd.PatnName = his.Name
  1861. pd.Gend = his.Gend
  1862. pd.Brdy = his.Brdy
  1863. pd.Poolarea = his.InsuplcAdmdvs
  1864. pd.CurrMdtrtID = his.Number
  1865. var fed models.FsiEncounterDtos
  1866. fed.MdtrtID = his.Number
  1867. fed.MedinsID = miConfig.Code
  1868. fed.MedinsName = miConfig.OrgName
  1869. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1870. fed.MedMdtrtType = "1"
  1871. fed.MedinsType = "1"
  1872. fed.MedinsLv = "11"
  1873. tm := time.Unix(his.RecordDate, 0)
  1874. s_tm := tm.Format("2006-01-02 15:04:05")
  1875. fed.AdmDate = s_tm
  1876. fed.DscgDate = s_tm
  1877. fed.DscgMainDiseCodg = config[0].CountryCode
  1878. fed.DscgMainDiseName = config[0].CountryContentName
  1879. //诊断信息
  1880. var fdds []*models.FsiDiagnoseDtos
  1881. for index, item := range config {
  1882. if index == 0 {
  1883. var fdd models.FsiDiagnoseDtos
  1884. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1885. fdd.InoutDiseType = "1"
  1886. fdd.MaindiseFlag = "1"
  1887. fdd.DiseDate = s_tm
  1888. fdd.DiasSrtNo = "1"
  1889. fdd.DiseName = item.CountryContentName
  1890. fdd.DiseCodg = item.CountryCode
  1891. fdds = append(fdds, &fdd)
  1892. } else {
  1893. var fdd models.FsiDiagnoseDtos
  1894. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1895. fdd.InoutDiseType = "1"
  1896. fdd.MaindiseFlag = "1"
  1897. fdd.DiseDate = s_tm
  1898. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1899. fdd.DiseName = item.CountryContentName
  1900. fdd.DiseCodg = item.CountryCode
  1901. fdds = append(fdds, &fdd)
  1902. }
  1903. }
  1904. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1905. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1906. fed.AdmDeptName = department.Name
  1907. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1908. fed.DscgDeptName = department.Name
  1909. fed.MedType = order.MedType
  1910. //处方医嘱信息
  1911. var orders []*models.FsiOrderDtos
  1912. //for _, item := range prescriptions {
  1913. // for _, subItem := range item.HisDoctorAdviceInfo {
  1914. // var order models.FsiOrderDtos
  1915. // order.RxID = strconv.FormatInt(item.ID, 10)
  1916. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1917. // order.LongDrordFlag = "0"
  1918. // order.HilistType = "1"
  1919. // order.ChrgType = "1"
  1920. // order.DrordBhvr = "-"
  1921. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1922. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1923. // order.HilistLv = "1"
  1924. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1925. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1926. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1927. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1928. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1929. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1930. // order.OwnpayAmt = ""
  1931. // order.SelfpayAmt = ""
  1932. // order.Spec = ""
  1933. // order.SpecUnt = ""
  1934. // order.DrordBegnDate = s_tm
  1935. // order.DrordStopDate = ""
  1936. // order.DrordDrCodg = "1"
  1937. // order.DrordDeptName = department.Name
  1938. // order.DrordDrCodg = "1"
  1939. // order.DrordDrName = doctor_info.UserName
  1940. // order.DrordDrProfttl = ""
  1941. // order.CurrDrordFlag = "1"
  1942. // orders = append(orders, &order)
  1943. // }
  1944. // for _, subItem := range item.HisPrescriptionProject {
  1945. // if subItem.Type == 2 {
  1946. // var order models.FsiOrderDtos
  1947. // order.RxID = strconv.FormatInt(item.ID, 10)
  1948. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1949. // order.LongDrordFlag = "0"
  1950. // order.HilistType = "1"
  1951. // order.ChrgType = "1"
  1952. // order.DrordBhvr = "-"
  1953. // order.HilistCode = subItem.HisProject.MedicalCode
  1954. // order.HosplistName = subItem.HisProject.ProjectName
  1955. // order.HilistLv = "1"
  1956. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1957. // order.HosplistCode = subItem.HisProject.MedicalCode
  1958. // order.HosplistName = subItem.HisProject.ProjectName
  1959. // order.Cnt = subItem.Count
  1960. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1961. //
  1962. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1963. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1964. // order.OwnpayAmt = ""
  1965. // order.SelfpayAmt = ""
  1966. // order.Spec = ""
  1967. // order.SpecUnt = ""
  1968. // order.DrordBegnDate = s_tm
  1969. // order.DrordStopDate = ""
  1970. // order.DrordDrCodg = "1"
  1971. // order.DrordDeptName = department.Name
  1972. // order.DrordDrCodg = "1"
  1973. // order.DrordDrName = doctor_info.UserName
  1974. // order.DrordDrProfttl = ""
  1975. // order.CurrDrordFlag = "1"
  1976. // orders = append(orders, &order)
  1977. //
  1978. // }
  1979. // if subItem.Type == 3 {
  1980. //
  1981. // var order models.FsiOrderDtos
  1982. // order.RxID = strconv.FormatInt(item.ID, 10)
  1983. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1984. // order.LongDrordFlag = "0"
  1985. // order.HilistType = "1"
  1986. // order.ChrgType = "1"
  1987. // order.DrordBhvr = "-"
  1988. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1989. // order.HosplistName = subItem.GoodInfo.GoodName
  1990. // order.HilistLv = "1"
  1991. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1992. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1993. // order.HosplistName = subItem.GoodInfo.GoodName
  1994. // order.Cnt = subItem.Count
  1995. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1996. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1997. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1998. // order.OwnpayAmt = ""
  1999. // order.SelfpayAmt = ""
  2000. // order.Spec = ""
  2001. // order.SpecUnt = ""
  2002. // order.DrordBegnDate = s_tm
  2003. // order.DrordStopDate = ""
  2004. // order.DrordDrCodg = "1"
  2005. // order.DrordDeptName = department.Name
  2006. // order.DrordDrCodg = "1"
  2007. // order.DrordDrName = doctor_info.UserName
  2008. // order.DrordDrProfttl = ""
  2009. // order.CurrDrordFlag = "1"
  2010. // orders = append(orders, &order)
  2011. //
  2012. // }
  2013. // }
  2014. //}
  2015. for _, item := range prescriptions {
  2016. for _, subItem := range item.HisDoctorAdviceInfo {
  2017. var order models.FsiOrderDtos
  2018. order.RxID = strconv.FormatInt(item.ID, 10)
  2019. order.Rxno = strconv.FormatInt(item.ID, 10)
  2020. order.LongDrordFlag = "0"
  2021. order.HilistType = "1"
  2022. order.ChrgType = "1"
  2023. order.DrordBhvr = "-"
  2024. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2025. order.HosplistName = subItem.BaseDrugLib.DrugName
  2026. order.HilistLv = "1"
  2027. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2028. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2029. order.HosplistName = subItem.BaseDrugLib.DrugName
  2030. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2031. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2032. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2033. order.OwnpayAmt = ""
  2034. order.SelfpayAmt = ""
  2035. order.Spec = ""
  2036. order.SpecUnt = ""
  2037. order.DrordBegnDate = s_tm
  2038. order.DrordStopDate = ""
  2039. order.DrordDrCodg = "1"
  2040. order.DrordDeptName = department.Name
  2041. order.DrordDrCodg = "1"
  2042. order.DrordDrName = doctor_info.UserName
  2043. order.DrordDrProfttl = ""
  2044. order.CurrDrordFlag = "1"
  2045. orders = append(orders, &order)
  2046. }
  2047. for _, subItem := range item.HisPrescriptionProject {
  2048. if subItem.Type == 2 {
  2049. var order models.FsiOrderDtos
  2050. order.RxID = strconv.FormatInt(item.ID, 10)
  2051. order.Rxno = strconv.FormatInt(item.ID, 10)
  2052. order.LongDrordFlag = "0"
  2053. order.HilistType = "1"
  2054. order.ChrgType = "1"
  2055. order.DrordBhvr = "-"
  2056. order.HilistCode = subItem.HisProject.MedicalCode
  2057. order.HosplistName = subItem.HisProject.ProjectName
  2058. order.HilistLv = "1"
  2059. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2060. order.HosplistCode = subItem.HisProject.MedicalCode
  2061. order.HosplistName = subItem.HisProject.ProjectName
  2062. order.Cnt = subItem.Count
  2063. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2064. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2065. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2066. order.OwnpayAmt = ""
  2067. order.SelfpayAmt = ""
  2068. order.Spec = ""
  2069. order.SpecUnt = ""
  2070. order.DrordBegnDate = s_tm
  2071. order.DrordStopDate = ""
  2072. order.DrordDrCodg = "1"
  2073. order.DrordDeptName = department.Name
  2074. order.DrordDrCodg = "1"
  2075. order.DrordDrName = doctor_info.UserName
  2076. order.DrordDrProfttl = ""
  2077. order.CurrDrordFlag = "1"
  2078. orders = append(orders, &order)
  2079. }
  2080. if subItem.Type == 3 {
  2081. var order models.FsiOrderDtos
  2082. order.RxID = strconv.FormatInt(item.ID, 10)
  2083. order.Rxno = strconv.FormatInt(item.ID, 10)
  2084. order.LongDrordFlag = "0"
  2085. order.HilistType = "1"
  2086. order.ChrgType = "1"
  2087. order.DrordBhvr = "-"
  2088. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2089. order.HosplistName = subItem.GoodInfo.GoodName
  2090. order.HilistLv = "1"
  2091. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2092. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2093. order.HosplistName = subItem.GoodInfo.GoodName
  2094. order.Cnt = subItem.Count
  2095. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2096. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2097. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2098. order.OwnpayAmt = ""
  2099. order.SelfpayAmt = ""
  2100. order.Spec = ""
  2101. order.SpecUnt = ""
  2102. order.DrordBegnDate = s_tm
  2103. order.DrordStopDate = ""
  2104. order.DrordDrCodg = "1"
  2105. order.DrordDeptName = department.Name
  2106. order.DrordDrCodg = "1"
  2107. order.DrordDrName = doctor_info.UserName
  2108. order.DrordDrProfttl = ""
  2109. order.CurrDrordFlag = "1"
  2110. orders = append(orders, &order)
  2111. }
  2112. }
  2113. }
  2114. //处方医嘱信息
  2115. fed.MatnStas = "0"
  2116. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2117. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2118. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2119. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2120. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2121. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2122. fed.SetlTotlnum = "1"
  2123. fed.Insutype = his.Insutype
  2124. fed.ReimFlag = "0"
  2125. fed.OutSetlFlag = "0"
  2126. var fopd []*models.FsiOperationDtosData
  2127. data := make(map[string]interface{})
  2128. data["fed"] = fed
  2129. data["fdd"] = fdds
  2130. data["fod"] = orders
  2131. data["pd"] = pd
  2132. data["pp"] = pp
  2133. data["fopd"] = fopd
  2134. data["trig_scen"] = trig_scen
  2135. client := &http.Client{}
  2136. bytesData, _ := json.Marshal(data)
  2137. var req *http.Request
  2138. if miConfig.MdtrtareaAdmvs == "320921" {
  2139. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2140. } else {
  2141. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2142. }
  2143. resp, _ := client.Do(req)
  2144. defer resp.Body.Close()
  2145. body, ioErr := ioutil.ReadAll(resp.Body)
  2146. if ioErr != nil {
  2147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2149. return res
  2150. }
  2151. var respJSON map[string]interface{}
  2152. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2155. return res
  2156. }
  2157. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2158. result, _ := json.Marshal(respJSON)
  2159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2160. utils.ErrorLog("解析失败:%v", err)
  2161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2162. return res
  2163. }
  2164. return res
  2165. //手术操作集合
  2166. //手术操作集合
  2167. }
  2168. func (c *HisApiController) Check() {
  2169. psn_no := c.GetString("psn_no")
  2170. in := c.GetString("in")
  2171. mt := c.GetString("mt")
  2172. baseParams := models.BaseParams{
  2173. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2174. FixmedinsCode: "H15049901371",
  2175. InsuplcAdmdvs: "150499",
  2176. MdtrtareaAdmvs: "150499",
  2177. OrgName: "赤峰费森血液透析中心",
  2178. Doctor: "1111",
  2179. }
  2180. service.Gdyb2001(baseParams, psn_no, in, mt)
  2181. }
  2182. func (c *HisApiController) GetPsnNcdsInfo() {
  2183. admin_user_id, _ := c.GetInt64("admin_user_id")
  2184. patient_id, _ := c.GetInt64("patient_id")
  2185. id, _ := c.GetInt64("id")
  2186. adminUser := c.GetAdminUserInfo()
  2187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2188. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2189. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2190. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2191. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2192. //
  2193. //if psn_record.ID == 0 {
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2195. // return
  2196. //}
  2197. var res Result5301
  2198. var res10265 Result5301For10265
  2199. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2200. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2201. var api string
  2202. if miConfig.MdtrtareaAdmvs == "320921" {
  2203. 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 +
  2204. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2205. } else {
  2206. 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 +
  2207. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2208. }
  2209. resp, requestErr := http.Get(api)
  2210. if requestErr != nil {
  2211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2212. return
  2213. }
  2214. body, ioErr := ioutil.ReadAll(resp.Body)
  2215. if ioErr != nil {
  2216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2218. return
  2219. }
  2220. var respJSON map[string]interface{}
  2221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. return
  2225. }
  2226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2227. result, _ := json.Marshal(respJSON)
  2228. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2229. utils.ErrorLog("解析失败:%v", err)
  2230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2231. return
  2232. }
  2233. res.ErrMsg = res10265.ErrMsg
  2234. res.Output = res10265.Output
  2235. res.InfRefmsgid = res10265.InfRefmsgid
  2236. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2237. res.Infcode = infocode
  2238. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2239. p, _ := service.GetHisPatientById(patient_id)
  2240. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2241. var dat map[string]interface{}
  2242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2243. fmt.Println(dat)
  2244. } else {
  2245. fmt.Println(err)
  2246. }
  2247. userJSONBytes, _ := json.Marshal(dat)
  2248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2249. utils.ErrorLog("解析失败:%v", err)
  2250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. return
  2252. }
  2253. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2254. p, _ := service.GetHisPatientById(patient_id)
  2255. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2256. var dat map[string]interface{}
  2257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2258. fmt.Println(dat)
  2259. } else {
  2260. fmt.Println(err)
  2261. }
  2262. userJSONBytes, _ := json.Marshal(dat)
  2263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2264. utils.ErrorLog("解析失败:%v", err)
  2265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2266. return
  2267. }
  2268. } else {
  2269. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2270. var dat map[string]interface{}
  2271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2272. fmt.Println(dat)
  2273. } else {
  2274. fmt.Println(err)
  2275. }
  2276. userJSONBytes, _ := json.Marshal(dat)
  2277. if miConfig.Code == "H15049901371" {
  2278. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2279. utils.ErrorLog("解析失败:%v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. res.InfRefmsgid = res10265.InfRefmsgid
  2284. res.Output = res10265.Output
  2285. res.ErrMsg = res10265.ErrMsg
  2286. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2287. res.Infcode = infocode
  2288. } else {
  2289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2290. utils.ErrorLog("解析失败:%v", err)
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2292. return
  2293. }
  2294. }
  2295. }
  2296. if res.Infcode == 0 {
  2297. c.ServeSuccessJSON(map[string]interface{}{
  2298. "result": res.Output.Result,
  2299. })
  2300. }
  2301. }
  2302. func (c *HisApiController) CheckInsutype() {
  2303. his_patient_id, _ := c.GetInt64("his_patient_id")
  2304. admin_user_id, _ := c.GetInt64("admin_user_id")
  2305. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2306. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2308. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2309. var dat map[string]interface{}
  2310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2311. fmt.Println(dat)
  2312. } else {
  2313. fmt.Println(err)
  2314. }
  2315. userJSONBytes, _ := json.Marshal(dat)
  2316. var res Result90100
  2317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2318. utils.ErrorLog("解析失败:%v", err)
  2319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2320. return
  2321. }
  2322. if res.Infcode != 0 {
  2323. c.ServeSuccessJSON(map[string]interface{}{
  2324. "failed_code": -10,
  2325. "msg": res.ErrMsg,
  2326. })
  2327. return
  2328. } else {
  2329. fmt.Println(res)
  2330. }
  2331. }
  2332. func (c *HisApiController) CheckCardPWD() {
  2333. card_pwd := c.GetString("card_pwd")
  2334. his_patient_id, _ := c.GetInt64("his_patient_id")
  2335. admin_user_id, _ := c.GetInt64("admin_user_id")
  2336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2338. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2339. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2340. bas := strings.Split(psn.CardInfo, "|")
  2341. basNumber := bas[2]
  2342. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2343. var dat map[string]interface{}
  2344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2345. fmt.Println(dat)
  2346. } else {
  2347. fmt.Println(err)
  2348. }
  2349. userJSONBytes, _ := json.Marshal(dat)
  2350. var res Result90991
  2351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2352. utils.ErrorLog("解析失败:%v", err)
  2353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. return
  2355. }
  2356. if res.Infcode != 0 {
  2357. c.ServeSuccessJSON(map[string]interface{}{
  2358. "failed_code": -10,
  2359. "msg": res.ErrMsg,
  2360. })
  2361. return
  2362. } else {
  2363. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2364. var msg string
  2365. switch res.Output.Result.CardStat {
  2366. case "00":
  2367. msg = "未激活"
  2368. break
  2369. case "10":
  2370. msg = "激活"
  2371. break
  2372. case "20":
  2373. msg = "窗口挂失"
  2374. break
  2375. case "21":
  2376. msg = "电话挂失"
  2377. break
  2378. case "22":
  2379. msg = "单位网上申报挂失"
  2380. break
  2381. case "23":
  2382. msg = "保健办挂失"
  2383. break
  2384. case "24":
  2385. msg = "个人网上挂失"
  2386. break
  2387. case "25":
  2388. msg = "网上服务大厅挂失"
  2389. break
  2390. case "30":
  2391. msg = "注销"
  2392. break
  2393. case "40":
  2394. msg = "回收"
  2395. break
  2396. case "99":
  2397. msg = "制卡中(无效卡)"
  2398. break
  2399. }
  2400. c.ServeSuccessJSON(map[string]interface{}{
  2401. "failed_code": -10,
  2402. "msg": msg,
  2403. })
  2404. return
  2405. } else {
  2406. c.ServeSuccessJSON(map[string]interface{}{
  2407. "msg": "校验成功",
  2408. })
  2409. return
  2410. }
  2411. }
  2412. }
  2413. func (c *HisApiController) CheckCardPWDTwo() {
  2414. //card_pwd := c.GetString("card_pwd")
  2415. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2416. admin_user_id, _ := c.GetInt64("admin_user_id")
  2417. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2419. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2420. var dat map[string]interface{}
  2421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2422. fmt.Println(dat)
  2423. } else {
  2424. fmt.Println(err)
  2425. }
  2426. userJSONBytes, _ := json.Marshal(dat)
  2427. var res Result90991
  2428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2429. utils.ErrorLog("解析失败:%v", err)
  2430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2431. return
  2432. }
  2433. if res.Infcode != 0 {
  2434. c.ServeSuccessJSON(map[string]interface{}{
  2435. "failed_code": -10,
  2436. "msg": res.ErrMsg,
  2437. })
  2438. return
  2439. } else {
  2440. if res.Output.Result.SscnoCheckStat == "0" {
  2441. var msg string
  2442. switch res.Output.Result.CardStat {
  2443. case "00":
  2444. msg = "未激活"
  2445. break
  2446. case "10":
  2447. msg = "激活"
  2448. break
  2449. case "20":
  2450. msg = "窗口挂失"
  2451. break
  2452. case "21":
  2453. msg = "电话挂失"
  2454. break
  2455. case "22":
  2456. msg = "单位网上申报挂失"
  2457. break
  2458. case "23":
  2459. msg = "保健办挂失"
  2460. break
  2461. case "24":
  2462. msg = "个人网上挂失"
  2463. break
  2464. case "25":
  2465. msg = "网上服务大厅挂失"
  2466. break
  2467. case "30":
  2468. msg = "注销"
  2469. break
  2470. case "40":
  2471. msg = "回收"
  2472. break
  2473. case "99":
  2474. msg = "制卡中(无效卡)"
  2475. break
  2476. }
  2477. c.ServeSuccessJSON(map[string]interface{}{
  2478. "failed_code": -10,
  2479. "msg": msg,
  2480. })
  2481. return
  2482. } else {
  2483. c.ServeSuccessJSON(map[string]interface{}{
  2484. "msg": "校验成功",
  2485. })
  2486. return
  2487. }
  2488. }
  2489. }
  2490. type ELeCertData struct {
  2491. Data struct {
  2492. Extra string `json:"extra"`
  2493. IDNo string `json:"idNo"`
  2494. IDType string `json:"idType"`
  2495. EcToken string `json:"ecToken"`
  2496. InsuOrg string `json:"insuOrg"`
  2497. UserName string `json:"userName"`
  2498. EcIndexNo string `json:"ecIndexNo"`
  2499. Gender string `json:"gender"`
  2500. Birthday string `json:"birthday"`
  2501. Nationality string `json:"nationality"`
  2502. Email string `json:"email"`
  2503. } `json:"OutData"`
  2504. }
  2505. func (c *HisApiController) ReadCard() {
  2506. id_card_type, _ := c.GetInt64("id_card_type")
  2507. admin_user_id, _ := c.GetInt64("admin_user_id")
  2508. certificates, _ := c.GetInt64("certificates")
  2509. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2511. switch id_card_type {
  2512. case 1:
  2513. if miConfig.MdtrtareaAdmvs == "421300" {
  2514. var res ResultTwo
  2515. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2516. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2517. "&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)
  2518. resp, requestErr := http.Get(api)
  2519. if requestErr != nil {
  2520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2521. return
  2522. }
  2523. body, ioErr := ioutil.ReadAll(resp.Body)
  2524. if ioErr != nil {
  2525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2527. return
  2528. }
  2529. var respJSON map[string]interface{}
  2530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. return
  2534. }
  2535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2536. result, _ := json.Marshal(respJSON)
  2537. fmt.Println("log")
  2538. fmt.Println(string(result))
  2539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2540. utils.ErrorLog("解析失败:%v", err)
  2541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. return
  2543. }
  2544. if res.Infcode == 0 {
  2545. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2546. if err == gorm.ErrRecordNotFound {
  2547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2548. return
  2549. } else if err != nil {
  2550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2551. return
  2552. } else {
  2553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2555. infoStr := string(Iinfos)
  2556. idetinfoStr := string(Idetinfos)
  2557. psn := &models.HisPsn{
  2558. PsnNo: res.Output.Baseinfo.PsnNo,
  2559. Age: res.Output.Baseinfo.Age,
  2560. PatientId: patient.ID,
  2561. Certno: res.Output.Baseinfo.Certno,
  2562. Brdy: res.Output.Baseinfo.Brdy,
  2563. Gend: res.Output.Baseinfo.Gend,
  2564. Naty: res.Output.Baseinfo.Naty,
  2565. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2566. PsnName: res.Output.Baseinfo.PsnName,
  2567. Idetinfo: idetinfoStr,
  2568. Insuinfo: infoStr,
  2569. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2570. }
  2571. service.CreateHisPsn(psn)
  2572. c.ServeSuccessJSON(map[string]interface{}{
  2573. "patient": patient,
  2574. "number": res.Output.Baseinfo.Certno,
  2575. })
  2576. }
  2577. } else {
  2578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2579. return
  2580. }
  2581. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2582. var api string
  2583. if miConfig.MdtrtareaAdmvs == "320921" {
  2584. 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 +
  2585. "&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
  2586. fmt.Println(api)
  2587. } else {
  2588. 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 +
  2589. "&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)
  2590. }
  2591. resp, requestErr := http.Get(api)
  2592. if requestErr != nil {
  2593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2594. return
  2595. }
  2596. body, ioErr := ioutil.ReadAll(resp.Body)
  2597. if ioErr != nil {
  2598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. return
  2601. }
  2602. var respJSON map[string]interface{}
  2603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2606. return
  2607. }
  2608. var status string
  2609. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2610. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2611. //console.log()
  2612. fmt.Println("type===")
  2613. fmt.Println(card_type)
  2614. var token string
  2615. var res ResultTwo //1101结果
  2616. var res10265 ResultTwo10265 //1101结果
  2617. var card_info string //卡信息
  2618. var busi_card_info string
  2619. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2620. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2621. if status == "0" { //读卡成功
  2622. if card_type == "1" {
  2623. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.ErrMsg = res10265.ErrMsg
  2631. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2632. res.Infcode = infocode
  2633. res.Output = res10265.Output
  2634. res.InfRefmsgid = res10265.InfRefmsgid
  2635. } else {
  2636. //var card_info string //卡信息
  2637. //var busi_card_info string
  2638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2639. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2640. //fmt.Println(card_info)
  2641. //fmt.Println(busi_card_info)
  2642. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2643. result, _ := json.Marshal(respJSON)
  2644. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2645. utils.ErrorLog("解析失败:%v", err)
  2646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2647. return
  2648. }
  2649. res.ErrMsg = res10265.ErrMsg
  2650. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2651. res.Infcode = infocode
  2652. res.Output = res10265.Output
  2653. res.InfRefmsgid = res10265.InfRefmsgid
  2654. }
  2655. if res.Infcode == 0 {
  2656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2657. if err == gorm.ErrRecordNotFound {
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2659. return
  2660. } else if err != nil {
  2661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2662. return
  2663. } else {
  2664. if card_type == "1" {
  2665. bas := strings.Split(card_info, "|")
  2666. basNumber := bas[2]
  2667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2669. infoStr := string(Iinfos)
  2670. idetinfoStr := string(Idetinfos)
  2671. psn := &models.HisPsn{
  2672. PsnNo: res.Output.Baseinfo.PsnNo,
  2673. Age: res.Output.Baseinfo.Age,
  2674. PatientId: patient.ID,
  2675. Certno: res.Output.Baseinfo.Certno,
  2676. Brdy: res.Output.Baseinfo.Brdy,
  2677. Gend: res.Output.Baseinfo.Gend,
  2678. Naty: res.Output.Baseinfo.Naty,
  2679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2680. PsnName: res.Output.Baseinfo.PsnName,
  2681. Idetinfo: idetinfoStr,
  2682. Insuinfo: infoStr,
  2683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2684. CardInfo: card_info,
  2685. VerifyNumber: busi_card_info,
  2686. }
  2687. service.CreateHisPsn(psn)
  2688. var rf []*ResultFive
  2689. json.Unmarshal([]byte(infoStr), &rf)
  2690. var insutypes []*ResultFive
  2691. var insutype string
  2692. var is390 int = 0
  2693. var is310 int = 0
  2694. for _, item := range rf {
  2695. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2696. insutypes = append(insutypes, item)
  2697. }
  2698. }
  2699. if len(insutypes) == 1 {
  2700. insutype = insutypes[0].Insutype
  2701. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2702. } else {
  2703. for _, i := range insutypes {
  2704. if i.Insutype == "390" {
  2705. is390 = 1
  2706. }
  2707. if i.Insutype == "310" {
  2708. is310 = 1
  2709. }
  2710. }
  2711. }
  2712. if is390 == 1 {
  2713. insutype = "390"
  2714. }
  2715. if is310 == 1 {
  2716. insutype = "310"
  2717. }
  2718. if len(insutypes) == 0 {
  2719. insutype = "310"
  2720. }
  2721. c.ServeSuccessJSON(map[string]interface{}{
  2722. "patient": patient,
  2723. "number": basNumber,
  2724. "insutype": insutype,
  2725. })
  2726. } else {
  2727. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2728. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2729. infoStr := string(Iinfos)
  2730. idetinfoStr := string(Idetinfos)
  2731. psn := &models.HisPsn{
  2732. PsnNo: res.Output.Baseinfo.PsnNo,
  2733. Age: res.Output.Baseinfo.Age,
  2734. PatientId: patient.ID,
  2735. Certno: res.Output.Baseinfo.Certno,
  2736. Brdy: res.Output.Baseinfo.Brdy,
  2737. Gend: res.Output.Baseinfo.Gend,
  2738. Naty: res.Output.Baseinfo.Naty,
  2739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2740. PsnName: res.Output.Baseinfo.PsnName,
  2741. Idetinfo: idetinfoStr,
  2742. Insuinfo: infoStr,
  2743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2744. CardInfo: card_info,
  2745. VerifyNumber: token,
  2746. }
  2747. service.CreateHisPsn(psn)
  2748. c.ServeSuccessJSON(map[string]interface{}{
  2749. "patient": patient,
  2750. "number": token,
  2751. })
  2752. }
  2753. }
  2754. } else {
  2755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2756. return
  2757. }
  2758. } else { //读卡失败
  2759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2760. return
  2761. }
  2762. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2763. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2764. cardnum = DeleteExtraSpaceTwo(cardnum)
  2765. cardCode = DeleteExtraSpaceTwo(cardCode)
  2766. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2767. name = DeleteExtraSpaceTwo(name)
  2768. errmsg = DeleteExtraSpaceTwo(errmsg)
  2769. cardnum = Remove0000(cardnum)
  2770. cardCode = Remove0000(cardCode)
  2771. id_card_no = Remove0000(id_card_no)
  2772. name = Remove0000(name)
  2773. errmsg = Remove0000(errmsg)
  2774. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  2775. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2776. 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, patient.Name)
  2777. saveLog(result, requestLog, "1101", "获取人员信息")
  2778. fmt.Println(errMsgLog)
  2779. if len(errMsgLog) > 0 {
  2780. } else {
  2781. var dat map[string]interface{}
  2782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2783. fmt.Println(dat)
  2784. } else {
  2785. fmt.Println(err)
  2786. }
  2787. userJSONBytes, _ := json.Marshal(dat)
  2788. var res ResultTwo
  2789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2790. utils.ErrorLog("解析失败:%v", err)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. res.ErrMsg = errMsgLog
  2795. if res.Infcode == 0 {
  2796. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2797. if err == gorm.ErrRecordNotFound {
  2798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2799. return
  2800. } else if err != nil {
  2801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2802. return
  2803. } else {
  2804. fmt.Println(res)
  2805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2807. infoStr := string(Iinfos)
  2808. idetinfoStr := string(Idetinfos)
  2809. psn := &models.HisPsn{
  2810. PsnNo: res.Output.Baseinfo.PsnNo,
  2811. Age: res.Output.Baseinfo.Age,
  2812. PatientId: patient.ID,
  2813. Certno: res.Output.Baseinfo.Certno,
  2814. Brdy: res.Output.Baseinfo.Brdy,
  2815. Gend: res.Output.Baseinfo.Gend,
  2816. Naty: res.Output.Baseinfo.Naty,
  2817. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2818. PsnName: res.Output.Baseinfo.PsnName,
  2819. Idetinfo: idetinfoStr,
  2820. Insuinfo: infoStr,
  2821. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2822. CardInfo: basStr,
  2823. VerifyNumber: "",
  2824. }
  2825. service.CreateHisPsn(psn)
  2826. var rf []*ResultFive
  2827. json.Unmarshal([]byte(infoStr), &rf)
  2828. var insutypes []*ResultFive
  2829. var insutype string
  2830. var is390 int = 0
  2831. var is310 int = 0
  2832. for _, item := range rf {
  2833. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2834. insutypes = append(insutypes, item)
  2835. }
  2836. }
  2837. if len(insutypes) == 1 {
  2838. insutype = insutypes[0].Insutype
  2839. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2840. } else {
  2841. for _, i := range insutypes {
  2842. if i.Insutype == "390" {
  2843. is390 = 1
  2844. }
  2845. if i.Insutype == "310" {
  2846. is310 = 1
  2847. }
  2848. }
  2849. }
  2850. if is390 == 1 {
  2851. insutype = "390"
  2852. }
  2853. if is310 == 1 {
  2854. insutype = "310"
  2855. }
  2856. if len(insutypes) == 0 {
  2857. insutype = "390"
  2858. }
  2859. c.ServeSuccessJSON(map[string]interface{}{
  2860. "patient": patient,
  2861. "number": cardnum,
  2862. "insutype": insutype,
  2863. })
  2864. }
  2865. } else {
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2867. return
  2868. }
  2869. }
  2870. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2871. fmt.Println(initFlag)
  2872. fmt.Println("initFlag")
  2873. if initFlag == 0 {
  2874. c.TestGetJiangXiBasBaseInit()
  2875. }
  2876. basStr := c.GetBasBaseInfo()
  2877. if len(basStr) == 0 {
  2878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2879. return
  2880. }
  2881. fmt.Println(basStr)
  2882. bas := strings.Split(basStr, "|")
  2883. basNumber := bas[1]
  2884. fmt.Println(basNumber)
  2885. card_sn := bas[3]
  2886. fmt.Println(card_sn)
  2887. 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, "")
  2888. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2889. var dat map[string]interface{}
  2890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2891. fmt.Println(dat)
  2892. } else {
  2893. fmt.Println(err)
  2894. }
  2895. userJSONBytes, _ := json.Marshal(dat)
  2896. var res ResultTwo
  2897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2898. utils.ErrorLog("解析失败:%v", err)
  2899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2900. return
  2901. }
  2902. if res.Infcode == 0 {
  2903. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2904. if err == gorm.ErrRecordNotFound {
  2905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2906. return
  2907. } else if err != nil {
  2908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2909. return
  2910. } else {
  2911. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2912. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2913. infoStr := string(Iinfos)
  2914. idetinfoStr := string(Idetinfos)
  2915. psn := &models.HisPsn{
  2916. PsnNo: res.Output.Baseinfo.PsnNo,
  2917. Age: res.Output.Baseinfo.Age,
  2918. PatientId: patient.ID,
  2919. Certno: res.Output.Baseinfo.Certno,
  2920. Brdy: res.Output.Baseinfo.Brdy,
  2921. Gend: res.Output.Baseinfo.Gend,
  2922. Naty: res.Output.Baseinfo.Naty,
  2923. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2924. PsnName: res.Output.Baseinfo.PsnName,
  2925. Idetinfo: idetinfoStr,
  2926. Insuinfo: infoStr,
  2927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2928. CardInfo: basStr,
  2929. VerifyNumber: "",
  2930. }
  2931. service.CreateHisPsn(psn)
  2932. var rf []*ResultFive
  2933. json.Unmarshal([]byte(infoStr), &rf)
  2934. var insutypes []*ResultFive
  2935. var insutype string
  2936. var is390 int = 0
  2937. var is310 int = 0
  2938. for _, item := range rf {
  2939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2940. insutypes = append(insutypes, item)
  2941. }
  2942. }
  2943. if len(insutypes) == 1 {
  2944. insutype = insutypes[0].Insutype
  2945. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2946. } else {
  2947. for _, i := range insutypes {
  2948. if i.Insutype == "390" {
  2949. is390 = 1
  2950. }
  2951. if i.Insutype == "310" {
  2952. is310 = 1
  2953. }
  2954. }
  2955. }
  2956. if is390 == 1 {
  2957. insutype = "390"
  2958. }
  2959. if is310 == 1 {
  2960. insutype = "310"
  2961. }
  2962. if len(insutypes) == 0 {
  2963. insutype = "310"
  2964. }
  2965. c.ServeSuccessJSON(map[string]interface{}{
  2966. "patient": patient,
  2967. "number": basNumber,
  2968. "insutype": insutype,
  2969. })
  2970. }
  2971. } else {
  2972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2973. return
  2974. }
  2975. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2976. fmt.Println(initFlag)
  2977. fmt.Println("initFlag")
  2978. if initFlag == 0 {
  2979. c.TestGetHnBasBaseInit()
  2980. }
  2981. basStr := c.GetBasBaseInfo()
  2982. if len(basStr) == 0 {
  2983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2984. return
  2985. }
  2986. fmt.Println(basStr)
  2987. bas := strings.Split(basStr, "|")
  2988. basNumber := bas[1]
  2989. fmt.Println(basNumber)
  2990. card_sn := bas[3]
  2991. card_no := bas[2]
  2992. fmt.Println(card_sn)
  2993. name := bas[4]
  2994. name = ConvertToString(name, "gbk", "utf-8")
  2995. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  2996. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2997. var dat map[string]interface{}
  2998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2999. fmt.Println(dat)
  3000. } else {
  3001. fmt.Println(err)
  3002. }
  3003. userJSONBytes, _ := json.Marshal(dat)
  3004. var res ResultTwo
  3005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3006. utils.ErrorLog("解析失败:%v", err)
  3007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3008. return
  3009. }
  3010. if res.Infcode == 0 {
  3011. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3012. if err == gorm.ErrRecordNotFound {
  3013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3014. return
  3015. } else if err != nil {
  3016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3017. return
  3018. } else {
  3019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3021. infoStr := string(Iinfos)
  3022. idetinfoStr := string(Idetinfos)
  3023. psn := &models.HisPsn{
  3024. PsnNo: res.Output.Baseinfo.PsnNo,
  3025. Age: res.Output.Baseinfo.Age,
  3026. PatientId: patient.ID,
  3027. Certno: res.Output.Baseinfo.Certno,
  3028. Brdy: res.Output.Baseinfo.Brdy,
  3029. Gend: res.Output.Baseinfo.Gend,
  3030. Naty: res.Output.Baseinfo.Naty,
  3031. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3032. PsnName: res.Output.Baseinfo.PsnName,
  3033. Idetinfo: idetinfoStr,
  3034. Insuinfo: infoStr,
  3035. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3036. CardInfo: basStr,
  3037. VerifyNumber: "",
  3038. }
  3039. service.CreateHisPsn(psn)
  3040. var rf []*ResultFive
  3041. json.Unmarshal([]byte(infoStr), &rf)
  3042. var insutypes []*ResultFive
  3043. var insutype string
  3044. var is390 int = 0
  3045. var is310 int = 0
  3046. for _, item := range rf {
  3047. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3048. insutypes = append(insutypes, item)
  3049. }
  3050. }
  3051. if len(insutypes) == 1 {
  3052. insutype = insutypes[0].Insutype
  3053. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3054. } else {
  3055. for _, i := range insutypes {
  3056. if i.Insutype == "390" {
  3057. is390 = 1
  3058. }
  3059. if i.Insutype == "310" {
  3060. is310 = 1
  3061. }
  3062. }
  3063. }
  3064. if is390 == 1 {
  3065. insutype = "390"
  3066. }
  3067. if is310 == 1 {
  3068. insutype = "310"
  3069. }
  3070. if len(insutypes) == 0 {
  3071. insutype = "310"
  3072. }
  3073. c.ServeSuccessJSON(map[string]interface{}{
  3074. "patient": patient,
  3075. "number": basNumber,
  3076. "insutype": insutype,
  3077. })
  3078. }
  3079. } else {
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3081. return
  3082. }
  3083. } else {
  3084. if initFlag == 0 {
  3085. c.TestGetBasBaseInit()
  3086. }
  3087. basStr := c.GetBasBaseInfo()
  3088. if len(basStr) == 0 {
  3089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3090. return
  3091. }
  3092. fmt.Println(basStr)
  3093. bas := strings.Split(basStr, "|")
  3094. basNumber := bas[1]
  3095. fmt.Println(basNumber)
  3096. card_sn := bas[3]
  3097. fmt.Println(card_sn)
  3098. cardNumber := bas[2]
  3099. fmt.Println(cardNumber)
  3100. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3101. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3102. var dat map[string]interface{}
  3103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3104. fmt.Println(dat)
  3105. } else {
  3106. fmt.Println(err)
  3107. }
  3108. userJSONBytes, _ := json.Marshal(dat)
  3109. var res ResultTwo
  3110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3111. utils.ErrorLog("解析失败:%v", err)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. if res.Infcode == 0 {
  3116. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3117. if err == gorm.ErrRecordNotFound {
  3118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3119. return
  3120. } else if err != nil {
  3121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3122. return
  3123. } else {
  3124. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3125. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3126. infoStr := string(Iinfos)
  3127. idetinfoStr := string(Idetinfos)
  3128. var rf []*ResultFive
  3129. json.Unmarshal([]byte(infoStr), &rf)
  3130. var insutypes []*ResultFive
  3131. var insutype string
  3132. var is390 int = 0
  3133. var is310 int = 0
  3134. var insuplc_admdvs string
  3135. for _, item := range rf {
  3136. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3137. insutypes = append(insutypes, item)
  3138. }
  3139. }
  3140. if len(insutypes) == 1 {
  3141. insutype = insutypes[0].Insutype
  3142. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3143. } else {
  3144. for _, i := range insutypes {
  3145. if i.Insutype == "390" {
  3146. is390 = 1
  3147. }
  3148. if i.Insutype == "310" {
  3149. is310 = 1
  3150. }
  3151. }
  3152. }
  3153. if is390 == 1 {
  3154. insutype = "390"
  3155. }
  3156. if is310 == 1 {
  3157. insutype = "310"
  3158. }
  3159. if len(insutypes) == 0 {
  3160. insutype = "390"
  3161. }
  3162. for _, item := range rf {
  3163. if item.Insutype == insutype {
  3164. insuplc_admdvs = item.InsuplcAdmdvs
  3165. }
  3166. }
  3167. psn := &models.HisPsn{
  3168. PsnNo: res.Output.Baseinfo.PsnNo,
  3169. Age: res.Output.Baseinfo.Age,
  3170. PatientId: patient.ID,
  3171. Certno: res.Output.Baseinfo.Certno,
  3172. Brdy: res.Output.Baseinfo.Brdy,
  3173. Gend: res.Output.Baseinfo.Gend,
  3174. Naty: res.Output.Baseinfo.Naty,
  3175. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3176. PsnName: res.Output.Baseinfo.PsnName,
  3177. Idetinfo: idetinfoStr,
  3178. Insuinfo: infoStr,
  3179. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3180. CardInfo: basStr,
  3181. VerifyNumber: "",
  3182. InsuplcAdmdvs: insuplc_admdvs,
  3183. }
  3184. service.CreateHisPsn(psn)
  3185. c.ServeSuccessJSON(map[string]interface{}{
  3186. "patient": patient,
  3187. "number": basNumber,
  3188. })
  3189. }
  3190. } else {
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3192. return
  3193. }
  3194. break
  3195. }
  3196. case 2:
  3197. if miConfig.MdtrtareaAdmvs == "430800" {
  3198. if initFlag == 0 {
  3199. c.TestGetHnBasBaseInit()
  3200. }
  3201. SFZStr := c.GetSFZBaseInfo()
  3202. if len(SFZStr) == 0 {
  3203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3204. return
  3205. }
  3206. fmt.Println(SFZStr)
  3207. id_card_str := strings.Split(SFZStr, "^")
  3208. card_no := id_card_str[0]
  3209. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3210. //name := id_card_str[1]
  3211. //name = ConvertToString(name, "gbk", "utf-8")
  3212. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  3213. var dat map[string]interface{}
  3214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3215. fmt.Println(dat)
  3216. } else {
  3217. fmt.Println(err)
  3218. }
  3219. userJSONBytes, _ := json.Marshal(dat)
  3220. var res ResultTwo
  3221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3222. utils.ErrorLog("解析失败:%v", err)
  3223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3224. return
  3225. }
  3226. if res.Infcode == 0 {
  3227. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3228. if err == gorm.ErrRecordNotFound {
  3229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3230. return
  3231. } else if err != nil {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3233. return
  3234. } else {
  3235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3237. infoStr := string(Iinfos)
  3238. idetinfoStr := string(Idetinfos)
  3239. psn := &models.HisPsn{
  3240. PsnNo: res.Output.Baseinfo.PsnNo,
  3241. Age: res.Output.Baseinfo.Age,
  3242. PatientId: patient.ID,
  3243. Certno: res.Output.Baseinfo.Certno,
  3244. Brdy: res.Output.Baseinfo.Brdy,
  3245. Gend: res.Output.Baseinfo.Gend,
  3246. Naty: res.Output.Baseinfo.Naty,
  3247. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3248. PsnName: res.Output.Baseinfo.PsnName,
  3249. Idetinfo: idetinfoStr,
  3250. Insuinfo: infoStr,
  3251. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3252. CardInfo: SFZStr,
  3253. VerifyNumber: "",
  3254. }
  3255. service.CreateHisPsn(psn)
  3256. var rf []*ResultFive
  3257. json.Unmarshal([]byte(infoStr), &rf)
  3258. var insutypes []*ResultFive
  3259. var insutype string
  3260. var is390 int = 0
  3261. var is310 int = 0
  3262. for _, item := range rf {
  3263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3264. insutypes = append(insutypes, item)
  3265. }
  3266. }
  3267. if len(insutypes) == 1 {
  3268. insutype = insutypes[0].Insutype
  3269. } else {
  3270. for _, i := range insutypes {
  3271. if i.Insutype == "390" {
  3272. is390 = 1
  3273. }
  3274. if i.Insutype == "310" {
  3275. is310 = 1
  3276. }
  3277. }
  3278. }
  3279. if is390 == 1 {
  3280. insutype = "390"
  3281. }
  3282. if is310 == 1 {
  3283. insutype = "310"
  3284. }
  3285. if len(insutypes) == 0 {
  3286. insutype = "310"
  3287. }
  3288. c.ServeSuccessJSON(map[string]interface{}{
  3289. "patient": patient,
  3290. "number": card_no,
  3291. "insutype": insutype,
  3292. })
  3293. }
  3294. } else {
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3296. return
  3297. }
  3298. } else {
  3299. SFZStr := c.GetSFZBaseInfo()
  3300. id_card_str := strings.Split(SFZStr, "^")
  3301. id_card_number := id_card_str[0]
  3302. card_sn := ""
  3303. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3304. var dat map[string]interface{}
  3305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3306. fmt.Println(dat)
  3307. } else {
  3308. fmt.Println(err)
  3309. }
  3310. userJSONBytes, _ := json.Marshal(dat)
  3311. var res ResultTwo
  3312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3313. utils.ErrorLog("解析失败:%v", err)
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3315. return
  3316. }
  3317. if res.Infcode == 0 {
  3318. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3319. if err == gorm.ErrRecordNotFound {
  3320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3321. return
  3322. } else if err != nil {
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3324. return
  3325. } else {
  3326. c.ServeSuccessJSON(map[string]interface{}{
  3327. "patient": patient,
  3328. "number": id_card_number,
  3329. })
  3330. }
  3331. } else {
  3332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3333. return
  3334. }
  3335. }
  3336. break
  3337. case 3:
  3338. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3339. var api string
  3340. if miConfig.MdtrtareaAdmvs == "320921" {
  3341. 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 +
  3342. "&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
  3343. fmt.Println(api)
  3344. } else {
  3345. 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 +
  3346. "&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)
  3347. }
  3348. resp, requestErr := http.Get(api)
  3349. if requestErr != nil {
  3350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3351. return
  3352. }
  3353. body, ioErr := ioutil.ReadAll(resp.Body)
  3354. if ioErr != nil {
  3355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3357. return
  3358. }
  3359. var respJSON map[string]interface{}
  3360. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3363. return
  3364. }
  3365. var status string
  3366. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3367. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3368. var token string
  3369. var res ResultTwo //1101结果
  3370. var res10265 ResultTwo10265 //1101结果
  3371. var card_info string //卡信息
  3372. var busi_card_info string
  3373. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3374. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3375. if status == "0" { //读卡成功
  3376. if card_type == "1" {
  3377. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3378. result, _ := json.Marshal(respJSON)
  3379. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3380. utils.ErrorLog("解析失败:%v", err)
  3381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3382. return
  3383. }
  3384. res.ErrMsg = res10265.ErrMsg
  3385. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3386. res.Infcode = infocode
  3387. res.Output = res10265.Output
  3388. res.InfRefmsgid = res10265.InfRefmsgid
  3389. } else {
  3390. //var card_info string //卡信息
  3391. //var busi_card_info string
  3392. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3393. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3394. //fmt.Println(card_info)
  3395. //fmt.Println(busi_card_info)
  3396. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3397. result, _ := json.Marshal(respJSON)
  3398. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3399. utils.ErrorLog("解析失败:%v", err)
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. res.ErrMsg = res10265.ErrMsg
  3404. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3405. res.Infcode = infocode
  3406. res.Output = res10265.Output
  3407. res.InfRefmsgid = res10265.InfRefmsgid
  3408. }
  3409. if res.Infcode == 0 {
  3410. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3411. if err == gorm.ErrRecordNotFound {
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3413. return
  3414. } else if err != nil {
  3415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3416. return
  3417. } else {
  3418. if card_type == "1" {
  3419. bas := strings.Split(card_info, "|")
  3420. basNumber := bas[2]
  3421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3423. infoStr := string(Iinfos)
  3424. idetinfoStr := string(Idetinfos)
  3425. psn := &models.HisPsn{
  3426. PsnNo: res.Output.Baseinfo.PsnNo,
  3427. Age: res.Output.Baseinfo.Age,
  3428. PatientId: patient.ID,
  3429. Certno: res.Output.Baseinfo.Certno,
  3430. Brdy: res.Output.Baseinfo.Brdy,
  3431. Gend: res.Output.Baseinfo.Gend,
  3432. Naty: res.Output.Baseinfo.Naty,
  3433. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3434. PsnName: res.Output.Baseinfo.PsnName,
  3435. Idetinfo: idetinfoStr,
  3436. Insuinfo: infoStr,
  3437. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3438. CardInfo: card_info,
  3439. VerifyNumber: busi_card_info,
  3440. }
  3441. service.CreateHisPsn(psn)
  3442. c.ServeSuccessJSON(map[string]interface{}{
  3443. "patient": patient,
  3444. "number": basNumber,
  3445. })
  3446. } else {
  3447. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3448. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3449. infoStr := string(Iinfos)
  3450. idetinfoStr := string(Idetinfos)
  3451. psn := &models.HisPsn{
  3452. PsnNo: res.Output.Baseinfo.PsnNo,
  3453. Age: res.Output.Baseinfo.Age,
  3454. PatientId: patient.ID,
  3455. Certno: res.Output.Baseinfo.Certno,
  3456. Brdy: res.Output.Baseinfo.Brdy,
  3457. Gend: res.Output.Baseinfo.Gend,
  3458. Naty: res.Output.Baseinfo.Naty,
  3459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3460. PsnName: res.Output.Baseinfo.PsnName,
  3461. Idetinfo: idetinfoStr,
  3462. Insuinfo: infoStr,
  3463. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3464. CardInfo: card_info,
  3465. VerifyNumber: token,
  3466. }
  3467. service.CreateHisPsn(psn)
  3468. var rf []*ResultFive
  3469. json.Unmarshal([]byte(infoStr), &rf)
  3470. var insutypes []*ResultFive
  3471. var insutype string
  3472. var is390 int = 0
  3473. var is310 int = 0
  3474. for _, item := range rf {
  3475. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3476. insutypes = append(insutypes, item)
  3477. }
  3478. }
  3479. if len(insutypes) == 1 {
  3480. insutype = insutypes[0].Insutype
  3481. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3482. } else {
  3483. for _, i := range insutypes {
  3484. if i.Insutype == "390" {
  3485. is390 = 1
  3486. }
  3487. if i.Insutype == "310" {
  3488. is310 = 1
  3489. }
  3490. }
  3491. }
  3492. if is390 == 1 {
  3493. insutype = "390"
  3494. }
  3495. if is310 == 1 {
  3496. insutype = "310"
  3497. }
  3498. if len(insutypes) == 0 {
  3499. insutype = "310"
  3500. }
  3501. c.ServeSuccessJSON(map[string]interface{}{
  3502. "patient": patient,
  3503. "number": token,
  3504. "insutype": insutype,
  3505. })
  3506. }
  3507. }
  3508. } else {
  3509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3510. return
  3511. }
  3512. } else { //读卡失败
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3514. return
  3515. }
  3516. }
  3517. break
  3518. case 4:
  3519. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3520. var api string
  3521. if miConfig.MdtrtareaAdmvs == "320921" {
  3522. 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 +
  3523. "&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
  3524. fmt.Println(api)
  3525. } else {
  3526. 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 +
  3527. "&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)
  3528. }
  3529. resp, requestErr := http.Get(api)
  3530. if requestErr != nil {
  3531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3532. return
  3533. }
  3534. body, ioErr := ioutil.ReadAll(resp.Body)
  3535. if ioErr != nil {
  3536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3538. return
  3539. }
  3540. var respJSON map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. var status string
  3547. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3548. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3549. var token string
  3550. var res ResultTwo //1101结果
  3551. var res10265 ResultTwo10265 //1101结果
  3552. if status == "0" { //读卡成功
  3553. var card_info string //卡信息
  3554. var busi_card_info string
  3555. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3556. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3557. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3558. fmt.Println(card_info)
  3559. fmt.Println(busi_card_info)
  3560. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3561. result, _ := json.Marshal(respJSON)
  3562. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3563. utils.ErrorLog("解析失败:%v", err)
  3564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3565. return
  3566. }
  3567. res.ErrMsg = res10265.ErrMsg
  3568. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3569. res.Infcode = infocode
  3570. res.Output = res10265.Output
  3571. res.InfRefmsgid = res10265.InfRefmsgid
  3572. if res.Infcode == 0 {
  3573. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3574. if err == gorm.ErrRecordNotFound {
  3575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3576. return
  3577. } else if err != nil {
  3578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3579. return
  3580. } else {
  3581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3583. infoStr := string(Iinfos)
  3584. idetinfoStr := string(Idetinfos)
  3585. psn := &models.HisPsn{
  3586. PsnNo: res.Output.Baseinfo.PsnNo,
  3587. Age: res.Output.Baseinfo.Age,
  3588. PatientId: patient.ID,
  3589. Certno: res.Output.Baseinfo.Certno,
  3590. Brdy: res.Output.Baseinfo.Brdy,
  3591. Gend: res.Output.Baseinfo.Gend,
  3592. Naty: res.Output.Baseinfo.Naty,
  3593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3594. PsnName: res.Output.Baseinfo.PsnName,
  3595. Idetinfo: idetinfoStr,
  3596. Insuinfo: infoStr,
  3597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3598. CardInfo: card_info,
  3599. VerifyNumber: token,
  3600. }
  3601. var rf []*ResultFive
  3602. json.Unmarshal([]byte(infoStr), &rf)
  3603. var insutypes []*ResultFive
  3604. var insutype string
  3605. var is390 int = 0
  3606. var is310 int = 0
  3607. for _, item := range rf {
  3608. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3609. insutypes = append(insutypes, item)
  3610. }
  3611. }
  3612. if len(insutypes) == 1 {
  3613. insutype = insutypes[0].Insutype
  3614. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3615. } else {
  3616. for _, i := range insutypes {
  3617. if i.Insutype == "390" {
  3618. is390 = 1
  3619. }
  3620. if i.Insutype == "310" {
  3621. is310 = 1
  3622. }
  3623. }
  3624. }
  3625. if is390 == 1 {
  3626. insutype = "390"
  3627. }
  3628. if is310 == 1 {
  3629. insutype = "310"
  3630. }
  3631. if len(insutypes) == 0 {
  3632. insutype = "310"
  3633. }
  3634. service.CreateHisPsn(psn)
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "patient": patient,
  3637. "number": token,
  3638. "insutype": insutype,
  3639. })
  3640. }
  3641. } else {
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3643. return
  3644. }
  3645. } else { //读卡失败
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3647. return
  3648. }
  3649. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3650. if initFlag == 0 {
  3651. c.TestGetBasBaseInit()
  3652. }
  3653. token := c.GetEleBaseInfo()
  3654. token = Remove0000(token)
  3655. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3656. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3657. //
  3658. var res ResultTwo
  3659. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3660. utils.ErrorLog("解析失败:%v", err)
  3661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3662. return
  3663. }
  3664. if res.Infcode == 0 {
  3665. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3666. if err == gorm.ErrRecordNotFound {
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3668. return
  3669. } else if err != nil {
  3670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3671. return
  3672. } else {
  3673. //month := time.Unix(1557042972, 0).Format("1")
  3674. //year := time.Now().Format("2006")
  3675. //month = time.Now().Format("01")
  3676. //day := time.Now().Format("02")
  3677. //date := year+"-"+month+"-"+day + " "+"00:00:00"
  3678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3680. infoStr := string(Iinfos)
  3681. idetinfoStr := string(Idetinfos)
  3682. psn := &models.HisPsn{
  3683. PsnNo: res.Output.Baseinfo.PsnNo,
  3684. Age: res.Output.Baseinfo.Age,
  3685. PatientId: patient.ID,
  3686. Certno: res.Output.Baseinfo.Certno,
  3687. Brdy: res.Output.Baseinfo.Brdy,
  3688. Gend: res.Output.Baseinfo.Gend,
  3689. Naty: res.Output.Baseinfo.Naty,
  3690. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3691. PsnName: res.Output.Baseinfo.PsnName,
  3692. Idetinfo: idetinfoStr,
  3693. Insuinfo: infoStr,
  3694. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3695. CardInfo: "",
  3696. Stage: "1",
  3697. //RecordDate:
  3698. VerifyNumber: token,
  3699. }
  3700. service.CreateHisPsn(psn)
  3701. c.ServeSuccessJSON(map[string]interface{}{
  3702. "patient": patient,
  3703. "number": token,
  3704. })
  3705. }
  3706. } else {
  3707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3708. return
  3709. }
  3710. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3711. //if initFlag == 0 {
  3712. c.TestGetJiangXiBasBaseInit()
  3713. //}
  3714. //if initEleFlag == 0 {
  3715. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3716. //}
  3717. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3718. type ELeData struct {
  3719. Data struct {
  3720. IdNo string `json:"idNo"`
  3721. IdType string `json:"idType"`
  3722. UserName string `json:"userName"`
  3723. EcToken string `json:"ecToken"`
  3724. InsuOrg string `json:"insuOrg"`
  3725. Gender string `json:"gender"`
  3726. Birthday string `json:"birthday"`
  3727. Nationality string `json:"nationality"`
  3728. Email string `json:"email"`
  3729. Extra string `json:"extra"`
  3730. } `json:"data"`
  3731. Code int `json:"code"`
  3732. Message string `json:"message"`
  3733. }
  3734. var ele ELeData
  3735. err := json.Unmarshal([]byte(json_result), &ele)
  3736. if err != nil {
  3737. utils.ErrorLog("解析失败:%v", err)
  3738. }
  3739. token := ele.Data.EcToken
  3740. token = Remove0000(token)
  3741. 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)
  3742. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3743. var res ResultTwo
  3744. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3745. utils.ErrorLog("解析失败:%v", err)
  3746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. return
  3748. }
  3749. if res.Infcode == 0 {
  3750. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3751. if err == gorm.ErrRecordNotFound {
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3753. return
  3754. } else if err != nil {
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3756. return
  3757. } else {
  3758. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3759. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3760. infoStr := string(Iinfos)
  3761. idetinfoStr := string(Idetinfos)
  3762. psn := &models.HisPsn{
  3763. PsnNo: res.Output.Baseinfo.PsnNo,
  3764. Age: res.Output.Baseinfo.Age,
  3765. PatientId: patient.ID,
  3766. Certno: res.Output.Baseinfo.Certno,
  3767. Brdy: res.Output.Baseinfo.Brdy,
  3768. Gend: res.Output.Baseinfo.Gend,
  3769. Naty: res.Output.Baseinfo.Naty,
  3770. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3771. PsnName: res.Output.Baseinfo.PsnName,
  3772. Idetinfo: idetinfoStr,
  3773. Insuinfo: infoStr,
  3774. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3775. CardInfo: "",
  3776. //RecordDate:
  3777. VerifyNumber: token,
  3778. }
  3779. service.CreateHisPsn(psn)
  3780. var rf []*ResultFive
  3781. json.Unmarshal([]byte(infoStr), &rf)
  3782. var insutypes []*ResultFive
  3783. var insutype string
  3784. var is390 int = 0
  3785. var is310 int = 0
  3786. for _, item := range rf {
  3787. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3788. insutypes = append(insutypes, item)
  3789. }
  3790. }
  3791. if len(insutypes) == 1 {
  3792. insutype = insutypes[0].Insutype
  3793. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3794. } else {
  3795. for _, i := range insutypes {
  3796. if i.Insutype == "390" {
  3797. is390 = 1
  3798. }
  3799. if i.Insutype == "310" {
  3800. is310 = 1
  3801. }
  3802. }
  3803. }
  3804. if is390 == 1 {
  3805. insutype = "390"
  3806. }
  3807. if is310 == 1 {
  3808. insutype = "310"
  3809. }
  3810. if len(insutypes) == 0 {
  3811. insutype = "310"
  3812. }
  3813. c.ServeSuccessJSON(map[string]interface{}{
  3814. "patient": patient,
  3815. "number": token,
  3816. "insutype": insutype,
  3817. })
  3818. }
  3819. } else {
  3820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3821. return
  3822. }
  3823. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3824. //if initFlag == 0 {
  3825. c.TestGetJiangXiBasBaseInit()
  3826. //}
  3827. //if initEleFlag == 0 {
  3828. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3829. //}
  3830. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3831. type ELeData struct {
  3832. Data struct {
  3833. IdNo string `json:"idNo"`
  3834. IdType string `json:"idType"`
  3835. UserName string `json:"userName"`
  3836. EcToken string `json:"ecToken"`
  3837. InsuOrg string `json:"insuOrg"`
  3838. Gender string `json:"gender"`
  3839. Birthday string `json:"birthday"`
  3840. Nationality string `json:"nationality"`
  3841. Email string `json:"email"`
  3842. Extra string `json:"extra"`
  3843. } `json:"data"`
  3844. Code int `json:"code"`
  3845. Message string `json:"message"`
  3846. }
  3847. var ele ELeData
  3848. err := json.Unmarshal([]byte(json_result), &ele)
  3849. if err != nil {
  3850. utils.ErrorLog("解析失败:%v", err)
  3851. }
  3852. token := ele.Data.EcToken
  3853. token = Remove0000(token)
  3854. 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)
  3855. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3856. var res ResultTwo
  3857. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3858. utils.ErrorLog("解析失败:%v", err)
  3859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. return
  3861. }
  3862. if res.Infcode == 0 {
  3863. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3864. if err == gorm.ErrRecordNotFound {
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3866. return
  3867. } else if err != nil {
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3869. return
  3870. } else {
  3871. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3872. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3873. infoStr := string(Iinfos)
  3874. idetinfoStr := string(Idetinfos)
  3875. psn := &models.HisPsn{
  3876. PsnNo: res.Output.Baseinfo.PsnNo,
  3877. Age: res.Output.Baseinfo.Age,
  3878. PatientId: patient.ID,
  3879. Certno: res.Output.Baseinfo.Certno,
  3880. Brdy: res.Output.Baseinfo.Brdy,
  3881. Gend: res.Output.Baseinfo.Gend,
  3882. Naty: res.Output.Baseinfo.Naty,
  3883. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3884. PsnName: res.Output.Baseinfo.PsnName,
  3885. Idetinfo: idetinfoStr,
  3886. Insuinfo: infoStr,
  3887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3888. CardInfo: "",
  3889. VerifyNumber: token,
  3890. }
  3891. service.CreateHisPsn(psn)
  3892. var rf []*ResultFive
  3893. json.Unmarshal([]byte(infoStr), &rf)
  3894. var insutypes []*ResultFive
  3895. var insutype string
  3896. var is390 int = 0
  3897. var is310 int = 0
  3898. for _, item := range rf {
  3899. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3900. insutypes = append(insutypes, item)
  3901. }
  3902. }
  3903. if len(insutypes) == 1 {
  3904. insutype = insutypes[0].Insutype
  3905. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3906. } else {
  3907. for _, i := range insutypes {
  3908. if i.Insutype == "390" {
  3909. is390 = 1
  3910. }
  3911. if i.Insutype == "310" {
  3912. is310 = 1
  3913. }
  3914. }
  3915. }
  3916. if is390 == 1 {
  3917. insutype = "390"
  3918. }
  3919. if is310 == 1 {
  3920. insutype = "310"
  3921. }
  3922. if len(insutypes) == 0 {
  3923. insutype = "310"
  3924. }
  3925. c.ServeSuccessJSON(map[string]interface{}{
  3926. "patient": patient,
  3927. "number": token,
  3928. "insutype": insutype,
  3929. })
  3930. }
  3931. } else {
  3932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3933. return
  3934. }
  3935. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3936. type ELeData struct {
  3937. Code string `json:"code"`
  3938. Data struct {
  3939. Aac002 string `json:"aac002"`
  3940. Aaz500 string `json:"aaz500"`
  3941. ActCardNo string `json:"actCardNo"`
  3942. Bab520 string `json:"bab520"`
  3943. Bkz543 string `json:"bkz543"`
  3944. BusinessType string `json:"businessType"`
  3945. CertfCodg string `json:"certfCodg"`
  3946. EcIndexNo string `json:"ecIndexNo"`
  3947. EcToken string `json:"ecToken"`
  3948. ID0000 string `json:"id0000"`
  3949. IDNo string `json:"idNo"`
  3950. IDType string `json:"idType"`
  3951. Idcode string `json:"idcode"`
  3952. IdentityToken string `json:"identity_token"`
  3953. InsuOrg string `json:"insuOrg"`
  3954. OfficeID string `json:"officeId"`
  3955. OfficeName string `json:"officeName"`
  3956. OperatorID string `json:"operatorId"`
  3957. OperatorName string `json:"operatorName"`
  3958. OrgID string `json:"orgId"`
  3959. UserName string `json:"userName"`
  3960. } `json:"data"`
  3961. Infno interface{} `json:"infno"`
  3962. Message string `json:"message"`
  3963. OrgID string `json:"orgId"`
  3964. TransType string `json:"transType"`
  3965. }
  3966. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3967. outPutInfo = Remove0000(outPutInfo)
  3968. if len(outPutInfo) > 0 {
  3969. var ele ELeData
  3970. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3971. if err != nil {
  3972. utils.ErrorLog("解析失败:%v", err)
  3973. }
  3974. token := ele.Data.EcToken
  3975. fmt.Println(inputInfo)
  3976. fmt.Println(outPutInfo)
  3977. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3978. saveLog(result, requestLog, "1101", "获取人员信息")
  3979. var dat map[string]interface{}
  3980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3981. fmt.Println(dat)
  3982. } else {
  3983. fmt.Println(err)
  3984. }
  3985. userJSONBytes, _ := json.Marshal(dat)
  3986. var res ResultTwo
  3987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3988. utils.ErrorLog("解析失败:%v", err)
  3989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. return
  3991. }
  3992. res.ErrMsg = errMsgLog
  3993. if res.Infcode == 0 {
  3994. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3995. if err == gorm.ErrRecordNotFound {
  3996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3997. return
  3998. } else if err != nil {
  3999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4000. return
  4001. } else {
  4002. fmt.Println(res)
  4003. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4004. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4005. infoStr := string(Iinfos)
  4006. idetinfoStr := string(Idetinfos)
  4007. psn := &models.HisPsn{
  4008. PsnNo: res.Output.Baseinfo.PsnNo,
  4009. Age: res.Output.Baseinfo.Age,
  4010. PatientId: patient.ID,
  4011. Certno: res.Output.Baseinfo.Certno,
  4012. Brdy: res.Output.Baseinfo.Brdy,
  4013. Gend: res.Output.Baseinfo.Gend,
  4014. Naty: res.Output.Baseinfo.Naty,
  4015. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4016. PsnName: res.Output.Baseinfo.PsnName,
  4017. Idetinfo: idetinfoStr,
  4018. Insuinfo: infoStr,
  4019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4020. CardInfo: outPutInfo,
  4021. VerifyNumber: token,
  4022. InsuplcAdmdvs: ele.Data.InsuOrg,
  4023. }
  4024. service.CreateHisPsn(psn)
  4025. var rf []*ResultFive
  4026. json.Unmarshal([]byte(infoStr), &rf)
  4027. var insutypes []*ResultFive
  4028. var insutype string
  4029. var is390 int = 0
  4030. var is310 int = 0
  4031. for _, item := range rf {
  4032. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4033. insutypes = append(insutypes, item)
  4034. }
  4035. }
  4036. if len(insutypes) == 1 {
  4037. insutype = insutypes[0].Insutype
  4038. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4039. } else {
  4040. for _, i := range insutypes {
  4041. if i.Insutype == "390" {
  4042. is390 = 1
  4043. }
  4044. if i.Insutype == "310" {
  4045. is310 = 1
  4046. }
  4047. }
  4048. }
  4049. if is390 == 1 {
  4050. insutype = "390"
  4051. }
  4052. if is310 == 1 {
  4053. insutype = "310"
  4054. }
  4055. if len(insutypes) == 0 {
  4056. insutype = "310"
  4057. }
  4058. c.ServeSuccessJSON(map[string]interface{}{
  4059. "patient": patient,
  4060. "number": token,
  4061. "insutype": insutype,
  4062. })
  4063. }
  4064. } else {
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4066. return
  4067. }
  4068. }
  4069. } else {
  4070. if initFlag == 0 {
  4071. c.TestGetBasBaseInit()
  4072. }
  4073. token := c.GetEleBaseInfo()
  4074. token = Remove0000(token)
  4075. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4076. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4077. //
  4078. var res ResultTwo
  4079. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4080. utils.ErrorLog("解析失败:%v", err)
  4081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4082. return
  4083. }
  4084. if res.Infcode == 0 {
  4085. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4086. if err == gorm.ErrRecordNotFound {
  4087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4088. return
  4089. } else if err != nil {
  4090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4091. return
  4092. } else {
  4093. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4094. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4095. infoStr := string(Iinfos)
  4096. idetinfoStr := string(Idetinfos)
  4097. psn := &models.HisPsn{
  4098. PsnNo: res.Output.Baseinfo.PsnNo,
  4099. Age: res.Output.Baseinfo.Age,
  4100. PatientId: patient.ID,
  4101. Certno: res.Output.Baseinfo.Certno,
  4102. Brdy: res.Output.Baseinfo.Brdy,
  4103. Gend: res.Output.Baseinfo.Gend,
  4104. Naty: res.Output.Baseinfo.Naty,
  4105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4106. PsnName: res.Output.Baseinfo.PsnName,
  4107. Idetinfo: idetinfoStr,
  4108. Insuinfo: infoStr,
  4109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4110. CardInfo: "",
  4111. VerifyNumber: token,
  4112. }
  4113. service.CreateHisPsn(psn)
  4114. c.ServeSuccessJSON(map[string]interface{}{
  4115. "patient": patient,
  4116. "number": token,
  4117. })
  4118. }
  4119. } else {
  4120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4121. return
  4122. }
  4123. }
  4124. break
  4125. }
  4126. }
  4127. var initFlag int64 = 0
  4128. var initEleFlag int64 = 0
  4129. func (c *HisApiController) TestGetBasBaseInit() {
  4130. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4131. Iinit := DllDef.MustFindProc("Init")
  4132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4133. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4134. if ret != 0 {
  4135. fmt.Println("SSCard的报错原因:", err)
  4136. fmt.Println("SSCard的运算结果为:", ret)
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4138. return
  4139. }
  4140. result := int(ret)
  4141. fmt.Println("SSCard的运算结果为1:", result)
  4142. initFlag = 1
  4143. return
  4144. }
  4145. func (c *HisApiController) HandleJiangXiReadCard() {
  4146. fmt.Println("~~~~~~")
  4147. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4148. admin_user_id, _ := c.GetInt64("admin_user_id")
  4149. id_card_type, _ := c.GetInt64("id_card_type")
  4150. //certificates, _ := c.GetInt64("certificates")
  4151. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4152. if initFlag == 0 {
  4153. c.TestGetJiangXiBasBaseInit()
  4154. }
  4155. basStr := c.GetBasBaseInfo()
  4156. if len(basStr) == 0 {
  4157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4158. return
  4159. }
  4160. fmt.Println(basStr)
  4161. bas := strings.Split(basStr, "|")
  4162. basNumber := bas[1]
  4163. fmt.Println(basNumber)
  4164. card_sn := bas[3]
  4165. fmt.Println(card_sn)
  4166. 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, "")
  4167. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4168. var dat map[string]interface{}
  4169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4170. fmt.Println(dat)
  4171. } else {
  4172. fmt.Println(err)
  4173. }
  4174. userJSONBytes, _ := json.Marshal(dat)
  4175. var res ResultTwo
  4176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4177. utils.ErrorLog("解析失败:%v", err)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. if res.Infcode == 0 {
  4182. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4183. if err == gorm.ErrRecordNotFound {
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4185. return
  4186. } else if err != nil {
  4187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4188. return
  4189. } else {
  4190. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4191. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4192. infoStr := string(Iinfos)
  4193. idetinfoStr := string(Idetinfos)
  4194. psn := &models.HisPsn{
  4195. PsnNo: res.Output.Baseinfo.PsnNo,
  4196. Age: res.Output.Baseinfo.Age,
  4197. PatientId: patient.ID,
  4198. Certno: res.Output.Baseinfo.Certno,
  4199. Brdy: res.Output.Baseinfo.Brdy,
  4200. Gend: res.Output.Baseinfo.Gend,
  4201. Naty: res.Output.Baseinfo.Naty,
  4202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4203. PsnName: res.Output.Baseinfo.PsnName,
  4204. Idetinfo: idetinfoStr,
  4205. Insuinfo: infoStr,
  4206. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4207. CardInfo: basStr,
  4208. VerifyNumber: "",
  4209. }
  4210. service.CreateHisPsn(psn)
  4211. c.ServeSuccessJSON(map[string]interface{}{
  4212. "patient": patient,
  4213. "number": basNumber,
  4214. })
  4215. }
  4216. } else {
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4218. return
  4219. }
  4220. }
  4221. func (c *HisApiController) TestGetHnBasBaseInit() {
  4222. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4223. Iinit := DllDef.MustFindProc("Init")
  4224. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4225. //http://10.77.211.236/CSB/hsa-fsi-1303
  4226. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  4227. if ret != 0 {
  4228. fmt.Println("SSCard的报错原因:", err)
  4229. fmt.Println("SSCard的运算结果为:", ret)
  4230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4231. return
  4232. }
  4233. result := int(ret)
  4234. fmt.Println("SSCard的运算结果为1:", result)
  4235. initFlag = 1
  4236. return
  4237. }
  4238. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  4239. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4240. Iinit := DllDef.MustFindProc("Init")
  4241. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4242. //http://10.77.211.236/CSB/hsa-fsi-1303
  4243. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4244. if ret != 0 {
  4245. fmt.Println("SSCard的报错原因:", err)
  4246. fmt.Println("SSCard的运算结果为:", ret)
  4247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4248. return
  4249. }
  4250. result := int(ret)
  4251. fmt.Println("SSCard的运算结果为1:", result)
  4252. initFlag = 1
  4253. return
  4254. }
  4255. func (c *HisApiController) GetSFZBaseInfo() string {
  4256. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4257. readCard := DllDef.MustFindProc("ReadSFZ")
  4258. if readCard == nil {
  4259. fmt.Println("readcard is nil")
  4260. readCard = DllDef.MustFindProc("ReadSFZ")
  4261. }
  4262. str := make([]byte, 8096)
  4263. str1 := make([]byte, 8096)
  4264. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  4265. fmt.Println(r)
  4266. return Remove0000(string(str))
  4267. }
  4268. func (c *HisApiController) GetEleBaseInfo() string {
  4269. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4270. readCard := DllDef.MustFindProc("GetQRBase")
  4271. fmt.Println(readCard)
  4272. if readCard == nil {
  4273. fmt.Println("readcard is nil")
  4274. readCard = DllDef.MustFindProc("GetQRBase")
  4275. }
  4276. str := make([]byte, 1024)
  4277. str1 := make([]byte, 1024)
  4278. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4279. fmt.Println(ret2)
  4280. fmt.Println(string(str1))
  4281. fmt.Println(string(str))
  4282. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4283. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4284. if ret2 != 0 {
  4285. return ""
  4286. }
  4287. return string(str)
  4288. }
  4289. func GetJxEleBaseInfo(org_id int64) string {
  4290. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4291. readCard := DllDef.MustFindProc("NationEcTrans")
  4292. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4293. if readCard == nil {
  4294. fmt.Println("readcard is nil")
  4295. readCard = DllDef.MustFindProc("NationEcTrans")
  4296. }
  4297. str1 := make([]byte, 1024)
  4298. data := make(map[string]interface{})
  4299. inputData := make(map[string]interface{})
  4300. inputData["orgId"] = miConfig.Code
  4301. inputData["businessType"] = "01101"
  4302. inputData["operatorId"] = "test001"
  4303. inputData["operatorName"] = "cn"
  4304. inputData["officeId"] = "32760"
  4305. inputData["officeName"] = "waike"
  4306. inputData["deviceType"] = ""
  4307. data["data"] = inputData
  4308. data["transType"] = "ec.query"
  4309. data["extra "] = ""
  4310. data["orgId"] = miConfig.Code
  4311. bytesData, _ := json.Marshal(data)
  4312. //bytesData, _ := json.Marshal(data)
  4313. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4314. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4315. fmt.Println(ret2)
  4316. fmt.Println(string(str1))
  4317. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4318. if ret2 != 0 {
  4319. return ""
  4320. }
  4321. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4322. }
  4323. func GetJxEleBaseInitInfo(org_id int64) string {
  4324. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4325. readCard := DllDef.MustFindProc("NationEcTrans")
  4326. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4327. if readCard == nil {
  4328. fmt.Println("readcard is nil")
  4329. readCard = DllDef.MustFindProc("NationEcTrans")
  4330. }
  4331. str1 := make([]byte, 2048)
  4332. data := make(map[string]interface{})
  4333. inputData := make(map[string]interface{})
  4334. inputData["orgId"] = miConfig.Code
  4335. inputData["businessType"] = "01101"
  4336. inputData["operatorId"] = "1"
  4337. inputData["operatorName"] = "huangchuang"
  4338. inputData["officeId"] = "101"
  4339. inputData["officeName"] = "xuetou"
  4340. inputData["deviceType"] = ""
  4341. data["data"] = inputData
  4342. data["transType"] = "ec.query"
  4343. data["orgId"] = miConfig.Code
  4344. bytesData, _ := json.Marshal(data)
  4345. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4346. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4347. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  4348. fmt.Println(ret2)
  4349. fmt.Println(string(str1))
  4350. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4351. if ret2 != 0 {
  4352. return ""
  4353. }
  4354. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  4355. initEleFlag = 1
  4356. }
  4357. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4358. }
  4359. func (c *HisApiController) GetBasBaseInfo() string {
  4360. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4361. readCard := DllDef.MustFindProc("ReadCardBas")
  4362. if readCard == nil {
  4363. fmt.Println("readcard is nil")
  4364. readCard = DllDef.MustFindProc("ReadCardBas")
  4365. }
  4366. str := make([]byte, 1024)
  4367. str1 := make([]byte, 1024)
  4368. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4369. fmt.Println(string(str1))
  4370. fmt.Println(string(str))
  4371. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4372. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4373. if ret2 != 0 {
  4374. return ""
  4375. }
  4376. return string(str)
  4377. }
  4378. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  4379. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  4380. readCard := DllDef.MustFindProc("read_cardinfo")
  4381. if readCard == nil {
  4382. fmt.Println("readcard is nil")
  4383. readCard = DllDef.MustFindProc("read_cardinfo")
  4384. }
  4385. str := make([]byte, 1024) //卡号
  4386. str1 := make([]byte, 1024) //卡识别码
  4387. str2 := make([]byte, 1024) //身份证号
  4388. str3 := make([]byte, 1024) //姓名
  4389. str4 := make([]byte, 1024) //错误信息
  4390. 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])))
  4391. fmt.Println(string(str1))
  4392. fmt.Println(string(str))
  4393. fmt.Println(string(str2))
  4394. fmt.Println(string(str3))
  4395. fmt.Println(string(str4))
  4396. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4397. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4398. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  4399. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  4400. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  4401. if ret2 != 0 {
  4402. return "", "", "", "", ""
  4403. }
  4404. return string(str), string(str1), string(str2), string(str3), string(str4)
  4405. }
  4406. type CustomFundPay struct {
  4407. FundPayType string `json:"fund_pay_type"`
  4408. FundPayamt float64 `json:"fund_payamt"`
  4409. }
  4410. func (c *HisApiController) GetSettleList() {
  4411. order_id, _ := c.GetInt64("order_id")
  4412. admin_user_id, _ := c.GetInt64("admin_user_id")
  4413. order, _ := service.GetHisOrderByIDTwo(order_id)
  4414. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4415. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4416. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4417. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4418. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4420. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4421. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4422. if order.ID == 0 {
  4423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4424. return
  4425. }
  4426. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4427. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4428. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4429. //fmt.Println(count)
  4430. //var zero string
  4431. //number := count + 1
  4432. //if number >= 1000 {
  4433. // zero = "0000" + strconv.FormatInt(number, 10)
  4434. //} else if number >= 10000 {
  4435. // zero = "000" + strconv.FormatInt(number, 10)
  4436. //} else if number >= 100000 {
  4437. // zero = "00" + strconv.FormatInt(number, 10)
  4438. //} else if number >= 1000000 {
  4439. // zero = "0" + strconv.FormatInt(number, 10)
  4440. //} else {
  4441. // zero = strconv.FormatInt(number, 10)
  4442. //}
  4443. //fmt.Println(zero)
  4444. struct4101 := service.Struct4101{
  4445. PsnNo: order.PsnNo,
  4446. MdtrtId: order.MdtrtId,
  4447. SetlId: order.SetlId,
  4448. PsnName: order.PsnName,
  4449. Gend: order.Gend,
  4450. Brdy: his.Brdy,
  4451. Age: his.Age,
  4452. Naty: order.Naty,
  4453. PatnCertType: "01",
  4454. Certno: order.Certno,
  4455. Prfs: "90",
  4456. ConerName: roles[0].UserName,
  4457. PatnRlts: "99",
  4458. ConerAddr: miConfig.OrgName,
  4459. ConerTel: admin.Mobile,
  4460. HiType: order.Insutype,
  4461. Insuplc: miConfig.InsuplcAdmdvs,
  4462. MaindiagFlag: "1",
  4463. BillCode: order.SetlId,
  4464. BillNo: order.SetlId,
  4465. BizSn: order.Number,
  4466. PsnSelfPay: order.PsnPartAmt,
  4467. PsnOwnPay: order.PsnPartAmt,
  4468. AcctPay: order.AcctPay,
  4469. PsnCashpay: order.PsnCashPay,
  4470. HiPaymtd: "1",
  4471. Hsorg: miConfig.InsuplcAdmdvs,
  4472. HsorgOpter: miConfig.InsuplcAdmdvs,
  4473. MedinsFillPsn: curRoles.UserName,
  4474. MedinsFillDept: depart.Name,
  4475. IptMedType: "2",
  4476. }
  4477. struct4101.SetlBegnDate = order.SetlTime
  4478. struct4101.SetlEndDate = order.SetlTime
  4479. time_arr := strings.Split(order.SetlTime, " ")
  4480. struct4101.AdmTime = time_arr[0]
  4481. struct4101.AdmEndTime = time_arr[0]
  4482. var rf []CustomFundPay
  4483. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4484. var tempFunPays []service.CustomStruct
  4485. for _, item := range rf {
  4486. var tempFunPay service.CustomStruct
  4487. tempFunPay.FundPayamt = item.FundPayamt
  4488. tempFunPay.FundPayType = item.FundPayType
  4489. tempFunPays = append(tempFunPays, tempFunPay)
  4490. }
  4491. struct4101.CustomStruct = tempFunPays
  4492. var tempDiaginfos []service.DiaginfoStructTwo
  4493. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4494. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4495. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4496. var config []*models.HisXtDiagnoseConfig
  4497. for _, item := range diagnosis_ids {
  4498. id, _ := strconv.ParseInt(item, 10, 64)
  4499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4500. config = append(config, &diagnosisConfig)
  4501. }
  4502. for index, item := range config {
  4503. if index == 0 {
  4504. var tempDiaginfo service.DiaginfoStructTwo
  4505. tempDiaginfo.DiagCode = item.CountryCode
  4506. tempDiaginfo.DiagName = item.CountryContentName
  4507. tempDiaginfo.DiagType = "1"
  4508. tempDiaginfo.MaindiagFlag = "1"
  4509. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4510. } else {
  4511. var tempDiaginfo service.DiaginfoStructTwo
  4512. tempDiaginfo.DiagCode = item.CountryCode
  4513. tempDiaginfo.DiagName = item.CountryContentName
  4514. tempDiaginfo.DiagType = "2"
  4515. tempDiaginfo.MaindiagFlag = "0"
  4516. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4517. }
  4518. }
  4519. struct4101.Diseinfo = tempDiaginfos
  4520. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4521. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4522. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4523. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4524. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4525. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4526. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4527. var iteminfo service.IteminfoStruct
  4528. var bedCostTotal float64 = 0 //床位总费
  4529. var bedCostSelfTotal float64 = 0 //床位自费
  4530. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4531. var operationCostTotal float64 = 0 //手术费
  4532. var operationCostSelfTotal float64 = 0 //手术费
  4533. var operationCostPartSelfTotal float64 = 0 //手术费
  4534. var otherCostTotal float64 = 0 //其他费用
  4535. var otherCostSelfTotal float64 = 0 //其他费用
  4536. var otherCostPartSelfTotal float64 = 0 //其他费用
  4537. var materialCostTotal float64 = 0 //材料费
  4538. var materialCostSelfTotal float64 = 0 //材料费
  4539. var materialCostPartSelfTotal float64 = 0 //材料费
  4540. var westernMedicineCostTotal float64 = 0 //西药费
  4541. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4542. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4543. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4544. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4545. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4546. var checkCostTotal float64 = 0 //检查费
  4547. var checkCostSelfTotal float64 = 0 //检查费
  4548. var checkCostPartSelfTotal float64 = 0 //检查费
  4549. var laboratoryCostTotal float64 = 0 //化验费
  4550. var laboratoryCostSelfTotal float64 = 0 //化验费
  4551. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4552. var treatCostTotal float64 = 0 //治疗费用
  4553. var treatCostSelfTotal float64 = 0 //治疗费用
  4554. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4555. decimal.DivisionPrecision = 2
  4556. var bed_fulamt_ownpay_amt float64 = 0
  4557. var operation_fulamt_ownpay_amt float64 = 0
  4558. var other_fulamt_ownpay_amt float64 = 0
  4559. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4560. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4561. var check_fulamt_ownpay_amt float64 = 0
  4562. var material_fulamt_ownpay_amt float64 = 0
  4563. var laboratory_fulamt_ownpay_amt float64 = 0
  4564. var treat_fulamt_ownpay_amt float64 = 0
  4565. var bed_claa_sunmfee float64 = 0
  4566. var bed_clab_amt float64 = 0
  4567. var bed_other_amt float64 = 0
  4568. var operation_claa_sunmfee float64 = 0
  4569. var operation_clab_amt float64 = 0
  4570. var operation_other_amt float64 = 0
  4571. var other_claa_sunmfee float64 = 0
  4572. var other_clab_amt float64 = 0
  4573. var other_other_amt float64 = 0
  4574. var westernMedicine_claa_sunmfee float64 = 0
  4575. var westernMedicine_clab_amt float64 = 0
  4576. var westernMedicine_other_amt float64 = 0
  4577. var chineseTraditional_claa_sunmfee float64 = 0
  4578. var chineseTraditional_clab_amt float64 = 0
  4579. var chineseTraditional_other_amt float64 = 0
  4580. var check_claa_sunmfee float64 = 0
  4581. var check_clab_amt float64 = 0
  4582. var check_other_amt float64 = 0
  4583. var material_claa_sunmfee float64 = 0
  4584. var material_clab_amt float64 = 0
  4585. var material_other_amt float64 = 0
  4586. var laboratory_claa_sunmfee float64 = 0
  4587. var laboratory_clab_amt float64 = 0
  4588. var laboratory_other_amt float64 = 0
  4589. var treat_claa_sunmfee float64 = 0
  4590. var treat_clab_amt float64 = 0
  4591. var treat_other_amt float64 = 0
  4592. for _, item := range order.HisOrderInfo {
  4593. if item.MedChrgitmType == "01" { //床位费
  4594. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4595. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4596. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4597. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4598. if item.ChrgitmLv == "1" {
  4599. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4600. }
  4601. if item.ChrgitmLv == "2" {
  4602. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4603. }
  4604. if item.ChrgitmLv == "3" {
  4605. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4606. }
  4607. }
  4608. if item.MedChrgitmType == "03" { //检查费
  4609. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4610. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4611. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4612. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4613. if item.ChrgitmLv == "1" {
  4614. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4615. }
  4616. if item.ChrgitmLv == "2" {
  4617. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4618. }
  4619. if item.ChrgitmLv == "3" {
  4620. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4621. }
  4622. }
  4623. if item.MedChrgitmType == "04" { //化验费
  4624. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4625. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4626. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4627. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4628. if item.ChrgitmLv == "1" {
  4629. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4630. }
  4631. if item.ChrgitmLv == "2" {
  4632. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4633. }
  4634. if item.ChrgitmLv == "3" {
  4635. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4636. }
  4637. }
  4638. if item.MedChrgitmType == "05" { //治疗费
  4639. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4640. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4641. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4642. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4643. if item.ChrgitmLv == "1" {
  4644. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4645. }
  4646. if item.ChrgitmLv == "2" {
  4647. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4648. }
  4649. if item.ChrgitmLv == "3" {
  4650. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4651. }
  4652. }
  4653. if item.MedChrgitmType == "06" { //手术费
  4654. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4655. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4656. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4657. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4658. if item.ChrgitmLv == "1" {
  4659. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4660. }
  4661. if item.ChrgitmLv == "2" {
  4662. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4663. }
  4664. if item.ChrgitmLv == "3" {
  4665. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4666. }
  4667. }
  4668. if item.MedChrgitmType == "08" { //材料费
  4669. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4670. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4671. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4672. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4673. if item.ChrgitmLv == "1" {
  4674. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4675. }
  4676. if item.ChrgitmLv == "2" {
  4677. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4678. }
  4679. if item.ChrgitmLv == "3" {
  4680. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4681. }
  4682. }
  4683. if item.MedChrgitmType == "09" { //西药费
  4684. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4685. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4686. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4687. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4688. if item.ChrgitmLv == "1" {
  4689. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4690. }
  4691. if item.ChrgitmLv == "2" {
  4692. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4693. }
  4694. if item.ChrgitmLv == "3" {
  4695. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4696. }
  4697. }
  4698. if item.MedChrgitmType == "11" { //中成费
  4699. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4700. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4701. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4702. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4703. if item.ChrgitmLv == "1" {
  4704. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4705. }
  4706. if item.ChrgitmLv == "2" {
  4707. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4708. }
  4709. if item.ChrgitmLv == "3" {
  4710. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4711. }
  4712. }
  4713. if item.MedChrgitmType == "14" { //其他费
  4714. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4715. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4716. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4717. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4718. if item.ChrgitmLv == "1" {
  4719. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4720. }
  4721. if item.ChrgitmLv == "2" {
  4722. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4723. }
  4724. if item.ChrgitmLv == "3" {
  4725. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4726. }
  4727. }
  4728. }
  4729. var iteminfoStructs []service.IteminfoStruct
  4730. if bedCostTotal != 0 {
  4731. iteminfo.MedChrgitm = "01"
  4732. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4733. iteminfo.Amt = bedCostTotal
  4734. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4735. iteminfo.ClabAmt = bed_clab_amt
  4736. iteminfo.OthAmt = bed_other_amt
  4737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4738. }
  4739. if checkCostTotal != 0 {
  4740. iteminfo.MedChrgitm = "03"
  4741. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4742. iteminfo.Amt = checkCostTotal
  4743. iteminfo.ClaaSumfee = check_claa_sunmfee
  4744. iteminfo.ClabAmt = check_clab_amt
  4745. iteminfo.OthAmt = check_other_amt
  4746. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4747. }
  4748. if laboratoryCostTotal != 0 {
  4749. iteminfo.MedChrgitm = "04"
  4750. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4751. iteminfo.Amt = laboratoryCostTotal
  4752. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4753. iteminfo.ClabAmt = laboratory_clab_amt
  4754. iteminfo.OthAmt = laboratory_other_amt
  4755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4756. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4757. }
  4758. if treatCostTotal != 0 {
  4759. iteminfo.MedChrgitm = "05"
  4760. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4761. iteminfo.Amt = treatCostTotal
  4762. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4763. iteminfo.ClabAmt = treat_clab_amt
  4764. iteminfo.OthAmt = treat_other_amt
  4765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4766. //(struct4101.IteminfoStruct, iteminfo)
  4767. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4768. }
  4769. if operationCostTotal != 0 {
  4770. iteminfo.MedChrgitm = "06"
  4771. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4772. iteminfo.Amt = operationCostTotal
  4773. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4774. iteminfo.ClabAmt = operation_clab_amt
  4775. iteminfo.OthAmt = operation_other_amt
  4776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4778. }
  4779. if materialCostTotal != 0 {
  4780. iteminfo.MedChrgitm = "08"
  4781. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4782. iteminfo.Amt = materialCostTotal
  4783. iteminfo.ClaaSumfee = material_claa_sunmfee
  4784. iteminfo.ClabAmt = material_clab_amt
  4785. iteminfo.OthAmt = material_other_amt
  4786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4788. }
  4789. if westernMedicineCostTotal != 0 {
  4790. iteminfo.MedChrgitm = "09"
  4791. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4792. iteminfo.Amt = westernMedicineCostTotal
  4793. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4794. iteminfo.ClabAmt = westernMedicine_clab_amt
  4795. iteminfo.OthAmt = westernMedicine_other_amt
  4796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4797. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4798. }
  4799. if chineseTraditionalMedicineCostTotal != 0 {
  4800. iteminfo.MedChrgitm = "11"
  4801. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4802. iteminfo.Amt = westernMedicineCostTotal
  4803. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4804. iteminfo.ClabAmt = westernMedicine_clab_amt
  4805. iteminfo.OthAmt = westernMedicine_other_amt
  4806. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4808. }
  4809. if otherCostTotal != 0 {
  4810. iteminfo.MedChrgitm = "14"
  4811. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4812. iteminfo.Amt = otherCostTotal
  4813. iteminfo.ClaaSumfee = other_claa_sunmfee
  4814. iteminfo.ClabAmt = other_clab_amt
  4815. iteminfo.OthAmt = other_other_amt
  4816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4818. }
  4819. struct4101.IteminfoStruct = iteminfoStructs
  4820. struct4101.Ntly = "中国"
  4821. struct4101.AdmCaty = "A03.06"
  4822. struct4101.DoctorName = doctor.UserName
  4823. struct4101.DoctorCode = doctor.DoctorNumber
  4824. var res ResultSeventeen
  4825. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4826. struct4101.BillCode = order.Number
  4827. struct4101.BillNo = order.SetlId
  4828. var resOther ResultSeventeenOther
  4829. var pp models.PublicParams
  4830. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4831. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4832. pp.FixmedinsName = miConfig.OrgName
  4833. pp.FixmedinsCode = miConfig.Code
  4834. pp.RequestUrl = miConfig.Url
  4835. pp.Cainfo = miConfig.Cainfo
  4836. pp.SecretKey = miConfig.SecretKey
  4837. pp.AccessKey = miConfig.AccessKey
  4838. pp.OpterName = curRoles.UserName
  4839. client := &http.Client{}
  4840. var req *http.Request
  4841. data := make(map[string]interface{})
  4842. data["struct4101"] = struct4101
  4843. data["pp"] = pp
  4844. bytesData, _ := json.Marshal(data)
  4845. if miConfig.MdtrtareaAdmvs == "320921" {
  4846. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4847. } else {
  4848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4849. }
  4850. resp, _ := client.Do(req)
  4851. defer resp.Body.Close()
  4852. body, ioErr := ioutil.ReadAll(resp.Body)
  4853. if ioErr != nil {
  4854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. var respJSON map[string]interface{}
  4859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. return
  4863. }
  4864. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4865. userJSONBytes, _ := json.Marshal(respJSON)
  4866. fmt.Println("log")
  4867. fmt.Println(string(userJSONBytes))
  4868. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4869. utils.ErrorLog("解析失败:%v", err)
  4870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4871. return
  4872. }
  4873. res.InfRefmsgid = resOther.InfRefmsgid
  4874. res.Output = resOther.Output
  4875. res.ErrMsg = resOther.ErrMsg
  4876. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4877. res.Infcode = infocode
  4878. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4879. var pp models.PublicParams
  4880. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4881. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4882. pp.FixmedinsName = miConfig.OrgName
  4883. pp.FixmedinsCode = miConfig.Code
  4884. pp.RequestUrl = miConfig.Url
  4885. pp.Cainfo = miConfig.Cainfo
  4886. pp.SecretKey = miConfig.SecretKey
  4887. pp.AccessKey = miConfig.AccessKey
  4888. pp.OpterName = curRoles.UserName
  4889. result, _ := service.Jxyb4101(struct4101, pp)
  4890. var dat map[string]interface{}
  4891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4892. fmt.Println(dat)
  4893. } else {
  4894. fmt.Println(err)
  4895. }
  4896. userJSONBytes, _ := json.Marshal(dat)
  4897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4898. utils.ErrorLog("解析失败:%v", err)
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4900. return
  4901. }
  4902. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4903. var pp models.PublicParams
  4904. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4905. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4906. pp.FixmedinsName = miConfig.OrgName
  4907. pp.FixmedinsCode = miConfig.Code
  4908. pp.RequestUrl = miConfig.Url
  4909. pp.Cainfo = miConfig.Cainfo
  4910. pp.SecretKey = miConfig.SecretKey
  4911. pp.AccessKey = miConfig.AccessKey
  4912. pp.OpterName = curRoles.UserName
  4913. result, _ := service.Hnyb4101(struct4101, pp)
  4914. var dat map[string]interface{}
  4915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4916. fmt.Println(dat)
  4917. } else {
  4918. fmt.Println(err)
  4919. }
  4920. userJSONBytes, _ := json.Marshal(dat)
  4921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4922. utils.ErrorLog("解析失败:%v", err)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. } else {
  4927. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4928. var dat map[string]interface{}
  4929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4930. fmt.Println(dat)
  4931. } else {
  4932. fmt.Println(err)
  4933. }
  4934. userJSONBytes, _ := json.Marshal(dat)
  4935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4936. utils.ErrorLog("解析失败:%v", err)
  4937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. return
  4939. }
  4940. }
  4941. if res.Infcode != 0 {
  4942. c.ServeSuccessJSON(map[string]interface{}{
  4943. "failed_code": -10,
  4944. "msg": res.ErrMsg,
  4945. })
  4946. return
  4947. } else {
  4948. //order.FaPiaoNumber = zero
  4949. //order.FaPiaoCode = last_order.FaPiaoCode
  4950. //service.UpdateOrder(order)
  4951. hisFundSettleListResult := &models.HisFundSettleListResult{
  4952. Number: res.Output.SetlListId,
  4953. Status: 1,
  4954. Ctime: time.Now().Unix(),
  4955. Mtime: time.Now().Unix(),
  4956. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4957. IsUpload: 1,
  4958. OrderId: order_id,
  4959. }
  4960. service.CreateUploadRecord(hisFundSettleListResult)
  4961. c.ServeSuccessJSON(map[string]interface{}{
  4962. "msg": "上传成功",
  4963. "result": hisFundSettleListResult,
  4964. })
  4965. return
  4966. }
  4967. }
  4968. func (c *HisApiController) GetSettleListHospital() {
  4969. order_id, _ := c.GetInt64("order_id")
  4970. admin_user_id, _ := c.GetInt64("admin_user_id")
  4971. order, _ := service.GetHisOrderByIDTwo(order_id)
  4972. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4973. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4974. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4975. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4976. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4978. if order.ID == 0 {
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4980. return
  4981. }
  4982. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4983. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4984. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4985. fmt.Println(count)
  4986. var zero string
  4987. number := count + 1
  4988. if number >= 1000 {
  4989. zero = "0000" + strconv.FormatInt(number, 10)
  4990. } else if number >= 10000 {
  4991. zero = "000" + strconv.FormatInt(number, 10)
  4992. } else if number >= 100000 {
  4993. zero = "00" + strconv.FormatInt(number, 10)
  4994. } else if number >= 1000000 {
  4995. zero = "0" + strconv.FormatInt(number, 10)
  4996. } else {
  4997. zero = strconv.FormatInt(number, 10)
  4998. }
  4999. fmt.Println(zero)
  5000. struct4101 := service.Struct4101{
  5001. PsnNo: order.PsnNo,
  5002. MdtrtId: order.MdtrtId,
  5003. SetlId: order.SetlId,
  5004. PsnName: order.PsnName,
  5005. Gend: order.Gend,
  5006. Brdy: his.Brdy,
  5007. Age: int64(order.Age),
  5008. Naty: order.Naty,
  5009. PatnCertType: "01",
  5010. Certno: order.Certno,
  5011. Prfs: "90",
  5012. ConerName: roles[0].UserName,
  5013. PatnRlts: "99",
  5014. ConerAddr: miConfig.OrgName,
  5015. ConerTel: admin.Mobile,
  5016. HiType: order.Insutype,
  5017. Insuplc: miConfig.InsuplcAdmdvs,
  5018. MaindiagFlag: "1",
  5019. BillCode: order.SetlId,
  5020. BillNo: order.SetlId,
  5021. BizSn: order.Number,
  5022. PsnSelfPay: order.PsnPartAmt,
  5023. PsnOwnPay: order.PsnPartAmt,
  5024. AcctPay: order.AcctPay,
  5025. PsnCashpay: order.PsnCashPay,
  5026. HiPaymtd: "1",
  5027. Hsorg: miConfig.InsuplcAdmdvs,
  5028. HsorgOpter: miConfig.InsuplcAdmdvs,
  5029. MedinsFillPsn: curRoles.UserName,
  5030. MedinsFillDept: depart.Name,
  5031. IptMedType: "2",
  5032. AdmTime: his.InHosptialTime,
  5033. AdmEndTime: his.OutHosptialTime,
  5034. }
  5035. struct4101.SetlBegnDate = order.SetlTime
  5036. struct4101.SetlEndDate = order.SetlTime
  5037. var rf []CustomFundPay
  5038. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5039. var tempFunPays []service.CustomStruct
  5040. for _, item := range rf {
  5041. var tempFunPay service.CustomStruct
  5042. tempFunPay.FundPayamt = item.FundPayamt
  5043. tempFunPay.FundPayType = item.FundPayType
  5044. tempFunPays = append(tempFunPays, tempFunPay)
  5045. }
  5046. struct4101.CustomStruct = tempFunPays
  5047. var tempDiaginfos []service.DiaginfoStructTwo
  5048. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5049. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5050. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5051. var config []*models.HisXtDiagnoseConfig
  5052. for _, item := range diagnosis_ids {
  5053. id, _ := strconv.ParseInt(item, 10, 64)
  5054. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5055. config = append(config, &diagnosisConfig)
  5056. }
  5057. for index, item := range config {
  5058. if index == 0 {
  5059. var tempDiaginfo service.DiaginfoStructTwo
  5060. tempDiaginfo.DiagCode = item.CountryCode
  5061. tempDiaginfo.DiagName = item.CountryContentName
  5062. tempDiaginfo.DiagType = "1"
  5063. tempDiaginfo.MaindiagFlag = "1"
  5064. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5065. } else {
  5066. var tempDiaginfo service.DiaginfoStructTwo
  5067. tempDiaginfo.DiagCode = item.CountryCode
  5068. tempDiaginfo.DiagName = item.CountryContentName
  5069. tempDiaginfo.DiagType = "2"
  5070. tempDiaginfo.MaindiagFlag = "0"
  5071. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5072. }
  5073. }
  5074. struct4101.Diseinfo = tempDiaginfos
  5075. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5076. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5077. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5078. tempOpspdiseinfo2.OprnOprtCode = ""
  5079. tempOpspdiseinfo2.OprnOprtName = ""
  5080. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5081. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5082. var iteminfo service.IteminfoStruct
  5083. var bedCostTotal float64 = 0 //床位总费
  5084. var bedCostSelfTotal float64 = 0 //床位自费
  5085. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5086. var operationCostTotal float64 = 0 //手术费
  5087. var operationCostSelfTotal float64 = 0 //手术费
  5088. var operationCostPartSelfTotal float64 = 0 //手术费
  5089. var otherCostTotal float64 = 0 //其他费用
  5090. var otherCostSelfTotal float64 = 0 //其他费用
  5091. var otherCostPartSelfTotal float64 = 0 //其他费用
  5092. var materialCostTotal float64 = 0 //材料费
  5093. var materialCostSelfTotal float64 = 0 //材料费
  5094. var materialCostPartSelfTotal float64 = 0 //材料费
  5095. var westernMedicineCostTotal float64 = 0 //西药费
  5096. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5097. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5098. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5099. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5100. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5101. var checkCostTotal float64 = 0 //检查费
  5102. var checkCostSelfTotal float64 = 0 //检查费
  5103. var checkCostPartSelfTotal float64 = 0 //检查费
  5104. var laboratoryCostTotal float64 = 0 //化验费
  5105. var laboratoryCostSelfTotal float64 = 0 //化验费
  5106. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5107. var treatCostTotal float64 = 0 //治疗费用
  5108. var treatCostSelfTotal float64 = 0 //治疗费用
  5109. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5110. decimal.DivisionPrecision = 2
  5111. var bed_fulamt_ownpay_amt float64 = 0
  5112. var operation_fulamt_ownpay_amt float64 = 0
  5113. var other_fulamt_ownpay_amt float64 = 0
  5114. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5115. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5116. var check_fulamt_ownpay_amt float64 = 0
  5117. var material_fulamt_ownpay_amt float64 = 0
  5118. var laboratory_fulamt_ownpay_amt float64 = 0
  5119. var treat_fulamt_ownpay_amt float64 = 0
  5120. var bed_claa_sunmfee float64 = 0
  5121. var bed_clab_amt float64 = 0
  5122. var bed_other_amt float64 = 0
  5123. var operation_claa_sunmfee float64 = 0
  5124. var operation_clab_amt float64 = 0
  5125. var operation_other_amt float64 = 0
  5126. var other_claa_sunmfee float64 = 0
  5127. var other_clab_amt float64 = 0
  5128. var other_other_amt float64 = 0
  5129. var westernMedicine_claa_sunmfee float64 = 0
  5130. var westernMedicine_clab_amt float64 = 0
  5131. var westernMedicine_other_amt float64 = 0
  5132. var chineseTraditional_claa_sunmfee float64 = 0
  5133. var chineseTraditional_clab_amt float64 = 0
  5134. var chineseTraditional_other_amt float64 = 0
  5135. var check_claa_sunmfee float64 = 0
  5136. var check_clab_amt float64 = 0
  5137. var check_other_amt float64 = 0
  5138. var material_claa_sunmfee float64 = 0
  5139. var material_clab_amt float64 = 0
  5140. var material_other_amt float64 = 0
  5141. var laboratory_claa_sunmfee float64 = 0
  5142. var laboratory_clab_amt float64 = 0
  5143. var laboratory_other_amt float64 = 0
  5144. var treat_claa_sunmfee float64 = 0
  5145. var treat_clab_amt float64 = 0
  5146. var treat_other_amt float64 = 0
  5147. for _, item := range order.HisOrderInfo {
  5148. if item.MedChrgitmType == "01" { //床位费
  5149. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5150. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5151. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5152. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5153. if item.ChrgitmLv == "1" {
  5154. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5155. }
  5156. if item.ChrgitmLv == "2" {
  5157. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5158. }
  5159. if item.ChrgitmLv == "3" {
  5160. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5161. }
  5162. }
  5163. if item.MedChrgitmType == "03" { //检查费
  5164. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5165. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5166. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5167. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5168. if item.ChrgitmLv == "1" {
  5169. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5170. }
  5171. if item.ChrgitmLv == "2" {
  5172. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5173. }
  5174. if item.ChrgitmLv == "3" {
  5175. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5176. }
  5177. }
  5178. if item.MedChrgitmType == "04" { //化验费
  5179. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5180. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5181. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5182. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5183. if item.ChrgitmLv == "1" {
  5184. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5185. }
  5186. if item.ChrgitmLv == "2" {
  5187. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5188. }
  5189. if item.ChrgitmLv == "3" {
  5190. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5191. }
  5192. }
  5193. if item.MedChrgitmType == "05" { //治疗费
  5194. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5195. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5196. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5197. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5198. if item.ChrgitmLv == "1" {
  5199. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5200. }
  5201. if item.ChrgitmLv == "2" {
  5202. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5203. }
  5204. if item.ChrgitmLv == "3" {
  5205. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5206. }
  5207. }
  5208. if item.MedChrgitmType == "06" { //手术费
  5209. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5210. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5211. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5212. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5213. if item.ChrgitmLv == "1" {
  5214. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5215. }
  5216. if item.ChrgitmLv == "2" {
  5217. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5218. }
  5219. if item.ChrgitmLv == "3" {
  5220. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5221. }
  5222. }
  5223. if item.MedChrgitmType == "08" { //材料费
  5224. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5225. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5226. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5227. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5228. if item.ChrgitmLv == "1" {
  5229. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5230. }
  5231. if item.ChrgitmLv == "2" {
  5232. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5233. }
  5234. if item.ChrgitmLv == "3" {
  5235. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5236. }
  5237. }
  5238. if item.MedChrgitmType == "09" { //西药费
  5239. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5240. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5241. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5242. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5243. if item.ChrgitmLv == "1" {
  5244. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5245. }
  5246. if item.ChrgitmLv == "2" {
  5247. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5248. }
  5249. if item.ChrgitmLv == "3" {
  5250. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5251. }
  5252. }
  5253. if item.MedChrgitmType == "11" { //中成费
  5254. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5255. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5256. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5257. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5258. if item.ChrgitmLv == "1" {
  5259. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5260. }
  5261. if item.ChrgitmLv == "2" {
  5262. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5263. }
  5264. if item.ChrgitmLv == "3" {
  5265. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5266. }
  5267. }
  5268. if item.MedChrgitmType == "14" { //其他费
  5269. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5270. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5271. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5272. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5273. if item.ChrgitmLv == "1" {
  5274. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5275. }
  5276. if item.ChrgitmLv == "2" {
  5277. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5278. }
  5279. if item.ChrgitmLv == "3" {
  5280. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5281. }
  5282. }
  5283. }
  5284. var iteminfoStructs []service.IteminfoStruct
  5285. if bedCostTotal != 0 {
  5286. iteminfo.MedChrgitm = "01"
  5287. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5288. iteminfo.Amt = bedCostTotal
  5289. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5290. iteminfo.ClabAmt = bed_clab_amt
  5291. iteminfo.OthAmt = bed_other_amt
  5292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5293. }
  5294. if checkCostTotal != 0 {
  5295. iteminfo.MedChrgitm = "03"
  5296. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5297. iteminfo.Amt = checkCostTotal
  5298. iteminfo.ClaaSumfee = check_claa_sunmfee
  5299. iteminfo.ClabAmt = check_clab_amt
  5300. iteminfo.OthAmt = check_other_amt
  5301. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5302. }
  5303. if laboratoryCostTotal != 0 {
  5304. iteminfo.MedChrgitm = "04"
  5305. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5306. iteminfo.Amt = laboratoryCostTotal
  5307. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5308. iteminfo.ClabAmt = laboratory_clab_amt
  5309. iteminfo.OthAmt = laboratory_other_amt
  5310. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5311. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5312. }
  5313. if treatCostTotal != 0 {
  5314. iteminfo.MedChrgitm = "05"
  5315. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5316. iteminfo.Amt = treatCostTotal
  5317. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5318. iteminfo.ClabAmt = treat_clab_amt
  5319. iteminfo.OthAmt = treat_other_amt
  5320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5321. //(struct4101.IteminfoStruct, iteminfo)
  5322. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5323. }
  5324. if operationCostTotal != 0 {
  5325. iteminfo.MedChrgitm = "06"
  5326. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5327. iteminfo.Amt = operationCostTotal
  5328. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5329. iteminfo.ClabAmt = operation_clab_amt
  5330. iteminfo.OthAmt = operation_other_amt
  5331. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5333. }
  5334. if materialCostTotal != 0 {
  5335. iteminfo.MedChrgitm = "08"
  5336. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5337. iteminfo.Amt = materialCostTotal
  5338. iteminfo.ClaaSumfee = material_claa_sunmfee
  5339. iteminfo.ClabAmt = material_clab_amt
  5340. iteminfo.OthAmt = material_other_amt
  5341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5343. }
  5344. if westernMedicineCostTotal != 0 {
  5345. iteminfo.MedChrgitm = "09"
  5346. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5347. iteminfo.Amt = westernMedicineCostTotal
  5348. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5349. iteminfo.ClabAmt = westernMedicine_clab_amt
  5350. iteminfo.OthAmt = westernMedicine_other_amt
  5351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5353. }
  5354. if chineseTraditionalMedicineCostTotal != 0 {
  5355. iteminfo.MedChrgitm = "11"
  5356. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5357. iteminfo.Amt = westernMedicineCostTotal
  5358. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5359. iteminfo.ClabAmt = westernMedicine_clab_amt
  5360. iteminfo.OthAmt = westernMedicine_other_amt
  5361. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5363. }
  5364. if otherCostTotal != 0 {
  5365. iteminfo.MedChrgitm = "14"
  5366. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5367. iteminfo.Amt = otherCostTotal
  5368. iteminfo.ClaaSumfee = other_claa_sunmfee
  5369. iteminfo.ClabAmt = other_clab_amt
  5370. iteminfo.OthAmt = other_other_amt
  5371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5373. }
  5374. struct4101.IteminfoStruct = iteminfoStructs
  5375. struct4101.Ntly = "中国"
  5376. struct4101.AdmCaty = "A03.06"
  5377. var resOther ResultSeventeenOther
  5378. var res ResultSeventeen
  5379. if miConfig.MdtrtareaAdmvs == "150499" {
  5380. var pp models.PublicParams
  5381. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5382. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5383. pp.FixmedinsName = miConfig.OrgName
  5384. pp.FixmedinsCode = miConfig.Code
  5385. pp.RequestUrl = miConfig.Url
  5386. pp.Cainfo = miConfig.Cainfo
  5387. pp.SecretKey = miConfig.SecretKey
  5388. pp.AccessKey = miConfig.AccessKey
  5389. pp.OpterName = curRoles.UserName
  5390. client := &http.Client{}
  5391. var req *http.Request
  5392. data := make(map[string]interface{})
  5393. data["struct4101"] = struct4101
  5394. data["pp"] = pp
  5395. bytesData, _ := json.Marshal(data)
  5396. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  5397. resp, _ := client.Do(req)
  5398. defer resp.Body.Close()
  5399. body, ioErr := ioutil.ReadAll(resp.Body)
  5400. if ioErr != nil {
  5401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5403. return
  5404. }
  5405. var respJSON map[string]interface{}
  5406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5409. return
  5410. }
  5411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5412. userJSONBytes, _ := json.Marshal(respJSON)
  5413. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5414. utils.ErrorLog("解析失败:%v", err)
  5415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5416. return
  5417. }
  5418. res.InfRefmsgid = resOther.InfRefmsgid
  5419. res.Output = resOther.Output
  5420. res.ErrMsg = resOther.ErrMsg
  5421. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5422. res.Infcode = infocode
  5423. } else {
  5424. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5425. var dat map[string]interface{}
  5426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5427. fmt.Println(dat)
  5428. } else {
  5429. fmt.Println(err)
  5430. }
  5431. userJSONBytes, _ := json.Marshal(dat)
  5432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5433. utils.ErrorLog("解析失败:%v", err)
  5434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5435. return
  5436. }
  5437. }
  5438. if res.Infcode != 0 {
  5439. c.ServeSuccessJSON(map[string]interface{}{
  5440. "failed_code": -10,
  5441. "msg": res.ErrMsg,
  5442. })
  5443. return
  5444. } else {
  5445. if miConfig.MdtrtareaAdmvs != "150499" {
  5446. order.FaPiaoNumber = zero
  5447. order.FaPiaoCode = last_order.FaPiaoCode
  5448. service.UpdateOrder(order)
  5449. }
  5450. hisFundSettleListResult := &models.HisFundSettleListResult{
  5451. Number: res.Output.SetlListId,
  5452. Status: 1,
  5453. Ctime: time.Now().Unix(),
  5454. Mtime: time.Now().Unix(),
  5455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5456. IsUpload: 1,
  5457. OrderId: order_id,
  5458. }
  5459. service.CreateUploadRecord(hisFundSettleListResult)
  5460. c.ServeSuccessJSON(map[string]interface{}{
  5461. "msg": "上传成功",
  5462. "result": hisFundSettleListResult,
  5463. })
  5464. return
  5465. }
  5466. }
  5467. func (c *HisApiController) GetBatchSettleList() {
  5468. orders, _ := service.GetAllHisOrder(10106)
  5469. for _, item := range orders {
  5470. order_id := item.ID
  5471. order, _ := service.GetHisOrderByIDTwo(order_id)
  5472. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5473. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5474. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  5476. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5477. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5478. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5479. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5480. if order.ID == 0 {
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5482. return
  5483. }
  5484. if his.BalanceAccountsType == 2 {
  5485. continue
  5486. }
  5487. struct4101 := service.Struct4101{
  5488. PsnNo: order.PsnNo,
  5489. MdtrtId: order.MdtrtId,
  5490. SetlId: order.SetlId,
  5491. PsnName: order.PsnName,
  5492. Gend: order.Gend,
  5493. Brdy: his.Brdy,
  5494. Age: his.Age,
  5495. Naty: order.Naty,
  5496. PatnCertType: "01",
  5497. Certno: order.Certno,
  5498. Prfs: "90",
  5499. ConerName: roles[0].UserName,
  5500. PatnRlts: "99",
  5501. ConerAddr: miConfig.OrgName,
  5502. ConerTel: admin.Mobile,
  5503. HiType: order.Insutype,
  5504. Insuplc: his.InsuplcAdmdvs,
  5505. MaindiagFlag: "1",
  5506. BillCode: order.SetlId,
  5507. BillNo: order.SetlId,
  5508. BizSn: order.Number,
  5509. PsnSelfPay: order.PsnPartAmt,
  5510. PsnOwnPay: order.PsnPartAmt,
  5511. AcctPay: order.AcctPay,
  5512. PsnCashpay: order.PsnCashPay,
  5513. HiPaymtd: "1",
  5514. Hsorg: his.InsuplcAdmdvs,
  5515. HsorgOpter: his.InsuplcAdmdvs,
  5516. MedinsFillPsn: curRoles.UserName,
  5517. MedinsFillDept: depart.Name,
  5518. IptMedType: "2",
  5519. }
  5520. struct4101.SetlBegnDate = order.SetlTime
  5521. struct4101.SetlEndDate = order.SetlTime
  5522. //if order.SettleType == 1 {
  5523. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5524. // dateStr := t.Format("2006-01-02")
  5525. // struct4101.SetlBegnDate = dateStr
  5526. // struct4101.SetlEndDate = dateStr
  5527. //} else {
  5528. // t := time.Unix(int64(order.SettleStartTime), 0)
  5529. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5530. // dateStartStr := t.Format("2006-01-02")
  5531. // dateEndStr := t2.Format("2006-01-02")
  5532. // struct4101.SetlBegnDate = dateStartStr
  5533. // struct4101.SetlEndDate = dateEndStr
  5534. //}
  5535. var rf []CustomFundPay
  5536. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5537. var tempFunPays []service.CustomStruct
  5538. var tempFunPay610100 service.CustomStruct
  5539. for _, item := range rf {
  5540. if item.FundPayType == "610100" {
  5541. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5542. tempFunPay610100.FundPayType = item.FundPayType
  5543. } else {
  5544. var tempFunPay service.CustomStruct
  5545. tempFunPay.FundPayamt = item.FundPayamt
  5546. tempFunPay.FundPayType = item.FundPayType
  5547. tempFunPays = append(tempFunPays, tempFunPay)
  5548. }
  5549. }
  5550. tempFunPays = append(tempFunPays, tempFunPay610100)
  5551. struct4101.CustomStruct = tempFunPays
  5552. var tempDiaginfos []service.DiaginfoStructTwo
  5553. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5554. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5555. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5556. var config []*models.HisXtDiagnoseConfig
  5557. for _, item := range diagnosis_ids {
  5558. id, _ := strconv.ParseInt(item, 10, 64)
  5559. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5560. config = append(config, &diagnosisConfig)
  5561. }
  5562. for index, item := range config {
  5563. if index == 0 {
  5564. var tempDiaginfo service.DiaginfoStructTwo
  5565. tempDiaginfo.DiagCode = item.CountryCode
  5566. tempDiaginfo.DiagName = item.CountryContentName
  5567. tempDiaginfo.DiagType = "1"
  5568. tempDiaginfo.MaindiagFlag = "1"
  5569. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5570. } else {
  5571. var tempDiaginfo service.DiaginfoStructTwo
  5572. tempDiaginfo.DiagCode = item.CountryCode
  5573. tempDiaginfo.DiagName = item.CountryContentName
  5574. tempDiaginfo.DiagType = "2"
  5575. tempDiaginfo.MaindiagFlag = "0"
  5576. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5577. }
  5578. }
  5579. struct4101.Diseinfo = tempDiaginfos
  5580. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5581. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5582. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5583. tempOpspdiseinfo2.OprnOprtCode = ""
  5584. tempOpspdiseinfo2.OprnOprtName = ""
  5585. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5586. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5587. var iteminfo service.IteminfoStruct
  5588. var bedCostTotal float64 = 0 //床位总费
  5589. var bedCostSelfTotal float64 = 0 //床位自费
  5590. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5591. var examineCostTotal float64 = 0 //诊查总费
  5592. var examineCostSelfTotal float64 = 0 //诊查自费
  5593. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5594. var nursingCostTotal float64 = 0 //护理总费
  5595. var nursingCostSelfTotal float64 = 0 //护理自费
  5596. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5597. var chineseMedicineCostTotal float64 = 0 //中成药
  5598. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5599. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5600. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5601. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5602. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5603. var registerCostTotal float64 = 0 //一般诊疗费
  5604. var registerCostSelfTotal float64 = 0 //一般诊疗费
  5605. var registerPartSelfTotal float64 = 0 //一般诊疗费
  5606. var operationCostTotal float64 = 0 //手术费
  5607. var operationCostSelfTotal float64 = 0 //手术费
  5608. var operationCostPartSelfTotal float64 = 0 //手术费
  5609. var otherCostTotal float64 = 0 //其他费用
  5610. var otherCostSelfTotal float64 = 0 //其他费用
  5611. var otherCostPartSelfTotal float64 = 0 //其他费用
  5612. var materialCostTotal float64 = 0 //材料费
  5613. var materialCostSelfTotal float64 = 0 //材料费
  5614. var materialCostPartSelfTotal float64 = 0 //材料费
  5615. var westernMedicineCostTotal float64 = 0 //西药费
  5616. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5617. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5618. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5619. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5620. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5621. var checkCostTotal float64 = 0 //检查费
  5622. var checkCostSelfTotal float64 = 0 //检查费
  5623. var checkCostPartSelfTotal float64 = 0 //检查费
  5624. var laboratoryCostTotal float64 = 0 //化验费
  5625. var laboratoryCostSelfTotal float64 = 0 //化验费
  5626. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5627. var treatCostTotal float64 = 0 //治疗费用
  5628. var treatCostSelfTotal float64 = 0 //治疗费用
  5629. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5630. decimal.DivisionPrecision = 2
  5631. var bed_fulamt_ownpay_amt float64 = 0
  5632. var examine_fulamt_ownpay_amt float64 = 0
  5633. var nursing_fulamt_ownpay_amt float64 = 0
  5634. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  5635. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  5636. var register_fulamt_ownpay_amt float64 = 0
  5637. var operation_fulamt_ownpay_amt float64 = 0
  5638. var other_fulamt_ownpay_amt float64 = 0
  5639. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5640. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5641. var check_fulamt_ownpay_amt float64 = 0
  5642. var material_fulamt_ownpay_amt float64 = 0
  5643. var laboratory_fulamt_ownpay_amt float64 = 0
  5644. var treat_fulamt_ownpay_amt float64 = 0
  5645. var bed_claa_sunmfee float64 = 0
  5646. var bed_clab_amt float64 = 0
  5647. var bed_other_amt float64 = 0
  5648. var examine_claa_sunmfee float64 = 0
  5649. var examine_clab_amt float64 = 0
  5650. var examine_other_amt float64 = 0
  5651. var nursing_claa_sunmfee float64 = 0
  5652. var nursing_clab_amt float64 = 0
  5653. var nursing_other_amt float64 = 0
  5654. var chinese_medicine_claa_sunmfee float64 = 0
  5655. var chinese_medicine_clab_amt float64 = 0
  5656. var chinese_medicine_other_amt float64 = 0
  5657. var commonly_treatment_claa_sunmfee float64 = 0
  5658. var commonly_treatment_clab_amt float64 = 0
  5659. var commonly_treatment_other_amt float64 = 0
  5660. var operation_claa_sunmfee float64 = 0
  5661. var operation_clab_amt float64 = 0
  5662. var operation_other_amt float64 = 0
  5663. var other_claa_sunmfee float64 = 0
  5664. var other_clab_amt float64 = 0
  5665. var other_other_amt float64 = 0
  5666. var westernMedicine_claa_sunmfee float64 = 0
  5667. var westernMedicine_clab_amt float64 = 0
  5668. var westernMedicine_other_amt float64 = 0
  5669. var chineseTraditional_claa_sunmfee float64 = 0
  5670. var chineseTraditional_clab_amt float64 = 0
  5671. var chineseTraditional_other_amt float64 = 0
  5672. var check_claa_sunmfee float64 = 0
  5673. var check_clab_amt float64 = 0
  5674. var check_other_amt float64 = 0
  5675. var material_claa_sunmfee float64 = 0
  5676. var material_clab_amt float64 = 0
  5677. var material_other_amt float64 = 0
  5678. var laboratory_claa_sunmfee float64 = 0
  5679. var laboratory_clab_amt float64 = 0
  5680. var laboratory_other_amt float64 = 0
  5681. var treat_claa_sunmfee float64 = 0
  5682. var treat_clab_amt float64 = 0
  5683. var treat_other_amt float64 = 0
  5684. var register_claa_sunmfee float64 = 0
  5685. var register_clab_amt float64 = 0
  5686. var register_other_amt float64 = 0
  5687. for _, item := range order.HisOrderInfo {
  5688. if item.MedChrgitmType == "01" { //床位费
  5689. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5690. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5691. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5692. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5693. if item.ChrgitmLv == "1" {
  5694. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5695. }
  5696. if item.ChrgitmLv == "2" {
  5697. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5698. }
  5699. if item.ChrgitmLv == "3" {
  5700. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5701. }
  5702. }
  5703. if item.MedChrgitmType == "02" { //诊查
  5704. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5705. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5706. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5707. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5708. if item.ChrgitmLv == "1" {
  5709. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5710. }
  5711. if item.ChrgitmLv == "2" {
  5712. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5713. }
  5714. if item.ChrgitmLv == "3" {
  5715. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5716. }
  5717. }
  5718. if item.MedChrgitmType == "03" { //检查费
  5719. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5720. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5721. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5722. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5723. if item.ChrgitmLv == "1" {
  5724. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5725. }
  5726. if item.ChrgitmLv == "2" {
  5727. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5728. }
  5729. if item.ChrgitmLv == "3" {
  5730. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5731. }
  5732. }
  5733. if item.MedChrgitmType == "04" { //化验费
  5734. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5735. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5736. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5737. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5738. if item.ChrgitmLv == "1" {
  5739. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5740. }
  5741. if item.ChrgitmLv == "2" {
  5742. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5743. }
  5744. if item.ChrgitmLv == "3" {
  5745. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5746. }
  5747. }
  5748. if item.MedChrgitmType == "05" { //治疗费
  5749. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5750. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5751. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5752. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5753. if item.ChrgitmLv == "1" {
  5754. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5755. }
  5756. if item.ChrgitmLv == "2" {
  5757. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5758. }
  5759. if item.ChrgitmLv == "3" {
  5760. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5761. }
  5762. }
  5763. if item.MedChrgitmType == "06" { //手术费
  5764. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5765. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5766. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5767. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5768. if item.ChrgitmLv == "1" {
  5769. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5770. }
  5771. if item.ChrgitmLv == "2" {
  5772. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5773. }
  5774. if item.ChrgitmLv == "3" {
  5775. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5776. }
  5777. }
  5778. if item.MedChrgitmType == "07" { //手术费
  5779. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5780. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5781. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5782. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5783. if item.ChrgitmLv == "1" {
  5784. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5785. }
  5786. if item.ChrgitmLv == "2" {
  5787. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5788. }
  5789. if item.ChrgitmLv == "3" {
  5790. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5791. }
  5792. }
  5793. if item.MedChrgitmType == "08" { //材料费
  5794. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5795. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5796. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5797. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5798. if item.ChrgitmLv == "1" {
  5799. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5800. }
  5801. if item.ChrgitmLv == "2" {
  5802. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5803. }
  5804. if item.ChrgitmLv == "3" {
  5805. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5806. }
  5807. }
  5808. if item.MedChrgitmType == "09" { //西药费
  5809. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5810. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5811. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5812. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5813. if item.ChrgitmLv == "1" {
  5814. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5815. }
  5816. if item.ChrgitmLv == "2" {
  5817. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5818. }
  5819. if item.ChrgitmLv == "3" {
  5820. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5821. }
  5822. }
  5823. if item.MedChrgitmType == "10" { //中药饮片
  5824. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5825. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5826. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5827. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5828. if item.ChrgitmLv == "1" {
  5829. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5830. }
  5831. if item.ChrgitmLv == "2" {
  5832. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5833. }
  5834. if item.ChrgitmLv == "3" {
  5835. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5836. }
  5837. }
  5838. if item.MedChrgitmType == "11" { //中成费
  5839. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5840. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5841. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5842. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5843. if item.ChrgitmLv == "1" {
  5844. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5845. }
  5846. if item.ChrgitmLv == "2" {
  5847. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5848. }
  5849. if item.ChrgitmLv == "3" {
  5850. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5851. }
  5852. }
  5853. if item.MedChrgitmType == "12" { //中成费
  5854. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5855. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5856. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5857. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5858. if item.ChrgitmLv == "1" {
  5859. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5860. }
  5861. if item.ChrgitmLv == "2" {
  5862. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5863. }
  5864. if item.ChrgitmLv == "3" {
  5865. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5866. }
  5867. }
  5868. if item.MedChrgitmType == "13" { //中成费
  5869. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5870. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5871. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5872. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5873. if item.ChrgitmLv == "1" {
  5874. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5875. }
  5876. if item.ChrgitmLv == "2" {
  5877. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5878. }
  5879. if item.ChrgitmLv == "3" {
  5880. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5881. }
  5882. }
  5883. if item.MedChrgitmType == "14" { //其他费
  5884. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5885. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5886. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5887. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5888. if item.ChrgitmLv == "1" {
  5889. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5890. }
  5891. if item.ChrgitmLv == "2" {
  5892. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5893. }
  5894. if item.ChrgitmLv == "3" {
  5895. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5896. }
  5897. }
  5898. }
  5899. var iteminfoStructs []service.IteminfoStruct
  5900. if bedCostTotal != 0 {
  5901. iteminfo.MedChrgitm = "01"
  5902. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5903. iteminfo.Amt = bedCostTotal
  5904. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5905. iteminfo.ClabAmt = bed_clab_amt
  5906. iteminfo.OthAmt = bed_other_amt
  5907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5908. }
  5909. if examineCostTotal != 0 {
  5910. iteminfo.MedChrgitm = "02"
  5911. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5912. iteminfo.Amt = examineCostTotal
  5913. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5914. iteminfo.ClabAmt = examine_clab_amt
  5915. iteminfo.OthAmt = examine_other_amt
  5916. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5917. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5918. }
  5919. if checkCostTotal != 0 {
  5920. iteminfo.MedChrgitm = "03"
  5921. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5922. iteminfo.Amt = checkCostTotal
  5923. iteminfo.ClaaSumfee = check_claa_sunmfee
  5924. iteminfo.ClabAmt = check_clab_amt
  5925. iteminfo.OthAmt = check_other_amt
  5926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5927. }
  5928. if laboratoryCostTotal != 0 {
  5929. iteminfo.MedChrgitm = "04"
  5930. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5931. iteminfo.Amt = laboratoryCostTotal
  5932. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5933. iteminfo.ClabAmt = laboratory_clab_amt
  5934. iteminfo.OthAmt = laboratory_other_amt
  5935. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5936. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5937. }
  5938. if treatCostTotal != 0 {
  5939. iteminfo.MedChrgitm = "05"
  5940. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5941. iteminfo.Amt = treatCostTotal
  5942. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5943. iteminfo.ClabAmt = treat_clab_amt
  5944. iteminfo.OthAmt = treat_other_amt
  5945. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5946. //(struct4101.IteminfoStruct, iteminfo)
  5947. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5948. }
  5949. if operationCostTotal != 0 {
  5950. iteminfo.MedChrgitm = "06"
  5951. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5952. iteminfo.Amt = operationCostTotal
  5953. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5954. iteminfo.ClabAmt = operation_clab_amt
  5955. iteminfo.OthAmt = operation_other_amt
  5956. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5957. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5958. }
  5959. if nursingCostTotal != 0 {
  5960. iteminfo.MedChrgitm = "07"
  5961. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5962. iteminfo.Amt = nursingCostTotal
  5963. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5964. iteminfo.ClabAmt = nursing_clab_amt
  5965. iteminfo.OthAmt = nursing_other_amt
  5966. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5967. }
  5968. if materialCostTotal != 0 {
  5969. iteminfo.MedChrgitm = "08"
  5970. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5971. iteminfo.Amt = materialCostTotal
  5972. iteminfo.ClaaSumfee = material_claa_sunmfee
  5973. iteminfo.ClabAmt = material_clab_amt
  5974. iteminfo.OthAmt = material_other_amt
  5975. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5976. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5977. }
  5978. if westernMedicineCostTotal != 0 {
  5979. iteminfo.MedChrgitm = "09"
  5980. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5981. iteminfo.Amt = westernMedicineCostTotal
  5982. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5983. iteminfo.ClabAmt = westernMedicine_clab_amt
  5984. iteminfo.OthAmt = westernMedicine_other_amt
  5985. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5987. }
  5988. if chineseMedicineCostTotal != 0 {
  5989. iteminfo.MedChrgitm = "10"
  5990. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5991. iteminfo.Amt = chineseMedicineCostTotal
  5992. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5993. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5994. iteminfo.OthAmt = chinese_medicine_other_amt
  5995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5997. }
  5998. if chineseTraditionalMedicineCostTotal != 0 {
  5999. iteminfo.MedChrgitm = "11"
  6000. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6001. iteminfo.Amt = westernMedicineCostTotal
  6002. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6003. iteminfo.ClabAmt = westernMedicine_clab_amt
  6004. iteminfo.OthAmt = westernMedicine_other_amt
  6005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6007. }
  6008. if commonlyTreatmentCostTotal != 0 {
  6009. iteminfo.MedChrgitm = "12"
  6010. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6011. iteminfo.Amt = commonlyTreatmentCostTotal
  6012. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6013. iteminfo.ClabAmt = commonly_treatment_clab_amt
  6014. iteminfo.OthAmt = commonly_treatment_other_amt
  6015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6017. }
  6018. if registerCostTotal != 0 {
  6019. iteminfo.MedChrgitm = "13"
  6020. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  6021. iteminfo.Amt = registerCostTotal
  6022. iteminfo.ClaaSumfee = register_claa_sunmfee
  6023. iteminfo.ClabAmt = register_clab_amt
  6024. iteminfo.OthAmt = register_other_amt
  6025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6027. }
  6028. if otherCostTotal != 0 {
  6029. iteminfo.MedChrgitm = "14"
  6030. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6031. iteminfo.Amt = otherCostTotal
  6032. iteminfo.ClaaSumfee = other_claa_sunmfee
  6033. iteminfo.ClabAmt = other_clab_amt
  6034. iteminfo.OthAmt = other_other_amt
  6035. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6037. }
  6038. struct4101.IteminfoStruct = iteminfoStructs
  6039. time_arr := strings.Split(order.SetlTime, " ")
  6040. struct4101.AdmTime = time_arr[0]
  6041. struct4101.AdmEndTime = time_arr[0]
  6042. struct4101.DoctorName = doctor.UserName
  6043. struct4101.DoctorCode = doctor.DoctorNumber
  6044. struct4101.Ntly = "中国"
  6045. struct4101.AdmCaty = "A03.06"
  6046. var res ResultSeventeen
  6047. if miConfig.MdtrtareaAdmvs == "421300" {
  6048. data := make(map[string]interface{})
  6049. data["struct4101"] = struct4101
  6050. data["secret_key"] = miConfig.SecretKey
  6051. data["org_name"] = miConfig.OrgName
  6052. data["opera"] = curRoles.UserName
  6053. data["code"] = miConfig.Code
  6054. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6056. client := &http.Client{}
  6057. bytesData, _ := json.Marshal(data)
  6058. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  6059. resp, _ := client.Do(req)
  6060. defer resp.Body.Close()
  6061. body, ioErr := ioutil.ReadAll(resp.Body)
  6062. if ioErr != nil {
  6063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. var respJSON map[string]interface{}
  6068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6074. userJSONBytes, _ := json.Marshal(respJSON)
  6075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6076. utils.ErrorLog("解析失败:%v", err)
  6077. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6078. adminUser := c.GetAdminUserInfo()
  6079. errlog := &models.HisOrderError{
  6080. UserOrgId: adminUser.CurrentOrgId,
  6081. Ctime: time.Now().Unix(),
  6082. Mtime: time.Now().Unix(),
  6083. ErrMsg: res.ErrMsg + "解析失败",
  6084. Status: 1,
  6085. PatientId: order_id,
  6086. Stage: 10088,
  6087. }
  6088. service.CreateErrMsgLog(errlog)
  6089. continue
  6090. }
  6091. } else {
  6092. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  6093. fmt.Println(result)
  6094. var dat map[string]interface{}
  6095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6096. fmt.Println(dat)
  6097. } else {
  6098. fmt.Println(err)
  6099. }
  6100. userJSONBytes, _ := json.Marshal(dat)
  6101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6102. utils.ErrorLog("解析失败:%v", err)
  6103. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. adminUser := c.GetAdminUserInfo()
  6105. errlog := &models.HisOrderError{
  6106. UserOrgId: adminUser.CurrentOrgId,
  6107. Ctime: time.Now().Unix(),
  6108. Mtime: time.Now().Unix(),
  6109. ErrMsg: res.ErrMsg + "解析失败",
  6110. Status: 1,
  6111. PatientId: order_id,
  6112. Stage: 10106,
  6113. }
  6114. service.CreateErrMsgLog(errlog)
  6115. continue
  6116. }
  6117. }
  6118. if res.Infcode != 0 {
  6119. adminUser := c.GetAdminUserInfo()
  6120. errlog := &models.HisOrderError{
  6121. UserOrgId: adminUser.CurrentOrgId,
  6122. Ctime: time.Now().Unix(),
  6123. Mtime: time.Now().Unix(),
  6124. ErrMsg: res.ErrMsg,
  6125. Status: 1,
  6126. PatientId: order_id,
  6127. Stage: 10106,
  6128. }
  6129. service.CreateErrMsgLog(errlog)
  6130. continue
  6131. } else {
  6132. hisFundSettleListResult := &models.HisFundSettleListResult{
  6133. Number: res.Output.SetlListId,
  6134. Status: 1,
  6135. Ctime: time.Now().Unix(),
  6136. Mtime: time.Now().Unix(),
  6137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6138. IsUpload: 1,
  6139. OrderId: order_id,
  6140. }
  6141. service.CreateUploadRecord(hisFundSettleListResult)
  6142. continue
  6143. }
  6144. }
  6145. }
  6146. func (c *HisApiController) GetOrgInfo() {
  6147. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  6148. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  6149. }
  6150. func (c *HisApiController) GetHisPatientInfo() {
  6151. medical_insurance_card := c.GetString("medical_insurance_card")
  6152. id_card_type, _ := c.GetInt64("id_card_type")
  6153. id_card := c.GetString("id_card")
  6154. adminInfo := c.GetAdminUserInfo()
  6155. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6156. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6157. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  6158. IdCardNo := ""
  6159. if id_card_type == 1 {
  6160. IdCardNo = medical_insurance_card
  6161. } else if id_card_type == 2 {
  6162. IdCardNo = id_card
  6163. }
  6164. if config.IsOpen == 1 {
  6165. 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
  6166. resp, requestErr := http.Get(api)
  6167. if requestErr != nil {
  6168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6169. return
  6170. }
  6171. defer resp.Body.Close()
  6172. body, ioErr := ioutil.ReadAll(resp.Body)
  6173. if ioErr != nil {
  6174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6176. return
  6177. }
  6178. var respJSON map[string]interface{}
  6179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6182. return
  6183. }
  6184. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6185. userJSONBytes, _ := json.Marshal(userJSON)
  6186. var res ResultTwo
  6187. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6188. utils.ErrorLog("解析失败:%v", err)
  6189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6190. return
  6191. }
  6192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6194. infoStr := string(Iinfos)
  6195. idetinfoStr := string(Idetinfos)
  6196. if res.Infcode == 0 {
  6197. his := models.VMHisPatient{
  6198. Status: 1,
  6199. Ctime: time.Now().Unix(),
  6200. Mtime: time.Now().Unix(),
  6201. PsnNo: res.Output.Baseinfo.PsnNo,
  6202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6203. Certno: res.Output.Baseinfo.Certno,
  6204. PsnName: res.Output.Baseinfo.PsnName,
  6205. Gend: res.Output.Baseinfo.Gend,
  6206. Naty: res.Output.Baseinfo.Naty,
  6207. Brdy: res.Output.Baseinfo.Brdy,
  6208. Age: res.Output.Baseinfo.Age,
  6209. Iinfo: infoStr,
  6210. Idetinfo: idetinfoStr,
  6211. UserOrgId: adminInfo.CurrentOrgId,
  6212. IsReturn: 1,
  6213. IdCardType: id_card_type,
  6214. }
  6215. c.ServeSuccessJSON(map[string]interface{}{
  6216. "info": his,
  6217. })
  6218. } else {
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6220. return
  6221. }
  6222. }
  6223. }
  6224. //func GetBasBaseInfo() (jsonStr string, err error) {
  6225. //
  6226. // handle := syscall.NewLazyDLL("SSCard.dll")
  6227. // add := handle.NewProc("ReadCardBas")
  6228. // str := make([]byte, 1024)
  6229. // str1 := make([]byte, 1024)
  6230. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6231. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  6232. //
  6233. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  6234. //
  6235. // fmt.Println("> Add(4,5)的结果为:", ret)
  6236. // handle.Release()
  6237. //
  6238. // return "", nil
  6239. //
  6240. //}
  6241. //func GetQRBaseInfo() (jsonStr string, err error) {
  6242. // handle := syscall.LoadDLL("SSCard.dll")
  6243. // ReadCardBas := handle.FindProc("GetQRBase")
  6244. //
  6245. // str := make([]byte, 256)
  6246. // str1 := make([]byte, 256)
  6247. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6248. //
  6249. // fmt.Println(string(str))
  6250. // fmt.Println(r)
  6251. // return string(str), nil
  6252. //}
  6253. //func CardInit() int {
  6254. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  6255. // add := DllTestDef.MustFindProc("Init")
  6256. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6257. // if err != nil {
  6258. // fmt.Println("SSCard的运算结果为:", ret)
  6259. // }
  6260. // result := int(ret)
  6261. // return result
  6262. //}
  6263. //func CardInit() int {
  6264. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6265. // if err != nil {
  6266. // fmt.Println("SSCard的运算结果为:", ret)
  6267. // }
  6268. // fmt.Println(err)
  6269. // result := int(ret)
  6270. // return result
  6271. //}
  6272. func IntPtr(n int) uintptr {
  6273. return uintptr(n)
  6274. }
  6275. func StrPtr(s string) uintptr {
  6276. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6277. }
  6278. type Result2001 struct {
  6279. Cainfo interface{} `json:"cainfo"`
  6280. ErrMsg string `json:"err_msg"`
  6281. InfRefmsgid string `json:"inf_refmsgid"`
  6282. Infcode int64 `json:"infcode"`
  6283. Output struct {
  6284. Trtinfo struct {
  6285. PsnNo string `json:"psn_no"`
  6286. TrtChkType string `json:"trt_chk_type"`
  6287. FundPayType string `json:"fund_pay_type"`
  6288. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6289. Begndate string `json:"begndate"`
  6290. Enddate string `json:"enddate"`
  6291. TrtChkRslt string `json:"trt_chk_rslt"`
  6292. } `json:"trtinfo"`
  6293. } `json:"output"`
  6294. RefmsgTime string `json:"refmsg_time"`
  6295. RespondTime string `json:"respond_time"`
  6296. Signtype interface{} `json:"signtype"`
  6297. WarnMsg interface{} `json:"warn_msg"`
  6298. }
  6299. type Result2001Org10265 struct {
  6300. Cainfo interface{} `json:"cainfo"`
  6301. ErrMsg string `json:"err_msg"`
  6302. InfRefmsgid string `json:"inf_refmsgid"`
  6303. Infcode string `json:"infcode"`
  6304. Output struct {
  6305. Trtinfo struct {
  6306. PsnNo string `json:"psn_no"`
  6307. TrtChkType string `json:"trt_chk_type"`
  6308. FundPayType string `json:"fund_pay_type"`
  6309. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6310. Begndate string `json:"begndate"`
  6311. Enddate string `json:"enddate"`
  6312. TrtChkRslt string `json:"trt_chk_rslt"`
  6313. } `json:"trtinfo"`
  6314. } `json:"output"`
  6315. RefmsgTime string `json:"refmsg_time"`
  6316. RespondTime string `json:"respond_time"`
  6317. Signtype interface{} `json:"signtype"`
  6318. WarnMsg interface{} `json:"warn_msg"`
  6319. }
  6320. type ResultTwo struct {
  6321. ErrMsg string `json:"err_msg"`
  6322. InfRefmsgid string `json:"inf_refmsgid"`
  6323. Infcode int64 `json:"infcode"`
  6324. Output struct {
  6325. Baseinfo struct {
  6326. Age float64 `json:"age"`
  6327. Brdy string `json:"brdy"`
  6328. Certno string `json:"certno"`
  6329. Gend string `json:"gend"`
  6330. Naty string `json:"naty"`
  6331. PsnCertType string `json:"psn_cert_type"`
  6332. PsnName string `json:"psn_name"`
  6333. PsnNo string `json:"psn_no"`
  6334. } `json:"baseinfo"`
  6335. Idetinfo []interface{} `json:"idetinfo"`
  6336. Iinfo []struct {
  6337. Balc float64 `json:"balc"`
  6338. CvlservFlag string `json:"cvlserv_flag"`
  6339. EmpName string `json:"emp_name"`
  6340. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6341. Insutype string `json:"insutype"`
  6342. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6343. PausInsuDate string `json:"paus_insu_date"`
  6344. PsnInsuDate string `json:"psn_insu_date"`
  6345. PsnInsuStas string `json:"psn_insu_stas"`
  6346. PsnType string `json:"psn_type"`
  6347. } `json:"insuinfo"`
  6348. } `json:"output"`
  6349. RefmsgTime string `json:"refmsg_time"`
  6350. RespondTime string `json:"respond_time"`
  6351. Signtype interface{} `json:"signtype"`
  6352. WarnInfo interface{} `json:"warn_info"`
  6353. }
  6354. type ResultTwo10265 struct {
  6355. ErrMsg string `json:"err_msg"`
  6356. InfRefmsgid string `json:"inf_refmsgid"`
  6357. Infcode string `json:"infcode"`
  6358. Output struct {
  6359. Baseinfo struct {
  6360. Age float64 `json:"age"`
  6361. Brdy string `json:"brdy"`
  6362. Certno string `json:"certno"`
  6363. Gend string `json:"gend"`
  6364. Naty string `json:"naty"`
  6365. PsnCertType string `json:"psn_cert_type"`
  6366. PsnName string `json:"psn_name"`
  6367. PsnNo string `json:"psn_no"`
  6368. } `json:"baseinfo"`
  6369. Idetinfo []interface{} `json:"idetinfo"`
  6370. Iinfo []struct {
  6371. Balc float64 `json:"balc"`
  6372. CvlservFlag string `json:"cvlserv_flag"`
  6373. EmpName string `json:"emp_name"`
  6374. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6375. Insutype string `json:"insutype"`
  6376. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6377. PausInsuDate string `json:"paus_insu_date"`
  6378. PsnInsuDate string `json:"psn_insu_date"`
  6379. PsnInsuStas string `json:"psn_insu_stas"`
  6380. PsnType string `json:"psn_type"`
  6381. } `json:"insuinfo"`
  6382. } `json:"output"`
  6383. RefmsgTime string `json:"refmsg_time"`
  6384. RespondTime string `json:"respond_time"`
  6385. Signtype interface{} `json:"signtype"`
  6386. WarnInfo interface{} `json:"warn_info"`
  6387. }
  6388. type ResultThree struct {
  6389. Cainfo interface{} `json:"cainfo"`
  6390. ErrMsg string `json:"err_msg"`
  6391. InfRefmsgid string `json:"inf_refmsgid"`
  6392. Infcode int64 `json:"infcode"`
  6393. Output struct {
  6394. Data struct {
  6395. IptOtpNo string `json:"ipt_otp_no"`
  6396. MdtrtID string `json:"mdtrt_id"`
  6397. PsnNo string `json:"psn_no"`
  6398. } `json:"data"`
  6399. } `json:"output"`
  6400. RefmsgTime string `json:"refmsg_time"`
  6401. RespondTime string `json:"respond_time"`
  6402. Signtype interface{} `json:"signtype"`
  6403. WarnMsg interface{} `json:"warn_msg"`
  6404. }
  6405. type ResultThree10265 struct {
  6406. Cainfo interface{} `json:"cainfo"`
  6407. ErrMsg string `json:"err_msg"`
  6408. InfRefmsgid string `json:"inf_refmsgid"`
  6409. Infcode string `json:"infcode"`
  6410. Output struct {
  6411. Data struct {
  6412. IptOtpNo string `json:"ipt_otp_no"`
  6413. MdtrtID string `json:"mdtrt_id"`
  6414. PsnNo string `json:"psn_no"`
  6415. } `json:"data"`
  6416. } `json:"output"`
  6417. RefmsgTime string `json:"refmsg_time"`
  6418. RespondTime string `json:"respond_time"`
  6419. Signtype interface{} `json:"signtype"`
  6420. WarnMsg interface{} `json:"warn_msg"`
  6421. }
  6422. type ResultFour struct {
  6423. Cainfo string `json:"cainfo"`
  6424. ErrMsg string `json:"err_msg"`
  6425. InfRefmsgid string `json:"inf_refmsgid"`
  6426. Infcode int64 `json:"infcode"`
  6427. Output struct {
  6428. Result []struct {
  6429. BasMednFlag string `json:"bas_medn_flag"`
  6430. ChldMedcFlag string `json:"chld_medc_flag"`
  6431. ChrgitmLv string `json:"chrgitm_lv"`
  6432. Cnt float64 `json:"cnt"`
  6433. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6434. DrtReimFlag string `json:"drt_reim_flag"`
  6435. FeedetlSn string `json:"feedetl_sn"`
  6436. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6437. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6438. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6439. ListSpItemFlag string `json:"list_sp_item_flag"`
  6440. LmtUsedFlag string `json:"lmt_used_flag"`
  6441. MedChrgitmType string `json:"med_chrgitm_type"`
  6442. Memo string `json:"memo"`
  6443. OverlmtAmt float64 `json:"overlmt_amt"`
  6444. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6445. Pric float64 `json:"pric"`
  6446. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6447. SelfpayProp float64 `json:"selfpay_prop"`
  6448. } `json:"result"`
  6449. } `json:"output"`
  6450. RefmsgTime string `json:"refmsg_time"`
  6451. RespondTime string `json:"respond_time"`
  6452. Signtype string `json:"signtype"`
  6453. WarnMsg string `json:"warn_msg"`
  6454. }
  6455. type ResultFour10265 struct {
  6456. Cainfo string `json:"cainfo"`
  6457. ErrMsg string `json:"err_msg"`
  6458. InfRefmsgid string `json:"inf_refmsgid"`
  6459. Infcode string `json:"infcode"`
  6460. Output struct {
  6461. Result []struct {
  6462. BasMednFlag string `json:"bas_medn_flag"`
  6463. ChldMedcFlag string `json:"chld_medc_flag"`
  6464. ChrgitmLv string `json:"chrgitm_lv"`
  6465. Cnt float64 `json:"cnt"`
  6466. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6467. DrtReimFlag string `json:"drt_reim_flag"`
  6468. FeedetlSn string `json:"feedetl_sn"`
  6469. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6470. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6471. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6472. ListSpItemFlag string `json:"list_sp_item_flag"`
  6473. LmtUsedFlag string `json:"lmt_used_flag"`
  6474. MedChrgitmType string `json:"med_chrgitm_type"`
  6475. Memo string `json:"memo"`
  6476. OverlmtAmt float64 `json:"overlmt_amt"`
  6477. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6478. Pric float64 `json:"pric"`
  6479. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6480. SelfpayProp float64 `json:"selfpay_prop"`
  6481. } `json:"result"`
  6482. } `json:"output"`
  6483. RefmsgTime string `json:"refmsg_time"`
  6484. RespondTime string `json:"respond_time"`
  6485. Signtype string `json:"signtype"`
  6486. WarnMsg string `json:"warn_msg"`
  6487. }
  6488. type ResultMemo struct {
  6489. InsuAdmdvs string `json:"insuAdmdvs"`
  6490. }
  6491. //[{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  6492. type ResultIDInfo struct {
  6493. Begntime string `json:"begntime"`
  6494. Endtime string `json:"endtime"`
  6495. Memo string `json:"memo"`
  6496. }
  6497. type ResultFive struct {
  6498. Balc float64 `json:"balc"`
  6499. CvlservFlag string `json:"cvlserv_flag"`
  6500. EmpName string `json:"emp_name"`
  6501. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6502. Insutype string `json:"insutype"`
  6503. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6504. PausInsuDate string `json:"paus_insu_date"`
  6505. PsnInsuDate string `json:"psn_insu_date"`
  6506. PsnInsuStas string `json:"psn_insu_stas"`
  6507. PsnType string `json:"psn_type"`
  6508. }
  6509. type ResultSix struct {
  6510. Cainfo interface{} `json:"cainfo"`
  6511. ErrMsg string `json:"err_msg"`
  6512. InfRefmsgid string `json:"inf_refmsgid"`
  6513. Infcode int64 `json:"infcode"`
  6514. Output struct {
  6515. } `json:"output"`
  6516. RefmsgTime string `json:"refmsg_time"`
  6517. RespondTime string `json:"respond_time"`
  6518. Signtype interface{} `json:"signtype"`
  6519. WarnMsg interface{} `json:"warn_msg"`
  6520. }
  6521. type ResultSix10265 struct {
  6522. Cainfo interface{} `json:"cainfo"`
  6523. ErrMsg string `json:"err_msg"`
  6524. InfRefmsgid string `json:"inf_refmsgid"`
  6525. Infcode string `json:"infcode"`
  6526. Output struct {
  6527. } `json:"output"`
  6528. RefmsgTime string `json:"refmsg_time"`
  6529. RespondTime string `json:"respond_time"`
  6530. Signtype interface{} `json:"signtype"`
  6531. WarnMsg interface{} `json:"warn_msg"`
  6532. }
  6533. type ResultSeven struct {
  6534. Cainfo string `json:"cainfo"`
  6535. ErrMsg string `json:"err_msg"`
  6536. InfRefmsgid string `json:"inf_refmsgid"`
  6537. Infcode int64 `json:"infcode"`
  6538. Output struct {
  6539. Setldetail []interface{} `json:"setldetail"`
  6540. Setlinfo struct {
  6541. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6542. AcctPay float64 `json:"acct_pay"`
  6543. ActPayDedc float64 `json:"act_pay_dedc"`
  6544. Age float64 `json:"age"`
  6545. Balc float64 `json:"balc"`
  6546. Brdy string `json:"brdy"`
  6547. Certno string `json:"certno"`
  6548. ClrOptins string `json:"clr_optins"`
  6549. ClrType string `json:"clr_type"`
  6550. ClrWay string `json:"clr_way"`
  6551. CvlservFlag string `json:"cvlserv_flag"`
  6552. CvlservPay float64 `json:"cvlserv_pay"`
  6553. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6554. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6555. Gend string `json:"gend"`
  6556. HifesPay float64 `json:"hifes_pay"`
  6557. HifmiPay float64 `json:"hifmi_pay"`
  6558. HifpPay float64 `json:"hifp_pay"`
  6559. HospPartAmt float64 `json:"hosp_part_amt"`
  6560. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6561. Insutype string `json:"insutype"`
  6562. MafPay float64 `json:"maf_pay"`
  6563. MdtrtCertType string `json:"mdtrt_cert_type"`
  6564. HifobPay float64 `json:"hifob_pay"`
  6565. MdtrtID string `json:"mdtrt_id"`
  6566. MedType string `json:"med_type"`
  6567. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6568. MedinsSetlID string `json:"medins_setl_id"`
  6569. Naty string `json:"naty"`
  6570. OthPay float64 `json:"oth_pay"`
  6571. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6572. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6573. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6574. PsnCashPay float64 `json:"psn_cash_pay"`
  6575. PsnCertType string `json:"psn_cert_type"`
  6576. PsnName string `json:"psn_name"`
  6577. PsnNo string `json:"psn_no"`
  6578. PsnPartAmt float64 `json:"psn_part_amt"`
  6579. PsnType string `json:"psn_type"`
  6580. SetlID string `json:"setl_id"`
  6581. SetlTime string `json:"setl_time"`
  6582. } `json:"setlinfo"`
  6583. } `json:"output"`
  6584. RefmsgTime string `json:"refmsg_time"`
  6585. RespondTime string `json:"respond_time"`
  6586. Signtype interface{} `json:"signtype"`
  6587. WarnMsg interface{} `json:"warn_msg"`
  6588. }
  6589. type ResultSeven10265 struct {
  6590. Cainfo string `json:"cainfo"`
  6591. ErrMsg string `json:"err_msg"`
  6592. InfRefmsgid string `json:"inf_refmsgid"`
  6593. Infcode string `json:"infcode"`
  6594. Output struct {
  6595. Setldetail []interface{} `json:"setldetail"`
  6596. Setlinfo struct {
  6597. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6598. AcctPay float64 `json:"acct_pay"`
  6599. ActPayDedc float64 `json:"act_pay_dedc"`
  6600. Age float64 `json:"age"`
  6601. Balc float64 `json:"balc"`
  6602. Brdy string `json:"brdy"`
  6603. Certno string `json:"certno"`
  6604. ClrOptins string `json:"clr_optins"`
  6605. ClrType string `json:"clr_type"`
  6606. ClrWay string `json:"clr_way"`
  6607. CvlservFlag string `json:"cvlserv_flag"`
  6608. CvlservPay float64 `json:"cvlserv_pay"`
  6609. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6610. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6611. Gend string `json:"gend"`
  6612. HifesPay float64 `json:"hifes_pay"`
  6613. HifmiPay float64 `json:"hifmi_pay"`
  6614. HifpPay float64 `json:"hifp_pay"`
  6615. HospPartAmt float64 `json:"hosp_part_amt"`
  6616. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6617. Insutype string `json:"insutype"`
  6618. MafPay float64 `json:"maf_pay"`
  6619. MdtrtCertType string `json:"mdtrt_cert_type"`
  6620. HifobPay float64 `json:"hifob_pay"`
  6621. MdtrtID string `json:"mdtrt_id"`
  6622. MedType string `json:"med_type"`
  6623. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6624. MedinsSetlID string `json:"medins_setl_id"`
  6625. Naty string `json:"naty"`
  6626. OthPay float64 `json:"oth_pay"`
  6627. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6628. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6629. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6630. PsnCashPay float64 `json:"psn_cash_pay"`
  6631. PsnCertType string `json:"psn_cert_type"`
  6632. PsnName string `json:"psn_name"`
  6633. PsnNo string `json:"psn_no"`
  6634. PsnPartAmt float64 `json:"psn_part_amt"`
  6635. PsnType string `json:"psn_type"`
  6636. SetlID string `json:"setl_id"`
  6637. SetlTime string `json:"setl_time"`
  6638. } `json:"setlinfo"`
  6639. } `json:"output"`
  6640. RefmsgTime string `json:"refmsg_time"`
  6641. RespondTime string `json:"respond_time"`
  6642. Signtype interface{} `json:"signtype"`
  6643. WarnMsg interface{} `json:"warn_msg"`
  6644. }
  6645. type ResultEight struct {
  6646. Cainfo string `json:"cainfo"`
  6647. ErrMsg string `json:"err_msg"`
  6648. InfRefmsgid string `json:"inf_refmsgid"`
  6649. Infcode int64 `json:"infcode"`
  6650. Output struct {
  6651. Stmtinfo struct {
  6652. SetlOptins string `json:"setl_optins"`
  6653. StmtRslt string `json:"stmt_rslt"`
  6654. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6655. } `json:"stmtinfo"`
  6656. } `json:"output"`
  6657. RefmsgTime string `json:"refmsg_time"`
  6658. RespondTime string `json:"respond_time"`
  6659. Signtype interface{} `json:"signtype"`
  6660. WarnMsg interface{} `json:"warn_msg"`
  6661. }
  6662. type ResultEightFor10188 struct {
  6663. Cainfo string `json:"cainfo"`
  6664. ErrMsg string `json:"err_msg"`
  6665. InfRefmsgid string `json:"inf_refmsgid"`
  6666. Infcode string `json:"infcode"`
  6667. Output struct {
  6668. Stmtinfo struct {
  6669. SetlOptins string `json:"setl_optins"`
  6670. StmtRslt string `json:"stmt_rslt"`
  6671. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6672. } `json:"stmtinfo"`
  6673. } `json:"output"`
  6674. RefmsgTime string `json:"refmsg_time"`
  6675. RespondTime string `json:"respond_time"`
  6676. Signtype interface{} `json:"signtype"`
  6677. WarnMsg interface{} `json:"warn_msg"`
  6678. }
  6679. type ResultNine struct {
  6680. Cainfo string `json:"cainfo"`
  6681. ErrMsg string `json:"err_msg"`
  6682. InfRefmsgid string `json:"inf_refmsgid"`
  6683. Infcode int64 `json:"infcode"`
  6684. Output struct {
  6685. FileQuryNo string `json:"file_qury_no"`
  6686. } `json:"output"`
  6687. RefmsgTime string `json:"refmsg_time"`
  6688. RespondTime string `json:"respond_time"`
  6689. Signtype interface{} `json:"signtype"`
  6690. WarnMsg interface{} `json:"warn_msg"`
  6691. }
  6692. type ResultTen struct {
  6693. Cainfo string `json:"cainfo"`
  6694. ErrMsg string `json:"err_msg"`
  6695. InfRefmsgid string `json:"inf_refmsgid"`
  6696. Infcode int64 `json:"infcode"`
  6697. Output struct {
  6698. DldEndtime string `json:"dld_endtime"`
  6699. FileQuryNo string `json:"file_qury_no"`
  6700. Filename string `json:"filename"`
  6701. } `json:"output"`
  6702. RefmsgTime string `json:"refmsg_time"`
  6703. RespondTime string `json:"respond_time"`
  6704. Signtype interface{} `json:"signtype"`
  6705. WarnMsg interface{} `json:"warn_msg"`
  6706. }
  6707. //type Autogenerated struct {
  6708. // Output struct {
  6709. // Setlinfo struct {
  6710. // SetlTime string `json:"setl_time"`
  6711. // CvlservPay float64 `json:"cvlserv_pay"`
  6712. // Year string `json:"year"`
  6713. // MedType string `json:"med_type"`
  6714. // PsnPay float64 `json:"psn_pay"`
  6715. // OpterID string `json:"opter_id"`
  6716. // Begndate string `json:"begndate"`
  6717. // FlxempeFlag string `json:"flxempe_flag"`
  6718. // HifmiPay float64 `json:"hifmi_pay"`
  6719. // PsnNo string `json:"psn_no"`
  6720. // ActPayDedc float64 `json:"act_pay_dedc"`
  6721. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6722. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6723. // ClrWay string `json:"clr_way"`
  6724. // OthPay float64 `json:"oth_pay"`
  6725. // Gend string `json:"gend"`
  6726. // MdtrtID string `json:"mdtrt_id"`
  6727. // AcctPay float64 `json:"acct_pay"`
  6728. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6729. // Insutype string `json:"insutype"`
  6730. // Invono interface{} `json:"invono"`
  6731. // Enddate string `json:"enddate"`
  6732. // CashPayamt float64 `json:"cash_payamt"`
  6733. // PsnType string `json:"psn_type"`
  6734. // FixmedinsName string `json:"fixmedins_name"`
  6735. // HifpPay float64 `json:"hifp_pay"`
  6736. // NewFlag interface{} `json:"new_flag"`
  6737. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6738. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6739. // PayLoc string `json:"pay_loc"`
  6740. // ClrType string `json:"clr_type"`
  6741. // RefdSetlFlag string `json:"refd_setl_flag"`
  6742. // CvlservFlag string `json:"cvlserv_flag"`
  6743. // EmpName string `json:"emp_name"`
  6744. // Brdy string `json:"brdy"`
  6745. // Naty string `json:"naty"`
  6746. // Certno string `json:"certno"`
  6747. // DiseCode string `json:"dise_code"`
  6748. // FixmedinsCode string `json:"fixmedins_code"`
  6749. // DedcHospLv string `json:"dedc_hosp_lv"`
  6750. // OpterName string `json:"opter_name"`
  6751. // Balc float64 `json:"balc"`
  6752. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6753. // PsnCertType string `json:"psn_cert_type"`
  6754. // HifobPay float64 `json:"hifob_pay"`
  6755. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6756. // HifesPay float64 `json:"hifes_pay"`
  6757. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6758. // OptTime string `json:"opt_time"`
  6759. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6760. // SetlID string `json:"setl_id"`
  6761. // MafPay float64 `json:"maf_pay"`
  6762. // PsnName string `json:"psn_name"`
  6763. // InsuOptins interface{} `json:"insu_optins"`
  6764. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6765. // ClrOptins string `json:"clr_optins"`
  6766. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6767. // DiseName string `json:"dise_name"`
  6768. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6769. // Age float64 `json:"age"`
  6770. // DtrtCertType string `json:"dtrt_cert_type"`
  6771. // HospLv string `json:"hosp_lv"`
  6772. // } `json:"setlinfo"`
  6773. // Setldetail []struct {
  6774. // FundPayType string `json:"fund_pay_type"`
  6775. // FundPayamt float64 `json:"fund_payamt"`
  6776. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6777. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6778. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6779. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6780. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6781. // } `json:"setldetail"`
  6782. // } `json:"output"`
  6783. // Infcode int `json:"infcode"`
  6784. // WarnMsg interface{} `json:"warn_msg"`
  6785. // Cainfo interface{} `json:"cainfo"`
  6786. // ErrMsg interface{} `json:"err_msg"`
  6787. // RefmsgTime string `json:"refmsg_time"`
  6788. // Signtype interface{} `json:"signtype"`
  6789. // RespondTime string `json:"respond_time"`
  6790. // InfRefmsgid string `json:"inf_refmsgid"`
  6791. //}
  6792. type ResultEleven struct {
  6793. Cainfo string `json:"cainfo"`
  6794. ErrMsg string `json:"err_msg"`
  6795. InfRefmsgid string `json:"inf_refmsgid"`
  6796. Infcode int64 `json:"infcode"`
  6797. Output struct {
  6798. Setlinfo struct {
  6799. SetlTime string `json:"setl_time"`
  6800. CvlservPay float64 `json:"cvlserv_pay"`
  6801. Year string `json:"year"`
  6802. MedType string `json:"med_type"`
  6803. PsnPay float64 `json:"psn_pay"`
  6804. OpterID string `json:"opter_id"`
  6805. Begndate string `json:"begndate"`
  6806. FlxempeFlag string `json:"flxempe_flag"`
  6807. HifmiPay float64 `json:"hifmi_pay"`
  6808. PsnNo string `json:"psn_no"`
  6809. ActPayDedc float64 `json:"act_pay_dedc"`
  6810. MedinsSetlID interface{} `json:"medins_setl_id"`
  6811. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6812. ClrWay string `json:"clr_way"`
  6813. OthPay float64 `json:"oth_pay"`
  6814. Gend string `json:"gend"`
  6815. MdtrtID string `json:"mdtrt_id"`
  6816. AcctPay float64 `json:"acct_pay"`
  6817. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6818. Insutype string `json:"insutype"`
  6819. Invono interface{} `json:"invono"`
  6820. Enddate string `json:"enddate"`
  6821. CashPayamt float64 `json:"cash_payamt"`
  6822. PsnType string `json:"psn_type"`
  6823. FixmedinsName string `json:"fixmedins_name"`
  6824. HifpPay float64 `json:"hifp_pay"`
  6825. NewFlag interface{} `json:"new_flag"`
  6826. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6827. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6828. PayLoc string `json:"pay_loc"`
  6829. ClrType string `json:"clr_type"`
  6830. RefdSetlFlag string `json:"refd_setl_flag"`
  6831. CvlservFlag string `json:"cvlserv_flag"`
  6832. EmpName string `json:"emp_name"`
  6833. Brdy string `json:"brdy"`
  6834. Naty string `json:"naty"`
  6835. Certno string `json:"certno"`
  6836. DiseCode string `json:"dise_code"`
  6837. FixmedinsCode string `json:"fixmedins_code"`
  6838. DedcHospLv string `json:"dedc_hosp_lv"`
  6839. OpterName string `json:"opter_name"`
  6840. Balc float64 `json:"balc"`
  6841. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6842. PsnCertType string `json:"psn_cert_type"`
  6843. HifobPay float64 `json:"hifob_pay"`
  6844. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6845. HifesPay float64 `json:"hifes_pay"`
  6846. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6847. OptTime string `json:"opt_time"`
  6848. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6849. SetlID string `json:"setl_id"`
  6850. MafPay float64 `json:"maf_pay"`
  6851. PsnName string `json:"psn_name"`
  6852. InsuOptins interface{} `json:"insu_optins"`
  6853. PrefFundPay interface{} `json:"pref_fund_pay"`
  6854. ClrOptins string `json:"clr_optins"`
  6855. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6856. DiseName string `json:"dise_name"`
  6857. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6858. Age float64 `json:"age"`
  6859. DtrtCertType string `json:"dtrt_cert_type"`
  6860. HospLv string `json:"hosp_lv"`
  6861. PsnCashPay float64
  6862. } `json:"setlinfo"`
  6863. } `json:"output"`
  6864. RefmsgTime string `json:"refmsg_time"`
  6865. RespondTime string `json:"respond_time"`
  6866. Signtype interface{} `json:"signtype"`
  6867. WarnMsg interface{} `json:"warn_msg"`
  6868. }
  6869. type ResultEleven10265 struct {
  6870. Cainfo string `json:"cainfo"`
  6871. ErrMsg string `json:"err_msg"`
  6872. InfRefmsgid string `json:"inf_refmsgid"`
  6873. Infcode string `json:"infcode"`
  6874. Output struct {
  6875. Setlinfo struct {
  6876. SetlTime string `json:"setl_time"`
  6877. CvlservPay float64 `json:"cvlserv_pay"`
  6878. Year string `json:"year"`
  6879. MedType string `json:"med_type"`
  6880. PsnPay float64 `json:"psn_pay"`
  6881. OpterID string `json:"opter_id"`
  6882. Begndate string `json:"begndate"`
  6883. FlxempeFlag string `json:"flxempe_flag"`
  6884. HifmiPay float64 `json:"hifmi_pay"`
  6885. PsnNo string `json:"psn_no"`
  6886. ActPayDedc float64 `json:"act_pay_dedc"`
  6887. MedinsSetlID interface{} `json:"medins_setl_id"`
  6888. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6889. ClrWay string `json:"clr_way"`
  6890. OthPay float64 `json:"oth_pay"`
  6891. Gend string `json:"gend"`
  6892. MdtrtID string `json:"mdtrt_id"`
  6893. AcctPay float64 `json:"acct_pay"`
  6894. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6895. Insutype string `json:"insutype"`
  6896. Invono interface{} `json:"invono"`
  6897. Enddate string `json:"enddate"`
  6898. CashPayamt float64 `json:"cash_payamt"`
  6899. PsnType string `json:"psn_type"`
  6900. FixmedinsName string `json:"fixmedins_name"`
  6901. HifpPay float64 `json:"hifp_pay"`
  6902. NewFlag interface{} `json:"new_flag"`
  6903. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6904. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6905. PayLoc string `json:"pay_loc"`
  6906. ClrType string `json:"clr_type"`
  6907. RefdSetlFlag string `json:"refd_setl_flag"`
  6908. CvlservFlag string `json:"cvlserv_flag"`
  6909. EmpName string `json:"emp_name"`
  6910. Brdy string `json:"brdy"`
  6911. Naty string `json:"naty"`
  6912. Certno string `json:"certno"`
  6913. DiseCode string `json:"dise_code"`
  6914. FixmedinsCode string `json:"fixmedins_code"`
  6915. DedcHospLv string `json:"dedc_hosp_lv"`
  6916. OpterName string `json:"opter_name"`
  6917. Balc float64 `json:"balc"`
  6918. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6919. PsnCertType string `json:"psn_cert_type"`
  6920. HifobPay float64 `json:"hifob_pay"`
  6921. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6922. HifesPay float64 `json:"hifes_pay"`
  6923. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6924. OptTime string `json:"opt_time"`
  6925. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6926. SetlID string `json:"setl_id"`
  6927. MafPay float64 `json:"maf_pay"`
  6928. PsnName string `json:"psn_name"`
  6929. InsuOptins interface{} `json:"insu_optins"`
  6930. PrefFundPay interface{} `json:"pref_fund_pay"`
  6931. ClrOptins string `json:"clr_optins"`
  6932. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6933. DiseName string `json:"dise_name"`
  6934. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6935. Age float64 `json:"age"`
  6936. DtrtCertType string `json:"dtrt_cert_type"`
  6937. HospLv string `json:"hosp_lv"`
  6938. PsnCashPay float64
  6939. } `json:"setlinfo"`
  6940. } `json:"output"`
  6941. RefmsgTime string `json:"refmsg_time"`
  6942. RespondTime string `json:"respond_time"`
  6943. Signtype interface{} `json:"signtype"`
  6944. WarnMsg interface{} `json:"warn_msg"`
  6945. }
  6946. type ResultTwelve struct {
  6947. Cainfo string `json:"cainfo"`
  6948. ErrMsg string `json:"err_msg"`
  6949. InfRefmsgid string `json:"inf_refmsgid"`
  6950. Infcode int64 `json:"infcode"`
  6951. Output struct {
  6952. MdtrtId string `json:"mdtrt_id"`
  6953. ChrgBchno string `json:"chrg_bchno"`
  6954. PsnNo string `json:"psn_no"`
  6955. } `json:"output"`
  6956. RefmsgTime string `json:"refmsg_time"`
  6957. RespondTime string `json:"respond_time"`
  6958. Signtype interface{} `json:"signtype"`
  6959. WarnMsg interface{} `json:"warn_msg"`
  6960. }
  6961. type ResultThirteen struct {
  6962. ErrMsg string `json:"err_msg"`
  6963. InfRefmsgid string `json:"inf_refmsgid"`
  6964. Infcode int64 `json:"infcode"`
  6965. Output struct {
  6966. Result struct {
  6967. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6968. } `json:"result"`
  6969. } `json:"output"`
  6970. RefmsgTime string `json:"refmsg_time"`
  6971. RespondTime string `json:"respond_time"`
  6972. Signtype interface{} `json:"signtype"`
  6973. WarnInfo interface{} `json:"warn_info"`
  6974. }
  6975. type ResultThirteen10265 struct {
  6976. ErrMsg string `json:"err_msg"`
  6977. InfRefmsgid string `json:"inf_refmsgid"`
  6978. Infcode string `json:"infcode"`
  6979. Output struct {
  6980. Result struct {
  6981. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6982. } `json:"result"`
  6983. } `json:"output"`
  6984. RefmsgTime string `json:"refmsg_time"`
  6985. RespondTime string `json:"respond_time"`
  6986. Signtype interface{} `json:"signtype"`
  6987. WarnInfo interface{} `json:"warn_info"`
  6988. }
  6989. type ResultFourteen struct {
  6990. ErrMsg string `json:"err_msg"`
  6991. InfRefmsgid string `json:"inf_refmsgid"`
  6992. Infcode int64 `json:"infcode"`
  6993. Output struct {
  6994. } `json:"output"`
  6995. RefmsgTime string `json:"refmsg_time"`
  6996. RespondTime string `json:"respond_time"`
  6997. Signtype interface{} `json:"signtype"`
  6998. WarnInfo interface{} `json:"warn_info"`
  6999. }
  7000. type ResultFourteen10265 struct {
  7001. ErrMsg string `json:"err_msg"`
  7002. InfRefmsgid string `json:"inf_refmsgid"`
  7003. Infcode string `json:"infcode"`
  7004. Output struct {
  7005. } `json:"output"`
  7006. RefmsgTime string `json:"refmsg_time"`
  7007. RespondTime string `json:"respond_time"`
  7008. Signtype interface{} `json:"signtype"`
  7009. WarnInfo interface{} `json:"warn_info"`
  7010. }
  7011. type ResultSixteen struct {
  7012. Cainfo string `json:"cainfo"`
  7013. ErrMsg string `json:"err_msg"`
  7014. InfRefmsgid string `json:"inf_refmsgid"`
  7015. Infcode int64 `json:"infcode"`
  7016. Output struct {
  7017. Setldetail []interface{} `json:"setldetail"`
  7018. Setlinfo struct {
  7019. MdtrtID string `json:"mdtrt_id"`
  7020. SetlID string `json:"setl_id"`
  7021. ClrOptins string `json:"clr_optins"`
  7022. SetlTime string `json:"setl_time"`
  7023. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7024. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7025. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7026. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7027. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7028. ActPayDedc float64 `json:"act_pay_dedc"`
  7029. HifpPay float64 `json:"hifp_pay"`
  7030. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7031. Lfpay float64 `json:"selfpay"`
  7032. CvlservPay float64 `json:"cvlserv_pay"`
  7033. HifesPay float64 `json:"hifes_pay"`
  7034. HifmiPay float64 `json:"hifmi_pay"`
  7035. HifobPay float64 `json:"hifob_pay"`
  7036. MafPay float64 `json:"maf_pay"`
  7037. OthPay float64 `json:"oth_pay"`
  7038. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7039. PsnPartAmt float64 `json:"psn_part_amt"`
  7040. AcctPay float64 `json:"acct_pay"`
  7041. Balc float64 `json:"balc"`
  7042. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7043. HospPartAmt float64 `json:"hosp_part_amt"`
  7044. MedinsSetlID string `json:"medins_setl_id"`
  7045. PdnCashPay string `json:"pdn_cash_pay"`
  7046. } `json:"setlinfo"`
  7047. } `json:"output"`
  7048. RefmsgTime string `json:"refmsg_time"`
  7049. RespondTime string `json:"respond_time"`
  7050. Signtype interface{} `json:"signtype"`
  7051. WarnMsg interface{} `json:"warn_msg"`
  7052. }
  7053. type ResultSixteen10265 struct {
  7054. Cainfo string `json:"cainfo"`
  7055. ErrMsg string `json:"err_msg"`
  7056. InfRefmsgid string `json:"inf_refmsgid"`
  7057. Infcode string `json:"infcode"`
  7058. Output struct {
  7059. Setldetail []interface{} `json:"setldetail"`
  7060. Setlinfo struct {
  7061. MdtrtID string `json:"mdtrt_id"`
  7062. SetlID string `json:"setl_id"`
  7063. ClrOptins string `json:"clr_optins"`
  7064. SetlTime string `json:"setl_time"`
  7065. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7066. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7067. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7068. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7069. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7070. ActPayDedc float64 `json:"act_pay_dedc"`
  7071. HifpPay float64 `json:"hifp_pay"`
  7072. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7073. Lfpay float64 `json:"selfpay"`
  7074. CvlservPay float64 `json:"cvlserv_pay"`
  7075. HifesPay float64 `json:"hifes_pay"`
  7076. HifmiPay float64 `json:"hifmi_pay"`
  7077. HifobPay float64 `json:"hifob_pay"`
  7078. MafPay float64 `json:"maf_pay"`
  7079. OthPay float64 `json:"oth_pay"`
  7080. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7081. PsnPartAmt float64 `json:"psn_part_amt"`
  7082. AcctPay float64 `json:"acct_pay"`
  7083. Balc float64 `json:"balc"`
  7084. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7085. HospPartAmt float64 `json:"hosp_part_amt"`
  7086. MedinsSetlID string `json:"medins_setl_id"`
  7087. PdnCashPay string `json:"pdn_cash_pay"`
  7088. } `json:"setlinfo"`
  7089. } `json:"output"`
  7090. RefmsgTime string `json:"refmsg_time"`
  7091. RespondTime string `json:"respond_time"`
  7092. Signtype interface{} `json:"signtype"`
  7093. WarnMsg interface{} `json:"warn_msg"`
  7094. }
  7095. type ResultSeventeen struct {
  7096. ErrMsg string `json:"err_msg"`
  7097. InfRefmsgid string `json:"inf_refmsgid"`
  7098. Infcode int64 `json:"infcode"`
  7099. Output struct {
  7100. SetlListId string `json:"setl_list_id"`
  7101. } `json:"output"`
  7102. RefmsgTime string `json:"refmsg_time"`
  7103. RespondTime string `json:"respond_time"`
  7104. Signtype string `json:"signtype"`
  7105. WarnInfo string `json:"warn_info"`
  7106. }
  7107. type ResultSeventeenOther struct {
  7108. ErrMsg string `json:"err_msg"`
  7109. InfRefmsgid string `json:"inf_refmsgid"`
  7110. Infcode string `json:"infcode"`
  7111. Output struct {
  7112. SetlListId string `json:"setl_list_id"`
  7113. } `json:"output"`
  7114. RefmsgTime string `json:"refmsg_time"`
  7115. RespondTime string `json:"respond_time"`
  7116. Signtype string `json:"signtype"`
  7117. WarnInfo string `json:"warn_info"`
  7118. }
  7119. type Result90991 struct {
  7120. ErrMsg string `json:"err_msg"`
  7121. InfRefmsgid string `json:"inf_refmsgid"`
  7122. Infcode int64 `json:"infcode"`
  7123. Output struct {
  7124. Result struct {
  7125. PsnNo string `json:"psn_no"`
  7126. CardStat string `json:"card_stat"`
  7127. Certno string `json:"certno"`
  7128. PsnName string `json:"psn_name"`
  7129. CheckStat string `json:"check_stat"`
  7130. SscnoCheckStat string `json:"sscno_check_stat"`
  7131. } `json:"result"`
  7132. } `json:"output"`
  7133. RefmsgTime string `json:"refmsg_time"`
  7134. RespondTime string `json:"respond_time"`
  7135. Signtype interface{} `json:"signtype"`
  7136. WarnInfo interface{} `json:"warn_info"`
  7137. }
  7138. type Result90100 struct {
  7139. ErrMsg string `json:"err_msg"`
  7140. InfRefmsgid string `json:"inf_refmsgid"`
  7141. Infcode int64 `json:"infcode"`
  7142. Output struct {
  7143. PoolareaNo string `json:"poolarea_no"`
  7144. PoolareaNoName string `json:"poolarea_no_name"`
  7145. Insutype string `json:"insutype"`
  7146. InsutypeName string `json:"insutype_name"`
  7147. ClctType string `json:"clct_type"`
  7148. ClctTypeName string `json:"clct_type_name"`
  7149. ClctFlag string `json:"clct_flag"`
  7150. ClctFlagName string `json:"clct_flag_name"`
  7151. AccrymBegn string `json:"accrym_begn"`
  7152. AccrymEnd string `json:"accrym_end"`
  7153. ClctTime string `json:"clct_time"`
  7154. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  7155. } `json:"output"`
  7156. RefmsgTime string `json:"refmsg_time"`
  7157. RespondTime string `json:"respond_time"`
  7158. Signtype interface{} `json:"signtype"`
  7159. WarnInfo interface{} `json:"warn_info"`
  7160. }
  7161. type Custom struct {
  7162. DetItemFeeSumamt string
  7163. Cut string
  7164. FeedetlSn string
  7165. Price string
  7166. MedListCodg string
  7167. Type int64
  7168. AdviceId int64
  7169. ProjectId int64
  7170. ItemId int64
  7171. }
  7172. type Result5301 struct {
  7173. ErrMsg string `json:"err_msg"`
  7174. InfRefmsgid string `json:"inf_refmsgid"`
  7175. Infcode int64 `json:"infcode"`
  7176. Output struct {
  7177. Result []struct {
  7178. OpspDiseCode string `json:"opsp_dise_code"`
  7179. OpspDiseName string `json:"opsp_dise_name"`
  7180. Begndate string `json:"begndate"`
  7181. Enddate string `json:"enddate"`
  7182. } `json:"feedetail"`
  7183. } `json:"output"`
  7184. RefmsgTime string `json:"refmsg_time"`
  7185. RespondTime string `json:"respond_time"`
  7186. Signtype interface{} `json:"signtype"`
  7187. WarnInfo interface{} `json:"warn_info"`
  7188. }
  7189. type Result5301For10265 struct {
  7190. ErrMsg string `json:"err_msg"`
  7191. InfRefmsgid string `json:"inf_refmsgid"`
  7192. Infcode string `json:"infcode"`
  7193. Output struct {
  7194. Result []struct {
  7195. OpspDiseCode string `json:"opsp_dise_code"`
  7196. OpspDiseName string `json:"opsp_dise_name"`
  7197. Begndate string `json:"begndate"`
  7198. Enddate string `json:"enddate"`
  7199. } `json:"feedetail"`
  7200. } `json:"output"`
  7201. RefmsgTime string `json:"refmsg_time"`
  7202. RespondTime string `json:"respond_time"`
  7203. Signtype interface{} `json:"signtype"`
  7204. WarnInfo interface{} `json:"warn_info"`
  7205. }
  7206. //获取个人信息----挂号-----上传就诊信息
  7207. func (c *HisApiController) GetRegisterInfo() {
  7208. id, _ := c.GetInt64("id")
  7209. record_time := c.GetString("record_time")
  7210. settlementValue, _ := c.GetInt64("settlement_value")
  7211. medical_insurance_card := c.GetString("medical_insurance_card")
  7212. name := c.GetString("name")
  7213. id_card_type, _ := c.GetInt64("id_card_type")
  7214. certificates, _ := c.GetInt64("certificates")
  7215. medical_care, _ := c.GetInt64("medical_care")
  7216. birthday := c.GetString("birthday")
  7217. id_card := c.GetString("id_card")
  7218. register_type, _ := c.GetInt64("register")
  7219. doctor, _ := c.GetInt64("doctor")
  7220. department, _ := c.GetInt64("department")
  7221. gender, _ := c.GetInt64("sex")
  7222. registration_fee, _ := c.GetFloat("registration_fee")
  7223. medical_expenses, _ := c.GetFloat("medical_expenses")
  7224. social_type, _ := c.GetInt64("social_type")
  7225. med_type := c.GetString("social_type")
  7226. admin_user_id, _ := c.GetInt64("admin_user_id")
  7227. insuplc_admdvs := c.GetString("insuplc_admdvs")
  7228. mdtrt_type := c.GetString("mdtrt_type")
  7229. timeLayout := "2006-01-02"
  7230. loc, _ := time.LoadLocation("Local")
  7231. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  7232. birthUnix := birthdays.Unix()
  7233. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7234. if err != nil {
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7236. return
  7237. }
  7238. recordDateTime := theTime.Unix()
  7239. adminInfo := c.GetAdminUserInfo()
  7240. var patient service.Patients
  7241. if id == 0 {
  7242. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  7243. } else {
  7244. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  7245. }
  7246. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7247. if patientPrescription.ID == 0 {
  7248. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7249. }
  7250. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7251. if patient.ID == 0 {
  7252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7253. return
  7254. }
  7255. if len(patient.IdCardNo) == 0 {
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7257. return
  7258. }
  7259. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7260. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  7261. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  7262. //就诊结算未完成,不能进行二次挂号
  7263. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  7264. if len(his) >= 1 {
  7265. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  7266. if len(his) >= 1 && order.ID == 0 {
  7267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  7268. return
  7269. }
  7270. }
  7271. //var register_log string
  7272. if config.IsOpen == 1 {
  7273. var res ResultTwo
  7274. var res10265 ResultTwo10265
  7275. var PsnNo string
  7276. var PsnCertType string
  7277. var Certno string
  7278. var PsnName string
  7279. var Gend string
  7280. var Naty string
  7281. var Brdy string
  7282. var Age float64
  7283. var infoStr string
  7284. var idetinfoStr string
  7285. var infocode int64
  7286. var verify_number string
  7287. fmt.Println(verify_number)
  7288. if miConfig.MdtrtareaAdmvs == "421300" {
  7289. psn_info, _ := service.GetPsnByPatientId(id)
  7290. PsnNo = psn_info.PsnNo
  7291. PsnCertType = psn_info.PsnCertType
  7292. Certno = psn_info.Certno
  7293. PsnName = psn_info.PsnName
  7294. Gend = psn_info.Gend
  7295. Naty = psn_info.Naty
  7296. Brdy = psn_info.Brdy
  7297. Age = psn_info.Age
  7298. infoStr = psn_info.Insuinfo
  7299. idetinfoStr = psn_info.Idetinfo
  7300. infocode = 0
  7301. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7302. psn_info, _ := service.GetPsnByPatientId(id)
  7303. PsnNo = psn_info.PsnNo
  7304. PsnCertType = psn_info.PsnCertType
  7305. Certno = psn_info.Certno
  7306. PsnName = psn_info.PsnName
  7307. Gend = psn_info.Gend
  7308. Naty = psn_info.Naty
  7309. Brdy = psn_info.Brdy
  7310. Age = psn_info.Age
  7311. infoStr = psn_info.Insuinfo
  7312. idetinfoStr = psn_info.Idetinfo
  7313. infocode = 0
  7314. verify_number = psn_info.VerifyNumber
  7315. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7316. if id_card_type == 1 {
  7317. psn_info, _ := service.GetPsnByPatientId(id)
  7318. PsnNo = psn_info.PsnNo
  7319. PsnCertType = psn_info.PsnCertType
  7320. Certno = psn_info.Certno
  7321. PsnName = psn_info.PsnName
  7322. Gend = psn_info.Gend
  7323. Naty = psn_info.Naty
  7324. Brdy = psn_info.Brdy
  7325. Age = psn_info.Age
  7326. infoStr = psn_info.Insuinfo
  7327. idetinfoStr = psn_info.Idetinfo
  7328. infocode = 0
  7329. verify_number = psn_info.VerifyNumber
  7330. } else if id_card_type == 2 {
  7331. 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, "")
  7332. fmt.Println(errMsgLog)
  7333. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7335. utils.ErrorLog("解析失败:%v", err)
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. return
  7338. }
  7339. PsnNo = res.Output.Baseinfo.PsnNo
  7340. PsnCertType = res.Output.Baseinfo.PsnCertType
  7341. Certno = res.Output.Baseinfo.Certno
  7342. PsnName = res.Output.Baseinfo.PsnName
  7343. Gend = res.Output.Baseinfo.Gend
  7344. Naty = res.Output.Baseinfo.Naty
  7345. Brdy = res.Output.Baseinfo.Brdy
  7346. Age = res.Output.Baseinfo.Age
  7347. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7348. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7349. infoStr = string(Iinfos)
  7350. idetinfoStr = string(Idetinfos)
  7351. infocode = res.Infcode
  7352. }
  7353. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7354. if id_card_type == 1 {
  7355. psn_info, _ := service.GetPsnByPatientId(id)
  7356. PsnNo = psn_info.PsnNo
  7357. PsnCertType = psn_info.PsnCertType
  7358. Certno = psn_info.Certno
  7359. PsnName = psn_info.PsnName
  7360. Gend = psn_info.Gend
  7361. Naty = psn_info.Naty
  7362. Brdy = psn_info.Brdy
  7363. Age = psn_info.Age
  7364. infoStr = psn_info.Insuinfo
  7365. idetinfoStr = psn_info.Idetinfo
  7366. infocode = 0
  7367. verify_number = psn_info.VerifyNumber
  7368. } else if id_card_type == 2 {
  7369. 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, "")
  7370. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7371. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7372. utils.ErrorLog("解析失败:%v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. PsnNo = res.Output.Baseinfo.PsnNo
  7377. PsnCertType = res.Output.Baseinfo.PsnCertType
  7378. Certno = res.Output.Baseinfo.Certno
  7379. PsnName = res.Output.Baseinfo.PsnName
  7380. Gend = res.Output.Baseinfo.Gend
  7381. Naty = res.Output.Baseinfo.Naty
  7382. Brdy = res.Output.Baseinfo.Brdy
  7383. Age = res.Output.Baseinfo.Age
  7384. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7385. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7386. infoStr = string(Iinfos)
  7387. idetinfoStr = string(Idetinfos)
  7388. infocode = res.Infcode
  7389. }
  7390. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7391. if id_card_type == 1 {
  7392. psn_info, _ := service.GetPsnByPatientId(id)
  7393. PsnNo = psn_info.PsnNo
  7394. PsnCertType = psn_info.PsnCertType
  7395. Certno = psn_info.Certno
  7396. PsnName = psn_info.PsnName
  7397. Gend = psn_info.Gend
  7398. Naty = psn_info.Naty
  7399. Brdy = psn_info.Brdy
  7400. Age = psn_info.Age
  7401. infoStr = psn_info.Insuinfo
  7402. idetinfoStr = psn_info.Idetinfo
  7403. infocode = 0
  7404. verify_number = psn_info.VerifyNumber
  7405. } else if id_card_type == 2 {
  7406. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  7407. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7408. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. return
  7412. }
  7413. PsnNo = res.Output.Baseinfo.PsnNo
  7414. PsnCertType = res.Output.Baseinfo.PsnCertType
  7415. Certno = res.Output.Baseinfo.Certno
  7416. PsnName = res.Output.Baseinfo.PsnName
  7417. Gend = res.Output.Baseinfo.Gend
  7418. Naty = res.Output.Baseinfo.Naty
  7419. Brdy = res.Output.Baseinfo.Brdy
  7420. Age = res.Output.Baseinfo.Age
  7421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7423. infoStr = string(Iinfos)
  7424. idetinfoStr = string(Idetinfos)
  7425. infocode = res.Infcode
  7426. }
  7427. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7428. var result string
  7429. var requestLog string
  7430. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  7431. if id_card_type == 4 {
  7432. psn_info, _ := service.GetPsnByPatientId(id)
  7433. PsnNo = psn_info.PsnNo
  7434. PsnCertType = psn_info.PsnCertType
  7435. Certno = psn_info.Certno
  7436. PsnName = psn_info.PsnName
  7437. Gend = psn_info.Gend
  7438. Naty = psn_info.Naty
  7439. Brdy = psn_info.Brdy
  7440. Age = psn_info.Age
  7441. infoStr = psn_info.Insuinfo
  7442. idetinfoStr = psn_info.Idetinfo
  7443. infocode = 0
  7444. verify_number = psn_info.VerifyNumber
  7445. } else {
  7446. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7447. if miConfig.Code == "H15049901371" {
  7448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7449. utils.ErrorLog("解析失败:%v", err)
  7450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. return
  7452. }
  7453. res.ErrMsg = res10265.ErrMsg
  7454. res.Output = res10265.Output
  7455. res.InfRefmsgid = res10265.InfRefmsgid
  7456. } else {
  7457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7458. utils.ErrorLog("解析失败:%v", err)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. }
  7463. PsnNo = res.Output.Baseinfo.PsnNo
  7464. PsnCertType = res.Output.Baseinfo.PsnCertType
  7465. Certno = res.Output.Baseinfo.Certno
  7466. PsnName = res.Output.Baseinfo.PsnName
  7467. Gend = res.Output.Baseinfo.Gend
  7468. Naty = res.Output.Baseinfo.Naty
  7469. Brdy = res.Output.Baseinfo.Brdy
  7470. Age = res.Output.Baseinfo.Age
  7471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7473. infoStr = string(Iinfos)
  7474. idetinfoStr = string(Idetinfos)
  7475. if miConfig.Code == "H15049901371" {
  7476. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7477. } else {
  7478. infocode = res.Infcode
  7479. }
  7480. }
  7481. } else {
  7482. var result string
  7483. var requestLog string
  7484. if miConfig.UserOrgId == 10138 {
  7485. if id_card_type != 4 || id_card_type != 2 {
  7486. var insa string
  7487. if len(patient.InsuplcAdmdvs) > 0 {
  7488. insa = patient.InsuplcAdmdvs
  7489. } else {
  7490. insa = miConfig.InsuplcAdmdvs
  7491. }
  7492. //psn_info, _ := service.GetPsnByPatientId(id)
  7493. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  7494. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  7495. }
  7496. } else {
  7497. var insa string
  7498. if len(patient.InsuplcAdmdvs) > 0 {
  7499. insa = patient.InsuplcAdmdvs
  7500. } else {
  7501. insa = miConfig.InsuplcAdmdvs
  7502. }
  7503. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  7504. }
  7505. if id_card_type == 4 || id_card_type == 1 {
  7506. psn_info, _ := service.GetPsnByPatientId(id)
  7507. PsnNo = psn_info.PsnNo
  7508. PsnCertType = psn_info.PsnCertType
  7509. Certno = psn_info.Certno
  7510. PsnName = psn_info.PsnName
  7511. Gend = psn_info.Gend
  7512. Naty = psn_info.Naty
  7513. Brdy = psn_info.Brdy
  7514. Age = psn_info.Age
  7515. infoStr = psn_info.Insuinfo
  7516. idetinfoStr = psn_info.Idetinfo
  7517. infocode = 0
  7518. verify_number = psn_info.VerifyNumber
  7519. } else {
  7520. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7521. if miConfig.Code == "H15049901371" {
  7522. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7523. utils.ErrorLog("解析失败:%v", err)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. res.ErrMsg = res10265.ErrMsg
  7528. res.Output = res10265.Output
  7529. res.InfRefmsgid = res10265.InfRefmsgid
  7530. } else {
  7531. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7532. utils.ErrorLog("解析失败:%v", err)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. }
  7537. PsnNo = res.Output.Baseinfo.PsnNo
  7538. PsnCertType = res.Output.Baseinfo.PsnCertType
  7539. Certno = res.Output.Baseinfo.Certno
  7540. PsnName = res.Output.Baseinfo.PsnName
  7541. Gend = res.Output.Baseinfo.Gend
  7542. Naty = res.Output.Baseinfo.Naty
  7543. Brdy = res.Output.Baseinfo.Brdy
  7544. Age = res.Output.Baseinfo.Age
  7545. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7546. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7547. infoStr = string(Iinfos)
  7548. idetinfoStr = string(Idetinfos)
  7549. if miConfig.Code == "H15049901371" {
  7550. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7551. } else {
  7552. infocode = res.Infcode
  7553. }
  7554. }
  7555. }
  7556. if infocode == 0 {
  7557. his := models.VMHisPatient{
  7558. Name: name,
  7559. Gender: gender,
  7560. Birthday: birthUnix,
  7561. MedicalTreatmentType: medical_care,
  7562. IdType: certificates,
  7563. IdCardNo: id_card,
  7564. BalanceAccountsType: settlementValue,
  7565. SocialType: social_type,
  7566. MedicalInsuranceNumber: medical_insurance_card,
  7567. RegisterType: register_type,
  7568. RegisterCost: registration_fee,
  7569. TreatmentCost: medical_expenses,
  7570. Status: 1,
  7571. Ctime: time.Now().Unix(),
  7572. Mtime: time.Now().Unix(),
  7573. PsnNo: PsnNo,
  7574. PsnCertType: PsnCertType,
  7575. Certno: Certno,
  7576. PsnName: PsnName,
  7577. Gend: Gend,
  7578. Naty: Naty,
  7579. Brdy: Brdy,
  7580. Age: Age,
  7581. Iinfo: infoStr,
  7582. Idetinfo: idetinfoStr,
  7583. PatientId: patient.ID,
  7584. RecordDate: theTime.Unix(),
  7585. UserOrgId: adminInfo.CurrentOrgId,
  7586. AdminUserId: admin_user_id,
  7587. IsReturn: 1,
  7588. IdCardType: id_card_type,
  7589. Doctor: doctor,
  7590. Departments: department,
  7591. MdtrtGrpType: mdtrt_type,
  7592. }
  7593. timestamp := time.Now().Unix()
  7594. tempTime := time.Unix(timestamp, 0)
  7595. timeFormat := tempTime.Format("20060102150405")
  7596. chrgBchno := rand.Intn(100000) + 10000
  7597. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7598. his.Number = ipt_otp_no
  7599. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  7600. department, _ := service.GetDepartMentDetail(department)
  7601. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  7602. IdCardNo := ""
  7603. if id_card_type == 1 {
  7604. // IdCardNo = medical_insurance_card
  7605. IdCardNo = patient.IdCardNo
  7606. } else {
  7607. IdCardNo = patient.IdCardNo
  7608. }
  7609. var rf []*ResultFive
  7610. json.Unmarshal([]byte(his.Iinfo), &rf)
  7611. var insutypes []*ResultFive
  7612. var insutype string
  7613. var insuplc_admdvs_temp string
  7614. var is390 int = 0
  7615. var is310 int = 0
  7616. for _, item := range rf {
  7617. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7618. insutypes = append(insutypes, item)
  7619. }
  7620. }
  7621. if len(insutypes) == 1 {
  7622. insutype = insutypes[0].Insutype
  7623. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7624. } else {
  7625. for _, i := range insutypes {
  7626. if i.Insutype == "390" {
  7627. is390 = 1
  7628. }
  7629. if i.Insutype == "310" {
  7630. is310 = 1
  7631. }
  7632. }
  7633. }
  7634. if is390 == 1 {
  7635. insutype = "390"
  7636. }
  7637. if is310 == 1 {
  7638. insutype = "310"
  7639. }
  7640. if len(insutypes) == 0 {
  7641. insutype = "390"
  7642. }
  7643. if len(insutypes) == 2 {
  7644. insutype = med_type
  7645. }
  7646. if len(med_type) > 0 {
  7647. insutype = med_type
  7648. }
  7649. var infocode int64
  7650. var resThree ResultThree
  7651. var resThree10265 ResultThree10265
  7652. if len(insuplc_admdvs) == 0 {
  7653. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  7654. } else {
  7655. insuplc_admdvs_temp = insuplc_admdvs
  7656. }
  7657. if miConfig.MdtrtareaAdmvs == "350500" {
  7658. var rf []*ResultIDInfo
  7659. json.Unmarshal([]byte(idetinfoStr), &rf)
  7660. if len(rf) > 0 {
  7661. if len(rf[0].Memo) > 0 {
  7662. content := rf[0].Memo[1:len(rf[0].Memo)]
  7663. content2 := content[:len(content)-1]
  7664. fmt.Println(content2)
  7665. //var rf2 ResultMemo
  7666. //json.Unmarshal([]byte(content2), &rf2)
  7667. //fmt.Println(rf2)
  7668. //fmt.Println(rf2.InsuAdmdvs)
  7669. arr := strings.Split(content2, ",")
  7670. var tarstring string
  7671. for _, item := range arr {
  7672. if find := strings.Contains(item, "insuAdmdvs"); find {
  7673. tarstring = item
  7674. }
  7675. }
  7676. fmt.Println(tarstring)
  7677. if len(tarstring) > 0 {
  7678. arr := strings.Split(tarstring, ":")
  7679. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  7680. //insuplc_admdvs_temp = arr[1]
  7681. }
  7682. }
  7683. }
  7684. }
  7685. if miConfig.MdtrtareaAdmvs == "421300" {
  7686. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  7687. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  7688. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7689. "&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
  7690. resp, requestErr := http.Get(api)
  7691. if requestErr != nil {
  7692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7693. return
  7694. }
  7695. body, ioErr := ioutil.ReadAll(resp.Body)
  7696. if ioErr != nil {
  7697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7699. return
  7700. }
  7701. var respJSON map[string]interface{}
  7702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. return
  7706. }
  7707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7708. result, _ := json.Marshal(respJSON)
  7709. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7710. utils.ErrorLog("解析失败:%v", err)
  7711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7712. return
  7713. }
  7714. infocode = resThree.Infcode
  7715. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7716. psn_info, _ := service.GetPsnByPatientId(id)
  7717. his.PsnNo = psn_info.PsnNo
  7718. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7719. var cert_no string
  7720. if id_card_type == 3 {
  7721. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7722. cert_no = IdCardNo
  7723. } else if id_card_type == 4 {
  7724. cert_no = IdCardNo
  7725. psn_info.VerifyNumber = psn_info.VerifyNumber
  7726. } else {
  7727. bas := strings.Split(psn_info.CardInfo, "|")
  7728. cert_no = bas[2]
  7729. }
  7730. var hisPrescription []*models.HisPrescription
  7731. for _, item := range rf {
  7732. if item.Insutype == insutype {
  7733. //insuplc_admdvs = item.InsuplcAdmdvs
  7734. his.InsuplcAdmdvs = insuplc_admdvs
  7735. }
  7736. }
  7737. his.Insutype = insutype
  7738. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7739. fmt.Println(res3101)
  7740. fmt.Println(res3101.Infcode)
  7741. if res3101.Infcode == "0" {
  7742. fmt.Println("33333333")
  7743. if len(res3101.Output.Result) > 0 {
  7744. fmt.Println("222222")
  7745. for _, item := range res3101.Output.Result {
  7746. if len(res3101.ErrMsg) == 0 {
  7747. res3101.ErrMsg = item.VolaCont
  7748. } else {
  7749. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7750. }
  7751. }
  7752. c.ServeSuccessJSON(map[string]interface{}{
  7753. "failed_code": -10,
  7754. "msg": res3101.ErrMsg,
  7755. })
  7756. return
  7757. } else {
  7758. fmt.Println("11111")
  7759. var api string
  7760. if miConfig.MdtrtareaAdmvs == "320921" {
  7761. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7762. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7763. "&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
  7764. } else {
  7765. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7766. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7767. "&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
  7768. }
  7769. resp, requestErr := http.Get(api)
  7770. if requestErr != nil {
  7771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7772. return
  7773. }
  7774. body, ioErr := ioutil.ReadAll(resp.Body)
  7775. if ioErr != nil {
  7776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. return
  7779. }
  7780. var respJSON map[string]interface{}
  7781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. return
  7785. }
  7786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7787. result, _ := json.Marshal(respJSON)
  7788. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7789. utils.ErrorLog("解析失败:%v", err)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. resThree.ErrMsg = resThree10265.ErrMsg
  7794. resThree.Output = resThree10265.Output
  7795. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7796. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7797. }
  7798. } else if res3101.Infcode != "0" {
  7799. c.ServeSuccessJSON(map[string]interface{}{
  7800. "failed_code": -10,
  7801. "msg": res3101.ErrMsg,
  7802. })
  7803. return
  7804. }
  7805. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7806. psn_info, _ := service.GetPsnByPatientId(id)
  7807. var cert_no string
  7808. if id_card_type == 1 {
  7809. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7810. } else if id_card_type == 4 {
  7811. cert_no = psn_info.VerifyNumber
  7812. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7813. } else {
  7814. cert_no = psn_info.VerifyNumber
  7815. }
  7816. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  7817. saveLog(result, requestLog, "2201", "挂号")
  7818. if miConfig.Code == "H15049901371" {
  7819. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7820. utils.ErrorLog("解析失败:%v", err)
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7822. return
  7823. }
  7824. resThree.ErrMsg = resThree10265.ErrMsg
  7825. resThree.Output = resThree10265.Output
  7826. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7827. } else {
  7828. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. }
  7834. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7835. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7836. psn_info, _ := service.GetPsnByPatientId(id)
  7837. var result string
  7838. var requestLog string
  7839. if id_card_type == 1 {
  7840. bas := strings.Split(psn_info.CardInfo, "|")
  7841. basNumber := bas[2]
  7842. card_sn := bas[3]
  7843. 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)
  7844. saveLog(result, requestLog, "2201A", "挂号")
  7845. } else if id_card_type == 2 {
  7846. 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, "", "")
  7847. saveLog(result, requestLog, "2201A", "挂号")
  7848. } else {
  7849. 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, "", "")
  7850. saveLog(result, requestLog, "2201A", "挂号")
  7851. }
  7852. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7853. utils.ErrorLog("解析失败:%v", err)
  7854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7855. return
  7856. }
  7857. infocode = resThree.Infcode
  7858. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7859. psn_info, _ := service.GetPsnByPatientId(id)
  7860. var result string
  7861. var requestLog string
  7862. if id_card_type == 1 {
  7863. bas := strings.Split(psn_info.CardInfo, "|")
  7864. basNumber := bas[2]
  7865. card_sn := bas[3]
  7866. 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)
  7867. saveLog(result, requestLog, "2201A", "挂号")
  7868. } else if id_card_type == 2 {
  7869. 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, "", "")
  7870. saveLog(result, requestLog, "2201A", "挂号")
  7871. } else {
  7872. 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, "", "")
  7873. saveLog(result, requestLog, "2201A", "挂号")
  7874. }
  7875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7876. utils.ErrorLog("解析失败:%v", err)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. infocode = resThree.Infcode
  7881. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7882. psn_info, _ := service.GetPsnByPatientId(id)
  7883. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  7884. saveLog(result, requestLog, "2201A", "挂号")
  7885. if miConfig.Code == "H15049901371" {
  7886. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7887. utils.ErrorLog("解析失败:%v", err)
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. return
  7890. }
  7891. resThree.ErrMsg = resThree10265.ErrMsg
  7892. resThree.Output = resThree10265.Output
  7893. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7894. } else {
  7895. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7896. utils.ErrorLog("解析失败:%v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. }
  7901. if miConfig.Code == "H15049901371" {
  7902. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7903. } else {
  7904. infocode = resThree.Infcode
  7905. }
  7906. } else {
  7907. psn_info, _ := service.GetPsnByPatientId(id)
  7908. if id_card_type == 4 || id_card_type == 1 {
  7909. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7910. }
  7911. 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)
  7912. saveLog(result, requestLog, "2201A", "挂号")
  7913. if miConfig.Code == "H15049901371" {
  7914. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7915. utils.ErrorLog("解析失败:%v", err)
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. resThree.ErrMsg = resThree10265.ErrMsg
  7920. resThree.Output = resThree10265.Output
  7921. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7922. } else {
  7923. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7924. utils.ErrorLog("解析失败:%v", err)
  7925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. return
  7927. }
  7928. }
  7929. if miConfig.Code == "H15049901371" {
  7930. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7931. } else {
  7932. infocode = resThree.Infcode
  7933. }
  7934. }
  7935. if infocode != 0 {
  7936. adminUser := c.GetAdminUserInfo()
  7937. errlog := &models.HisOrderError{
  7938. UserOrgId: adminUser.CurrentOrgId,
  7939. Ctime: time.Now().Unix(),
  7940. Mtime: time.Now().Unix(),
  7941. ErrMsg: resThree.ErrMsg,
  7942. Status: 1,
  7943. PatientId: id,
  7944. RecordTime: recordDateTime,
  7945. Stage: 2,
  7946. }
  7947. service.CreateErrMsgLog(errlog)
  7948. c.ServeSuccessJSON(map[string]interface{}{
  7949. "failed_code": -10,
  7950. "msg": resThree.ErrMsg,
  7951. })
  7952. return
  7953. }
  7954. his.Number = resThree.Output.Data.MdtrtID
  7955. his.PsnNo = resThree.Output.Data.PsnNo
  7956. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7957. his.IdCardNo = patient.IdCardNo
  7958. his.PhoneNumber = patient.Phone
  7959. his.UserOrgId = adminInfo.CurrentOrgId
  7960. his.Insutype = insutype
  7961. his.Ctime = time.Now().Unix()
  7962. his.Mtime = time.Now().Unix()
  7963. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7964. his.Status = 1
  7965. his.MdtrtGrpType = mdtrt_type
  7966. service.UpdateHisPatientStatus(&his)
  7967. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7968. c.ServeSuccessJSON(map[string]interface{}{
  7969. "his_info": his,
  7970. })
  7971. } else {
  7972. adminUser := c.GetAdminUserInfo()
  7973. errlog := &models.HisOrderError{
  7974. UserOrgId: adminUser.CurrentOrgId,
  7975. Ctime: time.Now().Unix(),
  7976. Mtime: time.Now().Unix(),
  7977. ErrMsg: res.ErrMsg,
  7978. Status: 1,
  7979. PatientId: id,
  7980. RecordTime: recordDateTime,
  7981. Stage: 1,
  7982. }
  7983. service.CreateErrMsgLog(errlog)
  7984. c.ServeSuccessJSON(map[string]interface{}{
  7985. "failed_code": -10,
  7986. "msg": res.ErrMsg,
  7987. })
  7988. return
  7989. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7990. }
  7991. }
  7992. }
  7993. //
  7994. func (c *HisApiController) GetUploadInfo() {
  7995. id, _ := c.GetInt64("id")
  7996. record_time := c.GetString("record_time")
  7997. his_patient_id, _ := c.GetInt64("his_patient_id")
  7998. order_id, _ := c.GetInt64("order_id")
  7999. pay_way, _ := c.GetInt64("pay_way")
  8000. pay_ways := c.GetString("pay_ways")
  8001. oth_desc := c.GetString("oth_desc")
  8002. pay_price, _ := c.GetFloat("pay_price")
  8003. pay_card_no := c.GetString("pay_card_no")
  8004. discount_price, _ := c.GetFloat("discount_price")
  8005. preferential_price, _ := c.GetFloat("preferential_price")
  8006. reality_price, _ := c.GetFloat("reality_price")
  8007. found_price, _ := c.GetFloat("found_price")
  8008. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  8009. private_price, _ := c.GetFloat("private_price")
  8010. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8011. admin_user_id, _ := c.GetInt64("admin_user_id")
  8012. fapiao_code := c.GetString("fapiao_code")
  8013. fapiao_number := c.GetString("fapiao_number")
  8014. diagnosis_id := c.GetString("diagnosis")
  8015. sick_type, _ := c.GetInt64("sick_type")
  8016. reg_type, _ := c.GetInt64("p_type")
  8017. begin_time := c.GetString("begin_time")
  8018. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  8019. cash_pay := c.GetString("cash_pay")
  8020. band_card_pay := c.GetString("band_card_pay")
  8021. wechat_pay := c.GetString("wechat_pay")
  8022. ali_pay := c.GetString("ali_pay")
  8023. jifen_pay := c.GetString("jifen_pay")
  8024. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  8025. fmt.Println(acct_used_flag)
  8026. id_str := c.GetString("ids")
  8027. ids_arr := strings.Split(id_str, ",")
  8028. timeLayout := "2006-01-02"
  8029. loc, _ := time.LoadLocation("Local")
  8030. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8031. if err != nil {
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8033. return
  8034. }
  8035. recordDateTime := theTime.Unix()
  8036. adminUser := c.GetAdminUserInfo()
  8037. var tempOrder models.HisOrder
  8038. tempOrder, _ = service.GetHisOrderByID(order_id)
  8039. var prescriptions []*models.HisPrescription
  8040. var start_time int64
  8041. var end_time int64
  8042. //押金模块
  8043. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  8044. tmp_decimal := c.GetString("tmp_decimal")
  8045. var decimal float64 //本次使用的押金
  8046. var errmsg error
  8047. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  8048. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  8049. return
  8050. }
  8051. if len(tmp_decimal) > 0 {
  8052. if tmp_decimal[0] == 45 {
  8053. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  8054. return
  8055. }
  8056. }
  8057. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  8058. fmt.Println(errs)
  8059. decimal = tt
  8060. //if adminUser.CurrentOrgId == 10106{
  8061. // if len(fapiao_code) == 0{
  8062. // fapiao_code = "144072080589"
  8063. // }
  8064. // if len(fapiao_number) == 0{
  8065. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  8066. // if order.ID == 0{
  8067. // fapiao_number = "00001520"
  8068. // }else{
  8069. // //fapiao_code = "00001520"
  8070. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  8071. // var zero string
  8072. // if fpNumber >= 1000{
  8073. // zero = "0000" + strconv.Itoa(fpNumber)
  8074. // }else if fpNumber >= 10000{
  8075. // zero = "000" + strconv.Itoa(fpNumber)
  8076. // } else if fpNumber >= 100000{
  8077. // zero = "00" + strconv.Itoa(fpNumber)
  8078. // } else if fpNumber >= 1000000{
  8079. // zero = "0" + strconv.Itoa(fpNumber)
  8080. // }else {
  8081. // zero = strconv.Itoa(fpNumber)
  8082. // }
  8083. // fapiao_number = zero
  8084. // }
  8085. // }
  8086. //}
  8087. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8088. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8089. var patientPrescription models.HisPrescriptionInfo
  8090. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8091. if patientPrescription.ID == 0 {
  8092. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8093. }
  8094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8095. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8096. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8097. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8098. var config []*models.HisXtDiagnoseConfig
  8099. for _, item := range diagnosis_ids {
  8100. id, _ := strconv.ParseInt(item, 10, 64)
  8101. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8102. config = append(config, &diagnosisConfig)
  8103. }
  8104. sickConfig, _ := service.FindSickById(sick_type)
  8105. //if tempOrder.ID == 0 {
  8106. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  8107. //}
  8108. if tempOrder.ID == 0 {
  8109. var result string
  8110. var requestLog string
  8111. var res2 ResultSix
  8112. var ressix10265 ResultSix10265
  8113. if miConfig.MdtrtareaAdmvs == "421300" {
  8114. data := make(map[string]interface{})
  8115. client := &http.Client{}
  8116. data["psn_no"] = his.PsnNo
  8117. data["mdtrt_id"] = his.Number
  8118. data["opter"] = roles.UserName
  8119. data["org_name"] = miConfig.OrgName
  8120. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8121. data["doctor_id"] = doctor_info.DoctorNumber
  8122. data["doctor_name"] = doctor_info.UserName
  8123. data["department"] = department.Name
  8124. data["fixmedins_code"] = miConfig.Code
  8125. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8127. data["secret_key"] = miConfig.SecretKey
  8128. data["sick_code"] = sickConfig.CountryCode
  8129. data["sick_name"] = sickConfig.ClassName
  8130. data["dept"] = strconv.FormatInt(department.ID, 10)
  8131. data["config"] = config
  8132. data["begin_time"] = begin_time
  8133. bytesData, _ := json.Marshal(data)
  8134. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8135. resp, _ := client.Do(req)
  8136. defer resp.Body.Close()
  8137. body, ioErr := ioutil.ReadAll(resp.Body)
  8138. if ioErr != nil {
  8139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. var respJSON map[string]interface{}
  8144. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8150. userJSONBytes, _ := json.Marshal(respJSON)
  8151. fmt.Println("log")
  8152. fmt.Println(string(userJSONBytes))
  8153. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8154. utils.ErrorLog("解析失败:%v", err)
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8159. data := make(map[string]interface{})
  8160. client := &http.Client{}
  8161. data["psn_no"] = his.PsnNo
  8162. data["mdtrt_id"] = his.Number
  8163. data["doctor"] = roles.UserName
  8164. data["department"] = department.Name
  8165. data["org_name"] = miConfig.OrgName
  8166. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8167. data["doctor_id"] = doctor_info.DoctorNumber
  8168. data["new_doctor_name"] = doctor_info.UserName
  8169. data["fixmedins_code"] = miConfig.Code
  8170. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8171. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8172. data["secret_key"] = miConfig.SecretKey
  8173. data["sick_code"] = sickConfig.CountryCode
  8174. data["sick_name"] = sickConfig.ClassName
  8175. data["url"] = miConfig.Url
  8176. data["ak"] = miConfig.AccessKey
  8177. data["begin_time"] = begin_time
  8178. data["cainfo"] = miConfig.Cainfo
  8179. data["dept"] = strconv.FormatInt(department.ID, 10)
  8180. data["config"] = config
  8181. bytesData, _ := json.Marshal(data)
  8182. var req *http.Request
  8183. if miConfig.MdtrtareaAdmvs == "320921" {
  8184. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8185. //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 +
  8186. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  8187. } else {
  8188. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8189. }
  8190. resp, _ := client.Do(req)
  8191. defer resp.Body.Close()
  8192. body, ioErr := ioutil.ReadAll(resp.Body)
  8193. if ioErr != nil {
  8194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. var respJSON map[string]interface{}
  8199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8205. userJSONBytes, _ := json.Marshal(respJSON)
  8206. fmt.Println("log")
  8207. fmt.Println(string(userJSONBytes))
  8208. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  8209. utils.ErrorLog("解析失败:%v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8214. res2.Output = ressix10265.Output
  8215. res2.ErrMsg = ressix10265.ErrMsg
  8216. res2.Cainfo = ressix10265.Cainfo
  8217. res2.WarnMsg = ressix10265.WarnMsg
  8218. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8219. res2.Infcode = infocode
  8220. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8221. 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)
  8222. saveLog(result, requestLog, "2203", "上传就诊信息")
  8223. var respJSON2 map[string]interface{}
  8224. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. userJSONBytes2, _ := json.Marshal(respJSON2)
  8230. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8231. utils.ErrorLog("解析失败:%v", err)
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8233. return
  8234. }
  8235. } else {
  8236. if miConfig.MdtrtareaAdmvs == "440781" { //
  8237. 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)
  8238. } else {
  8239. if miConfig.Code == "H15049901371" {
  8240. //赤峰地区国家医保医疗类别
  8241. //职工透析:医疗类别选特殊情况门诊990502
  8242. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8243. var med_type string
  8244. if his.Insutype == "390" {
  8245. if reg_type == 14 {
  8246. med_type = "9933"
  8247. } else if reg_type == 11 {
  8248. med_type = "11"
  8249. }
  8250. } else if his.Insutype == "310" {
  8251. if reg_type == 14 {
  8252. med_type = "990502"
  8253. } else if reg_type == 11 {
  8254. med_type = "11"
  8255. }
  8256. }
  8257. 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)
  8258. } else {
  8259. 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)
  8260. }
  8261. }
  8262. saveLog(result, requestLog, "2203", "上传就诊信息")
  8263. var respJSON2 map[string]interface{}
  8264. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. return
  8268. }
  8269. userJSONBytes2, _ := json.Marshal(respJSON2)
  8270. if miConfig.Code == "H15049901371" {
  8271. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  8272. utils.ErrorLog("解析失败:%v", err)
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8277. res2.Output = ressix10265.Output
  8278. res2.ErrMsg = ressix10265.ErrMsg
  8279. res2.Cainfo = ressix10265.Cainfo
  8280. res2.WarnMsg = ressix10265.WarnMsg
  8281. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8282. res2.Infcode = infocode
  8283. } else {
  8284. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8285. utils.ErrorLog("解析失败:%v", err)
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8287. return
  8288. }
  8289. }
  8290. }
  8291. if res2.Infcode != 0 {
  8292. adminUser := c.GetAdminUserInfo()
  8293. errlog := &models.HisOrderError{
  8294. UserOrgId: adminUser.CurrentOrgId,
  8295. Ctime: time.Now().Unix(),
  8296. Mtime: time.Now().Unix(),
  8297. ErrMsg: res2.ErrMsg,
  8298. Status: 1,
  8299. PatientId: id,
  8300. RecordTime: recordDateTime,
  8301. Stage: 3,
  8302. }
  8303. service.CreateErrMsgLog(errlog)
  8304. c.ServeSuccessJSON(map[string]interface{}{
  8305. "failed_code": -10,
  8306. "msg": res2.ErrMsg,
  8307. })
  8308. return
  8309. } else {
  8310. his.Diagnosis = diagnosis_id
  8311. his.SickType = sickConfig.ID
  8312. //var p_type int64
  8313. //if reg_type == 1111 || reg_type == 1112 {
  8314. // p_type = 11
  8315. //
  8316. //}
  8317. his.PType = fmt.Sprintf("%d", reg_type)
  8318. service.UpdateHisPatientThree(&his)
  8319. data := make(map[string]interface{})
  8320. if settle_accounts_type == 1 { //日结
  8321. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  8322. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  8323. } else {
  8324. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  8325. }
  8326. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  8327. data["pre"] = prescriptions
  8328. } else { //月结
  8329. start_time_str := c.GetString("start_time")
  8330. end_time_str := c.GetString("end_time")
  8331. timeLayout := "2006-01-02"
  8332. loc, _ := time.LoadLocation("Local")
  8333. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8334. if err != nil {
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8336. return
  8337. }
  8338. recordStartTime := theStartTime.Unix()
  8339. start_time = recordStartTime
  8340. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8341. if err != nil {
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8343. return
  8344. }
  8345. recordEndTime := theEndTime.Unix()
  8346. end_time = recordEndTime
  8347. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8348. data["pre"] = prescriptions
  8349. }
  8350. timestamp := time.Now().Unix()
  8351. tempTime := time.Unix(timestamp, 0)
  8352. timeFormat := tempTime.Format("20060102150405")
  8353. chrgBchno := rand.Intn(100000) + 10000
  8354. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8355. strconv.FormatInt(his.PatientId, 10)
  8356. client := &http.Client{}
  8357. data["psn_no"] = his.PsnNo
  8358. data["mdtrt_id"] = his.Number
  8359. data["chrg_bchno"] = chrg_bchno
  8360. data["org_name"] = miConfig.OrgName
  8361. data["doctor"] = doctor_info.UserName
  8362. data["doctor_id"] = doctor_info.DoctorNumber
  8363. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8364. data["fixmedins_code"] = miConfig.Code
  8365. data["opter"] = roles.UserName
  8366. data["dept_code"] = department.Number
  8367. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8368. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8369. data["secret_key"] = miConfig.SecretKey
  8370. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8371. data["url"] = miConfig.Url
  8372. data["ak"] = miConfig.AccessKey
  8373. data["new_doctor_name"] = patientPrescription.Doctor
  8374. data["diag_code"] = sickConfig.CountryCode
  8375. data["cainfo"] = miConfig.Cainfo
  8376. data["opter"] = roles.UserName
  8377. var ids []int64
  8378. for _, item := range prescriptions {
  8379. ids = append(ids, item.ID)
  8380. }
  8381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8382. if config.IsOpen == 1 { //对接了医保,走医保流程
  8383. var res ResultFour
  8384. var resFour10265 ResultFour10265
  8385. if miConfig.MdtrtareaAdmvs == "421300" {
  8386. bytesData, _ := json.Marshal(data)
  8387. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8388. resp, _ := client.Do(req)
  8389. defer resp.Body.Close()
  8390. body, ioErr := ioutil.ReadAll(resp.Body)
  8391. if ioErr != nil {
  8392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. return
  8395. }
  8396. var respJSON map[string]interface{}
  8397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8400. return
  8401. }
  8402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8403. userJSONBytes, _ := json.Marshal(respJSON)
  8404. fmt.Println("log")
  8405. fmt.Println(string(userJSONBytes))
  8406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8407. utils.ErrorLog("解析失败:%v", err)
  8408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8409. return
  8410. }
  8411. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8412. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8413. if result3101.Infcode == "0" {
  8414. if len(result3101.Output.Result) > 0 {
  8415. var errMsgs []string
  8416. for _, item := range result3101.Output.Result {
  8417. errMsgs = append(errMsgs, item.VolaCont)
  8418. }
  8419. c.ServeSuccessJSON(map[string]interface{}{
  8420. "failed_code": -10,
  8421. "msg": errMsgs,
  8422. })
  8423. return
  8424. }
  8425. }
  8426. if miConfig.MdtrtareaAdmvs == "320921" {
  8427. data["doctor_id"] = "D320923012139"
  8428. } else {
  8429. data["doctor_id"] = "D371621008686"
  8430. }
  8431. bytesData, _ := json.Marshal(data)
  8432. var req *http.Request
  8433. if miConfig.MdtrtareaAdmvs == "320921" {
  8434. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8435. } else {
  8436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8437. }
  8438. resp, _ := client.Do(req)
  8439. defer resp.Body.Close()
  8440. body, ioErr := ioutil.ReadAll(resp.Body)
  8441. if ioErr != nil {
  8442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. var respJSON map[string]interface{}
  8447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8450. return
  8451. }
  8452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8453. userJSONBytes, _ := json.Marshal(respJSON)
  8454. fmt.Println("log")
  8455. fmt.Println(string(userJSONBytes))
  8456. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8457. utils.ErrorLog("解析失败:%v", err)
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. return
  8460. }
  8461. res.InfRefmsgid = resFour10265.InfRefmsgid
  8462. res.Output = resFour10265.Output
  8463. res.ErrMsg = resFour10265.ErrMsg
  8464. res.Cainfo = resFour10265.Cainfo
  8465. res.WarnMsg = resFour10265.WarnMsg
  8466. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8467. res.Infcode = infocode
  8468. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8469. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  8470. var dat map[string]interface{}
  8471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8472. fmt.Println(dat)
  8473. } else {
  8474. fmt.Println(err)
  8475. }
  8476. saveLog(result, request_log, "2204", "上传费用明细")
  8477. userJSONBytes, _ := json.Marshal(dat)
  8478. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8479. utils.ErrorLog("解析失败:%v", err)
  8480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. return
  8482. }
  8483. res.InfRefmsgid = resFour10265.InfRefmsgid
  8484. res.Output = resFour10265.Output
  8485. res.ErrMsg = resFour10265.ErrMsg
  8486. res.Cainfo = resFour10265.Cainfo
  8487. res.WarnMsg = resFour10265.WarnMsg
  8488. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8489. res.Infcode = infocode
  8490. } else {
  8491. if miConfig.Code == "H15049901371" {
  8492. 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)
  8493. var dat map[string]interface{}
  8494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8495. fmt.Println(dat)
  8496. } else {
  8497. fmt.Println(err)
  8498. }
  8499. saveLog(result, request_log, "2204", "上传费用明细")
  8500. userJSONBytes, _ := json.Marshal(dat)
  8501. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8502. utils.ErrorLog("解析失败:%v", err)
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8504. return
  8505. }
  8506. res.InfRefmsgid = resFour10265.InfRefmsgid
  8507. res.Output = resFour10265.Output
  8508. res.ErrMsg = resFour10265.ErrMsg
  8509. res.Cainfo = resFour10265.Cainfo
  8510. res.WarnMsg = resFour10265.WarnMsg
  8511. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8512. res.Infcode = infocode
  8513. } else {
  8514. 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)
  8515. var dat map[string]interface{}
  8516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8517. fmt.Println(dat)
  8518. } else {
  8519. fmt.Println(err)
  8520. }
  8521. saveLog(result, request_log, "2204", "上传费用明细")
  8522. userJSONBytes, _ := json.Marshal(dat)
  8523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. }
  8529. }
  8530. if res.Infcode == 0 {
  8531. order := &models.HisOrder{
  8532. UserOrgId: adminUser.CurrentOrgId,
  8533. HisPatientId: his.ID,
  8534. PatientId: his.PatientId,
  8535. SettleAccountsDate: recordDateTime,
  8536. MdtrtId: his.Number,
  8537. PsnNo: his.PsnNo,
  8538. MedType: strconv.FormatInt(reg_type, 10),
  8539. Ctime: time.Now().Unix(),
  8540. Mtime: time.Now().Unix(),
  8541. Status: 1,
  8542. Number: chrg_bchno,
  8543. Infcode: res.Infcode,
  8544. WarnMsg: res.WarnMsg,
  8545. Cainfo: res.Cainfo,
  8546. ErrMsg: res.ErrMsg,
  8547. RespondTime: res.RefmsgTime,
  8548. InfRefmsgid: res.InfRefmsgid,
  8549. OrderStatus: 1,
  8550. PayWay: pay_way,
  8551. PayWays: pay_ways,
  8552. OthDesc: oth_desc,
  8553. PayPrice: pay_price,
  8554. PayCardNo: pay_card_no,
  8555. DiscountPrice: discount_price,
  8556. PreferentialPrice: preferential_price,
  8557. RealityPrice: reality_price,
  8558. FoundPrice: found_price,
  8559. MedicalInsurancePrice: medical_insurance_price,
  8560. PrivatePrice: private_price,
  8561. IsMedicineInsurance: 1,
  8562. SettleType: settle_accounts_type,
  8563. SettleStartTime: start_time,
  8564. SettleEndTime: end_time,
  8565. Creator: roles.AdminUserId,
  8566. Modify: roles.AdminUserId,
  8567. FaPiaoNumber: fapiao_number,
  8568. FaPiaoCode: fapiao_code,
  8569. PType: 2,
  8570. Diagnosis: diagnosis_id,
  8571. CashPay: cash_pay,
  8572. WechatPay: wechat_pay,
  8573. AliPay: ali_pay,
  8574. JifenPay: jifen_pay,
  8575. BandCardPay: band_card_pay,
  8576. }
  8577. err = service.CreateOrder(order)
  8578. if err != nil {
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8580. return
  8581. }
  8582. for _, item := range res.Output.Result {
  8583. temp := strings.Split(item.FeedetlSn, "-")
  8584. var advice_id int64 = 0
  8585. var project_id int64 = 0
  8586. var types int64 = 0
  8587. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8588. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8589. if temp[1] == "1" {
  8590. advice_id = id
  8591. project_id = 0
  8592. } else if temp[1] == "2" {
  8593. advice_id = 0
  8594. project_id = id
  8595. }
  8596. if item.MedChrgitmType == "9" {
  8597. item.MedChrgitmType = "09"
  8598. }
  8599. info := &models.HisOrderInfo{
  8600. OrderNumber: order.Number,
  8601. FeedetlSn: item.FeedetlSn,
  8602. UploadDate: time.Now().Unix(),
  8603. AdviceId: advice_id,
  8604. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8605. Cnt: item.Cnt,
  8606. Pric: float64(item.Pric),
  8607. PatientId: his.PatientId,
  8608. PricUplmtAmt: item.PricUplmtAmt,
  8609. SelfpayProp: item.SelfpayProp,
  8610. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8611. OverlmtAmt: item.OverlmtAmt,
  8612. PreselfpayAmt: item.PreselfpayAmt,
  8613. BasMednFlag: item.BasMednFlag,
  8614. MedChrgitmType: item.MedChrgitmType,
  8615. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8616. Status: 1,
  8617. Memo: item.Memo,
  8618. Mtime: time.Now().Unix(),
  8619. InscpScpAmt: item.InscpScpAmt,
  8620. DrtReimFlag: item.DrtReimFlag,
  8621. Ctime: time.Now().Unix(),
  8622. ListSpItemFlag: item.ListSpItemFlag,
  8623. ChldMedcFlag: item.ChldMedcFlag,
  8624. LmtUsedFlag: item.LmtUsedFlag,
  8625. ChrgitmLv: item.ChrgitmLv,
  8626. UserOrgId: adminUser.CurrentOrgId,
  8627. HisPatientId: his.ID,
  8628. OrderId: order.ID,
  8629. ProjectId: project_id,
  8630. Type: types,
  8631. }
  8632. service.CreateOrderInfo(info)
  8633. }
  8634. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8635. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8636. var total float64
  8637. for _, item := range prescriptions {
  8638. if item.Type == 1 { //药品
  8639. for _, subItem := range item.HisDoctorAdviceInfo {
  8640. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8641. total_one := price * subItem.PrescribingNumber
  8642. total = total + total_one
  8643. }
  8644. }
  8645. if item.Type == 2 { //项目
  8646. for _, subItem := range item.HisPrescriptionProject {
  8647. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8648. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8649. total_one := price * cnt
  8650. total = total + total_one
  8651. }
  8652. }
  8653. }
  8654. allTotal := fmt.Sprintf("%f", total)
  8655. //if adminUser.CurrentOrgId == 9919 {
  8656. //
  8657. // allTotal = fmt.Sprintf("%.2f", total)
  8658. //
  8659. //} else {
  8660. //
  8661. // allTotal = fmt.Sprintf("%.2f", total)
  8662. //
  8663. //}
  8664. if res.Infcode == 0 {
  8665. var rf []*ResultFive
  8666. json.Unmarshal([]byte(his.Iinfo), &rf)
  8667. chrg_bchno := chrg_bchno
  8668. cert_no := his.Certno
  8669. var insutypes []string
  8670. var insutype string
  8671. var is390 int = 0
  8672. var is310 int = 0
  8673. for _, item := range rf {
  8674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8675. insutypes = append(insutypes, item.Insutype)
  8676. }
  8677. }
  8678. if len(insutypes) == 1 {
  8679. insutype = insutypes[0]
  8680. } else {
  8681. for _, i := range insutypes {
  8682. if i == "390" {
  8683. is390 = 1
  8684. }
  8685. if i == "310" {
  8686. is310 = 1
  8687. }
  8688. }
  8689. }
  8690. if is390 == 1 {
  8691. insutype = "390"
  8692. }
  8693. if is310 == 1 {
  8694. insutype = "310"
  8695. }
  8696. if len(insutypes) == 0 {
  8697. insutype = "310"
  8698. }
  8699. if len(insutypes) == 2 {
  8700. insutype = strconv.FormatInt(his.SocialType, 10)
  8701. }
  8702. insutype = strconv.FormatInt(his.SocialType, 10)
  8703. //insutype = "390"
  8704. if his.IdCardType == 1 {
  8705. // cert_no = his.MedicalInsuranceNumber
  8706. cert_no = his.Certno
  8707. } else {
  8708. cert_no = his.Certno
  8709. }
  8710. var res ResultSeven
  8711. var resSeven10265 ResultSeven10265
  8712. var src_resquest string
  8713. var result2 string
  8714. if miConfig.MdtrtareaAdmvs == "421300" {
  8715. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8716. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8717. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8718. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8719. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8720. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8721. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8722. resp, requestErr := http.Get(api)
  8723. if requestErr != nil {
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. body, ioErr := ioutil.ReadAll(resp.Body)
  8728. if ioErr != nil {
  8729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8731. return
  8732. }
  8733. var respJSON map[string]interface{}
  8734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8740. result, _ := json.Marshal(respJSON)
  8741. if miConfig.Code == "H15049901371" {
  8742. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8743. utils.ErrorLog("解析失败:%v", err)
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8745. return
  8746. }
  8747. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8748. res.Output = resSeven10265.Output
  8749. res.ErrMsg = resSeven10265.ErrMsg
  8750. res.Cainfo = resSeven10265.Cainfo
  8751. res.WarnMsg = resSeven10265.WarnMsg
  8752. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8753. res.Infcode = infocode
  8754. } else {
  8755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. }
  8761. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8762. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8763. if result3101.Infcode == "0" {
  8764. if len(result3101.Output.Result) > 0 {
  8765. var errMsgs []string
  8766. for _, item := range result3101.Output.Result {
  8767. errMsgs = append(errMsgs, item.VolaCont)
  8768. }
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "failed_code": -10,
  8771. "msg": errMsgs,
  8772. })
  8773. return
  8774. } else {
  8775. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8776. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8777. bas := strings.Split(psn_info.CardInfo, "|")
  8778. if his.IdCardType == 1 {
  8779. cert_no = bas[2]
  8780. } else if his.IdCardType == 3 {
  8781. cert_no = his.Certno
  8782. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8783. } else if his.IdCardType == 4 {
  8784. cert_no = his.Certno
  8785. psn_info.VerifyNumber = psn_info.VerifyNumber
  8786. }
  8787. var api string
  8788. if miConfig.MdtrtareaAdmvs == "320921" {
  8789. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8790. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8791. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8793. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8794. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8795. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8796. } else {
  8797. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8798. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8799. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8801. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8802. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8803. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8804. }
  8805. resp, requestErr := http.Get(api)
  8806. if requestErr != nil {
  8807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8808. return
  8809. }
  8810. body, ioErr := ioutil.ReadAll(resp.Body)
  8811. if ioErr != nil {
  8812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8814. return
  8815. }
  8816. var respJSON map[string]interface{}
  8817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8820. return
  8821. }
  8822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8823. result, _ := json.Marshal(respJSON)
  8824. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8830. res.Output = resSeven10265.Output
  8831. res.ErrMsg = resSeven10265.ErrMsg
  8832. res.Cainfo = resSeven10265.Cainfo
  8833. res.WarnMsg = resSeven10265.WarnMsg
  8834. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8835. res.Infcode = infocode
  8836. }
  8837. }
  8838. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8839. var cert_no string
  8840. if his.IdCardType == 4 {
  8841. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8842. cert_no = psn_info.VerifyNumber
  8843. 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)
  8844. } else if his.IdCardType == 1 {
  8845. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8846. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8847. 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)
  8848. }
  8849. //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)
  8850. var dat map[string]interface{}
  8851. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8852. fmt.Println(dat)
  8853. } else {
  8854. fmt.Println(err)
  8855. }
  8856. saveLog(result2, src_resquest, "2207", "结算")
  8857. userJSONBytes, _ := json.Marshal(dat)
  8858. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8859. utils.ErrorLog("解析失败:%v", err)
  8860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8861. return
  8862. }
  8863. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8864. res.Output = resSeven10265.Output
  8865. res.ErrMsg = resSeven10265.ErrMsg
  8866. res.Cainfo = resSeven10265.Cainfo
  8867. res.WarnMsg = resSeven10265.WarnMsg
  8868. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8869. res.Infcode = infocode
  8870. } else {
  8871. if miConfig.Code == "H15049901371" {
  8872. //赤峰地区国家医保医疗类别
  8873. //职工透析:医疗类别选特殊情况门诊990502
  8874. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8875. var med_type string
  8876. if his.Insutype == "390" {
  8877. if reg_type == 14 {
  8878. med_type = "9933"
  8879. } else if reg_type == 11 {
  8880. med_type = "11"
  8881. }
  8882. } else if his.Insutype == "310" {
  8883. if reg_type == 14 {
  8884. med_type = "990502"
  8885. } else if reg_type == 11 {
  8886. med_type = "11"
  8887. }
  8888. }
  8889. 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, "")
  8890. } else {
  8891. if his.IdCardType == 4 {
  8892. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8893. var token string
  8894. token = psn_info.VerifyNumber
  8895. 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)
  8896. } else {
  8897. 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, "")
  8898. }
  8899. }
  8900. //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)
  8901. var dat map[string]interface{}
  8902. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8903. fmt.Println(dat)
  8904. } else {
  8905. fmt.Println(err)
  8906. }
  8907. saveLog(result2, src_resquest, "2207", "结算")
  8908. userJSONBytes, _ := json.Marshal(dat)
  8909. if miConfig.Code == "H15049901371" {
  8910. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8911. utils.ErrorLog("解析失败:%v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8916. res.Output = resSeven10265.Output
  8917. res.ErrMsg = resSeven10265.ErrMsg
  8918. res.Cainfo = resSeven10265.Cainfo
  8919. res.WarnMsg = resSeven10265.WarnMsg
  8920. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8921. res.Infcode = infocode
  8922. } else {
  8923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8924. utils.ErrorLog("解析失败:%v", err)
  8925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8926. return
  8927. }
  8928. }
  8929. }
  8930. if res.Infcode != 0 {
  8931. errlog := &models.HisOrderError{
  8932. UserOrgId: adminUser.CurrentOrgId,
  8933. Ctime: time.Now().Unix(),
  8934. Mtime: time.Now().Unix(),
  8935. Number: chrg_bchno,
  8936. ErrMsg: res.ErrMsg,
  8937. Status: 1,
  8938. PatientId: id,
  8939. RecordTime: recordDateTime,
  8940. Stage: 6,
  8941. }
  8942. service.CreateErrMsgLog(errlog)
  8943. c.ServeSuccessJSON(map[string]interface{}{
  8944. "failed_code": -10,
  8945. "msg": res.ErrMsg,
  8946. })
  8947. return
  8948. } else {
  8949. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8950. order.OrderStatus = 2
  8951. order.Status = 1
  8952. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8953. order.SetlId = res.Output.Setlinfo.SetlID
  8954. order.PsnNo = res.Output.Setlinfo.PsnNo
  8955. order.PsnName = res.Output.Setlinfo.PsnName
  8956. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8957. order.Certno = res.Output.Setlinfo.Certno
  8958. order.Gend = res.Output.Setlinfo.Gend
  8959. order.Naty = res.Output.Setlinfo.Naty
  8960. order.Age = res.Output.Setlinfo.Age
  8961. order.Insutype = res.Output.Setlinfo.Insutype
  8962. order.PsnType = res.Output.Setlinfo.PsnType
  8963. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8964. order.SetlTime = res.Output.Setlinfo.SetlTime
  8965. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8966. if res.Output.Setlinfo.MedType == "140101" {
  8967. order.MedType = "14"
  8968. } else {
  8969. order.MedType = res.Output.Setlinfo.MedType
  8970. }
  8971. if reg_type == 1112 {
  8972. order.MedType = "1112"
  8973. }
  8974. if reg_type == 1111 {
  8975. order.MedType = "1111"
  8976. }
  8977. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8978. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8979. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8980. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8981. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8982. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8983. order.HifpPay = res.Output.Setlinfo.HifpPay
  8984. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8985. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8986. order.HifesPay = res.Output.Setlinfo.HifesPay
  8987. order.HifobPay = res.Output.Setlinfo.HifobPay
  8988. order.MafPay = res.Output.Setlinfo.MafPay
  8989. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8990. order.OthPay = res.Output.Setlinfo.OthPay
  8991. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8992. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8993. order.AcctPay = res.Output.Setlinfo.AcctPay
  8994. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8995. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8996. order.Balc = res.Output.Setlinfo.Balc
  8997. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8998. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8999. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9000. order.ClrType = res.Output.Setlinfo.ClrType
  9001. order.ClrWay = res.Output.Setlinfo.ClrWay
  9002. order.Creator = order.Creator
  9003. order.Modify = roles.AdminUserId
  9004. order.RequestLog = src_resquest
  9005. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9006. detailStr := string(setlDetail)
  9007. order.SetlDetail = detailStr
  9008. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9009. err = service.UpDateOrder(order)
  9010. if err == nil {
  9011. //判断是否使用了押金
  9012. if dec_way == "true" {
  9013. tmpstring := strconv.FormatInt(order.ID, 10)
  9014. order.Decimal = decimal
  9015. service.UpDateOrder(order)
  9016. //扣押金
  9017. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9018. if errmsg != nil {
  9019. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9020. return
  9021. }
  9022. }
  9023. c.ServeSuccessJSON(map[string]interface{}{
  9024. "msg": "结算成功",
  9025. })
  9026. } else {
  9027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9028. return
  9029. }
  9030. }
  9031. } else {
  9032. adminUser := c.GetAdminUserInfo()
  9033. errlog := &models.HisOrderError{
  9034. UserOrgId: adminUser.CurrentOrgId,
  9035. Ctime: time.Now().Unix(),
  9036. Mtime: time.Now().Unix(),
  9037. ErrMsg: res.ErrMsg,
  9038. Status: 1,
  9039. PatientId: id,
  9040. RecordTime: recordDateTime,
  9041. Stage: 4,
  9042. }
  9043. service.CreateErrMsgLog(errlog)
  9044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9045. return
  9046. }
  9047. } else {
  9048. adminUser := c.GetAdminUserInfo()
  9049. errlog := &models.HisOrderError{
  9050. UserOrgId: adminUser.CurrentOrgId,
  9051. Ctime: time.Now().Unix(),
  9052. Mtime: time.Now().Unix(),
  9053. ErrMsg: res.ErrMsg,
  9054. Status: 1,
  9055. PatientId: id,
  9056. RecordTime: recordDateTime,
  9057. Stage: 4,
  9058. }
  9059. service.CreateErrMsgLog(errlog)
  9060. c.ServeSuccessJSON(map[string]interface{}{
  9061. "failed_code": -10,
  9062. "msg": res.ErrMsg,
  9063. })
  9064. return
  9065. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9066. //return
  9067. }
  9068. }
  9069. }
  9070. } else if tempOrder.ID > 0 {
  9071. if tempOrder.IsPre == 1 {
  9072. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  9073. var rf []*ResultFive
  9074. json.Unmarshal([]byte(his.Iinfo), &rf)
  9075. chrg_bchno := tempOrder.Number
  9076. cert_no := his.Certno
  9077. var insutypes []string
  9078. var insutype string
  9079. var is390 int = 0
  9080. var is310 int = 0
  9081. for _, item := range rf {
  9082. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9083. insutypes = append(insutypes, item.Insutype)
  9084. }
  9085. }
  9086. if len(insutypes) == 1 {
  9087. insutype = insutypes[0]
  9088. } else {
  9089. for _, i := range insutypes {
  9090. if i == "390" {
  9091. is390 = 1
  9092. }
  9093. if i == "310" {
  9094. is310 = 1
  9095. }
  9096. }
  9097. }
  9098. if is390 == 1 {
  9099. insutype = "390"
  9100. }
  9101. if is310 == 1 {
  9102. insutype = "310"
  9103. }
  9104. if len(insutypes) == 0 {
  9105. insutype = "310"
  9106. }
  9107. if len(insutypes) == 2 {
  9108. insutype = strconv.FormatInt(his.SocialType, 10)
  9109. }
  9110. //insutype = "390"
  9111. if his.IdCardType == 1 {
  9112. // cert_no = his.MedicalInsuranceNumber
  9113. cert_no = his.Certno
  9114. } else {
  9115. cert_no = his.Certno
  9116. }
  9117. var res ResultSeven
  9118. var resSeven10265 ResultSeven10265
  9119. var src_resquest string
  9120. var result2 string
  9121. if miConfig.MdtrtareaAdmvs == "421300" {
  9122. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9123. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9124. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9126. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9127. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9128. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9129. resp, requestErr := http.Get(api)
  9130. if requestErr != nil {
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. body, ioErr := ioutil.ReadAll(resp.Body)
  9135. if ioErr != nil {
  9136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9138. return
  9139. }
  9140. var respJSON map[string]interface{}
  9141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9144. return
  9145. }
  9146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9147. result, _ := json.Marshal(respJSON)
  9148. fmt.Println("log")
  9149. fmt.Println(string(result))
  9150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9151. utils.ErrorLog("解析失败:%v", err)
  9152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9153. return
  9154. }
  9155. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9156. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  9157. if result3101.Infcode == "0" {
  9158. if len(result3101.Output.Result) > 0 {
  9159. var errMsgs []string
  9160. for _, item := range result3101.Output.Result {
  9161. errMsgs = append(errMsgs, item.VolaCont)
  9162. }
  9163. c.ServeSuccessJSON(map[string]interface{}{
  9164. "failed_code": -10,
  9165. "msg": errMsgs,
  9166. })
  9167. return
  9168. } else {
  9169. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9170. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9171. bas := strings.Split(psn_info.CardInfo, "|")
  9172. if his.IdCardType == 1 {
  9173. cert_no = bas[2]
  9174. } else if his.IdCardType == 3 {
  9175. cert_no = his.Certno
  9176. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9177. } else if his.IdCardType == 4 {
  9178. cert_no = his.Certno
  9179. psn_info.VerifyNumber = psn_info.VerifyNumber
  9180. }
  9181. //江苏地区国家医保医疗类别
  9182. //职工透析:医疗类别选特殊情况门诊9933
  9183. //居民血透门慢: 医疗类别选门诊慢病1402
  9184. //var med_type string
  9185. //if his.Insutype == "310" {
  9186. // if reg_type == 14 {
  9187. // med_type = "9933"
  9188. // } else if reg_type == 11 {
  9189. // med_type = "11"
  9190. //
  9191. // }
  9192. //} else if his.Insutype == "390" {
  9193. // if reg_type == 14 {
  9194. // med_type = "1402"
  9195. // } else if reg_type == 11 {
  9196. // med_type = "11"
  9197. // }
  9198. //}
  9199. var api string
  9200. if miConfig.MdtrtareaAdmvs == "320921" {
  9201. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9202. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9203. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9205. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9206. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9207. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9208. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9209. } else {
  9210. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9211. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9212. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9213. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9215. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9216. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9217. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9218. }
  9219. resp, requestErr := http.Get(api)
  9220. if requestErr != nil {
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. body, ioErr := ioutil.ReadAll(resp.Body)
  9225. if ioErr != nil {
  9226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. var respJSON map[string]interface{}
  9231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9237. result, _ := json.Marshal(respJSON)
  9238. fmt.Println("log")
  9239. fmt.Println(string(result))
  9240. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9241. utils.ErrorLog("解析失败:%v", err)
  9242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9243. return
  9244. }
  9245. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9246. res.Output = resSeven10265.Output
  9247. res.ErrMsg = resSeven10265.ErrMsg
  9248. res.Cainfo = resSeven10265.Cainfo
  9249. res.WarnMsg = resSeven10265.WarnMsg
  9250. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9251. res.Infcode = infocode
  9252. }
  9253. }
  9254. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9255. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9256. var cert_no string
  9257. if his.IdCardType == 1 {
  9258. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9259. } else {
  9260. cert_no = psn_info.VerifyNumber
  9261. }
  9262. 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)
  9263. var dat map[string]interface{}
  9264. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9265. fmt.Println(dat)
  9266. } else {
  9267. fmt.Println(err)
  9268. }
  9269. saveLog(result2, src_resquest, "2207", "结算")
  9270. userJSONBytes, _ := json.Marshal(dat)
  9271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9272. utils.ErrorLog("解析失败:%v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9277. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9278. var cert_no string
  9279. if his.IdCardType == 1 {
  9280. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9281. } else if his.IdCardType == 2 {
  9282. cert_no = his.IdCardNo
  9283. } else {
  9284. cert_no = psn_info.VerifyNumber
  9285. }
  9286. 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, "")
  9287. var dat map[string]interface{}
  9288. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9289. fmt.Println(dat)
  9290. } else {
  9291. fmt.Println(err)
  9292. }
  9293. saveLog(result2, src_resquest, "2207", "结算")
  9294. userJSONBytes, _ := json.Marshal(dat)
  9295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9296. utils.ErrorLog("解析失败:%v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9301. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9302. var cert_no string
  9303. if his.IdCardType == 1 {
  9304. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9305. } else if his.IdCardType == 2 {
  9306. cert_no = his.IdCardNo
  9307. } else {
  9308. cert_no = psn_info.VerifyNumber
  9309. }
  9310. 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, "")
  9311. var dat map[string]interface{}
  9312. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9313. fmt.Println(dat)
  9314. } else {
  9315. fmt.Println(err)
  9316. }
  9317. saveLog(result2, src_resquest, "2207", "结算")
  9318. userJSONBytes, _ := json.Marshal(dat)
  9319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9320. utils.ErrorLog("解析失败:%v", err)
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9322. return
  9323. }
  9324. } else {
  9325. var src_resquest string
  9326. if miConfig.Code == "H15049901371" {
  9327. //赤峰地区国家医保医疗类别
  9328. //职工透析:医疗类别选特殊情况门诊990502
  9329. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9330. var med_type string
  9331. if his.Insutype == "390" {
  9332. if reg_type == 14 {
  9333. med_type = "9933"
  9334. } else if reg_type == 11 {
  9335. med_type = "11"
  9336. }
  9337. } else if his.Insutype == "310" {
  9338. if reg_type == 14 {
  9339. med_type = "990502"
  9340. } else if reg_type == 11 {
  9341. med_type = "11"
  9342. }
  9343. }
  9344. 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, "")
  9345. } else {
  9346. if his.IdCardType == 4 {
  9347. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9348. token := psn_info.VerifyNumber
  9349. 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)
  9350. } else {
  9351. 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, "")
  9352. }
  9353. }
  9354. var dat map[string]interface{}
  9355. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9356. fmt.Println(dat)
  9357. } else {
  9358. fmt.Println(err)
  9359. }
  9360. saveLog(result2, src_resquest, "2207", "结算")
  9361. userJSONBytes, _ := json.Marshal(dat)
  9362. if miConfig.Code == "H15049901371" {
  9363. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9369. res.Output = resSeven10265.Output
  9370. res.ErrMsg = resSeven10265.ErrMsg
  9371. res.Cainfo = resSeven10265.Cainfo
  9372. res.WarnMsg = resSeven10265.WarnMsg
  9373. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9374. res.Infcode = infocode
  9375. } else {
  9376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9377. utils.ErrorLog("解析失败:%v", err)
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9379. return
  9380. }
  9381. }
  9382. }
  9383. if res.Infcode != 0 {
  9384. errlog := &models.HisOrderError{
  9385. UserOrgId: adminUser.CurrentOrgId,
  9386. Ctime: time.Now().Unix(),
  9387. Mtime: time.Now().Unix(),
  9388. Number: chrg_bchno,
  9389. ErrMsg: res.ErrMsg,
  9390. Status: 1,
  9391. PatientId: id,
  9392. RecordTime: recordDateTime,
  9393. Stage: 6,
  9394. }
  9395. service.CreateErrMsgLog(errlog)
  9396. c.ServeSuccessJSON(map[string]interface{}{
  9397. "failed_code": -10,
  9398. "msg": res.ErrMsg,
  9399. })
  9400. return
  9401. } else {
  9402. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9403. order.OrderStatus = 2
  9404. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9405. order.SetlId = res.Output.Setlinfo.SetlID
  9406. order.PsnNo = res.Output.Setlinfo.PsnNo
  9407. order.PsnName = res.Output.Setlinfo.PsnName
  9408. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9409. order.Certno = res.Output.Setlinfo.Certno
  9410. order.Gend = res.Output.Setlinfo.Gend
  9411. order.Naty = res.Output.Setlinfo.Naty
  9412. order.Age = res.Output.Setlinfo.Age
  9413. order.Insutype = res.Output.Setlinfo.Insutype
  9414. order.PsnType = res.Output.Setlinfo.PsnType
  9415. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9416. order.SetlTime = res.Output.Setlinfo.SetlTime
  9417. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9418. //order.MedType = res.Output.Setlinfo.MedType
  9419. if reg_type == 1112 {
  9420. order.MedType = "1112"
  9421. }
  9422. if reg_type == 1111 {
  9423. order.MedType = "1111"
  9424. }
  9425. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9426. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9427. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9428. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9429. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9430. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9431. order.HifpPay = res.Output.Setlinfo.HifpPay
  9432. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9433. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9434. order.HifesPay = res.Output.Setlinfo.HifesPay
  9435. order.HifobPay = res.Output.Setlinfo.HifobPay
  9436. order.MafPay = res.Output.Setlinfo.MafPay
  9437. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9438. order.OthPay = res.Output.Setlinfo.OthPay
  9439. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9440. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9441. order.AcctPay = res.Output.Setlinfo.AcctPay
  9442. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9443. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9444. order.Balc = res.Output.Setlinfo.Balc
  9445. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9446. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9447. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9448. order.ClrWay = res.Output.Setlinfo.ClrWay
  9449. order.Creator = order.Creator
  9450. order.Modify = roles.AdminUserId
  9451. order.RequestLog = src_resquest
  9452. order.Diagnosis = diagnosis_id
  9453. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9454. detailStr := string(setlDetail)
  9455. order.SetlDetail = detailStr
  9456. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9457. err = service.UpDateOrder(order)
  9458. if err == nil {
  9459. //判断是否使用了押金
  9460. if dec_way == "true" {
  9461. tmpstring := strconv.FormatInt(order.ID, 10)
  9462. //扣押金
  9463. order.Decimal = decimal
  9464. service.UpDateOrder(order)
  9465. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9466. if errmsg != nil {
  9467. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9468. return
  9469. }
  9470. }
  9471. c.ServeSuccessJSON(map[string]interface{}{
  9472. "msg": "结算成功",
  9473. })
  9474. } else {
  9475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9476. return
  9477. }
  9478. }
  9479. }
  9480. }
  9481. }
  9482. //func (c *HisApiController) GetPreUploadInfo() {
  9483. // id, _ := c.GetInt64("id")
  9484. // record_time := c.GetString("record_time")
  9485. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9486. // admin_user_id, _ := c.GetInt64("admin_user_id")
  9487. //
  9488. // timeLayout := "2006-01-02"
  9489. // loc, _ := time.LoadLocation("Local")
  9490. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9491. // if err != nil {
  9492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9493. // return
  9494. // }
  9495. // recordDateTime := theTime.Unix()
  9496. // adminUser := c.GetAdminUserInfo()
  9497. //
  9498. // var prescriptions []*models.HisPrescription
  9499. //
  9500. // var start_time int64
  9501. // var end_time int64
  9502. //
  9503. // data := make(map[string]interface{})
  9504. // if settle_accounts_type == 1 { //日结
  9505. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  9506. // data["pre"] = prescriptions
  9507. //
  9508. // } else { //月结
  9509. // start_time_str := c.GetString("start_time")
  9510. // end_time_str := c.GetString("end_time")
  9511. // timeLayout := "2006-01-02"
  9512. // loc, _ := time.LoadLocation("Local")
  9513. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9514. // if err != nil {
  9515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9516. // return
  9517. // }
  9518. // recordStartTime := theStartTime.Unix()
  9519. // start_time = recordStartTime
  9520. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9521. // if err != nil {
  9522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9523. // return
  9524. // }
  9525. // recordEndTime := theEndTime.Unix()
  9526. // end_time = recordEndTime
  9527. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  9528. // data["pre"] = prescriptions
  9529. //
  9530. // }
  9531. //
  9532. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9533. //
  9534. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9535. // timestamp := time.Now().Unix()
  9536. // tempTime := time.Unix(timestamp, 0)
  9537. // timeFormat := tempTime.Format("20060102150405")
  9538. // chrgBchno := rand.Intn(100000) + 10000
  9539. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9540. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9541. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9542. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9543. // strconv.FormatInt(his.PatientId, 10)
  9544. // client := &http.Client{}
  9545. // data["psn_no"] = his.PsnNo
  9546. // data["mdtrt_id"] = his.Number
  9547. // data["chrg_bchno"] = chrg_bchno
  9548. // data["org_name"] = miConfig.OrgName
  9549. // data["doctor"] = roles.UserName
  9550. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  9551. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9552. // data["fixmedins_code"] = miConfig.Code
  9553. // data["dept_code"] = department.Number
  9554. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9555. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9556. // data["secret_key"] = miConfig.SecretKey
  9557. // var ids []int64
  9558. //
  9559. // for _, item := range prescriptions {
  9560. // ids = append(ids, item.ID)
  9561. // }
  9562. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9563. // if config.IsOpen == 1 { //对接了医保,走医保流程
  9564. // bytesData, _ := json.Marshal(data)
  9565. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  9566. // resp, _ := client.Do(req)
  9567. // defer resp.Body.Close()
  9568. // body, ioErr := ioutil.ReadAll(resp.Body)
  9569. // if ioErr != nil {
  9570. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9572. // return
  9573. // }
  9574. // var respJSON map[string]interface{}
  9575. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9576. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9578. // return
  9579. // }
  9580. //
  9581. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9582. // userJSONBytes, _ := json.Marshal(respJSON)
  9583. // var res ResultFour
  9584. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9585. // utils.ErrorLog("解析失败:%v", err)
  9586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9587. // return
  9588. // }
  9589. //
  9590. // if res.Infcode == 0 {
  9591. // order := &models.HisOrder{
  9592. // UserOrgId: adminUser.CurrentOrgId,
  9593. // HisPatientId: his.ID,
  9594. // PatientId: his.PatientId,
  9595. // SettleAccountsDate: recordDateTime,
  9596. // Ctime: time.Now().Unix(),
  9597. // Mtime: time.Now().Unix(),
  9598. // Status: 1,
  9599. // Number: chrg_bchno,
  9600. // Infcode: res.Infcode,
  9601. // WarnMsg: res.WarnMsg,
  9602. // Cainfo: res.Cainfo,
  9603. // ErrMsg: res.ErrMsg,
  9604. // RespondTime: res.RefmsgTime,
  9605. // InfRefmsgid: res.InfRefmsgid,
  9606. // OrderStatus: 1,
  9607. // IsMedicineInsurance: 1,
  9608. // SettleType: settle_accounts_type,
  9609. // SettleStartTime: start_time,
  9610. // SettleEndTime: end_time,
  9611. // Creator: roles.ID,
  9612. // Modify: roles.ID,
  9613. // PType: 2,
  9614. // }
  9615. // err = service.CreateOrder(order)
  9616. // if err != nil {
  9617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9618. // return
  9619. // }
  9620. //
  9621. // for _, item := range res.Output.Result {
  9622. // temp := strings.Split(item.FeedetlSn, "-")
  9623. // var advice_id int64 = 0
  9624. // var project_id int64 = 0
  9625. // var types int64 = 0
  9626. //
  9627. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  9628. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  9629. //
  9630. // if temp[1] == "1" {
  9631. // advice_id = id
  9632. // project_id = 0
  9633. // } else if temp[1] == "2" {
  9634. // advice_id = 0
  9635. // project_id = id
  9636. // }
  9637. //
  9638. // info := &models.HisOrderInfo{
  9639. // OrderNumber: order.Number,
  9640. // FeedetlSn: item.FeedetlSn,
  9641. // UploadDate: time.Now().Unix(),
  9642. // AdviceId: advice_id,
  9643. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  9644. // Cnt: item.Cnt,
  9645. // Pric: float64(item.Pric),
  9646. // PatientId: his.PatientId,
  9647. // PricUplmtAmt: item.PricUplmtAmt,
  9648. // SelfpayProp: item.SelfpayProp,
  9649. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9650. // OverlmtAmt: item.OverlmtAmt,
  9651. // PreselfpayAmt: item.PreselfpayAmt,
  9652. // BasMednFlag: item.BasMednFlag,
  9653. // MedChrgitmType: item.MedChrgitmType,
  9654. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  9655. // Status: 1,
  9656. // Memo: item.Memo,
  9657. // Mtime: time.Now().Unix(),
  9658. // InscpScpAmt: item.InscpScpAmt,
  9659. // DrtReimFlag: item.DrtReimFlag,
  9660. // Ctime: time.Now().Unix(),
  9661. // ListSpItemFlag: item.ListSpItemFlag,
  9662. // ChldMedcFlag: item.ChldMedcFlag,
  9663. // LmtUsedFlag: item.LmtUsedFlag,
  9664. // ChrgitmLv: item.ChrgitmLv,
  9665. // UserOrgId: adminUser.CurrentOrgId,
  9666. // HisPatientId: his.ID,
  9667. // OrderId: order.ID,
  9668. // ProjectId: project_id,
  9669. // Type: types,
  9670. // }
  9671. // service.CreateOrderInfo(info)
  9672. //
  9673. // }
  9674. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9675. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  9676. //
  9677. // var total float64
  9678. // for _, item := range prescriptions {
  9679. // if item.Type == 1 { //药品
  9680. // for _, subItem := range item.HisDoctorAdviceInfo {
  9681. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9682. // }
  9683. // }
  9684. // if item.Type == 2 { //项目
  9685. // for _, subItem := range item.HisPrescriptionProject {
  9686. // total = total + (subItem.Price * float64(subItem.Count))
  9687. // }
  9688. // }
  9689. // }
  9690. //
  9691. // for _, item := range prescriptions {
  9692. // for _, subItem := range item.HisAdditionalCharge {
  9693. // total = total + (subItem.Price * float64(subItem.Count))
  9694. // }
  9695. // }
  9696. //
  9697. // allTotal := fmt.Sprintf("%.2f", total)
  9698. // if res.Infcode == 0 {
  9699. // var rf []*ResultFive
  9700. // json.Unmarshal([]byte(his.Iinfo), &rf)
  9701. // psn_no := his.PsnNo
  9702. // mdtrt_id := his.Number
  9703. // chrg_bchno := chrg_bchno
  9704. // cert_no := his.Certno
  9705. // insutype := rf[0].Insutype
  9706. //
  9707. // if his.IdCardType == 1 {
  9708. // cert_no = his.MedicalInsuranceNumber
  9709. //
  9710. // } else {
  9711. //
  9712. // cert_no = his.Certno
  9713. //
  9714. // }
  9715. //
  9716. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  9717. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  9718. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9719. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9720. // resp, requestErr := http.Get(api)
  9721. // if requestErr != nil {
  9722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9723. // return
  9724. // }
  9725. // defer resp.Body.Close()
  9726. // body, ioErr := ioutil.ReadAll(resp.Body)
  9727. // if ioErr != nil {
  9728. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9730. // return
  9731. // }
  9732. // var respJSON map[string]interface{}
  9733. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9734. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9736. // return
  9737. // }
  9738. // fmt.Println(respJSON)
  9739. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9740. // userJSONBytes, _ := json.Marshal(respJSON)
  9741. // var res ResultSeven
  9742. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9743. // utils.ErrorLog("解析失败:%v", err)
  9744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9745. // return
  9746. // }
  9747. // if res.Infcode != 0 {
  9748. // errlog := &models.HisOrderError{
  9749. // UserOrgId: adminUser.CurrentOrgId,
  9750. // Ctime: time.Now().Unix(),
  9751. // Mtime: time.Now().Unix(),
  9752. // Number: chrg_bchno,
  9753. // ErrMsg: res.ErrMsg,
  9754. // Status: 1,
  9755. // PatientId: id,
  9756. // RecordTime: recordDateTime,
  9757. // Stage: 7,
  9758. // }
  9759. // service.CreateErrMsgLog(errlog)
  9760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9761. // return
  9762. // } else {
  9763. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9764. // order.OrderStatus = 1
  9765. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9766. // order.SetlId = res.Output.Setlinfo.SetlID
  9767. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9768. // order.PsnName = res.Output.Setlinfo.PsnName
  9769. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9770. // order.Certno = res.Output.Setlinfo.Certno
  9771. // order.Gend = res.Output.Setlinfo.Gend
  9772. // order.Naty = res.Output.Setlinfo.Naty
  9773. // order.Age = res.Output.Setlinfo.Age
  9774. // order.Insutype = res.Output.Setlinfo.Insutype
  9775. // order.PsnType = res.Output.Setlinfo.PsnType
  9776. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9777. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9778. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9779. // order.MedType = res.Output.Setlinfo.MedType
  9780. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9781. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9782. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9783. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9784. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9785. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9786. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9787. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9788. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9789. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9790. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9791. // order.MafPay = res.Output.Setlinfo.MafPay
  9792. // order.OthPay = res.Output.Setlinfo.OthPay
  9793. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9794. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9795. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9796. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9797. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9798. // order.Balc = res.Output.Setlinfo.Balc
  9799. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9800. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9801. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9802. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9803. // order.Creator = order.Creator
  9804. // order.Modify = roles.ID
  9805. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9806. // detailStr := string(setlDetail)
  9807. // order.SetlDetail = detailStr
  9808. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9809. // err = service.UpDateOrder(order)
  9810. // if err == nil {
  9811. // c.ServeSuccessJSON(map[string]interface{}{
  9812. // "msg": "预结算成功",
  9813. // })
  9814. // } else {
  9815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9816. // return
  9817. // }
  9818. // }
  9819. // } else {
  9820. // adminUser := c.GetAdminUserInfo()
  9821. // errlog := &models.HisOrderError{
  9822. // UserOrgId: adminUser.CurrentOrgId,
  9823. // Ctime: time.Now().Unix(),
  9824. // Mtime: time.Now().Unix(),
  9825. // ErrMsg: res.ErrMsg,
  9826. // Status: 1,
  9827. // PatientId: id,
  9828. // RecordTime: recordDateTime,
  9829. // Stage: 4,
  9830. // }
  9831. // service.CreateErrMsgLog(errlog)
  9832. //
  9833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9834. // return
  9835. // }
  9836. // } else {
  9837. // adminUser := c.GetAdminUserInfo()
  9838. // errlog := &models.HisOrderError{
  9839. // UserOrgId: adminUser.CurrentOrgId,
  9840. // Ctime: time.Now().Unix(),
  9841. // Mtime: time.Now().Unix(),
  9842. // ErrMsg: res.ErrMsg,
  9843. // Status: 1,
  9844. // PatientId: id,
  9845. // RecordTime: recordDateTime,
  9846. // Stage: 4,
  9847. // }
  9848. // service.CreateErrMsgLog(errlog)
  9849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9850. // return
  9851. // }
  9852. //
  9853. // } else {
  9854. // var total float64
  9855. // for _, item := range prescriptions {
  9856. // if item.Type == 1 { //药品
  9857. // for _, subItem := range item.HisDoctorAdviceInfo {
  9858. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9859. // }
  9860. // }
  9861. // if item.Type == 2 { //项目
  9862. // for _, subItem := range item.HisPrescriptionProject {
  9863. // total = total + (subItem.Price * float64(subItem.Count))
  9864. // }
  9865. // }
  9866. //
  9867. // for _, subItem := range item.HisAdditionalCharge {
  9868. // total = total + (subItem.Price * float64(subItem.Count))
  9869. // }
  9870. // }
  9871. //
  9872. // allTotal := fmt.Sprintf("%.2f", total)
  9873. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9874. // order := &models.HisOrder{
  9875. // UserOrgId: adminUser.CurrentOrgId,
  9876. // HisPatientId: his.ID,
  9877. // PatientId: id,
  9878. // SettleAccountsDate: recordDateTime,
  9879. // Ctime: time.Now().Unix(),
  9880. // Mtime: time.Now().Unix(),
  9881. // Status: 1,
  9882. // OrderStatus: 2,
  9883. // Number: chrg_bchno,
  9884. // MedfeeSumamt: totals,
  9885. // }
  9886. // err = service.CreateOrder(order)
  9887. // if err != nil {
  9888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9889. // return
  9890. // }
  9891. //
  9892. // var customs []*Custom
  9893. // for _, item := range prescriptions {
  9894. //
  9895. // if item.Type == 1 { //药品
  9896. // for _, subItem := range item.HisDoctorAdviceInfo {
  9897. // cus := &Custom{
  9898. // AdviceId: subItem.ID,
  9899. // ProjectId: 0,
  9900. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9901. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9902. // FeedetlSn: subItem.FeedetlSn,
  9903. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9904. // MedListCodg: subItem.MedListCodg,
  9905. // Type: 1,
  9906. // }
  9907. // customs = append(customs, cus)
  9908. // }
  9909. // }
  9910. //
  9911. // if item.Type == 2 { //项目
  9912. // for _, subItem := range item.HisPrescriptionProject {
  9913. //
  9914. // cus := &Custom{
  9915. // AdviceId: 0,
  9916. // ProjectId: subItem.ID,
  9917. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9918. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9919. // FeedetlSn: subItem.FeedetlSn,
  9920. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9921. // MedListCodg: subItem.MedListCodg,
  9922. // Type: 2,
  9923. // }
  9924. //
  9925. // customs = append(customs, cus)
  9926. // }
  9927. // }
  9928. //
  9929. // for _, item := range item.HisAdditionalCharge {
  9930. // cus := &Custom{
  9931. // ItemId: item.ID,
  9932. // AdviceId: 0,
  9933. // ProjectId: 0,
  9934. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9935. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9936. // FeedetlSn: item.FeedetlSn,
  9937. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9938. // MedListCodg: item.XtHisAddtionConfig.Code,
  9939. // Type: 3,
  9940. // }
  9941. //
  9942. // customs = append(customs, cus)
  9943. // }
  9944. //
  9945. // }
  9946. //
  9947. // for _, item := range customs {
  9948. // var advice_id int64 = 0
  9949. // var project_id int64 = 0
  9950. // var item_id int64 = 0
  9951. //
  9952. // var types int64 = 0
  9953. //
  9954. // if item.Type == 1 {
  9955. // advice_id = item.AdviceId
  9956. // project_id = 0
  9957. // item_id = 0
  9958. // } else if item.Type == 2 {
  9959. // advice_id = 0
  9960. // item_id = 0
  9961. //
  9962. // project_id = item.ProjectId
  9963. // } else if item.Type == 3 {
  9964. // advice_id = 0
  9965. // item_id = item.ItemId
  9966. // project_id = 0
  9967. // }
  9968. //
  9969. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9970. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9971. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9972. //
  9973. // info := &models.HisOrderInfo{
  9974. // OrderNumber: order.Number,
  9975. // UploadDate: time.Now().Unix(),
  9976. // AdviceId: advice_id,
  9977. // DetItemFeeSumamt: detItemFeeSumamt,
  9978. // Cnt: cut,
  9979. // Pric: pric,
  9980. // PatientId: id,
  9981. // Status: 1,
  9982. // Mtime: time.Now().Unix(),
  9983. // Ctime: time.Now().Unix(),
  9984. // UserOrgId: adminUser.CurrentOrgId,
  9985. // HisPatientId: his.ID,
  9986. // OrderId: order.ID,
  9987. // ProjectId: project_id,
  9988. // Type: types,
  9989. // ItemId: item_id,
  9990. // }
  9991. // service.CreateOrderInfo(info)
  9992. // }
  9993. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9994. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9995. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9996. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9997. // if err == nil {
  9998. // c.ServeSuccessJSON(map[string]interface{}{
  9999. // "msg": "结算成功",
  10000. // })
  10001. // } else {
  10002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10003. // return
  10004. // }
  10005. // }
  10006. //}
  10007. //上传明细-预结算-
  10008. func (c *HisApiController) GetPreUploadInfo() {
  10009. id, _ := c.GetInt64("id")
  10010. record_time := c.GetString("record_time")
  10011. his_patient_id, _ := c.GetInt64("his_patient_id")
  10012. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10013. admin_user_id, _ := c.GetInt64("admin_user_id")
  10014. diagnosis_id := c.GetString("diagnosis")
  10015. sick_type, _ := c.GetInt64("sick_type")
  10016. reg_type, _ := c.GetInt64("p_type")
  10017. begin_time := c.GetString("begin_time")
  10018. acct_used_flag := c.GetString("acct_used_flag")
  10019. id_str := c.GetString("ids")
  10020. ids_arr := strings.Split(id_str, ",")
  10021. timeLayout := "2006-01-02"
  10022. loc, _ := time.LoadLocation("Local")
  10023. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10024. if err != nil {
  10025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10026. return
  10027. }
  10028. recordDateTime := theTime.Unix()
  10029. adminUser := c.GetAdminUserInfo()
  10030. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10031. var config []*models.HisXtDiagnoseConfig
  10032. for _, item := range diagnosis_ids {
  10033. id, _ := strconv.ParseInt(item, 10, 64)
  10034. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10035. config = append(config, &diagnosisConfig)
  10036. }
  10037. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10038. sickConfig, _ := service.FindSickById(sick_type)
  10039. var prescriptions []*models.HisPrescription
  10040. var start_time int64
  10041. var end_time int64
  10042. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10043. fmt.Println(his_patient_id)
  10044. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10045. timestamp := time.Now().Unix()
  10046. tempTime := time.Unix(timestamp, 0)
  10047. timeFormat := tempTime.Format("20060102150405")
  10048. chrgBchno := rand.Intn(100000) + 10000
  10049. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10050. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10051. var patientPrescription models.HisPrescriptionInfo
  10052. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10053. if patientPrescription.ID == 0 {
  10054. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10055. }
  10056. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10057. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10058. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10059. strconv.FormatInt(his.PatientId, 10)
  10060. var res2 ResultSix
  10061. var resSix10265 ResultSix10265
  10062. //var time_stamp string
  10063. if miConfig.MdtrtareaAdmvs == "421300" {
  10064. data := make(map[string]interface{})
  10065. client := &http.Client{}
  10066. data["psn_no"] = his.PsnNo
  10067. data["mdtrt_id"] = his.Number
  10068. data["department"] = department.Name
  10069. data["org_name"] = miConfig.OrgName
  10070. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10071. data["doctor_id"] = doctor_info.DoctorNumber
  10072. data["doctor_name"] = roles.UserName
  10073. data["fixmedins_code"] = miConfig.Code
  10074. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10076. data["secret_key"] = miConfig.SecretKey
  10077. data["sick_code"] = sickConfig.CountryCode
  10078. data["sick_name"] = sickConfig.ClassName
  10079. data["begin_time"] = begin_time
  10080. data["dept"] = strconv.FormatInt(department.ID, 10)
  10081. data["config"] = config
  10082. data["opter"] = roles.UserName
  10083. fmt.Println(data)
  10084. bytesData, _ := json.Marshal(data)
  10085. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10086. resp, _ := client.Do(req)
  10087. defer resp.Body.Close()
  10088. body, ioErr := ioutil.ReadAll(resp.Body)
  10089. if ioErr != nil {
  10090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10092. return
  10093. }
  10094. var respJSON map[string]interface{}
  10095. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10098. return
  10099. }
  10100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10101. userJSONBytes, _ := json.Marshal(respJSON)
  10102. fmt.Println("log")
  10103. fmt.Println(string(userJSONBytes))
  10104. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10105. utils.ErrorLog("解析失败:%v", err)
  10106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10107. return
  10108. }
  10109. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10110. data := make(map[string]interface{})
  10111. client := &http.Client{}
  10112. data["psn_no"] = his.PsnNo
  10113. data["mdtrt_id"] = his.Number
  10114. data["doctor"] = roles.UserName
  10115. data["department"] = department.Name
  10116. data["org_name"] = miConfig.OrgName
  10117. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10118. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  10119. data["fixmedins_code"] = miConfig.Code
  10120. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10121. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10122. data["secret_key"] = miConfig.SecretKey
  10123. data["sick_code"] = sickConfig.CountryCode
  10124. data["sick_name"] = sickConfig.ClassName
  10125. data["begin_time"] = begin_time
  10126. data["dept"] = strconv.FormatInt(department.ID, 10)
  10127. data["config"] = config
  10128. data["url"] = miConfig.Url
  10129. data["ak"] = miConfig.AccessKey
  10130. data["cainfo"] = miConfig.Cainfo
  10131. bytesData, _ := json.Marshal(data)
  10132. var req *http.Request
  10133. if miConfig.MdtrtareaAdmvs == "320921" {
  10134. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10135. } else {
  10136. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10137. }
  10138. resp, _ := client.Do(req)
  10139. defer resp.Body.Close()
  10140. body, ioErr := ioutil.ReadAll(resp.Body)
  10141. if ioErr != nil {
  10142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. var respJSON map[string]interface{}
  10147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10150. return
  10151. }
  10152. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  10153. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  10154. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  10155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10156. userJSONBytes, _ := json.Marshal(respJSON)
  10157. fmt.Println("log")
  10158. fmt.Println(string(userJSONBytes))
  10159. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10165. res2.Output = resSix10265.Output
  10166. res2.ErrMsg = resSix10265.ErrMsg
  10167. res2.Cainfo = resSix10265.Cainfo
  10168. res2.WarnMsg = resSix10265.WarnMsg
  10169. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10170. res2.Infcode = infocode
  10171. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10172. 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)
  10173. saveLog(result, requestLog, "2203", "上传就诊信息")
  10174. var respJSON2 map[string]interface{}
  10175. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10178. return
  10179. }
  10180. userJSONBytes2, _ := json.Marshal(respJSON2)
  10181. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10182. utils.ErrorLog("解析失败:%v", err)
  10183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10184. return
  10185. }
  10186. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10187. var result string
  10188. var requestLog string
  10189. 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, "")
  10190. saveLog(result, requestLog, "2203", "上传就诊信息")
  10191. var respJSON2 map[string]interface{}
  10192. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10195. return
  10196. }
  10197. userJSONBytes2, _ := json.Marshal(respJSON2)
  10198. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10199. utils.ErrorLog("解析失败:%v", err)
  10200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10201. return
  10202. }
  10203. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10204. var result string
  10205. var requestLog string
  10206. 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, "")
  10207. saveLog(result, requestLog, "2203", "上传就诊信息")
  10208. var respJSON2 map[string]interface{}
  10209. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10212. return
  10213. }
  10214. userJSONBytes2, _ := json.Marshal(respJSON2)
  10215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10216. utils.ErrorLog("解析失败:%v", err)
  10217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10218. return
  10219. }
  10220. } else {
  10221. var result string
  10222. var requestLog string
  10223. if miConfig.MdtrtareaAdmvs == "440781" { //
  10224. 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)
  10225. } else {
  10226. if miConfig.Code == "H15049901371" {
  10227. //赤峰地区国家医保医疗类别
  10228. //职工透析:医疗类别选特殊情况门诊990502
  10229. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10230. var med_type string
  10231. if his.Insutype == "390" {
  10232. if reg_type == 14 {
  10233. med_type = "9933"
  10234. } else if reg_type == 11 {
  10235. med_type = "11"
  10236. }
  10237. } else if his.Insutype == "310" {
  10238. if reg_type == 14 {
  10239. med_type = "990502"
  10240. } else if reg_type == 11 {
  10241. med_type = "11"
  10242. }
  10243. }
  10244. 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)
  10245. } else {
  10246. 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)
  10247. }
  10248. saveLog(result, requestLog, "2203", "上传就诊信息")
  10249. var respJSON2 map[string]interface{}
  10250. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10253. return
  10254. }
  10255. userJSONBytes2, _ := json.Marshal(respJSON2)
  10256. if miConfig.Code == "H15049901371" {
  10257. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10263. res2.Output = resSix10265.Output
  10264. res2.ErrMsg = resSix10265.ErrMsg
  10265. res2.Cainfo = resSix10265.Cainfo
  10266. res2.WarnMsg = resSix10265.WarnMsg
  10267. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10268. res2.Infcode = infocode
  10269. } else {
  10270. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10271. utils.ErrorLog("解析失败:%v", err)
  10272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10273. return
  10274. }
  10275. }
  10276. }
  10277. }
  10278. if res2.Infcode != 0 {
  10279. adminUser := c.GetAdminUserInfo()
  10280. errlog := &models.HisOrderError{
  10281. UserOrgId: adminUser.CurrentOrgId,
  10282. Ctime: time.Now().Unix(),
  10283. Mtime: time.Now().Unix(),
  10284. ErrMsg: res2.ErrMsg,
  10285. Status: 1,
  10286. PatientId: id,
  10287. RecordTime: recordDateTime,
  10288. Stage: 3,
  10289. }
  10290. service.CreateErrMsgLog(errlog)
  10291. c.ServeSuccessJSON(map[string]interface{}{
  10292. "failed_code": -10,
  10293. "msg": res2.ErrMsg,
  10294. })
  10295. return
  10296. } else {
  10297. his.Diagnosis = diagnosis_id
  10298. his.SickType = sickConfig.ID
  10299. his.PType = fmt.Sprintf("%d", reg_type)
  10300. service.UpdateHisPatientThree(&his)
  10301. data := make(map[string]interface{})
  10302. if settle_accounts_type == 1 { //日结
  10303. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10304. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10305. } else {
  10306. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10307. }
  10308. data["pre"] = prescriptions
  10309. } else { //月结
  10310. start_time_str := c.GetString("start_time")
  10311. end_time_str := c.GetString("end_time")
  10312. timeLayout := "2006-01-02"
  10313. loc, _ := time.LoadLocation("Local")
  10314. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10315. if err != nil {
  10316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10317. return
  10318. }
  10319. recordStartTime := theStartTime.Unix()
  10320. start_time = recordStartTime
  10321. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10322. if err != nil {
  10323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10324. return
  10325. }
  10326. recordEndTime := theEndTime.Unix()
  10327. end_time = recordEndTime
  10328. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10329. data["pre"] = prescriptions
  10330. }
  10331. client := &http.Client{}
  10332. data["psn_no"] = his.PsnNo
  10333. data["mdtrt_id"] = his.Number
  10334. data["chrg_bchno"] = chrg_bchno
  10335. data["org_name"] = miConfig.OrgName
  10336. data["doctor"] = doctor_info.UserName
  10337. data["doctor_id"] = doctor_info.DoctorNumber
  10338. data["dept"] = department.Name
  10339. data["fixmedins_code"] = miConfig.Code
  10340. data["opter"] = roles.UserName
  10341. data["dept_code"] = department.Number
  10342. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10343. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10344. data["secret_key"] = miConfig.SecretKey
  10345. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10346. data["url"] = miConfig.Url
  10347. data["ak"] = miConfig.AccessKey
  10348. data["new_doctor_name"] = patientPrescription.Doctor
  10349. data["diag_code"] = sickConfig.CountryCode
  10350. data["cainfo"] = miConfig.Cainfo
  10351. data["opter"] = roles.UserName
  10352. var ids []int64
  10353. for _, item := range prescriptions {
  10354. ids = append(ids, item.ID)
  10355. }
  10356. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10357. if config.IsOpen == 1 { //对接了医保,走医保流程
  10358. var res ResultFour
  10359. var resFour10265 ResultFour10265
  10360. if miConfig.MdtrtareaAdmvs == "421300" {
  10361. bytesData, _ := json.Marshal(data)
  10362. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10363. resp, _ := client.Do(req)
  10364. defer resp.Body.Close()
  10365. body, ioErr := ioutil.ReadAll(resp.Body)
  10366. if ioErr != nil {
  10367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10369. return
  10370. }
  10371. var respJSON map[string]interface{}
  10372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10375. return
  10376. }
  10377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10378. userJSONBytes, _ := json.Marshal(respJSON)
  10379. fmt.Println("log")
  10380. fmt.Println(string(userJSONBytes))
  10381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10382. utils.ErrorLog("解析失败:%v", err)
  10383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10384. return
  10385. }
  10386. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10387. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10388. if result3101.Infcode == "0" {
  10389. if len(result3101.Output.Result) > 0 {
  10390. var errMsgs []string
  10391. for _, item := range result3101.Output.Result {
  10392. errMsgs = append(errMsgs, item.VolaCont)
  10393. }
  10394. c.ServeSuccessJSON(map[string]interface{}{
  10395. "failed_code": -10,
  10396. "msg": errMsgs,
  10397. })
  10398. return
  10399. } else {
  10400. if miConfig.MdtrtareaAdmvs == "320921" {
  10401. data["doctor_id"] = "D320923012139"
  10402. } else {
  10403. data["doctor_id"] = "D371621008686"
  10404. }
  10405. bytesData, _ := json.Marshal(data)
  10406. var req *http.Request
  10407. if miConfig.MdtrtareaAdmvs == "320921" {
  10408. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10409. } else {
  10410. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10411. }
  10412. resp, _ := client.Do(req)
  10413. defer resp.Body.Close()
  10414. body, ioErr := ioutil.ReadAll(resp.Body)
  10415. if ioErr != nil {
  10416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10418. return
  10419. }
  10420. var respJSON map[string]interface{}
  10421. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10427. userJSONBytes, _ := json.Marshal(respJSON)
  10428. fmt.Println("log")
  10429. fmt.Println(string(userJSONBytes))
  10430. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10431. utils.ErrorLog("解析失败:%v", err)
  10432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10433. return
  10434. }
  10435. res.InfRefmsgid = resFour10265.InfRefmsgid
  10436. res.Output = resFour10265.Output
  10437. res.ErrMsg = resFour10265.ErrMsg
  10438. res.Cainfo = resFour10265.Cainfo
  10439. res.WarnMsg = resFour10265.WarnMsg
  10440. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10441. res.Infcode = infocode
  10442. }
  10443. }
  10444. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10445. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  10446. var dat map[string]interface{}
  10447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10448. fmt.Println(dat)
  10449. } else {
  10450. fmt.Println(err)
  10451. }
  10452. saveLog(result, request_log, "2204", "上传费用明细")
  10453. userJSONBytes, _ := json.Marshal(dat)
  10454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10455. utils.ErrorLog("解析失败:%v", err)
  10456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10457. return
  10458. }
  10459. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10460. 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, "", "")
  10461. var dat map[string]interface{}
  10462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10463. fmt.Println(dat)
  10464. } else {
  10465. fmt.Println(err)
  10466. }
  10467. saveLog(result, request_log, "2204", "上传费用明细")
  10468. userJSONBytes, _ := json.Marshal(dat)
  10469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10470. utils.ErrorLog("解析失败:%v", err)
  10471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10472. return
  10473. }
  10474. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10475. 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, "", "")
  10476. var dat map[string]interface{}
  10477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10478. fmt.Println(dat)
  10479. } else {
  10480. fmt.Println(err)
  10481. }
  10482. saveLog(result, request_log, "2204", "上传费用明细")
  10483. userJSONBytes, _ := json.Marshal(dat)
  10484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10485. utils.ErrorLog("解析失败:%v", err)
  10486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10487. return
  10488. }
  10489. } else {
  10490. if miConfig.Code == "H15049901371" {
  10491. 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)
  10492. var dat map[string]interface{}
  10493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10494. fmt.Println(dat)
  10495. } else {
  10496. fmt.Println(err)
  10497. }
  10498. saveLog(result, request_log, "2204", "上传费用明细")
  10499. userJSONBytes, _ := json.Marshal(dat)
  10500. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10501. utils.ErrorLog("解析失败:%v", err)
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10503. return
  10504. }
  10505. res.InfRefmsgid = resFour10265.InfRefmsgid
  10506. res.Output = resFour10265.Output
  10507. res.ErrMsg = resFour10265.ErrMsg
  10508. res.Cainfo = resFour10265.Cainfo
  10509. res.WarnMsg = resFour10265.WarnMsg
  10510. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10511. res.Infcode = infocode
  10512. } else {
  10513. 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)
  10514. var dat map[string]interface{}
  10515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10516. fmt.Println(dat)
  10517. } else {
  10518. fmt.Println(err)
  10519. }
  10520. saveLog(result, request_log, "2204", "上传费用明细")
  10521. userJSONBytes, _ := json.Marshal(dat)
  10522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10523. utils.ErrorLog("解析失败:%v", err)
  10524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10525. return
  10526. }
  10527. }
  10528. }
  10529. var total_two float64
  10530. if res.Infcode == 0 {
  10531. order := &models.HisOrder{
  10532. UserOrgId: adminUser.CurrentOrgId,
  10533. HisPatientId: his.ID,
  10534. PatientId: his.PatientId,
  10535. SettleAccountsDate: recordDateTime,
  10536. Ctime: time.Now().Unix(),
  10537. Mtime: time.Now().Unix(),
  10538. MdtrtId: his.Number,
  10539. PsnNo: his.PsnNo,
  10540. MedType: strconv.FormatInt(reg_type, 10),
  10541. Status: 1,
  10542. Number: chrg_bchno,
  10543. Infcode: res.Infcode,
  10544. WarnMsg: res.WarnMsg,
  10545. Cainfo: res.Cainfo,
  10546. ErrMsg: res.ErrMsg,
  10547. RespondTime: res.RefmsgTime,
  10548. InfRefmsgid: res.InfRefmsgid,
  10549. OrderStatus: 1,
  10550. IsMedicineInsurance: 1,
  10551. SettleType: settle_accounts_type,
  10552. SettleStartTime: start_time,
  10553. SettleEndTime: end_time,
  10554. Creator: roles.AdminUserId,
  10555. Modify: roles.AdminUserId,
  10556. PType: 2,
  10557. Diagnosis: diagnosis_id,
  10558. }
  10559. err = service.CreateOrder(order)
  10560. if err != nil {
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10562. return
  10563. }
  10564. for _, item := range res.Output.Result {
  10565. temp := strings.Split(item.FeedetlSn, "-")
  10566. var advice_id int64 = 0
  10567. var project_id int64 = 0
  10568. var types int64 = 0
  10569. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10570. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10571. if temp[1] == "1" {
  10572. advice_id = id
  10573. project_id = 0
  10574. } else if temp[1] == "2" {
  10575. advice_id = 0
  10576. project_id = id
  10577. }
  10578. total_two = total_two + item.DetItemFeeSumamt
  10579. info := &models.HisOrderInfo{
  10580. OrderNumber: order.Number,
  10581. FeedetlSn: item.FeedetlSn,
  10582. UploadDate: time.Now().Unix(),
  10583. AdviceId: advice_id,
  10584. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10585. Cnt: item.Cnt,
  10586. Pric: float64(item.Pric),
  10587. PatientId: his.PatientId,
  10588. PricUplmtAmt: item.PricUplmtAmt,
  10589. SelfpayProp: item.SelfpayProp,
  10590. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10591. OverlmtAmt: item.OverlmtAmt,
  10592. PreselfpayAmt: item.PreselfpayAmt,
  10593. BasMednFlag: item.BasMednFlag,
  10594. MedChrgitmType: item.MedChrgitmType,
  10595. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10596. Status: 1,
  10597. Memo: item.Memo,
  10598. Mtime: time.Now().Unix(),
  10599. InscpScpAmt: item.InscpScpAmt,
  10600. DrtReimFlag: item.DrtReimFlag,
  10601. Ctime: time.Now().Unix(),
  10602. ListSpItemFlag: item.ListSpItemFlag,
  10603. ChldMedcFlag: item.ChldMedcFlag,
  10604. LmtUsedFlag: item.LmtUsedFlag,
  10605. ChrgitmLv: item.ChrgitmLv,
  10606. UserOrgId: adminUser.CurrentOrgId,
  10607. HisPatientId: his.ID,
  10608. OrderId: order.ID,
  10609. ProjectId: project_id,
  10610. Type: types,
  10611. }
  10612. service.CreateOrderInfo(info)
  10613. }
  10614. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10615. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10616. var total float64
  10617. for _, item := range prescriptions {
  10618. if item.Type == 1 { //药品
  10619. for _, subItem := range item.HisDoctorAdviceInfo {
  10620. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10621. total_one := price * subItem.PrescribingNumber
  10622. fmt.Println("subItem")
  10623. fmt.Println(subItem.Price)
  10624. fmt.Println("price")
  10625. fmt.Println(price)
  10626. fmt.Println("total_one")
  10627. fmt.Println(total_one)
  10628. total = total + total_one
  10629. fmt.Println(total)
  10630. }
  10631. }
  10632. if item.Type == 2 { //项目
  10633. for _, subItem := range item.HisPrescriptionProject {
  10634. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10635. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10636. total_one := price * cnt
  10637. total = total + total_one
  10638. }
  10639. }
  10640. }
  10641. allTotal := fmt.Sprintf("%2f", total)
  10642. if res.Infcode == 0 {
  10643. var rf []*ResultFive
  10644. json.Unmarshal([]byte(his.Iinfo), &rf)
  10645. chrg_bchno := chrg_bchno
  10646. cert_no := his.Certno
  10647. var insutypes []string
  10648. var insutype string
  10649. var is390 int = 0
  10650. var is310 int = 0
  10651. for _, item := range rf {
  10652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10653. insutypes = append(insutypes, item.Insutype)
  10654. }
  10655. }
  10656. if len(insutypes) == 1 {
  10657. insutype = insutypes[0]
  10658. } else {
  10659. for _, i := range insutypes {
  10660. if i == "390" {
  10661. is390 = 1
  10662. }
  10663. if i == "310" {
  10664. is310 = 1
  10665. }
  10666. }
  10667. }
  10668. if is390 == 1 {
  10669. insutype = "390"
  10670. }
  10671. if is310 == 1 {
  10672. insutype = "310"
  10673. }
  10674. if len(insutypes) == 0 {
  10675. insutype = "390"
  10676. }
  10677. if len(insutypes) == 2 {
  10678. insutype = strconv.FormatInt(his.SocialType, 10)
  10679. }
  10680. //insutype = "390"
  10681. if his.IdCardType == 1 {
  10682. cert_no = his.MedicalInsuranceNumber
  10683. } else {
  10684. cert_no = his.Certno
  10685. }
  10686. var res ResultSeven
  10687. var resSeven10265 ResultSeven10265
  10688. if miConfig.MdtrtareaAdmvs == "421300" {
  10689. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10690. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10691. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10693. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10694. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10695. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  10696. resp, requestErr := http.Get(api)
  10697. if requestErr != nil {
  10698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10699. return
  10700. }
  10701. body, ioErr := ioutil.ReadAll(resp.Body)
  10702. if ioErr != nil {
  10703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10705. return
  10706. }
  10707. var respJSON map[string]interface{}
  10708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10711. return
  10712. }
  10713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10714. result, _ := json.Marshal(respJSON)
  10715. fmt.Println("log")
  10716. fmt.Println(string(result))
  10717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10718. utils.ErrorLog("解析失败:%v", err)
  10719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10720. return
  10721. }
  10722. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10723. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  10724. if result3101.Infcode == "0" {
  10725. if len(result3101.Output.Result) > 0 {
  10726. var errMsgs []string
  10727. for _, item := range result3101.Output.Result {
  10728. errMsgs = append(errMsgs, item.VolaCont)
  10729. }
  10730. c.ServeSuccessJSON(map[string]interface{}{
  10731. "failed_code": -10,
  10732. "msg": errMsgs,
  10733. })
  10734. return
  10735. } else {
  10736. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10737. if his.IdCardType != 4 {
  10738. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10739. bas := strings.Split(psn_info.CardInfo, "|")
  10740. if his.IdCardType == 1 {
  10741. cert_no = bas[2]
  10742. } else {
  10743. cert_no = bas[1]
  10744. }
  10745. } else {
  10746. cert_no = his.Certno
  10747. }
  10748. //江苏地区国家医保医疗类别
  10749. //职工透析:医疗类别选特殊情况门诊9933
  10750. //居民血透门慢: 医疗类别选门诊慢病1402
  10751. //var med_type string
  10752. //if his.Insutype == "310" {
  10753. // if reg_type == 14 {
  10754. // med_type = "9933"
  10755. // } else if reg_type == 11 {
  10756. // med_type = "11"
  10757. //
  10758. // }
  10759. //} else if his.Insutype == "390" {
  10760. // if reg_type == 14 {
  10761. // med_type = "1402"
  10762. // } else if reg_type == 11 {
  10763. // med_type = "11"
  10764. // }
  10765. //}
  10766. var api string
  10767. if miConfig.MdtrtareaAdmvs == "320921" {
  10768. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10769. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10770. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10771. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10772. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10773. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10774. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10775. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10776. } else {
  10777. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10778. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10779. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10780. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10782. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10783. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10784. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10785. }
  10786. resp, requestErr := http.Get(api)
  10787. if requestErr != nil {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10789. return
  10790. }
  10791. body, ioErr := ioutil.ReadAll(resp.Body)
  10792. if ioErr != nil {
  10793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10795. return
  10796. }
  10797. var respJSON map[string]interface{}
  10798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10801. return
  10802. }
  10803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10804. result, _ := json.Marshal(respJSON)
  10805. fmt.Println("log")
  10806. fmt.Println(string(result))
  10807. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10808. utils.ErrorLog("解析失败:%v", err)
  10809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10810. return
  10811. }
  10812. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10813. res.Output = resSeven10265.Output
  10814. res.ErrMsg = resSeven10265.ErrMsg
  10815. res.Cainfo = resSeven10265.Cainfo
  10816. res.WarnMsg = resSeven10265.WarnMsg
  10817. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10818. res.Infcode = infocode
  10819. }
  10820. }
  10821. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10822. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  10823. var result string
  10824. var request_log string
  10825. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10826. 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)
  10827. } else {
  10828. 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)
  10829. }
  10830. var dat map[string]interface{}
  10831. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10832. fmt.Println(dat)
  10833. } else {
  10834. fmt.Println(err)
  10835. }
  10836. saveLog(result, request_log, "2206", "预结算")
  10837. userJSONBytes, _ := json.Marshal(dat)
  10838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10839. utils.ErrorLog("解析失败:%v", err)
  10840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10841. return
  10842. }
  10843. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10844. var result string
  10845. var request_log string
  10846. if his.IdCardType == 2 {
  10847. 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, "")
  10848. } else if his.IdCardType == 1 {
  10849. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10850. bas := strings.Split(psn_info.CardInfo, "|")
  10851. basNumber := bas[2]
  10852. card_sn := bas[3]
  10853. 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)
  10854. } else {
  10855. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10856. 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, "")
  10857. }
  10858. var dat map[string]interface{}
  10859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10860. fmt.Println(dat)
  10861. } else {
  10862. fmt.Println(err)
  10863. }
  10864. saveLog(result, request_log, "2206", "预结算")
  10865. userJSONBytes, _ := json.Marshal(dat)
  10866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10867. utils.ErrorLog("解析失败:%v", err)
  10868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10869. return
  10870. }
  10871. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10872. var result string
  10873. var request_log string
  10874. if his.IdCardType == 2 {
  10875. 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, "", acct_used_flag)
  10876. } else if his.IdCardType == 1 {
  10877. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10878. bas := strings.Split(psn_info.CardInfo, "|")
  10879. basNumber := bas[2]
  10880. card_sn := bas[3]
  10881. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, acct_used_flag)
  10882. } else {
  10883. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10884. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", acct_used_flag)
  10885. }
  10886. var dat map[string]interface{}
  10887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10888. fmt.Println(dat)
  10889. } else {
  10890. fmt.Println(err)
  10891. }
  10892. saveLog(result, request_log, "2206", "预结算")
  10893. userJSONBytes, _ := json.Marshal(dat)
  10894. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10895. utils.ErrorLog("解析失败:%v", err)
  10896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10897. return
  10898. }
  10899. } else {
  10900. var result string
  10901. var request_log string
  10902. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10903. allTotal = fmt.Sprintf("%2f", total_two)
  10904. if his.IdCardType == 4 {
  10905. 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)
  10906. } else {
  10907. 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)
  10908. }
  10909. var dat map[string]interface{}
  10910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10911. fmt.Println(dat)
  10912. } else {
  10913. fmt.Println(err)
  10914. }
  10915. saveLog(result, request_log, "2206", "预结算")
  10916. //userJSONBytes, _ := json.Marshal(dat)
  10917. //
  10918. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10919. // utils.ErrorLog("解析失败:%v", err)
  10920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10921. // return
  10922. //}
  10923. userJSONBytes, _ := json.Marshal(dat)
  10924. if miConfig.Code == "H15049901371" {
  10925. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10926. utils.ErrorLog("解析失败:%v", err)
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10931. res.Output = resSeven10265.Output
  10932. res.ErrMsg = resSeven10265.ErrMsg
  10933. res.Cainfo = resSeven10265.Cainfo
  10934. res.WarnMsg = resSeven10265.WarnMsg
  10935. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10936. res.Infcode = infocode
  10937. } else {
  10938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10939. utils.ErrorLog("解析失败:%v", err)
  10940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10941. return
  10942. }
  10943. }
  10944. }
  10945. if res.Infcode != 0 {
  10946. errlog := &models.HisOrderError{
  10947. UserOrgId: adminUser.CurrentOrgId,
  10948. Ctime: time.Now().Unix(),
  10949. Mtime: time.Now().Unix(),
  10950. Number: chrg_bchno,
  10951. ErrMsg: res.ErrMsg,
  10952. Status: 1,
  10953. PatientId: id,
  10954. RecordTime: recordDateTime,
  10955. Stage: 20,
  10956. }
  10957. service.CreateErrMsgLog(errlog)
  10958. c.ServeSuccessJSON(map[string]interface{}{
  10959. "failed_code": -10,
  10960. "msg": res.ErrMsg,
  10961. })
  10962. return
  10963. } else {
  10964. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10965. order.OrderStatus = 1
  10966. order.IsPre = 1
  10967. order.Status = 1
  10968. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10969. order.SetlId = res.Output.Setlinfo.SetlID
  10970. order.PsnNo = res.Output.Setlinfo.PsnNo
  10971. order.PsnName = res.Output.Setlinfo.PsnName
  10972. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10973. order.Certno = res.Output.Setlinfo.Certno
  10974. order.Gend = res.Output.Setlinfo.Gend
  10975. order.Naty = res.Output.Setlinfo.Naty
  10976. order.Age = res.Output.Setlinfo.Age
  10977. order.Insutype = res.Output.Setlinfo.Insutype
  10978. order.PsnType = res.Output.Setlinfo.PsnType
  10979. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10980. order.SetlTime = res.Output.Setlinfo.SetlTime
  10981. order.AcctUsedFlag = acct_used_flag
  10982. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10983. if res.Output.Setlinfo.MedType == "140101" {
  10984. order.MedType = "14"
  10985. } else {
  10986. order.MedType = res.Output.Setlinfo.MedType
  10987. }
  10988. if reg_type == 1112 {
  10989. order.MedType = "1112"
  10990. }
  10991. if reg_type == 1111 {
  10992. order.MedType = "1111"
  10993. }
  10994. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10995. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10996. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10997. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10998. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10999. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11000. order.HifpPay = res.Output.Setlinfo.HifpPay
  11001. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11002. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11003. order.HifesPay = res.Output.Setlinfo.HifesPay
  11004. order.HifobPay = res.Output.Setlinfo.HifobPay
  11005. order.MafPay = res.Output.Setlinfo.MafPay
  11006. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11007. order.OthPay = res.Output.Setlinfo.OthPay
  11008. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11009. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11010. order.AcctPay = res.Output.Setlinfo.AcctPay
  11011. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11012. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11013. order.Balc = res.Output.Setlinfo.Balc
  11014. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11015. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11016. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11017. order.ClrWay = res.Output.Setlinfo.ClrWay
  11018. order.Creator = order.Creator
  11019. order.Modify = roles.AdminUserId
  11020. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11021. detailStr := string(setlDetail)
  11022. order.SetlDetail = detailStr
  11023. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11024. err = service.UpDateOrder(order)
  11025. if err == nil {
  11026. c.ServeSuccessJSON(map[string]interface{}{
  11027. "msg": "预结算成功",
  11028. })
  11029. } else {
  11030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11031. return
  11032. }
  11033. }
  11034. } else {
  11035. adminUser := c.GetAdminUserInfo()
  11036. errlog := &models.HisOrderError{
  11037. UserOrgId: adminUser.CurrentOrgId,
  11038. Ctime: time.Now().Unix(),
  11039. Mtime: time.Now().Unix(),
  11040. ErrMsg: res.ErrMsg,
  11041. Status: 1,
  11042. PatientId: id,
  11043. RecordTime: recordDateTime,
  11044. Stage: 4,
  11045. }
  11046. service.CreateErrMsgLog(errlog)
  11047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11048. return
  11049. }
  11050. } else {
  11051. adminUser := c.GetAdminUserInfo()
  11052. errlog := &models.HisOrderError{
  11053. UserOrgId: adminUser.CurrentOrgId,
  11054. Ctime: time.Now().Unix(),
  11055. Mtime: time.Now().Unix(),
  11056. ErrMsg: res.ErrMsg,
  11057. Status: 1,
  11058. PatientId: id,
  11059. RecordTime: recordDateTime,
  11060. Stage: 4,
  11061. }
  11062. service.CreateErrMsgLog(errlog)
  11063. c.ServeSuccessJSON(map[string]interface{}{
  11064. "failed_code": -10,
  11065. "msg": res.ErrMsg,
  11066. })
  11067. return
  11068. }
  11069. }
  11070. }
  11071. }
  11072. //退款
  11073. func (c *HisApiController) Refund() {
  11074. order_id, _ := c.GetInt64("order_id")
  11075. admin_user_id, _ := c.GetInt64("admin_user_id")
  11076. adminUser := c.GetAdminUserInfo()
  11077. var order models.HisOrder
  11078. order, _ = service.GetHisOrderByID(order_id)
  11079. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11080. if order.ID == 0 {
  11081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11082. return
  11083. }
  11084. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11087. if config.IsOpen == 1 { //对接了医保,走医保流程
  11088. var res ResultSixteen
  11089. var resSixteen10265 ResultSixteen10265
  11090. var src_resquest string
  11091. var result string
  11092. if miConfig.MdtrtareaAdmvs == "421300" {
  11093. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  11094. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11096. resp3, requestErr3 := http.Get(api3)
  11097. if requestErr3 != nil {
  11098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11099. return
  11100. }
  11101. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11102. if ioErr3 != nil {
  11103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11105. return
  11106. }
  11107. var respJSON3 map[string]interface{}
  11108. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11111. return
  11112. }
  11113. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11114. userJSONBytes3, _ := json.Marshal(respJSON3)
  11115. fmt.Println("log")
  11116. fmt.Println(string(userJSONBytes3))
  11117. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  11118. utils.ErrorLog("解析失败:%v", err)
  11119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11120. return
  11121. }
  11122. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11123. var api3 string
  11124. if miConfig.MdtrtareaAdmvs == "320921" {
  11125. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11126. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11128. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11129. } else {
  11130. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11131. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11132. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11133. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11134. }
  11135. resp3, requestErr3 := http.Get(api3)
  11136. if requestErr3 != nil {
  11137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11138. return
  11139. }
  11140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11141. if ioErr3 != nil {
  11142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11144. return
  11145. }
  11146. var respJSON3 map[string]interface{}
  11147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11150. return
  11151. }
  11152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11153. userJSONBytes3, _ := json.Marshal(respJSON3)
  11154. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  11155. utils.ErrorLog("解析失败:%v", err)
  11156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. return
  11158. }
  11159. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11160. res.Output = resSixteen10265.Output
  11161. res.ErrMsg = resSixteen10265.ErrMsg
  11162. res.Cainfo = resSixteen10265.Cainfo
  11163. res.WarnMsg = resSixteen10265.WarnMsg
  11164. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11165. res.Infcode = infocode
  11166. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11167. 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)
  11168. var dat map[string]interface{}
  11169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11170. fmt.Println(dat)
  11171. } else {
  11172. fmt.Println(err)
  11173. }
  11174. saveLog(result, src_resquest, "2208", "退费")
  11175. userJSONBytes, _ := json.Marshal(dat)
  11176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11177. utils.ErrorLog("解析失败:%v", err)
  11178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11179. return
  11180. }
  11181. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11182. 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, "")
  11183. var dat map[string]interface{}
  11184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11185. fmt.Println(dat)
  11186. } else {
  11187. fmt.Println(err)
  11188. }
  11189. saveLog(result, src_resquest, "2208", "退费")
  11190. userJSONBytes, _ := json.Marshal(dat)
  11191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11192. utils.ErrorLog("解析失败:%v", err)
  11193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11194. return
  11195. }
  11196. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11197. 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, "")
  11198. var dat map[string]interface{}
  11199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11200. fmt.Println(dat)
  11201. } else {
  11202. fmt.Println(err)
  11203. }
  11204. saveLog(result, src_resquest, "2208", "退费")
  11205. userJSONBytes, _ := json.Marshal(dat)
  11206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11207. utils.ErrorLog("解析失败:%v", err)
  11208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11209. return
  11210. }
  11211. } else {
  11212. if miConfig.Code == "H15049901371" {
  11213. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11214. var dat map[string]interface{}
  11215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11216. fmt.Println(dat)
  11217. } else {
  11218. fmt.Println(err)
  11219. }
  11220. saveLog(result, src_resquest, "2208", "退费")
  11221. userJSONBytes, _ := json.Marshal(dat)
  11222. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  11223. utils.ErrorLog("解析失败:%v", err)
  11224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11225. return
  11226. }
  11227. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11228. res.Output = resSixteen10265.Output
  11229. res.ErrMsg = resSixteen10265.ErrMsg
  11230. res.Cainfo = resSixteen10265.Cainfo
  11231. res.WarnMsg = resSixteen10265.WarnMsg
  11232. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11233. res.Infcode = infocode
  11234. } else {
  11235. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11236. var dat map[string]interface{}
  11237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11238. fmt.Println(dat)
  11239. } else {
  11240. fmt.Println(err)
  11241. }
  11242. saveLog(result, src_resquest, "2208", "退费")
  11243. userJSONBytes, _ := json.Marshal(dat)
  11244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11245. utils.ErrorLog("解析失败:%v", err)
  11246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11247. return
  11248. }
  11249. }
  11250. }
  11251. if res.Infcode == 0 {
  11252. var res2 ResultSix
  11253. var resSix10265 ResultSix10265
  11254. if miConfig.MdtrtareaAdmvs == "421300" {
  11255. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11256. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11258. resp3, requestErr3 := http.Get(api3)
  11259. if requestErr3 != nil {
  11260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11261. return
  11262. }
  11263. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11264. if ioErr3 != nil {
  11265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11267. return
  11268. }
  11269. var respJSON3 map[string]interface{}
  11270. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. return
  11274. }
  11275. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11276. userJSONBytes3, _ := json.Marshal(respJSON3)
  11277. fmt.Println("log")
  11278. fmt.Println(string(userJSONBytes3))
  11279. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11280. utils.ErrorLog("解析失败:%v", err)
  11281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11282. return
  11283. }
  11284. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11285. var api3 string
  11286. if miConfig.MdtrtareaAdmvs == "320921" {
  11287. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11288. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11290. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11291. } else {
  11292. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11293. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11294. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11295. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11296. }
  11297. resp3, requestErr3 := http.Get(api3)
  11298. if requestErr3 != nil {
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11300. return
  11301. }
  11302. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11303. if ioErr3 != nil {
  11304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11306. return
  11307. }
  11308. var respJSON3 map[string]interface{}
  11309. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11312. return
  11313. }
  11314. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11315. userJSONBytes3, _ := json.Marshal(respJSON3)
  11316. fmt.Println("log")
  11317. fmt.Println(string(userJSONBytes3))
  11318. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11319. utils.ErrorLog("解析失败:%v", err)
  11320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11321. return
  11322. }
  11323. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11324. res2.Output = resSix10265.Output
  11325. res2.ErrMsg = resSix10265.ErrMsg
  11326. res2.Cainfo = resSix10265.Cainfo
  11327. res2.WarnMsg = resSix10265.WarnMsg
  11328. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11329. res2.Infcode = infocode
  11330. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11331. 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)
  11332. var dat map[string]interface{}
  11333. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11334. fmt.Println(dat)
  11335. } else {
  11336. fmt.Println(err)
  11337. }
  11338. saveLog(result2, src_request, "2205", "撤销明细")
  11339. userJSONBytes, _ := json.Marshal(dat)
  11340. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11341. utils.ErrorLog("解析失败:%v", err)
  11342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11343. return
  11344. }
  11345. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11346. 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, "")
  11347. var dat map[string]interface{}
  11348. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11349. fmt.Println(dat)
  11350. } else {
  11351. fmt.Println(err)
  11352. }
  11353. saveLog(result2, src_request, "2205", "撤销明细")
  11354. userJSONBytes, _ := json.Marshal(dat)
  11355. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11356. utils.ErrorLog("解析失败:%v", err)
  11357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11358. return
  11359. }
  11360. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11361. 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, "")
  11362. var dat map[string]interface{}
  11363. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11364. fmt.Println(dat)
  11365. } else {
  11366. fmt.Println(err)
  11367. }
  11368. saveLog(result2, src_request, "2205", "撤销明细")
  11369. userJSONBytes, _ := json.Marshal(dat)
  11370. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11371. utils.ErrorLog("解析失败:%v", err)
  11372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11373. return
  11374. }
  11375. } else {
  11376. if miConfig.Code == "H15049901371" {
  11377. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11378. var dat map[string]interface{}
  11379. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11380. fmt.Println(dat)
  11381. } else {
  11382. fmt.Println(err)
  11383. }
  11384. saveLog(result2, src_request, "2205", "撤销明细")
  11385. userJSONBytes, _ := json.Marshal(dat)
  11386. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11387. utils.ErrorLog("解析失败:%v", err)
  11388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11389. return
  11390. }
  11391. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11392. res2.Output = resSix10265.Output
  11393. res2.ErrMsg = resSix10265.ErrMsg
  11394. res2.Cainfo = resSix10265.Cainfo
  11395. res2.WarnMsg = resSix10265.WarnMsg
  11396. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11397. res2.Infcode = infocode
  11398. } else {
  11399. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11400. var dat map[string]interface{}
  11401. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11402. fmt.Println(dat)
  11403. } else {
  11404. fmt.Println(err)
  11405. }
  11406. saveLog(result2, src_request, "2205", "撤销明细")
  11407. userJSONBytes, _ := json.Marshal(dat)
  11408. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11409. utils.ErrorLog("解析失败:%v", err)
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return
  11412. }
  11413. }
  11414. }
  11415. if res2.Infcode == 0 {
  11416. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  11417. if err == nil {
  11418. //当押金不为零时产生退费记录
  11419. if order.Decimal != 0 {
  11420. tmp := strconv.FormatInt(order.ID, 10)
  11421. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  11422. if err != nil {
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return
  11425. }
  11426. }
  11427. c.ServeSuccessJSON(map[string]interface{}{
  11428. "msg": "退费成功",
  11429. })
  11430. } else {
  11431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11432. return
  11433. }
  11434. } else {
  11435. c.ServeSuccessJSON(map[string]interface{}{
  11436. "code": -10,
  11437. "msg": res2.ErrMsg,
  11438. })
  11439. }
  11440. } else {
  11441. c.ServeSuccessJSON(map[string]interface{}{
  11442. "code": -10,
  11443. "msg": res.ErrMsg,
  11444. })
  11445. }
  11446. }
  11447. }
  11448. func (c *HisApiController) RefundNumber() {
  11449. record_time := c.GetString("record_time")
  11450. //patient_id, _ := c.GetInt64("patient_id")
  11451. admin_user_id, _ := c.GetInt64("admin_user_id")
  11452. his_patient_id, _ := c.GetInt64("id")
  11453. timeLayout := "2006-01-02"
  11454. loc, _ := time.LoadLocation("Local")
  11455. adminUser := c.GetAdminUserInfo()
  11456. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11457. fmt.Println(err)
  11458. if err != nil {
  11459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11460. return
  11461. }
  11462. recordDateTime := theTime.Unix()
  11463. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11464. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  11465. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11466. //order, _ := service.GetHisOrderByID(order_id)
  11467. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11468. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11469. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11470. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  11471. if count > 0 {
  11472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  11473. return
  11474. }
  11475. if config.IsOpen == 1 { //对接了医保,走医保流程
  11476. var res2 ResultSix
  11477. var resSix10265 ResultSix10265
  11478. if miConfig.MdtrtareaAdmvs == "421300" {
  11479. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  11480. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11481. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11482. resp3, requestErr3 := http.Get(api3)
  11483. if requestErr3 != nil {
  11484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11485. return
  11486. }
  11487. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11488. if ioErr3 != nil {
  11489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11491. return
  11492. }
  11493. var respJSON3 map[string]interface{}
  11494. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11497. return
  11498. }
  11499. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11500. userJSONBytes3, _ := json.Marshal(respJSON3)
  11501. fmt.Println("log")
  11502. fmt.Println(string(userJSONBytes3))
  11503. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11504. utils.ErrorLog("解析失败:%v", err)
  11505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11506. return
  11507. }
  11508. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11509. var api3 string
  11510. if miConfig.MdtrtareaAdmvs == "320921" {
  11511. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11512. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11514. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11515. } else {
  11516. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11517. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11518. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11519. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11520. }
  11521. resp3, requestErr3 := http.Get(api3)
  11522. if requestErr3 != nil {
  11523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11524. return
  11525. }
  11526. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11527. if ioErr3 != nil {
  11528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11530. return
  11531. }
  11532. var respJSON3 map[string]interface{}
  11533. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11536. return
  11537. }
  11538. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11539. userJSONBytes3, _ := json.Marshal(respJSON3)
  11540. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11541. utils.ErrorLog("解析失败:%v", err)
  11542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11543. return
  11544. }
  11545. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11546. res2.Output = resSix10265.Output
  11547. res2.ErrMsg = resSix10265.ErrMsg
  11548. res2.Cainfo = resSix10265.Cainfo
  11549. res2.WarnMsg = resSix10265.WarnMsg
  11550. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11551. res2.Infcode = infocode
  11552. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11553. 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)
  11554. var dat map[string]interface{}
  11555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11556. fmt.Println(dat)
  11557. } else {
  11558. fmt.Println(err)
  11559. }
  11560. saveLog(result, request, "2202", "退号")
  11561. userJSONBytes, _ := json.Marshal(dat)
  11562. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11563. utils.ErrorLog("解析失败:%v", err)
  11564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11565. return
  11566. }
  11567. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11568. 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, "")
  11569. var dat map[string]interface{}
  11570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11571. fmt.Println(dat)
  11572. } else {
  11573. fmt.Println(err)
  11574. }
  11575. saveLog(result, request, "2202", "退号")
  11576. userJSONBytes, _ := json.Marshal(dat)
  11577. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11578. utils.ErrorLog("解析失败:%v", err)
  11579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11580. return
  11581. }
  11582. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11583. 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, "")
  11584. var dat map[string]interface{}
  11585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11586. fmt.Println(dat)
  11587. } else {
  11588. fmt.Println(err)
  11589. }
  11590. saveLog(result, request, "2202", "退号")
  11591. userJSONBytes, _ := json.Marshal(dat)
  11592. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11593. utils.ErrorLog("解析失败:%v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return
  11596. }
  11597. } else {
  11598. var api3 string
  11599. if miConfig.Code == "H15049901371" {
  11600. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11601. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11603. } else {
  11604. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11605. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11607. }
  11608. resp3, requestErr3 := http.Get(api3)
  11609. if requestErr3 != nil {
  11610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11611. return
  11612. }
  11613. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11614. if ioErr3 != nil {
  11615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11617. return
  11618. }
  11619. var respJSON3 map[string]interface{}
  11620. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11623. return
  11624. }
  11625. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11626. userJSONBytes3, _ := json.Marshal(respJSON3)
  11627. if miConfig.Code == "H15049901371" {
  11628. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11629. utils.ErrorLog("解析失败:%v", err)
  11630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11631. return
  11632. }
  11633. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11634. res2.Output = resSix10265.Output
  11635. res2.ErrMsg = resSix10265.ErrMsg
  11636. res2.Cainfo = resSix10265.Cainfo
  11637. res2.WarnMsg = resSix10265.WarnMsg
  11638. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11639. res2.Infcode = infocode
  11640. } else {
  11641. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11642. utils.ErrorLog("解析失败:%v", err)
  11643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11644. return
  11645. }
  11646. }
  11647. }
  11648. if res2.Infcode == 0 {
  11649. if err == nil {
  11650. c.ServeSuccessJSON(map[string]interface{}{
  11651. "msg": "退号成功",
  11652. })
  11653. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  11654. } else {
  11655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11656. return
  11657. }
  11658. } else {
  11659. c.ServeSuccessJSON(map[string]interface{}{
  11660. "code": -10,
  11661. "msg": res2.ErrMsg,
  11662. })
  11663. }
  11664. } else {
  11665. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  11666. //if err == nil {
  11667. // c.ServeSuccessJSON(map[string]interface{}{
  11668. // "msg": "退费成功",
  11669. // })
  11670. //} else {
  11671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11672. // return
  11673. //}
  11674. }
  11675. }
  11676. func (c *HisApiController) RefundDetail() {
  11677. order_id, _ := c.GetInt64("order_id")
  11678. admin_user_id, _ := c.GetInt64("admin_user_id")
  11679. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11680. number := c.GetString("number")
  11681. record_time := c.GetString("record_time")
  11682. patient_id, _ := c.GetInt64("patient_id")
  11683. //med_type, _ := c.GetInt64("med_type")
  11684. timeLayout := "2006-01-02"
  11685. loc, _ := time.LoadLocation("Local")
  11686. adminUser := c.GetAdminUserInfo()
  11687. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11688. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11689. fmt.Println(err)
  11690. if err != nil {
  11691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11692. return
  11693. }
  11694. recordDateTime := theTime.Unix()
  11695. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11696. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11698. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11699. var order models.HisOrder
  11700. order, _ = service.GetHisOrderByID(order_id)
  11701. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11702. if config.IsOpen == 1 { //对接了医保,走医保流程
  11703. var res2 ResultSix
  11704. if miConfig.MdtrtareaAdmvs == "421300" {
  11705. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11706. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11708. resp3, requestErr3 := http.Get(api3)
  11709. if requestErr3 != nil {
  11710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11711. return
  11712. }
  11713. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11714. if ioErr3 != nil {
  11715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11717. return
  11718. }
  11719. var respJSON3 map[string]interface{}
  11720. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11723. return
  11724. }
  11725. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11726. userJSONBytes3, _ := json.Marshal(respJSON3)
  11727. fmt.Println("log")
  11728. fmt.Println(string(userJSONBytes3))
  11729. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11730. utils.ErrorLog("解析失败:%v", err)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return
  11733. }
  11734. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11735. if err == nil {
  11736. c.ServeSuccessJSON(map[string]interface{}{
  11737. "msg": "撤销明细成功",
  11738. })
  11739. return
  11740. } else {
  11741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11742. return
  11743. }
  11744. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11745. var resSix10265 ResultSix10265
  11746. var api3 string
  11747. if miConfig.MdtrtareaAdmvs == "320921" {
  11748. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11749. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11751. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11752. } else {
  11753. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11754. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11755. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11757. }
  11758. resp3, requestErr3 := http.Get(api3)
  11759. if requestErr3 != nil {
  11760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11761. return
  11762. }
  11763. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11764. if ioErr3 != nil {
  11765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11767. return
  11768. }
  11769. var respJSON3 map[string]interface{}
  11770. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11773. return
  11774. }
  11775. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11776. userJSONBytes3, _ := json.Marshal(respJSON3)
  11777. fmt.Println("log")
  11778. fmt.Println(string(userJSONBytes3))
  11779. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11780. utils.ErrorLog("解析失败:%v", err)
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11782. return
  11783. }
  11784. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11785. res2.Output = resSix10265.Output
  11786. res2.ErrMsg = resSix10265.ErrMsg
  11787. res2.Cainfo = resSix10265.Cainfo
  11788. res2.WarnMsg = resSix10265.WarnMsg
  11789. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11790. res2.Infcode = infocode
  11791. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11792. if err == nil {
  11793. c.ServeSuccessJSON(map[string]interface{}{
  11794. "msg": "撤销明细成功",
  11795. })
  11796. return
  11797. } else {
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return
  11800. }
  11801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11802. 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)
  11803. var dat map[string]interface{}
  11804. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11805. fmt.Println(dat)
  11806. } else {
  11807. fmt.Println(err)
  11808. }
  11809. saveLog(result2, src_request, "2205", "撤销明细")
  11810. userJSONBytes, _ := json.Marshal(dat)
  11811. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11812. utils.ErrorLog("解析失败:%v", err)
  11813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11814. return
  11815. }
  11816. if res2.Infcode == 0 {
  11817. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11818. if err == nil {
  11819. c.ServeSuccessJSON(map[string]interface{}{
  11820. "msg": "撤销明细成功",
  11821. })
  11822. return
  11823. } else {
  11824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11825. return
  11826. }
  11827. } else {
  11828. c.ServeSuccessJSON(map[string]interface{}{
  11829. "code": -10,
  11830. "msg": res2.ErrMsg,
  11831. })
  11832. }
  11833. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11834. 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, "")
  11835. var dat map[string]interface{}
  11836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11837. fmt.Println(dat)
  11838. } else {
  11839. fmt.Println(err)
  11840. }
  11841. saveLog(result2, src_request, "2205", "撤销明细")
  11842. userJSONBytes, _ := json.Marshal(dat)
  11843. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11844. utils.ErrorLog("解析失败:%v", err)
  11845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11846. return
  11847. }
  11848. if res2.Infcode == 0 {
  11849. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11850. if err == nil {
  11851. c.ServeSuccessJSON(map[string]interface{}{
  11852. "msg": "撤销明细成功",
  11853. })
  11854. return
  11855. } else {
  11856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11857. return
  11858. }
  11859. } else {
  11860. c.ServeSuccessJSON(map[string]interface{}{
  11861. "code": -10,
  11862. "msg": res2.ErrMsg,
  11863. })
  11864. }
  11865. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11866. 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, "")
  11867. var dat map[string]interface{}
  11868. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11869. fmt.Println(dat)
  11870. } else {
  11871. fmt.Println(err)
  11872. }
  11873. saveLog(result2, src_request, "2205", "撤销明细")
  11874. userJSONBytes, _ := json.Marshal(dat)
  11875. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11876. utils.ErrorLog("解析失败:%v", err)
  11877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11878. return
  11879. }
  11880. if res2.Infcode == 0 {
  11881. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11882. if err == nil {
  11883. c.ServeSuccessJSON(map[string]interface{}{
  11884. "msg": "撤销明细成功",
  11885. })
  11886. return
  11887. } else {
  11888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11889. return
  11890. }
  11891. } else {
  11892. c.ServeSuccessJSON(map[string]interface{}{
  11893. "code": -10,
  11894. "msg": res2.ErrMsg,
  11895. })
  11896. }
  11897. } else {
  11898. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11899. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11901. resp2, requestErr2 := http.Get(api2)
  11902. if requestErr2 != nil {
  11903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11904. return
  11905. }
  11906. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11907. if ioErr2 != nil {
  11908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11910. return
  11911. }
  11912. var respJSON2 map[string]interface{}
  11913. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11916. return
  11917. }
  11918. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11919. if err == nil {
  11920. c.ServeSuccessJSON(map[string]interface{}{
  11921. "msg": "撤销明细成功",
  11922. })
  11923. return
  11924. } else {
  11925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11926. return
  11927. }
  11928. }
  11929. } else {
  11930. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11931. if err == nil {
  11932. c.ServeSuccessJSON(map[string]interface{}{
  11933. "msg": "退费成功",
  11934. })
  11935. } else {
  11936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11937. return
  11938. }
  11939. }
  11940. }
  11941. //对账
  11942. func (c *HisApiController) GetCheckAccount() {
  11943. start_time := c.GetString("start_time")
  11944. end_time := c.GetString("end_time")
  11945. insutype := c.GetString("insutype")
  11946. clr_type := c.GetString("clr_type")
  11947. clr_org := c.GetString("clr_optins")
  11948. admin_user_id, _ := c.GetInt64("admin_user_id")
  11949. adminUser := c.GetAdminUserInfo()
  11950. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11951. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11952. if len(clr_org) == 0 {
  11953. clr_org = miConfig.MdtrtareaAdmvs
  11954. }
  11955. timeLayout := "2006-01-02"
  11956. loc, _ := time.LoadLocation("Local")
  11957. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11958. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11959. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11960. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11961. fixmedins_setl_cnt := int64(len(orders))
  11962. var medfee_sumamt float64
  11963. var acct_pay float64
  11964. var fund_pay_sumamt float64
  11965. for _, item := range orders {
  11966. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11967. acct_pay = acct_pay + item.AcctPay
  11968. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11969. }
  11970. var user_name string
  11971. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11972. if role.ID == 0 {
  11973. user_name = "xxx"
  11974. } else {
  11975. user_name = role.UserName
  11976. }
  11977. var res ResultEight
  11978. var res10188 ResultEightFor10188
  11979. if config.IsOpen == 1 {
  11980. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11981. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11982. "insutype=" + insutype +
  11983. "&clr_type=" + clr_type +
  11984. "&setl_optins=" + clr_org +
  11985. "&stmt_begndate=" + start_time +
  11986. "&stm_enddate=" + end_time +
  11987. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11988. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11989. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11990. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11991. "&fixmedins_code=" + miConfig.Code +
  11992. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11993. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11994. "&secret_key=" + miConfig.SecretKey +
  11995. "&org_name=" + miConfig.OrgName +
  11996. "&doctor=" + user_name +
  11997. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11998. fmt.Println(api)
  11999. resp, requestErr := http.Get(api)
  12000. if requestErr != nil {
  12001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12002. return
  12003. }
  12004. body, ioErr := ioutil.ReadAll(resp.Body)
  12005. fmt.Println(body)
  12006. if ioErr != nil {
  12007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. var respJSON map[string]interface{}
  12012. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12015. return
  12016. }
  12017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12018. userJSONBytes, _ := json.Marshal(respJSON)
  12019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12020. utils.ErrorLog("解析失败:%v", err)
  12021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12022. return
  12023. }
  12024. res.InfRefmsgid = res10188.InfRefmsgid
  12025. res.Output = res10188.Output
  12026. res.ErrMsg = res10188.ErrMsg
  12027. res.Cainfo = res10188.Cainfo
  12028. res.WarnMsg = res10188.WarnMsg
  12029. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12030. res.Infcode = infocode
  12031. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12032. if clr_type == "11" {
  12033. fixmedins_setl_cnt = 2
  12034. }
  12035. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  12036. "insutype=" + insutype +
  12037. "&clr_type=" + "51" +
  12038. "&setl_optins=" + clr_org +
  12039. "&stmt_begndate=" + start_time +
  12040. "&stm_enddate=" + end_time +
  12041. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12042. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12043. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12044. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12045. "&fixmedins_code=" + miConfig.Code +
  12046. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12047. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12048. "&secret_key=" + miConfig.SecretKey +
  12049. "&org_name=" + miConfig.OrgName +
  12050. "&doctor=" + user_name
  12051. resp, requestErr := http.Get(api)
  12052. if requestErr != nil {
  12053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12054. return
  12055. }
  12056. body, ioErr := ioutil.ReadAll(resp.Body)
  12057. if ioErr != nil {
  12058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12060. return
  12061. }
  12062. var respJSON map[string]interface{}
  12063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12066. return
  12067. }
  12068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12069. result, _ := json.Marshal(respJSON)
  12070. fmt.Println("log")
  12071. fmt.Println(string(result))
  12072. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  12073. utils.ErrorLog("解析失败:%v", err)
  12074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12075. return
  12076. }
  12077. res.InfRefmsgid = res10188.InfRefmsgid
  12078. res.Output = res10188.Output
  12079. res.ErrMsg = res10188.ErrMsg
  12080. res.Cainfo = res10188.Cainfo
  12081. res.WarnMsg = res10188.WarnMsg
  12082. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12083. res.Infcode = infocode
  12084. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12085. var baseParams models.BaseParams
  12086. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12087. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12088. baseParams.SecretKey = miConfig.SecretKey
  12089. baseParams.OrgName = miConfig.OrgName
  12090. baseParams.FixmedinsCode = miConfig.Code
  12091. baseParams.EncKey = miConfig.EncKey
  12092. baseParams.AppSecret = miConfig.AppSecret
  12093. baseParams.SignKey = miConfig.SignKey
  12094. baseParams.AppID = miConfig.Code
  12095. baseParams.Doctor = role.UserName
  12096. baseParams.RequestUrl = miConfig.Url
  12097. businessParams := models.BusinessParams{
  12098. Insutype: insutype,
  12099. ClrType: clr_type,
  12100. SetlOptins: clr_org,
  12101. StmtBegndate: start_time,
  12102. StmtEnddate: end_time,
  12103. MedfeeSumamt: medfee_sumamt,
  12104. FundPaySumamt: fund_pay_sumamt,
  12105. AcctPay: acct_pay,
  12106. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12107. }
  12108. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12109. fmt.Println(requestLog)
  12110. fmt.Println(result)
  12111. fmt.Println(err_msg)
  12112. var dat map[string]interface{}
  12113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12114. fmt.Println(dat)
  12115. } else {
  12116. fmt.Println(err)
  12117. }
  12118. userJSONBytes, _ := json.Marshal(dat)
  12119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12120. utils.ErrorLog("解析失败:%v", err)
  12121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12122. return
  12123. }
  12124. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12125. var baseParams models.BaseParams
  12126. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12127. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12128. baseParams.SecretKey = miConfig.SecretKey
  12129. baseParams.OrgName = miConfig.OrgName
  12130. baseParams.FixmedinsCode = miConfig.Code
  12131. baseParams.EncKey = miConfig.EncKey
  12132. baseParams.AppSecret = miConfig.AppSecret
  12133. baseParams.SignKey = miConfig.SignKey
  12134. baseParams.AppID = miConfig.Code
  12135. baseParams.Doctor = role.UserName
  12136. baseParams.RequestUrl = miConfig.Url
  12137. baseParams.AccessKey = miConfig.AccessKey
  12138. businessParams := models.BusinessParams{
  12139. Insutype: insutype,
  12140. ClrType: clr_type,
  12141. SetlOptins: "430822",
  12142. StmtBegndate: start_time,
  12143. StmtEnddate: end_time,
  12144. MedfeeSumamt: medfee_sumamt,
  12145. FundPaySumamt: fund_pay_sumamt,
  12146. AcctPay: acct_pay,
  12147. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12148. }
  12149. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  12150. fmt.Println(requestLog)
  12151. fmt.Println(result)
  12152. var dat map[string]interface{}
  12153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12154. fmt.Println(dat)
  12155. } else {
  12156. fmt.Println(err)
  12157. }
  12158. userJSONBytes, _ := json.Marshal(dat)
  12159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12160. utils.ErrorLog("解析失败:%v", err)
  12161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12162. return
  12163. }
  12164. } else if miConfig.MdtrtareaAdmvs == "" {
  12165. var baseParams models.BaseParams
  12166. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12167. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12168. baseParams.SecretKey = miConfig.SecretKey
  12169. baseParams.OrgName = miConfig.OrgName
  12170. baseParams.FixmedinsCode = miConfig.Code
  12171. baseParams.EncKey = miConfig.EncKey
  12172. baseParams.AppSecret = miConfig.AppSecret
  12173. baseParams.SignKey = miConfig.SignKey
  12174. baseParams.AppID = miConfig.Code
  12175. baseParams.Doctor = role.UserName
  12176. baseParams.RequestUrl = miConfig.Url
  12177. businessParams := models.BusinessParams{
  12178. Insutype: insutype,
  12179. ClrType: clr_type,
  12180. SetlOptins: clr_org,
  12181. StmtBegndate: start_time,
  12182. StmtEnddate: end_time,
  12183. MedfeeSumamt: medfee_sumamt,
  12184. FundPaySumamt: fund_pay_sumamt,
  12185. AcctPay: acct_pay,
  12186. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12187. }
  12188. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12189. fmt.Println(requestLog)
  12190. fmt.Println(result)
  12191. fmt.Println(err_msg)
  12192. var dat map[string]interface{}
  12193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12194. fmt.Println(dat)
  12195. } else {
  12196. fmt.Println(err)
  12197. }
  12198. userJSONBytes, _ := json.Marshal(dat)
  12199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12200. utils.ErrorLog("解析失败:%v", err)
  12201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12202. return
  12203. }
  12204. } else {
  12205. if len(clr_type) == 0 {
  12206. clr_type = "11"
  12207. }
  12208. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12209. "insutype=" + insutype +
  12210. "&clr_type=" + clr_type +
  12211. "&setl_optins=" + clr_org +
  12212. "&stmt_begndate=" + start_time +
  12213. "&stm_enddate=" + end_time +
  12214. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12215. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12216. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12217. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12218. "&fixmedins_code=" + miConfig.Code +
  12219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12220. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12221. "&secret_key=" + miConfig.SecretKey +
  12222. "&org_name=" + miConfig.OrgName +
  12223. "&doctor=" + user_name
  12224. fmt.Println(api)
  12225. resp, requestErr := http.Get(api)
  12226. if requestErr != nil {
  12227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12228. return
  12229. }
  12230. body, ioErr := ioutil.ReadAll(resp.Body)
  12231. fmt.Println(body)
  12232. if ioErr != nil {
  12233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. return
  12236. }
  12237. var respJSON map[string]interface{}
  12238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. return
  12242. }
  12243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12244. userJSONBytes, _ := json.Marshal(respJSON)
  12245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12246. utils.ErrorLog("解析失败:%v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. }
  12251. if res.Infcode == 0 {
  12252. if res.Output.Stmtinfo.StmtRslt == "0" {
  12253. micc := &models.MedicalInsuranceCostCompare{
  12254. StartTime: startime.Unix(),
  12255. EndTime: endtime.Unix(),
  12256. Insutype: insutype,
  12257. CheckType: 1,
  12258. Num: fixmedins_setl_cnt,
  12259. Mtime: time.Now().Unix(),
  12260. Status: 1,
  12261. UserOrgId: adminUser.CurrentOrgId,
  12262. CostTotal: medfee_sumamt,
  12263. FuncTotal: fund_pay_sumamt,
  12264. PsnPay: acct_pay,
  12265. Creator: admin_user_id,
  12266. Ctime: time.Now().Unix(),
  12267. ClrType: clr_type,
  12268. }
  12269. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  12270. if err == nil {
  12271. c.ServeSuccessJSON(map[string]interface{}{
  12272. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12273. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12274. })
  12275. } else {
  12276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12277. }
  12278. } else {
  12279. c.ServeSuccessJSON(map[string]interface{}{
  12280. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12281. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12282. })
  12283. }
  12284. } else {
  12285. c.ServeSuccessJSON(map[string]interface{}{
  12286. "code": -10,
  12287. "msg": res.ErrMsg,
  12288. })
  12289. }
  12290. }
  12291. }
  12292. func (c *HisApiController) Check310() {
  12293. adminUser := c.GetAdminUserInfo()
  12294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12295. var user_name string
  12296. user_name = "高慧裕"
  12297. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12298. "insutype=" + "310" +
  12299. "&clr_type=" + "" +
  12300. "&setl_optins=" + "441202" +
  12301. "&stmt_begndate=" + "2022-03-01" +
  12302. "&stm_enddate=" + "2022-03-31" +
  12303. "&medfee_sumamt=" + "194930.12" +
  12304. "&fund_pay_sumamt=" + "188741.46" +
  12305. "&acct_pay=" + "0" +
  12306. "&fixmedins_setl_cnt=" + "452" +
  12307. "&fixmedins_code=" + miConfig.Code +
  12308. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12309. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12310. "&secret_key=" + miConfig.SecretKey +
  12311. "&org_name=" + miConfig.OrgName +
  12312. "&doctor=" + user_name
  12313. fmt.Println(api)
  12314. resp, requestErr := http.Get(api)
  12315. if requestErr != nil {
  12316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12317. return
  12318. }
  12319. body, ioErr := ioutil.ReadAll(resp.Body)
  12320. fmt.Println(body)
  12321. if ioErr != nil {
  12322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12324. return
  12325. }
  12326. var respJSON map[string]interface{}
  12327. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12330. return
  12331. }
  12332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12333. userJSONBytes, _ := json.Marshal(respJSON)
  12334. var res ResultEight
  12335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12336. utils.ErrorLog("解析失败:%v", err)
  12337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12338. return
  12339. }
  12340. }
  12341. func (c *HisApiController) Check390() {
  12342. adminUser := c.GetAdminUserInfo()
  12343. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12344. var user_name string
  12345. user_name = "高慧裕"
  12346. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12347. "insutype=" + "390" +
  12348. "&clr_type=" + "" +
  12349. "&setl_optins=" + "441202" +
  12350. "&stmt_begndate=" + "2022-03-01" +
  12351. "&stm_enddate=" + "2022-03-31" +
  12352. "&medfee_sumamt=" + "1068448.89" +
  12353. "&fund_pay_sumamt=" + "1014677.62" +
  12354. "&acct_pay=" + "0" +
  12355. "&fixmedins_setl_cnt=" + "1950" +
  12356. "&fixmedins_code=" + miConfig.Code +
  12357. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12358. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12359. "&secret_key=" + miConfig.SecretKey +
  12360. "&org_name=" + miConfig.OrgName +
  12361. "&doctor=" + user_name
  12362. fmt.Println(api)
  12363. resp, requestErr := http.Get(api)
  12364. if requestErr != nil {
  12365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12366. return
  12367. }
  12368. body, ioErr := ioutil.ReadAll(resp.Body)
  12369. fmt.Println(body)
  12370. if ioErr != nil {
  12371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12373. return
  12374. }
  12375. var respJSON map[string]interface{}
  12376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12379. return
  12380. }
  12381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12382. userJSONBytes, _ := json.Marshal(respJSON)
  12383. var res ResultEight
  12384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12385. utils.ErrorLog("解析失败:%v", err)
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. }
  12390. //对账明细
  12391. func (c *HisApiController) GetCheckDetailAccount() {
  12392. start_time := c.GetString("start_time")
  12393. end_time := c.GetString("end_time")
  12394. admin_user_id, _ := c.GetInt64("admin_user_id")
  12395. adminUser := c.GetAdminUserInfo()
  12396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12397. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12398. timeLayout := "2006-01-02"
  12399. loc, _ := time.LoadLocation("Local")
  12400. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12401. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12402. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12403. rand.Seed(time.Now().UnixNano())
  12404. num := rand.Intn(30000)
  12405. Mkdir(miConfig.OrgName)
  12406. file := strconv.FormatInt(int64(num), 10)
  12407. file_name := file + ".txt"
  12408. zip_name := file + ".zip"
  12409. zip_path := miConfig.OrgName + "/" + zip_name
  12410. file_path := miConfig.OrgName + "/" + file_name
  12411. decimal.DivisionPrecision = 2
  12412. var medfee_sumamt float64
  12413. var psn_cash_pay float64
  12414. var fund_pay_sumamt float64
  12415. fixmedins_setl_cnt := int64(len(orders))
  12416. for _, item := range orders {
  12417. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12418. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  12419. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12420. }
  12421. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  12422. defer f.Close()
  12423. if err != nil {
  12424. fmt.Println(err.Error())
  12425. } else {
  12426. for _, item := range orders {
  12427. var refd_setl_flag string
  12428. if item.OrderStatus == 2 {
  12429. refd_setl_flag = "0"
  12430. var str string
  12431. str = item.SetlId + " " +
  12432. item.MdtrtId + " " +
  12433. item.PsnNo + " " +
  12434. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12435. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12436. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  12437. _, err = f.Write([]byte(str))
  12438. }
  12439. if item.OrderStatus == 3 {
  12440. var str string
  12441. str = item.SetlId + " " +
  12442. item.MdtrtId + " " +
  12443. item.PsnNo + " " +
  12444. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12445. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12446. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  12447. _, err = f.Write([]byte(str))
  12448. var str2 string
  12449. str2 = item.SetlId + " " +
  12450. item.MdtrtId + " " +
  12451. item.PsnNo + " " +
  12452. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  12453. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  12454. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  12455. _, err = f.Write([]byte(str2))
  12456. }
  12457. }
  12458. }
  12459. Zip(file_path, zip_path)
  12460. fmt.Println(ReadFile(zip_path))
  12461. fmt.Println(string(ReadFile(zip_path)))
  12462. if config.IsOpen == 1 {
  12463. var user_name string
  12464. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12465. if role.ID == 0 {
  12466. user_name = "管理员"
  12467. } else {
  12468. user_name = role.UserName
  12469. }
  12470. baseParams := models.BaseParams{
  12471. SecretKey: miConfig.SecretKey,
  12472. FixmedinsCode: miConfig.Code,
  12473. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12474. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12475. OrgName: miConfig.OrgName,
  12476. Doctor: user_name,
  12477. }
  12478. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  12479. var dat map[string]interface{}
  12480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12481. fmt.Println(dat)
  12482. } else {
  12483. fmt.Println(err)
  12484. }
  12485. userJSONBytes, _ := json.Marshal(dat)
  12486. var res ResultNine
  12487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12488. utils.ErrorLog("解析失败:%v", err)
  12489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12490. return
  12491. }
  12492. if res.Infcode == 0 {
  12493. fileNo := res.Output.FileQuryNo
  12494. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  12495. "file_qury_no=" + fileNo +
  12496. "&setl_optins=" + "定点医保中心" +
  12497. "&stmt_begndate=" + start_time +
  12498. "&stm_enddate=" + end_time +
  12499. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12500. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12501. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  12502. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12503. "&fixmedins_code=" + miConfig.Code +
  12504. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12505. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12506. "&secret_key=" + miConfig.SecretKey +
  12507. "&org_name=" + miConfig.OrgName +
  12508. "&doctor=" + user_name
  12509. resp, requestErr := http.Get(api)
  12510. if requestErr != nil {
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return
  12513. }
  12514. body, ioErr := ioutil.ReadAll(resp.Body)
  12515. if ioErr != nil {
  12516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12518. return
  12519. }
  12520. var respJSON map[string]interface{}
  12521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12524. return
  12525. }
  12526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12527. userJSONBytes, _ := json.Marshal(respJSON)
  12528. var res ResultTen
  12529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12530. utils.ErrorLog("解析失败:%v", err)
  12531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12532. return
  12533. }
  12534. if res.Infcode == 0 {
  12535. service.Gdyb9102(baseParams, zip_name, fileNo)
  12536. micc := &models.MedicalInsuranceCostCompare{
  12537. StartTime: startime.Unix(),
  12538. EndTime: endtime.Unix(),
  12539. Insutype: "0",
  12540. CheckType: 2,
  12541. Num: fixmedins_setl_cnt,
  12542. Mtime: time.Now().Unix(),
  12543. Status: 1,
  12544. UserOrgId: adminUser.CurrentOrgId,
  12545. CostTotal: medfee_sumamt,
  12546. FuncTotal: fund_pay_sumamt,
  12547. PsnPay: psn_cash_pay,
  12548. Creator: admin_user_id,
  12549. Ctime: time.Now().Unix(),
  12550. }
  12551. service.CreateMedicalInsuranceCostCompareRecord(micc)
  12552. c.ServeSuccessJSON(map[string]interface{}{
  12553. "msg": "明细对账成功",
  12554. })
  12555. }
  12556. } else {
  12557. }
  12558. }
  12559. }
  12560. type CustomOrderInfo struct {
  12561. Name string
  12562. Spec string
  12563. Unit string
  12564. Count float64
  12565. Price float64
  12566. Total float64
  12567. }
  12568. func (c *HisApiController) GetSettleAccounts() {
  12569. //id, _ := c.GetInt64("id")
  12570. //record_time := c.GetString("record_time")
  12571. order_id, _ := c.GetInt64("order_id")
  12572. admin_user_id, _ := c.GetInt64("admin_user_id")
  12573. //timeLayout := "2006-01-02"
  12574. //loc, _ := time.LoadLocation("Local")
  12575. //
  12576. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12577. //if err != nil {
  12578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12579. // return
  12580. //}
  12581. //recordDateTime := theTime.Unix()
  12582. adminUser := c.GetAdminUserInfo()
  12583. order, _ := service.GetHisOrderByID(order_id)
  12584. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12585. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  12586. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  12587. orderInfos = append(orderInfos, orderInfos_two...)
  12588. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12589. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  12590. var diagnosis_ids []string
  12591. if his.ID > 0 {
  12592. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  12593. } else {
  12594. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  12595. }
  12596. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  12597. var dia_config []*models.HisXtDiagnoseConfig
  12598. var name string
  12599. for _, item := range diagnosis_ids {
  12600. id, _ := strconv.ParseInt(item, 10, 64)
  12601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12602. dia_config = append(dia_config, &diagnosisConfig)
  12603. if len(name) == 0 {
  12604. name = diagnosisConfig.ClassName
  12605. } else {
  12606. name = name + "," + diagnosisConfig.ClassName
  12607. }
  12608. }
  12609. var bedCostTotal float64 = 0 //床位总费
  12610. var bedCostSelfTotal float64 = 0 //床位自费
  12611. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12612. var bedSelfTotal float64 = 0 //床位部分项目自费
  12613. var bedInscpTotal float64 = 0 //床位部分项目自费
  12614. var operationCostTotal float64 = 0 //手术费
  12615. var operationCostSelfTotal float64 = 0 //手术费
  12616. var operationCostPartSelfTotal float64 = 0 //手术费
  12617. var operationSelfTotal float64 = 0 //床位部分项目自费
  12618. var operationInscpTotal float64 = 0 //床位部分项目自费
  12619. var otherCostTotal float64 = 0 //其他费用
  12620. var otherCostSelfTotal float64 = 0 //其他费用
  12621. var otherCostPartSelfTotal float64 = 0 //其他费用
  12622. var otherSelfTotal float64 = 0 //床位部分项目自费
  12623. var otherInscpTotal float64 = 0 //床位部分项目自费
  12624. var materialCostTotal float64 = 0 //材料费
  12625. var materialCostSelfTotal float64 = 0 //材料费
  12626. var materialCostPartSelfTotal float64 = 0 //材料费
  12627. var materialSelfTotal float64 = 0 //床位部分项目自费
  12628. var materialInscpTotal float64 = 0 //床位部分项目自费
  12629. var westernMedicineCostTotal float64 = 0 //西药费
  12630. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12631. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12632. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  12633. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  12634. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12635. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12636. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12637. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  12638. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  12639. var checkCostTotal float64 = 0 //检查费
  12640. var checkCostSelfTotal float64 = 0 //检查费
  12641. var checkCostPartSelfTotal float64 = 0 //检查费
  12642. var checkSelfTotal float64 = 0 //床位部分项目自费
  12643. var checkInscpTotal float64 = 0 //床位部分项目自费
  12644. var laboratoryCostTotal float64 = 0 //化验费
  12645. var laboratoryCostSelfTotal float64 = 0 //化验费
  12646. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12647. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  12648. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  12649. var treatCostTotal float64 = 0 //治疗费用
  12650. var treatCostSelfTotal float64 = 0 //治疗费用
  12651. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12652. var treatSelfTotal float64 = 0 //床位部分项目自费
  12653. var treatInscpTotal float64 = 0 //床位部分项目自费
  12654. decimal.DivisionPrecision = 2
  12655. for _, item := range orderInfos {
  12656. if item.MedChrgitmType == "01" { //床位费
  12657. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12658. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12659. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12660. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12661. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12662. }
  12663. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  12664. if item.MedChrgitmType == "03" { //检查费
  12665. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12666. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12667. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12668. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12669. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12670. }
  12671. } else {
  12672. if item.MedChrgitmType == "03" { //检查费
  12673. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12674. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12675. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12676. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12677. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12678. }
  12679. }
  12680. if item.MedChrgitmType == "04" { //化验费
  12681. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12682. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12683. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12684. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12685. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12686. }
  12687. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  12688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12691. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12692. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12693. }
  12694. if item.MedChrgitmType == "06" { //手术费
  12695. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12696. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12697. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12698. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12699. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12700. }
  12701. if item.MedChrgitmType == "08" { //材料费
  12702. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12703. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12704. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12705. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12706. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12707. }
  12708. if item.MedChrgitmType == "09" { //西药费
  12709. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12710. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12711. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12712. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12713. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12714. }
  12715. if item.MedChrgitmType == "11" { //中成费
  12716. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12717. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12718. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12719. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12720. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12721. }
  12722. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  12723. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12724. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12725. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12726. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12727. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12728. }
  12729. }
  12730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12732. var user_name string
  12733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12734. if role.ID == 0 {
  12735. user_name = "管理员"
  12736. } else {
  12737. user_name = role.UserName
  12738. }
  12739. baseParams := models.BaseParams{
  12740. SecretKey: miConfig.SecretKey,
  12741. FixmedinsCode: miConfig.Code,
  12742. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12743. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12744. OrgName: miConfig.OrgName,
  12745. Doctor: user_name,
  12746. RequestUrl: miConfig.Url,
  12747. AccessKey: miConfig.AccessKey,
  12748. }
  12749. businessParams := models.BusinessParams{
  12750. PsnNo: order.PsnNo,
  12751. MdtrtId: order.MdtrtId,
  12752. SetlId: order.SetlId,
  12753. }
  12754. var res ResultEleven
  12755. var resEleven10265 ResultEleven10265
  12756. if config.IsOpen == 1 {
  12757. if miConfig.MdtrtareaAdmvs == "421300" {
  12758. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12759. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12760. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12761. resp, requestErr := http.Get(api)
  12762. if requestErr != nil {
  12763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12764. return
  12765. }
  12766. body, ioErr := ioutil.ReadAll(resp.Body)
  12767. if ioErr != nil {
  12768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12770. return
  12771. }
  12772. var respJSON map[string]interface{}
  12773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12776. return
  12777. }
  12778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12779. result, _ := json.Marshal(respJSON)
  12780. fmt.Println("log")
  12781. fmt.Println(string(result))
  12782. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12783. utils.ErrorLog("解析失败:%v", err)
  12784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12785. return
  12786. }
  12787. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12788. var api string
  12789. if miConfig.MdtrtareaAdmvs == "320921" {
  12790. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12791. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12793. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12794. } else {
  12795. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12796. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12797. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12798. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12799. }
  12800. resp, requestErr := http.Get(api)
  12801. if requestErr != nil {
  12802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12803. return
  12804. }
  12805. body, ioErr := ioutil.ReadAll(resp.Body)
  12806. if ioErr != nil {
  12807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12809. return
  12810. }
  12811. var respJSON map[string]interface{}
  12812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12815. return
  12816. }
  12817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12818. result, _ := json.Marshal(respJSON)
  12819. fmt.Println("log")
  12820. fmt.Println(string(result))
  12821. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12822. utils.ErrorLog("解析失败:%v", err)
  12823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12824. return
  12825. }
  12826. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12827. res.Output = resEleven10265.Output
  12828. res.ErrMsg = resEleven10265.ErrMsg
  12829. res.Cainfo = resEleven10265.Cainfo
  12830. res.WarnMsg = resEleven10265.WarnMsg
  12831. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12832. res.Infcode = infocode
  12833. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12834. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12835. saveLog(result, requestLog, "5203", "结算单")
  12836. var dat map[string]interface{}
  12837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12838. fmt.Println(dat)
  12839. } else {
  12840. fmt.Println(err)
  12841. }
  12842. userJSONBytes, _ := json.Marshal(dat)
  12843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12844. utils.ErrorLog("解析失败:%v", err)
  12845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12846. return
  12847. }
  12848. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12849. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12850. saveLog(result, requestLog, "5203", "结算单")
  12851. var dat map[string]interface{}
  12852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12853. fmt.Println(dat)
  12854. } else {
  12855. fmt.Println(err)
  12856. }
  12857. userJSONBytes, _ := json.Marshal(dat)
  12858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12859. utils.ErrorLog("解析失败:%v", err)
  12860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12861. return
  12862. }
  12863. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12864. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12865. saveLog(result, requestLog, "5203", "结算单")
  12866. var dat map[string]interface{}
  12867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12868. fmt.Println(dat)
  12869. } else {
  12870. fmt.Println(err)
  12871. }
  12872. userJSONBytes, _ := json.Marshal(dat)
  12873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12874. utils.ErrorLog("解析失败:%v", err)
  12875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12876. return
  12877. }
  12878. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12879. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12880. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12881. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12882. resp, requestErr := http.Get(api)
  12883. if requestErr != nil {
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12885. return
  12886. }
  12887. body, ioErr := ioutil.ReadAll(resp.Body)
  12888. if ioErr != nil {
  12889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12891. return
  12892. }
  12893. var respJSON map[string]interface{}
  12894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12897. return
  12898. }
  12899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12900. result, _ := json.Marshal(respJSON)
  12901. fmt.Println("log")
  12902. fmt.Println(string(result))
  12903. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12904. utils.ErrorLog("解析失败:%v", err)
  12905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12906. return
  12907. }
  12908. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12909. res.Output = resEleven10265.Output
  12910. res.ErrMsg = resEleven10265.ErrMsg
  12911. res.Cainfo = resEleven10265.Cainfo
  12912. res.WarnMsg = resEleven10265.WarnMsg
  12913. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12914. res.Infcode = infocode
  12915. } else {
  12916. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  12917. result := service.Gdyb5203(baseParams, businessParams)
  12918. //service.Gdyb5204(baseParams, businessParams)
  12919. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12920. var dat map[string]interface{}
  12921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12922. fmt.Println(dat)
  12923. } else {
  12924. fmt.Println(err)
  12925. }
  12926. userJSONBytes, _ := json.Marshal(dat)
  12927. if miConfig.Code == "H15049901371" {
  12928. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12929. utils.ErrorLog("解析失败:%v", err)
  12930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12931. return
  12932. }
  12933. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12934. res.Output = resEleven10265.Output
  12935. res.ErrMsg = resEleven10265.ErrMsg
  12936. res.Cainfo = resEleven10265.Cainfo
  12937. res.WarnMsg = resEleven10265.WarnMsg
  12938. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12939. res.Infcode = infocode
  12940. } else {
  12941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12942. utils.ErrorLog("解析失败:%v", err)
  12943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12944. return
  12945. }
  12946. }
  12947. }
  12948. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12949. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12950. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12951. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12952. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12953. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12954. var doctor_name string
  12955. if roles.ID == 0 {
  12956. doctor_name = "管理员"
  12957. } else {
  12958. doctor_name = roles.UserName
  12959. }
  12960. yiliao_leibie := ""
  12961. switch order.MedType {
  12962. case "11":
  12963. yiliao_leibie = "普通门诊"
  12964. break
  12965. case "12":
  12966. yiliao_leibie = "门诊挂号"
  12967. break
  12968. case "13":
  12969. yiliao_leibie = "急诊"
  12970. break
  12971. case "14":
  12972. yiliao_leibie = "门诊特殊病"
  12973. break
  12974. case "15":
  12975. yiliao_leibie = "门诊统筹"
  12976. break
  12977. case "16":
  12978. yiliao_leibie = "门诊慢性病"
  12979. break
  12980. case "21":
  12981. yiliao_leibie = "普通住院"
  12982. break
  12983. }
  12984. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12985. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12986. if res.Infcode == 0 {
  12987. c.ServeSuccessJSON(map[string]interface{}{
  12988. "diagnosis": name,
  12989. "order_infos": orderInfos,
  12990. "number": order.MdtrtId,
  12991. "date": order.SettleAccountsDate,
  12992. "charge_admin": charge_admin,
  12993. "printor_admin": printor_admin,
  12994. "info": res.Output.Setlinfo,
  12995. "order": order,
  12996. "bedCostTotal": bedCostTotal,
  12997. "bedCostSelfTotal": bedCostSelfTotal,
  12998. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12999. "bedSelfTotal": bedSelfTotal,
  13000. "bedInscpTotal": bedInscpTotal,
  13001. "operationCostTotal": operationCostTotal,
  13002. "operationCostSelfTotal": operationCostSelfTotal,
  13003. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13004. "operationSelfTotal": operationSelfTotal,
  13005. "operationInscpTotal": operationInscpTotal,
  13006. "otherCostTotal": otherCostTotal,
  13007. "otherCostSelfTotal": otherCostSelfTotal,
  13008. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13009. "otherSelfTotal": otherSelfTotal,
  13010. "otherInscpTotal": otherInscpTotal,
  13011. "materialCostTotal": materialCostTotal,
  13012. "materialCostSelfTotal": materialCostSelfTotal,
  13013. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13014. "materialSelfTotal": materialSelfTotal,
  13015. "materialInscpTotal": materialInscpTotal,
  13016. "westernMedicineCostTotal": westernMedicineCostTotal,
  13017. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13018. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13019. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13020. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13021. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13022. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13023. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13024. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13025. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13026. "checkCostTotal": checkCostTotal,
  13027. "checkCostSelfTotal": checkCostSelfTotal,
  13028. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13029. "checkSelfTotal": checkSelfTotal,
  13030. "checkInscpTotal": checkInscpTotal,
  13031. "laboratoryCostTotal": laboratoryCostTotal,
  13032. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13033. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13034. "laboratorySelfTotal": laboratorySelfTotal,
  13035. "laboratoryInscpTotal": laboratoryInscpTotal,
  13036. "treatCostTotal": treatCostTotal,
  13037. "treatCostSelfTotal": treatCostSelfTotal,
  13038. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13039. "treatSelfTotal": treatSelfTotal,
  13040. "treatInscpTotal": treatInscpTotal,
  13041. "doctor_info": doctor_info,
  13042. "doctor_code": adminRole_two.DoctorCode,
  13043. "doctor_name": doctor_name,
  13044. "health_card_no": order.PsnNo,
  13045. "department": departments.Name,
  13046. "yiliao_leibie": yiliao_leibie,
  13047. "after_money": order.AccountPrice,
  13048. "patient": patient,
  13049. "org_name": miConfig.OrgName,
  13050. "org_code": miConfig.Code,
  13051. "order_number": order.Number,
  13052. "his_hospital": his_hospital,
  13053. "his": his,
  13054. "dia_config": dia_config,
  13055. //"check_order_info": cus_slice,
  13056. })
  13057. }
  13058. }
  13059. }
  13060. func (c *HisApiController) CheckTreatment() {
  13061. patient_id, _ := c.GetInt64("patient_id")
  13062. id_card_no := c.GetString("id_card_no")
  13063. insutype := c.GetString("insutype")
  13064. med_type := c.GetString("med_type")
  13065. admin_user_id, _ := c.GetInt64("admin_user_id")
  13066. adminUser := c.GetAdminUserInfo()
  13067. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13068. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13069. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13070. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13071. if miConfig.MdtrtareaAdmvs == "421300" {
  13072. var res ResultTwo
  13073. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13074. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13075. "&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)
  13076. resp, requestErr := http.Get(api)
  13077. if requestErr != nil {
  13078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13079. return
  13080. }
  13081. body, ioErr := ioutil.ReadAll(resp.Body)
  13082. if ioErr != nil {
  13083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13085. return
  13086. }
  13087. var respJSON map[string]interface{}
  13088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13091. return
  13092. }
  13093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13094. result, _ := json.Marshal(respJSON)
  13095. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13096. utils.ErrorLog("解析失败:%v", err)
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. if res.Infcode == 0 {
  13101. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  13102. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13103. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  13104. resp, requestErr := http.Get(api)
  13105. if requestErr != nil {
  13106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13107. return
  13108. }
  13109. body, ioErr := ioutil.ReadAll(resp.Body)
  13110. if ioErr != nil {
  13111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13113. return
  13114. }
  13115. var respJSON map[string]interface{}
  13116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. var res Result2001
  13122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13123. result2, _ := json.Marshal(respJSON)
  13124. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13125. utils.ErrorLog("解析失败:%v", err)
  13126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. return
  13128. }
  13129. if res.Infcode == 0 {
  13130. c.ServeSuccessJSON(map[string]interface{}{
  13131. "msg": res.Output.Trtinfo,
  13132. })
  13133. }
  13134. } else {
  13135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13136. return
  13137. }
  13138. } else {
  13139. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13140. var dat map[string]interface{}
  13141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13142. fmt.Println(dat)
  13143. } else {
  13144. fmt.Println(err)
  13145. }
  13146. userJSONBytes, _ := json.Marshal(dat)
  13147. var res ResultTwo
  13148. var res10265 ResultTwo10265
  13149. if miConfig.Code == "H15049901371" {
  13150. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13151. utils.ErrorLog("解析失败:%v", err)
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13153. return
  13154. }
  13155. res.ErrMsg = res10265.ErrMsg
  13156. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13157. res.Infcode = infocode
  13158. res.Output = res10265.Output
  13159. res.InfRefmsgid = res10265.InfRefmsgid
  13160. } else {
  13161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13162. utils.ErrorLog("解析失败:%v", err)
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13164. return
  13165. }
  13166. }
  13167. var user_name string
  13168. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  13169. if role.ID == 0 {
  13170. user_name = "xxx"
  13171. } else {
  13172. user_name = role.UserName
  13173. }
  13174. baseParams := models.BaseParams{
  13175. SecretKey: miConfig.SecretKey,
  13176. FixmedinsCode: miConfig.Code,
  13177. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13178. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13179. OrgName: miConfig.OrgName,
  13180. Doctor: user_name,
  13181. }
  13182. if config.IsOpen == 1 {
  13183. if miConfig.Code == "H15049901371" {
  13184. if med_type == "14" {
  13185. if insutype == "390" {
  13186. med_type = "9933"
  13187. } else if insutype == "310" {
  13188. med_type = "990502"
  13189. }
  13190. } else if med_type == "11" {
  13191. med_type = "11"
  13192. }
  13193. }
  13194. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  13195. var dat map[string]interface{}
  13196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13197. fmt.Println(dat)
  13198. } else {
  13199. fmt.Println(err)
  13200. }
  13201. var res Result2001
  13202. var res10265 Result2001Org10265
  13203. if miConfig.Code == "H15049901371" {
  13204. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13205. utils.ErrorLog("解析失败:%v", err)
  13206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13207. return
  13208. }
  13209. res.ErrMsg = res10265.ErrMsg
  13210. res.Output = res10265.Output
  13211. res.InfRefmsgid = res10265.InfRefmsgid
  13212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13213. res.Infcode = infocode
  13214. } else {
  13215. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13216. utils.ErrorLog("解析失败:%v", err)
  13217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13218. return
  13219. }
  13220. }
  13221. if res.Infcode == 0 {
  13222. c.ServeSuccessJSON(map[string]interface{}{
  13223. "msg": res.Output.Trtinfo,
  13224. })
  13225. }
  13226. }
  13227. }
  13228. }
  13229. //func (c *HisApiController) PutRecord() {
  13230. // id, _ := c.GetInt64("id")
  13231. // record_time := c.GetString("record_time")
  13232. // timeLayout := "2006-01-02"
  13233. // loc, _ := time.LoadLocation("Local")
  13234. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13235. // if err != nil {
  13236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13237. // return
  13238. // }
  13239. // recordDateTime := theTime.Unix()
  13240. //
  13241. // adminInfo := c.GetAdminUserInfo()
  13242. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  13243. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13244. //
  13245. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13246. //
  13247. // fmt.Println(miConfig.SecretKey)
  13248. //
  13249. // if patient == nil {
  13250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13251. // return
  13252. // }
  13253. // if len(patient.IdCardNo) == 0 {
  13254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  13255. // return
  13256. // }
  13257. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  13258. // if config.IsOpen == 1 {
  13259. // 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
  13260. // resp, requestErr := http.Get(api)
  13261. // if requestErr != nil {
  13262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13263. // return
  13264. // }
  13265. // defer resp.Body.Close()
  13266. // body, ioErr := ioutil.ReadAll(resp.Body)
  13267. // if ioErr != nil {
  13268. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13270. // return
  13271. // }
  13272. // var respJSON map[string]interface{}
  13273. //
  13274. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13277. // return
  13278. // }
  13279. //
  13280. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13281. // userJSONBytes, _ := json.Marshal(userJSON)
  13282. // var res ResultTwo
  13283. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13284. // utils.ErrorLog("解析失败:%v", err)
  13285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13286. // return
  13287. // }
  13288. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13289. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13290. // infoStr := string(Iinfos)
  13291. // idetinfoStr := string(Idetinfos)
  13292. //
  13293. // if res.Infcode == 0 {
  13294. // his := models.VMHisPatient{
  13295. // Status: 1,
  13296. // Ctime: time.Now().Unix(),
  13297. // Mtime: time.Now().Unix(),
  13298. // PsnNo: res.Output.Baseinfo.PsnNo,
  13299. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  13300. // Certno: res.Output.Baseinfo.Certno,
  13301. // PsnName: res.Output.Baseinfo.PsnName,
  13302. // Gend: res.Output.Baseinfo.Gend,
  13303. // Naty: res.Output.Baseinfo.Naty,
  13304. // Brdy: res.Output.Baseinfo.Brdy,
  13305. // Age: res.Output.Baseinfo.Age,
  13306. // Iinfo: infoStr,
  13307. // Idetinfo: idetinfoStr,
  13308. // PatientId: patient.ID,
  13309. // RecordDate: theTime.Unix(),
  13310. // UserOrgId: adminInfo.CurrentOrgId,
  13311. // AdminUserId: adminInfo.AdminUser.Id,
  13312. // IsReturn: 1,
  13313. // }
  13314. //
  13315. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  13316. // //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")
  13317. // //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")
  13318. //
  13319. // //var dat map[string]interface{}
  13320. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13321. // // fmt.Println(dat)
  13322. // //} else {
  13323. // // fmt.Println(err)
  13324. // //}
  13325. //
  13326. // var dat2 map[string]interface{}
  13327. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13328. // fmt.Println(dat2)
  13329. // } else {
  13330. // fmt.Println(err)
  13331. // }
  13332. //
  13333. // } else {
  13334. // adminUser := c.GetAdminUserInfo()
  13335. // errlog := &models.HisOrderError{
  13336. // UserOrgId: adminUser.CurrentOrgId,
  13337. // Ctime: time.Now().Unix(),
  13338. // Mtime: time.Now().Unix(),
  13339. // ErrMsg: res.ErrMsg,
  13340. // Status: 1,
  13341. // PatientId: id,
  13342. // RecordTime: recordDateTime,
  13343. // Stage: 1,
  13344. // }
  13345. // service.CreateErrMsgLog(errlog)
  13346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  13347. // return
  13348. // }
  13349. // }
  13350. //
  13351. //}
  13352. //func (c *HisApiController) GetUploadDiag() {
  13353. // id, _ := c.GetInt64("id")
  13354. // record_time := c.GetString("record_time")
  13355. //
  13356. // diagnosis_id, _ := c.GetInt64("diagnosis")
  13357. // sick_type, _ := c.GetInt64("sick_type")
  13358. // reg_type, _ := c.GetInt64("reg_type")
  13359. //
  13360. // timeLayout := "2006-01-02"
  13361. // loc, _ := time.LoadLocation("Local")
  13362. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13363. // if err != nil {
  13364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13365. // return
  13366. // }
  13367. //
  13368. // var patientPrescription models.HisPrescriptionInfo
  13369. // recordDateTime := theTime.Unix()
  13370. // adminInfo := c.GetAdminUserInfo()
  13371. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13372. //
  13373. // if patientPrescription.ID == 0 {
  13374. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13375. // }
  13376. //
  13377. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13378. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13379. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13380. // sickConfig, _ := service.FindSickById(sick_type)
  13381. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13382. //
  13383. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  13384. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  13385. // "&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 +
  13386. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  13387. // resp2, requestErr2 := http.Get(api2)
  13388. // if requestErr2 != nil {
  13389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13390. // return
  13391. // }
  13392. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13393. // if ioErr2 != nil {
  13394. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13396. // return
  13397. // }
  13398. // var respJSON2 map[string]interface{}
  13399. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13400. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13402. // return
  13403. // }
  13404. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13405. // userJSONBytes2, _ := json.Marshal(respJSON2)
  13406. //
  13407. // var res2 ResultSix
  13408. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13409. // utils.ErrorLog("解析失败:%v", err)
  13410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13411. // return
  13412. // }
  13413. // if res2.Infcode != 0 {
  13414. // adminUser := c.GetAdminUserInfo()
  13415. // errlog := &models.HisOrderError{
  13416. // UserOrgId: adminUser.CurrentOrgId,
  13417. // Ctime: time.Now().Unix(),
  13418. // Mtime: time.Now().Unix(),
  13419. // ErrMsg: res2.ErrMsg,
  13420. // Status: 1,
  13421. // PatientId: id,
  13422. // RecordTime: recordDateTime,
  13423. // Stage: 3,
  13424. // }
  13425. // service.CreateErrMsgLog(errlog)
  13426. //
  13427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  13428. // return
  13429. // }
  13430. //
  13431. // c.ServeSuccessJSON(map[string]interface{}{
  13432. // "msg": "上传成功",
  13433. // })
  13434. //
  13435. //}
  13436. type QueryResult struct {
  13437. ID int64
  13438. Name string
  13439. Code string
  13440. List_type_code string
  13441. }
  13442. func (c *HisApiController) GetCheckCode() {
  13443. ids_str := c.GetString("ids")
  13444. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13445. ids_arr := strings.Split(ids_str, ",")
  13446. var queryResult []QueryResult
  13447. ids := make([]int64, 0)
  13448. for _, item := range ids_arr {
  13449. id, _ := strconv.ParseInt(item, 10, 64)
  13450. ids = append(ids, id)
  13451. }
  13452. if record_type == 1 {
  13453. drugs, _ := service.GetBatchDrugList(ids)
  13454. for _, item := range drugs {
  13455. result := QueryResult{
  13456. ID: item.ID,
  13457. Name: item.DrugName,
  13458. Code: item.MedicalInsuranceNumber,
  13459. List_type_code: "101",
  13460. }
  13461. queryResult = append(queryResult, result)
  13462. }
  13463. } else if record_type == 2 {
  13464. goods, _ := service.GetBatchGoodInformationList(ids)
  13465. for _, item := range goods {
  13466. result := QueryResult{
  13467. ID: item.ID,
  13468. Name: item.GoodName,
  13469. Code: item.MedicalInsuranceNumber,
  13470. List_type_code: "301",
  13471. }
  13472. queryResult = append(queryResult, result)
  13473. }
  13474. } else if record_type == 3 {
  13475. projects, _ := service.GetBathchMyPorjecgList(ids)
  13476. for _, item := range projects {
  13477. result := QueryResult{
  13478. ID: item.ID,
  13479. Name: item.ProjectName,
  13480. Code: item.MedicalCode,
  13481. List_type_code: "201",
  13482. }
  13483. queryResult = append(queryResult, result)
  13484. }
  13485. }
  13486. admin_user_id, _ := c.GetInt64("admin_user_id")
  13487. adminUser := c.GetAdminUserInfo()
  13488. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13489. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13490. var user_name string
  13491. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13492. if role.ID == 0 {
  13493. user_name = "xxx"
  13494. } else {
  13495. user_name = role.UserName
  13496. }
  13497. baseParams := &models.BaseParams{
  13498. SecretKey: miConfig.SecretKey,
  13499. FixmedinsCode: miConfig.Code,
  13500. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13501. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13502. OrgName: miConfig.OrgName,
  13503. Doctor: user_name,
  13504. }
  13505. if config.IsOpen == 1 {
  13506. for _, item := range queryResult {
  13507. var result string
  13508. if record_type == 1 {
  13509. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13510. } else if record_type == 2 {
  13511. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13512. } else if record_type == 3 {
  13513. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13514. }
  13515. var dat map[string]interface{}
  13516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13517. fmt.Println(dat)
  13518. } else {
  13519. fmt.Println(err)
  13520. }
  13521. userJSONBytes, _ := json.Marshal(dat)
  13522. var res ResultSix
  13523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13524. utils.ErrorLog("解析失败:%v", err)
  13525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13526. return
  13527. }
  13528. if res.Infcode == 0 {
  13529. if record_type == 1 {
  13530. service.UpdateBaseDrugById(item.ID)
  13531. } else if record_type == 2 {
  13532. service.UpdateGoodInformaitonByDetail(item.ID)
  13533. } else if record_type == 3 {
  13534. service.UpdateProjectById(item.ID)
  13535. }
  13536. c.ServeSuccessJSON(map[string]interface{}{
  13537. "failed_code": 0,
  13538. "msg": "目录对照成功",
  13539. })
  13540. } else {
  13541. c.ServeSuccessJSON(map[string]interface{}{
  13542. "failed_code": -10,
  13543. "msg": res.ErrMsg,
  13544. })
  13545. }
  13546. }
  13547. }
  13548. }
  13549. func (c *HisApiController) UnCheckCode() {
  13550. ids_str := c.GetString("ids")
  13551. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13552. admin_user_id, _ := c.GetInt64("admin_user_id")
  13553. ids_arr := strings.Split(ids_str, ",")
  13554. var queryResult []QueryResult
  13555. ids := make([]int64, 0)
  13556. for _, item := range ids_arr {
  13557. id, _ := strconv.ParseInt(item, 10, 64)
  13558. ids = append(ids, id)
  13559. }
  13560. if record_type == 1 {
  13561. drugs, _ := service.GetBatchDrugList(ids)
  13562. for _, item := range drugs {
  13563. result := QueryResult{
  13564. ID: item.ID,
  13565. Name: item.DrugName,
  13566. Code: item.MedicalInsuranceNumber,
  13567. List_type_code: "101",
  13568. }
  13569. queryResult = append(queryResult, result)
  13570. }
  13571. } else if record_type == 2 {
  13572. goods, _ := service.GetBatchGoodInformationList(ids)
  13573. for _, item := range goods {
  13574. result := QueryResult{
  13575. ID: item.ID,
  13576. Name: item.GoodName,
  13577. Code: item.MedicalInsuranceNumber,
  13578. List_type_code: "301",
  13579. }
  13580. queryResult = append(queryResult, result)
  13581. }
  13582. } else if record_type == 3 {
  13583. projects, _ := service.GetBathchMyPorjecgList(ids)
  13584. for _, item := range projects {
  13585. result := QueryResult{
  13586. ID: item.ID,
  13587. Name: item.ProjectName,
  13588. Code: item.MedicalCode,
  13589. List_type_code: "201",
  13590. }
  13591. queryResult = append(queryResult, result)
  13592. }
  13593. }
  13594. adminUser := c.GetAdminUserInfo()
  13595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13596. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13597. var user_name string
  13598. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13599. if role.ID == 0 {
  13600. user_name = "xxx"
  13601. } else {
  13602. user_name = role.UserName
  13603. }
  13604. baseParams := &models.BaseParams{
  13605. SecretKey: miConfig.SecretKey,
  13606. FixmedinsCode: miConfig.Code,
  13607. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13608. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13609. OrgName: miConfig.OrgName,
  13610. Doctor: user_name,
  13611. }
  13612. if config.IsOpen == 1 {
  13613. for _, item := range queryResult {
  13614. var result string
  13615. if record_type == 1 {
  13616. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13617. } else if record_type == 2 {
  13618. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13619. } else if record_type == 3 {
  13620. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13621. }
  13622. var dat2 map[string]interface{}
  13623. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  13624. fmt.Println(dat2)
  13625. } else {
  13626. fmt.Println(err)
  13627. }
  13628. userJSONBytes, _ := json.Marshal(dat2)
  13629. var res ResultSix
  13630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13631. utils.ErrorLog("解析失败:%v", err)
  13632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13633. return
  13634. }
  13635. if res.Infcode == 0 {
  13636. if record_type == 1 {
  13637. service.UpdateDrugByIdDetail(item.ID)
  13638. } else if record_type == 2 {
  13639. service.UpdateGoodInfoById(item.ID)
  13640. } else if record_type == 3 {
  13641. service.UpdateMyProjectById(item.ID)
  13642. }
  13643. c.ServeSuccessJSON(map[string]interface{}{
  13644. "failed_code": 0,
  13645. "msg": "撤销目录对照成功",
  13646. })
  13647. } else {
  13648. c.ServeSuccessJSON(map[string]interface{}{
  13649. "failed_code": -10,
  13650. "msg": res.ErrMsg,
  13651. })
  13652. }
  13653. }
  13654. }
  13655. }
  13656. func (c *HisApiController) GetPatientInfo() {
  13657. id_card_no := c.GetString("id_card_no")
  13658. admin_user_id, _ := c.GetInt64("admin_user_id")
  13659. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13660. if patient.ID == 0 {
  13661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13662. return
  13663. }
  13664. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13665. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13666. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  13667. if config.IsOpen == 1 {
  13668. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13669. var dat map[string]interface{}
  13670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13671. fmt.Println(dat)
  13672. } else {
  13673. fmt.Println(err)
  13674. }
  13675. userJSONBytes, _ := json.Marshal(dat)
  13676. var res ResultTwo
  13677. var res10265 ResultTwo10265
  13678. if miConfig.Code == "H15049901371" {
  13679. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13680. utils.ErrorLog("解析失败:%v", err)
  13681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13682. return
  13683. }
  13684. res.ErrMsg = res10265.ErrMsg
  13685. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13686. res.Infcode = infocode
  13687. res.Output = res10265.Output
  13688. res.InfRefmsgid = res10265.InfRefmsgid
  13689. } else {
  13690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13691. utils.ErrorLog("解析失败:%v", err)
  13692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13693. return
  13694. }
  13695. }
  13696. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13697. // utils.ErrorLog("解析失败:%v", err)
  13698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13699. // return
  13700. //}
  13701. if res.Infcode != 0 {
  13702. c.ServeSuccessJSON(map[string]interface{}{
  13703. "failed_code": -10,
  13704. "msg": res.ErrMsg,
  13705. })
  13706. } else {
  13707. c.ServeSuccessJSON(map[string]interface{}{
  13708. "failed_code": 0,
  13709. "info": res,
  13710. })
  13711. }
  13712. }
  13713. }
  13714. func (c *HisApiController) PsnPutOnRecord() {
  13715. record_type, _ := c.GetInt64("type")
  13716. patient_id, _ := c.GetInt64("patient_id")
  13717. admin_user_id, _ := c.GetInt64("admin_user_id")
  13718. start_time := c.GetString("start_time")
  13719. end_time := c.GetString("end_time")
  13720. adminUser := c.GetAdminUserInfo()
  13721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13723. var patients []*models.Patients
  13724. if record_type == 1 { //全部备案
  13725. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  13726. patients = append(patients, patient...)
  13727. } else { //单个备案
  13728. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13729. patients = append(patients, patient)
  13730. }
  13731. var user_name string
  13732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13733. if role.ID == 0 {
  13734. user_name = "xxx"
  13735. } else {
  13736. user_name = role.UserName
  13737. }
  13738. if config.IsOpen == 1 {
  13739. for _, item := range patients {
  13740. 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
  13741. resp, requestErr := http.Get(api)
  13742. if requestErr != nil {
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13744. return
  13745. }
  13746. defer resp.Body.Close()
  13747. body, ioErr := ioutil.ReadAll(resp.Body)
  13748. if ioErr != nil {
  13749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13751. return
  13752. }
  13753. var respJSON map[string]interface{}
  13754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13757. return
  13758. }
  13759. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13760. userJSONBytes, _ := json.Marshal(userJSON)
  13761. var res ResultTwo
  13762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13763. utils.ErrorLog("解析失败:%v", err)
  13764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13765. return
  13766. }
  13767. if res.Infcode == 0 {
  13768. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13769. var dat map[string]interface{}
  13770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13771. fmt.Println(dat)
  13772. } else {
  13773. fmt.Println(err)
  13774. }
  13775. userJSONBytes, _ := json.Marshal(dat)
  13776. var res2 ResultThirteen
  13777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13778. utils.ErrorLog("解析失败:%v", err)
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. if res2.Infcode == 0 {
  13783. psnResult := &models.GdybPsnRecord{
  13784. UserOrgId: adminUser.CurrentOrgId,
  13785. PatientId: item.ID,
  13786. PsnNo: res.Output.Baseinfo.PsnNo,
  13787. Ctime: time.Now().Unix(),
  13788. Mtime: time.Now().Unix(),
  13789. Status: 1,
  13790. IsCancel: 1,
  13791. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13792. }
  13793. service.CreatePsnRecord(psnResult)
  13794. } else {
  13795. c.ServeSuccessJSON(map[string]interface{}{
  13796. "failed_code": -10,
  13797. "msg": res2.ErrMsg,
  13798. })
  13799. return
  13800. }
  13801. }
  13802. }
  13803. }
  13804. }
  13805. func (c *HisApiController) PsnUnPutOnRecord() {
  13806. id, _ := c.GetInt64("id")
  13807. //record_type, _ := c.GetInt64("type")
  13808. admin_user_id, _ := c.GetInt64("admin_user_id")
  13809. adminUser := c.GetAdminUserInfo()
  13810. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13811. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13812. var user_name string
  13813. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13814. if role.ID == 0 {
  13815. user_name = "xxx"
  13816. } else {
  13817. user_name = role.UserName
  13818. }
  13819. psn_record, _ := service.GetPsnRecordById(id)
  13820. if psn_record.ID == 0 {
  13821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13822. return
  13823. }
  13824. if config.IsOpen == 1 {
  13825. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13826. var dat map[string]interface{}
  13827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13828. fmt.Println(dat)
  13829. } else {
  13830. fmt.Println(err)
  13831. }
  13832. userJSONBytes, _ := json.Marshal(dat)
  13833. var res ResultFourteen
  13834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13835. utils.ErrorLog("解析失败:%v", err)
  13836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13837. return
  13838. }
  13839. if res.Infcode == 0 {
  13840. psn_record.IsCancel = 2
  13841. service.CreatePsnRecord(&psn_record)
  13842. } else {
  13843. c.ServeSuccessJSON(map[string]interface{}{
  13844. "failed_code": -10,
  13845. "msg": res.ErrMsg,
  13846. })
  13847. return
  13848. }
  13849. }
  13850. }
  13851. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13852. patient_id, _ := c.GetInt64("patient_id")
  13853. insutype_two := c.GetString("insutype")
  13854. psn_no := c.GetString("psn_no")
  13855. doctor_id, _ := c.GetInt64("doctor_id")
  13856. sick_id, _ := c.GetInt64("sick_id")
  13857. department_id, _ := c.GetInt64("department_id")
  13858. start_time := c.GetString("start_time")
  13859. end_time := c.GetString("end_time")
  13860. check_time := c.GetString("check_time")
  13861. hospital_code := c.GetString("hospital_code")
  13862. hospital_name := c.GetString("hospital_name")
  13863. adminUser := c.GetAdminUserInfo()
  13864. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13867. sick, _ := service.FindSickById(sick_id)
  13868. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13869. if len(hospital_code) == 0 {
  13870. hospital_code = miConfig.Code
  13871. }
  13872. if len(hospital_name) == 0 {
  13873. hospital_name = miConfig.OrgName
  13874. }
  13875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13876. var res ResultTwo
  13877. var res10265 ResultTwo10265
  13878. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13879. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13880. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13881. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13882. "&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
  13883. resp, requestErr := http.Get(api)
  13884. if requestErr != nil {
  13885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13886. return
  13887. }
  13888. body, ioErr := ioutil.ReadAll(resp.Body)
  13889. if ioErr != nil {
  13890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13892. return
  13893. }
  13894. var respJSON map[string]interface{}
  13895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13898. return
  13899. }
  13900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13901. result, _ := json.Marshal(respJSON)
  13902. fmt.Println("log")
  13903. fmt.Println(string(result))
  13904. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13905. utils.ErrorLog("解析失败:%v", err)
  13906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13907. return
  13908. }
  13909. res.ErrMsg = res10265.ErrMsg
  13910. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13911. res.Infcode = infocode
  13912. res.Output = res10265.Output
  13913. res.InfRefmsgid = res10265.InfRefmsgid
  13914. } else {
  13915. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13916. if miConfig.Code == "H15049901371" {
  13917. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13918. utils.ErrorLog("解析失败:%v", err)
  13919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13920. return
  13921. }
  13922. res.ErrMsg = res10265.ErrMsg
  13923. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13924. res.Infcode = infocode
  13925. res.Output = res10265.Output
  13926. res.InfRefmsgid = res10265.InfRefmsgid
  13927. } else {
  13928. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13929. utils.ErrorLog("解析失败:%v", err)
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13931. return
  13932. }
  13933. }
  13934. }
  13935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13936. infoStr := string(Iinfos)
  13937. var rf []*ResultFive
  13938. json.Unmarshal([]byte(infoStr), &rf)
  13939. var insuplc_admdvs string
  13940. var insutype string
  13941. var is390 int = 0
  13942. var is310 int = 0
  13943. var insutypes []*ResultFive
  13944. for _, item := range rf {
  13945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13946. insutypes = append(insutypes, item)
  13947. }
  13948. }
  13949. if len(insutypes) == 1 {
  13950. insutype = insutypes[0].Insutype
  13951. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13952. } else {
  13953. for _, i := range insutypes {
  13954. if i.Insutype == "390" {
  13955. is390 = 1
  13956. }
  13957. if i.Insutype == "310" {
  13958. is310 = 1
  13959. }
  13960. }
  13961. }
  13962. if is390 == 1 {
  13963. insutype = "390"
  13964. }
  13965. if is310 == 1 {
  13966. insutype = "310"
  13967. }
  13968. if len(insutypes) == 2 {
  13969. insutype = insutype_two
  13970. }
  13971. if len(insutypes) == 0 {
  13972. insutype = "310"
  13973. }
  13974. insutype = insutype_two
  13975. fmt.Println(insutype)
  13976. for _, item := range rf {
  13977. fmt.Println(item.Insutype)
  13978. fmt.Println(insutype)
  13979. if item.Insutype == insutype {
  13980. fmt.Println(item.Insutype)
  13981. fmt.Println(insutype)
  13982. insuplc_admdvs = item.InsuplcAdmdvs
  13983. }
  13984. }
  13985. fmt.Println(insuplc_admdvs)
  13986. var res2 ResultThirteen
  13987. var res10265_2 ResultThirteen10265
  13988. if config.IsOpen == 1 {
  13989. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13990. } else {
  13991. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  13992. var dat map[string]interface{}
  13993. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13994. fmt.Println(dat)
  13995. } else {
  13996. fmt.Println(err)
  13997. }
  13998. userJSONBytes, _ := json.Marshal(dat)
  13999. if miConfig.Code == "H15049901371" {
  14000. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  14001. utils.ErrorLog("解析失败:%v", err)
  14002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14003. return
  14004. }
  14005. res2.ErrMsg = res10265_2.ErrMsg
  14006. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  14007. res2.Infcode = infocode
  14008. res2.Output = res10265_2.Output
  14009. res2.InfRefmsgid = res10265_2.InfRefmsgid
  14010. } else {
  14011. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14012. utils.ErrorLog("解析失败:%v", err)
  14013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14014. return
  14015. }
  14016. }
  14017. }
  14018. if res2.Infcode == 0 {
  14019. psnResult := &models.GdybPsnNcdsRecord{
  14020. UserOrgId: adminUser.CurrentOrgId,
  14021. PatientId: patient.ID,
  14022. PsnNo: psn_no,
  14023. DoctorId: doctor.AdminUserId,
  14024. DepartmentId: department_id,
  14025. SickType: sick_id,
  14026. Insutype: insutype,
  14027. Ctime: time.Now().Unix(),
  14028. Mtime: time.Now().Unix(),
  14029. Status: 1,
  14030. IsCancel: 1,
  14031. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14032. }
  14033. service.CreatePsnNCDSRecord(psnResult)
  14034. c.ServeSuccessJSON(map[string]interface{}{
  14035. "failed_code": 0,
  14036. "msg": "备案成功",
  14037. "result": psnResult,
  14038. })
  14039. } else {
  14040. c.ServeSuccessJSON(map[string]interface{}{
  14041. "failed_code": -10,
  14042. "msg": res2.ErrMsg,
  14043. })
  14044. return
  14045. }
  14046. }
  14047. }
  14048. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  14049. id, _ := c.GetInt64("id")
  14050. admin_user_id, _ := c.GetInt64("admin_user_id")
  14051. adminUser := c.GetAdminUserInfo()
  14052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14053. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14054. //config, _ := service.Ge(adminUser.CurrentOrgId)
  14055. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  14056. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14057. //var user_name string
  14058. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14059. //if role.ID == 0 {
  14060. // user_name = "xxx"
  14061. //} else {
  14062. // user_name = role.UserName
  14063. //}
  14064. psn_record, _ := service.GetPsnNCDSRecordById(id)
  14065. if psn_record.ID == 0 {
  14066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14067. return
  14068. }
  14069. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14070. var res ResultTwo
  14071. var res10265 ResultTwo10265
  14072. if miConfig.Code == "H15049901371" {
  14073. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14074. utils.ErrorLog("解析失败:%v", err)
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14076. return
  14077. }
  14078. res.ErrMsg = res10265.ErrMsg
  14079. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14080. res.Infcode = infocode
  14081. res.Output = res10265.Output
  14082. res.InfRefmsgid = res10265.InfRefmsgid
  14083. } else {
  14084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14085. utils.ErrorLog("解析失败:%v", err)
  14086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14087. return
  14088. }
  14089. }
  14090. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14091. infoStr := string(Iinfos)
  14092. var rf []*ResultFive
  14093. json.Unmarshal([]byte(infoStr), &rf)
  14094. var insuplc_admdvs string
  14095. var insutype string
  14096. var is390 int = 0
  14097. var is310 int = 0
  14098. var insutypes []*ResultFive
  14099. for _, item := range rf {
  14100. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14101. insutypes = append(insutypes, item)
  14102. }
  14103. }
  14104. if len(insutypes) == 1 {
  14105. insutype = insutypes[0].Insutype
  14106. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14107. } else {
  14108. for _, i := range insutypes {
  14109. if i.Insutype == "390" {
  14110. is390 = 1
  14111. }
  14112. if i.Insutype == "310" {
  14113. is310 = 1
  14114. }
  14115. }
  14116. }
  14117. if is390 == 1 {
  14118. insutype = "390"
  14119. }
  14120. if is310 == 1 {
  14121. insutype = "310"
  14122. }
  14123. if len(insutypes) == 0 {
  14124. insutype = "310"
  14125. }
  14126. insutype = psn_record.Insutype
  14127. for _, item := range rf {
  14128. if item.Insutype == insutype {
  14129. insuplc_admdvs = item.InsuplcAdmdvs
  14130. }
  14131. }
  14132. if config.IsOpen == 1 {
  14133. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14134. var dat map[string]interface{}
  14135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14136. fmt.Println(dat)
  14137. } else {
  14138. fmt.Println(err)
  14139. }
  14140. userJSONBytes, _ := json.Marshal(dat)
  14141. var res ResultFourteen
  14142. var res10265 ResultFourteen10265
  14143. if miConfig.Code == "H15049901371" {
  14144. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14145. utils.ErrorLog("解析失败:%v", err)
  14146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14147. return
  14148. }
  14149. res.ErrMsg = res10265.ErrMsg
  14150. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14151. res.Infcode = infocode
  14152. res.Output = res10265.Output
  14153. res.InfRefmsgid = res10265.InfRefmsgid
  14154. } else {
  14155. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14156. utils.ErrorLog("解析失败:%v", err)
  14157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14158. return
  14159. }
  14160. }
  14161. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14162. // utils.ErrorLog("解析失败:%v", err)
  14163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14164. // return
  14165. //}
  14166. if res.Infcode == 0 {
  14167. psn_record.IsCancel = 2
  14168. service.CreatePsnNCDSRecord(&psn_record)
  14169. c.ServeSuccessJSON(map[string]interface{}{
  14170. "failed_code": 0,
  14171. "msg": "撤销备案成功",
  14172. })
  14173. } else {
  14174. c.ServeSuccessJSON(map[string]interface{}{
  14175. "failed_code": -10,
  14176. "msg": res.ErrMsg,
  14177. })
  14178. return
  14179. }
  14180. }
  14181. }
  14182. func (c *HisApiController) TestTest() {
  14183. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  14184. fmt.Println(patient.Iinfo)
  14185. }
  14186. type CustomData struct {
  14187. MsgId string
  14188. PsnNo string
  14189. Info string
  14190. }
  14191. func (c *HisApiController) ReversalData() {
  14192. var customData []*CustomData
  14193. custom := &CustomData{
  14194. MsgId: "H44022900158202103301714472004",
  14195. PsnNo: "44020000001101329945",
  14196. Info: "2207",
  14197. }
  14198. customData = append(customData, custom)
  14199. custom1 := &CustomData{
  14200. MsgId: "H4402290015820210330172057803",
  14201. PsnNo: "44020000001101161813",
  14202. Info: "2207",
  14203. }
  14204. customData = append(customData, custom1)
  14205. custom2 := &CustomData{
  14206. MsgId: "H44022900158202103301705198813",
  14207. PsnNo: "44190000133097375417",
  14208. Info: "2207",
  14209. }
  14210. customData = append(customData, custom2)
  14211. custom3 := &CustomData{
  14212. MsgId: "H44022900158202103301715524756",
  14213. PsnNo: "44020000001100187221",
  14214. Info: "2207",
  14215. }
  14216. customData = append(customData, custom3)
  14217. custom4 := &CustomData{
  14218. MsgId: "H44022900158202103301730376224",
  14219. PsnNo: "44020000001101959155",
  14220. Info: "2207",
  14221. }
  14222. customData = append(customData, custom4)
  14223. custom5 := &CustomData{
  14224. MsgId: "H44022900158202103301748008725",
  14225. PsnNo: "44020000001104246641",
  14226. Info: "2207",
  14227. }
  14228. customData = append(customData, custom5)
  14229. custom6 := &CustomData{
  14230. MsgId: "H44022900158202103301718096755",
  14231. PsnNo: "44020000001102211860",
  14232. Info: "2207",
  14233. }
  14234. customData = append(customData, custom6)
  14235. custom7 := &CustomData{
  14236. MsgId: "H44022900158202103301736551640",
  14237. PsnNo: "44020000001102687718",
  14238. Info: "2207",
  14239. }
  14240. customData = append(customData, custom7)
  14241. custom8 := &CustomData{
  14242. MsgId: "H44022900158202103301743097676",
  14243. PsnNo: "44020000001102127785",
  14244. Info: "2207",
  14245. }
  14246. customData = append(customData, custom8)
  14247. custom9 := &CustomData{
  14248. MsgId: "H44022900158202103301712304203",
  14249. PsnNo: "44020000001101518097",
  14250. Info: "2207",
  14251. }
  14252. customData = append(customData, custom9)
  14253. custom10 := &CustomData{
  14254. MsgId: "H44022900158202103301738448785",
  14255. PsnNo: "44020000001100500813",
  14256. Info: "2207",
  14257. }
  14258. customData = append(customData, custom10)
  14259. custom11 := &CustomData{
  14260. MsgId: "H44022900158202103301732455843",
  14261. PsnNo: "44020000001102690557",
  14262. Info: "2207",
  14263. }
  14264. customData = append(customData, custom11)
  14265. custom12 := &CustomData{
  14266. MsgId: "H44022900158202103301745421708",
  14267. PsnNo: "44020000001102211928",
  14268. Info: "2207",
  14269. }
  14270. customData = append(customData, custom12)
  14271. custom1212 := &CustomData{
  14272. MsgId: "H440229001582021033017351627",
  14273. PsnNo: "44020000001102481733",
  14274. Info: "2207",
  14275. }
  14276. customData = append(customData, custom1212)
  14277. custom13 := &CustomData{
  14278. MsgId: "H44022900158202103301740327951",
  14279. PsnNo: "44020000001103174866",
  14280. Info: "2207",
  14281. }
  14282. customData = append(customData, custom13)
  14283. custom14 := &CustomData{
  14284. MsgId: "H4402290015820210330174922668",
  14285. PsnNo: "44020000001102927272",
  14286. Info: "2207",
  14287. }
  14288. customData = append(customData, custom14)
  14289. custom15 := &CustomData{
  14290. MsgId: "H44022900158202103301752362273",
  14291. PsnNo: "44020000001102942890",
  14292. Info: "2207",
  14293. }
  14294. customData = append(customData, custom15)
  14295. custom16 := &CustomData{
  14296. MsgId: "H44022900158202103301751082917",
  14297. PsnNo: "44020000001101662162",
  14298. Info: "2207",
  14299. }
  14300. customData = append(customData, custom16)
  14301. custom17 := &CustomData{
  14302. MsgId: "H44022900158202103301754147728",
  14303. PsnNo: "44020000000229014511",
  14304. Info: "2207",
  14305. }
  14306. customData = append(customData, custom17)
  14307. adminUser := c.GetAdminUserInfo()
  14308. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14309. for _, item := range customData {
  14310. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14311. fmt.Println(result)
  14312. }
  14313. }
  14314. //func (c *HisApiController) GetAllopatry() {
  14315. // year := c.GetString("year")
  14316. // month := c.GetString("month")
  14317. // admin_user_id, _ := c.GetInt64("admin_user_id")
  14318. // adminUser := c.GetAdminUserInfo()
  14319. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14320. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14321. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  14322. //
  14323. // var dat map[string]interface{}
  14324. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14325. // fmt.Println(dat)
  14326. // } else {
  14327. // fmt.Println(err)
  14328. // }
  14329. // userJSONBytes, _ := json.Marshal(dat)
  14330. // var res models.Result9001
  14331. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14332. // utils.ErrorLog("解析失败:%v", err)
  14333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14334. // return
  14335. // }
  14336. //
  14337. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14338. // var dat2 map[string]interface{}
  14339. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14340. // fmt.Println(dat)
  14341. // } else {
  14342. // fmt.Println(err)
  14343. // }
  14344. // userJSONBytes2, _ := json.Marshal(dat2)
  14345. // var res2 models.Result3260
  14346. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14347. // utils.ErrorLog("解析失败:%v", err)
  14348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14349. // return
  14350. // }
  14351. // if res2.Infcode == 0 {
  14352. // c.ServeSuccessJSON(map[string]interface{}{
  14353. // "list": res2.Output.Data,
  14354. // })
  14355. // return
  14356. // } else {
  14357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14358. // return
  14359. // }
  14360. //
  14361. //}
  14362. //func (c *HisApiController) ComfirmAllopatry() {
  14363. // year := c.GetString("year")
  14364. // month := c.GetString("month")
  14365. // admin_user_id, _ := c.GetInt64("admin_user_id")
  14366. // adminUser := c.GetAdminUserInfo()
  14367. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14368. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14369. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  14370. // var dat map[string]interface{}
  14371. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14372. // fmt.Println(dat)
  14373. // } else {
  14374. // fmt.Println(err)
  14375. // }
  14376. // userJSONBytes, _ := json.Marshal(dat)
  14377. // var res models.Result9001
  14378. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14379. // utils.ErrorLog("解析失败:%v", err)
  14380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14381. // return
  14382. // }
  14383. //
  14384. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14385. // var dat2 map[string]interface{}
  14386. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14387. // fmt.Println(dat)
  14388. // } else {
  14389. // fmt.Println(err)
  14390. // }
  14391. // userJSONBytes2, _ := json.Marshal(dat2)
  14392. // var res2 models.Result3260
  14393. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14394. // utils.ErrorLog("解析失败:%v", err)
  14395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14396. // return
  14397. // }
  14398. //
  14399. // if res2.Infcode == 0 {
  14400. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14401. // var dat map[string]interface{}
  14402. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14403. // fmt.Println(dat)
  14404. // } else {
  14405. // fmt.Println(err)
  14406. // }
  14407. // userJSONBytes, _ := json.Marshal(dat)
  14408. // var res3 models.Result3261
  14409. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  14410. // utils.ErrorLog("解析失败:%v", err)
  14411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14412. // return
  14413. // }
  14414. //
  14415. // if res3.Infcode == 0 {
  14416. // record := &models.HisYidiClearRecord{
  14417. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14418. // Ctime: time.Now().Unix(),
  14419. // Mtime: time.Now().Unix(),
  14420. // Status: 1,
  14421. // MsgId: msgId,
  14422. // }
  14423. // service.SaveClearRecord(record)
  14424. // c.ServeSuccessJSON(map[string]interface{}{
  14425. // "msg": "提取成功",
  14426. // })
  14427. // }
  14428. // }
  14429. //}
  14430. func (c *HisApiController) RefundAllopatry() {
  14431. year := c.GetString("year")
  14432. month := c.GetString("month")
  14433. id, _ := c.GetInt64("id")
  14434. admin_user_id, _ := c.GetInt64("admin_user_id")
  14435. adminUser := c.GetAdminUserInfo()
  14436. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14437. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14438. record, _ := service.GetClearRecordById(id)
  14439. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  14440. var dat map[string]interface{}
  14441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14442. fmt.Println(dat)
  14443. } else {
  14444. fmt.Println(err)
  14445. }
  14446. userJSONBytes, _ := json.Marshal(dat)
  14447. var empty ResultFourteen
  14448. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  14449. utils.ErrorLog("解析失败:%v", err)
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14451. return
  14452. }
  14453. if empty.Infcode == 0 {
  14454. c.ServeSuccessJSON(map[string]interface{}{
  14455. "msg": "撤销成功",
  14456. })
  14457. return
  14458. }
  14459. }
  14460. func (c *HisApiController) ReversalOtherData() {
  14461. var customData []*CustomData
  14462. custom := &CustomData{
  14463. MsgId: "H44022900158202103301714472004",
  14464. PsnNo: "44020000001101329945",
  14465. Info: "2208",
  14466. }
  14467. customData = append(customData, custom)
  14468. custom1 := &CustomData{
  14469. MsgId: "H4402290015820210330172057803",
  14470. PsnNo: "44020000001101161813",
  14471. Info: "2208",
  14472. }
  14473. customData = append(customData, custom1)
  14474. custom2 := &CustomData{
  14475. MsgId: "H44022900158202103301705198813",
  14476. PsnNo: "44190000133097375417",
  14477. Info: "2208",
  14478. }
  14479. customData = append(customData, custom2)
  14480. custom3 := &CustomData{
  14481. MsgId: "H44022900158202103301715524756",
  14482. PsnNo: "44020000001100187221",
  14483. Info: "2208",
  14484. }
  14485. customData = append(customData, custom3)
  14486. custom4 := &CustomData{
  14487. MsgId: "H44022900158202103301730376224",
  14488. PsnNo: "44020000001101959155",
  14489. Info: "2208",
  14490. }
  14491. customData = append(customData, custom4)
  14492. custom5 := &CustomData{
  14493. MsgId: "H44022900158202103301748008725",
  14494. PsnNo: "44020000001104246641",
  14495. Info: "2208",
  14496. }
  14497. customData = append(customData, custom5)
  14498. custom6 := &CustomData{
  14499. MsgId: "H44022900158202103301718096755",
  14500. PsnNo: "44020000001102211860",
  14501. Info: "2208",
  14502. }
  14503. customData = append(customData, custom6)
  14504. custom7 := &CustomData{
  14505. MsgId: "H44022900158202103301736551640",
  14506. PsnNo: "44020000001102687718",
  14507. Info: "2208",
  14508. }
  14509. customData = append(customData, custom7)
  14510. custom8 := &CustomData{
  14511. MsgId: "H44022900158202103301743097676",
  14512. PsnNo: "44020000001102127785",
  14513. Info: "2208",
  14514. }
  14515. customData = append(customData, custom8)
  14516. custom9 := &CustomData{
  14517. MsgId: "H44022900158202103301712304203",
  14518. PsnNo: "44020000001101518097",
  14519. Info: "2208",
  14520. }
  14521. customData = append(customData, custom9)
  14522. custom10 := &CustomData{
  14523. MsgId: "H44022900158202103301738448785",
  14524. PsnNo: "44020000001100500813",
  14525. Info: "2208",
  14526. }
  14527. customData = append(customData, custom10)
  14528. custom11 := &CustomData{
  14529. MsgId: "H44022900158202103301732455843",
  14530. PsnNo: "44020000001102690557",
  14531. Info: "2208",
  14532. }
  14533. customData = append(customData, custom11)
  14534. custom12 := &CustomData{
  14535. MsgId: "H44022900158202103301745421708",
  14536. PsnNo: "44020000001102211928",
  14537. Info: "2208",
  14538. }
  14539. customData = append(customData, custom12)
  14540. custom1212 := &CustomData{
  14541. MsgId: "H440229001582021033017351627",
  14542. PsnNo: "44020000001102481733",
  14543. Info: "2208",
  14544. }
  14545. customData = append(customData, custom1212)
  14546. custom13 := &CustomData{
  14547. MsgId: "H44022900158202103301740327951",
  14548. PsnNo: "44020000001103174866",
  14549. Info: "2208",
  14550. }
  14551. customData = append(customData, custom13)
  14552. custom14 := &CustomData{
  14553. MsgId: "H4402290015820210330174922668",
  14554. PsnNo: "44020000001102927272",
  14555. Info: "2208",
  14556. }
  14557. customData = append(customData, custom14)
  14558. custom15 := &CustomData{
  14559. MsgId: "H44022900158202103301752362273",
  14560. PsnNo: "44020000001102942890",
  14561. Info: "2208",
  14562. }
  14563. customData = append(customData, custom15)
  14564. custom16 := &CustomData{
  14565. MsgId: "H44022900158202103301751082917",
  14566. PsnNo: "44020000001101662162",
  14567. Info: "2208",
  14568. }
  14569. customData = append(customData, custom16)
  14570. custom17 := &CustomData{
  14571. MsgId: "H44022900158202103301754147728",
  14572. PsnNo: "44020000000229014511",
  14573. Info: "2208",
  14574. }
  14575. customData = append(customData, custom17)
  14576. adminUser := c.GetAdminUserInfo()
  14577. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14578. for _, item := range customData {
  14579. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14580. fmt.Println(result)
  14581. }
  14582. }
  14583. func PathExists(path string) (bool, error) {
  14584. _, err := os.Stat(path)
  14585. if err == nil {
  14586. return true, nil
  14587. }
  14588. if os.IsNotExist(err) {
  14589. return false, nil
  14590. }
  14591. return false, err
  14592. }
  14593. //创建文件夹
  14594. func Mkdir(dir string) {
  14595. // 创建文件夹
  14596. exist, err := PathExists(dir)
  14597. if err != nil {
  14598. fmt.Println(err.Error())
  14599. } else {
  14600. if exist {
  14601. fmt.Println(dir + "文件夹已存在!")
  14602. } else {
  14603. // 文件夹名称,权限
  14604. err := os.Mkdir(dir, os.ModePerm)
  14605. if err != nil {
  14606. fmt.Println(dir+"文件夹创建失败:", err.Error())
  14607. } else {
  14608. fmt.Println(dir + "文件夹创建成功!")
  14609. }
  14610. }
  14611. }
  14612. }
  14613. //压缩文件
  14614. func Zip(srcFile string, destZip string) error {
  14615. zipfile, err := os.Create(destZip)
  14616. if err != nil {
  14617. return err
  14618. }
  14619. defer zipfile.Close()
  14620. archive := zip.NewWriter(zipfile)
  14621. defer archive.Close()
  14622. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  14623. if err != nil {
  14624. return err
  14625. }
  14626. header, err := zip.FileInfoHeader(info)
  14627. if err != nil {
  14628. return err
  14629. }
  14630. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  14631. // header.Name = path
  14632. if info.IsDir() {
  14633. header.Name += "/"
  14634. } else {
  14635. header.Method = zip.Deflate
  14636. }
  14637. writer, err := archive.CreateHeader(header)
  14638. if err != nil {
  14639. return err
  14640. }
  14641. if !info.IsDir() {
  14642. file, err := os.Open(path)
  14643. if err != nil {
  14644. return err
  14645. }
  14646. defer file.Close()
  14647. _, err = io.Copy(writer, file)
  14648. }
  14649. return err
  14650. })
  14651. return err
  14652. }
  14653. func ReadFile(filePath string) []byte {
  14654. f, err := os.Open(filePath)
  14655. if err != nil {
  14656. fmt.Println("read file fail", err)
  14657. return nil
  14658. }
  14659. defer f.Close()
  14660. fd, err := ioutil.ReadAll(f)
  14661. if err != nil {
  14662. fmt.Println("read to fd fail", err)
  14663. return nil
  14664. }
  14665. return fd
  14666. }
  14667. func saveLog(result string, request string, infno string, desc string) {
  14668. org_id, _ := beego.AppConfig.Int64("org_id")
  14669. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14670. dir := miConfig.OrgName + "日志"
  14671. utils.Mkdir(dir)
  14672. month := time.Unix(1557042972, 0).Format("1")
  14673. year := time.Now().Format("2006")
  14674. month = time.Now().Format("01")
  14675. day := time.Now().Format("02")
  14676. hour := time.Now().Format("15")
  14677. min := time.Now().Format("04")
  14678. sec := time.Now().Format("05")
  14679. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  14680. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  14681. file_name := file + ".txt"
  14682. file_path := miConfig.OrgName + "日志" + "/" + file_name
  14683. exist, _ := utils.PathExists(file_path)
  14684. if exist { //存在
  14685. fmt.Println("存在")
  14686. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  14687. if err != nil {
  14688. fmt.Println("read fail")
  14689. }
  14690. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  14691. n, _ := f.Seek(0, 2)
  14692. _, err = f.WriteAt([]byte(content), n)
  14693. } else { //不存在
  14694. fmt.Println("文件不存在,创建文件")
  14695. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  14696. defer f.Close()
  14697. if err != nil {
  14698. } else {
  14699. _, err = f.Write([]byte("记录日志"))
  14700. }
  14701. }
  14702. }
  14703. type Charset string
  14704. const (
  14705. UTF8 = Charset("UTF-8")
  14706. GB18030 = Charset("GB18030")
  14707. )
  14708. func ConvertToString(src string, srcCode string, tagCode string) string {
  14709. srcCoder := mahonia.NewDecoder(srcCode)
  14710. srcResult := srcCoder.ConvertString(src)
  14711. tagCoder := mahonia.NewDecoder(tagCode)
  14712. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  14713. result := string(cdata)
  14714. return result
  14715. }
  14716. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  14717. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  14718. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14719. var token string
  14720. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14721. var api string
  14722. if miConfig.MdtrtareaAdmvs == "320921" {
  14723. 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 +
  14724. "&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
  14725. fmt.Println(api)
  14726. } else {
  14727. 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 +
  14728. "&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
  14729. }
  14730. resp, requestErr := http.Get(api)
  14731. if requestErr != nil {
  14732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14733. return ""
  14734. }
  14735. body, ioErr := ioutil.ReadAll(resp.Body)
  14736. if ioErr != nil {
  14737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14739. return ""
  14740. }
  14741. var respJSON map[string]interface{}
  14742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14745. return ""
  14746. }
  14747. var status string
  14748. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14749. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14750. var res ResultTwo //1101结果
  14751. var res10265 ResultTwo10265 //1101结果
  14752. if status == "0" { //读卡成功
  14753. var card_info string //卡信息
  14754. var busi_card_info string
  14755. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14756. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14757. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14758. fmt.Println(card_info)
  14759. fmt.Println(busi_card_info)
  14760. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14761. result, _ := json.Marshal(respJSON)
  14762. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14763. utils.ErrorLog("解析失败:%v", err)
  14764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14765. return ""
  14766. }
  14767. res.ErrMsg = res10265.ErrMsg
  14768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14769. res.Infcode = infocode
  14770. res.Output = res10265.Output
  14771. res.InfRefmsgid = res10265.InfRefmsgid
  14772. if res.Infcode == 0 {
  14773. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14774. if err == gorm.ErrRecordNotFound {
  14775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14776. return ""
  14777. } else if err != nil {
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14779. return ""
  14780. } else {
  14781. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14782. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14783. infoStr := string(Iinfos)
  14784. idetinfoStr := string(Idetinfos)
  14785. psn := &models.HisPsn{
  14786. PsnNo: res.Output.Baseinfo.PsnNo,
  14787. Age: res.Output.Baseinfo.Age,
  14788. PatientId: patient.ID,
  14789. Certno: res.Output.Baseinfo.Certno,
  14790. Brdy: res.Output.Baseinfo.Brdy,
  14791. Gend: res.Output.Baseinfo.Gend,
  14792. Naty: res.Output.Baseinfo.Naty,
  14793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14794. PsnName: res.Output.Baseinfo.PsnName,
  14795. Idetinfo: idetinfoStr,
  14796. Insuinfo: infoStr,
  14797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14798. CardInfo: card_info,
  14799. VerifyNumber: token,
  14800. }
  14801. service.CreateHisPsn(psn)
  14802. return token
  14803. }
  14804. }
  14805. } else {
  14806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14807. return ""
  14808. }
  14809. } else { //读卡失败
  14810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14811. return ""
  14812. }
  14813. return token
  14814. }
  14815. func DeleteExtraSpaceTwo(s string) string {
  14816. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14817. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14818. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14819. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14820. s2 := make([]byte, len(s1)) //定义字符数组切片
  14821. copy(s2, s1) //将字符串复制到切片
  14822. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14823. for len(spc_index) > 0 { //找到适配项
  14824. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14825. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14826. }
  14827. return string(s2)
  14828. }
  14829. func Remove0000(s string) string {
  14830. str := make([]rune, 0, len(s))
  14831. for _, v := range []rune(s) {
  14832. if v == 0 {
  14833. continue
  14834. }
  14835. str = append(str, v)
  14836. }
  14837. return string(str)
  14838. }
  14839. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14840. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14841. readCard := DllDef.MustFindProc("EcQuery")
  14842. pCardInfo := make([]byte, 8192)
  14843. pBusiCardInfo := make([]byte, 8192)
  14844. data := make(map[string]interface{})
  14845. //pData := make(map[string]interface{})
  14846. inputData := make(map[string]interface{})
  14847. inputData["orgId"] = code
  14848. inputData["businessType"] = "01101"
  14849. inputData["operatorId"] = operator_id
  14850. inputData["operatorName"] = operator_name
  14851. inputData["officeId"] = "001"
  14852. inputData["officeName"] = "血透室"
  14853. //
  14854. data["data"] = inputData
  14855. data["transType"] = "ec.query"
  14856. data["orgId"] = code
  14857. bytesData, _ := json.Marshal(data)
  14858. pCardInfo = bytesData
  14859. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14860. fmt.Println(ret2)
  14861. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14862. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14863. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14864. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14865. if ret2 != 0 {
  14866. return "", ""
  14867. }
  14868. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14869. }
  14870. func DeleteExtraSpace(s string) string {
  14871. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14872. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14873. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14874. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14875. s2 := make([]byte, len(s1)) //定义字符数组切片
  14876. copy(s2, s1) //将字符串复制到切片
  14877. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14878. for len(spc_index) > 0 { //找到适配项
  14879. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14880. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14881. }
  14882. return string(s2)
  14883. }
  14884. //对账
  14885. func (c *HisApiController) Post3202() {
  14886. start_time := c.GetString("start_time")
  14887. end_time := c.GetString("end_time")
  14888. //insutype := c.GetString("insutype")
  14889. clr_type := c.GetString("clr_type")
  14890. clr_org := c.GetString("clr_optins")
  14891. admin_user_id, _ := c.GetInt64("admin_user_id")
  14892. adminUser := c.GetAdminUserInfo()
  14893. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14894. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14895. if len(clr_org) == 0 {
  14896. clr_org = miConfig.MdtrtareaAdmvs
  14897. }
  14898. timeLayout := "2006-01-02"
  14899. loc, _ := time.LoadLocation("Local")
  14900. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14901. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14902. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14903. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14904. //fixmedins_setl_cnt := int64(len(orders))
  14905. var medfee_sumamt float64
  14906. var acct_pay float64
  14907. var fund_pay_sumamt float64
  14908. for _, item := range orders {
  14909. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14910. acct_pay = acct_pay + item.AcctPay
  14911. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14912. }
  14913. //var medfee_sumamt_two float64
  14914. //var acct_pay_two float64
  14915. //var fund_pay_sumamt_two float64
  14916. //for _, item := range orders_two {
  14917. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14918. // acct_pay_two = acct_pay_two + item.AcctPay
  14919. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14920. //}
  14921. //var user_name string
  14922. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14923. //if role.ID == 0 {
  14924. // user_name = "xxx"
  14925. //} else {
  14926. // user_name = role.UserName
  14927. //}
  14928. var res ResultSix
  14929. if config.IsOpen == 1 {
  14930. var bps []*models.BusinessParamsTwo
  14931. var bp models.BusinessParamsTwo
  14932. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14933. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14934. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14935. bp.MedfeeSumamt = medfee_sumamt_str
  14936. bp.AcctPay = acct_pay_str
  14937. bp.FundPaySumamt = fund_pay_sumamt_str
  14938. bp.Insutype = "390"
  14939. bp.StmtBegndate = start_time
  14940. bp.ClrType = clr_type
  14941. bp.SetlOptins = clr_org
  14942. bp.StmtEnddate = end_time
  14943. bps = append(bps, &bp)
  14944. data := make(map[string]interface{})
  14945. data["bps"] = bps
  14946. data["org_name"] = miConfig.OrgName
  14947. data["doctor"] = role.UserName
  14948. data["fixmedins_code"] = miConfig.Code
  14949. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14951. if miConfig.MdtrtareaAdmvs == "421300" {
  14952. client := &http.Client{}
  14953. bytesData, _ := json.Marshal(data)
  14954. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14955. resp, _ := client.Do(req)
  14956. defer resp.Body.Close()
  14957. body, ioErr := ioutil.ReadAll(resp.Body)
  14958. if ioErr != nil {
  14959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14961. return
  14962. }
  14963. var respJSON map[string]interface{}
  14964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14967. return
  14968. }
  14969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14970. userJSONBytes, _ := json.Marshal(respJSON)
  14971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14972. utils.ErrorLog("解析失败:%v", err)
  14973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14974. return
  14975. }
  14976. }
  14977. if res.Infcode == 0 {
  14978. c.ServeSuccessJSON(map[string]interface{}{
  14979. "msg": "发起成功",
  14980. })
  14981. } else {
  14982. c.ServeSuccessJSON(map[string]interface{}{
  14983. "code": -10,
  14984. "msg": res.ErrMsg,
  14985. })
  14986. }
  14987. }
  14988. }
  14989. func (c *HisApiController) Post3501() {
  14990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14991. data := make(map[string]interface{})
  14992. var struct3501s []models.Struct3501
  14993. var struct3501 models.Struct3501
  14994. struct3501.OrgName = miConfig.OrgName
  14995. struct3501.AccessKey = miConfig.AccessKey
  14996. struct3501.RequestUrl = miConfig.Url
  14997. struct3501.SecretKey = miConfig.SecretKey
  14998. struct3501.ManuDate = "2022-08-17"
  14999. struct3501.FixmedinsBchno = ""
  15000. struct3501.ManuLotnum = ""
  15001. struct3501.RxFlag = "0"
  15002. struct3501.ExpyEnd = "2022-08-17"
  15003. struct3501.Invdate = "2022-08-17"
  15004. struct3501.InvCnt = "20.25"
  15005. struct3501.Memo = ""
  15006. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15007. struct3501.FixmedinsHilistId = miConfig.Code
  15008. struct3501.FixmedinsHilistName = miConfig.OrgName
  15009. struct3501s = append(struct3501s, struct3501)
  15010. data["struct_3501s"] = struct3501s
  15011. client := &http.Client{}
  15012. bytesData, _ := json.Marshal(data)
  15013. var req *http.Request
  15014. if miConfig.MdtrtareaAdmvs == "320921" {
  15015. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15016. } else {
  15017. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15018. }
  15019. resp, _ := client.Do(req)
  15020. defer resp.Body.Close()
  15021. body, ioErr := ioutil.ReadAll(resp.Body)
  15022. if ioErr != nil {
  15023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15025. return
  15026. }
  15027. var respJSON map[string]interface{}
  15028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15031. return
  15032. }
  15033. var res ResultSix
  15034. var resSix10265 ResultSix10265 //1101结果
  15035. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15036. result, _ := json.Marshal(respJSON)
  15037. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15038. utils.ErrorLog("解析失败:%v", err)
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15040. return
  15041. }
  15042. res.InfRefmsgid = resSix10265.InfRefmsgid
  15043. res.Output = resSix10265.Output
  15044. res.ErrMsg = resSix10265.ErrMsg
  15045. res.Cainfo = resSix10265.Cainfo
  15046. res.WarnMsg = resSix10265.WarnMsg
  15047. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15048. res.Infcode = infocode
  15049. if infocode == 0 {
  15050. c.ServeSuccessJSON(map[string]interface{}{
  15051. "msg": "上传成功",
  15052. })
  15053. return
  15054. } else {
  15055. c.ServeSuccessJSON(map[string]interface{}{
  15056. "failed_code": -10,
  15057. "msg": res.ErrMsg,
  15058. })
  15059. return
  15060. }
  15061. }
  15062. func (c *HisApiController) Post3502() {
  15063. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15064. data := make(map[string]interface{})
  15065. var struct3502s []models.Struct3502
  15066. var struct3502 models.Struct3502
  15067. struct3502.OrgName = miConfig.OrgName
  15068. struct3502.AccessKey = miConfig.AccessKey
  15069. struct3502.RequestUrl = miConfig.Url
  15070. struct3502.SecretKey = miConfig.SecretKey
  15071. struct3502.ManuDate = "2022-08-15"
  15072. struct3502.FixmedinsBchno = ""
  15073. struct3502.ManuLotnum = ""
  15074. struct3502.RxFlag = "0"
  15075. struct3502.ExpyEnd = "2022-08-15"
  15076. struct3502.Invdate = "2022-08-15"
  15077. struct3502.InvCnt = "20.25"
  15078. struct3502.Memo = ""
  15079. struct3502.MedListCodg = "XB01ABD056B002020200517"
  15080. struct3502.FixmedinsHilistId = miConfig.Code
  15081. struct3502.FixmedinsHilistName = miConfig.OrgName
  15082. struct3502s = append(struct3502s, struct3502)
  15083. data["struct_3502s"] = struct3502s
  15084. client := &http.Client{}
  15085. bytesData, _ := json.Marshal(data)
  15086. var req *http.Request
  15087. if miConfig.MdtrtareaAdmvs == "320921" {
  15088. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15089. } else {
  15090. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15091. }
  15092. resp, _ := client.Do(req)
  15093. defer resp.Body.Close()
  15094. body, ioErr := ioutil.ReadAll(resp.Body)
  15095. if ioErr != nil {
  15096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15098. return
  15099. }
  15100. var respJSON map[string]interface{}
  15101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15104. return
  15105. }
  15106. var res ResultSix
  15107. var resSix10265 ResultSix10265 //1101结果
  15108. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15109. result, _ := json.Marshal(respJSON)
  15110. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15111. utils.ErrorLog("解析失败:%v", err)
  15112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15113. return
  15114. }
  15115. res.InfRefmsgid = resSix10265.InfRefmsgid
  15116. res.Output = resSix10265.Output
  15117. res.ErrMsg = resSix10265.ErrMsg
  15118. res.Cainfo = resSix10265.Cainfo
  15119. res.WarnMsg = resSix10265.WarnMsg
  15120. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15121. res.Infcode = infocode
  15122. if infocode == 0 {
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "msg": "上传成功",
  15125. })
  15126. return
  15127. } else {
  15128. c.ServeSuccessJSON(map[string]interface{}{
  15129. "failed_code": -10,
  15130. "msg": res.ErrMsg,
  15131. })
  15132. return
  15133. }
  15134. }
  15135. func (c *HisApiController) Post3503() {
  15136. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15137. data := make(map[string]interface{})
  15138. var struct3501s []models.Struct3501
  15139. var struct3501 models.Struct3501
  15140. struct3501.OrgName = miConfig.OrgName
  15141. struct3501.AccessKey = miConfig.AccessKey
  15142. struct3501.RequestUrl = miConfig.Url
  15143. struct3501.SecretKey = miConfig.SecretKey
  15144. struct3501.ManuDate = "2022-08-15"
  15145. struct3501.FixmedinsBchno = ""
  15146. struct3501.ManuLotnum = ""
  15147. struct3501.RxFlag = "0"
  15148. struct3501.ExpyEnd = "2022-08-15"
  15149. struct3501.Invdate = "2022-08-15"
  15150. struct3501.InvCnt = "20.25"
  15151. struct3501.Memo = ""
  15152. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15153. struct3501.FixmedinsHilistId = miConfig.Code
  15154. struct3501.FixmedinsHilistName = miConfig.OrgName
  15155. struct3501s = append(struct3501s, struct3501)
  15156. data["struct_3501s"] = struct3501s
  15157. client := &http.Client{}
  15158. bytesData, _ := json.Marshal(data)
  15159. var req *http.Request
  15160. if miConfig.MdtrtareaAdmvs == "320921" {
  15161. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15162. } else {
  15163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15164. }
  15165. resp, _ := client.Do(req)
  15166. defer resp.Body.Close()
  15167. body, ioErr := ioutil.ReadAll(resp.Body)
  15168. if ioErr != nil {
  15169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15171. return
  15172. }
  15173. var respJSON map[string]interface{}
  15174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15177. return
  15178. }
  15179. var res ResultSix
  15180. var resSix10265 ResultSix10265 //1101结果
  15181. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15182. result, _ := json.Marshal(respJSON)
  15183. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15184. utils.ErrorLog("解析失败:%v", err)
  15185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15186. return
  15187. }
  15188. res.InfRefmsgid = resSix10265.InfRefmsgid
  15189. res.Output = resSix10265.Output
  15190. res.ErrMsg = resSix10265.ErrMsg
  15191. res.Cainfo = resSix10265.Cainfo
  15192. res.WarnMsg = resSix10265.WarnMsg
  15193. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15194. res.Infcode = infocode
  15195. if infocode == 0 {
  15196. c.ServeSuccessJSON(map[string]interface{}{
  15197. "msg": "上传成功",
  15198. })
  15199. return
  15200. } else {
  15201. c.ServeSuccessJSON(map[string]interface{}{
  15202. "failed_code": -10,
  15203. "msg": res.ErrMsg,
  15204. })
  15205. return
  15206. }
  15207. }
  15208. func (c *HisApiController) Post3504() {
  15209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15210. data := make(map[string]interface{})
  15211. var struct3501s []models.Struct3501
  15212. var struct3501 models.Struct3501
  15213. struct3501.OrgName = miConfig.OrgName
  15214. struct3501.AccessKey = miConfig.AccessKey
  15215. struct3501.RequestUrl = miConfig.Url
  15216. struct3501.SecretKey = miConfig.SecretKey
  15217. struct3501.ManuDate = "2022-08-15"
  15218. struct3501.FixmedinsBchno = ""
  15219. struct3501.ManuLotnum = ""
  15220. struct3501.RxFlag = "0"
  15221. struct3501.ExpyEnd = "2022-08-15"
  15222. struct3501.Invdate = "2022-08-15"
  15223. struct3501.InvCnt = "20.25"
  15224. struct3501.Memo = ""
  15225. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15226. struct3501.FixmedinsHilistId = miConfig.Code
  15227. struct3501.FixmedinsHilistName = miConfig.OrgName
  15228. struct3501s = append(struct3501s, struct3501)
  15229. data["struct_3501s"] = struct3501s
  15230. client := &http.Client{}
  15231. bytesData, _ := json.Marshal(data)
  15232. var req *http.Request
  15233. if miConfig.MdtrtareaAdmvs == "320921" {
  15234. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15235. } else {
  15236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15237. }
  15238. resp, _ := client.Do(req)
  15239. defer resp.Body.Close()
  15240. body, ioErr := ioutil.ReadAll(resp.Body)
  15241. if ioErr != nil {
  15242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15244. return
  15245. }
  15246. var respJSON map[string]interface{}
  15247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15250. return
  15251. }
  15252. var res ResultSix
  15253. var resSix10265 ResultSix10265 //1101结果
  15254. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15255. result, _ := json.Marshal(respJSON)
  15256. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15257. utils.ErrorLog("解析失败:%v", err)
  15258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15259. return
  15260. }
  15261. res.InfRefmsgid = resSix10265.InfRefmsgid
  15262. res.Output = resSix10265.Output
  15263. res.ErrMsg = resSix10265.ErrMsg
  15264. res.Cainfo = resSix10265.Cainfo
  15265. res.WarnMsg = resSix10265.WarnMsg
  15266. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15267. res.Infcode = infocode
  15268. if infocode == 0 {
  15269. c.ServeSuccessJSON(map[string]interface{}{
  15270. "msg": "上传成功",
  15271. })
  15272. return
  15273. } else {
  15274. c.ServeSuccessJSON(map[string]interface{}{
  15275. "failed_code": -10,
  15276. "msg": res.ErrMsg,
  15277. })
  15278. return
  15279. }
  15280. }
  15281. func (c *HisApiController) Post3505() {
  15282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15283. data := make(map[string]interface{})
  15284. var struct3501s []models.Struct3501
  15285. var struct3501 models.Struct3501
  15286. struct3501.OrgName = miConfig.OrgName
  15287. struct3501.AccessKey = miConfig.AccessKey
  15288. struct3501.RequestUrl = miConfig.Url
  15289. struct3501.SecretKey = miConfig.SecretKey
  15290. struct3501.ManuDate = "2022-08-15"
  15291. struct3501.FixmedinsBchno = ""
  15292. struct3501.ManuLotnum = ""
  15293. struct3501.RxFlag = "0"
  15294. struct3501.ExpyEnd = "2022-08-15"
  15295. struct3501.Invdate = "2022-08-15"
  15296. struct3501.InvCnt = "20.25"
  15297. struct3501.Memo = ""
  15298. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15299. struct3501.FixmedinsHilistId = miConfig.Code
  15300. struct3501.FixmedinsHilistName = miConfig.OrgName
  15301. struct3501s = append(struct3501s, struct3501)
  15302. data["struct_3501s"] = struct3501s
  15303. client := &http.Client{}
  15304. bytesData, _ := json.Marshal(data)
  15305. var req *http.Request
  15306. if miConfig.MdtrtareaAdmvs == "320921" {
  15307. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15308. } else {
  15309. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15310. }
  15311. resp, _ := client.Do(req)
  15312. defer resp.Body.Close()
  15313. body, ioErr := ioutil.ReadAll(resp.Body)
  15314. if ioErr != nil {
  15315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15317. return
  15318. }
  15319. var respJSON map[string]interface{}
  15320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15323. return
  15324. }
  15325. var res ResultSix
  15326. var resSix10265 ResultSix10265 //1101结果
  15327. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15328. result, _ := json.Marshal(respJSON)
  15329. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15330. utils.ErrorLog("解析失败:%v", err)
  15331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15332. return
  15333. }
  15334. res.InfRefmsgid = resSix10265.InfRefmsgid
  15335. res.Output = resSix10265.Output
  15336. res.ErrMsg = resSix10265.ErrMsg
  15337. res.Cainfo = resSix10265.Cainfo
  15338. res.WarnMsg = resSix10265.WarnMsg
  15339. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15340. res.Infcode = infocode
  15341. if infocode == 0 {
  15342. c.ServeSuccessJSON(map[string]interface{}{
  15343. "msg": "上传成功",
  15344. })
  15345. return
  15346. } else {
  15347. c.ServeSuccessJSON(map[string]interface{}{
  15348. "failed_code": -10,
  15349. "msg": res.ErrMsg,
  15350. })
  15351. return
  15352. }
  15353. }
  15354. func (c *HisApiController) Post3506() {
  15355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15356. data := make(map[string]interface{})
  15357. var struct3501s []models.Struct3501
  15358. var struct3501 models.Struct3501
  15359. struct3501.OrgName = miConfig.OrgName
  15360. struct3501.AccessKey = miConfig.AccessKey
  15361. struct3501.RequestUrl = miConfig.Url
  15362. struct3501.SecretKey = miConfig.SecretKey
  15363. struct3501.ManuDate = "2022-08-15"
  15364. struct3501.FixmedinsBchno = ""
  15365. struct3501.ManuLotnum = ""
  15366. struct3501.RxFlag = "0"
  15367. struct3501.ExpyEnd = "2022-08-15"
  15368. struct3501.Invdate = "2022-08-15"
  15369. struct3501.InvCnt = "20.25"
  15370. struct3501.Memo = ""
  15371. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15372. struct3501.FixmedinsHilistId = miConfig.Code
  15373. struct3501.FixmedinsHilistName = miConfig.OrgName
  15374. struct3501s = append(struct3501s, struct3501)
  15375. data["struct_3501s"] = struct3501s
  15376. client := &http.Client{}
  15377. bytesData, _ := json.Marshal(data)
  15378. var req *http.Request
  15379. if miConfig.MdtrtareaAdmvs == "320921" {
  15380. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15381. } else {
  15382. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15383. }
  15384. resp, _ := client.Do(req)
  15385. defer resp.Body.Close()
  15386. body, ioErr := ioutil.ReadAll(resp.Body)
  15387. if ioErr != nil {
  15388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15390. return
  15391. }
  15392. var respJSON map[string]interface{}
  15393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15396. return
  15397. }
  15398. var res ResultSix
  15399. var resSix10265 ResultSix10265 //1101结果
  15400. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15401. result, _ := json.Marshal(respJSON)
  15402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15403. utils.ErrorLog("解析失败:%v", err)
  15404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15405. return
  15406. }
  15407. res.InfRefmsgid = resSix10265.InfRefmsgid
  15408. res.Output = resSix10265.Output
  15409. res.ErrMsg = resSix10265.ErrMsg
  15410. res.Cainfo = resSix10265.Cainfo
  15411. res.WarnMsg = resSix10265.WarnMsg
  15412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15413. res.Infcode = infocode
  15414. if infocode == 0 {
  15415. c.ServeSuccessJSON(map[string]interface{}{
  15416. "msg": "上传成功",
  15417. })
  15418. return
  15419. } else {
  15420. c.ServeSuccessJSON(map[string]interface{}{
  15421. "failed_code": -10,
  15422. "msg": res.ErrMsg,
  15423. })
  15424. return
  15425. }
  15426. }
  15427. func (c *HisApiController) Post3507() {
  15428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15429. data := make(map[string]interface{})
  15430. var struct3501s []models.Struct3501
  15431. var struct3501 models.Struct3501
  15432. struct3501.OrgName = miConfig.OrgName
  15433. struct3501.AccessKey = miConfig.AccessKey
  15434. struct3501.RequestUrl = miConfig.Url
  15435. struct3501.SecretKey = miConfig.SecretKey
  15436. struct3501.ManuDate = "2022-08-15"
  15437. struct3501.FixmedinsBchno = ""
  15438. struct3501.ManuLotnum = ""
  15439. struct3501.RxFlag = "0"
  15440. struct3501.ExpyEnd = "2022-08-15"
  15441. struct3501.Invdate = "2022-08-15"
  15442. struct3501.InvCnt = "20.25"
  15443. struct3501.Memo = ""
  15444. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15445. struct3501.FixmedinsHilistId = miConfig.Code
  15446. struct3501.FixmedinsHilistName = miConfig.OrgName
  15447. struct3501s = append(struct3501s, struct3501)
  15448. data["struct_3501s"] = struct3501s
  15449. client := &http.Client{}
  15450. bytesData, _ := json.Marshal(data)
  15451. var req *http.Request
  15452. if miConfig.MdtrtareaAdmvs == "320921" {
  15453. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15454. } else {
  15455. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15456. }
  15457. resp, _ := client.Do(req)
  15458. defer resp.Body.Close()
  15459. body, ioErr := ioutil.ReadAll(resp.Body)
  15460. if ioErr != nil {
  15461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15463. return
  15464. }
  15465. var respJSON map[string]interface{}
  15466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15469. return
  15470. }
  15471. var res ResultSix
  15472. var resSix10265 ResultSix10265 //1101结果
  15473. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15474. result, _ := json.Marshal(respJSON)
  15475. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15476. utils.ErrorLog("解析失败:%v", err)
  15477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15478. return
  15479. }
  15480. res.InfRefmsgid = resSix10265.InfRefmsgid
  15481. res.Output = resSix10265.Output
  15482. res.ErrMsg = resSix10265.ErrMsg
  15483. res.Cainfo = resSix10265.Cainfo
  15484. res.WarnMsg = resSix10265.WarnMsg
  15485. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15486. res.Infcode = infocode
  15487. if infocode == 0 {
  15488. c.ServeSuccessJSON(map[string]interface{}{
  15489. "msg": "上传成功",
  15490. })
  15491. return
  15492. } else {
  15493. c.ServeSuccessJSON(map[string]interface{}{
  15494. "failed_code": -10,
  15495. "msg": res.ErrMsg,
  15496. })
  15497. return
  15498. }
  15499. }