his_api_controller.go 800KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "math"
  6. //"crypto/x509/pkix"
  7. "encoding/json"
  8. "fmt"
  9. //"github.com/tjfoc/gmsm/sm2"
  10. //"github.com/tjfoc/gmsm/sm3"
  11. "gdyb/controllers"
  12. "gdyb/enums"
  13. "gdyb/models"
  14. "gdyb/service"
  15. "gdyb/utils"
  16. "github.com/astaxie/beego"
  17. "github.com/axgle/mahonia"
  18. "github.com/gorilla/websocket"
  19. "github.com/jinzhu/gorm"
  20. "github.com/shopspring/decimal"
  21. "io"
  22. "io/ioutil"
  23. //"math"
  24. "math/rand"
  25. "net/http"
  26. "net/url"
  27. "os"
  28. "path/filepath"
  29. "regexp"
  30. "strconv"
  31. "strings"
  32. "syscall"
  33. "time"
  34. "unsafe"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  81. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  87. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  88. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  89. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  90. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  91. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  92. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  93. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  94. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  95. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  96. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  97. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  98. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  99. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  102. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  103. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  104. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  105. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  106. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  107. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  108. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  109. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  110. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  111. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  112. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  113. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  114. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  115. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  116. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  117. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  118. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  119. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  120. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  121. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  122. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  123. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  124. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  125. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  126. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  127. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  128. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  129. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  130. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  131. }
  132. func (c *HisApiController) Get4102() {
  133. order_id, _ := c.GetInt64("order_id")
  134. admin_user_id, _ := c.GetInt64("admin_user_id")
  135. stas_type := c.GetString("stas_type")
  136. order, _ := service.GetHisOrderByIDTwo(order_id)
  137. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  139. var pp models.PublicParams
  140. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  141. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  142. pp.FixmedinsName = miConfig.OrgName
  143. pp.FixmedinsCode = miConfig.Code
  144. pp.RequestUrl = miConfig.Url
  145. pp.Cainfo = miConfig.Cainfo
  146. pp.SecretKey = miConfig.SecretKey
  147. pp.AccessKey = miConfig.AccessKey
  148. pp.OpterName = curRoles.UserName
  149. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  150. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  151. saveLog(result, request, "4102", "清单确认")
  152. var dat map[string]interface{}
  153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  154. fmt.Println(dat)
  155. } else {
  156. fmt.Println(err)
  157. }
  158. var empty ResultFourteen
  159. userJSONBytes, _ := json.Marshal(dat)
  160. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  161. utils.ErrorLog("解析失败:%v", err)
  162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  163. return
  164. }
  165. if empty.Infcode == 0 {
  166. c.ServeSuccessJSON(map[string]interface{}{
  167. "msg": "确认成功",
  168. })
  169. return
  170. }
  171. }
  172. // 对账权限查询
  173. func (c *HisApiController) Get3260() {
  174. admin_user_id, _ := c.GetInt64("admin_user_id")
  175. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  176. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  177. var api string
  178. var res models.JSResult3260
  179. if miConfig.MdtrtareaAdmvs == "320921" {
  180. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  181. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  182. } else {
  183. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  184. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  185. }
  186. resp, requestErr := http.Get(api)
  187. if requestErr != nil {
  188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  189. return
  190. }
  191. body, ioErr := ioutil.ReadAll(resp.Body)
  192. if ioErr != nil {
  193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  195. return
  196. }
  197. var respJSON map[string]interface{}
  198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  201. return
  202. }
  203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  204. result, _ := json.Marshal(respJSON)
  205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  206. utils.ErrorLog("解析失败:%v", err)
  207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  208. return
  209. }
  210. if res.Infcode == "0" {
  211. c.ServeSuccessJSON(map[string]interface{}{
  212. "result": res.Output.Data,
  213. })
  214. } else {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. }
  221. }
  222. func (c *HisApiController) Get3261() {
  223. admin_user_id, _ := c.GetInt64("admin_user_id")
  224. //month := c.GetString("month")
  225. startTime := c.GetString("start_time")
  226. //endTime, _ := c.GetString("end_time")
  227. times := strings.Split(startTime, "-")
  228. stmt_mon := times[0] + times[1]
  229. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  231. var api string
  232. var res models.JSResult3261
  233. //var res10265 Result5301For10265
  234. if miConfig.MdtrtareaAdmvs == "320921" {
  235. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  236. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  237. } else {
  238. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  239. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  240. }
  241. resp, requestErr := http.Get(api)
  242. if requestErr != nil {
  243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  244. return
  245. }
  246. body, ioErr := ioutil.ReadAll(resp.Body)
  247. if ioErr != nil {
  248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  250. return
  251. }
  252. var respJSON map[string]interface{}
  253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  256. return
  257. }
  258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  259. result, _ := json.Marshal(respJSON)
  260. if err := json.Unmarshal([]byte(result), &res); err != nil {
  261. utils.ErrorLog("解析失败:%v", err)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. if res.Infcode == "0" {
  266. c.ServeSuccessJSON(map[string]interface{}{
  267. "result": res.Output,
  268. })
  269. } else {
  270. c.ServeSuccessJSON(map[string]interface{}{
  271. "failed_code": -10,
  272. "msg": res.ErrMsg,
  273. })
  274. return
  275. }
  276. }
  277. func (c *HisApiController) Get3262() {
  278. admin_user_id, _ := c.GetInt64("admin_user_id")
  279. startTime := c.GetString("start_time")
  280. endTime := c.GetString("end_time")
  281. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  283. //timeLayout := "2006-01-02"
  284. //loc, _ := time.LoadLocation("Local")
  285. //var theStartTIme int64
  286. //if len(startTime) > 0 {
  287. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  288. // if err != nil {
  289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  290. // return
  291. // }
  292. // theStartTIme = theTime.Unix()
  293. //}
  294. //var theEndtTIme int64
  295. //if len(endTime) > 0 {
  296. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  297. // if err != nil {
  298. // utils.ErrorLog(err.Error())
  299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  300. // return
  301. // }
  302. // theEndtTIme = theTime.Unix()
  303. //}
  304. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  305. var twos []models.FixMonRecDetailFileInTwo
  306. for _, team := range datas {
  307. var two models.FixMonRecDetailFileInTwo
  308. two.MedType = team.MedType
  309. two.Insutype = team.Insutype
  310. two.PsnType = team.PsnType
  311. two.MedType = team.MedType
  312. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  313. two.InsuAdmdvs = team.InsuAdmdvs
  314. two.PsnTime = team.PsnTime
  315. two.PsnCnt = team.PsnCnt
  316. two.FundKey = team.FundKey
  317. //strconv.FormatFloat(team.MedfeeSumAmt, 'E', -1, 64)
  318. fmt.Println("1111")
  319. fmt.Println(team.Sumamt)
  320. fmt.Println(team.Fund)
  321. fmt.Println(team.Amt)
  322. fmt.Println("1111")
  323. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  324. fps, _ := strconv.ParseFloat(team.Fund, 64)
  325. fmt.Println(fps)
  326. ia, _ := strconv.ParseFloat(team.Amt, 64)
  327. fmt.Println(ia)
  328. two.MedfeeSumAmt = ms
  329. two.InscpAmt = ia
  330. two.FundPaySumAmt = fps
  331. twos = append(twos, two)
  332. }
  333. //startTime := c.GetString("start_time")
  334. //endTime, _ := c.GetString("end_time")
  335. times := strings.Split(startTime, "-")
  336. stmt_mon := times[0] + times[1]
  337. var funs []models.FundDetail
  338. for _, item := range datas {
  339. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  340. funs = append(funs, fun...)
  341. }
  342. var funInfos []models.Fund
  343. for _, item := range funs {
  344. var rf []models.FundInfo
  345. json.Unmarshal([]byte(item.SetlDetail), &rf)
  346. for _, subitem := range rf {
  347. var fund models.Fund
  348. fund.FundCode = subitem.FundPayType
  349. fund.FundName = subitem.FundPayTypeName
  350. fund.FundAmt = subitem.FundPayAmt
  351. fund.FundKey = item.FundKey
  352. fund.InsuAdmdvs = "555555"
  353. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  354. funInfos = append(funInfos, fund)
  355. }
  356. }
  357. var upld_btch string
  358. var empty models.JSResultEmpty
  359. data := make(map[string]interface{})
  360. data["org_name"] = miConfig.OrgName
  361. data["doctor"] = curRoles.UserName
  362. data["doctor_name"] = curRoles.UserName
  363. data["fixmedins_code"] = miConfig.Code
  364. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  365. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  366. data["secret_key"] = miConfig.SecretKey
  367. data["url"] = miConfig.Url
  368. data["ak"] = miConfig.AccessKey
  369. data["cainfo"] = miConfig.Cainfo
  370. data["datas"] = twos
  371. data["fund"] = funInfos
  372. fmt.Println(twos)
  373. month := time.Unix(1557042972, 0).Format("1")
  374. year := time.Now().Format("2006")
  375. month = time.Now().Format("01")
  376. day := time.Now().Format("02")
  377. hour := time.Now().Format("15")
  378. min := time.Now().Format("04")
  379. sec := time.Now().Format("05")
  380. fix_fill_date := year + month + day + hour + min + sec
  381. data["fix_fill_dept"] = miConfig.OrgName
  382. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  383. data["fix_fill_psn"] = curRoles.UserName
  384. data["fix_fill_date"] = fix_fill_date
  385. data["stmt_loc"] = "2"
  386. data["setl_mon"] = stmt_mon
  387. upld_btch = "0"
  388. data["upld_btch"] = upld_btch
  389. //fmt.Println(data)
  390. client := &http.Client{}
  391. bytesData, _ := json.Marshal(data)
  392. var req *http.Request
  393. if miConfig.MdtrtareaAdmvs == "320921" {
  394. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  395. } else {
  396. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  397. }
  398. resp, _ := client.Do(req)
  399. defer resp.Body.Close()
  400. body, ioErr := ioutil.ReadAll(resp.Body)
  401. if ioErr != nil {
  402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. }
  410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  411. //fmt.Println(respJSON)
  412. result, _ := json.Marshal(respJSON)
  413. //fmt.Println(result)
  414. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  415. utils.ErrorLog("解析失败:%v", err)
  416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  417. }
  418. if empty.Infcode != "0" {
  419. c.ServeSuccessJSON(map[string]interface{}{
  420. "failed_code": -10,
  421. "msg": empty.ErrMsg,
  422. })
  423. return
  424. } else {
  425. c.ServeSuccessJSON(map[string]interface{}{
  426. "msg": "上传成功",
  427. })
  428. return
  429. }
  430. }
  431. func (c *HisApiController) Get3263() {
  432. admin_user_id, _ := c.GetInt64("admin_user_id")
  433. startTime := c.GetString("start_time")
  434. //endTime, _ := c.GetString("end_time")
  435. times := strings.Split(startTime, "-")
  436. setl_mon := times[0] + times[1]
  437. upld_btch := "0"
  438. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  439. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  440. var result3263 models.JSResult3263
  441. data := make(map[string]interface{})
  442. data["org_name"] = miConfig.OrgName
  443. data["doctor"] = curRoles.UserName
  444. data["doctor_name"] = curRoles.UserName
  445. data["fixmedins_code"] = miConfig.Code
  446. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  447. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  448. data["secret_key"] = miConfig.SecretKey
  449. data["url"] = miConfig.Url
  450. data["ak"] = miConfig.AccessKey
  451. data["cainfo"] = miConfig.Cainfo
  452. data["setl_mon"] = setl_mon
  453. data["stmt_loc"] = "2"
  454. data["upld_btch"] = upld_btch
  455. client := &http.Client{}
  456. bytesData, _ := json.Marshal(data)
  457. var req *http.Request
  458. if miConfig.MdtrtareaAdmvs == "320921" {
  459. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  460. } else {
  461. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  462. }
  463. resp, _ := client.Do(req)
  464. defer resp.Body.Close()
  465. body, ioErr := ioutil.ReadAll(resp.Body)
  466. if ioErr != nil {
  467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. }
  470. var respJSON map[string]interface{}
  471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  474. }
  475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  476. fmt.Println(respJSON)
  477. result, _ := json.Marshal(respJSON)
  478. fmt.Println(result)
  479. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  480. utils.ErrorLog("解析失败:%v", err)
  481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  482. }
  483. if result3263.Infcode != "0" {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "failed_code": -10,
  486. "msg": result3263.ErrMsg,
  487. })
  488. return
  489. } else {
  490. c.ServeSuccessJSON(map[string]interface{}{
  491. "list": result3263.Output,
  492. })
  493. return
  494. }
  495. }
  496. func (c *HisApiController) Get3264() {
  497. admin_user_id, _ := c.GetInt64("admin_user_id")
  498. startTime := c.GetString("start_time")
  499. //endTime, _ := c.GetString("end_time")
  500. times := strings.Split(startTime, "-")
  501. setl_mon := times[0] + times[1]
  502. upld_btch := "0"
  503. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  504. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  505. //solidify_id := []
  506. var result3263 models.JSResult3263
  507. data := make(map[string]interface{})
  508. data["org_name"] = miConfig.OrgName
  509. data["doctor"] = curRoles.UserName
  510. data["doctor_name"] = curRoles.UserName
  511. data["fixmedins_code"] = miConfig.Code
  512. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  514. data["secret_key"] = miConfig.SecretKey
  515. data["url"] = miConfig.Url
  516. data["ak"] = miConfig.AccessKey
  517. data["cainfo"] = miConfig.Cainfo
  518. data["setl_mon"] = setl_mon
  519. data["stmt_loc"] = "2"
  520. data["upld_btch"] = upld_btch
  521. client := &http.Client{}
  522. bytesData, _ := json.Marshal(data)
  523. var req3263 *http.Request
  524. if miConfig.MdtrtareaAdmvs == "320921" {
  525. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  526. } else {
  527. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  528. }
  529. resp, _ := client.Do(req3263)
  530. defer resp.Body.Close()
  531. body, ioErr := ioutil.ReadAll(resp.Body)
  532. if ioErr != nil {
  533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. }
  536. var respJSON3263 map[string]interface{}
  537. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. }
  541. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  542. fmt.Println(respJSON3263)
  543. result, _ := json.Marshal(respJSON3263)
  544. fmt.Println(result)
  545. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  546. utils.ErrorLog("解析失败:%v", err)
  547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  548. }
  549. var ids []string
  550. for _, item := range result3263.Output {
  551. ids = append(ids, item.SolidifyID)
  552. }
  553. var empty models.JSResultEmpty
  554. data2 := make(map[string]interface{})
  555. data2["org_name"] = miConfig.OrgName
  556. data2["doctor"] = curRoles.UserName
  557. data2["doctor_name"] = curRoles.UserName
  558. data2["fixmedins_code"] = miConfig.Code
  559. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  560. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  561. data2["secret_key"] = miConfig.SecretKey
  562. data2["url"] = miConfig.Url
  563. data2["ak"] = miConfig.AccessKey
  564. data2["cainfo"] = miConfig.Cainfo
  565. data2["setl_mon"] = setl_mon
  566. data2["stmt_loc"] = "2"
  567. data2["upld_btch"] = upld_btch
  568. data2["solidify_id"] = ids
  569. client2 := &http.Client{}
  570. bytesData2, _ := json.Marshal(data2)
  571. var req *http.Request
  572. if miConfig.MdtrtareaAdmvs == "320921" {
  573. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  574. } else {
  575. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  576. }
  577. resp2, _ := client2.Do(req)
  578. defer resp.Body.Close()
  579. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  580. if ioErr2 != nil {
  581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  583. }
  584. var respJSON map[string]interface{}
  585. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  588. }
  589. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  590. fmt.Println(respJSON)
  591. result2, _ := json.Marshal(respJSON)
  592. fmt.Println(result2)
  593. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  594. utils.ErrorLog("解析失败:%v", err)
  595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  596. }
  597. if empty.Infcode != "0" {
  598. c.ServeSuccessJSON(map[string]interface{}{
  599. "failed_code": -10,
  600. "msg": empty.ErrMsg,
  601. })
  602. return
  603. } else {
  604. c.ServeSuccessJSON(map[string]interface{}{
  605. "msg": "",
  606. })
  607. return
  608. }
  609. }
  610. func (c *HisApiController) Get3265() {
  611. admin_user_id, _ := c.GetInt64("admin_user_id")
  612. startTime := c.GetString("start_time")
  613. //endTime, _ := c.GetString("end_time")
  614. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  615. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  616. times := strings.Split(startTime, "-")
  617. setl_mon := times[0] + times[1]
  618. var upld_btch string
  619. upld_btch = "0"
  620. //var empty models.JSResultEmpty
  621. var result3265 models.JSResult3264
  622. var result3263 models.JSResult3263
  623. data2 := make(map[string]interface{})
  624. data2["org_name"] = miConfig.OrgName
  625. data2["doctor"] = curRoles.UserName
  626. data2["doctor_name"] = curRoles.UserName
  627. data2["fixmedins_code"] = miConfig.Code
  628. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  629. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  630. data2["secret_key"] = miConfig.SecretKey
  631. data2["url"] = miConfig.Url
  632. data2["ak"] = miConfig.AccessKey
  633. data2["cainfo"] = miConfig.Cainfo
  634. data2["setl_mon"] = setl_mon
  635. data2["stmt_loc"] = "2"
  636. data2["upld_btch"] = upld_btch
  637. client2 := &http.Client{}
  638. bytesData2, _ := json.Marshal(data2)
  639. var req3263 *http.Request
  640. if miConfig.MdtrtareaAdmvs == "320921" {
  641. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  642. } else {
  643. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  644. }
  645. resp2, _ := client2.Do(req3263)
  646. defer resp2.Body.Close()
  647. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  648. if ioErr2 != nil {
  649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  651. }
  652. var respJSON3263 map[string]interface{}
  653. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  656. }
  657. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  658. fmt.Println(respJSON3263)
  659. result2, _ := json.Marshal(respJSON3263)
  660. fmt.Println(result2)
  661. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  662. utils.ErrorLog("解析失败:%v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. }
  665. var ids []string
  666. for _, item := range result3263.Output {
  667. ids = append(ids, item.SolidifyID)
  668. }
  669. data := make(map[string]interface{})
  670. data["org_name"] = miConfig.OrgName
  671. data["doctor"] = curRoles.UserName
  672. data["doctor_name"] = curRoles.UserName
  673. data["fixmedins_code"] = miConfig.Code
  674. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  675. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  676. data["secret_key"] = miConfig.SecretKey
  677. data["url"] = miConfig.Url
  678. data["ak"] = miConfig.AccessKey
  679. data["cainfo"] = miConfig.Cainfo
  680. data["setl_mon"] = setl_mon
  681. data["solidify_id"] = ids
  682. month := time.Unix(1557042972, 0).Format("1")
  683. year := time.Now().Format("2006")
  684. month = time.Now().Format("01")
  685. day := time.Now().Format("02")
  686. hour := time.Now().Format("15")
  687. min := time.Now().Format("04")
  688. sec := time.Now().Format("05")
  689. fix_fill_date := year + month + day + hour + min + sec
  690. data["fix_fill_dept"] = miConfig.OrgName
  691. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  692. data["fix_fill_psn"] = curRoles.UserName
  693. data["fix_fill_date"] = fix_fill_date
  694. data["stmt_loc"] = "2"
  695. data["upld_btch"] = upld_btch
  696. client := &http.Client{}
  697. bytesData, _ := json.Marshal(data)
  698. var req *http.Request
  699. if miConfig.MdtrtareaAdmvs == "320921" {
  700. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  701. } else {
  702. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  703. }
  704. resp, _ := client.Do(req)
  705. defer resp.Body.Close()
  706. body, ioErr := ioutil.ReadAll(resp.Body)
  707. if ioErr != nil {
  708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. }
  711. var respJSON map[string]interface{}
  712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  715. }
  716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  717. fmt.Println(respJSON)
  718. result, _ := json.Marshal(respJSON)
  719. fmt.Println(result)
  720. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  721. utils.ErrorLog("解析失败:%v", err)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. }
  724. if result3265.Infcode != "0" {
  725. c.ServeSuccessJSON(map[string]interface{}{
  726. "failed_code": -10,
  727. "msg": result3265.ErrMsg,
  728. })
  729. return
  730. } else {
  731. c.ServeSuccessJSON(map[string]interface{}{
  732. "info": result3265.Output,
  733. })
  734. return
  735. }
  736. }
  737. func (c *HisApiController) Get3266() {
  738. admin_user_id, _ := c.GetInt64("admin_user_id")
  739. startTime := c.GetString("start_time")
  740. //endTime, _ := c.GetString("end_time")
  741. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  743. times := strings.Split(startTime, "-")
  744. stmt_mon := times[0] + times[1]
  745. var upld_btch string
  746. //var empty models.JSResultEmpty
  747. var result3265 models.JSResult3264
  748. data := make(map[string]interface{})
  749. data["org_name"] = miConfig.OrgName
  750. data["doctor"] = curRoles.UserName
  751. data["doctor_name"] = curRoles.UserName
  752. data["fixmedins_code"] = miConfig.Code
  753. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  754. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  755. data["secret_key"] = miConfig.SecretKey
  756. data["url"] = miConfig.Url
  757. data["ak"] = miConfig.AccessKey
  758. data["cainfo"] = miConfig.Cainfo
  759. data["setl_mon"] = stmt_mon
  760. month := time.Unix(1557042972, 0).Format("1")
  761. year := time.Now().Format("2006")
  762. month = time.Now().Format("01")
  763. day := time.Now().Format("02")
  764. hour := time.Now().Format("15")
  765. min := time.Now().Format("04")
  766. sec := time.Now().Format("05")
  767. fix_fill_date := year + month + day + hour + min + sec
  768. data["fix_fill_dept"] = miConfig.OrgName
  769. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  770. data["fix_fill_psn"] = curRoles.UserName
  771. data["fix_fill_date"] = fix_fill_date
  772. data["stmt_loc"] = "2"
  773. upld_btch = "0"
  774. data["upld_btch"] = upld_btch
  775. client := &http.Client{}
  776. bytesData, _ := json.Marshal(data)
  777. var req *http.Request
  778. if miConfig.MdtrtareaAdmvs == "320921" {
  779. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  780. } else {
  781. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  782. }
  783. resp, _ := client.Do(req)
  784. defer resp.Body.Close()
  785. body, ioErr := ioutil.ReadAll(resp.Body)
  786. if ioErr != nil {
  787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  789. }
  790. var respJSON map[string]interface{}
  791. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  794. }
  795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  796. fmt.Println(respJSON)
  797. result, _ := json.Marshal(respJSON)
  798. fmt.Println(result)
  799. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  800. utils.ErrorLog("解析失败:%v", err)
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. }
  803. if result3265.Infcode != "0" {
  804. c.ServeSuccessJSON(map[string]interface{}{
  805. "failed_code": -10,
  806. "msg": result3265.ErrMsg,
  807. })
  808. return
  809. } else {
  810. c.ServeSuccessJSON(map[string]interface{}{
  811. "info": result3265.Output,
  812. })
  813. return
  814. }
  815. }
  816. func (c *HisApiController) Get3267() {
  817. admin_user_id, _ := c.GetInt64("admin_user_id")
  818. startTime := c.GetString("start_time")
  819. //endTime, _ := c.GetString("end_time")
  820. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  822. times := strings.Split(startTime, "-")
  823. setl_mon := times[0] + times[1]
  824. var upld_btch string
  825. //var empty models.JSResultEmpty
  826. var result3265 models.JSResult3264
  827. upld_btch = "0"
  828. data := make(map[string]interface{})
  829. data["org_name"] = miConfig.OrgName
  830. data["doctor"] = curRoles.UserName
  831. data["doctor_name"] = curRoles.UserName
  832. data["fixmedins_code"] = miConfig.Code
  833. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  834. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  835. data["secret_key"] = miConfig.SecretKey
  836. data["url"] = miConfig.Url
  837. data["ak"] = miConfig.AccessKey
  838. data["cainfo"] = miConfig.Cainfo
  839. data["setl_mon"] = setl_mon
  840. data["stmt_loc"] = "2"
  841. data["upld_btch"] = upld_btch
  842. client := &http.Client{}
  843. bytesData, _ := json.Marshal(data)
  844. var req *http.Request
  845. if miConfig.MdtrtareaAdmvs == "320921" {
  846. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  847. } else {
  848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  849. }
  850. resp, _ := client.Do(req)
  851. defer resp.Body.Close()
  852. body, ioErr := ioutil.ReadAll(resp.Body)
  853. if ioErr != nil {
  854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  856. }
  857. var respJSON map[string]interface{}
  858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. }
  862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  863. fmt.Println(respJSON)
  864. result, _ := json.Marshal(respJSON)
  865. fmt.Println(result)
  866. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  867. utils.ErrorLog("解析失败:%v", err)
  868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  869. }
  870. if result3265.Infcode != "0" {
  871. c.ServeSuccessJSON(map[string]interface{}{
  872. "failed_code": -10,
  873. "msg": result3265.ErrMsg,
  874. })
  875. return
  876. } else {
  877. c.ServeSuccessJSON(map[string]interface{}{
  878. "info": result3265.Output.Data,
  879. })
  880. return
  881. }
  882. }
  883. func (c *HisApiController) Get3268() {
  884. admin_user_id, _ := c.GetInt64("admin_user_id")
  885. startTime := c.GetString("start_time")
  886. endTime := c.GetString("end_time")
  887. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  889. times := strings.Split(startTime, "-")
  890. setl_mon := times[0] + times[1]
  891. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  892. var twos []models.FixMonRecDetailFileInTwo
  893. var funs []models.FundDetail
  894. for _, item := range datas {
  895. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  896. funs = append(funs, fun...)
  897. }
  898. var funInfos []models.Fund
  899. for _, item := range funs {
  900. var rf []models.FundInfo
  901. json.Unmarshal([]byte(item.SetlDetail), &rf)
  902. for _, subitem := range rf {
  903. var fund models.Fund
  904. fund.FundCode = subitem.FundPayType
  905. fund.FundName = subitem.FundPayTypeName
  906. fund.FundAmt = subitem.FundPayAmt
  907. fund.FundKey = item.FundKey
  908. fund.InsuAdmdvs = "555555"
  909. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  910. funInfos = append(funInfos, fund)
  911. }
  912. }
  913. for _, team := range datas {
  914. var two models.FixMonRecDetailFileInTwo
  915. two.SetlDate = time.Now().Format("2006-01-02")
  916. two.MedType = team.MedType
  917. two.Insutype = team.Insutype
  918. two.PsnType = team.PsnType
  919. two.MedType = team.MedType
  920. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  921. two.InsuAdmdvs = team.InsuAdmdvs
  922. two.PsnTime = team.PsnTime
  923. two.PsnCnt = team.PsnCnt
  924. two.FundKey = team.FundKey
  925. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  926. fps, _ := strconv.ParseFloat(team.Fund, 64)
  927. ia, _ := strconv.ParseFloat(team.Amt, 64)
  928. two.MedfeeSumAmt = ms
  929. two.InscpAmt = ia
  930. two.FundPaySumAmt = fps
  931. twos = append(twos, two)
  932. }
  933. var upld_btch string
  934. upld_btch = "0"
  935. var empty models.JSResultEmpty
  936. data := make(map[string]interface{})
  937. data["org_name"] = miConfig.OrgName
  938. data["doctor"] = curRoles.UserName
  939. data["doctor_name"] = curRoles.UserName
  940. data["fixmedins_code"] = miConfig.Code
  941. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  942. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  943. data["secret_key"] = miConfig.SecretKey
  944. data["url"] = miConfig.Url
  945. data["ak"] = miConfig.AccessKey
  946. data["cainfo"] = miConfig.Cainfo
  947. data["datas"] = twos
  948. data["fund"] = funInfos
  949. data["setl_mon"] = setl_mon
  950. month := time.Unix(1557042972, 0).Format("1")
  951. year := time.Now().Format("2006")
  952. month = time.Now().Format("01")
  953. day := time.Now().Format("02")
  954. hour := time.Now().Format("15")
  955. min := time.Now().Format("04")
  956. sec := time.Now().Format("05")
  957. fix_fill_date := year + month + day + hour + min + sec
  958. data["fix_fill_dept"] = miConfig.OrgName
  959. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  960. data["fix_fill_psn"] = curRoles.UserName
  961. data["fix_fill_date"] = fix_fill_date
  962. data["stmt_loc"] = "2"
  963. data["upld_btch"] = upld_btch
  964. client := &http.Client{}
  965. bytesData, _ := json.Marshal(data)
  966. var req *http.Request
  967. if miConfig.MdtrtareaAdmvs == "320921" {
  968. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  969. } else {
  970. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  971. }
  972. resp, _ := client.Do(req)
  973. defer resp.Body.Close()
  974. body, ioErr := ioutil.ReadAll(resp.Body)
  975. if ioErr != nil {
  976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. }
  979. var respJSON map[string]interface{}
  980. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  983. }
  984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  985. fmt.Println(respJSON)
  986. result, _ := json.Marshal(respJSON)
  987. fmt.Println(result)
  988. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  989. utils.ErrorLog("解析失败:%v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. }
  992. if empty.Infcode != "0" {
  993. c.ServeSuccessJSON(map[string]interface{}{
  994. "failed_code": -10,
  995. "msg": empty.ErrMsg,
  996. })
  997. return
  998. } else {
  999. c.ServeSuccessJSON(map[string]interface{}{
  1000. "msg": "上传成功",
  1001. })
  1002. return
  1003. }
  1004. }
  1005. func (c *HisApiController) Get3269() {
  1006. admin_user_id, _ := c.GetInt64("admin_user_id")
  1007. startTime := c.GetString("start_time")
  1008. //endTime, _ := c.GetString("end_time")
  1009. times := strings.Split(startTime, "-")
  1010. setl_mon := times[0] + times[1]
  1011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1013. var result3263 models.JSResult3263
  1014. data := make(map[string]interface{})
  1015. data["org_name"] = miConfig.OrgName
  1016. data["doctor"] = curRoles.UserName
  1017. data["doctor_name"] = curRoles.UserName
  1018. data["fixmedins_code"] = miConfig.Code
  1019. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1020. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1021. data["secret_key"] = miConfig.SecretKey
  1022. data["url"] = miConfig.Url
  1023. data["ak"] = miConfig.AccessKey
  1024. data["cainfo"] = miConfig.Cainfo
  1025. data["setl_mon"] = setl_mon
  1026. data["stmt_loc"] = "2"
  1027. client := &http.Client{}
  1028. bytesData, _ := json.Marshal(data)
  1029. var req *http.Request
  1030. if miConfig.MdtrtareaAdmvs == "320921" {
  1031. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1032. } else {
  1033. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1034. }
  1035. resp, _ := client.Do(req)
  1036. defer resp.Body.Close()
  1037. body, ioErr := ioutil.ReadAll(resp.Body)
  1038. if ioErr != nil {
  1039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1041. }
  1042. var respJSON map[string]interface{}
  1043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. }
  1047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1048. fmt.Println(respJSON)
  1049. result, _ := json.Marshal(respJSON)
  1050. fmt.Println(result)
  1051. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1052. utils.ErrorLog("解析失败:%v", err)
  1053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1054. }
  1055. if result3263.Infcode != "0" {
  1056. c.ServeSuccessJSON(map[string]interface{}{
  1057. "failed_code": -10,
  1058. "msg": result3263.ErrMsg,
  1059. })
  1060. return
  1061. } else {
  1062. c.ServeSuccessJSON(map[string]interface{}{
  1063. "msg": "上传成功",
  1064. })
  1065. return
  1066. }
  1067. }
  1068. func (c *HisApiController) Get3270() {
  1069. admin_user_id, _ := c.GetInt64("admin_user_id")
  1070. startTime := c.GetString("start_time")
  1071. //endTime, _ := c.GetString("end_time")
  1072. times := strings.Split(startTime, "-")
  1073. setl_mon := times[0] + times[1]
  1074. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1075. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1076. var result3263 models.JSResult3263
  1077. data2 := make(map[string]interface{})
  1078. data2["org_name"] = miConfig.OrgName
  1079. data2["doctor"] = curRoles.UserName
  1080. data2["doctor_name"] = curRoles.UserName
  1081. data2["fixmedins_code"] = miConfig.Code
  1082. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1083. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1084. data2["secret_key"] = miConfig.SecretKey
  1085. data2["url"] = miConfig.Url
  1086. data2["ak"] = miConfig.AccessKey
  1087. data2["cainfo"] = miConfig.Cainfo
  1088. data2["setl_mon"] = setl_mon
  1089. data2["stmt_loc"] = "2"
  1090. client2 := &http.Client{}
  1091. bytesData2, _ := json.Marshal(data2)
  1092. var req3263 *http.Request
  1093. if miConfig.MdtrtareaAdmvs == "320921" {
  1094. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1095. } else {
  1096. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1097. }
  1098. resp2, _ := client2.Do(req3263)
  1099. defer resp2.Body.Close()
  1100. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1101. if ioErr2 != nil {
  1102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. }
  1105. var respJSON3263 map[string]interface{}
  1106. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1109. }
  1110. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1111. fmt.Println(respJSON3263)
  1112. result2, _ := json.Marshal(respJSON3263)
  1113. fmt.Println(result2)
  1114. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1115. utils.ErrorLog("解析失败:%v", err)
  1116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1117. }
  1118. var ids []string
  1119. for _, item := range result3263.Output {
  1120. ids = append(ids, item.SolidifyID)
  1121. }
  1122. var result3264 models.JSResult3264
  1123. data := make(map[string]interface{})
  1124. data["org_name"] = miConfig.OrgName
  1125. data["doctor"] = curRoles.UserName
  1126. data["doctor_name"] = curRoles.UserName
  1127. data["fixmedins_code"] = miConfig.Code
  1128. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1129. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1130. data["secret_key"] = miConfig.SecretKey
  1131. data["url"] = miConfig.Url
  1132. data["ak"] = miConfig.AccessKey
  1133. data["cainfo"] = miConfig.Cainfo
  1134. data["setl_mon"] = setl_mon
  1135. data["stmt_loc"] = "2"
  1136. data["solidify_id"] = ids
  1137. client := &http.Client{}
  1138. bytesData, _ := json.Marshal(data)
  1139. var req *http.Request
  1140. if miConfig.MdtrtareaAdmvs == "320921" {
  1141. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1142. } else {
  1143. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1144. }
  1145. resp, _ := client.Do(req)
  1146. defer resp.Body.Close()
  1147. body, ioErr := ioutil.ReadAll(resp.Body)
  1148. if ioErr != nil {
  1149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. }
  1152. var respJSON map[string]interface{}
  1153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1156. }
  1157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1158. fmt.Println(respJSON)
  1159. result, _ := json.Marshal(respJSON)
  1160. fmt.Println(result)
  1161. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1162. utils.ErrorLog("解析失败:%v", err)
  1163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1164. }
  1165. if result3264.Infcode != "0" {
  1166. c.ServeSuccessJSON(map[string]interface{}{
  1167. "failed_code": -10,
  1168. "msg": result3264.ErrMsg,
  1169. })
  1170. return
  1171. } else {
  1172. c.ServeSuccessJSON(map[string]interface{}{
  1173. "info": result3264.Output,
  1174. })
  1175. return
  1176. }
  1177. }
  1178. func (c *HisApiController) Get3271() {
  1179. admin_user_id, _ := c.GetInt64("admin_user_id")
  1180. startTime := c.GetString("start_time")
  1181. //endTime, _ := c.GetString("end_time")
  1182. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1184. times := strings.Split(startTime, "-")
  1185. setl_mon := times[0] + times[1]
  1186. //var empty models.JSResultEmpty
  1187. var result3265 models.JSResult3264
  1188. var result3263 models.JSResult3263
  1189. data2 := make(map[string]interface{})
  1190. data2["org_name"] = miConfig.OrgName
  1191. data2["doctor"] = curRoles.UserName
  1192. data2["doctor_name"] = curRoles.UserName
  1193. data2["fixmedins_code"] = miConfig.Code
  1194. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1195. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1196. data2["secret_key"] = miConfig.SecretKey
  1197. data2["url"] = miConfig.Url
  1198. data2["ak"] = miConfig.AccessKey
  1199. data2["cainfo"] = miConfig.Cainfo
  1200. data2["setl_mon"] = setl_mon
  1201. data2["stmt_loc"] = "2"
  1202. client2 := &http.Client{}
  1203. bytesData2, _ := json.Marshal(data2)
  1204. var req3263 *http.Request
  1205. if miConfig.MdtrtareaAdmvs == "320921" {
  1206. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1207. } else {
  1208. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1209. }
  1210. resp2, _ := client2.Do(req3263)
  1211. defer resp2.Body.Close()
  1212. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1213. if ioErr2 != nil {
  1214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1216. }
  1217. var respJSON3263 map[string]interface{}
  1218. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1221. }
  1222. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1223. fmt.Println(respJSON3263)
  1224. result2, _ := json.Marshal(respJSON3263)
  1225. fmt.Println(result2)
  1226. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1227. utils.ErrorLog("解析失败:%v", err)
  1228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1229. }
  1230. var ids []string
  1231. for _, item := range result3263.Output {
  1232. ids = append(ids, item.SolidifyID)
  1233. }
  1234. data := make(map[string]interface{})
  1235. data["org_name"] = miConfig.OrgName
  1236. data["doctor"] = curRoles.UserName
  1237. data["doctor_name"] = curRoles.UserName
  1238. data["fixmedins_code"] = miConfig.Code
  1239. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1241. data["secret_key"] = miConfig.SecretKey
  1242. data["url"] = miConfig.Url
  1243. data["ak"] = miConfig.AccessKey
  1244. data["cainfo"] = miConfig.Cainfo
  1245. data["setl_mon"] = setl_mon
  1246. data["solidify_id"] = ids
  1247. month := time.Unix(1557042972, 0).Format("1")
  1248. year := time.Now().Format("2006")
  1249. month = time.Now().Format("01")
  1250. day := time.Now().Format("02")
  1251. hour := time.Now().Format("15")
  1252. min := time.Now().Format("04")
  1253. sec := time.Now().Format("05")
  1254. fix_fill_date := year + month + day + hour + min + sec
  1255. data["fix_fill_dept"] = miConfig.OrgName
  1256. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1257. data["fix_fill_psn"] = curRoles.UserName
  1258. data["fix_fill_date"] = fix_fill_date
  1259. data["stmt_loc"] = "2"
  1260. client := &http.Client{}
  1261. bytesData, _ := json.Marshal(data)
  1262. var req *http.Request
  1263. if miConfig.MdtrtareaAdmvs == "320921" {
  1264. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1265. } else {
  1266. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1267. }
  1268. resp, _ := client.Do(req)
  1269. defer resp.Body.Close()
  1270. body, ioErr := ioutil.ReadAll(resp.Body)
  1271. if ioErr != nil {
  1272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. }
  1275. var respJSON map[string]interface{}
  1276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. }
  1280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1281. fmt.Println(respJSON)
  1282. result, _ := json.Marshal(respJSON)
  1283. fmt.Println(result)
  1284. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1285. utils.ErrorLog("解析失败:%v", err)
  1286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1287. }
  1288. if result3265.Infcode != "0" {
  1289. c.ServeSuccessJSON(map[string]interface{}{
  1290. "failed_code": -10,
  1291. "msg": result3265.ErrMsg,
  1292. })
  1293. return
  1294. } else {
  1295. c.ServeSuccessJSON(map[string]interface{}{
  1296. "info": result3265.Output.Data,
  1297. })
  1298. return
  1299. }
  1300. }
  1301. func (c *HisApiController) Get3272() {
  1302. admin_user_id, _ := c.GetInt64("admin_user_id")
  1303. startTime := c.GetString("start_time")
  1304. //endTime, _ := c.GetString("end_time")
  1305. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1306. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1307. times := strings.Split(startTime, "-")
  1308. setl_mon := times[0] + times[1]
  1309. var upld_btch string
  1310. //var empty models.JSResultEmpty
  1311. var result3265 models.JSResult3264
  1312. data := make(map[string]interface{})
  1313. data["org_name"] = miConfig.OrgName
  1314. data["doctor"] = curRoles.UserName
  1315. data["doctor_name"] = curRoles.UserName
  1316. data["fixmedins_code"] = miConfig.Code
  1317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1319. data["secret_key"] = miConfig.SecretKey
  1320. data["url"] = miConfig.Url
  1321. data["ak"] = miConfig.AccessKey
  1322. data["cainfo"] = miConfig.Cainfo
  1323. data["setl_mon"] = setl_mon
  1324. month := time.Unix(1557042972, 0).Format("1")
  1325. year := time.Now().Format("2006")
  1326. month = time.Now().Format("01")
  1327. day := time.Now().Format("02")
  1328. hour := time.Now().Format("15")
  1329. min := time.Now().Format("04")
  1330. sec := time.Now().Format("05")
  1331. fix_fill_date := year + month + day + hour + min + sec
  1332. data["fix_fill_dept"] = miConfig.OrgName
  1333. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1334. data["fix_fill_psn"] = curRoles.UserName
  1335. data["fix_fill_date"] = fix_fill_date
  1336. data["stmt_loc"] = "2"
  1337. data["upld_btch"] = upld_btch
  1338. client := &http.Client{}
  1339. bytesData, _ := json.Marshal(data)
  1340. var req *http.Request
  1341. if miConfig.MdtrtareaAdmvs == "320921" {
  1342. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1343. } else {
  1344. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1345. }
  1346. resp, _ := client.Do(req)
  1347. defer resp.Body.Close()
  1348. body, ioErr := ioutil.ReadAll(resp.Body)
  1349. if ioErr != nil {
  1350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. }
  1353. var respJSON map[string]interface{}
  1354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. }
  1358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1359. fmt.Println(respJSON)
  1360. result, _ := json.Marshal(respJSON)
  1361. fmt.Println(result)
  1362. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1363. utils.ErrorLog("解析失败:%v", err)
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1365. }
  1366. if result3265.Infcode != "0" {
  1367. c.ServeSuccessJSON(map[string]interface{}{
  1368. "failed_code": -10,
  1369. "msg": result3265.ErrMsg,
  1370. })
  1371. return
  1372. } else {
  1373. c.ServeSuccessJSON(map[string]interface{}{
  1374. "info": result3265.Output,
  1375. })
  1376. return
  1377. }
  1378. }
  1379. func (c *HisApiController) Get3273() {
  1380. admin_user_id, _ := c.GetInt64("admin_user_id")
  1381. startTime := c.GetString("start_time")
  1382. //endTime, _ := c.GetString("end_time")
  1383. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1384. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1385. times := strings.Split(startTime, "-")
  1386. setl_mon := times[0] + times[1]
  1387. var result3265 models.JSResult3264
  1388. data := make(map[string]interface{})
  1389. data["org_name"] = miConfig.OrgName
  1390. data["doctor"] = curRoles.UserName
  1391. data["doctor_name"] = curRoles.UserName
  1392. data["fixmedins_code"] = miConfig.Code
  1393. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1394. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1395. data["secret_key"] = miConfig.SecretKey
  1396. data["url"] = miConfig.Url
  1397. data["ak"] = miConfig.AccessKey
  1398. data["cainfo"] = miConfig.Cainfo
  1399. data["setl_mon"] = setl_mon
  1400. data["stmt_loc"] = "2"
  1401. client := &http.Client{}
  1402. bytesData, _ := json.Marshal(data)
  1403. var req *http.Request
  1404. if miConfig.MdtrtareaAdmvs == "320921" {
  1405. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1406. } else {
  1407. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1408. }
  1409. resp, _ := client.Do(req)
  1410. defer resp.Body.Close()
  1411. body, ioErr := ioutil.ReadAll(resp.Body)
  1412. if ioErr != nil {
  1413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. }
  1416. var respJSON map[string]interface{}
  1417. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. }
  1421. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1422. fmt.Println(respJSON)
  1423. result, _ := json.Marshal(respJSON)
  1424. fmt.Println(result)
  1425. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1426. utils.ErrorLog("解析失败:%v", err)
  1427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1428. }
  1429. if result3265.Infcode != "0" {
  1430. c.ServeSuccessJSON(map[string]interface{}{
  1431. "failed_code": -10,
  1432. "msg": result3265.ErrMsg,
  1433. })
  1434. return
  1435. } else {
  1436. c.ServeSuccessJSON(map[string]interface{}{
  1437. "info": result3265.Output.Data,
  1438. })
  1439. return
  1440. }
  1441. }
  1442. func (c *HisApiController) Get3274() {
  1443. //if miConfig.MdtrtareaAdmvs == "320921" {
  1444. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1445. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1446. // "&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
  1447. //
  1448. //} else {
  1449. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1450. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1451. // "&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
  1452. //
  1453. //}
  1454. }
  1455. func (c *HisApiController) Get3275() {
  1456. //if miConfig.MdtrtareaAdmvs == "320921" {
  1457. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1458. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1459. // "&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
  1460. //
  1461. //} else {
  1462. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1463. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1464. // "&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
  1465. //
  1466. //}
  1467. }
  1468. func (c *HisApiController) Get3276() {
  1469. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1470. //month := c.GetString("month")
  1471. //
  1472. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1473. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1474. //var api string
  1475. //var res Result5301
  1476. //
  1477. //if miConfig.MdtrtareaAdmvs == "320921" {
  1478. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1479. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1480. //} else {
  1481. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1482. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1483. //}
  1484. //
  1485. //resp, requestErr := http.Get(api)
  1486. //if requestErr != nil {
  1487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. // return
  1489. //}
  1490. //
  1491. //body, ioErr := ioutil.ReadAll(resp.Body)
  1492. //if ioErr != nil {
  1493. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1495. // return
  1496. //}
  1497. //var respJSON map[string]interface{}
  1498. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1499. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. // return
  1502. //}
  1503. //
  1504. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1505. //result, _ := json.Marshal(respJSON)
  1506. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1507. // utils.ErrorLog("解析失败:%v", err)
  1508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1509. // return
  1510. //}
  1511. }
  1512. func (c *HisApiController) Get3277() {
  1513. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1514. //month := c.GetString("month")
  1515. //
  1516. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1517. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1518. //var api string
  1519. //var res Result5301
  1520. //
  1521. //if miConfig.MdtrtareaAdmvs == "320921" {
  1522. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1523. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1524. //} else {
  1525. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1526. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1527. //}
  1528. //
  1529. //resp, requestErr := http.Get(api)
  1530. //if requestErr != nil {
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //
  1535. //body, ioErr := ioutil.ReadAll(resp.Body)
  1536. //if ioErr != nil {
  1537. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. //var respJSON map[string]interface{}
  1542. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1543. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. // return
  1546. //}
  1547. //
  1548. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1549. //result, _ := json.Marshal(respJSON)
  1550. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1551. // utils.ErrorLog("解析失败:%v", err)
  1552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. // return
  1554. //}
  1555. }
  1556. func (c *HisApiController) GetCFYLJG001() {
  1557. admin_user_id, _ := c.GetInt64("admin_user_id")
  1558. patient_id, _ := c.GetInt64("patient_id")
  1559. his_patient_id, _ := c.GetInt64("his_patient_id")
  1560. record_time := c.GetString("record_time")
  1561. admin_user_id = 3626
  1562. patient_id = 19424
  1563. his_patient_id = 238932
  1564. record_time = "2023-07-03"
  1565. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1566. psn, _ := service.GetPsnByPatientId(patient_id)
  1567. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1568. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1569. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1570. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1571. var cFYLJG001 models.CFYLJG001
  1572. timeLayout := "2006-01-02"
  1573. loc, _ := time.LoadLocation("Local")
  1574. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1575. if err != nil {
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1577. return
  1578. }
  1579. recordDateTime := theTime.Unix()
  1580. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1581. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1582. for _, item := range prescriptions {
  1583. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  1584. if his.IdCardType == 1 {
  1585. bas := strings.Split(psn.CardInfo, "|")
  1586. basNumber := bas[1]
  1587. fmt.Println(basNumber)
  1588. card_sn := bas[3]
  1589. card_no := bas[2]
  1590. cFYLJG001.MdtrtCertType = "03"
  1591. cFYLJG001.CardSn = card_sn
  1592. cFYLJG001.MdtrtCertNo = card_no
  1593. cFYLJG001.EcToken = ""
  1594. cFYLJG001.AuthNo = ""
  1595. } else if his.IdCardType == 2 {
  1596. cFYLJG001.MdtrtCertType = "02"
  1597. cFYLJG001.CardSn = ""
  1598. cFYLJG001.MdtrtCertNo = his.IdCardNo
  1599. cFYLJG001.EcToken = ""
  1600. cFYLJG001.AuthNo = ""
  1601. } else if his.IdCardType == 4 {
  1602. cFYLJG001.MdtrtCertType = "01"
  1603. cFYLJG001.CardSn = ""
  1604. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  1605. cFYLJG001.EcToken = psn.VerifyNumber
  1606. cFYLJG001.AuthNo = ""
  1607. }
  1608. cFYLJG001.BizTypeCode = "01"
  1609. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  1610. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  1611. cFYLJG001.RxTypeCode = "1"
  1612. tempTime := time.Unix(item.PreTime, 0)
  1613. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1614. cFYLJG001.PrscTime = timeFormatOne
  1615. var count float64
  1616. if item.Type == 1 {
  1617. for _, sumItem := range item.HisDoctorAdviceInfo {
  1618. count = count + sumItem.PrescribingNumber
  1619. }
  1620. }
  1621. cFYLJG001.RxDrugCnt = count
  1622. cFYLJG001.ValiDays = "5"
  1623. ts := time.Unix(item.PreTime, 0)
  1624. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  1625. tempTime3 := time.Unix(record_time2, 0)
  1626. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  1627. cFYLJG001.ValiEndTime = timeFormat3
  1628. cFYLJG001.RxCotnFlag = "0"
  1629. for _, subItem := range item.HisDoctorAdviceInfo {
  1630. var drug models.RxDrug
  1631. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1632. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1633. drug.RxItemTypeCode = "11"
  1634. drug.DrugDosform = "乳膏剂" //TODO
  1635. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  1636. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  1637. }
  1638. drug.MedcWayDscr = subItem.DeliveryWay
  1639. tempTime2 := time.Unix(subItem.StartTime, 0)
  1640. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1641. drug.MedcBegntime = timeFormatTwo
  1642. if subItem.Day > 0 {
  1643. ts := time.Unix(subItem.StartTime, 0)
  1644. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  1645. tempTime4 := time.Unix(record_time, 0)
  1646. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  1647. drug.MedcEndtime = timeFormat5
  1648. } else {
  1649. tempTime2 := time.Unix(subItem.StartTime, 0)
  1650. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  1651. drug.MedcEndtime = timeFormatTwo
  1652. }
  1653. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  1654. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  1655. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  1656. drug.DrugCnt = subItem.PrescribingNumber
  1657. drug.DrugDosunt = subItem.PrescribingNumberUnit
  1658. drug.DrugGenname = subItem.AdviceName
  1659. drug.MedcWayCodg = subItem.DeliveryWay
  1660. //drug.DrugTotlcnt = subItem.PrescribingNumber
  1661. drug.SinDoscnt = subItem.SingleDose
  1662. drug.SinDosunt = subItem.SingleDoseUnit
  1663. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  1664. drug.UsedFrquName = subItem.ExecutionFrequency
  1665. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1666. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  1667. drug.HospApprFlag = "1"
  1668. cFYLJG001.List = append(cFYLJG001.List, drug)
  1669. }
  1670. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  1671. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  1672. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  1673. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  1674. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  1675. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  1676. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  1677. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  1678. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  1679. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  1680. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1681. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  1682. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  1683. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  1684. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1685. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  1686. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  1687. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  1688. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  1689. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  1690. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  1691. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  1692. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  1693. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  1694. tempTime2 := time.Now().Unix()
  1695. tempTime6 := time.Unix(tempTime2, 0)
  1696. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  1697. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  1698. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  1699. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  1700. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  1701. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  1702. memo := make(map[string]interface{})
  1703. memo["insutype"] = his.Insutype
  1704. bytesData, _ := json.Marshal(memo)
  1705. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  1706. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  1707. var config []*models.HisXtDiagnoseConfig
  1708. for _, item := range diagnosis_ids {
  1709. id, _ := strconv.ParseInt(item, 10, 64)
  1710. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1711. config = append(config, &diagnosisConfig)
  1712. }
  1713. for index, subitem := range config {
  1714. if index == 0 {
  1715. var dia models.DiseInfo
  1716. dia.DiagType = "1"
  1717. dia.MaindiagFlag = "1"
  1718. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1719. dia.DiagCode = subitem.CountryCode
  1720. dia.DiagName = subitem.ClassName
  1721. dia.DiagDept = "肾内科"
  1722. dia.DiagDrNo = doctor.DoctorNumber
  1723. dia.DiagDrName = doctor.UserName
  1724. tempTime3 := time.Unix(item.PreTime, 0)
  1725. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1726. dia.DiagTime = timeFormatTwo
  1727. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1728. } else {
  1729. var dia models.DiseInfo
  1730. dia.DiagType = "1"
  1731. dia.MaindiagFlag = "0"
  1732. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1733. dia.DiagCode = subitem.CountryCode
  1734. dia.DiagName = subitem.ClassName
  1735. dia.DiagDept = "肾内科"
  1736. dia.DiagDrNo = doctor.DoctorNumber
  1737. dia.DiagDrName = doctor.UserName
  1738. tempTime3 := time.Unix(item.PreTime, 0)
  1739. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1740. dia.DiagTime = timeFormatTwo
  1741. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1742. }
  1743. }
  1744. fmt.Println(cFYLJG001)
  1745. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  1746. }
  1747. }
  1748. func (c *HisApiController) GetCFYLJG002() {
  1749. admin_user_id, _ := c.GetInt64("admin_user_id")
  1750. id, _ := c.GetInt64("id")
  1751. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1752. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1753. flow, _ := service.Getflow(id)
  1754. his, _ := service.GetHisPatientByNumber(flow.MID)
  1755. inputData := make(map[string]interface{})
  1756. inputData["rxtracecode"] = flow.RxTraceCode
  1757. inputData["hirxno"] = flow.HiRxno
  1758. inputData["mdtrtid"] = flow.MID
  1759. inputData["patnname"] = his.PsnName
  1760. inputData["psncerttype"] = his.PsnCertType
  1761. inputData["certno"] = his.Certno
  1762. inputData["fixmedinsname"] = miConfig.OrgName
  1763. inputData["fixmedinscode"] = miConfig.Code
  1764. inputData["drcode"] = ""
  1765. inputData["prscdrname"] = ""
  1766. inputData["phardeptname"] = ""
  1767. inputData["phardeptcode"] = ""
  1768. inputData["pharprofttlcodg"] = ""
  1769. inputData["pharprofttlname"] = ""
  1770. inputData["pharcode"] = ""
  1771. inputData["rxfrquname"] = ""
  1772. inputData["pharcerttype"] = ""
  1773. inputData["pharcertno"] = ""
  1774. inputData["pharname"] = ""
  1775. inputData["pharpraccertno"] = ""
  1776. inputData["pharchktime"] = ""
  1777. bytesData, _ := json.Marshal(inputData)
  1778. fmt.Println(bytesData)
  1779. //// 使用 SM3 计算 JSON 数据的哈希值
  1780. //hash := sm3.New()
  1781. //hash.Write(bytesData)
  1782. //hashValue := hash.Sum(nil)
  1783. //
  1784. //// 加载 SM2 私钥
  1785. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  1786. //if err != nil {
  1787. // fmt.Println("Failed to read private key file:", err)
  1788. // return
  1789. //}
  1790. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  1791. //if err != nil {
  1792. // fmt.Println("Failed to parse private key:", err)
  1793. // return
  1794. //}
  1795. //
  1796. //// 使用私钥对哈希值进行签名
  1797. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  1798. //if err != nil {
  1799. // fmt.Println("Failed to sign data:", err)
  1800. // return
  1801. //}
  1802. //signature, err := syntax.EncodeSM2Signature(r, s)
  1803. //if err != nil {
  1804. // fmt.Println("Failed to encode signature:", err)
  1805. // return
  1806. //}
  1807. //
  1808. //// 构建 CMS/PKCS#7 Detached 数据结构
  1809. //// 这里只包含签名值和原始数据
  1810. //signedData := &pkix.ContentInfo{
  1811. // ContentType: pkix.SignedDataOID,
  1812. // Content: &pkix.SignedData{
  1813. // Version: 3,
  1814. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  1815. // EncapContentInfo: pkix.EncapContentInfo{
  1816. // EContentType: pkix.DataOID,
  1817. // EContent: jsonBytes,
  1818. // },
  1819. // Certificates: []pkix.Certificate{},
  1820. // CRLs: []pkix.CertificateList{},
  1821. // SignerInfos: []pkix.SignerInfo{},
  1822. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  1823. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  1824. // },
  1825. // EncryptedDigest: signature,
  1826. // },
  1827. //}
  1828. //
  1829. //// 使用 DER 编码进行序列化
  1830. //derBytes, err := syntax.Marshal(signedData)
  1831. //if err != nil {
  1832. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  1833. // return
  1834. //}
  1835. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  1836. }
  1837. func (c *HisApiController) GetCFYLJG003() {
  1838. admin_user_id, _ := c.GetInt64("admin_user_id")
  1839. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1840. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1841. var cFYLJG003 models.CFYLJG003
  1842. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  1843. }
  1844. func (c *HisApiController) GetCFYLJG004() {
  1845. admin_user_id, _ := c.GetInt64("admin_user_id")
  1846. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1847. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1848. var cFYLJG004 models.CFYLJG004
  1849. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  1850. }
  1851. func (c *HisApiController) GetCFYLJG005() {
  1852. admin_user_id, _ := c.GetInt64("admin_user_id")
  1853. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1854. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1855. var cFYLJG005 models.CFYLJG005
  1856. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  1857. }
  1858. func (c *HisApiController) GetCFYLJG006() {
  1859. admin_user_id, _ := c.GetInt64("admin_user_id")
  1860. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1861. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1862. var cFYLJG006 models.CFYLJG006
  1863. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  1864. }
  1865. func (c *HisApiController) GetCFYLJG007() {
  1866. admin_user_id, _ := c.GetInt64("admin_user_id")
  1867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1869. var cFYLJG007 models.CFYLJG007
  1870. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  1871. }
  1872. func (c *HisApiController) GetBL4201A() {
  1873. order_id, _ := c.GetInt64("order_id")
  1874. admin_user_id, _ := c.GetInt64("admin_user_id")
  1875. order, _ := service.GetHisOrderByIDTwo(order_id)
  1876. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1877. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  1878. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  1879. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1880. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1881. department, _ := service.GetDepartMentDetail(his.Departments)
  1882. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1883. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1884. if order.ID == 0 {
  1885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1886. return
  1887. }
  1888. var struct4201A models.Struct4201A
  1889. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1890. for _, items := range order_info {
  1891. memo := make(map[string]interface{})
  1892. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1893. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1894. fsiOPFLD.MedType = "14"
  1895. fsiOPFLD.BkkpSn = items.FeedetlSn
  1896. fsiOPFLD.FixmedinsCode = miConfig.Code
  1897. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1898. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1899. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1900. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1901. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1902. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1903. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1904. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1905. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1906. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1907. fsiOPFLD.BilgDeptName = department.Name
  1908. fsiOPFLD.BilgDeptCodg = department.Number
  1909. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1910. fsiOPFLD.BilgDrName = doctor.UserName
  1911. fsiOPFLD.MedChrgitmType = "09"
  1912. memo["hosp_appr_flag"] = "1"
  1913. memo["invoice_no"] = order.MdtrtId
  1914. memo["memo"] = "自费"
  1915. bytesData, _ := json.Marshal(memo)
  1916. fsiOPFLD.Memo = string(bytesData)
  1917. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1918. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1919. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1920. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1921. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1922. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1923. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1924. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1925. fsiOPFLD.BilgDeptName = department.Name
  1926. fsiOPFLD.BilgDeptCodg = department.Number
  1927. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1928. fsiOPFLD.BilgDrName = doctor.UserName
  1929. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1930. case 0:
  1931. break
  1932. case 1:
  1933. fsiOPFLD.MedChrgitmType = "14"
  1934. break
  1935. case 2:
  1936. fsiOPFLD.MedChrgitmType = "05"
  1937. break
  1938. case 3:
  1939. fsiOPFLD.MedChrgitmType = "03"
  1940. break
  1941. case 4:
  1942. fsiOPFLD.MedChrgitmType = "03"
  1943. break
  1944. case 5:
  1945. fsiOPFLD.MedChrgitmType = "08"
  1946. break
  1947. case 6:
  1948. fsiOPFLD.MedChrgitmType = "14"
  1949. break
  1950. case 7:
  1951. fsiOPFLD.MedChrgitmType = "14"
  1952. break
  1953. case 8:
  1954. fsiOPFLD.MedChrgitmType = "03"
  1955. break
  1956. case 9:
  1957. fsiOPFLD.MedChrgitmType = "14"
  1958. break
  1959. case 10:
  1960. fsiOPFLD.MedChrgitmType = "14"
  1961. break
  1962. case 11:
  1963. fsiOPFLD.MedChrgitmType = "06"
  1964. break
  1965. case 12:
  1966. fsiOPFLD.MedChrgitmType = "12"
  1967. break
  1968. case 13:
  1969. fsiOPFLD.MedChrgitmType = "01"
  1970. break
  1971. case 14:
  1972. fsiOPFLD.MedChrgitmType = "04"
  1973. break
  1974. case 15:
  1975. fsiOPFLD.MedChrgitmType = "14"
  1976. break
  1977. }
  1978. memo["hosp_appr_flag"] = "1"
  1979. memo["invoice_no"] = order.MdtrtId
  1980. memo["memo"] = "自费"
  1981. bytesData, _ := json.Marshal(memo)
  1982. fsiOPFLD.Memo = string(bytesData)
  1983. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1984. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1985. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1986. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1987. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1988. fsiOPFLD.BilgDeptName = department.Name
  1989. fsiOPFLD.BilgDeptCodg = department.Number
  1990. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1991. fsiOPFLD.BilgDrName = doctor.UserName
  1992. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1993. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1994. fsiOPFLD.MedChrgitmType = "08"
  1995. memo["hosp_appr_flag"] = "1"
  1996. memo["invoice_no"] = order.MdtrtId
  1997. memo["memo"] = "自费"
  1998. bytesData, _ := json.Marshal(memo)
  1999. fsiOPFLD.Memo = string(bytesData)
  2000. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2001. }
  2002. }
  2003. }
  2004. for _, items := range order_info_two {
  2005. memo := make(map[string]interface{})
  2006. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2007. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2008. fsiOPFLD.MedType = "14"
  2009. fsiOPFLD.BkkpSn = items.FeedetlSn
  2010. fsiOPFLD.FixmedinsCode = miConfig.Code
  2011. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2012. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2013. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2014. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2015. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2016. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2017. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2018. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2019. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2020. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2021. fsiOPFLD.BilgDeptName = department.Name
  2022. fsiOPFLD.BilgDeptCodg = department.Number
  2023. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2024. fsiOPFLD.BilgDrName = doctor.UserName
  2025. fsiOPFLD.MedChrgitmType = "09"
  2026. memo["hosp_appr_flag"] = "1"
  2027. memo["invoice_no"] = order.MdtrtId
  2028. memo["memo"] = "自费"
  2029. bytesData, _ := json.Marshal(memo)
  2030. fsiOPFLD.Memo = string(bytesData)
  2031. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2032. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2033. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2034. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2035. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2036. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2037. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2038. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2039. fsiOPFLD.BilgDeptName = department.Name
  2040. fsiOPFLD.BilgDeptCodg = department.Number
  2041. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2042. fsiOPFLD.BilgDrName = doctor.UserName
  2043. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2044. case 0:
  2045. break
  2046. case 1:
  2047. fsiOPFLD.MedChrgitmType = "14"
  2048. break
  2049. case 2:
  2050. fsiOPFLD.MedChrgitmType = "05"
  2051. break
  2052. case 3:
  2053. fsiOPFLD.MedChrgitmType = "03"
  2054. break
  2055. case 4:
  2056. fsiOPFLD.MedChrgitmType = "03"
  2057. break
  2058. case 5:
  2059. fsiOPFLD.MedChrgitmType = "08"
  2060. break
  2061. case 6:
  2062. fsiOPFLD.MedChrgitmType = "14"
  2063. break
  2064. case 7:
  2065. fsiOPFLD.MedChrgitmType = "14"
  2066. break
  2067. case 8:
  2068. fsiOPFLD.MedChrgitmType = "03"
  2069. break
  2070. case 9:
  2071. fsiOPFLD.MedChrgitmType = "14"
  2072. break
  2073. case 10:
  2074. fsiOPFLD.MedChrgitmType = "14"
  2075. break
  2076. case 11:
  2077. fsiOPFLD.MedChrgitmType = "06"
  2078. break
  2079. case 12:
  2080. fsiOPFLD.MedChrgitmType = "12"
  2081. break
  2082. case 13:
  2083. fsiOPFLD.MedChrgitmType = "01"
  2084. break
  2085. case 14:
  2086. fsiOPFLD.MedChrgitmType = "04"
  2087. break
  2088. case 15:
  2089. fsiOPFLD.MedChrgitmType = "14"
  2090. break
  2091. }
  2092. memo["hosp_appr_flag"] = "1"
  2093. memo["invoice_no"] = order.MdtrtId
  2094. memo["memo"] = "自费"
  2095. bytesData, _ := json.Marshal(memo)
  2096. fsiOPFLD.Memo = string(bytesData)
  2097. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2098. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2099. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2100. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2101. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2102. fsiOPFLD.BilgDeptName = department.Name
  2103. fsiOPFLD.BilgDeptCodg = department.Number
  2104. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2105. fsiOPFLD.BilgDrName = doctor.UserName
  2106. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2107. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2108. fsiOPFLD.MedChrgitmType = "08"
  2109. memo["hosp_appr_flag"] = "1"
  2110. memo["invoice_no"] = order.MdtrtId
  2111. memo["memo"] = "自费"
  2112. bytesData, _ := json.Marshal(memo)
  2113. fsiOPFLD.Memo = string(bytesData)
  2114. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2115. }
  2116. }
  2117. }
  2118. fmt.Println(fsiOPFLDs)
  2119. struct4201A.Fopfd = fsiOPFLDs
  2120. fmt.Println(struct4201A.Fopfd)
  2121. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2122. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2123. var res2 ResultSix
  2124. var respJSON2 map[string]interface{}
  2125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2128. return
  2129. }
  2130. userJSONBytes2, _ := json.Marshal(respJSON2)
  2131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2132. utils.ErrorLog("解析失败:%v", err)
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. return
  2135. }
  2136. if res2.Infcode != 0 {
  2137. c.ServeSuccessJSON(map[string]interface{}{
  2138. "failed_code": -10,
  2139. "msg": res2.ErrMsg,
  2140. })
  2141. return
  2142. } else {
  2143. order.IsUploadOrderInfo = 1
  2144. service.UpdateOrder(order)
  2145. c.ServeSuccessJSON(map[string]interface{}{
  2146. "msg": "上传成功",
  2147. })
  2148. }
  2149. }
  2150. func (c *HisApiController) Get2505() {
  2151. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  2152. 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")
  2153. }
  2154. func (c *HisApiController) Get4201A() {
  2155. order_id, _ := c.GetInt64("order_id")
  2156. admin_user_id, _ := c.GetInt64("admin_user_id")
  2157. order, _ := service.GetHisOrderByIDTwo(order_id)
  2158. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2159. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2160. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2161. //order_info = append(order_info, order_info_two...)
  2162. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2164. department, _ := service.GetDepartMentDetail(his.Departments)
  2165. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2166. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2167. if order.ID == 0 {
  2168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2169. return
  2170. }
  2171. var struct4201A models.Struct4201A
  2172. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2173. for _, items := range order_info {
  2174. memo := make(map[string]interface{})
  2175. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2176. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2177. fsiOPFLD.MedType = "14"
  2178. fsiOPFLD.BkkpSn = items.FeedetlSn
  2179. fsiOPFLD.FixmedinsCode = miConfig.Code
  2180. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2181. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2182. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2183. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2184. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2185. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2186. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2187. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2188. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2189. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2190. fsiOPFLD.BilgDeptName = department.Name
  2191. fsiOPFLD.BilgDeptCodg = department.Number
  2192. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2193. fsiOPFLD.BilgDrName = doctor.UserName
  2194. fsiOPFLD.MedChrgitmType = "09"
  2195. memo["hosp_appr_flag"] = "1"
  2196. memo["invoice_no"] = order.MdtrtId
  2197. memo["memo"] = "自费"
  2198. bytesData, _ := json.Marshal(memo)
  2199. fsiOPFLD.Memo = string(bytesData)
  2200. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2201. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2202. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2203. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2204. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2205. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2206. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2207. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2208. fsiOPFLD.BilgDeptName = department.Name
  2209. fsiOPFLD.BilgDeptCodg = department.Number
  2210. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2211. fsiOPFLD.BilgDrName = doctor.UserName
  2212. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2213. case 0:
  2214. break
  2215. case 1:
  2216. fsiOPFLD.MedChrgitmType = "14"
  2217. break
  2218. case 2:
  2219. fsiOPFLD.MedChrgitmType = "05"
  2220. break
  2221. case 3:
  2222. fsiOPFLD.MedChrgitmType = "03"
  2223. break
  2224. case 4:
  2225. fsiOPFLD.MedChrgitmType = "03"
  2226. break
  2227. case 5:
  2228. fsiOPFLD.MedChrgitmType = "08"
  2229. break
  2230. case 6:
  2231. fsiOPFLD.MedChrgitmType = "14"
  2232. break
  2233. case 7:
  2234. fsiOPFLD.MedChrgitmType = "14"
  2235. break
  2236. case 8:
  2237. fsiOPFLD.MedChrgitmType = "03"
  2238. break
  2239. case 9:
  2240. fsiOPFLD.MedChrgitmType = "14"
  2241. break
  2242. case 10:
  2243. fsiOPFLD.MedChrgitmType = "14"
  2244. break
  2245. case 11:
  2246. fsiOPFLD.MedChrgitmType = "06"
  2247. break
  2248. case 12:
  2249. fsiOPFLD.MedChrgitmType = "12"
  2250. break
  2251. case 13:
  2252. fsiOPFLD.MedChrgitmType = "01"
  2253. break
  2254. case 14:
  2255. fsiOPFLD.MedChrgitmType = "04"
  2256. break
  2257. case 15:
  2258. fsiOPFLD.MedChrgitmType = "14"
  2259. break
  2260. }
  2261. memo["hosp_appr_flag"] = "1"
  2262. memo["invoice_no"] = order.MdtrtId
  2263. memo["memo"] = "自费"
  2264. bytesData, _ := json.Marshal(memo)
  2265. fsiOPFLD.Memo = string(bytesData)
  2266. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2267. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2268. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2269. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2270. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2271. fsiOPFLD.BilgDeptName = department.Name
  2272. fsiOPFLD.BilgDeptCodg = department.Number
  2273. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2274. fsiOPFLD.BilgDrName = doctor.UserName
  2275. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2276. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2277. fsiOPFLD.MedChrgitmType = "08"
  2278. memo["hosp_appr_flag"] = "1"
  2279. memo["invoice_no"] = order.MdtrtId
  2280. memo["memo"] = "自费"
  2281. bytesData, _ := json.Marshal(memo)
  2282. fsiOPFLD.Memo = string(bytesData)
  2283. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2284. }
  2285. }
  2286. }
  2287. for _, items := range order_info_two {
  2288. memo := make(map[string]interface{})
  2289. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2290. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2291. fsiOPFLD.MedType = "14"
  2292. fsiOPFLD.BkkpSn = items.FeedetlSn
  2293. fsiOPFLD.FixmedinsCode = miConfig.Code
  2294. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2295. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2296. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2297. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2298. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2299. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2300. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2301. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2302. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2303. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2304. fsiOPFLD.BilgDeptName = department.Name
  2305. fsiOPFLD.BilgDeptCodg = department.Number
  2306. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2307. fsiOPFLD.BilgDrName = doctor.UserName
  2308. fsiOPFLD.MedChrgitmType = "09"
  2309. memo["hosp_appr_flag"] = "1"
  2310. memo["invoice_no"] = order.MdtrtId
  2311. memo["memo"] = "自费"
  2312. bytesData, _ := json.Marshal(memo)
  2313. fsiOPFLD.Memo = string(bytesData)
  2314. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2315. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2316. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2317. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2318. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2319. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2320. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2321. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2322. fsiOPFLD.BilgDeptName = department.Name
  2323. fsiOPFLD.BilgDeptCodg = department.Number
  2324. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2325. fsiOPFLD.BilgDrName = doctor.UserName
  2326. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2327. case 0:
  2328. break
  2329. case 1:
  2330. fsiOPFLD.MedChrgitmType = "14"
  2331. break
  2332. case 2:
  2333. fsiOPFLD.MedChrgitmType = "05"
  2334. break
  2335. case 3:
  2336. fsiOPFLD.MedChrgitmType = "03"
  2337. break
  2338. case 4:
  2339. fsiOPFLD.MedChrgitmType = "03"
  2340. break
  2341. case 5:
  2342. fsiOPFLD.MedChrgitmType = "08"
  2343. break
  2344. case 6:
  2345. fsiOPFLD.MedChrgitmType = "14"
  2346. break
  2347. case 7:
  2348. fsiOPFLD.MedChrgitmType = "14"
  2349. break
  2350. case 8:
  2351. fsiOPFLD.MedChrgitmType = "03"
  2352. break
  2353. case 9:
  2354. fsiOPFLD.MedChrgitmType = "14"
  2355. break
  2356. case 10:
  2357. fsiOPFLD.MedChrgitmType = "14"
  2358. break
  2359. case 11:
  2360. fsiOPFLD.MedChrgitmType = "06"
  2361. break
  2362. case 12:
  2363. fsiOPFLD.MedChrgitmType = "12"
  2364. break
  2365. case 13:
  2366. fsiOPFLD.MedChrgitmType = "01"
  2367. break
  2368. case 14:
  2369. fsiOPFLD.MedChrgitmType = "04"
  2370. break
  2371. case 15:
  2372. fsiOPFLD.MedChrgitmType = "14"
  2373. break
  2374. }
  2375. memo["hosp_appr_flag"] = "1"
  2376. memo["invoice_no"] = order.MdtrtId
  2377. memo["memo"] = "自费"
  2378. bytesData, _ := json.Marshal(memo)
  2379. fsiOPFLD.Memo = string(bytesData)
  2380. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2381. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2382. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2383. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2384. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2385. fsiOPFLD.BilgDeptName = department.Name
  2386. fsiOPFLD.BilgDeptCodg = department.Number
  2387. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2388. fsiOPFLD.BilgDrName = doctor.UserName
  2389. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2390. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2391. fsiOPFLD.MedChrgitmType = "08"
  2392. memo["hosp_appr_flag"] = "1"
  2393. memo["invoice_no"] = order.MdtrtId
  2394. memo["memo"] = "自费"
  2395. bytesData, _ := json.Marshal(memo)
  2396. fsiOPFLD.Memo = string(bytesData)
  2397. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2398. }
  2399. }
  2400. }
  2401. fmt.Println(fsiOPFLDs)
  2402. struct4201A.Fopfd = fsiOPFLDs
  2403. fmt.Println(struct4201A.Fopfd)
  2404. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2405. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2406. var res2 ResultSix
  2407. var respJSON2 map[string]interface{}
  2408. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2411. return
  2412. }
  2413. userJSONBytes2, _ := json.Marshal(respJSON2)
  2414. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2415. utils.ErrorLog("解析失败:%v", err)
  2416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. return
  2418. }
  2419. if res2.Infcode != 0 {
  2420. c.ServeSuccessJSON(map[string]interface{}{
  2421. "failed_code": -10,
  2422. "msg": res2.ErrMsg,
  2423. })
  2424. return
  2425. } else {
  2426. order.IsUploadOrderInfo = 1
  2427. service.UpdateOrder(order)
  2428. c.ServeSuccessJSON(map[string]interface{}{
  2429. "msg": "上传成功",
  2430. })
  2431. }
  2432. }
  2433. func (c *HisApiController) Get4202() {
  2434. order_id, _ := c.GetInt64("order_id")
  2435. admin_user_id, _ := c.GetInt64("admin_user_id")
  2436. order, _ := service.GetHisOrderByIDTwo(order_id)
  2437. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2438. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2439. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2440. if order.ID == 0 {
  2441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2442. return
  2443. }
  2444. var struct4202 models.Struct4202
  2445. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2446. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2447. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2448. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2449. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2450. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2451. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  2452. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  2453. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2454. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2455. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2456. var config []*models.HisXtDiagnoseConfig
  2457. for _, item := range diagnosis_ids {
  2458. id, _ := strconv.ParseInt(item, 10, 64)
  2459. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2460. config = append(config, &diagnosisConfig)
  2461. }
  2462. var tempDiaginfos []models.OwnPayPatnDiagListD
  2463. for index, item := range config {
  2464. if index == 0 {
  2465. var tempDiaginfo models.OwnPayPatnDiagListD
  2466. tempDiaginfo.InoutDiagType = "1"
  2467. tempDiaginfo.DiagCode = item.CountryCode
  2468. tempDiaginfo.DiagName = item.CountryContentName
  2469. tempDiaginfo.DiagType = "1"
  2470. tempDiaginfo.DiagSrtNo = "1"
  2471. tempDiaginfo.MaindiagFlag = "1"
  2472. tempDiaginfo.ValiFlag = "1"
  2473. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2474. } else {
  2475. var tempDiaginfo models.OwnPayPatnDiagListD
  2476. tempDiaginfo.DiagCode = item.CountryCode
  2477. tempDiaginfo.DiagName = item.CountryContentName
  2478. tempDiaginfo.DiagType = "2"
  2479. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2480. tempDiaginfo.MaindiagFlag = "0"
  2481. tempDiaginfo.ValiFlag = "1"
  2482. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2483. }
  2484. }
  2485. struct4202.ODiagListD = tempDiaginfos
  2486. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  2487. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  2488. var res2 ResultSix
  2489. var respJSON2 map[string]interface{}
  2490. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2493. return
  2494. }
  2495. userJSONBytes2, _ := json.Marshal(respJSON2)
  2496. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2497. utils.ErrorLog("解析失败:%v", err)
  2498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2499. return
  2500. }
  2501. if res2.Infcode != 0 {
  2502. c.ServeSuccessJSON(map[string]interface{}{
  2503. "failed_code": -10,
  2504. "msg": res2.ErrMsg,
  2505. })
  2506. return
  2507. } else {
  2508. order.IsUploadDiagnose = 1
  2509. service.UpdateOrder(order)
  2510. c.ServeSuccessJSON(map[string]interface{}{
  2511. "msg": "上传成功",
  2512. })
  2513. }
  2514. }
  2515. func (c *HisApiController) Get4203() {
  2516. admin_user_id, _ := c.GetInt64("admin_user_id")
  2517. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2518. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2519. order_id, _ := c.GetInt64("order_id")
  2520. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2521. number := ""
  2522. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2523. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2524. if his.ID == 0 {
  2525. number = hospital.Number
  2526. } else {
  2527. number = his.Number
  2528. }
  2529. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  2530. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  2531. var res2 ResultSix
  2532. var respJSON2 map[string]interface{}
  2533. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2536. return
  2537. }
  2538. userJSONBytes2, _ := json.Marshal(respJSON2)
  2539. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2540. utils.ErrorLog("解析失败:%v", err)
  2541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. return
  2543. }
  2544. if res2.Infcode != 0 {
  2545. c.ServeSuccessJSON(map[string]interface{}{
  2546. "failed_code": -10,
  2547. "msg": res2.ErrMsg,
  2548. })
  2549. return
  2550. } else {
  2551. order.IsUploadSuccess = 1
  2552. service.UpdateOrderTwo(order)
  2553. c.ServeSuccessJSON(map[string]interface{}{
  2554. "msg": "上传成功",
  2555. })
  2556. }
  2557. }
  2558. func (c *HisApiController) Get4205() {
  2559. order_id, _ := c.GetInt64("order_id")
  2560. admin_user_id, _ := c.GetInt64("admin_user_id")
  2561. fapiao_code := c.GetString("fapiao_code")
  2562. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2563. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2564. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2566. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  2567. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  2568. //order_info = append(order_info, order_info_two...)
  2569. department, _ := service.GetDepartMentDetail(his.Departments)
  2570. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2571. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2572. if order.ID == 0 {
  2573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2574. return
  2575. }
  2576. var struct4201A models.Struct4201A
  2577. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2578. for _, items := range order_info {
  2579. memo := make(map[string]interface{})
  2580. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2581. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2582. fsiOPFLD.MedType = pre.MedType
  2583. fsiOPFLD.FixmedinsCode = miConfig.Code
  2584. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2585. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2586. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2587. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2588. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2589. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2590. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2591. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  2592. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2593. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2594. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2595. fsiOPFLD.BilgDeptName = department.Name
  2596. fsiOPFLD.BilgDeptCodg = department.Number
  2597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2598. fsiOPFLD.BilgDrName = doctor.UserName
  2599. fsiOPFLD.MedChrgitmType = "09"
  2600. memo["hosp_appr_flag"] = "1"
  2601. memo["invoice_no"] = fapiao_code
  2602. memo["memo"] = "自费"
  2603. bytesData, _ := json.Marshal(memo)
  2604. fsiOPFLD.Memo = string(bytesData)
  2605. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2606. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2607. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2608. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2609. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2610. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2611. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2612. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2613. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2614. fsiOPFLD.BilgDeptName = department.Name
  2615. fsiOPFLD.BilgDeptCodg = department.Number
  2616. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2617. fsiOPFLD.BilgDrName = doctor.UserName
  2618. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2619. case 0:
  2620. break
  2621. case 1:
  2622. fsiOPFLD.MedChrgitmType = "14"
  2623. break
  2624. case 2:
  2625. fsiOPFLD.MedChrgitmType = "05"
  2626. break
  2627. case 3:
  2628. fsiOPFLD.MedChrgitmType = "03"
  2629. break
  2630. case 4:
  2631. fsiOPFLD.MedChrgitmType = "03"
  2632. break
  2633. case 5:
  2634. fsiOPFLD.MedChrgitmType = "08"
  2635. break
  2636. case 6:
  2637. fsiOPFLD.MedChrgitmType = "14"
  2638. break
  2639. case 7:
  2640. fsiOPFLD.MedChrgitmType = "14"
  2641. break
  2642. case 8:
  2643. fsiOPFLD.MedChrgitmType = "03"
  2644. break
  2645. case 9:
  2646. fsiOPFLD.MedChrgitmType = "14"
  2647. break
  2648. case 10:
  2649. fsiOPFLD.MedChrgitmType = "14"
  2650. break
  2651. case 11:
  2652. fsiOPFLD.MedChrgitmType = "06"
  2653. break
  2654. case 12:
  2655. fsiOPFLD.MedChrgitmType = "12"
  2656. break
  2657. case 13:
  2658. fsiOPFLD.MedChrgitmType = "01"
  2659. break
  2660. case 14:
  2661. fsiOPFLD.MedChrgitmType = "04"
  2662. break
  2663. case 15:
  2664. fsiOPFLD.MedChrgitmType = "14"
  2665. break
  2666. }
  2667. memo["hosp_appr_flag"] = "1"
  2668. memo["invoice_no"] = fapiao_code
  2669. memo["memo"] = "自费"
  2670. bytesData, _ := json.Marshal(memo)
  2671. fsiOPFLD.Memo = string(bytesData)
  2672. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2673. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2674. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2675. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2676. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2677. fsiOPFLD.BilgDeptName = department.Name
  2678. fsiOPFLD.BilgDeptCodg = department.Number
  2679. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2680. fsiOPFLD.BilgDrName = doctor.UserName
  2681. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2682. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2683. fsiOPFLD.MedChrgitmType = "08"
  2684. memo["hosp_appr_flag"] = "1"
  2685. memo["invoice_no"] = fapiao_code
  2686. memo["memo"] = "自费"
  2687. bytesData, _ := json.Marshal(memo)
  2688. fsiOPFLD.Memo = string(bytesData)
  2689. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2690. }
  2691. }
  2692. }
  2693. for _, items := range order_info_two {
  2694. memo := make(map[string]interface{})
  2695. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2696. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2697. fsiOPFLD.MedType = pre.MedType
  2698. fsiOPFLD.BkkpSn = items.FeedetlSn
  2699. fsiOPFLD.FixmedinsCode = miConfig.Code
  2700. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2701. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2702. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2703. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2704. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2705. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2706. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2707. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2708. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2709. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2710. fsiOPFLD.BilgDeptName = department.Name
  2711. fsiOPFLD.BilgDeptCodg = department.Number
  2712. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2713. fsiOPFLD.BilgDrName = doctor.UserName
  2714. fsiOPFLD.MedChrgitmType = "09"
  2715. memo["hosp_appr_flag"] = "1"
  2716. memo["invoice_no"] = fapiao_code
  2717. memo["memo"] = "自费"
  2718. bytesData, _ := json.Marshal(memo)
  2719. fsiOPFLD.Memo = string(bytesData)
  2720. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2721. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2722. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2723. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2724. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2725. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2726. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2727. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2728. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2729. fsiOPFLD.BilgDeptName = department.Name
  2730. fsiOPFLD.BilgDeptCodg = department.Number
  2731. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2732. fsiOPFLD.BilgDrName = doctor.UserName
  2733. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2734. case 0:
  2735. break
  2736. case 1:
  2737. fsiOPFLD.MedChrgitmType = "14"
  2738. break
  2739. case 2:
  2740. fsiOPFLD.MedChrgitmType = "05"
  2741. break
  2742. case 3:
  2743. fsiOPFLD.MedChrgitmType = "03"
  2744. break
  2745. case 4:
  2746. fsiOPFLD.MedChrgitmType = "03"
  2747. break
  2748. case 5:
  2749. fsiOPFLD.MedChrgitmType = "08"
  2750. break
  2751. case 6:
  2752. fsiOPFLD.MedChrgitmType = "14"
  2753. break
  2754. case 7:
  2755. fsiOPFLD.MedChrgitmType = "14"
  2756. break
  2757. case 8:
  2758. fsiOPFLD.MedChrgitmType = "03"
  2759. break
  2760. case 9:
  2761. fsiOPFLD.MedChrgitmType = "14"
  2762. break
  2763. case 10:
  2764. fsiOPFLD.MedChrgitmType = "14"
  2765. break
  2766. case 11:
  2767. fsiOPFLD.MedChrgitmType = "06"
  2768. break
  2769. case 12:
  2770. fsiOPFLD.MedChrgitmType = "12"
  2771. break
  2772. case 13:
  2773. fsiOPFLD.MedChrgitmType = "01"
  2774. break
  2775. case 14:
  2776. fsiOPFLD.MedChrgitmType = "04"
  2777. break
  2778. case 15:
  2779. fsiOPFLD.MedChrgitmType = "14"
  2780. break
  2781. }
  2782. memo["hosp_appr_flag"] = "1"
  2783. memo["invoice_no"] = fapiao_code
  2784. memo["memo"] = "自费"
  2785. bytesData, _ := json.Marshal(memo)
  2786. fsiOPFLD.Memo = string(bytesData)
  2787. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2788. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2789. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2790. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2791. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2792. fsiOPFLD.BilgDeptName = department.Name
  2793. fsiOPFLD.BilgDeptCodg = department.Number
  2794. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2795. fsiOPFLD.BilgDrName = doctor.UserName
  2796. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2797. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2798. fsiOPFLD.MedChrgitmType = "08"
  2799. memo["hosp_appr_flag"] = "1"
  2800. memo["invoice_no"] = fapiao_code
  2801. memo["memo"] = "自费"
  2802. bytesData, _ := json.Marshal(memo)
  2803. fsiOPFLD.Memo = string(bytesData)
  2804. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2805. }
  2806. }
  2807. }
  2808. fmt.Println(fsiOPFLDs)
  2809. struct4201A.Fopfd = fsiOPFLDs
  2810. fmt.Println(struct4201A.Fopfd)
  2811. var struct4202 models.Struct4202
  2812. timeLayout := "2006-01-02 15:04:05"
  2813. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  2814. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2815. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2816. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2817. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2818. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2819. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2820. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  2821. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  2822. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2823. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2824. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2825. var config []*models.HisXtDiagnoseConfig
  2826. for _, item := range diagnosis_ids {
  2827. id, _ := strconv.ParseInt(item, 10, 64)
  2828. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2829. config = append(config, &diagnosisConfig)
  2830. }
  2831. var tempDiaginfos []models.OwnPayPatnDiagListD
  2832. for index, item := range config {
  2833. if index == 0 {
  2834. var tempDiaginfo models.OwnPayPatnDiagListD
  2835. tempDiaginfo.InoutDiagType = "1"
  2836. tempDiaginfo.DiagCode = item.CountryCode
  2837. tempDiaginfo.DiagName = item.CountryContentName
  2838. tempDiaginfo.DiagType = "1"
  2839. tempDiaginfo.DiagSrtNo = "1"
  2840. tempDiaginfo.MaindiagFlag = "1"
  2841. tempDiaginfo.ValiFlag = "1"
  2842. tempDiaginfo.DiagDrName = doctor.UserName
  2843. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2844. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2845. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2846. } else {
  2847. var tempDiaginfo models.OwnPayPatnDiagListD
  2848. tempDiaginfo.DiagCode = item.CountryCode
  2849. tempDiaginfo.DiagName = item.CountryContentName
  2850. tempDiaginfo.DiagType = "2"
  2851. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2852. tempDiaginfo.MaindiagFlag = "0"
  2853. tempDiaginfo.ValiFlag = "1"
  2854. tempDiaginfo.DiagDrName = doctor.UserName
  2855. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  2856. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  2857. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2858. }
  2859. }
  2860. struct4202.ODiagListD = tempDiaginfos
  2861. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  2862. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  2863. var res2 ResultSix
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. if res2.Infcode != 0 {
  2877. c.ServeSuccessJSON(map[string]interface{}{
  2878. "failed_code": -10,
  2879. "msg": res2.ErrMsg,
  2880. })
  2881. return
  2882. } else {
  2883. order.IsUploadDiagnose = 1
  2884. order.IsUploadOrderInfo = 1
  2885. service.UpdateOrderTwo(order)
  2886. c.ServeSuccessJSON(map[string]interface{}{
  2887. "msg": "上传成功",
  2888. })
  2889. }
  2890. }
  2891. func (c *HisApiController) Get4207() {
  2892. admin_user_id, _ := c.GetInt64("admin_user_id")
  2893. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2895. order_id, _ := c.GetInt64("order_id")
  2896. order, _ := service.GetHisOrderByIDTwo(order_id)
  2897. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2898. var struct4207 models.Struct4207
  2899. struct4207.PageNum = "1"
  2900. struct4207.PageSize = "1000"
  2901. struct4207.FixmedinsCode = miConfig.Code
  2902. struct4207.FixmedinsMdtrtID = order.Number
  2903. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  2904. saveLog(result, requestLog, "4207", "查询")
  2905. var res2 ResultSix
  2906. var respJSON2 map[string]interface{}
  2907. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2910. return
  2911. }
  2912. userJSONBytes2, _ := json.Marshal(respJSON2)
  2913. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res2.Infcode != 0 {
  2919. c.ServeSuccessJSON(map[string]interface{}{
  2920. "failed_code": -10,
  2921. "msg": res2.ErrMsg,
  2922. })
  2923. return
  2924. } else {
  2925. c.ServeSuccessJSON(map[string]interface{}{
  2926. "msg": "查询成功",
  2927. })
  2928. }
  2929. }
  2930. func (c *HisApiController) Get4208() {
  2931. admin_user_id, _ := c.GetInt64("admin_user_id")
  2932. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2933. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2934. order_id, _ := c.GetInt64("order_id")
  2935. order, _ := service.GetHisOrderByIDTwo(order_id)
  2936. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2937. var struct4208 models.Struct4208
  2938. struct4208.PageNum = "1"
  2939. struct4208.PageSize = "1000"
  2940. struct4208.PsnCertType = "01"
  2941. struct4208.Certno = his.Certno
  2942. struct4208.MedType = order.MedType
  2943. struct4208.PsnName = his.Name
  2944. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  2945. saveLog(result, requestLog, "4208", "查询")
  2946. var res2 ResultSix
  2947. var respJSON2 map[string]interface{}
  2948. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2951. return
  2952. }
  2953. userJSONBytes2, _ := json.Marshal(respJSON2)
  2954. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2955. utils.ErrorLog("解析失败:%v", err)
  2956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2957. return
  2958. }
  2959. if res2.Infcode != 0 {
  2960. c.ServeSuccessJSON(map[string]interface{}{
  2961. "failed_code": -10,
  2962. "msg": res2.ErrMsg,
  2963. })
  2964. return
  2965. } else {
  2966. c.ServeSuccessJSON(map[string]interface{}{
  2967. "msg": "查询成功",
  2968. })
  2969. }
  2970. }
  2971. func (c *HisApiController) Get4209() {
  2972. admin_user_id, _ := c.GetInt64("admin_user_id")
  2973. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2974. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2975. order_id, _ := c.GetInt64("order_id")
  2976. order, _ := service.GetHisOrderByIDTwo(order_id)
  2977. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2978. var struct4209 models.Struct4209
  2979. struct4209.FixmedinsMdtrtID = order.Number
  2980. struct4209.FixmedinsCode = miConfig.Code
  2981. struct4209.PageSize = "1000"
  2982. struct4209.PageNum = "1"
  2983. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  2984. saveLog(result, requestLog, "4209", "查询")
  2985. var res2 ResultSix
  2986. var respJSON2 map[string]interface{}
  2987. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. userJSONBytes2, _ := json.Marshal(respJSON2)
  2993. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2994. utils.ErrorLog("解析失败:%v", err)
  2995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2996. return
  2997. }
  2998. if res2.Infcode != 0 {
  2999. c.ServeSuccessJSON(map[string]interface{}{
  3000. "failed_code": -10,
  3001. "msg": res2.ErrMsg,
  3002. })
  3003. return
  3004. } else {
  3005. c.ServeSuccessJSON(map[string]interface{}{
  3006. "msg": "查询成功",
  3007. })
  3008. }
  3009. }
  3010. type Result3101 struct {
  3011. Infcode string `json:"infcode"`
  3012. InfRefmsgid string `json:"inf_refmsgid"`
  3013. RefmsgTime string `json:"refmsg_time"`
  3014. RespondTime string `json:"respond_time"`
  3015. Enctype string `json:"enctype"`
  3016. Signtype string `json:"signtype"`
  3017. ErrMsg string `json:"err_msg"`
  3018. Output struct {
  3019. Result []struct {
  3020. JudgeResultDetailDtos []struct {
  3021. VolaItemType string `json:"vola_item_type"`
  3022. MdtrtID string `json:"mdtrt_id"`
  3023. JrdID string `json:"jrd_id"`
  3024. PatnID string `json:"patn_id"`
  3025. RxID string `json:"rx_id"`
  3026. VolaAmt interface{} `json:"vola_amt"`
  3027. } `json:"judge_result_detail_dtos"`
  3028. RuleID string `json:"rule_id"`
  3029. VolaEvid string `json:"vola_evid"`
  3030. MdtrtID string `json:"mdtrt_id"`
  3031. RuleName string `json:"rule_name"`
  3032. VolaAmtStas string `json:"vola_amt_stas"`
  3033. JrID string `json:"jr_id"`
  3034. PatnID string `json:"patn_id"`
  3035. SevDeg string `json:"sev_deg"`
  3036. VolaAmt float64 `json:"vola_amt"`
  3037. VolaBhvrType string `json:"vola_bhvr_type"`
  3038. VolaCont string `json:"vola_cont"`
  3039. } `json:"result"`
  3040. } `json:"output"`
  3041. }
  3042. func (c *HisApiController) ReadEleToken() {
  3043. admin_user_id, _ := c.GetInt64("admin_user_id")
  3044. his_patient_id, _ := c.GetInt64("his_patient_id")
  3045. adminUser := c.GetAdminUserInfo()
  3046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3047. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3048. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3049. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3050. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3051. if len(tokens) > 0 {
  3052. c.ServeSuccessJSON(map[string]interface{}{
  3053. "msg": "读取成功",
  3054. })
  3055. } else {
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "failed_code": -10,
  3058. "msg": "读取失败",
  3059. })
  3060. }
  3061. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3062. var api string
  3063. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3064. "&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
  3065. resp, requestErr := http.Get(api)
  3066. if requestErr != nil {
  3067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3068. }
  3069. body, ioErr := ioutil.ReadAll(resp.Body)
  3070. if ioErr != nil {
  3071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3073. }
  3074. var respJSON map[string]interface{}
  3075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3078. return
  3079. }
  3080. var status string
  3081. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3082. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3083. var token string
  3084. var res ResultTwo //1101结果
  3085. var res10265 ResultTwo10265 //1101结果
  3086. if status == "0" { //读卡成功
  3087. var card_info string //卡信息
  3088. var busi_card_info string
  3089. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3090. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3091. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3092. fmt.Println(card_info)
  3093. fmt.Println(busi_card_info)
  3094. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3095. result, _ := json.Marshal(respJSON)
  3096. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3097. utils.ErrorLog("解析失败:%v", err)
  3098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3099. return
  3100. }
  3101. res.ErrMsg = res10265.ErrMsg
  3102. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3103. res.Infcode = infocode
  3104. res.Output = res10265.Output
  3105. res.InfRefmsgid = res10265.InfRefmsgid
  3106. if res.Infcode == 0 {
  3107. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3108. if err == gorm.ErrRecordNotFound {
  3109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3110. return
  3111. } else if err != nil {
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3113. return
  3114. } else {
  3115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3116. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3117. infoStr := string(Iinfos)
  3118. idetinfoStr := string(Idetinfos)
  3119. psn := &models.HisPsn{
  3120. PsnNo: res.Output.Baseinfo.PsnNo,
  3121. Age: res.Output.Baseinfo.Age,
  3122. PatientId: patient.ID,
  3123. Certno: res.Output.Baseinfo.Certno,
  3124. Brdy: res.Output.Baseinfo.Brdy,
  3125. Gend: res.Output.Baseinfo.Gend,
  3126. Naty: res.Output.Baseinfo.Naty,
  3127. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3128. PsnName: res.Output.Baseinfo.PsnName,
  3129. Idetinfo: idetinfoStr,
  3130. Insuinfo: infoStr,
  3131. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3132. CardInfo: card_info,
  3133. VerifyNumber: token,
  3134. IdCardType: 4,
  3135. }
  3136. var rf []*ResultFive
  3137. json.Unmarshal([]byte(infoStr), &rf)
  3138. var insutypes []*ResultFive
  3139. var insutype string
  3140. var is390 int = 0
  3141. var is310 int = 0
  3142. for _, item := range rf {
  3143. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3144. insutypes = append(insutypes, item)
  3145. }
  3146. }
  3147. if len(insutypes) == 1 {
  3148. insutype = insutypes[0].Insutype
  3149. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3150. } else {
  3151. for _, i := range insutypes {
  3152. if i.Insutype == "390" {
  3153. is390 = 1
  3154. }
  3155. if i.Insutype == "310" {
  3156. is310 = 1
  3157. }
  3158. }
  3159. }
  3160. if is390 == 1 {
  3161. insutype = "390"
  3162. }
  3163. if is310 == 1 {
  3164. insutype = "310"
  3165. }
  3166. if len(insutypes) == 0 {
  3167. insutype = "310"
  3168. }
  3169. service.CreateHisPsn(psn)
  3170. c.ServeSuccessJSON(map[string]interface{}{
  3171. "patient": patient,
  3172. "number": token,
  3173. "insutype": insutype,
  3174. })
  3175. }
  3176. } else {
  3177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3178. return
  3179. }
  3180. } else { //读卡失败
  3181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3182. return
  3183. }
  3184. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3185. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  3186. if len(errMsg) == 0 {
  3187. type ELeData struct {
  3188. Data struct {
  3189. IdNo string `json:"idNo"`
  3190. IdType string `json:"idType"`
  3191. UserName string `json:"userName"`
  3192. EcToken string `json:"ecToken"`
  3193. InsuOrg string `json:"insuOrg"`
  3194. Gender string `json:"gender"`
  3195. Birthday string `json:"birthday"`
  3196. Nationality string `json:"nationality"`
  3197. Email string `json:"email"`
  3198. Extra string `json:"extra"`
  3199. } `json:"data"`
  3200. Code int `json:"code"`
  3201. Message string `json:"message"`
  3202. }
  3203. var ele ELeData
  3204. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3205. if err != nil {
  3206. utils.ErrorLog("解析失败:%v", err)
  3207. }
  3208. token := ele.Data.EcToken
  3209. if len(token) > 0 {
  3210. psn := &models.HisPsn{
  3211. PsnNo: his.PsnNo,
  3212. Age: 0,
  3213. PatientId: his.PatientId,
  3214. Certno: his.Certno,
  3215. Brdy: his.Brdy,
  3216. Gend: his.Gend,
  3217. Naty: his.Naty,
  3218. PsnCertType: his.PsnCertType,
  3219. PsnName: his.PsnName,
  3220. Idetinfo: his.Idetinfo,
  3221. Insuinfo: his.Iinfo,
  3222. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3223. CardInfo: outPutInfo,
  3224. VerifyNumber: token,
  3225. }
  3226. service.CreateHisPsn(psn)
  3227. }
  3228. if len(token) > 0 {
  3229. c.ServeSuccessJSON(map[string]interface{}{
  3230. "msg": "读取成功",
  3231. })
  3232. } else {
  3233. c.ServeSuccessJSON(map[string]interface{}{
  3234. "failed_code": -10,
  3235. "msg": "读取失败",
  3236. })
  3237. }
  3238. }
  3239. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3240. if initFlag == 0 {
  3241. c.TestGetJiangXiBasBaseInit()
  3242. }
  3243. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3244. type ELeData struct {
  3245. Data struct {
  3246. IdNo string `json:"idNo"`
  3247. IdType string `json:"idType"`
  3248. UserName string `json:"userName"`
  3249. EcToken string `json:"ecToken"`
  3250. InsuOrg string `json:"insuOrg"`
  3251. Gender string `json:"gender"`
  3252. Birthday string `json:"birthday"`
  3253. Nationality string `json:"nationality"`
  3254. Email string `json:"email"`
  3255. Extra string `json:"extra"`
  3256. } `json:"data"`
  3257. Code int `json:"code"`
  3258. Message string `json:"message"`
  3259. }
  3260. var ele ELeData
  3261. err := json.Unmarshal([]byte(json_result), &ele)
  3262. if err != nil {
  3263. utils.ErrorLog("解析失败:%v", err)
  3264. }
  3265. token := ele.Data.EcToken
  3266. token = Remove0000(token)
  3267. fmt.Println(ele.Data.UserName)
  3268. 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)
  3269. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3270. var res ResultTwo
  3271. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3274. return
  3275. }
  3276. if res.Infcode == 0 {
  3277. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3278. if err == gorm.ErrRecordNotFound {
  3279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3280. return
  3281. } else if err != nil {
  3282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3283. return
  3284. } else {
  3285. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3286. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3287. infoStr := string(Iinfos)
  3288. idetinfoStr := string(Idetinfos)
  3289. psn := &models.HisPsn{
  3290. PsnNo: res.Output.Baseinfo.PsnNo,
  3291. Age: res.Output.Baseinfo.Age,
  3292. PatientId: patient.ID,
  3293. Certno: res.Output.Baseinfo.Certno,
  3294. Brdy: res.Output.Baseinfo.Brdy,
  3295. Gend: res.Output.Baseinfo.Gend,
  3296. Naty: res.Output.Baseinfo.Naty,
  3297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3298. PsnName: res.Output.Baseinfo.PsnName,
  3299. Idetinfo: idetinfoStr,
  3300. Insuinfo: infoStr,
  3301. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3302. CardInfo: "",
  3303. VerifyNumber: token,
  3304. }
  3305. service.CreateHisPsn(psn)
  3306. c.ServeSuccessJSON(map[string]interface{}{
  3307. "patient": patient,
  3308. "number": token,
  3309. })
  3310. }
  3311. } else {
  3312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3313. return
  3314. }
  3315. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3316. idNo := c.GetString("idNo")
  3317. userName := c.GetString("userName")
  3318. ecToken := c.GetString("ecToken")
  3319. insuOrg := c.GetString("insuOrg")
  3320. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  3321. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3322. var res ResultTwo
  3323. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3324. utils.ErrorLog("解析失败:%v", err)
  3325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3326. return
  3327. }
  3328. if res.Infcode == 0 {
  3329. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3330. if err == gorm.ErrRecordNotFound {
  3331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3332. return
  3333. } else if err != nil {
  3334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3335. return
  3336. } else {
  3337. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3338. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3339. infoStr := string(Iinfos)
  3340. idetinfoStr := string(Idetinfos)
  3341. psn := &models.HisPsn{
  3342. PsnNo: res.Output.Baseinfo.PsnNo,
  3343. Age: res.Output.Baseinfo.Age,
  3344. PatientId: patient.ID,
  3345. Certno: res.Output.Baseinfo.Certno,
  3346. Brdy: res.Output.Baseinfo.Brdy,
  3347. Gend: res.Output.Baseinfo.Gend,
  3348. Naty: res.Output.Baseinfo.Naty,
  3349. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3350. PsnName: res.Output.Baseinfo.PsnName,
  3351. Idetinfo: idetinfoStr,
  3352. Insuinfo: infoStr,
  3353. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3354. CardInfo: "",
  3355. VerifyNumber: ecToken,
  3356. InsuplcAdmdvs: insuOrg,
  3357. }
  3358. service.CreateHisPsn(psn)
  3359. c.ServeSuccessJSON(map[string]interface{}{
  3360. "patient": patient,
  3361. "number": ecToken,
  3362. })
  3363. }
  3364. } else {
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3366. return
  3367. }
  3368. } else {
  3369. //if initFlag == 0 {
  3370. // c.TestGetBasBaseInit()
  3371. //}
  3372. //token := c.GetEleBaseInfo()
  3373. //token = Remove0000(token)
  3374. type ELeData struct {
  3375. Code string `json:"code"`
  3376. Data struct {
  3377. Aac002 string `json:"aac002"`
  3378. Aaz500 string `json:"aaz500"`
  3379. ActCardNo string `json:"actCardNo"`
  3380. Bab520 string `json:"bab520"`
  3381. Bkz543 string `json:"bkz543"`
  3382. BusinessType string `json:"businessType"`
  3383. CertfCodg string `json:"certfCodg"`
  3384. EcIndexNo string `json:"ecIndexNo"`
  3385. EcToken string `json:"ecToken"`
  3386. ID0000 string `json:"id0000"`
  3387. IDNo string `json:"idNo"`
  3388. IDType string `json:"idType"`
  3389. Idcode string `json:"idcode"`
  3390. IdentityToken string `json:"identity_token"`
  3391. InsuOrg string `json:"insuOrg"`
  3392. OfficeID string `json:"officeId"`
  3393. OfficeName string `json:"officeName"`
  3394. OperatorID string `json:"operatorId"`
  3395. OperatorName string `json:"operatorName"`
  3396. OrgID string `json:"orgId"`
  3397. UserName string `json:"userName"`
  3398. } `json:"data"`
  3399. Infno interface{} `json:"infno"`
  3400. Message string `json:"message"`
  3401. OrgID string `json:"orgId"`
  3402. TransType string `json:"transType"`
  3403. }
  3404. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  3405. fmt.Println(result)
  3406. outPutInfo := Remove0000(result)
  3407. fmt.Println(outPutInfo)
  3408. var ele ELeData
  3409. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3410. if err != nil {
  3411. utils.ErrorLog("解析失败:%v", err)
  3412. }
  3413. token := ele.Data.EcToken
  3414. if len(token) > 0 {
  3415. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  3416. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3417. var res ResultTwo
  3418. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3419. utils.ErrorLog("解析失败:%v", err)
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3421. return
  3422. }
  3423. if res.Infcode == 0 {
  3424. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3425. if err == gorm.ErrRecordNotFound {
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3427. return
  3428. } else if err != nil {
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3430. return
  3431. } else {
  3432. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3433. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3434. infoStr := string(Iinfos)
  3435. idetinfoStr := string(Idetinfos)
  3436. psn := &models.HisPsn{
  3437. PsnNo: res.Output.Baseinfo.PsnNo,
  3438. Age: res.Output.Baseinfo.Age,
  3439. PatientId: patient.ID,
  3440. Certno: res.Output.Baseinfo.Certno,
  3441. Brdy: res.Output.Baseinfo.Brdy,
  3442. Gend: res.Output.Baseinfo.Gend,
  3443. Naty: res.Output.Baseinfo.Naty,
  3444. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3445. PsnName: res.Output.Baseinfo.PsnName,
  3446. Idetinfo: idetinfoStr,
  3447. Insuinfo: infoStr,
  3448. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3449. CardInfo: "",
  3450. VerifyNumber: token,
  3451. }
  3452. service.CreateHisPsn(psn)
  3453. c.ServeSuccessJSON(map[string]interface{}{
  3454. "msg": "读取成功",
  3455. })
  3456. }
  3457. } else {
  3458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3459. return
  3460. }
  3461. } else {
  3462. c.ServeSuccessJSON(map[string]interface{}{
  3463. "failed_code": -10,
  3464. "msg": "读取失败",
  3465. })
  3466. }
  3467. }
  3468. }
  3469. func (c *HisApiController) Get9001() {
  3470. adminUser := c.GetAdminUserInfo()
  3471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3472. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  3473. if miConfig.MdtrtareaAdmvs == "350500" {
  3474. service.GetFjAuthorizationInfo(miConfig.Code)
  3475. } else if miConfig.MdtrtareaAdmvs == "131023" {
  3476. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3477. var dat map[string]interface{}
  3478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3479. fmt.Println(dat)
  3480. } else {
  3481. fmt.Println(err)
  3482. }
  3483. userJSONBytes, _ := json.Marshal(dat)
  3484. var res models.Result9001
  3485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3486. utils.ErrorLog("解析失败:%v", err)
  3487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3488. return
  3489. }
  3490. } else {
  3491. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3492. var dat map[string]interface{}
  3493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3494. fmt.Println(dat)
  3495. } else {
  3496. fmt.Println(err)
  3497. }
  3498. userJSONBytes, _ := json.Marshal(dat)
  3499. var res models.Result9001
  3500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3501. utils.ErrorLog("解析失败:%v", err)
  3502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. return
  3504. }
  3505. }
  3506. }
  3507. 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) {
  3508. var res Result3101
  3509. adminUser := c.GetAdminUserInfo()
  3510. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3511. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3512. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3513. //record_time := c.GetString("record_time")
  3514. //trig_scen := c.GetString("trig_scen")
  3515. timeLayout := "2006-01-02"
  3516. loc, _ := time.LoadLocation("Local")
  3517. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3518. if err != nil {
  3519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3520. return res
  3521. }
  3522. recordDateTime := theTime.Unix()
  3523. var patientPrescription models.HisPrescriptionInfo
  3524. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3525. //if patientPrescription.ID == 0 {
  3526. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3527. //}
  3528. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3529. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3530. //
  3531. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3532. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3533. var pp models.PublicParams
  3534. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3535. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3536. pp.FixmedinsName = miConfig.OrgName
  3537. pp.FixmedinsCode = miConfig.Code
  3538. pp.RequestUrl = miConfig.Url
  3539. pp.Cainfo = miConfig.Cainfo
  3540. pp.SecretKey = miConfig.SecretKey
  3541. pp.AccessKey = miConfig.AccessKey
  3542. pp.OpterName = roles.UserName
  3543. var config []*models.HisXtDiagnoseConfig
  3544. for _, item := range diagnosis_ids {
  3545. id, _ := strconv.ParseInt(item, 10, 64)
  3546. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3547. config = append(config, &diagnosisConfig)
  3548. }
  3549. var pd models.PatientDtos
  3550. pd.PatnID = his.PsnNo
  3551. pd.PatnName = his.Name
  3552. pd.Gend = his.Gend
  3553. pd.Brdy = his.Brdy
  3554. pd.Poolarea = miConfig.MdtrtareaAdmvs
  3555. pd.CurrMdtrtID = his.Number
  3556. var fed models.FsiEncounterDtos
  3557. fed.MdtrtID = his.Number
  3558. fed.MedinsID = miConfig.Code
  3559. fed.MedinsName = miConfig.OrgName
  3560. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3561. fed.MedMdtrtType = "1"
  3562. fed.MedinsType = "1"
  3563. fed.MedinsLv = "11"
  3564. tm := time.Unix(his.RecordDate, 0)
  3565. s_tm := tm.Format("2006-01-02 15:04:05")
  3566. fed.AdmDate = s_tm
  3567. fed.DscgDate = s_tm
  3568. fed.DscgMainDiseCodg = config[0].CountryCode
  3569. fed.DscgMainDiseName = config[0].CountryContentName
  3570. //诊断信息
  3571. var fdds []*models.FsiDiagnoseDtos
  3572. for index, item := range config {
  3573. if index == 0 {
  3574. var fdd models.FsiDiagnoseDtos
  3575. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3576. fdd.InoutDiseType = "1"
  3577. fdd.MaindiseFlag = "1"
  3578. fdd.DiseDate = s_tm
  3579. fdd.DiasSrtNo = "1"
  3580. fdd.DiseName = item.CountryContentName
  3581. fdd.DiseCodg = item.CountryCode
  3582. fdds = append(fdds, &fdd)
  3583. } else {
  3584. var fdd models.FsiDiagnoseDtos
  3585. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3586. fdd.InoutDiseType = "1"
  3587. fdd.MaindiseFlag = "1"
  3588. fdd.DiseDate = s_tm
  3589. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3590. fdd.DiseName = item.CountryContentName
  3591. fdd.DiseCodg = item.CountryCode
  3592. fdds = append(fdds, &fdd)
  3593. }
  3594. }
  3595. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3596. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3597. fed.AdmDeptName = department.Name
  3598. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3599. fed.DscgDeptName = department.Name
  3600. fed.MedMdtrtType = "1"
  3601. fed.MedType = "11"
  3602. //if his.Insutype == "390" {
  3603. // fed.MedType = "1402"
  3604. //} else {
  3605. // fed.MedType = "9933"
  3606. //}
  3607. var orders []*models.FsiOrderDtos
  3608. if trig_scen == "2" {
  3609. //处方医嘱信息
  3610. for _, item := range prescriptions {
  3611. for _, subItem := range item.HisDoctorAdviceInfo {
  3612. var order models.FsiOrderDtos
  3613. order.RxID = strconv.FormatInt(item.ID, 10)
  3614. order.Rxno = strconv.FormatInt(item.ID, 10)
  3615. order.LongDrordFlag = "0"
  3616. order.HilistType = "1"
  3617. order.ChrgType = "1"
  3618. order.DrordBhvr = "-"
  3619. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3620. order.HosplistName = subItem.BaseDrugLib.DrugName
  3621. order.HilistLv = "1"
  3622. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3623. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3624. order.HosplistName = subItem.BaseDrugLib.DrugName
  3625. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3626. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3627. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3628. order.OwnpayAmt = ""
  3629. order.SelfpayAmt = ""
  3630. order.Spec = ""
  3631. order.SpecUnt = ""
  3632. order.DrordBegnDate = s_tm
  3633. order.DrordStopDate = ""
  3634. order.DrordDrCodg = "1"
  3635. order.DrordDeptName = department.Name
  3636. order.DrordDrCodg = "1"
  3637. order.DrordDrName = doctor_info.UserName
  3638. order.DrordDrProfttl = ""
  3639. order.CurrDrordFlag = "1"
  3640. orders = append(orders, &order)
  3641. }
  3642. for _, subItem := range item.HisPrescriptionProject {
  3643. if subItem.Type == 2 {
  3644. var order models.FsiOrderDtos
  3645. order.RxID = strconv.FormatInt(item.ID, 10)
  3646. order.Rxno = strconv.FormatInt(item.ID, 10)
  3647. order.LongDrordFlag = "0"
  3648. order.HilistType = "1"
  3649. order.ChrgType = "1"
  3650. order.DrordBhvr = "-"
  3651. order.HilistCode = subItem.HisProject.MedicalCode
  3652. order.HosplistName = subItem.HisProject.ProjectName
  3653. order.HilistLv = "1"
  3654. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3655. order.HosplistCode = subItem.HisProject.MedicalCode
  3656. order.HosplistName = subItem.HisProject.ProjectName
  3657. order.Cnt = subItem.Count
  3658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3659. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3660. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3661. order.OwnpayAmt = ""
  3662. order.SelfpayAmt = ""
  3663. order.Spec = ""
  3664. order.SpecUnt = ""
  3665. order.DrordBegnDate = s_tm
  3666. order.DrordStopDate = ""
  3667. order.DrordDrCodg = "1"
  3668. order.DrordDeptName = department.Name
  3669. order.DrordDrCodg = "1"
  3670. order.DrordDrName = doctor_info.UserName
  3671. order.DrordDrProfttl = ""
  3672. order.CurrDrordFlag = "1"
  3673. orders = append(orders, &order)
  3674. }
  3675. if subItem.Type == 3 {
  3676. var order models.FsiOrderDtos
  3677. order.RxID = strconv.FormatInt(item.ID, 10)
  3678. order.Rxno = strconv.FormatInt(item.ID, 10)
  3679. order.LongDrordFlag = "0"
  3680. order.HilistType = "1"
  3681. order.ChrgType = "1"
  3682. order.DrordBhvr = "-"
  3683. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3684. order.HosplistName = subItem.GoodInfo.GoodName
  3685. order.HilistLv = "1"
  3686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3687. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3688. order.HosplistName = subItem.GoodInfo.GoodName
  3689. order.Cnt = subItem.Count
  3690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3693. order.OwnpayAmt = ""
  3694. order.SelfpayAmt = ""
  3695. order.Spec = ""
  3696. order.SpecUnt = ""
  3697. order.DrordBegnDate = s_tm
  3698. order.DrordStopDate = ""
  3699. order.DrordDrCodg = "1"
  3700. order.DrordDeptName = department.Name
  3701. order.DrordDrCodg = "1"
  3702. order.DrordDrName = doctor_info.UserName
  3703. order.DrordDrProfttl = ""
  3704. order.CurrDrordFlag = "1"
  3705. orders = append(orders, &order)
  3706. }
  3707. }
  3708. }
  3709. //处方医嘱信息
  3710. }
  3711. fed.MatnStas = "0"
  3712. fed.MedfeeSumamt = "0"
  3713. fed.OwnpayAmt = "0"
  3714. fed.SelfpayAmt = "0"
  3715. fed.AcctPayamt = "0"
  3716. fed.MaAmt = "0"
  3717. fed.HifpPayamt = "0"
  3718. fed.SetlTotlnum = "1"
  3719. fed.Insutype = his.Insutype
  3720. fed.ReimFlag = "0"
  3721. fed.OutSetlFlag = "0"
  3722. var fopd []*models.FsiOperationDtosData
  3723. data := make(map[string]interface{})
  3724. data["fed"] = fed
  3725. data["fdd"] = fdds
  3726. data["fod"] = orders
  3727. data["pd"] = pd
  3728. data["pp"] = pp
  3729. data["fopd"] = fopd
  3730. data["trig_scen"] = trig_scen
  3731. fmt.Println(data)
  3732. fmt.Println(fed)
  3733. fmt.Println(fdds)
  3734. fmt.Println(orders)
  3735. fmt.Println(pd)
  3736. fmt.Println(pp)
  3737. fmt.Println(fopd)
  3738. client := &http.Client{}
  3739. bytesData, _ := json.Marshal(data)
  3740. var req *http.Request
  3741. if miConfig.MdtrtareaAdmvs == "320921" {
  3742. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3743. } else {
  3744. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3745. }
  3746. resp, _ := client.Do(req)
  3747. defer resp.Body.Close()
  3748. body, ioErr := ioutil.ReadAll(resp.Body)
  3749. if ioErr != nil {
  3750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. return res
  3753. }
  3754. var respJSON map[string]interface{}
  3755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3758. return res
  3759. }
  3760. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3761. fmt.Println(respJSON)
  3762. result, _ := json.Marshal(respJSON)
  3763. fmt.Println(result)
  3764. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3765. utils.ErrorLog("解析失败:%v", err)
  3766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3767. return res
  3768. }
  3769. return res
  3770. }
  3771. 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) {
  3772. adminUser := c.GetAdminUserInfo()
  3773. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3774. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3775. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3776. //record_time := c.GetString("record_time")
  3777. //trig_scen := c.GetString("trig_scen")
  3778. timeLayout := "2006-01-02"
  3779. loc, _ := time.LoadLocation("Local")
  3780. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3781. if err != nil {
  3782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3783. return res
  3784. }
  3785. recordDateTime := theTime.Unix()
  3786. var patientPrescription models.HisPrescriptionInfo
  3787. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3788. if patientPrescription.ID == 0 {
  3789. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3790. }
  3791. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3792. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3793. //
  3794. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3795. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3796. var pp models.PublicParams
  3797. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3798. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3799. pp.FixmedinsName = miConfig.OrgName
  3800. pp.FixmedinsCode = miConfig.Code
  3801. pp.RequestUrl = miConfig.Url
  3802. pp.Cainfo = miConfig.Cainfo
  3803. pp.SecretKey = miConfig.SecretKey
  3804. pp.AccessKey = miConfig.AccessKey
  3805. pp.OpterName = roles.UserName
  3806. var config []*models.HisXtDiagnoseConfig
  3807. for _, item := range diagnosis_ids {
  3808. id, _ := strconv.ParseInt(item, 10, 64)
  3809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3810. config = append(config, &diagnosisConfig)
  3811. }
  3812. var pd models.PatientDtos
  3813. pd.PatnID = his.PsnNo
  3814. pd.PatnName = his.Name
  3815. pd.Gend = his.Gend
  3816. pd.Brdy = his.Brdy
  3817. pd.Poolarea = his.InsuplcAdmdvs
  3818. pd.CurrMdtrtID = his.Number
  3819. var fed models.FsiEncounterDtos
  3820. fed.MdtrtID = his.Number
  3821. fed.MedinsID = miConfig.Code
  3822. fed.MedinsName = miConfig.OrgName
  3823. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3824. fed.MedMdtrtType = "1"
  3825. fed.MedinsType = "1"
  3826. fed.MedinsLv = "11"
  3827. tm := time.Unix(his.RecordDate, 0)
  3828. s_tm := tm.Format("2006-01-02 15:04:05")
  3829. fed.AdmDate = s_tm
  3830. fed.DscgDate = s_tm
  3831. fed.DscgMainDiseCodg = config[0].CountryCode
  3832. fed.DscgMainDiseName = config[0].CountryContentName
  3833. //诊断信息
  3834. var fdds []*models.FsiDiagnoseDtos
  3835. for index, item := range config {
  3836. if index == 0 {
  3837. var fdd models.FsiDiagnoseDtos
  3838. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3839. fdd.InoutDiseType = "1"
  3840. fdd.MaindiseFlag = "1"
  3841. fdd.DiseDate = s_tm
  3842. fdd.DiasSrtNo = "1"
  3843. fdd.DiseName = item.CountryContentName
  3844. fdd.DiseCodg = item.CountryCode
  3845. fdds = append(fdds, &fdd)
  3846. } else {
  3847. var fdd models.FsiDiagnoseDtos
  3848. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3849. fdd.InoutDiseType = "1"
  3850. fdd.MaindiseFlag = "1"
  3851. fdd.DiseDate = s_tm
  3852. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3853. fdd.DiseName = item.CountryContentName
  3854. fdd.DiseCodg = item.CountryCode
  3855. fdds = append(fdds, &fdd)
  3856. }
  3857. }
  3858. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3859. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3860. fed.AdmDeptName = department.Name
  3861. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3862. fed.DscgDeptName = department.Name
  3863. fed.MedMdtrtType = "1"
  3864. fed.MedType = "11"
  3865. //if his.Insutype == "390" {
  3866. // fed.MedType = "1402"
  3867. //} else {
  3868. // fed.MedType = "9933"
  3869. //}
  3870. var orders []*models.FsiOrderDtos
  3871. if trig_scen == "2" {
  3872. //处方医嘱信息
  3873. for _, item := range prescriptions {
  3874. for _, subItem := range item.HisDoctorAdviceInfo {
  3875. var order models.FsiOrderDtos
  3876. order.RxID = strconv.FormatInt(item.ID, 10)
  3877. order.Rxno = strconv.FormatInt(item.ID, 10)
  3878. order.LongDrordFlag = "0"
  3879. order.HilistType = "1"
  3880. order.ChrgType = "1"
  3881. order.DrordBhvr = "-"
  3882. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3883. order.HosplistName = subItem.BaseDrugLib.DrugName
  3884. order.HilistLv = "1"
  3885. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3886. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3887. order.HosplistName = subItem.BaseDrugLib.DrugName
  3888. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3889. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3890. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3891. order.OwnpayAmt = ""
  3892. order.SelfpayAmt = ""
  3893. order.Spec = ""
  3894. order.SpecUnt = ""
  3895. order.DrordBegnDate = s_tm
  3896. order.DrordStopDate = ""
  3897. order.DrordDrCodg = "1"
  3898. order.DrordDeptName = department.Name
  3899. order.DrordDrCodg = "1"
  3900. order.DrordDrName = doctor_info.UserName
  3901. order.DrordDrProfttl = ""
  3902. order.CurrDrordFlag = "1"
  3903. orders = append(orders, &order)
  3904. }
  3905. for _, subItem := range item.HisPrescriptionProject {
  3906. if subItem.Type == 2 {
  3907. var order models.FsiOrderDtos
  3908. order.RxID = strconv.FormatInt(item.ID, 10)
  3909. order.Rxno = strconv.FormatInt(item.ID, 10)
  3910. order.LongDrordFlag = "0"
  3911. order.HilistType = "1"
  3912. order.ChrgType = "1"
  3913. order.DrordBhvr = "-"
  3914. order.HilistCode = subItem.HisProject.MedicalCode
  3915. order.HosplistName = subItem.HisProject.ProjectName
  3916. order.HilistLv = "1"
  3917. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3918. order.HosplistCode = subItem.HisProject.MedicalCode
  3919. order.HosplistName = subItem.HisProject.ProjectName
  3920. order.Cnt = subItem.Count
  3921. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3922. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3923. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3924. order.OwnpayAmt = ""
  3925. order.SelfpayAmt = ""
  3926. order.Spec = ""
  3927. order.SpecUnt = ""
  3928. order.DrordBegnDate = s_tm
  3929. order.DrordStopDate = ""
  3930. order.DrordDrCodg = "1"
  3931. order.DrordDeptName = department.Name
  3932. order.DrordDrCodg = "1"
  3933. order.DrordDrName = doctor_info.UserName
  3934. order.DrordDrProfttl = ""
  3935. order.CurrDrordFlag = "1"
  3936. orders = append(orders, &order)
  3937. }
  3938. if subItem.Type == 3 {
  3939. var order models.FsiOrderDtos
  3940. order.RxID = strconv.FormatInt(item.ID, 10)
  3941. order.Rxno = strconv.FormatInt(item.ID, 10)
  3942. order.LongDrordFlag = "0"
  3943. order.HilistType = "1"
  3944. order.ChrgType = "1"
  3945. order.DrordBhvr = "-"
  3946. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3947. order.HosplistName = subItem.GoodInfo.GoodName
  3948. order.HilistLv = "1"
  3949. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3950. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3951. order.HosplistName = subItem.GoodInfo.GoodName
  3952. order.Cnt = subItem.Count
  3953. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3954. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3955. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3956. order.OwnpayAmt = ""
  3957. order.SelfpayAmt = ""
  3958. order.Spec = ""
  3959. order.SpecUnt = ""
  3960. order.DrordBegnDate = s_tm
  3961. order.DrordStopDate = ""
  3962. order.DrordDrCodg = "1"
  3963. order.DrordDeptName = department.Name
  3964. order.DrordDrCodg = "1"
  3965. order.DrordDrName = doctor_info.UserName
  3966. order.DrordDrProfttl = ""
  3967. order.CurrDrordFlag = "1"
  3968. orders = append(orders, &order)
  3969. }
  3970. }
  3971. }
  3972. //处方医嘱信息
  3973. }
  3974. fed.MatnStas = "0"
  3975. fed.MedfeeSumamt = "0"
  3976. fed.OwnpayAmt = "0"
  3977. fed.SelfpayAmt = "0"
  3978. fed.AcctPayamt = "0"
  3979. fed.MaAmt = "0"
  3980. fed.HifpPayamt = "0"
  3981. fed.SetlTotlnum = "1"
  3982. fed.Insutype = his.Insutype
  3983. fed.ReimFlag = "0"
  3984. fed.OutSetlFlag = "0"
  3985. var fopd []*models.FsiOperationDtosData
  3986. data := make(map[string]interface{})
  3987. data["fed"] = fed
  3988. data["fdd"] = fdds
  3989. data["fod"] = orders
  3990. data["pd"] = pd
  3991. data["pp"] = pp
  3992. data["fopd"] = fopd
  3993. data["trig_scen"] = trig_scen
  3994. fmt.Println(data)
  3995. fmt.Println(fed)
  3996. fmt.Println(fdds)
  3997. fmt.Println(orders)
  3998. fmt.Println(pd)
  3999. fmt.Println(pp)
  4000. fmt.Println(fopd)
  4001. client := &http.Client{}
  4002. bytesData, _ := json.Marshal(data)
  4003. var req *http.Request
  4004. if miConfig.MdtrtareaAdmvs == "320921" {
  4005. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4006. } else {
  4007. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4008. }
  4009. resp, _ := client.Do(req)
  4010. defer resp.Body.Close()
  4011. body, ioErr := ioutil.ReadAll(resp.Body)
  4012. if ioErr != nil {
  4013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. return res
  4016. }
  4017. var respJSON map[string]interface{}
  4018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4021. return res
  4022. }
  4023. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4024. result, _ := json.Marshal(respJSON)
  4025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4026. utils.ErrorLog("解析失败:%v", err)
  4027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4028. return res
  4029. }
  4030. return res
  4031. }
  4032. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  4033. ////patient_id, _ := c.GetInt64("patient_id")
  4034. //order_id, _ := c.GetInt64("order_id")
  4035. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  4036. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  4037. //trig_scen := c.GetString("trig_scen")
  4038. adminUser := c.GetAdminUserInfo()
  4039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4040. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4041. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4042. record_time := c.GetString("record_time")
  4043. order, _ := service.GetHisOrderByID(order_id)
  4044. timeLayout := "2006-01-02"
  4045. loc, _ := time.LoadLocation("Local")
  4046. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4047. if err != nil {
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4049. return
  4050. }
  4051. recordDateTime := theTime.Unix()
  4052. var patientPrescription models.HisPrescriptionInfo
  4053. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4054. if patientPrescription.ID == 0 {
  4055. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4056. }
  4057. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4058. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4059. //
  4060. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4061. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4062. var pp models.PublicParams
  4063. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4064. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4065. pp.FixmedinsName = miConfig.OrgName
  4066. pp.FixmedinsCode = miConfig.Code
  4067. pp.RequestUrl = miConfig.Url
  4068. pp.Cainfo = miConfig.Cainfo
  4069. pp.SecretKey = miConfig.SecretKey
  4070. pp.AccessKey = miConfig.AccessKey
  4071. pp.OpterName = roles.UserName
  4072. var config []*models.HisXtDiagnoseConfig
  4073. for _, item := range diagnosis_ids {
  4074. id, _ := strconv.ParseInt(item, 10, 64)
  4075. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4076. config = append(config, &diagnosisConfig)
  4077. }
  4078. var pd models.PatientDtos
  4079. pd.PatnID = his.PsnNo
  4080. pd.PatnName = his.Name
  4081. pd.Gend = his.Gend
  4082. pd.Brdy = his.Brdy
  4083. pd.Poolarea = his.InsuplcAdmdvs
  4084. pd.CurrMdtrtID = his.Number
  4085. var fed models.FsiEncounterDtos
  4086. fed.MdtrtID = his.Number
  4087. fed.MedinsID = miConfig.Code
  4088. fed.MedinsName = miConfig.OrgName
  4089. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4090. fed.MedMdtrtType = "1"
  4091. fed.MedinsType = "1"
  4092. fed.MedinsLv = "11"
  4093. tm := time.Unix(his.RecordDate, 0)
  4094. s_tm := tm.Format("2006-01-02 15:04:05")
  4095. fed.AdmDate = s_tm
  4096. fed.DscgDate = s_tm
  4097. fed.DscgMainDiseCodg = config[0].CountryCode
  4098. fed.DscgMainDiseName = config[0].CountryContentName
  4099. //诊断信息
  4100. var fdds []*models.FsiDiagnoseDtos
  4101. for index, item := range config {
  4102. if index == 0 {
  4103. var fdd models.FsiDiagnoseDtos
  4104. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4105. fdd.InoutDiseType = "1"
  4106. fdd.MaindiseFlag = "1"
  4107. fdd.DiseDate = s_tm
  4108. fdd.DiasSrtNo = "1"
  4109. fdd.DiseName = item.CountryContentName
  4110. fdd.DiseCodg = item.CountryCode
  4111. fdds = append(fdds, &fdd)
  4112. } else {
  4113. var fdd models.FsiDiagnoseDtos
  4114. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4115. fdd.InoutDiseType = "1"
  4116. fdd.MaindiseFlag = "1"
  4117. fdd.DiseDate = s_tm
  4118. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4119. fdd.DiseName = item.CountryContentName
  4120. fdd.DiseCodg = item.CountryCode
  4121. fdds = append(fdds, &fdd)
  4122. }
  4123. }
  4124. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4125. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4126. fed.AdmDeptName = department.Name
  4127. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4128. fed.DscgDeptName = department.Name
  4129. fed.MedType = order.MedType
  4130. //处方医嘱信息
  4131. var orders []*models.FsiOrderDtos
  4132. //for _, item := range prescriptions {
  4133. // for _, subItem := range item.HisDoctorAdviceInfo {
  4134. // var order models.FsiOrderDtos
  4135. // order.RxID = strconv.FormatInt(item.ID, 10)
  4136. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4137. // order.LongDrordFlag = "0"
  4138. // order.HilistType = "1"
  4139. // order.ChrgType = "1"
  4140. // order.DrordBhvr = "-"
  4141. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4142. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4143. // order.HilistLv = "1"
  4144. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4145. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4146. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4147. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  4148. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4149. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  4150. // order.OwnpayAmt = ""
  4151. // order.SelfpayAmt = ""
  4152. // order.Spec = ""
  4153. // order.SpecUnt = ""
  4154. // order.DrordBegnDate = s_tm
  4155. // order.DrordStopDate = ""
  4156. // order.DrordDrCodg = "1"
  4157. // order.DrordDeptName = department.Name
  4158. // order.DrordDrCodg = "1"
  4159. // order.DrordDrName = doctor_info.UserName
  4160. // order.DrordDrProfttl = ""
  4161. // order.CurrDrordFlag = "1"
  4162. // orders = append(orders, &order)
  4163. // }
  4164. // for _, subItem := range item.HisPrescriptionProject {
  4165. // if subItem.Type == 2 {
  4166. // var order models.FsiOrderDtos
  4167. // order.RxID = strconv.FormatInt(item.ID, 10)
  4168. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4169. // order.LongDrordFlag = "0"
  4170. // order.HilistType = "1"
  4171. // order.ChrgType = "1"
  4172. // order.DrordBhvr = "-"
  4173. // order.HilistCode = subItem.HisProject.MedicalCode
  4174. // order.HosplistName = subItem.HisProject.ProjectName
  4175. // order.HilistLv = "1"
  4176. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4177. // order.HosplistCode = subItem.HisProject.MedicalCode
  4178. // order.HosplistName = subItem.HisProject.ProjectName
  4179. // order.Cnt = subItem.Count
  4180. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4181. //
  4182. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4183. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4184. // order.OwnpayAmt = ""
  4185. // order.SelfpayAmt = ""
  4186. // order.Spec = ""
  4187. // order.SpecUnt = ""
  4188. // order.DrordBegnDate = s_tm
  4189. // order.DrordStopDate = ""
  4190. // order.DrordDrCodg = "1"
  4191. // order.DrordDeptName = department.Name
  4192. // order.DrordDrCodg = "1"
  4193. // order.DrordDrName = doctor_info.UserName
  4194. // order.DrordDrProfttl = ""
  4195. // order.CurrDrordFlag = "1"
  4196. // orders = append(orders, &order)
  4197. //
  4198. // }
  4199. // if subItem.Type == 3 {
  4200. //
  4201. // var order models.FsiOrderDtos
  4202. // order.RxID = strconv.FormatInt(item.ID, 10)
  4203. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4204. // order.LongDrordFlag = "0"
  4205. // order.HilistType = "1"
  4206. // order.ChrgType = "1"
  4207. // order.DrordBhvr = "-"
  4208. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4209. // order.HosplistName = subItem.GoodInfo.GoodName
  4210. // order.HilistLv = "1"
  4211. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4212. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4213. // order.HosplistName = subItem.GoodInfo.GoodName
  4214. // order.Cnt = subItem.Count
  4215. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4216. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4217. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4218. // order.OwnpayAmt = ""
  4219. // order.SelfpayAmt = ""
  4220. // order.Spec = ""
  4221. // order.SpecUnt = ""
  4222. // order.DrordBegnDate = s_tm
  4223. // order.DrordStopDate = ""
  4224. // order.DrordDrCodg = "1"
  4225. // order.DrordDeptName = department.Name
  4226. // order.DrordDrCodg = "1"
  4227. // order.DrordDrName = doctor_info.UserName
  4228. // order.DrordDrProfttl = ""
  4229. // order.CurrDrordFlag = "1"
  4230. // orders = append(orders, &order)
  4231. //
  4232. // }
  4233. // }
  4234. //}
  4235. for _, item := range prescriptions {
  4236. for _, subItem := range item.HisDoctorAdviceInfo {
  4237. var order models.FsiOrderDtos
  4238. order.RxID = strconv.FormatInt(item.ID, 10)
  4239. order.Rxno = strconv.FormatInt(item.ID, 10)
  4240. order.LongDrordFlag = "0"
  4241. order.HilistType = "1"
  4242. order.ChrgType = "1"
  4243. order.DrordBhvr = "-"
  4244. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4245. order.HosplistName = subItem.BaseDrugLib.DrugName
  4246. order.HilistLv = "1"
  4247. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4248. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4249. order.HosplistName = subItem.BaseDrugLib.DrugName
  4250. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4252. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4253. order.OwnpayAmt = ""
  4254. order.SelfpayAmt = ""
  4255. order.Spec = ""
  4256. order.SpecUnt = ""
  4257. order.DrordBegnDate = s_tm
  4258. order.DrordStopDate = ""
  4259. order.DrordDrCodg = "1"
  4260. order.DrordDeptName = department.Name
  4261. order.DrordDrCodg = "1"
  4262. order.DrordDrName = doctor_info.UserName
  4263. order.DrordDrProfttl = ""
  4264. order.CurrDrordFlag = "1"
  4265. orders = append(orders, &order)
  4266. }
  4267. for _, subItem := range item.HisPrescriptionProject {
  4268. if subItem.Type == 2 {
  4269. var order models.FsiOrderDtos
  4270. order.RxID = strconv.FormatInt(item.ID, 10)
  4271. order.Rxno = strconv.FormatInt(item.ID, 10)
  4272. order.LongDrordFlag = "0"
  4273. order.HilistType = "1"
  4274. order.ChrgType = "1"
  4275. order.DrordBhvr = "-"
  4276. order.HilistCode = subItem.HisProject.MedicalCode
  4277. order.HosplistName = subItem.HisProject.ProjectName
  4278. order.HilistLv = "1"
  4279. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4280. order.HosplistCode = subItem.HisProject.MedicalCode
  4281. order.HosplistName = subItem.HisProject.ProjectName
  4282. order.Cnt = subItem.Count
  4283. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4284. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4285. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4286. order.OwnpayAmt = ""
  4287. order.SelfpayAmt = ""
  4288. order.Spec = ""
  4289. order.SpecUnt = ""
  4290. order.DrordBegnDate = s_tm
  4291. order.DrordStopDate = ""
  4292. order.DrordDrCodg = "1"
  4293. order.DrordDeptName = department.Name
  4294. order.DrordDrCodg = "1"
  4295. order.DrordDrName = doctor_info.UserName
  4296. order.DrordDrProfttl = ""
  4297. order.CurrDrordFlag = "1"
  4298. orders = append(orders, &order)
  4299. }
  4300. if subItem.Type == 3 {
  4301. var order models.FsiOrderDtos
  4302. order.RxID = strconv.FormatInt(item.ID, 10)
  4303. order.Rxno = strconv.FormatInt(item.ID, 10)
  4304. order.LongDrordFlag = "0"
  4305. order.HilistType = "1"
  4306. order.ChrgType = "1"
  4307. order.DrordBhvr = "-"
  4308. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4309. order.HosplistName = subItem.GoodInfo.GoodName
  4310. order.HilistLv = "1"
  4311. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4312. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4313. order.HosplistName = subItem.GoodInfo.GoodName
  4314. order.Cnt = subItem.Count
  4315. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4316. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4317. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4318. order.OwnpayAmt = ""
  4319. order.SelfpayAmt = ""
  4320. order.Spec = ""
  4321. order.SpecUnt = ""
  4322. order.DrordBegnDate = s_tm
  4323. order.DrordStopDate = ""
  4324. order.DrordDrCodg = "1"
  4325. order.DrordDeptName = department.Name
  4326. order.DrordDrCodg = "1"
  4327. order.DrordDrName = doctor_info.UserName
  4328. order.DrordDrProfttl = ""
  4329. order.CurrDrordFlag = "1"
  4330. orders = append(orders, &order)
  4331. }
  4332. }
  4333. }
  4334. //处方医嘱信息
  4335. fed.MatnStas = "0"
  4336. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4337. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  4338. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  4339. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  4340. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  4341. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  4342. fed.SetlTotlnum = "1"
  4343. fed.Insutype = his.Insutype
  4344. fed.ReimFlag = "0"
  4345. fed.OutSetlFlag = "0"
  4346. var fopd []*models.FsiOperationDtosData
  4347. data := make(map[string]interface{})
  4348. data["fed"] = fed
  4349. data["fdd"] = fdds
  4350. data["fod"] = orders
  4351. data["pd"] = pd
  4352. data["pp"] = pp
  4353. data["fopd"] = fopd
  4354. data["trig_scen"] = trig_scen
  4355. client := &http.Client{}
  4356. bytesData, _ := json.Marshal(data)
  4357. var req *http.Request
  4358. if miConfig.MdtrtareaAdmvs == "320921" {
  4359. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4360. } else {
  4361. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4362. }
  4363. resp, _ := client.Do(req)
  4364. defer resp.Body.Close()
  4365. body, ioErr := ioutil.ReadAll(resp.Body)
  4366. if ioErr != nil {
  4367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4369. return res
  4370. }
  4371. var respJSON map[string]interface{}
  4372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4375. return res
  4376. }
  4377. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4378. result, _ := json.Marshal(respJSON)
  4379. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4380. utils.ErrorLog("解析失败:%v", err)
  4381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. return res
  4383. }
  4384. return res
  4385. //手术操作集合
  4386. //手术操作集合
  4387. }
  4388. func (c *HisApiController) Check() {
  4389. psn_no := c.GetString("psn_no")
  4390. in := c.GetString("in")
  4391. mt := c.GetString("mt")
  4392. baseParams := models.BaseParams{
  4393. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  4394. FixmedinsCode: "H15049901371",
  4395. InsuplcAdmdvs: "150499",
  4396. MdtrtareaAdmvs: "150499",
  4397. OrgName: "赤峰费森血液透析中心",
  4398. Doctor: "1111",
  4399. }
  4400. service.Gdyb2001(baseParams, psn_no, in, mt)
  4401. }
  4402. func (c *HisApiController) GetPsnNcdsInfo() {
  4403. admin_user_id, _ := c.GetInt64("admin_user_id")
  4404. patient_id, _ := c.GetInt64("patient_id")
  4405. id, _ := c.GetInt64("id")
  4406. adminUser := c.GetAdminUserInfo()
  4407. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4408. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4409. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  4410. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4411. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4412. //
  4413. //if psn_record.ID == 0 {
  4414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4415. // return
  4416. //}
  4417. var res Result5301
  4418. var res10265 Result5301For10265
  4419. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4420. psn_info, _ := service.GetPsnByPatientId(patient_id)
  4421. var api string
  4422. if miConfig.MdtrtareaAdmvs == "320921" {
  4423. api = "http://192.168.2.3:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  4424. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4425. } else {
  4426. 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 +
  4427. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4428. }
  4429. resp, requestErr := http.Get(api)
  4430. if requestErr != nil {
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. return
  4433. }
  4434. body, ioErr := ioutil.ReadAll(resp.Body)
  4435. if ioErr != nil {
  4436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. var respJSON map[string]interface{}
  4441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4444. return
  4445. }
  4446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4447. result, _ := json.Marshal(respJSON)
  4448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4449. utils.ErrorLog("解析失败:%v", err)
  4450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4451. return
  4452. }
  4453. res.ErrMsg = res10265.ErrMsg
  4454. res.Output = res10265.Output
  4455. res.InfRefmsgid = res10265.InfRefmsgid
  4456. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4457. res.Infcode = infocode
  4458. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4459. p, _ := service.GetHisPatientById(patient_id)
  4460. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4461. var dat map[string]interface{}
  4462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4463. fmt.Println(dat)
  4464. } else {
  4465. fmt.Println(err)
  4466. }
  4467. userJSONBytes, _ := json.Marshal(dat)
  4468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4469. utils.ErrorLog("解析失败:%v", err)
  4470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4471. return
  4472. }
  4473. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4474. p, _ := service.GetHisPatientById(patient_id)
  4475. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4476. var dat map[string]interface{}
  4477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4478. fmt.Println(dat)
  4479. } else {
  4480. fmt.Println(err)
  4481. }
  4482. userJSONBytes, _ := json.Marshal(dat)
  4483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4484. utils.ErrorLog("解析失败:%v", err)
  4485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. return
  4487. }
  4488. } else {
  4489. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4490. var dat map[string]interface{}
  4491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4492. fmt.Println(dat)
  4493. } else {
  4494. fmt.Println(err)
  4495. }
  4496. userJSONBytes, _ := json.Marshal(dat)
  4497. if miConfig.Code == "H15049901371" {
  4498. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  4499. utils.ErrorLog("解析失败:%v", err)
  4500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4501. return
  4502. }
  4503. res.InfRefmsgid = res10265.InfRefmsgid
  4504. res.Output = res10265.Output
  4505. res.ErrMsg = res10265.ErrMsg
  4506. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4507. res.Infcode = infocode
  4508. } else {
  4509. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4510. utils.ErrorLog("解析失败:%v", err)
  4511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4512. return
  4513. }
  4514. }
  4515. }
  4516. if res.Infcode == 0 {
  4517. c.ServeSuccessJSON(map[string]interface{}{
  4518. "result": res.Output.Result,
  4519. })
  4520. }
  4521. }
  4522. func (c *HisApiController) CheckInsutype() {
  4523. his_patient_id, _ := c.GetInt64("his_patient_id")
  4524. admin_user_id, _ := c.GetInt64("admin_user_id")
  4525. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4526. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4527. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4528. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4529. var dat map[string]interface{}
  4530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4531. fmt.Println(dat)
  4532. } else {
  4533. fmt.Println(err)
  4534. }
  4535. userJSONBytes, _ := json.Marshal(dat)
  4536. var res Result90100
  4537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4538. utils.ErrorLog("解析失败:%v", err)
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4540. return
  4541. }
  4542. if res.Infcode != 0 {
  4543. c.ServeSuccessJSON(map[string]interface{}{
  4544. "failed_code": -10,
  4545. "msg": res.ErrMsg,
  4546. })
  4547. return
  4548. } else {
  4549. fmt.Println(res)
  4550. }
  4551. }
  4552. func (c *HisApiController) CheckCardPWD() {
  4553. card_pwd := c.GetString("card_pwd")
  4554. his_patient_id, _ := c.GetInt64("his_patient_id")
  4555. admin_user_id, _ := c.GetInt64("admin_user_id")
  4556. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4558. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4559. psn, _ := service.GetPsnByPatientId(his.PatientId)
  4560. bas := strings.Split(psn.CardInfo, "|")
  4561. basNumber := bas[2]
  4562. if psn.InsuplcAdmdvs[:4] == "4403" {
  4563. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  4564. var dat map[string]interface{}
  4565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4566. fmt.Println(dat)
  4567. } else {
  4568. fmt.Println(err)
  4569. }
  4570. userJSONBytes, _ := json.Marshal(dat)
  4571. var res Result90991
  4572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4573. utils.ErrorLog("解析失败:%v", err)
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. return
  4576. }
  4577. if res.Infcode != 0 {
  4578. c.ServeSuccessJSON(map[string]interface{}{
  4579. "failed_code": -10,
  4580. "msg": res.ErrMsg,
  4581. })
  4582. return
  4583. } else {
  4584. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  4585. var msg string
  4586. switch res.Output.Result.CardStat {
  4587. case "00":
  4588. msg = "未激活"
  4589. break
  4590. case "10":
  4591. msg = "激活"
  4592. break
  4593. case "20":
  4594. msg = "窗口挂失"
  4595. break
  4596. case "21":
  4597. msg = "电话挂失"
  4598. break
  4599. case "22":
  4600. msg = "单位网上申报挂失"
  4601. break
  4602. case "23":
  4603. msg = "保健办挂失"
  4604. break
  4605. case "24":
  4606. msg = "个人网上挂失"
  4607. break
  4608. case "25":
  4609. msg = "网上服务大厅挂失"
  4610. break
  4611. case "30":
  4612. msg = "注销"
  4613. break
  4614. case "40":
  4615. msg = "回收"
  4616. break
  4617. case "99":
  4618. msg = "制卡中(无效卡)"
  4619. break
  4620. }
  4621. c.ServeSuccessJSON(map[string]interface{}{
  4622. "failed_code": -10,
  4623. "msg": msg,
  4624. })
  4625. return
  4626. } else {
  4627. c.ServeSuccessJSON(map[string]interface{}{
  4628. "msg": "校验成功",
  4629. })
  4630. return
  4631. }
  4632. }
  4633. } else {
  4634. c.ServeSuccessJSON(map[string]interface{}{
  4635. "msg": "校验成功",
  4636. })
  4637. return
  4638. }
  4639. }
  4640. func (c *HisApiController) CheckCardPWDTwo() {
  4641. //card_pwd := c.GetString("card_pwd")
  4642. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4643. admin_user_id, _ := c.GetInt64("admin_user_id")
  4644. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4645. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4646. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  4647. var dat map[string]interface{}
  4648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4649. fmt.Println(dat)
  4650. } else {
  4651. fmt.Println(err)
  4652. }
  4653. userJSONBytes, _ := json.Marshal(dat)
  4654. var res Result90991
  4655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. if res.Infcode != 0 {
  4661. c.ServeSuccessJSON(map[string]interface{}{
  4662. "failed_code": -10,
  4663. "msg": res.ErrMsg,
  4664. })
  4665. return
  4666. } else {
  4667. if res.Output.Result.SscnoCheckStat == "0" {
  4668. var msg string
  4669. switch res.Output.Result.CardStat {
  4670. case "00":
  4671. msg = "未激活"
  4672. break
  4673. case "10":
  4674. msg = "激活"
  4675. break
  4676. case "20":
  4677. msg = "窗口挂失"
  4678. break
  4679. case "21":
  4680. msg = "电话挂失"
  4681. break
  4682. case "22":
  4683. msg = "单位网上申报挂失"
  4684. break
  4685. case "23":
  4686. msg = "保健办挂失"
  4687. break
  4688. case "24":
  4689. msg = "个人网上挂失"
  4690. break
  4691. case "25":
  4692. msg = "网上服务大厅挂失"
  4693. break
  4694. case "30":
  4695. msg = "注销"
  4696. break
  4697. case "40":
  4698. msg = "回收"
  4699. break
  4700. case "99":
  4701. msg = "制卡中(无效卡)"
  4702. break
  4703. }
  4704. c.ServeSuccessJSON(map[string]interface{}{
  4705. "failed_code": -10,
  4706. "msg": msg,
  4707. })
  4708. return
  4709. } else {
  4710. c.ServeSuccessJSON(map[string]interface{}{
  4711. "msg": "校验成功",
  4712. })
  4713. return
  4714. }
  4715. }
  4716. }
  4717. type ELeCertData struct {
  4718. Data struct {
  4719. Extra string `json:"extra"`
  4720. IDNo string `json:"idNo"`
  4721. IDType string `json:"idType"`
  4722. EcToken string `json:"ecToken"`
  4723. InsuOrg string `json:"insuOrg"`
  4724. UserName string `json:"userName"`
  4725. EcIndexNo string `json:"ecIndexNo"`
  4726. Gender string `json:"gender"`
  4727. Birthday string `json:"birthday"`
  4728. Nationality string `json:"nationality"`
  4729. Email string `json:"email"`
  4730. } `json:"OutData"`
  4731. }
  4732. func (c *HisApiController) ReadCard() {
  4733. id_card_type, _ := c.GetInt64("id_card_type")
  4734. admin_user_id, _ := c.GetInt64("admin_user_id")
  4735. certificates, _ := c.GetInt64("certificates")
  4736. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  4737. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4739. switch id_card_type {
  4740. case 1:
  4741. if miConfig.MdtrtareaAdmvs == "421300" {
  4742. var res ResultTwo
  4743. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  4744. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4745. "&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)
  4746. resp, requestErr := http.Get(api)
  4747. if requestErr != nil {
  4748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4749. return
  4750. }
  4751. body, ioErr := ioutil.ReadAll(resp.Body)
  4752. if ioErr != nil {
  4753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. var respJSON map[string]interface{}
  4758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. return
  4762. }
  4763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4764. result, _ := json.Marshal(respJSON)
  4765. fmt.Println("log")
  4766. fmt.Println(string(result))
  4767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4768. utils.ErrorLog("解析失败:%v", err)
  4769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4770. return
  4771. }
  4772. if res.Infcode == 0 {
  4773. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4774. if err == gorm.ErrRecordNotFound {
  4775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4776. return
  4777. } else if err != nil {
  4778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4779. return
  4780. } else {
  4781. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4782. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4783. infoStr := string(Iinfos)
  4784. idetinfoStr := string(Idetinfos)
  4785. psn := &models.HisPsn{
  4786. PsnNo: res.Output.Baseinfo.PsnNo,
  4787. Age: res.Output.Baseinfo.Age,
  4788. PatientId: patient.ID,
  4789. Certno: res.Output.Baseinfo.Certno,
  4790. Brdy: res.Output.Baseinfo.Brdy,
  4791. Gend: res.Output.Baseinfo.Gend,
  4792. Naty: res.Output.Baseinfo.Naty,
  4793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4794. PsnName: res.Output.Baseinfo.PsnName,
  4795. Idetinfo: idetinfoStr,
  4796. Insuinfo: infoStr,
  4797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4798. }
  4799. service.CreateHisPsn(psn)
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "patient": patient,
  4802. "number": res.Output.Baseinfo.Certno,
  4803. })
  4804. }
  4805. } else {
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4807. return
  4808. }
  4809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4810. var api string
  4811. if miConfig.MdtrtareaAdmvs == "320921" {
  4812. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4813. "&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
  4814. fmt.Println(api)
  4815. } else {
  4816. 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 +
  4817. "&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)
  4818. }
  4819. resp, requestErr := http.Get(api)
  4820. if requestErr != nil {
  4821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4822. return
  4823. }
  4824. body, ioErr := ioutil.ReadAll(resp.Body)
  4825. if ioErr != nil {
  4826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4828. return
  4829. }
  4830. var respJSON map[string]interface{}
  4831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. return
  4835. }
  4836. var status string
  4837. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4838. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4839. //console.log()
  4840. fmt.Println("type===")
  4841. fmt.Println(card_type)
  4842. var token string
  4843. var res ResultTwo //1101结果
  4844. var res10265 ResultTwo10265 //1101结果
  4845. var card_info string //卡信息
  4846. var busi_card_info string
  4847. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4848. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4849. if status == "0" { //读卡成功
  4850. if card_type == "1" {
  4851. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4852. result, _ := json.Marshal(respJSON)
  4853. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4854. utils.ErrorLog("解析失败:%v", err)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. res.ErrMsg = res10265.ErrMsg
  4859. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4860. res.Infcode = infocode
  4861. res.Output = res10265.Output
  4862. res.InfRefmsgid = res10265.InfRefmsgid
  4863. } else {
  4864. //var card_info string //卡信息
  4865. //var busi_card_info string
  4866. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4867. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4868. //fmt.Println(card_info)
  4869. //fmt.Println(busi_card_info)
  4870. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4871. result, _ := json.Marshal(respJSON)
  4872. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4875. return
  4876. }
  4877. res.ErrMsg = res10265.ErrMsg
  4878. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4879. res.Infcode = infocode
  4880. res.Output = res10265.Output
  4881. res.InfRefmsgid = res10265.InfRefmsgid
  4882. }
  4883. if res.Infcode == 0 {
  4884. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4885. if err == gorm.ErrRecordNotFound {
  4886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4887. return
  4888. } else if err != nil {
  4889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4890. return
  4891. } else {
  4892. if card_type == "1" {
  4893. bas := strings.Split(card_info, "|")
  4894. basNumber := bas[2]
  4895. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4896. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4897. infoStr := string(Iinfos)
  4898. idetinfoStr := string(Idetinfos)
  4899. psn := &models.HisPsn{
  4900. PsnNo: res.Output.Baseinfo.PsnNo,
  4901. Age: res.Output.Baseinfo.Age,
  4902. PatientId: patient.ID,
  4903. Certno: res.Output.Baseinfo.Certno,
  4904. Brdy: res.Output.Baseinfo.Brdy,
  4905. Gend: res.Output.Baseinfo.Gend,
  4906. Naty: res.Output.Baseinfo.Naty,
  4907. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4908. PsnName: res.Output.Baseinfo.PsnName,
  4909. Idetinfo: idetinfoStr,
  4910. Insuinfo: infoStr,
  4911. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4912. CardInfo: card_info,
  4913. VerifyNumber: busi_card_info,
  4914. }
  4915. service.CreateHisPsn(psn)
  4916. var rf []*ResultFive
  4917. json.Unmarshal([]byte(infoStr), &rf)
  4918. var insutypes []*ResultFive
  4919. var insutype string
  4920. var is390 int = 0
  4921. var is310 int = 0
  4922. for _, item := range rf {
  4923. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4924. insutypes = append(insutypes, item)
  4925. }
  4926. }
  4927. if len(insutypes) == 1 {
  4928. insutype = insutypes[0].Insutype
  4929. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4930. } else {
  4931. for _, i := range insutypes {
  4932. if i.Insutype == "390" {
  4933. is390 = 1
  4934. }
  4935. if i.Insutype == "310" {
  4936. is310 = 1
  4937. }
  4938. }
  4939. }
  4940. if is390 == 1 {
  4941. insutype = "390"
  4942. }
  4943. if is310 == 1 {
  4944. insutype = "310"
  4945. }
  4946. if len(insutypes) == 0 {
  4947. insutype = "310"
  4948. }
  4949. c.ServeSuccessJSON(map[string]interface{}{
  4950. "patient": patient,
  4951. "number": basNumber,
  4952. "insutype": insutype,
  4953. })
  4954. } else {
  4955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4957. infoStr := string(Iinfos)
  4958. idetinfoStr := string(Idetinfos)
  4959. psn := &models.HisPsn{
  4960. PsnNo: res.Output.Baseinfo.PsnNo,
  4961. Age: res.Output.Baseinfo.Age,
  4962. PatientId: patient.ID,
  4963. Certno: res.Output.Baseinfo.Certno,
  4964. Brdy: res.Output.Baseinfo.Brdy,
  4965. Gend: res.Output.Baseinfo.Gend,
  4966. Naty: res.Output.Baseinfo.Naty,
  4967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4968. PsnName: res.Output.Baseinfo.PsnName,
  4969. Idetinfo: idetinfoStr,
  4970. Insuinfo: infoStr,
  4971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4972. CardInfo: card_info,
  4973. VerifyNumber: token,
  4974. }
  4975. service.CreateHisPsn(psn)
  4976. c.ServeSuccessJSON(map[string]interface{}{
  4977. "patient": patient,
  4978. "number": token,
  4979. })
  4980. }
  4981. }
  4982. } else {
  4983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4984. return
  4985. }
  4986. } else { //读卡失败
  4987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4988. return
  4989. }
  4990. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4991. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  4992. cardnum = DeleteExtraSpaceTwo(cardnum)
  4993. cardCode = DeleteExtraSpaceTwo(cardCode)
  4994. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  4995. name = DeleteExtraSpaceTwo(name)
  4996. errmsg = DeleteExtraSpaceTwo(errmsg)
  4997. cardnum = Remove0000(cardnum)
  4998. cardCode = Remove0000(cardCode)
  4999. id_card_no = Remove0000(id_card_no)
  5000. name = Remove0000(name)
  5001. errmsg = Remove0000(errmsg)
  5002. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  5003. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  5004. //result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  5005. //fmt.Println(result2)
  5006. //fmt.Println(requestLog2)
  5007. //fmt.Println(errMsgLog2)
  5008. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  5009. saveLog(result, requestLog, "1101", "获取人员信息")
  5010. fmt.Println(errMsgLog)
  5011. if len(errMsgLog) > 0 {
  5012. } else {
  5013. var dat map[string]interface{}
  5014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5015. fmt.Println(dat)
  5016. } else {
  5017. fmt.Println(err)
  5018. }
  5019. userJSONBytes, _ := json.Marshal(dat)
  5020. var res ResultTwo
  5021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5022. utils.ErrorLog("解析失败:%v", err)
  5023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5024. return
  5025. }
  5026. res.ErrMsg = errMsgLog
  5027. if res.Infcode == 0 {
  5028. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  5029. if err == gorm.ErrRecordNotFound {
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5031. return
  5032. } else if err != nil {
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5034. return
  5035. } else {
  5036. fmt.Println(res)
  5037. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5038. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5039. infoStr := string(Iinfos)
  5040. idetinfoStr := string(Idetinfos)
  5041. var rf []*ResultFive
  5042. json.Unmarshal([]byte(infoStr), &rf)
  5043. var insutypes []*ResultFive
  5044. var insutype string
  5045. var is390 int = 0
  5046. var is310 int = 0
  5047. for _, item := range rf {
  5048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5049. insutypes = append(insutypes, item)
  5050. }
  5051. }
  5052. if len(insutypes) == 1 {
  5053. insutype = insutypes[0].Insutype
  5054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5055. } else {
  5056. for _, i := range insutypes {
  5057. if i.Insutype == "390" {
  5058. is390 = 1
  5059. }
  5060. if i.Insutype == "310" {
  5061. is310 = 1
  5062. }
  5063. }
  5064. }
  5065. if is390 == 1 {
  5066. insutype = "390"
  5067. }
  5068. if is310 == 1 {
  5069. insutype = "310"
  5070. }
  5071. if len(insutypes) == 0 {
  5072. insutype = "390"
  5073. }
  5074. var insuplc_admdvs string
  5075. for _, item := range rf {
  5076. if item.Insutype == insutype {
  5077. insuplc_admdvs = item.InsuplcAdmdvs
  5078. }
  5079. }
  5080. psn := &models.HisPsn{
  5081. PsnNo: res.Output.Baseinfo.PsnNo,
  5082. Age: res.Output.Baseinfo.Age,
  5083. PatientId: patient.ID,
  5084. Certno: res.Output.Baseinfo.Certno,
  5085. Brdy: res.Output.Baseinfo.Brdy,
  5086. Gend: res.Output.Baseinfo.Gend,
  5087. Naty: res.Output.Baseinfo.Naty,
  5088. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5089. PsnName: res.Output.Baseinfo.PsnName,
  5090. Idetinfo: idetinfoStr,
  5091. Insuinfo: infoStr,
  5092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5093. CardInfo: basStr,
  5094. VerifyNumber: "",
  5095. InsuplcAdmdvs: insuplc_admdvs,
  5096. }
  5097. service.CreateHisPsn(psn)
  5098. c.ServeSuccessJSON(map[string]interface{}{
  5099. "patient": patient,
  5100. "number": cardnum,
  5101. "insutype": insutype,
  5102. })
  5103. }
  5104. } else {
  5105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5106. return
  5107. }
  5108. }
  5109. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5110. fmt.Println(initFlag)
  5111. fmt.Println("initFlag")
  5112. if initFlag == 0 {
  5113. c.TestGetJiangXiBasBaseInit()
  5114. }
  5115. basStr := c.GetBasBaseInfo()
  5116. if len(basStr) == 0 {
  5117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5118. return
  5119. }
  5120. fmt.Println(basStr)
  5121. bas := strings.Split(basStr, "|")
  5122. basNumber := bas[1]
  5123. fmt.Println(basNumber)
  5124. card_sn := bas[3]
  5125. fmt.Println(card_sn)
  5126. 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, "")
  5127. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5128. var dat map[string]interface{}
  5129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5130. fmt.Println(dat)
  5131. } else {
  5132. fmt.Println(err)
  5133. }
  5134. userJSONBytes, _ := json.Marshal(dat)
  5135. var res ResultTwo
  5136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5137. utils.ErrorLog("解析失败:%v", err)
  5138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5139. return
  5140. }
  5141. if res.Infcode == 0 {
  5142. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5143. if err == gorm.ErrRecordNotFound {
  5144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5145. return
  5146. } else if err != nil {
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5148. return
  5149. } else {
  5150. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5151. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5152. infoStr := string(Iinfos)
  5153. idetinfoStr := string(Idetinfos)
  5154. psn := &models.HisPsn{
  5155. PsnNo: res.Output.Baseinfo.PsnNo,
  5156. Age: res.Output.Baseinfo.Age,
  5157. PatientId: patient.ID,
  5158. Certno: res.Output.Baseinfo.Certno,
  5159. Brdy: res.Output.Baseinfo.Brdy,
  5160. Gend: res.Output.Baseinfo.Gend,
  5161. Naty: res.Output.Baseinfo.Naty,
  5162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5163. PsnName: res.Output.Baseinfo.PsnName,
  5164. Idetinfo: idetinfoStr,
  5165. Insuinfo: infoStr,
  5166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5167. CardInfo: basStr,
  5168. VerifyNumber: "",
  5169. }
  5170. service.CreateHisPsn(psn)
  5171. var rf []*ResultFive
  5172. json.Unmarshal([]byte(infoStr), &rf)
  5173. var insutypes []*ResultFive
  5174. var insutype string
  5175. var is390 int = 0
  5176. var is310 int = 0
  5177. for _, item := range rf {
  5178. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5179. insutypes = append(insutypes, item)
  5180. }
  5181. }
  5182. if len(insutypes) == 1 {
  5183. insutype = insutypes[0].Insutype
  5184. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5185. } else {
  5186. for _, i := range insutypes {
  5187. if i.Insutype == "390" {
  5188. is390 = 1
  5189. }
  5190. if i.Insutype == "310" {
  5191. is310 = 1
  5192. }
  5193. }
  5194. }
  5195. if is390 == 1 {
  5196. insutype = "390"
  5197. }
  5198. if is310 == 1 {
  5199. insutype = "310"
  5200. }
  5201. if len(insutypes) == 0 {
  5202. insutype = "310"
  5203. }
  5204. c.ServeSuccessJSON(map[string]interface{}{
  5205. "patient": patient,
  5206. "number": basNumber,
  5207. "insutype": insutype,
  5208. })
  5209. }
  5210. } else {
  5211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5212. return
  5213. }
  5214. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5215. fmt.Println(initFlag)
  5216. fmt.Println("initFlag")
  5217. if initFlag == 0 {
  5218. c.TestGetHnBasBaseInit()
  5219. }
  5220. basStr := c.GetBasBaseInfo()
  5221. if len(basStr) == 0 {
  5222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5223. return
  5224. }
  5225. fmt.Println(basStr)
  5226. bas := strings.Split(basStr, "|")
  5227. basNumber := bas[1]
  5228. fmt.Println(basNumber)
  5229. card_sn := bas[3]
  5230. card_no := bas[2]
  5231. fmt.Println(card_sn)
  5232. name := bas[4]
  5233. name = ConvertToString(name, "gbk", "utf-8")
  5234. 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)
  5235. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5236. var dat map[string]interface{}
  5237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5238. fmt.Println(dat)
  5239. } else {
  5240. fmt.Println(err)
  5241. }
  5242. userJSONBytes, _ := json.Marshal(dat)
  5243. var res ResultTwo
  5244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5245. utils.ErrorLog("解析失败:%v", err)
  5246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5247. return
  5248. }
  5249. if res.Infcode == 0 {
  5250. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5251. if err == gorm.ErrRecordNotFound {
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5253. return
  5254. } else if err != nil {
  5255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5256. return
  5257. } else {
  5258. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5259. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5260. infoStr := string(Iinfos)
  5261. idetinfoStr := string(Idetinfos)
  5262. psn := &models.HisPsn{
  5263. PsnNo: res.Output.Baseinfo.PsnNo,
  5264. Age: res.Output.Baseinfo.Age,
  5265. PatientId: patient.ID,
  5266. Certno: res.Output.Baseinfo.Certno,
  5267. Brdy: res.Output.Baseinfo.Brdy,
  5268. Gend: res.Output.Baseinfo.Gend,
  5269. Naty: res.Output.Baseinfo.Naty,
  5270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5271. PsnName: res.Output.Baseinfo.PsnName,
  5272. Idetinfo: idetinfoStr,
  5273. Insuinfo: infoStr,
  5274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5275. CardInfo: basStr,
  5276. VerifyNumber: "",
  5277. }
  5278. service.CreateHisPsn(psn)
  5279. var rf []*ResultFive
  5280. json.Unmarshal([]byte(infoStr), &rf)
  5281. var insutypes []*ResultFive
  5282. var insutype string
  5283. var is390 int = 0
  5284. var is310 int = 0
  5285. for _, item := range rf {
  5286. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5287. insutypes = append(insutypes, item)
  5288. }
  5289. }
  5290. if len(insutypes) == 1 {
  5291. insutype = insutypes[0].Insutype
  5292. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5293. } else {
  5294. for _, i := range insutypes {
  5295. if i.Insutype == "390" {
  5296. is390 = 1
  5297. }
  5298. if i.Insutype == "310" {
  5299. is310 = 1
  5300. }
  5301. }
  5302. }
  5303. if is390 == 1 {
  5304. insutype = "390"
  5305. }
  5306. if is310 == 1 {
  5307. insutype = "310"
  5308. }
  5309. if len(insutypes) == 0 {
  5310. insutype = "310"
  5311. }
  5312. c.ServeSuccessJSON(map[string]interface{}{
  5313. "patient": patient,
  5314. "number": basNumber,
  5315. "insutype": insutype,
  5316. })
  5317. }
  5318. } else {
  5319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5320. return
  5321. }
  5322. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5323. var api string
  5324. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5325. "&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
  5326. fmt.Println(api)
  5327. resp, requestErr := http.Get(api)
  5328. if requestErr != nil {
  5329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5330. return
  5331. }
  5332. body, ioErr := ioutil.ReadAll(resp.Body)
  5333. if ioErr != nil {
  5334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5336. return
  5337. }
  5338. var respJSON map[string]interface{}
  5339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5342. return
  5343. }
  5344. var status string
  5345. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5346. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5347. var token string
  5348. var res ResultTwo //1101结果
  5349. var res10265 ResultTwo10265 //1101结果
  5350. var card_info string //卡信息
  5351. var busi_card_info string
  5352. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5353. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5354. if status == "0" { //读卡成功
  5355. if card_type == "1" {
  5356. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5357. result, _ := json.Marshal(respJSON)
  5358. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5359. utils.ErrorLog("解析失败:%v", err)
  5360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5361. return
  5362. }
  5363. res.ErrMsg = res10265.ErrMsg
  5364. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5365. res.Infcode = infocode
  5366. res.Output = res10265.Output
  5367. res.InfRefmsgid = res10265.InfRefmsgid
  5368. } else {
  5369. //var card_info string //卡信息
  5370. //var busi_card_info string
  5371. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5372. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5373. //fmt.Println(card_info)
  5374. //fmt.Println(busi_card_info)
  5375. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5376. result, _ := json.Marshal(respJSON)
  5377. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5378. utils.ErrorLog("解析失败:%v", err)
  5379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5380. return
  5381. }
  5382. res.ErrMsg = res10265.ErrMsg
  5383. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5384. res.Infcode = infocode
  5385. res.Output = res10265.Output
  5386. res.InfRefmsgid = res10265.InfRefmsgid
  5387. }
  5388. if res.Infcode == 0 {
  5389. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5390. if err == gorm.ErrRecordNotFound {
  5391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5392. return
  5393. } else if err != nil {
  5394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5395. return
  5396. } else {
  5397. bas := strings.Split(card_info, "|")
  5398. basNumber := bas[2]
  5399. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5400. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5401. infoStr := string(Iinfos)
  5402. idetinfoStr := string(Idetinfos)
  5403. psn := &models.HisPsn{
  5404. PsnNo: res.Output.Baseinfo.PsnNo,
  5405. Age: res.Output.Baseinfo.Age,
  5406. PatientId: patient.ID,
  5407. Certno: res.Output.Baseinfo.Certno,
  5408. Brdy: res.Output.Baseinfo.Brdy,
  5409. Gend: res.Output.Baseinfo.Gend,
  5410. Naty: res.Output.Baseinfo.Naty,
  5411. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5412. PsnName: res.Output.Baseinfo.PsnName,
  5413. Idetinfo: idetinfoStr,
  5414. Insuinfo: infoStr,
  5415. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5416. CardInfo: card_info,
  5417. VerifyNumber: busi_card_info,
  5418. IdCardType: 1,
  5419. }
  5420. service.CreateHisPsn(psn)
  5421. var rf []*ResultFive
  5422. json.Unmarshal([]byte(infoStr), &rf)
  5423. var insutypes []*ResultFive
  5424. var insutype string
  5425. var is390 int = 0
  5426. var is310 int = 0
  5427. for _, item := range rf {
  5428. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5429. insutypes = append(insutypes, item)
  5430. }
  5431. }
  5432. if len(insutypes) == 1 {
  5433. insutype = insutypes[0].Insutype
  5434. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5435. } else {
  5436. for _, i := range insutypes {
  5437. if i.Insutype == "390" {
  5438. is390 = 1
  5439. }
  5440. if i.Insutype == "310" {
  5441. is310 = 1
  5442. }
  5443. }
  5444. }
  5445. if is390 == 1 {
  5446. insutype = "390"
  5447. }
  5448. if is310 == 1 {
  5449. insutype = "310"
  5450. }
  5451. if len(insutypes) == 0 {
  5452. insutype = "310"
  5453. }
  5454. c.ServeSuccessJSON(map[string]interface{}{
  5455. "patient": patient,
  5456. "number": basNumber,
  5457. "insutype": insutype,
  5458. })
  5459. }
  5460. } else {
  5461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5462. return
  5463. }
  5464. } else { //读卡失败
  5465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5466. return
  5467. }
  5468. } else {
  5469. if initFlag == 0 {
  5470. c.TestGetBasBaseInit()
  5471. }
  5472. basStr := c.GetBasBaseInfo()
  5473. if len(basStr) == 0 {
  5474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5475. return
  5476. }
  5477. fmt.Println(basStr)
  5478. bas := strings.Split(basStr, "|")
  5479. basNumber := bas[1]
  5480. fmt.Println(basNumber)
  5481. card_sn := bas[3]
  5482. fmt.Println(card_sn)
  5483. cardNumber := bas[2]
  5484. fmt.Println(cardNumber)
  5485. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  5486. var result string
  5487. if bas[0][:2] == "44" {
  5488. result = service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  5489. } else {
  5490. 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)
  5491. }
  5492. var dat map[string]interface{}
  5493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5494. fmt.Println(dat)
  5495. } else {
  5496. fmt.Println(err)
  5497. }
  5498. userJSONBytes, _ := json.Marshal(dat)
  5499. var res ResultTwo
  5500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5501. utils.ErrorLog("解析失败:%v", err)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. if res.Infcode == 0 {
  5506. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5507. if err == gorm.ErrRecordNotFound {
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5509. return
  5510. } else if err != nil {
  5511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5512. return
  5513. } else {
  5514. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5515. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5516. infoStr := string(Iinfos)
  5517. idetinfoStr := string(Idetinfos)
  5518. var rf []*ResultFive
  5519. json.Unmarshal([]byte(infoStr), &rf)
  5520. var insutypes []*ResultFive
  5521. var insutype string
  5522. var is390 int = 0
  5523. var is310 int = 0
  5524. var insuplc_admdvs string
  5525. for _, item := range rf {
  5526. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5527. insutypes = append(insutypes, item)
  5528. }
  5529. }
  5530. if len(insutypes) == 1 {
  5531. insutype = insutypes[0].Insutype
  5532. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5533. } else {
  5534. for _, i := range insutypes {
  5535. if i.Insutype == "390" {
  5536. is390 = 1
  5537. }
  5538. if i.Insutype == "310" {
  5539. is310 = 1
  5540. }
  5541. }
  5542. }
  5543. if is390 == 1 {
  5544. insutype = "390"
  5545. }
  5546. if is310 == 1 {
  5547. insutype = "310"
  5548. }
  5549. if len(insutypes) == 0 {
  5550. insutype = "310"
  5551. }
  5552. for _, item := range rf {
  5553. if item.Insutype == insutype {
  5554. insuplc_admdvs = item.InsuplcAdmdvs
  5555. }
  5556. }
  5557. psn := &models.HisPsn{
  5558. PsnNo: res.Output.Baseinfo.PsnNo,
  5559. Age: res.Output.Baseinfo.Age,
  5560. PatientId: patient.ID,
  5561. Certno: res.Output.Baseinfo.Certno,
  5562. Brdy: res.Output.Baseinfo.Brdy,
  5563. Gend: res.Output.Baseinfo.Gend,
  5564. Naty: res.Output.Baseinfo.Naty,
  5565. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5566. PsnName: res.Output.Baseinfo.PsnName,
  5567. Idetinfo: idetinfoStr,
  5568. Insuinfo: infoStr,
  5569. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5570. CardInfo: basStr,
  5571. VerifyNumber: "",
  5572. InsuplcAdmdvs: insuplc_admdvs,
  5573. }
  5574. service.CreateHisPsn(psn)
  5575. c.ServeSuccessJSON(map[string]interface{}{
  5576. "patient": patient,
  5577. "number": basNumber,
  5578. })
  5579. }
  5580. } else {
  5581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5582. return
  5583. }
  5584. break
  5585. }
  5586. case 2:
  5587. if miConfig.MdtrtareaAdmvs == "430800" {
  5588. if initFlag == 0 {
  5589. c.TestGetHnBasBaseInit()
  5590. }
  5591. SFZStr := c.GetSFZBaseInfo()
  5592. if len(SFZStr) == 0 {
  5593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5594. return
  5595. }
  5596. fmt.Println(SFZStr)
  5597. id_card_str := strings.Split(SFZStr, "^")
  5598. card_no := id_card_str[0]
  5599. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5600. //name := id_card_str[1]
  5601. //name = ConvertToString(name, "gbk", "utf-8")
  5602. 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)
  5603. var dat map[string]interface{}
  5604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5605. fmt.Println(dat)
  5606. } else {
  5607. fmt.Println(err)
  5608. }
  5609. userJSONBytes, _ := json.Marshal(dat)
  5610. var res ResultTwo
  5611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5612. utils.ErrorLog("解析失败:%v", err)
  5613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5614. return
  5615. }
  5616. if res.Infcode == 0 {
  5617. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5618. if err == gorm.ErrRecordNotFound {
  5619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5620. return
  5621. } else if err != nil {
  5622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5623. return
  5624. } else {
  5625. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5626. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5627. infoStr := string(Iinfos)
  5628. idetinfoStr := string(Idetinfos)
  5629. psn := &models.HisPsn{
  5630. PsnNo: res.Output.Baseinfo.PsnNo,
  5631. Age: res.Output.Baseinfo.Age,
  5632. PatientId: patient.ID,
  5633. Certno: res.Output.Baseinfo.Certno,
  5634. Brdy: res.Output.Baseinfo.Brdy,
  5635. Gend: res.Output.Baseinfo.Gend,
  5636. Naty: res.Output.Baseinfo.Naty,
  5637. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5638. PsnName: res.Output.Baseinfo.PsnName,
  5639. Idetinfo: idetinfoStr,
  5640. Insuinfo: infoStr,
  5641. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5642. CardInfo: SFZStr,
  5643. VerifyNumber: "",
  5644. }
  5645. service.CreateHisPsn(psn)
  5646. var rf []*ResultFive
  5647. json.Unmarshal([]byte(infoStr), &rf)
  5648. var insutypes []*ResultFive
  5649. var insutype string
  5650. var is390 int = 0
  5651. var is310 int = 0
  5652. for _, item := range rf {
  5653. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5654. insutypes = append(insutypes, item)
  5655. }
  5656. }
  5657. if len(insutypes) == 1 {
  5658. insutype = insutypes[0].Insutype
  5659. } else {
  5660. for _, i := range insutypes {
  5661. if i.Insutype == "390" {
  5662. is390 = 1
  5663. }
  5664. if i.Insutype == "310" {
  5665. is310 = 1
  5666. }
  5667. }
  5668. }
  5669. if is390 == 1 {
  5670. insutype = "390"
  5671. }
  5672. if is310 == 1 {
  5673. insutype = "310"
  5674. }
  5675. if len(insutypes) == 0 {
  5676. insutype = "310"
  5677. }
  5678. c.ServeSuccessJSON(map[string]interface{}{
  5679. "patient": patient,
  5680. "number": card_no,
  5681. "insutype": insutype,
  5682. })
  5683. }
  5684. } else {
  5685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5686. return
  5687. }
  5688. } else {
  5689. SFZStr := c.GetSFZBaseInfo()
  5690. id_card_str := strings.Split(SFZStr, "^")
  5691. id_card_number := id_card_str[0]
  5692. card_sn := ""
  5693. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  5694. var dat map[string]interface{}
  5695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5696. fmt.Println(dat)
  5697. } else {
  5698. fmt.Println(err)
  5699. }
  5700. userJSONBytes, _ := json.Marshal(dat)
  5701. var res ResultTwo
  5702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5703. utils.ErrorLog("解析失败:%v", err)
  5704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5705. return
  5706. }
  5707. if res.Infcode == 0 {
  5708. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  5709. if err == gorm.ErrRecordNotFound {
  5710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5711. return
  5712. } else if err != nil {
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5714. return
  5715. } else {
  5716. c.ServeSuccessJSON(map[string]interface{}{
  5717. "patient": patient,
  5718. "number": id_card_number,
  5719. })
  5720. }
  5721. } else {
  5722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5723. return
  5724. }
  5725. }
  5726. break
  5727. case 3:
  5728. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5729. var api string
  5730. if miConfig.MdtrtareaAdmvs == "320921" {
  5731. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5732. "&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
  5733. fmt.Println(api)
  5734. } else {
  5735. 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 +
  5736. "&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)
  5737. }
  5738. resp, requestErr := http.Get(api)
  5739. if requestErr != nil {
  5740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5741. return
  5742. }
  5743. body, ioErr := ioutil.ReadAll(resp.Body)
  5744. if ioErr != nil {
  5745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5747. return
  5748. }
  5749. var respJSON map[string]interface{}
  5750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5753. return
  5754. }
  5755. var status string
  5756. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5757. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5758. var token string
  5759. var res ResultTwo //1101结果
  5760. var res10265 ResultTwo10265 //1101结果
  5761. var card_info string //卡信息
  5762. var busi_card_info string
  5763. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5764. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5765. if status == "0" { //读卡成功
  5766. if card_type == "1" {
  5767. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5768. result, _ := json.Marshal(respJSON)
  5769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5770. utils.ErrorLog("解析失败:%v", err)
  5771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5772. return
  5773. }
  5774. res.ErrMsg = res10265.ErrMsg
  5775. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5776. res.Infcode = infocode
  5777. res.Output = res10265.Output
  5778. res.InfRefmsgid = res10265.InfRefmsgid
  5779. } else {
  5780. //var card_info string //卡信息
  5781. //var busi_card_info string
  5782. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5783. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5784. //fmt.Println(card_info)
  5785. //fmt.Println(busi_card_info)
  5786. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5787. result, _ := json.Marshal(respJSON)
  5788. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5789. utils.ErrorLog("解析失败:%v", err)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. res.ErrMsg = res10265.ErrMsg
  5794. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5795. res.Infcode = infocode
  5796. res.Output = res10265.Output
  5797. res.InfRefmsgid = res10265.InfRefmsgid
  5798. }
  5799. if res.Infcode == 0 {
  5800. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5801. if err == gorm.ErrRecordNotFound {
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5803. return
  5804. } else if err != nil {
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5806. return
  5807. } else {
  5808. if card_type == "1" {
  5809. bas := strings.Split(card_info, "|")
  5810. basNumber := bas[2]
  5811. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5812. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5813. infoStr := string(Iinfos)
  5814. idetinfoStr := string(Idetinfos)
  5815. psn := &models.HisPsn{
  5816. PsnNo: res.Output.Baseinfo.PsnNo,
  5817. Age: res.Output.Baseinfo.Age,
  5818. PatientId: patient.ID,
  5819. Certno: res.Output.Baseinfo.Certno,
  5820. Brdy: res.Output.Baseinfo.Brdy,
  5821. Gend: res.Output.Baseinfo.Gend,
  5822. Naty: res.Output.Baseinfo.Naty,
  5823. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5824. PsnName: res.Output.Baseinfo.PsnName,
  5825. Idetinfo: idetinfoStr,
  5826. Insuinfo: infoStr,
  5827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5828. CardInfo: card_info,
  5829. VerifyNumber: busi_card_info,
  5830. }
  5831. service.CreateHisPsn(psn)
  5832. c.ServeSuccessJSON(map[string]interface{}{
  5833. "patient": patient,
  5834. "number": basNumber,
  5835. })
  5836. } else {
  5837. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5838. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5839. infoStr := string(Iinfos)
  5840. idetinfoStr := string(Idetinfos)
  5841. psn := &models.HisPsn{
  5842. PsnNo: res.Output.Baseinfo.PsnNo,
  5843. Age: res.Output.Baseinfo.Age,
  5844. PatientId: patient.ID,
  5845. Certno: res.Output.Baseinfo.Certno,
  5846. Brdy: res.Output.Baseinfo.Brdy,
  5847. Gend: res.Output.Baseinfo.Gend,
  5848. Naty: res.Output.Baseinfo.Naty,
  5849. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5850. PsnName: res.Output.Baseinfo.PsnName,
  5851. Idetinfo: idetinfoStr,
  5852. Insuinfo: infoStr,
  5853. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5854. CardInfo: card_info,
  5855. VerifyNumber: token,
  5856. }
  5857. service.CreateHisPsn(psn)
  5858. var rf []*ResultFive
  5859. json.Unmarshal([]byte(infoStr), &rf)
  5860. var insutypes []*ResultFive
  5861. var insutype string
  5862. var is390 int = 0
  5863. var is310 int = 0
  5864. for _, item := range rf {
  5865. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5866. insutypes = append(insutypes, item)
  5867. }
  5868. }
  5869. if len(insutypes) == 1 {
  5870. insutype = insutypes[0].Insutype
  5871. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5872. } else {
  5873. for _, i := range insutypes {
  5874. if i.Insutype == "390" {
  5875. is390 = 1
  5876. }
  5877. if i.Insutype == "310" {
  5878. is310 = 1
  5879. }
  5880. }
  5881. }
  5882. if is390 == 1 {
  5883. insutype = "390"
  5884. }
  5885. if is310 == 1 {
  5886. insutype = "310"
  5887. }
  5888. if len(insutypes) == 0 {
  5889. insutype = "310"
  5890. }
  5891. c.ServeSuccessJSON(map[string]interface{}{
  5892. "patient": patient,
  5893. "number": token,
  5894. "insutype": insutype,
  5895. })
  5896. }
  5897. }
  5898. } else {
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5900. return
  5901. }
  5902. } else { //读卡失败
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5904. return
  5905. }
  5906. }
  5907. break
  5908. case 4:
  5909. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5910. var api string
  5911. if miConfig.MdtrtareaAdmvs == "320921" {
  5912. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5913. "&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
  5914. fmt.Println(api)
  5915. } else {
  5916. 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 +
  5917. "&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)
  5918. }
  5919. resp, requestErr := http.Get(api)
  5920. if requestErr != nil {
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. body, ioErr := ioutil.ReadAll(resp.Body)
  5925. if ioErr != nil {
  5926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. var respJSON map[string]interface{}
  5931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. var status string
  5937. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5938. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5939. var token string
  5940. var res ResultTwo //1101结果
  5941. var res10265 ResultTwo10265 //1101结果
  5942. if status == "0" { //读卡成功
  5943. var card_info string //卡信息
  5944. var busi_card_info string
  5945. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5946. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5947. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5948. fmt.Println(card_info)
  5949. fmt.Println(busi_card_info)
  5950. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5951. result, _ := json.Marshal(respJSON)
  5952. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5953. utils.ErrorLog("解析失败:%v", err)
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5955. return
  5956. }
  5957. res.ErrMsg = res10265.ErrMsg
  5958. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5959. res.Infcode = infocode
  5960. res.Output = res10265.Output
  5961. res.InfRefmsgid = res10265.InfRefmsgid
  5962. if res.Infcode == 0 {
  5963. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5964. if err == gorm.ErrRecordNotFound {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5966. return
  5967. } else if err != nil {
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5969. return
  5970. } else {
  5971. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5972. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5973. infoStr := string(Iinfos)
  5974. idetinfoStr := string(Idetinfos)
  5975. psn := &models.HisPsn{
  5976. PsnNo: res.Output.Baseinfo.PsnNo,
  5977. Age: res.Output.Baseinfo.Age,
  5978. PatientId: patient.ID,
  5979. Certno: res.Output.Baseinfo.Certno,
  5980. Brdy: res.Output.Baseinfo.Brdy,
  5981. Gend: res.Output.Baseinfo.Gend,
  5982. Naty: res.Output.Baseinfo.Naty,
  5983. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5984. PsnName: res.Output.Baseinfo.PsnName,
  5985. Idetinfo: idetinfoStr,
  5986. Insuinfo: infoStr,
  5987. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5988. CardInfo: card_info,
  5989. VerifyNumber: token,
  5990. }
  5991. var rf []*ResultFive
  5992. json.Unmarshal([]byte(infoStr), &rf)
  5993. var insutypes []*ResultFive
  5994. var insutype string
  5995. var is390 int = 0
  5996. var is310 int = 0
  5997. for _, item := range rf {
  5998. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5999. insutypes = append(insutypes, item)
  6000. }
  6001. }
  6002. if len(insutypes) == 1 {
  6003. insutype = insutypes[0].Insutype
  6004. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6005. } else {
  6006. for _, i := range insutypes {
  6007. if i.Insutype == "390" {
  6008. is390 = 1
  6009. }
  6010. if i.Insutype == "310" {
  6011. is310 = 1
  6012. }
  6013. }
  6014. }
  6015. if is390 == 1 {
  6016. insutype = "390"
  6017. }
  6018. if is310 == 1 {
  6019. insutype = "310"
  6020. }
  6021. if len(insutypes) == 0 {
  6022. insutype = "310"
  6023. }
  6024. service.CreateHisPsn(psn)
  6025. c.ServeSuccessJSON(map[string]interface{}{
  6026. "patient": patient,
  6027. "number": token,
  6028. "insutype": insutype,
  6029. })
  6030. }
  6031. } else {
  6032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6033. return
  6034. }
  6035. } else { //读卡失败
  6036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6037. return
  6038. }
  6039. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6040. idNo := c.GetString("idNo")
  6041. userName := c.GetString("userName")
  6042. ecToken := c.GetString("ecToken")
  6043. insuOrg := c.GetString("insuOrg")
  6044. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  6045. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6046. var res ResultTwo
  6047. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6048. utils.ErrorLog("解析失败:%v", err)
  6049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6050. return
  6051. }
  6052. if res.Infcode == 0 {
  6053. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6054. if err == gorm.ErrRecordNotFound {
  6055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6056. return
  6057. } else if err != nil {
  6058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6059. return
  6060. } else {
  6061. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6062. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6063. infoStr := string(Iinfos)
  6064. idetinfoStr := string(Idetinfos)
  6065. psn := &models.HisPsn{
  6066. PsnNo: res.Output.Baseinfo.PsnNo,
  6067. Age: res.Output.Baseinfo.Age,
  6068. PatientId: patient.ID,
  6069. Certno: res.Output.Baseinfo.Certno,
  6070. Brdy: res.Output.Baseinfo.Brdy,
  6071. Gend: res.Output.Baseinfo.Gend,
  6072. Naty: res.Output.Baseinfo.Naty,
  6073. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6074. PsnName: res.Output.Baseinfo.PsnName,
  6075. Idetinfo: idetinfoStr,
  6076. Insuinfo: infoStr,
  6077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6078. CardInfo: "",
  6079. Stage: "1",
  6080. VerifyNumber: ecToken,
  6081. InsuplcAdmdvs: insuOrg,
  6082. }
  6083. service.CreateHisPsn(psn)
  6084. var rf []*ResultFive
  6085. json.Unmarshal([]byte(infoStr), &rf)
  6086. var insutypes []*ResultFive
  6087. var insutype string
  6088. var is390 int = 0
  6089. var is310 int = 0
  6090. for _, item := range rf {
  6091. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6092. insutypes = append(insutypes, item)
  6093. }
  6094. }
  6095. if len(insutypes) == 1 {
  6096. insutype = insutypes[0].Insutype
  6097. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6098. } else {
  6099. for _, i := range insutypes {
  6100. if i.Insutype == "390" {
  6101. is390 = 1
  6102. }
  6103. if i.Insutype == "310" {
  6104. is310 = 1
  6105. }
  6106. }
  6107. }
  6108. if is390 == 1 {
  6109. insutype = "390"
  6110. }
  6111. if is310 == 1 {
  6112. insutype = "310"
  6113. }
  6114. if len(insutypes) == 0 {
  6115. insutype = "310"
  6116. }
  6117. c.ServeSuccessJSON(map[string]interface{}{
  6118. "patient": patient,
  6119. "number": ecToken,
  6120. "insutype": insutype,
  6121. })
  6122. }
  6123. } else {
  6124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6125. return
  6126. }
  6127. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6128. //if initFlag == 0 {
  6129. c.TestGetJiangXiBasBaseInit()
  6130. //}
  6131. //if initEleFlag == 0 {
  6132. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  6133. //}
  6134. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  6135. type ELeData struct {
  6136. Data struct {
  6137. IdNo string `json:"idNo"`
  6138. IdType string `json:"idType"`
  6139. UserName string `json:"userName"`
  6140. EcToken string `json:"ecToken"`
  6141. InsuOrg string `json:"insuOrg"`
  6142. Gender string `json:"gender"`
  6143. Birthday string `json:"birthday"`
  6144. Nationality string `json:"nationality"`
  6145. Email string `json:"email"`
  6146. Extra string `json:"extra"`
  6147. } `json:"data"`
  6148. Code int `json:"code"`
  6149. Message string `json:"message"`
  6150. }
  6151. var ele ELeData
  6152. err := json.Unmarshal([]byte(json_result), &ele)
  6153. if err != nil {
  6154. utils.ErrorLog("解析失败:%v", err)
  6155. }
  6156. token := ele.Data.EcToken
  6157. token = Remove0000(token)
  6158. 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)
  6159. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6160. var res ResultTwo
  6161. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6162. utils.ErrorLog("解析失败:%v", err)
  6163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6164. return
  6165. }
  6166. if res.Infcode == 0 {
  6167. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6168. if err == gorm.ErrRecordNotFound {
  6169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6170. return
  6171. } else if err != nil {
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6173. return
  6174. } else {
  6175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6177. infoStr := string(Iinfos)
  6178. idetinfoStr := string(Idetinfos)
  6179. psn := &models.HisPsn{
  6180. PsnNo: res.Output.Baseinfo.PsnNo,
  6181. Age: res.Output.Baseinfo.Age,
  6182. PatientId: patient.ID,
  6183. Certno: res.Output.Baseinfo.Certno,
  6184. Brdy: res.Output.Baseinfo.Brdy,
  6185. Gend: res.Output.Baseinfo.Gend,
  6186. Naty: res.Output.Baseinfo.Naty,
  6187. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6188. PsnName: res.Output.Baseinfo.PsnName,
  6189. Idetinfo: idetinfoStr,
  6190. Insuinfo: infoStr,
  6191. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6192. CardInfo: "",
  6193. //RecordDate:
  6194. VerifyNumber: token,
  6195. }
  6196. service.CreateHisPsn(psn)
  6197. var rf []*ResultFive
  6198. json.Unmarshal([]byte(infoStr), &rf)
  6199. var insutypes []*ResultFive
  6200. var insutype string
  6201. var is390 int = 0
  6202. var is310 int = 0
  6203. for _, item := range rf {
  6204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6205. insutypes = append(insutypes, item)
  6206. }
  6207. }
  6208. if len(insutypes) == 1 {
  6209. insutype = insutypes[0].Insutype
  6210. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6211. } else {
  6212. for _, i := range insutypes {
  6213. if i.Insutype == "390" {
  6214. is390 = 1
  6215. }
  6216. if i.Insutype == "310" {
  6217. is310 = 1
  6218. }
  6219. }
  6220. }
  6221. if is390 == 1 {
  6222. insutype = "390"
  6223. }
  6224. if is310 == 1 {
  6225. insutype = "310"
  6226. }
  6227. if len(insutypes) == 0 {
  6228. insutype = "310"
  6229. }
  6230. c.ServeSuccessJSON(map[string]interface{}{
  6231. "patient": patient,
  6232. "number": token,
  6233. "insutype": insutype,
  6234. })
  6235. }
  6236. } else {
  6237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6238. return
  6239. }
  6240. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6241. //if initFlag == 0 {
  6242. c.TestGetJiangXiBasBaseInit()
  6243. //}
  6244. //if initEleFlag == 0 {
  6245. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  6246. //}
  6247. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  6248. type ELeData struct {
  6249. Data struct {
  6250. IdNo string `json:"idNo"`
  6251. IdType string `json:"idType"`
  6252. UserName string `json:"userName"`
  6253. EcToken string `json:"ecToken"`
  6254. InsuOrg string `json:"insuOrg"`
  6255. Gender string `json:"gender"`
  6256. Birthday string `json:"birthday"`
  6257. Nationality string `json:"nationality"`
  6258. Email string `json:"email"`
  6259. Extra string `json:"extra"`
  6260. } `json:"data"`
  6261. Code int `json:"code"`
  6262. Message string `json:"message"`
  6263. }
  6264. var ele ELeData
  6265. err := json.Unmarshal([]byte(json_result), &ele)
  6266. if err != nil {
  6267. utils.ErrorLog("解析失败:%v", err)
  6268. }
  6269. token := ele.Data.EcToken
  6270. token = Remove0000(token)
  6271. 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)
  6272. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6273. var res ResultTwo
  6274. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6275. utils.ErrorLog("解析失败:%v", err)
  6276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. return
  6278. }
  6279. if res.Infcode == 0 {
  6280. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6281. if err == gorm.ErrRecordNotFound {
  6282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6283. return
  6284. } else if err != nil {
  6285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6286. return
  6287. } else {
  6288. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6289. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6290. infoStr := string(Iinfos)
  6291. idetinfoStr := string(Idetinfos)
  6292. psn := &models.HisPsn{
  6293. PsnNo: res.Output.Baseinfo.PsnNo,
  6294. Age: res.Output.Baseinfo.Age,
  6295. PatientId: patient.ID,
  6296. Certno: res.Output.Baseinfo.Certno,
  6297. Brdy: res.Output.Baseinfo.Brdy,
  6298. Gend: res.Output.Baseinfo.Gend,
  6299. Naty: res.Output.Baseinfo.Naty,
  6300. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6301. PsnName: res.Output.Baseinfo.PsnName,
  6302. Idetinfo: idetinfoStr,
  6303. Insuinfo: infoStr,
  6304. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6305. CardInfo: "",
  6306. VerifyNumber: token,
  6307. }
  6308. service.CreateHisPsn(psn)
  6309. var rf []*ResultFive
  6310. json.Unmarshal([]byte(infoStr), &rf)
  6311. var insutypes []*ResultFive
  6312. var insutype string
  6313. var is390 int = 0
  6314. var is310 int = 0
  6315. for _, item := range rf {
  6316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6317. insutypes = append(insutypes, item)
  6318. }
  6319. }
  6320. if len(insutypes) == 1 {
  6321. insutype = insutypes[0].Insutype
  6322. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6323. } else {
  6324. for _, i := range insutypes {
  6325. if i.Insutype == "390" {
  6326. is390 = 1
  6327. }
  6328. if i.Insutype == "310" {
  6329. is310 = 1
  6330. }
  6331. }
  6332. }
  6333. if is390 == 1 {
  6334. insutype = "390"
  6335. }
  6336. if is310 == 1 {
  6337. insutype = "310"
  6338. }
  6339. if len(insutypes) == 0 {
  6340. insutype = "310"
  6341. }
  6342. c.ServeSuccessJSON(map[string]interface{}{
  6343. "patient": patient,
  6344. "number": token,
  6345. "insutype": insutype,
  6346. })
  6347. }
  6348. } else {
  6349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6350. return
  6351. }
  6352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6353. type ELeData struct {
  6354. Code string `json:"code"`
  6355. Data struct {
  6356. Aac002 string `json:"aac002"`
  6357. Aaz500 string `json:"aaz500"`
  6358. ActCardNo string `json:"actCardNo"`
  6359. Bab520 string `json:"bab520"`
  6360. Bkz543 string `json:"bkz543"`
  6361. BusinessType string `json:"businessType"`
  6362. CertfCodg string `json:"certfCodg"`
  6363. EcIndexNo string `json:"ecIndexNo"`
  6364. EcToken string `json:"ecToken"`
  6365. ID0000 string `json:"id0000"`
  6366. IDNo string `json:"idNo"`
  6367. IDType string `json:"idType"`
  6368. Idcode string `json:"idcode"`
  6369. IdentityToken string `json:"identity_token"`
  6370. InsuOrg string `json:"insuOrg"`
  6371. OfficeID string `json:"officeId"`
  6372. OfficeName string `json:"officeName"`
  6373. OperatorID string `json:"operatorId"`
  6374. OperatorName string `json:"operatorName"`
  6375. OrgID string `json:"orgId"`
  6376. UserName string `json:"userName"`
  6377. } `json:"data"`
  6378. Infno interface{} `json:"infno"`
  6379. Message string `json:"message"`
  6380. OrgID string `json:"orgId"`
  6381. TransType string `json:"transType"`
  6382. }
  6383. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  6384. outPutInfo = Remove0000(outPutInfo)
  6385. if len(outPutInfo) > 0 {
  6386. var ele ELeData
  6387. err := json.Unmarshal([]byte(outPutInfo), &ele)
  6388. if err != nil {
  6389. utils.ErrorLog("解析失败:%v", err)
  6390. }
  6391. token := ele.Data.EcToken
  6392. fmt.Println(inputInfo)
  6393. fmt.Println(outPutInfo)
  6394. 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)
  6395. saveLog(result, requestLog, "1101", "获取人员信息")
  6396. var dat map[string]interface{}
  6397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6398. fmt.Println(dat)
  6399. } else {
  6400. fmt.Println(err)
  6401. }
  6402. userJSONBytes, _ := json.Marshal(dat)
  6403. var res ResultTwo
  6404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6405. utils.ErrorLog("解析失败:%v", err)
  6406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6407. return
  6408. }
  6409. res.ErrMsg = errMsgLog
  6410. if res.Infcode == 0 {
  6411. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  6412. if err == gorm.ErrRecordNotFound {
  6413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6414. return
  6415. } else if err != nil {
  6416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6417. return
  6418. } else {
  6419. fmt.Println(res)
  6420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6422. infoStr := string(Iinfos)
  6423. idetinfoStr := string(Idetinfos)
  6424. psn := &models.HisPsn{
  6425. PsnNo: res.Output.Baseinfo.PsnNo,
  6426. Age: res.Output.Baseinfo.Age,
  6427. PatientId: patient.ID,
  6428. Certno: res.Output.Baseinfo.Certno,
  6429. Brdy: res.Output.Baseinfo.Brdy,
  6430. Gend: res.Output.Baseinfo.Gend,
  6431. Naty: res.Output.Baseinfo.Naty,
  6432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6433. PsnName: res.Output.Baseinfo.PsnName,
  6434. Idetinfo: idetinfoStr,
  6435. Insuinfo: infoStr,
  6436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6437. CardInfo: outPutInfo,
  6438. VerifyNumber: token,
  6439. InsuplcAdmdvs: ele.Data.InsuOrg,
  6440. }
  6441. service.CreateHisPsn(psn)
  6442. var rf []*ResultFive
  6443. json.Unmarshal([]byte(infoStr), &rf)
  6444. var insutypes []*ResultFive
  6445. var insutype string
  6446. var is390 int = 0
  6447. var is310 int = 0
  6448. for _, item := range rf {
  6449. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6450. insutypes = append(insutypes, item)
  6451. }
  6452. }
  6453. if len(insutypes) == 1 {
  6454. insutype = insutypes[0].Insutype
  6455. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6456. } else {
  6457. for _, i := range insutypes {
  6458. if i.Insutype == "390" {
  6459. is390 = 1
  6460. }
  6461. if i.Insutype == "310" {
  6462. is310 = 1
  6463. }
  6464. }
  6465. }
  6466. if is390 == 1 {
  6467. insutype = "390"
  6468. }
  6469. if is310 == 1 {
  6470. insutype = "310"
  6471. }
  6472. if len(insutypes) == 0 {
  6473. insutype = "310"
  6474. }
  6475. c.ServeSuccessJSON(map[string]interface{}{
  6476. "patient": patient,
  6477. "number": token,
  6478. "insutype": insutype,
  6479. })
  6480. }
  6481. } else {
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6483. return
  6484. }
  6485. }
  6486. } else if miConfig.MdtrtareaAdmvs == "150499" {
  6487. var api string
  6488. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6489. "&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
  6490. resp, requestErr := http.Get(api)
  6491. if requestErr != nil {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6493. return
  6494. }
  6495. body, ioErr := ioutil.ReadAll(resp.Body)
  6496. if ioErr != nil {
  6497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. return
  6500. }
  6501. var respJSON map[string]interface{}
  6502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. var status string
  6508. status = respJSON["data"].(map[string]interface{})["status"].(string)
  6509. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  6510. var token string
  6511. var res ResultTwo //1101结果
  6512. var res10265 ResultTwo10265 //1101结果
  6513. if status == "0" { //读卡成功
  6514. var card_info string //卡信息
  6515. var busi_card_info string
  6516. token = respJSON["data"].(map[string]interface{})["token"].(string)
  6517. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  6518. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  6519. fmt.Println(card_info)
  6520. fmt.Println(busi_card_info)
  6521. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6522. result, _ := json.Marshal(respJSON)
  6523. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. res.ErrMsg = res10265.ErrMsg
  6529. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6530. res.Infcode = infocode
  6531. res.Output = res10265.Output
  6532. res.InfRefmsgid = res10265.InfRefmsgid
  6533. if res.Infcode == 0 {
  6534. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6535. if err == gorm.ErrRecordNotFound {
  6536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6537. return
  6538. } else if err != nil {
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6540. return
  6541. } else {
  6542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6544. infoStr := string(Iinfos)
  6545. idetinfoStr := string(Idetinfos)
  6546. psn := &models.HisPsn{
  6547. PsnNo: res.Output.Baseinfo.PsnNo,
  6548. Age: res.Output.Baseinfo.Age,
  6549. PatientId: patient.ID,
  6550. Certno: res.Output.Baseinfo.Certno,
  6551. Brdy: res.Output.Baseinfo.Brdy,
  6552. Gend: res.Output.Baseinfo.Gend,
  6553. Naty: res.Output.Baseinfo.Naty,
  6554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6555. PsnName: res.Output.Baseinfo.PsnName,
  6556. Idetinfo: idetinfoStr,
  6557. Insuinfo: infoStr,
  6558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6559. CardInfo: card_info,
  6560. VerifyNumber: token,
  6561. IdCardType: 4,
  6562. }
  6563. var rf []*ResultFive
  6564. json.Unmarshal([]byte(infoStr), &rf)
  6565. var insutypes []*ResultFive
  6566. var insutype string
  6567. var is390 int = 0
  6568. var is310 int = 0
  6569. for _, item := range rf {
  6570. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6571. insutypes = append(insutypes, item)
  6572. }
  6573. }
  6574. if len(insutypes) == 1 {
  6575. insutype = insutypes[0].Insutype
  6576. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6577. } else {
  6578. for _, i := range insutypes {
  6579. if i.Insutype == "390" {
  6580. is390 = 1
  6581. }
  6582. if i.Insutype == "310" {
  6583. is310 = 1
  6584. }
  6585. }
  6586. }
  6587. if is390 == 1 {
  6588. insutype = "390"
  6589. }
  6590. if is310 == 1 {
  6591. insutype = "310"
  6592. }
  6593. if len(insutypes) == 0 {
  6594. insutype = "310"
  6595. }
  6596. service.CreateHisPsn(psn)
  6597. c.ServeSuccessJSON(map[string]interface{}{
  6598. "patient": patient,
  6599. "number": token,
  6600. "insutype": insutype,
  6601. })
  6602. }
  6603. } else {
  6604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6605. return
  6606. }
  6607. } else { //读卡失败
  6608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6609. return
  6610. }
  6611. } else {
  6612. type ELeData struct {
  6613. Code string `json:"code"`
  6614. Data struct {
  6615. Aac002 string `json:"aac002"`
  6616. Aaz500 string `json:"aaz500"`
  6617. ActCardNo string `json:"actCardNo"`
  6618. Bab520 string `json:"bab520"`
  6619. Bkz543 string `json:"bkz543"`
  6620. BusinessType string `json:"businessType"`
  6621. CertfCodg string `json:"certfCodg"`
  6622. EcIndexNo string `json:"ecIndexNo"`
  6623. EcToken string `json:"ecToken"`
  6624. ID0000 string `json:"id0000"`
  6625. IDNo string `json:"idNo"`
  6626. IDType string `json:"idType"`
  6627. Idcode string `json:"idcode"`
  6628. IdentityToken string `json:"identity_token"`
  6629. InsuOrg string `json:"insuOrg"`
  6630. OfficeID string `json:"officeId"`
  6631. OfficeName string `json:"officeName"`
  6632. OperatorID string `json:"operatorId"`
  6633. OperatorName string `json:"operatorName"`
  6634. OrgID string `json:"orgId"`
  6635. UserName string `json:"userName"`
  6636. } `json:"data"`
  6637. Infno interface{} `json:"infno"`
  6638. Message string `json:"message"`
  6639. OrgID string `json:"orgId"`
  6640. TransType string `json:"transType"`
  6641. }
  6642. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  6643. fmt.Println(result)
  6644. outPutInfo := Remove0000(result)
  6645. fmt.Println(outPutInfo)
  6646. if len(outPutInfo) > 0 {
  6647. var ele ELeData
  6648. err := json.Unmarshal([]byte(outPutInfo), &ele)
  6649. if err != nil {
  6650. utils.ErrorLog("解析失败:%v", err)
  6651. }
  6652. token := ele.Data.EcToken
  6653. fmt.Println(outPutInfo)
  6654. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  6655. saveLog(result, requestLog, "1101", "获取人员信息")
  6656. var dat map[string]interface{}
  6657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6658. fmt.Println(dat)
  6659. } else {
  6660. fmt.Println(err)
  6661. }
  6662. userJSONBytes, _ := json.Marshal(dat)
  6663. var res ResultTwo
  6664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6665. utils.ErrorLog("解析失败:%v", err)
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6667. return
  6668. }
  6669. if res.Infcode == 0 {
  6670. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  6671. if err == gorm.ErrRecordNotFound {
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6673. return
  6674. } else if err != nil {
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6676. return
  6677. } else {
  6678. fmt.Println(res)
  6679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6681. infoStr := string(Iinfos)
  6682. idetinfoStr := string(Idetinfos)
  6683. psn := &models.HisPsn{
  6684. PsnNo: res.Output.Baseinfo.PsnNo,
  6685. Age: res.Output.Baseinfo.Age,
  6686. PatientId: patient.ID,
  6687. Certno: res.Output.Baseinfo.Certno,
  6688. Brdy: res.Output.Baseinfo.Brdy,
  6689. Gend: res.Output.Baseinfo.Gend,
  6690. Naty: res.Output.Baseinfo.Naty,
  6691. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6692. PsnName: res.Output.Baseinfo.PsnName,
  6693. Idetinfo: idetinfoStr,
  6694. Insuinfo: infoStr,
  6695. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6696. CardInfo: outPutInfo,
  6697. VerifyNumber: token,
  6698. InsuplcAdmdvs: ele.Data.InsuOrg,
  6699. }
  6700. service.CreateHisPsn(psn)
  6701. var rf []*ResultFive
  6702. json.Unmarshal([]byte(infoStr), &rf)
  6703. var insutypes []*ResultFive
  6704. var insutype string
  6705. var is390 int = 0
  6706. var is310 int = 0
  6707. for _, item := range rf {
  6708. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6709. insutypes = append(insutypes, item)
  6710. }
  6711. }
  6712. if len(insutypes) == 1 {
  6713. insutype = insutypes[0].Insutype
  6714. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6715. } else {
  6716. for _, i := range insutypes {
  6717. if i.Insutype == "390" {
  6718. is390 = 1
  6719. }
  6720. if i.Insutype == "310" {
  6721. is310 = 1
  6722. }
  6723. }
  6724. }
  6725. if is390 == 1 {
  6726. insutype = "390"
  6727. }
  6728. if is310 == 1 {
  6729. insutype = "310"
  6730. }
  6731. if len(insutypes) == 0 {
  6732. insutype = "310"
  6733. }
  6734. c.ServeSuccessJSON(map[string]interface{}{
  6735. "patient": patient,
  6736. "number": token,
  6737. "insutype": insutype,
  6738. })
  6739. }
  6740. } else {
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6742. return
  6743. }
  6744. }
  6745. //fmt.Println(result)
  6746. //
  6747. //if initFlag == 0 {
  6748. // c.TestGetBasBaseInit()
  6749. //}
  6750. //token := c.GetEleBaseInfo()
  6751. //
  6752. //token = Remove0000(token)
  6753. //
  6754. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  6755. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  6756. ////
  6757. //var res ResultTwo
  6758. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6759. // utils.ErrorLog("解析失败:%v", err)
  6760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. // return
  6762. //}
  6763. //
  6764. //if res.Infcode == 0 {
  6765. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6766. // if err == gorm.ErrRecordNotFound {
  6767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6768. // return
  6769. // } else if err != nil {
  6770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6771. // return
  6772. //
  6773. // } else {
  6774. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6775. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6776. // infoStr := string(Iinfos)
  6777. // idetinfoStr := string(Idetinfos)
  6778. //
  6779. //
  6780. //
  6781. //
  6782. // var rf []*ResultFive
  6783. // json.Unmarshal([]byte(infoStr), &rf)
  6784. //
  6785. // var insutypes []*ResultFive
  6786. // var insutype string
  6787. // var is390 int = 0
  6788. // var is310 int = 0
  6789. // var insuplc_admdvs string
  6790. //
  6791. // for _, item := range rf {
  6792. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6793. // insutypes = append(insutypes, item)
  6794. // }
  6795. // }
  6796. //
  6797. // if len(insutypes) == 1 {
  6798. // insutype = insutypes[0].Insutype
  6799. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6800. // } else {
  6801. // for _, i := range insutypes {
  6802. // if i.Insutype == "390" {
  6803. // is390 = 1
  6804. // }
  6805. //
  6806. // if i.Insutype == "310" {
  6807. // is310 = 1
  6808. // }
  6809. // }
  6810. // }
  6811. // if is390 == 1 {
  6812. // insutype = "390"
  6813. // }
  6814. //
  6815. // if is310 == 1 {
  6816. // insutype = "310"
  6817. // }
  6818. // if len(insutypes) == 0 {
  6819. // insutype = "310"
  6820. // }
  6821. // for _, item := range rf {
  6822. // if item.Insutype == insutype {
  6823. // insuplc_admdvs = item.InsuplcAdmdvs
  6824. // }
  6825. // }
  6826. // psn := &models.HisPsn{
  6827. // PsnNo: res.Output.Baseinfo.PsnNo,
  6828. // Age: res.Output.Baseinfo.Age,
  6829. // PatientId: patient.ID,
  6830. // Certno: res.Output.Baseinfo.Certno,
  6831. // Brdy: res.Output.Baseinfo.Brdy,
  6832. // Gend: res.Output.Baseinfo.Gend,
  6833. // Naty: res.Output.Baseinfo.Naty,
  6834. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  6835. // PsnName: res.Output.Baseinfo.PsnName,
  6836. // Idetinfo: idetinfoStr,
  6837. // Insuinfo: infoStr,
  6838. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6839. // CardInfo: "",
  6840. // VerifyNumber: token,
  6841. // InsuplcAdmdvs: insuplc_admdvs,
  6842. // }
  6843. // service.CreateHisPsn(psn)
  6844. //
  6845. // c.ServeSuccessJSON(map[string]interface{}{
  6846. // "patient": patient,
  6847. // "number": token,
  6848. // })
  6849. // }
  6850. //} else {
  6851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6852. // return
  6853. //}
  6854. }
  6855. break
  6856. }
  6857. }
  6858. var initFlag int64 = 0
  6859. var initEleFlag int64 = 0
  6860. func (c *HisApiController) TestGetBasBaseInit() {
  6861. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6862. Iinit := DllDef.MustFindProc("Init")
  6863. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6864. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  6865. if ret != 0 {
  6866. fmt.Println("SSCard的报错原因:", err)
  6867. fmt.Println("SSCard的运算结果为:", ret)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6869. return
  6870. }
  6871. result := int(ret)
  6872. fmt.Println("SSCard的运算结果为1:", result)
  6873. initFlag = 1
  6874. return
  6875. }
  6876. func (c *HisApiController) HandleJiangXiReadCard() {
  6877. fmt.Println("~~~~~~")
  6878. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6879. admin_user_id, _ := c.GetInt64("admin_user_id")
  6880. id_card_type, _ := c.GetInt64("id_card_type")
  6881. //certificates, _ := c.GetInt64("certificates")
  6882. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6883. if initFlag == 0 {
  6884. c.TestGetJiangXiBasBaseInit()
  6885. }
  6886. basStr := c.GetBasBaseInfo()
  6887. if len(basStr) == 0 {
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6889. return
  6890. }
  6891. fmt.Println(basStr)
  6892. bas := strings.Split(basStr, "|")
  6893. basNumber := bas[1]
  6894. fmt.Println(basNumber)
  6895. card_sn := bas[3]
  6896. fmt.Println(card_sn)
  6897. 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, "")
  6898. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  6899. var dat map[string]interface{}
  6900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6901. fmt.Println(dat)
  6902. } else {
  6903. fmt.Println(err)
  6904. }
  6905. userJSONBytes, _ := json.Marshal(dat)
  6906. var res ResultTwo
  6907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6908. utils.ErrorLog("解析失败:%v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. if res.Infcode == 0 {
  6913. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  6914. if err == gorm.ErrRecordNotFound {
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6916. return
  6917. } else if err != nil {
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6919. return
  6920. } else {
  6921. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6922. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6923. infoStr := string(Iinfos)
  6924. idetinfoStr := string(Idetinfos)
  6925. psn := &models.HisPsn{
  6926. PsnNo: res.Output.Baseinfo.PsnNo,
  6927. Age: res.Output.Baseinfo.Age,
  6928. PatientId: patient.ID,
  6929. Certno: res.Output.Baseinfo.Certno,
  6930. Brdy: res.Output.Baseinfo.Brdy,
  6931. Gend: res.Output.Baseinfo.Gend,
  6932. Naty: res.Output.Baseinfo.Naty,
  6933. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6934. PsnName: res.Output.Baseinfo.PsnName,
  6935. Idetinfo: idetinfoStr,
  6936. Insuinfo: infoStr,
  6937. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6938. CardInfo: basStr,
  6939. VerifyNumber: "",
  6940. }
  6941. service.CreateHisPsn(psn)
  6942. c.ServeSuccessJSON(map[string]interface{}{
  6943. "patient": patient,
  6944. "number": basNumber,
  6945. })
  6946. }
  6947. } else {
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6949. return
  6950. }
  6951. }
  6952. func (c *HisApiController) TestGetHnBasBaseInit() {
  6953. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6954. Iinit := DllDef.MustFindProc("Init")
  6955. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6956. //http://10.77.211.236/CSB/hsa-fsi-1303
  6957. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  6958. if ret != 0 {
  6959. fmt.Println("SSCard的报错原因:", err)
  6960. fmt.Println("SSCard的运算结果为:", ret)
  6961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6962. return
  6963. }
  6964. result := int(ret)
  6965. fmt.Println("SSCard的运算结果为1:", result)
  6966. initFlag = 1
  6967. return
  6968. }
  6969. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  6970. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6971. Iinit := DllDef.MustFindProc("Init")
  6972. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6973. //http://10.77.211.236/CSB/hsa-fsi-1303
  6974. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  6975. if ret != 0 {
  6976. fmt.Println("SSCard的报错原因:", err)
  6977. fmt.Println("SSCard的运算结果为:", ret)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6979. return
  6980. }
  6981. result := int(ret)
  6982. fmt.Println("SSCard的运算结果为1:", result)
  6983. initFlag = 1
  6984. return
  6985. }
  6986. func (c *HisApiController) GetSFZBaseInfo() string {
  6987. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6988. readCard := DllDef.MustFindProc("ReadSFZ")
  6989. if readCard == nil {
  6990. fmt.Println("readcard is nil")
  6991. readCard = DllDef.MustFindProc("ReadSFZ")
  6992. }
  6993. str := make([]byte, 8096)
  6994. str1 := make([]byte, 8096)
  6995. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  6996. fmt.Println(r)
  6997. return Remove0000(string(str))
  6998. }
  6999. func (c *HisApiController) GetEleBaseInfo() string {
  7000. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7001. readCard := DllDef.MustFindProc("GetQRBase")
  7002. fmt.Println(readCard)
  7003. if readCard == nil {
  7004. fmt.Println("readcard is nil")
  7005. readCard = DllDef.MustFindProc("GetQRBase")
  7006. }
  7007. str := make([]byte, 1024)
  7008. str1 := make([]byte, 1024)
  7009. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  7010. fmt.Println(ret2)
  7011. fmt.Println(string(str1))
  7012. fmt.Println(string(str))
  7013. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7014. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7015. if ret2 != 0 {
  7016. return ""
  7017. }
  7018. return string(str)
  7019. }
  7020. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  7021. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7022. readCard := DllDef.MustFindProc("NationEcTrans")
  7023. fmt.Println(readCard)
  7024. fmt.Println("!!!!!")
  7025. pBusiCardInfo := make([]byte, 2048)
  7026. input := make(map[string]interface{})
  7027. inputData := make(map[string]interface{})
  7028. inputData["orgId"] = code
  7029. inputData["businessType"] = "01101"
  7030. inputData["operatorId"] = "1"
  7031. inputData["operatorName"] = "admin"
  7032. inputData["officeId"] = "001"
  7033. inputData["officeName"] = "血透室"
  7034. inputData["deviceType"] = ""
  7035. input["data"] = inputData
  7036. input["orgId"] = code
  7037. input["transType"] = "ec.query"
  7038. bytesData, _ := json.Marshal(input)
  7039. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  7040. fmt.Println(ret2)
  7041. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7042. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7043. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  7044. }
  7045. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  7046. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7047. readCard := DllDef.MustFindProc("NationEcTrans")
  7048. fmt.Println(readCard)
  7049. fmt.Println("!!!!!")
  7050. pBusiCardInfo := make([]byte, 2048)
  7051. input := make(map[string]interface{})
  7052. inputData := make(map[string]interface{})
  7053. inputData["orgId"] = code
  7054. inputData["businessType"] = "01101"
  7055. inputData["operatorId"] = "9"
  7056. inputData["operatorName"] = "admin"
  7057. inputData["officeId"] = "001"
  7058. inputData["officeName"] = "血透室"
  7059. inputData["deviceType"] = ""
  7060. input["data"] = inputData
  7061. input["orgId"] = code
  7062. input["transType"] = "ec.query"
  7063. bytesData, _ := json.Marshal(input)
  7064. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  7065. fmt.Println(ret2)
  7066. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7067. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7068. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  7069. }
  7070. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  7071. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7072. readCard := DllDef.MustFindProc("NationEcTrans")
  7073. fmt.Println(readCard)
  7074. fmt.Println("!!!!!")
  7075. pBusiCardInfo := make([]byte, 2048)
  7076. input := make(map[string]interface{})
  7077. inputData := make(map[string]interface{})
  7078. inputData["orgId"] = code
  7079. inputData["businessType"] = "01301"
  7080. inputData["operatorId"] = "9"
  7081. inputData["operatorName"] = "admin"
  7082. inputData["officeId"] = "001"
  7083. inputData["officeName"] = "血透室"
  7084. inputData["deviceType"] = ""
  7085. input["data"] = inputData
  7086. input["orgId"] = code
  7087. input["transType"] = "ec.query"
  7088. bytesData, _ := json.Marshal(input)
  7089. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  7090. fmt.Println(ret2)
  7091. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7092. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7093. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  7094. }
  7095. func GetJxEleBaseInfo(org_id int64) string {
  7096. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7097. readCard := DllDef.MustFindProc("NationEcTrans")
  7098. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7099. if readCard == nil {
  7100. fmt.Println("readcard is nil")
  7101. readCard = DllDef.MustFindProc("NationEcTrans")
  7102. }
  7103. str1 := make([]byte, 1024)
  7104. data := make(map[string]interface{})
  7105. inputData := make(map[string]interface{})
  7106. inputData["orgId"] = miConfig.Code
  7107. inputData["businessType"] = "01101"
  7108. inputData["operatorId"] = "test001"
  7109. inputData["operatorName"] = "cn"
  7110. inputData["officeId"] = "32760"
  7111. inputData["officeName"] = "waike"
  7112. inputData["deviceType"] = ""
  7113. data["data"] = inputData
  7114. data["transType"] = "ec.query"
  7115. data["extra "] = ""
  7116. data["orgId"] = miConfig.Code
  7117. bytesData, _ := json.Marshal(data)
  7118. //bytesData, _ := json.Marshal(data)
  7119. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  7120. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  7121. fmt.Println(ret2)
  7122. fmt.Println(string(str1))
  7123. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7124. if ret2 != 0 {
  7125. return ""
  7126. }
  7127. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  7128. }
  7129. func GetJxEleBaseInitInfo(org_id int64) string {
  7130. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7131. readCard := DllDef.MustFindProc("NationEcTrans")
  7132. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7133. if readCard == nil {
  7134. fmt.Println("readcard is nil")
  7135. readCard = DllDef.MustFindProc("NationEcTrans")
  7136. }
  7137. str1 := make([]byte, 2048)
  7138. data := make(map[string]interface{})
  7139. inputData := make(map[string]interface{})
  7140. inputData["orgId"] = miConfig.Code
  7141. inputData["businessType"] = "01101"
  7142. inputData["operatorId"] = "1"
  7143. inputData["operatorName"] = "huangchuang"
  7144. inputData["officeId"] = "101"
  7145. inputData["officeName"] = "xuetou"
  7146. inputData["deviceType"] = ""
  7147. data["data"] = inputData
  7148. data["transType"] = "ec.query"
  7149. data["orgId"] = miConfig.Code
  7150. bytesData, _ := json.Marshal(data)
  7151. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  7152. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  7153. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  7154. fmt.Println(ret2)
  7155. fmt.Println(string(str1))
  7156. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7157. if ret2 != 0 {
  7158. return ""
  7159. }
  7160. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  7161. initEleFlag = 1
  7162. }
  7163. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  7164. }
  7165. func (c *HisApiController) GetBasBaseInfo() string {
  7166. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7167. readCard := DllDef.MustFindProc("ReadCardBas")
  7168. if readCard == nil {
  7169. fmt.Println("readcard is nil")
  7170. readCard = DllDef.MustFindProc("ReadCardBas")
  7171. }
  7172. str := make([]byte, 1024)
  7173. str1 := make([]byte, 1024)
  7174. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  7175. fmt.Println(string(str1))
  7176. fmt.Println(string(str))
  7177. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7178. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7179. if ret2 != 0 {
  7180. return ""
  7181. }
  7182. return string(str)
  7183. }
  7184. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  7185. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  7186. readCard := DllDef.MustFindProc("read_cardinfo")
  7187. if readCard == nil {
  7188. fmt.Println("readcard is nil")
  7189. readCard = DllDef.MustFindProc("read_cardinfo")
  7190. }
  7191. str := make([]byte, 1024) //卡号
  7192. str1 := make([]byte, 1024) //卡识别码
  7193. str2 := make([]byte, 1024) //身份证号
  7194. str3 := make([]byte, 1024) //姓名
  7195. str4 := make([]byte, 1024) //错误信息
  7196. 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])))
  7197. fmt.Println(string(str1))
  7198. fmt.Println(string(str))
  7199. fmt.Println(string(str2))
  7200. fmt.Println(string(str3))
  7201. fmt.Println(string(str4))
  7202. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7203. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7204. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  7205. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  7206. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  7207. if ret2 != 0 {
  7208. return "", "", "", "", ""
  7209. }
  7210. return string(str), string(str1), string(str2), string(str3), string(str4)
  7211. }
  7212. type CustomFundPay struct {
  7213. FundPayType string `json:"fund_pay_type"`
  7214. FundPayamt float64 `json:"fund_payamt"`
  7215. }
  7216. func (c *HisApiController) GetSettleList() {
  7217. order_id, _ := c.GetInt64("order_id")
  7218. admin_user_id, _ := c.GetInt64("admin_user_id")
  7219. order, _ := service.GetHisOrderByIDTwo(order_id)
  7220. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7221. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7222. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7223. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7224. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7225. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7226. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7227. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7228. if order.ID == 0 {
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7230. return
  7231. }
  7232. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7233. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7234. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7235. //fmt.Println(count)
  7236. //var zero string
  7237. //number := count + 1
  7238. //if number >= 1000 {
  7239. // zero = "0000" + strconv.FormatInt(number, 10)
  7240. //} else if number >= 10000 {
  7241. // zero = "000" + strconv.FormatInt(number, 10)
  7242. //} else if number >= 100000 {
  7243. // zero = "00" + strconv.FormatInt(number, 10)
  7244. //} else if number >= 1000000 {
  7245. // zero = "0" + strconv.FormatInt(number, 10)
  7246. //} else {
  7247. // zero = strconv.FormatInt(number, 10)
  7248. //}
  7249. //fmt.Println(zero)
  7250. struct4101 := service.Struct4101{
  7251. PsnNo: order.PsnNo,
  7252. MdtrtId: order.MdtrtId,
  7253. SetlId: order.SetlId,
  7254. PsnName: order.PsnName,
  7255. Gend: order.Gend,
  7256. Brdy: his.Brdy,
  7257. Age: his.Age,
  7258. Naty: order.Naty,
  7259. PatnCertType: "01",
  7260. Certno: order.Certno,
  7261. Prfs: "90",
  7262. ConerName: roles[0].UserName,
  7263. PatnRlts: "99",
  7264. ConerAddr: miConfig.OrgName,
  7265. ConerTel: admin.Mobile,
  7266. HiType: order.Insutype,
  7267. Insuplc: miConfig.InsuplcAdmdvs,
  7268. MaindiagFlag: "1",
  7269. BillCode: order.SetlId,
  7270. BillNo: order.SetlId,
  7271. BizSn: order.Number,
  7272. PsnSelfPay: order.PsnPartAmt,
  7273. PsnOwnPay: order.PsnPartAmt,
  7274. AcctPay: order.AcctPay,
  7275. PsnCashpay: order.PsnCashPay,
  7276. HiPaymtd: "1",
  7277. Hsorg: miConfig.InsuplcAdmdvs,
  7278. HsorgOpter: miConfig.InsuplcAdmdvs,
  7279. MedinsFillPsn: curRoles.UserName,
  7280. MedinsFillDept: depart.Name,
  7281. IptMedType: "2",
  7282. }
  7283. struct4101.SetlBegnDate = order.SetlTime
  7284. struct4101.SetlEndDate = order.SetlTime
  7285. time_arr := strings.Split(order.SetlTime, " ")
  7286. struct4101.AdmTime = time_arr[0]
  7287. struct4101.AdmEndTime = time_arr[0]
  7288. var rf []CustomFundPay
  7289. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7290. var tempFunPays []service.CustomStruct
  7291. for _, item := range rf {
  7292. var tempFunPay service.CustomStruct
  7293. tempFunPay.FundPayamt = item.FundPayamt
  7294. tempFunPay.FundPayType = item.FundPayType
  7295. tempFunPays = append(tempFunPays, tempFunPay)
  7296. }
  7297. struct4101.CustomStruct = tempFunPays
  7298. var tempDiaginfos []service.DiaginfoStructTwo
  7299. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7300. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7301. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7302. var config []*models.HisXtDiagnoseConfig
  7303. for _, item := range diagnosis_ids {
  7304. id, _ := strconv.ParseInt(item, 10, 64)
  7305. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7306. config = append(config, &diagnosisConfig)
  7307. }
  7308. for index, item := range config {
  7309. if index == 0 {
  7310. var tempDiaginfo service.DiaginfoStructTwo
  7311. tempDiaginfo.DiagCode = item.CountryCode
  7312. tempDiaginfo.DiagName = item.CountryContentName
  7313. tempDiaginfo.DiagType = "1"
  7314. tempDiaginfo.MaindiagFlag = "1"
  7315. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7316. } else {
  7317. var tempDiaginfo service.DiaginfoStructTwo
  7318. tempDiaginfo.DiagCode = item.CountryCode
  7319. tempDiaginfo.DiagName = item.CountryContentName
  7320. tempDiaginfo.DiagType = "2"
  7321. tempDiaginfo.MaindiagFlag = "0"
  7322. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7323. }
  7324. }
  7325. struct4101.Diseinfo = tempDiaginfos
  7326. sickConfigTwo, _ := service.FindSickById(his.SickType)
  7327. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7328. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7329. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  7330. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  7331. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7332. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7333. var iteminfo service.IteminfoStruct
  7334. var bedCostTotal float64 = 0 //床位总费
  7335. var bedCostSelfTotal float64 = 0 //床位自费
  7336. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7337. var operationCostTotal float64 = 0 //手术费
  7338. var operationCostSelfTotal float64 = 0 //手术费
  7339. var operationCostPartSelfTotal float64 = 0 //手术费
  7340. var otherCostTotal float64 = 0 //其他费用
  7341. var otherCostSelfTotal float64 = 0 //其他费用
  7342. var otherCostPartSelfTotal float64 = 0 //其他费用
  7343. var materialCostTotal float64 = 0 //材料费
  7344. var materialCostSelfTotal float64 = 0 //材料费
  7345. var materialCostPartSelfTotal float64 = 0 //材料费
  7346. var westernMedicineCostTotal float64 = 0 //西药费
  7347. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7348. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7349. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7350. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7351. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7352. var checkCostTotal float64 = 0 //检查费
  7353. var checkCostSelfTotal float64 = 0 //检查费
  7354. var checkCostPartSelfTotal float64 = 0 //检查费
  7355. var laboratoryCostTotal float64 = 0 //化验费
  7356. var laboratoryCostSelfTotal float64 = 0 //化验费
  7357. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7358. var treatCostTotal float64 = 0 //治疗费用
  7359. var treatCostSelfTotal float64 = 0 //治疗费用
  7360. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7361. decimal.DivisionPrecision = 2
  7362. var bed_fulamt_ownpay_amt float64 = 0
  7363. var operation_fulamt_ownpay_amt float64 = 0
  7364. var other_fulamt_ownpay_amt float64 = 0
  7365. var westernMedicine_fulamt_ownpay_amt float64 = 0
  7366. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7367. var check_fulamt_ownpay_amt float64 = 0
  7368. var material_fulamt_ownpay_amt float64 = 0
  7369. var laboratory_fulamt_ownpay_amt float64 = 0
  7370. var treat_fulamt_ownpay_amt float64 = 0
  7371. var bed_claa_sunmfee float64 = 0
  7372. var bed_clab_amt float64 = 0
  7373. var bed_other_amt float64 = 0
  7374. var operation_claa_sunmfee float64 = 0
  7375. var operation_clab_amt float64 = 0
  7376. var operation_other_amt float64 = 0
  7377. var other_claa_sunmfee float64 = 0
  7378. var other_clab_amt float64 = 0
  7379. var other_other_amt float64 = 0
  7380. var westernMedicine_claa_sunmfee float64 = 0
  7381. var westernMedicine_clab_amt float64 = 0
  7382. var westernMedicine_other_amt float64 = 0
  7383. var chineseTraditional_claa_sunmfee float64 = 0
  7384. var chineseTraditional_clab_amt float64 = 0
  7385. var chineseTraditional_other_amt float64 = 0
  7386. var check_claa_sunmfee float64 = 0
  7387. var check_clab_amt float64 = 0
  7388. var check_other_amt float64 = 0
  7389. var material_claa_sunmfee float64 = 0
  7390. var material_clab_amt float64 = 0
  7391. var material_other_amt float64 = 0
  7392. var laboratory_claa_sunmfee float64 = 0
  7393. var laboratory_clab_amt float64 = 0
  7394. var laboratory_other_amt float64 = 0
  7395. var treat_claa_sunmfee float64 = 0
  7396. var treat_clab_amt float64 = 0
  7397. var treat_other_amt float64 = 0
  7398. for _, item := range order.HisOrderInfo {
  7399. if item.MedChrgitmType == "01" { //床位费
  7400. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7401. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7402. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7403. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7404. if item.ChrgitmLv == "1" {
  7405. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7406. }
  7407. if item.ChrgitmLv == "2" {
  7408. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7409. }
  7410. if item.ChrgitmLv == "3" {
  7411. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7412. }
  7413. }
  7414. if item.MedChrgitmType == "03" { //检查费
  7415. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7416. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7417. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7418. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7419. if item.ChrgitmLv == "1" {
  7420. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7421. }
  7422. if item.ChrgitmLv == "2" {
  7423. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7424. }
  7425. if item.ChrgitmLv == "3" {
  7426. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7427. }
  7428. }
  7429. if item.MedChrgitmType == "04" { //化验费
  7430. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7431. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7432. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7433. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7434. if item.ChrgitmLv == "1" {
  7435. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7436. }
  7437. if item.ChrgitmLv == "2" {
  7438. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7439. }
  7440. if item.ChrgitmLv == "3" {
  7441. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7442. }
  7443. }
  7444. if item.MedChrgitmType == "05" { //治疗费
  7445. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7446. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7447. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7448. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7449. if item.ChrgitmLv == "1" {
  7450. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7451. }
  7452. if item.ChrgitmLv == "2" {
  7453. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7454. }
  7455. if item.ChrgitmLv == "3" {
  7456. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7457. }
  7458. }
  7459. if item.MedChrgitmType == "06" { //手术费
  7460. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7461. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7462. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7463. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7464. if item.ChrgitmLv == "1" {
  7465. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7466. }
  7467. if item.ChrgitmLv == "2" {
  7468. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7469. }
  7470. if item.ChrgitmLv == "3" {
  7471. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7472. }
  7473. }
  7474. if item.MedChrgitmType == "08" { //材料费
  7475. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7476. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7477. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7478. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7479. if item.ChrgitmLv == "1" {
  7480. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7481. }
  7482. if item.ChrgitmLv == "2" {
  7483. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7484. }
  7485. if item.ChrgitmLv == "3" {
  7486. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7487. }
  7488. }
  7489. if item.MedChrgitmType == "09" { //西药费
  7490. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7491. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7492. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7493. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7494. if item.ChrgitmLv == "1" {
  7495. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7496. }
  7497. if item.ChrgitmLv == "2" {
  7498. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7499. }
  7500. if item.ChrgitmLv == "3" {
  7501. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7502. }
  7503. }
  7504. if item.MedChrgitmType == "11" { //中成费
  7505. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7506. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7507. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7508. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7509. if item.ChrgitmLv == "1" {
  7510. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7511. }
  7512. if item.ChrgitmLv == "2" {
  7513. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7514. }
  7515. if item.ChrgitmLv == "3" {
  7516. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7517. }
  7518. }
  7519. if item.MedChrgitmType == "14" { //其他费
  7520. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7521. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7522. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7523. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7524. if item.ChrgitmLv == "1" {
  7525. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7526. }
  7527. if item.ChrgitmLv == "2" {
  7528. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7529. }
  7530. if item.ChrgitmLv == "3" {
  7531. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7532. }
  7533. }
  7534. }
  7535. var iteminfoStructs []service.IteminfoStruct
  7536. if bedCostTotal != 0 {
  7537. iteminfo.MedChrgitm = "01"
  7538. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7539. iteminfo.Amt = bedCostTotal
  7540. iteminfo.ClaaSumfee = bed_claa_sunmfee
  7541. iteminfo.ClabAmt = bed_clab_amt
  7542. iteminfo.OthAmt = bed_other_amt
  7543. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7544. }
  7545. if checkCostTotal != 0 {
  7546. iteminfo.MedChrgitm = "03"
  7547. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7548. iteminfo.Amt = checkCostTotal
  7549. iteminfo.ClaaSumfee = check_claa_sunmfee
  7550. iteminfo.ClabAmt = check_clab_amt
  7551. iteminfo.OthAmt = check_other_amt
  7552. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7553. }
  7554. if laboratoryCostTotal != 0 {
  7555. iteminfo.MedChrgitm = "04"
  7556. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7557. iteminfo.Amt = laboratoryCostTotal
  7558. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7559. iteminfo.ClabAmt = laboratory_clab_amt
  7560. iteminfo.OthAmt = laboratory_other_amt
  7561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7562. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7563. }
  7564. if treatCostTotal != 0 {
  7565. iteminfo.MedChrgitm = "05"
  7566. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7567. iteminfo.Amt = treatCostTotal
  7568. iteminfo.ClaaSumfee = treat_claa_sunmfee
  7569. iteminfo.ClabAmt = treat_clab_amt
  7570. iteminfo.OthAmt = treat_other_amt
  7571. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7572. //(struct4101.IteminfoStruct, iteminfo)
  7573. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7574. }
  7575. if operationCostTotal != 0 {
  7576. iteminfo.MedChrgitm = "06"
  7577. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7578. iteminfo.Amt = operationCostTotal
  7579. iteminfo.ClaaSumfee = operation_claa_sunmfee
  7580. iteminfo.ClabAmt = operation_clab_amt
  7581. iteminfo.OthAmt = operation_other_amt
  7582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7584. }
  7585. if materialCostTotal != 0 {
  7586. iteminfo.MedChrgitm = "08"
  7587. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7588. iteminfo.Amt = materialCostTotal
  7589. iteminfo.ClaaSumfee = material_claa_sunmfee
  7590. iteminfo.ClabAmt = material_clab_amt
  7591. iteminfo.OthAmt = material_other_amt
  7592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7594. }
  7595. if westernMedicineCostTotal != 0 {
  7596. iteminfo.MedChrgitm = "09"
  7597. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7598. iteminfo.Amt = westernMedicineCostTotal
  7599. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7600. iteminfo.ClabAmt = westernMedicine_clab_amt
  7601. iteminfo.OthAmt = westernMedicine_other_amt
  7602. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7604. }
  7605. if chineseTraditionalMedicineCostTotal != 0 {
  7606. iteminfo.MedChrgitm = "11"
  7607. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7608. iteminfo.Amt = westernMedicineCostTotal
  7609. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7610. iteminfo.ClabAmt = westernMedicine_clab_amt
  7611. iteminfo.OthAmt = westernMedicine_other_amt
  7612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7614. }
  7615. if otherCostTotal != 0 {
  7616. iteminfo.MedChrgitm = "14"
  7617. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7618. iteminfo.Amt = otherCostTotal
  7619. iteminfo.ClaaSumfee = other_claa_sunmfee
  7620. iteminfo.ClabAmt = other_clab_amt
  7621. iteminfo.OthAmt = other_other_amt
  7622. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7624. }
  7625. struct4101.IteminfoStruct = iteminfoStructs
  7626. struct4101.Ntly = "中国"
  7627. struct4101.AdmCaty = "A03.06"
  7628. struct4101.DoctorName = doctor.UserName
  7629. struct4101.DoctorCode = doctor.DoctorNumber
  7630. var res ResultSeventeen
  7631. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7632. struct4101.BillCode = order.Number
  7633. struct4101.BillNo = order.SetlId
  7634. var resOther ResultSeventeenOther
  7635. var pp models.PublicParams
  7636. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7637. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7638. pp.FixmedinsName = miConfig.OrgName
  7639. pp.FixmedinsCode = miConfig.Code
  7640. pp.RequestUrl = miConfig.Url
  7641. pp.Cainfo = miConfig.Cainfo
  7642. pp.SecretKey = miConfig.SecretKey
  7643. pp.AccessKey = miConfig.AccessKey
  7644. pp.OpterName = curRoles.UserName
  7645. client := &http.Client{}
  7646. var req *http.Request
  7647. data := make(map[string]interface{})
  7648. data["struct4101"] = struct4101
  7649. data["pp"] = pp
  7650. bytesData, _ := json.Marshal(data)
  7651. if miConfig.MdtrtareaAdmvs == "320921" {
  7652. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  7653. } else {
  7654. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  7655. }
  7656. resp, _ := client.Do(req)
  7657. defer resp.Body.Close()
  7658. body, ioErr := ioutil.ReadAll(resp.Body)
  7659. if ioErr != nil {
  7660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. var respJSON map[string]interface{}
  7665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7668. return
  7669. }
  7670. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7671. userJSONBytes, _ := json.Marshal(respJSON)
  7672. fmt.Println("log")
  7673. fmt.Println(string(userJSONBytes))
  7674. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  7675. utils.ErrorLog("解析失败:%v", err)
  7676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7677. return
  7678. }
  7679. res.InfRefmsgid = resOther.InfRefmsgid
  7680. res.Output = resOther.Output
  7681. res.ErrMsg = resOther.ErrMsg
  7682. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7683. res.Infcode = infocode
  7684. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7685. var pp models.PublicParams
  7686. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7687. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7688. pp.FixmedinsName = miConfig.OrgName
  7689. pp.FixmedinsCode = miConfig.Code
  7690. pp.RequestUrl = miConfig.Url
  7691. pp.Cainfo = miConfig.Cainfo
  7692. pp.SecretKey = miConfig.SecretKey
  7693. pp.AccessKey = miConfig.AccessKey
  7694. pp.OpterName = curRoles.UserName
  7695. result, _ := service.Jxyb4101(struct4101, pp)
  7696. var dat map[string]interface{}
  7697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7698. fmt.Println(dat)
  7699. } else {
  7700. fmt.Println(err)
  7701. }
  7702. userJSONBytes, _ := json.Marshal(dat)
  7703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7709. var pp models.PublicParams
  7710. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7711. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7712. pp.FixmedinsName = miConfig.OrgName
  7713. pp.FixmedinsCode = miConfig.Code
  7714. pp.RequestUrl = miConfig.Url
  7715. pp.Cainfo = miConfig.Cainfo
  7716. pp.SecretKey = miConfig.SecretKey
  7717. pp.AccessKey = miConfig.AccessKey
  7718. pp.OpterName = curRoles.UserName
  7719. result, _ := service.Hnyb4101(struct4101, pp)
  7720. var dat map[string]interface{}
  7721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7722. fmt.Println(dat)
  7723. } else {
  7724. fmt.Println(err)
  7725. }
  7726. userJSONBytes, _ := json.Marshal(dat)
  7727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7728. utils.ErrorLog("解析失败:%v", err)
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. } else {
  7733. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7734. var dat map[string]interface{}
  7735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7736. fmt.Println(dat)
  7737. } else {
  7738. fmt.Println(err)
  7739. }
  7740. userJSONBytes, _ := json.Marshal(dat)
  7741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7742. utils.ErrorLog("解析失败:%v", err)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. }
  7747. if res.Infcode != 0 {
  7748. c.ServeSuccessJSON(map[string]interface{}{
  7749. "failed_code": -10,
  7750. "msg": res.ErrMsg,
  7751. })
  7752. return
  7753. } else {
  7754. //order.FaPiaoNumber = zero
  7755. //order.FaPiaoCode = last_order.FaPiaoCode
  7756. //service.UpdateOrder(order)
  7757. hisFundSettleListResult := &models.HisFundSettleListResult{
  7758. Number: res.Output.SetlListId,
  7759. Status: 1,
  7760. Ctime: time.Now().Unix(),
  7761. Mtime: time.Now().Unix(),
  7762. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7763. IsUpload: 1,
  7764. OrderId: order_id,
  7765. }
  7766. service.CreateUploadRecord(hisFundSettleListResult)
  7767. c.ServeSuccessJSON(map[string]interface{}{
  7768. "msg": "上传成功",
  7769. "result": hisFundSettleListResult,
  7770. })
  7771. return
  7772. }
  7773. }
  7774. func (c *HisApiController) GetSettleListHospital() {
  7775. order_id, _ := c.GetInt64("order_id")
  7776. admin_user_id, _ := c.GetInt64("admin_user_id")
  7777. order, _ := service.GetHisOrderByIDTwo(order_id)
  7778. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7779. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7780. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7781. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7782. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7784. if order.ID == 0 {
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7786. return
  7787. }
  7788. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7789. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7790. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7791. fmt.Println(count)
  7792. var zero string
  7793. number := count + 1
  7794. if number >= 1000 {
  7795. zero = "0000" + strconv.FormatInt(number, 10)
  7796. } else if number >= 10000 {
  7797. zero = "000" + strconv.FormatInt(number, 10)
  7798. } else if number >= 100000 {
  7799. zero = "00" + strconv.FormatInt(number, 10)
  7800. } else if number >= 1000000 {
  7801. zero = "0" + strconv.FormatInt(number, 10)
  7802. } else {
  7803. zero = strconv.FormatInt(number, 10)
  7804. }
  7805. fmt.Println(zero)
  7806. struct4101 := service.Struct4101{
  7807. PsnNo: order.PsnNo,
  7808. MdtrtId: order.MdtrtId,
  7809. SetlId: order.SetlId,
  7810. PsnName: order.PsnName,
  7811. Gend: order.Gend,
  7812. Brdy: his.Brdy,
  7813. Age: int64(order.Age),
  7814. Naty: order.Naty,
  7815. PatnCertType: "01",
  7816. Certno: order.Certno,
  7817. Prfs: "90",
  7818. ConerName: roles[0].UserName,
  7819. PatnRlts: "99",
  7820. ConerAddr: miConfig.OrgName,
  7821. ConerTel: admin.Mobile,
  7822. HiType: order.Insutype,
  7823. Insuplc: miConfig.InsuplcAdmdvs,
  7824. MaindiagFlag: "1",
  7825. BillCode: order.SetlId,
  7826. BillNo: order.SetlId,
  7827. BizSn: order.Number,
  7828. PsnSelfPay: order.PsnPartAmt,
  7829. PsnOwnPay: order.PsnPartAmt,
  7830. AcctPay: order.AcctPay,
  7831. PsnCashpay: order.PsnCashPay,
  7832. HiPaymtd: "1",
  7833. Hsorg: miConfig.InsuplcAdmdvs,
  7834. HsorgOpter: miConfig.InsuplcAdmdvs,
  7835. MedinsFillPsn: curRoles.UserName,
  7836. MedinsFillDept: depart.Name,
  7837. IptMedType: "2",
  7838. AdmTime: his.InHosptialTime,
  7839. AdmEndTime: his.OutHosptialTime,
  7840. }
  7841. struct4101.SetlBegnDate = order.SetlTime
  7842. struct4101.SetlEndDate = order.SetlTime
  7843. var rf []CustomFundPay
  7844. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7845. var tempFunPays []service.CustomStruct
  7846. for _, item := range rf {
  7847. var tempFunPay service.CustomStruct
  7848. tempFunPay.FundPayamt = item.FundPayamt
  7849. tempFunPay.FundPayType = item.FundPayType
  7850. tempFunPays = append(tempFunPays, tempFunPay)
  7851. }
  7852. struct4101.CustomStruct = tempFunPays
  7853. var tempDiaginfos []service.DiaginfoStructTwo
  7854. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7855. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7856. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7857. var config []*models.HisXtDiagnoseConfig
  7858. for _, item := range diagnosis_ids {
  7859. id, _ := strconv.ParseInt(item, 10, 64)
  7860. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7861. config = append(config, &diagnosisConfig)
  7862. }
  7863. for index, item := range config {
  7864. if index == 0 {
  7865. var tempDiaginfo service.DiaginfoStructTwo
  7866. tempDiaginfo.DiagCode = item.CountryCode
  7867. tempDiaginfo.DiagName = item.CountryContentName
  7868. tempDiaginfo.DiagType = "1"
  7869. tempDiaginfo.MaindiagFlag = "1"
  7870. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7871. } else {
  7872. var tempDiaginfo service.DiaginfoStructTwo
  7873. tempDiaginfo.DiagCode = item.CountryCode
  7874. tempDiaginfo.DiagName = item.CountryContentName
  7875. tempDiaginfo.DiagType = "2"
  7876. tempDiaginfo.MaindiagFlag = "0"
  7877. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7878. }
  7879. }
  7880. struct4101.Diseinfo = tempDiaginfos
  7881. sickConfigTwo, _ := service.FindSickById(his.SickType)
  7882. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7883. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7884. tempOpspdiseinfo2.OprnOprtCode = ""
  7885. tempOpspdiseinfo2.OprnOprtName = ""
  7886. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7887. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7888. var iteminfo service.IteminfoStruct
  7889. var bedCostTotal float64 = 0 //床位总费
  7890. var bedCostSelfTotal float64 = 0 //床位自费
  7891. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7892. var operationCostTotal float64 = 0 //手术费
  7893. var operationCostSelfTotal float64 = 0 //手术费
  7894. var operationCostPartSelfTotal float64 = 0 //手术费
  7895. var otherCostTotal float64 = 0 //其他费用
  7896. var otherCostSelfTotal float64 = 0 //其他费用
  7897. var otherCostPartSelfTotal float64 = 0 //其他费用
  7898. var materialCostTotal float64 = 0 //材料费
  7899. var materialCostSelfTotal float64 = 0 //材料费
  7900. var materialCostPartSelfTotal float64 = 0 //材料费
  7901. var westernMedicineCostTotal float64 = 0 //西药费
  7902. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7903. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7904. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7905. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7906. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7907. var checkCostTotal float64 = 0 //检查费
  7908. var checkCostSelfTotal float64 = 0 //检查费
  7909. var checkCostPartSelfTotal float64 = 0 //检查费
  7910. var laboratoryCostTotal float64 = 0 //化验费
  7911. var laboratoryCostSelfTotal float64 = 0 //化验费
  7912. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7913. var treatCostTotal float64 = 0 //治疗费用
  7914. var treatCostSelfTotal float64 = 0 //治疗费用
  7915. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7916. decimal.DivisionPrecision = 2
  7917. var bed_fulamt_ownpay_amt float64 = 0
  7918. var operation_fulamt_ownpay_amt float64 = 0
  7919. var other_fulamt_ownpay_amt float64 = 0
  7920. var westernMedicine_fulamt_ownpay_amt float64 = 0
  7921. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7922. var check_fulamt_ownpay_amt float64 = 0
  7923. var material_fulamt_ownpay_amt float64 = 0
  7924. var laboratory_fulamt_ownpay_amt float64 = 0
  7925. var treat_fulamt_ownpay_amt float64 = 0
  7926. var bed_claa_sunmfee float64 = 0
  7927. var bed_clab_amt float64 = 0
  7928. var bed_other_amt float64 = 0
  7929. var operation_claa_sunmfee float64 = 0
  7930. var operation_clab_amt float64 = 0
  7931. var operation_other_amt float64 = 0
  7932. var other_claa_sunmfee float64 = 0
  7933. var other_clab_amt float64 = 0
  7934. var other_other_amt float64 = 0
  7935. var westernMedicine_claa_sunmfee float64 = 0
  7936. var westernMedicine_clab_amt float64 = 0
  7937. var westernMedicine_other_amt float64 = 0
  7938. var chineseTraditional_claa_sunmfee float64 = 0
  7939. var chineseTraditional_clab_amt float64 = 0
  7940. var chineseTraditional_other_amt float64 = 0
  7941. var check_claa_sunmfee float64 = 0
  7942. var check_clab_amt float64 = 0
  7943. var check_other_amt float64 = 0
  7944. var material_claa_sunmfee float64 = 0
  7945. var material_clab_amt float64 = 0
  7946. var material_other_amt float64 = 0
  7947. var laboratory_claa_sunmfee float64 = 0
  7948. var laboratory_clab_amt float64 = 0
  7949. var laboratory_other_amt float64 = 0
  7950. var treat_claa_sunmfee float64 = 0
  7951. var treat_clab_amt float64 = 0
  7952. var treat_other_amt float64 = 0
  7953. for _, item := range order.HisOrderInfo {
  7954. if item.MedChrgitmType == "01" { //床位费
  7955. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7956. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7957. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7958. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7959. if item.ChrgitmLv == "1" {
  7960. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7961. }
  7962. if item.ChrgitmLv == "2" {
  7963. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7964. }
  7965. if item.ChrgitmLv == "3" {
  7966. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7967. }
  7968. }
  7969. if item.MedChrgitmType == "03" { //检查费
  7970. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7971. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7972. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7973. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7974. if item.ChrgitmLv == "1" {
  7975. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7976. }
  7977. if item.ChrgitmLv == "2" {
  7978. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7979. }
  7980. if item.ChrgitmLv == "3" {
  7981. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7982. }
  7983. }
  7984. if item.MedChrgitmType == "04" { //化验费
  7985. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7986. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7987. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7988. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7989. if item.ChrgitmLv == "1" {
  7990. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7991. }
  7992. if item.ChrgitmLv == "2" {
  7993. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7994. }
  7995. if item.ChrgitmLv == "3" {
  7996. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7997. }
  7998. }
  7999. if item.MedChrgitmType == "05" { //治疗费
  8000. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8001. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8002. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8003. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8004. if item.ChrgitmLv == "1" {
  8005. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8006. }
  8007. if item.ChrgitmLv == "2" {
  8008. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8009. }
  8010. if item.ChrgitmLv == "3" {
  8011. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8012. }
  8013. }
  8014. if item.MedChrgitmType == "06" { //手术费
  8015. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8016. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8017. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8018. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8019. if item.ChrgitmLv == "1" {
  8020. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8021. }
  8022. if item.ChrgitmLv == "2" {
  8023. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8024. }
  8025. if item.ChrgitmLv == "3" {
  8026. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8027. }
  8028. }
  8029. if item.MedChrgitmType == "08" { //材料费
  8030. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8031. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8032. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8033. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8034. if item.ChrgitmLv == "1" {
  8035. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8036. }
  8037. if item.ChrgitmLv == "2" {
  8038. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8039. }
  8040. if item.ChrgitmLv == "3" {
  8041. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8042. }
  8043. }
  8044. if item.MedChrgitmType == "09" { //西药费
  8045. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8046. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8047. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8048. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8049. if item.ChrgitmLv == "1" {
  8050. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8051. }
  8052. if item.ChrgitmLv == "2" {
  8053. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8054. }
  8055. if item.ChrgitmLv == "3" {
  8056. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8057. }
  8058. }
  8059. if item.MedChrgitmType == "11" { //中成费
  8060. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8061. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8062. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8063. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8064. if item.ChrgitmLv == "1" {
  8065. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8066. }
  8067. if item.ChrgitmLv == "2" {
  8068. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8069. }
  8070. if item.ChrgitmLv == "3" {
  8071. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8072. }
  8073. }
  8074. if item.MedChrgitmType == "14" { //其他费
  8075. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8076. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8077. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8078. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8079. if item.ChrgitmLv == "1" {
  8080. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8081. }
  8082. if item.ChrgitmLv == "2" {
  8083. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8084. }
  8085. if item.ChrgitmLv == "3" {
  8086. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8087. }
  8088. }
  8089. }
  8090. var iteminfoStructs []service.IteminfoStruct
  8091. if bedCostTotal != 0 {
  8092. iteminfo.MedChrgitm = "01"
  8093. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8094. iteminfo.Amt = bedCostTotal
  8095. iteminfo.ClaaSumfee = bed_claa_sunmfee
  8096. iteminfo.ClabAmt = bed_clab_amt
  8097. iteminfo.OthAmt = bed_other_amt
  8098. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8099. }
  8100. if checkCostTotal != 0 {
  8101. iteminfo.MedChrgitm = "03"
  8102. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8103. iteminfo.Amt = checkCostTotal
  8104. iteminfo.ClaaSumfee = check_claa_sunmfee
  8105. iteminfo.ClabAmt = check_clab_amt
  8106. iteminfo.OthAmt = check_other_amt
  8107. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8108. }
  8109. if laboratoryCostTotal != 0 {
  8110. iteminfo.MedChrgitm = "04"
  8111. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8112. iteminfo.Amt = laboratoryCostTotal
  8113. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8114. iteminfo.ClabAmt = laboratory_clab_amt
  8115. iteminfo.OthAmt = laboratory_other_amt
  8116. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8117. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8118. }
  8119. if treatCostTotal != 0 {
  8120. iteminfo.MedChrgitm = "05"
  8121. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8122. iteminfo.Amt = treatCostTotal
  8123. iteminfo.ClaaSumfee = treat_claa_sunmfee
  8124. iteminfo.ClabAmt = treat_clab_amt
  8125. iteminfo.OthAmt = treat_other_amt
  8126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8127. //(struct4101.IteminfoStruct, iteminfo)
  8128. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8129. }
  8130. if operationCostTotal != 0 {
  8131. iteminfo.MedChrgitm = "06"
  8132. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8133. iteminfo.Amt = operationCostTotal
  8134. iteminfo.ClaaSumfee = operation_claa_sunmfee
  8135. iteminfo.ClabAmt = operation_clab_amt
  8136. iteminfo.OthAmt = operation_other_amt
  8137. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8138. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8139. }
  8140. if materialCostTotal != 0 {
  8141. iteminfo.MedChrgitm = "08"
  8142. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8143. iteminfo.Amt = materialCostTotal
  8144. iteminfo.ClaaSumfee = material_claa_sunmfee
  8145. iteminfo.ClabAmt = material_clab_amt
  8146. iteminfo.OthAmt = material_other_amt
  8147. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8149. }
  8150. if westernMedicineCostTotal != 0 {
  8151. iteminfo.MedChrgitm = "09"
  8152. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8153. iteminfo.Amt = westernMedicineCostTotal
  8154. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8155. iteminfo.ClabAmt = westernMedicine_clab_amt
  8156. iteminfo.OthAmt = westernMedicine_other_amt
  8157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8159. }
  8160. if chineseTraditionalMedicineCostTotal != 0 {
  8161. iteminfo.MedChrgitm = "11"
  8162. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8163. iteminfo.Amt = westernMedicineCostTotal
  8164. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8165. iteminfo.ClabAmt = westernMedicine_clab_amt
  8166. iteminfo.OthAmt = westernMedicine_other_amt
  8167. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8169. }
  8170. if otherCostTotal != 0 {
  8171. iteminfo.MedChrgitm = "14"
  8172. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  8173. iteminfo.Amt = otherCostTotal
  8174. iteminfo.ClaaSumfee = other_claa_sunmfee
  8175. iteminfo.ClabAmt = other_clab_amt
  8176. iteminfo.OthAmt = other_other_amt
  8177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8179. }
  8180. struct4101.IteminfoStruct = iteminfoStructs
  8181. struct4101.Ntly = "中国"
  8182. struct4101.AdmCaty = "A03.06"
  8183. var resOther ResultSeventeenOther
  8184. var res ResultSeventeen
  8185. if miConfig.MdtrtareaAdmvs == "150499" {
  8186. var pp models.PublicParams
  8187. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8188. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8189. pp.FixmedinsName = miConfig.OrgName
  8190. pp.FixmedinsCode = miConfig.Code
  8191. pp.RequestUrl = miConfig.Url
  8192. pp.Cainfo = miConfig.Cainfo
  8193. pp.SecretKey = miConfig.SecretKey
  8194. pp.AccessKey = miConfig.AccessKey
  8195. pp.OpterName = curRoles.UserName
  8196. client := &http.Client{}
  8197. var req *http.Request
  8198. data := make(map[string]interface{})
  8199. data["struct4101"] = struct4101
  8200. data["pp"] = pp
  8201. bytesData, _ := json.Marshal(data)
  8202. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  8203. resp, _ := client.Do(req)
  8204. defer resp.Body.Close()
  8205. body, ioErr := ioutil.ReadAll(resp.Body)
  8206. if ioErr != nil {
  8207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. var respJSON map[string]interface{}
  8212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8218. userJSONBytes, _ := json.Marshal(respJSON)
  8219. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  8220. utils.ErrorLog("解析失败:%v", err)
  8221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8222. return
  8223. }
  8224. res.InfRefmsgid = resOther.InfRefmsgid
  8225. res.Output = resOther.Output
  8226. res.ErrMsg = resOther.ErrMsg
  8227. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  8228. res.Infcode = infocode
  8229. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8230. var pp models.PublicParams
  8231. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8232. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8233. pp.FixmedinsName = miConfig.OrgName
  8234. pp.FixmedinsCode = miConfig.Code
  8235. pp.RequestUrl = miConfig.Url
  8236. pp.Cainfo = miConfig.Cainfo
  8237. pp.SecretKey = miConfig.SecretKey
  8238. pp.AccessKey = miConfig.AccessKey
  8239. pp.OpterName = curRoles.UserName
  8240. result, _ := service.Jxyb4101(struct4101, pp)
  8241. var dat map[string]interface{}
  8242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8243. fmt.Println(dat)
  8244. } else {
  8245. fmt.Println(err)
  8246. }
  8247. userJSONBytes, _ := json.Marshal(dat)
  8248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8249. utils.ErrorLog("解析失败:%v", err)
  8250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8251. return
  8252. }
  8253. } else {
  8254. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  8255. var dat map[string]interface{}
  8256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8257. fmt.Println(dat)
  8258. } else {
  8259. fmt.Println(err)
  8260. }
  8261. userJSONBytes, _ := json.Marshal(dat)
  8262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8263. utils.ErrorLog("解析失败:%v", err)
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8265. return
  8266. }
  8267. }
  8268. if res.Infcode != 0 {
  8269. c.ServeSuccessJSON(map[string]interface{}{
  8270. "failed_code": -10,
  8271. "msg": res.ErrMsg,
  8272. })
  8273. return
  8274. } else {
  8275. if miConfig.MdtrtareaAdmvs != "150499" {
  8276. order.FaPiaoNumber = zero
  8277. order.FaPiaoCode = last_order.FaPiaoCode
  8278. service.UpdateOrder(order)
  8279. }
  8280. hisFundSettleListResult := &models.HisFundSettleListResult{
  8281. Number: res.Output.SetlListId,
  8282. Status: 1,
  8283. Ctime: time.Now().Unix(),
  8284. Mtime: time.Now().Unix(),
  8285. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8286. IsUpload: 1,
  8287. OrderId: order_id,
  8288. }
  8289. service.CreateUploadRecord(hisFundSettleListResult)
  8290. c.ServeSuccessJSON(map[string]interface{}{
  8291. "msg": "上传成功",
  8292. "result": hisFundSettleListResult,
  8293. })
  8294. return
  8295. }
  8296. }
  8297. func (c *HisApiController) GetBatchSettleList() {
  8298. orders, _ := service.GetAllHisOrder(10106)
  8299. for _, item := range orders {
  8300. order_id := item.ID
  8301. order, _ := service.GetHisOrderByIDTwo(order_id)
  8302. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  8303. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8304. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  8305. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  8306. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  8307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8308. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8309. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8310. if order.ID == 0 {
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8312. return
  8313. }
  8314. if his.BalanceAccountsType == 2 {
  8315. continue
  8316. }
  8317. struct4101 := service.Struct4101{
  8318. PsnNo: order.PsnNo,
  8319. MdtrtId: order.MdtrtId,
  8320. SetlId: order.SetlId,
  8321. PsnName: order.PsnName,
  8322. Gend: order.Gend,
  8323. Brdy: his.Brdy,
  8324. Age: his.Age,
  8325. Naty: order.Naty,
  8326. PatnCertType: "01",
  8327. Certno: order.Certno,
  8328. Prfs: "90",
  8329. ConerName: roles[0].UserName,
  8330. PatnRlts: "99",
  8331. ConerAddr: miConfig.OrgName,
  8332. ConerTel: admin.Mobile,
  8333. HiType: order.Insutype,
  8334. Insuplc: his.InsuplcAdmdvs,
  8335. MaindiagFlag: "1",
  8336. BillCode: order.SetlId,
  8337. BillNo: order.SetlId,
  8338. BizSn: order.Number,
  8339. PsnSelfPay: order.PsnPartAmt,
  8340. PsnOwnPay: order.PsnPartAmt,
  8341. AcctPay: order.AcctPay,
  8342. PsnCashpay: order.PsnCashPay,
  8343. HiPaymtd: "1",
  8344. Hsorg: his.InsuplcAdmdvs,
  8345. HsorgOpter: his.InsuplcAdmdvs,
  8346. MedinsFillPsn: curRoles.UserName,
  8347. MedinsFillDept: depart.Name,
  8348. IptMedType: "2",
  8349. }
  8350. struct4101.SetlBegnDate = order.SetlTime
  8351. struct4101.SetlEndDate = order.SetlTime
  8352. //if order.SettleType == 1 {
  8353. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  8354. // dateStr := t.Format("2006-01-02")
  8355. // struct4101.SetlBegnDate = dateStr
  8356. // struct4101.SetlEndDate = dateStr
  8357. //} else {
  8358. // t := time.Unix(int64(order.SettleStartTime), 0)
  8359. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  8360. // dateStartStr := t.Format("2006-01-02")
  8361. // dateEndStr := t2.Format("2006-01-02")
  8362. // struct4101.SetlBegnDate = dateStartStr
  8363. // struct4101.SetlEndDate = dateEndStr
  8364. //}
  8365. var rf []CustomFundPay
  8366. json.Unmarshal([]byte(order.SetlDetail), &rf)
  8367. var tempFunPays []service.CustomStruct
  8368. var tempFunPay610100 service.CustomStruct
  8369. for _, item := range rf {
  8370. if item.FundPayType == "610100" {
  8371. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  8372. tempFunPay610100.FundPayType = item.FundPayType
  8373. } else {
  8374. var tempFunPay service.CustomStruct
  8375. tempFunPay.FundPayamt = item.FundPayamt
  8376. tempFunPay.FundPayType = item.FundPayType
  8377. tempFunPays = append(tempFunPays, tempFunPay)
  8378. }
  8379. }
  8380. tempFunPays = append(tempFunPays, tempFunPay610100)
  8381. struct4101.CustomStruct = tempFunPays
  8382. var tempDiaginfos []service.DiaginfoStructTwo
  8383. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  8384. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  8385. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8386. var config []*models.HisXtDiagnoseConfig
  8387. for _, item := range diagnosis_ids {
  8388. id, _ := strconv.ParseInt(item, 10, 64)
  8389. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8390. config = append(config, &diagnosisConfig)
  8391. }
  8392. for index, item := range config {
  8393. if index == 0 {
  8394. var tempDiaginfo service.DiaginfoStructTwo
  8395. tempDiaginfo.DiagCode = item.CountryCode
  8396. tempDiaginfo.DiagName = item.CountryContentName
  8397. tempDiaginfo.DiagType = "1"
  8398. tempDiaginfo.MaindiagFlag = "1"
  8399. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8400. } else {
  8401. var tempDiaginfo service.DiaginfoStructTwo
  8402. tempDiaginfo.DiagCode = item.CountryCode
  8403. tempDiaginfo.DiagName = item.CountryContentName
  8404. tempDiaginfo.DiagType = "2"
  8405. tempDiaginfo.MaindiagFlag = "0"
  8406. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8407. }
  8408. }
  8409. struct4101.Diseinfo = tempDiaginfos
  8410. sickConfigTwo, _ := service.FindSickById(his.SickType)
  8411. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  8412. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  8413. tempOpspdiseinfo2.OprnOprtCode = ""
  8414. tempOpspdiseinfo2.OprnOprtName = ""
  8415. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  8416. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  8417. var iteminfo service.IteminfoStruct
  8418. var bedCostTotal float64 = 0 //床位总费
  8419. var bedCostSelfTotal float64 = 0 //床位自费
  8420. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8421. var examineCostTotal float64 = 0 //诊查总费
  8422. var examineCostSelfTotal float64 = 0 //诊查自费
  8423. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  8424. var nursingCostTotal float64 = 0 //护理总费
  8425. var nursingCostSelfTotal float64 = 0 //护理自费
  8426. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  8427. var chineseMedicineCostTotal float64 = 0 //中成药
  8428. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  8429. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  8430. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  8431. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  8432. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  8433. var registerCostTotal float64 = 0 //一般诊疗费
  8434. var registerCostSelfTotal float64 = 0 //一般诊疗费
  8435. var registerPartSelfTotal float64 = 0 //一般诊疗费
  8436. var operationCostTotal float64 = 0 //手术费
  8437. var operationCostSelfTotal float64 = 0 //手术费
  8438. var operationCostPartSelfTotal float64 = 0 //手术费
  8439. var otherCostTotal float64 = 0 //其他费用
  8440. var otherCostSelfTotal float64 = 0 //其他费用
  8441. var otherCostPartSelfTotal float64 = 0 //其他费用
  8442. var materialCostTotal float64 = 0 //材料费
  8443. var materialCostSelfTotal float64 = 0 //材料费
  8444. var materialCostPartSelfTotal float64 = 0 //材料费
  8445. var westernMedicineCostTotal float64 = 0 //西药费
  8446. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8447. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8448. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8449. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8450. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8451. var checkCostTotal float64 = 0 //检查费
  8452. var checkCostSelfTotal float64 = 0 //检查费
  8453. var checkCostPartSelfTotal float64 = 0 //检查费
  8454. var laboratoryCostTotal float64 = 0 //化验费
  8455. var laboratoryCostSelfTotal float64 = 0 //化验费
  8456. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8457. var treatCostTotal float64 = 0 //治疗费用
  8458. var treatCostSelfTotal float64 = 0 //治疗费用
  8459. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8460. decimal.DivisionPrecision = 2
  8461. var bed_fulamt_ownpay_amt float64 = 0
  8462. var examine_fulamt_ownpay_amt float64 = 0
  8463. var nursing_fulamt_ownpay_amt float64 = 0
  8464. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  8465. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  8466. var register_fulamt_ownpay_amt float64 = 0
  8467. var operation_fulamt_ownpay_amt float64 = 0
  8468. var other_fulamt_ownpay_amt float64 = 0
  8469. var westernMedicine_fulamt_ownpay_amt float64 = 0
  8470. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  8471. var check_fulamt_ownpay_amt float64 = 0
  8472. var material_fulamt_ownpay_amt float64 = 0
  8473. var laboratory_fulamt_ownpay_amt float64 = 0
  8474. var treat_fulamt_ownpay_amt float64 = 0
  8475. var bed_claa_sunmfee float64 = 0
  8476. var bed_clab_amt float64 = 0
  8477. var bed_other_amt float64 = 0
  8478. var examine_claa_sunmfee float64 = 0
  8479. var examine_clab_amt float64 = 0
  8480. var examine_other_amt float64 = 0
  8481. var nursing_claa_sunmfee float64 = 0
  8482. var nursing_clab_amt float64 = 0
  8483. var nursing_other_amt float64 = 0
  8484. var chinese_medicine_claa_sunmfee float64 = 0
  8485. var chinese_medicine_clab_amt float64 = 0
  8486. var chinese_medicine_other_amt float64 = 0
  8487. var commonly_treatment_claa_sunmfee float64 = 0
  8488. var commonly_treatment_clab_amt float64 = 0
  8489. var commonly_treatment_other_amt float64 = 0
  8490. var operation_claa_sunmfee float64 = 0
  8491. var operation_clab_amt float64 = 0
  8492. var operation_other_amt float64 = 0
  8493. var other_claa_sunmfee float64 = 0
  8494. var other_clab_amt float64 = 0
  8495. var other_other_amt float64 = 0
  8496. var westernMedicine_claa_sunmfee float64 = 0
  8497. var westernMedicine_clab_amt float64 = 0
  8498. var westernMedicine_other_amt float64 = 0
  8499. var chineseTraditional_claa_sunmfee float64 = 0
  8500. var chineseTraditional_clab_amt float64 = 0
  8501. var chineseTraditional_other_amt float64 = 0
  8502. var check_claa_sunmfee float64 = 0
  8503. var check_clab_amt float64 = 0
  8504. var check_other_amt float64 = 0
  8505. var material_claa_sunmfee float64 = 0
  8506. var material_clab_amt float64 = 0
  8507. var material_other_amt float64 = 0
  8508. var laboratory_claa_sunmfee float64 = 0
  8509. var laboratory_clab_amt float64 = 0
  8510. var laboratory_other_amt float64 = 0
  8511. var treat_claa_sunmfee float64 = 0
  8512. var treat_clab_amt float64 = 0
  8513. var treat_other_amt float64 = 0
  8514. var register_claa_sunmfee float64 = 0
  8515. var register_clab_amt float64 = 0
  8516. var register_other_amt float64 = 0
  8517. for _, item := range order.HisOrderInfo {
  8518. if item.MedChrgitmType == "01" { //床位费
  8519. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8520. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8521. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8522. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8523. if item.ChrgitmLv == "1" {
  8524. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8525. }
  8526. if item.ChrgitmLv == "2" {
  8527. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8528. }
  8529. if item.ChrgitmLv == "3" {
  8530. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8531. }
  8532. }
  8533. if item.MedChrgitmType == "02" { //诊查
  8534. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8535. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8536. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8537. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8538. if item.ChrgitmLv == "1" {
  8539. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8540. }
  8541. if item.ChrgitmLv == "2" {
  8542. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8543. }
  8544. if item.ChrgitmLv == "3" {
  8545. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8546. }
  8547. }
  8548. if item.MedChrgitmType == "03" { //检查费
  8549. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8550. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8551. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8552. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8553. if item.ChrgitmLv == "1" {
  8554. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8555. }
  8556. if item.ChrgitmLv == "2" {
  8557. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8558. }
  8559. if item.ChrgitmLv == "3" {
  8560. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8561. }
  8562. }
  8563. if item.MedChrgitmType == "04" { //化验费
  8564. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8565. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8566. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8567. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8568. if item.ChrgitmLv == "1" {
  8569. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8570. }
  8571. if item.ChrgitmLv == "2" {
  8572. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8573. }
  8574. if item.ChrgitmLv == "3" {
  8575. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8576. }
  8577. }
  8578. if item.MedChrgitmType == "05" { //治疗费
  8579. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8580. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8581. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8582. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8583. if item.ChrgitmLv == "1" {
  8584. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8585. }
  8586. if item.ChrgitmLv == "2" {
  8587. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8588. }
  8589. if item.ChrgitmLv == "3" {
  8590. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8591. }
  8592. }
  8593. if item.MedChrgitmType == "06" { //手术费
  8594. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8595. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8596. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8597. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8598. if item.ChrgitmLv == "1" {
  8599. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8600. }
  8601. if item.ChrgitmLv == "2" {
  8602. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8603. }
  8604. if item.ChrgitmLv == "3" {
  8605. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8606. }
  8607. }
  8608. if item.MedChrgitmType == "07" { //手术费
  8609. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8610. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8611. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8612. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8613. if item.ChrgitmLv == "1" {
  8614. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8615. }
  8616. if item.ChrgitmLv == "2" {
  8617. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8618. }
  8619. if item.ChrgitmLv == "3" {
  8620. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8621. }
  8622. }
  8623. if item.MedChrgitmType == "08" { //材料费
  8624. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8625. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8626. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8627. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8628. if item.ChrgitmLv == "1" {
  8629. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8630. }
  8631. if item.ChrgitmLv == "2" {
  8632. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8633. }
  8634. if item.ChrgitmLv == "3" {
  8635. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8636. }
  8637. }
  8638. if item.MedChrgitmType == "09" { //西药费
  8639. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8640. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8641. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8642. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8643. if item.ChrgitmLv == "1" {
  8644. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8645. }
  8646. if item.ChrgitmLv == "2" {
  8647. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8648. }
  8649. if item.ChrgitmLv == "3" {
  8650. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8651. }
  8652. }
  8653. if item.MedChrgitmType == "10" { //中药饮片
  8654. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8655. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8656. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8657. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8658. if item.ChrgitmLv == "1" {
  8659. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8660. }
  8661. if item.ChrgitmLv == "2" {
  8662. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8663. }
  8664. if item.ChrgitmLv == "3" {
  8665. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8666. }
  8667. }
  8668. if item.MedChrgitmType == "11" { //中成费
  8669. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8670. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8671. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8672. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8673. if item.ChrgitmLv == "1" {
  8674. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8675. }
  8676. if item.ChrgitmLv == "2" {
  8677. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8678. }
  8679. if item.ChrgitmLv == "3" {
  8680. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8681. }
  8682. }
  8683. if item.MedChrgitmType == "12" { //中成费
  8684. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8685. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8686. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8687. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8688. if item.ChrgitmLv == "1" {
  8689. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8690. }
  8691. if item.ChrgitmLv == "2" {
  8692. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8693. }
  8694. if item.ChrgitmLv == "3" {
  8695. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8696. }
  8697. }
  8698. if item.MedChrgitmType == "13" { //中成费
  8699. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8700. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8701. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8702. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8703. if item.ChrgitmLv == "1" {
  8704. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8705. }
  8706. if item.ChrgitmLv == "2" {
  8707. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8708. }
  8709. if item.ChrgitmLv == "3" {
  8710. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8711. }
  8712. }
  8713. if item.MedChrgitmType == "14" { //其他费
  8714. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8715. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8716. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8717. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8718. if item.ChrgitmLv == "1" {
  8719. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8720. }
  8721. if item.ChrgitmLv == "2" {
  8722. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8723. }
  8724. if item.ChrgitmLv == "3" {
  8725. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8726. }
  8727. }
  8728. }
  8729. var iteminfoStructs []service.IteminfoStruct
  8730. if bedCostTotal != 0 {
  8731. iteminfo.MedChrgitm = "01"
  8732. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8733. iteminfo.Amt = bedCostTotal
  8734. iteminfo.ClaaSumfee = bed_claa_sunmfee
  8735. iteminfo.ClabAmt = bed_clab_amt
  8736. iteminfo.OthAmt = bed_other_amt
  8737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8738. }
  8739. if examineCostTotal != 0 {
  8740. iteminfo.MedChrgitm = "02"
  8741. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  8742. iteminfo.Amt = examineCostTotal
  8743. iteminfo.ClaaSumfee = examine_claa_sunmfee
  8744. iteminfo.ClabAmt = examine_clab_amt
  8745. iteminfo.OthAmt = examine_other_amt
  8746. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8747. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8748. }
  8749. if checkCostTotal != 0 {
  8750. iteminfo.MedChrgitm = "03"
  8751. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8752. iteminfo.Amt = checkCostTotal
  8753. iteminfo.ClaaSumfee = check_claa_sunmfee
  8754. iteminfo.ClabAmt = check_clab_amt
  8755. iteminfo.OthAmt = check_other_amt
  8756. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8757. }
  8758. if laboratoryCostTotal != 0 {
  8759. iteminfo.MedChrgitm = "04"
  8760. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8761. iteminfo.Amt = laboratoryCostTotal
  8762. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8763. iteminfo.ClabAmt = laboratory_clab_amt
  8764. iteminfo.OthAmt = laboratory_other_amt
  8765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8767. }
  8768. if treatCostTotal != 0 {
  8769. iteminfo.MedChrgitm = "05"
  8770. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8771. iteminfo.Amt = treatCostTotal
  8772. iteminfo.ClaaSumfee = treat_claa_sunmfee
  8773. iteminfo.ClabAmt = treat_clab_amt
  8774. iteminfo.OthAmt = treat_other_amt
  8775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8776. //(struct4101.IteminfoStruct, iteminfo)
  8777. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8778. }
  8779. if operationCostTotal != 0 {
  8780. iteminfo.MedChrgitm = "06"
  8781. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8782. iteminfo.Amt = operationCostTotal
  8783. iteminfo.ClaaSumfee = operation_claa_sunmfee
  8784. iteminfo.ClabAmt = operation_clab_amt
  8785. iteminfo.OthAmt = operation_other_amt
  8786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8788. }
  8789. if nursingCostTotal != 0 {
  8790. iteminfo.MedChrgitm = "07"
  8791. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  8792. iteminfo.Amt = nursingCostTotal
  8793. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  8794. iteminfo.ClabAmt = nursing_clab_amt
  8795. iteminfo.OthAmt = nursing_other_amt
  8796. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8797. }
  8798. if materialCostTotal != 0 {
  8799. iteminfo.MedChrgitm = "08"
  8800. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8801. iteminfo.Amt = materialCostTotal
  8802. iteminfo.ClaaSumfee = material_claa_sunmfee
  8803. iteminfo.ClabAmt = material_clab_amt
  8804. iteminfo.OthAmt = material_other_amt
  8805. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8806. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8807. }
  8808. if westernMedicineCostTotal != 0 {
  8809. iteminfo.MedChrgitm = "09"
  8810. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8811. iteminfo.Amt = westernMedicineCostTotal
  8812. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8813. iteminfo.ClabAmt = westernMedicine_clab_amt
  8814. iteminfo.OthAmt = westernMedicine_other_amt
  8815. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8816. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8817. }
  8818. if chineseMedicineCostTotal != 0 {
  8819. iteminfo.MedChrgitm = "10"
  8820. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  8821. iteminfo.Amt = chineseMedicineCostTotal
  8822. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  8823. iteminfo.ClabAmt = chinese_medicine_clab_amt
  8824. iteminfo.OthAmt = chinese_medicine_other_amt
  8825. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8827. }
  8828. if chineseTraditionalMedicineCostTotal != 0 {
  8829. iteminfo.MedChrgitm = "11"
  8830. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8831. iteminfo.Amt = westernMedicineCostTotal
  8832. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8833. iteminfo.ClabAmt = westernMedicine_clab_amt
  8834. iteminfo.OthAmt = westernMedicine_other_amt
  8835. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8837. }
  8838. if commonlyTreatmentCostTotal != 0 {
  8839. iteminfo.MedChrgitm = "12"
  8840. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  8841. iteminfo.Amt = commonlyTreatmentCostTotal
  8842. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  8843. iteminfo.ClabAmt = commonly_treatment_clab_amt
  8844. iteminfo.OthAmt = commonly_treatment_other_amt
  8845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8847. }
  8848. if registerCostTotal != 0 {
  8849. iteminfo.MedChrgitm = "13"
  8850. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  8851. iteminfo.Amt = registerCostTotal
  8852. iteminfo.ClaaSumfee = register_claa_sunmfee
  8853. iteminfo.ClabAmt = register_clab_amt
  8854. iteminfo.OthAmt = register_other_amt
  8855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8857. }
  8858. if otherCostTotal != 0 {
  8859. iteminfo.MedChrgitm = "14"
  8860. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  8861. iteminfo.Amt = otherCostTotal
  8862. iteminfo.ClaaSumfee = other_claa_sunmfee
  8863. iteminfo.ClabAmt = other_clab_amt
  8864. iteminfo.OthAmt = other_other_amt
  8865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8867. }
  8868. struct4101.IteminfoStruct = iteminfoStructs
  8869. time_arr := strings.Split(order.SetlTime, " ")
  8870. struct4101.AdmTime = time_arr[0]
  8871. struct4101.AdmEndTime = time_arr[0]
  8872. struct4101.DoctorName = doctor.UserName
  8873. struct4101.DoctorCode = doctor.DoctorNumber
  8874. struct4101.Ntly = "中国"
  8875. struct4101.AdmCaty = "A03.06"
  8876. var res ResultSeventeen
  8877. if miConfig.MdtrtareaAdmvs == "421300" {
  8878. data := make(map[string]interface{})
  8879. data["struct4101"] = struct4101
  8880. data["secret_key"] = miConfig.SecretKey
  8881. data["org_name"] = miConfig.OrgName
  8882. data["opera"] = curRoles.UserName
  8883. data["code"] = miConfig.Code
  8884. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8886. client := &http.Client{}
  8887. bytesData, _ := json.Marshal(data)
  8888. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  8889. resp, _ := client.Do(req)
  8890. defer resp.Body.Close()
  8891. body, ioErr := ioutil.ReadAll(resp.Body)
  8892. if ioErr != nil {
  8893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. var respJSON map[string]interface{}
  8898. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8904. userJSONBytes, _ := json.Marshal(respJSON)
  8905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8906. utils.ErrorLog("解析失败:%v", err)
  8907. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8908. adminUser := c.GetAdminUserInfo()
  8909. errlog := &models.HisOrderError{
  8910. UserOrgId: adminUser.CurrentOrgId,
  8911. Ctime: time.Now().Unix(),
  8912. Mtime: time.Now().Unix(),
  8913. ErrMsg: res.ErrMsg + "解析失败",
  8914. Status: 1,
  8915. PatientId: order_id,
  8916. Stage: 10088,
  8917. }
  8918. service.CreateErrMsgLog(errlog)
  8919. continue
  8920. }
  8921. } else {
  8922. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  8923. fmt.Println(result)
  8924. var dat map[string]interface{}
  8925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8926. fmt.Println(dat)
  8927. } else {
  8928. fmt.Println(err)
  8929. }
  8930. userJSONBytes, _ := json.Marshal(dat)
  8931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8932. utils.ErrorLog("解析失败:%v", err)
  8933. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8934. adminUser := c.GetAdminUserInfo()
  8935. errlog := &models.HisOrderError{
  8936. UserOrgId: adminUser.CurrentOrgId,
  8937. Ctime: time.Now().Unix(),
  8938. Mtime: time.Now().Unix(),
  8939. ErrMsg: res.ErrMsg + "解析失败",
  8940. Status: 1,
  8941. PatientId: order_id,
  8942. Stage: 10106,
  8943. }
  8944. service.CreateErrMsgLog(errlog)
  8945. continue
  8946. }
  8947. }
  8948. if res.Infcode != 0 {
  8949. adminUser := c.GetAdminUserInfo()
  8950. errlog := &models.HisOrderError{
  8951. UserOrgId: adminUser.CurrentOrgId,
  8952. Ctime: time.Now().Unix(),
  8953. Mtime: time.Now().Unix(),
  8954. ErrMsg: res.ErrMsg,
  8955. Status: 1,
  8956. PatientId: order_id,
  8957. Stage: 10106,
  8958. }
  8959. service.CreateErrMsgLog(errlog)
  8960. continue
  8961. } else {
  8962. hisFundSettleListResult := &models.HisFundSettleListResult{
  8963. Number: res.Output.SetlListId,
  8964. Status: 1,
  8965. Ctime: time.Now().Unix(),
  8966. Mtime: time.Now().Unix(),
  8967. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8968. IsUpload: 1,
  8969. OrderId: order_id,
  8970. }
  8971. service.CreateUploadRecord(hisFundSettleListResult)
  8972. continue
  8973. }
  8974. }
  8975. }
  8976. func (c *HisApiController) GetOrgInfo() {
  8977. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  8978. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  8979. }
  8980. func (c *HisApiController) GetHisPatientInfo() {
  8981. medical_insurance_card := c.GetString("medical_insurance_card")
  8982. id_card_type, _ := c.GetInt64("id_card_type")
  8983. id_card := c.GetString("id_card")
  8984. adminInfo := c.GetAdminUserInfo()
  8985. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8986. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8987. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  8988. IdCardNo := ""
  8989. if id_card_type == 1 {
  8990. IdCardNo = medical_insurance_card
  8991. } else if id_card_type == 2 {
  8992. IdCardNo = id_card
  8993. }
  8994. if config.IsOpen == 1 {
  8995. 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
  8996. resp, requestErr := http.Get(api)
  8997. if requestErr != nil {
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. defer resp.Body.Close()
  9002. body, ioErr := ioutil.ReadAll(resp.Body)
  9003. if ioErr != nil {
  9004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9006. return
  9007. }
  9008. var respJSON map[string]interface{}
  9009. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9015. userJSONBytes, _ := json.Marshal(userJSON)
  9016. var res ResultTwo
  9017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9018. utils.ErrorLog("解析失败:%v", err)
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9023. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9024. infoStr := string(Iinfos)
  9025. idetinfoStr := string(Idetinfos)
  9026. if res.Infcode == 0 {
  9027. his := models.VMHisPatient{
  9028. Status: 1,
  9029. Ctime: time.Now().Unix(),
  9030. Mtime: time.Now().Unix(),
  9031. PsnNo: res.Output.Baseinfo.PsnNo,
  9032. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9033. Certno: res.Output.Baseinfo.Certno,
  9034. PsnName: res.Output.Baseinfo.PsnName,
  9035. Gend: res.Output.Baseinfo.Gend,
  9036. Naty: res.Output.Baseinfo.Naty,
  9037. Brdy: res.Output.Baseinfo.Brdy,
  9038. Age: res.Output.Baseinfo.Age,
  9039. Iinfo: infoStr,
  9040. Idetinfo: idetinfoStr,
  9041. UserOrgId: adminInfo.CurrentOrgId,
  9042. IsReturn: 1,
  9043. IdCardType: id_card_type,
  9044. }
  9045. c.ServeSuccessJSON(map[string]interface{}{
  9046. "info": his,
  9047. })
  9048. } else {
  9049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9050. return
  9051. }
  9052. }
  9053. }
  9054. //func GetBasBaseInfo() (jsonStr string, err error) {
  9055. //
  9056. // handle := syscall.NewLazyDLL("SSCard.dll")
  9057. // add := handle.NewProc("ReadCardBas")
  9058. // str := make([]byte, 1024)
  9059. // str1 := make([]byte, 1024)
  9060. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  9061. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  9062. //
  9063. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  9064. //
  9065. // fmt.Println("> Add(4,5)的结果为:", ret)
  9066. // handle.Release()
  9067. //
  9068. // return "", nil
  9069. //
  9070. //}
  9071. //func GetQRBaseInfo() (jsonStr string, err error) {
  9072. // handle := syscall.LoadDLL("SSCard.dll")
  9073. // ReadCardBas := handle.FindProc("GetQRBase")
  9074. //
  9075. // str := make([]byte, 256)
  9076. // str1 := make([]byte, 256)
  9077. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  9078. //
  9079. // fmt.Println(string(str))
  9080. // fmt.Println(r)
  9081. // return string(str), nil
  9082. //}
  9083. //func CardInit() int {
  9084. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  9085. // add := DllTestDef.MustFindProc("Init")
  9086. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  9087. // if err != nil {
  9088. // fmt.Println("SSCard的运算结果为:", ret)
  9089. // }
  9090. // result := int(ret)
  9091. // return result
  9092. //}
  9093. //func CardInit() int {
  9094. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  9095. // if err != nil {
  9096. // fmt.Println("SSCard的运算结果为:", ret)
  9097. // }
  9098. // fmt.Println(err)
  9099. // result := int(ret)
  9100. // return result
  9101. //}
  9102. func IntPtr(n int) uintptr {
  9103. return uintptr(n)
  9104. }
  9105. func StrPtr(s string) uintptr {
  9106. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  9107. }
  9108. type Result2001 struct {
  9109. Cainfo interface{} `json:"cainfo"`
  9110. ErrMsg string `json:"err_msg"`
  9111. InfRefmsgid string `json:"inf_refmsgid"`
  9112. Infcode int64 `json:"infcode"`
  9113. Output struct {
  9114. Trtinfo struct {
  9115. PsnNo string `json:"psn_no"`
  9116. TrtChkType string `json:"trt_chk_type"`
  9117. FundPayType string `json:"fund_pay_type"`
  9118. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  9119. Begndate string `json:"begndate"`
  9120. Enddate string `json:"enddate"`
  9121. TrtChkRslt string `json:"trt_chk_rslt"`
  9122. } `json:"trtinfo"`
  9123. } `json:"output"`
  9124. RefmsgTime string `json:"refmsg_time"`
  9125. RespondTime string `json:"respond_time"`
  9126. Signtype interface{} `json:"signtype"`
  9127. WarnMsg interface{} `json:"warn_msg"`
  9128. }
  9129. type Result2001Org10265 struct {
  9130. Cainfo interface{} `json:"cainfo"`
  9131. ErrMsg string `json:"err_msg"`
  9132. InfRefmsgid string `json:"inf_refmsgid"`
  9133. Infcode string `json:"infcode"`
  9134. Output struct {
  9135. Trtinfo struct {
  9136. PsnNo string `json:"psn_no"`
  9137. TrtChkType string `json:"trt_chk_type"`
  9138. FundPayType string `json:"fund_pay_type"`
  9139. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  9140. Begndate string `json:"begndate"`
  9141. Enddate string `json:"enddate"`
  9142. TrtChkRslt string `json:"trt_chk_rslt"`
  9143. } `json:"trtinfo"`
  9144. } `json:"output"`
  9145. RefmsgTime string `json:"refmsg_time"`
  9146. RespondTime string `json:"respond_time"`
  9147. Signtype interface{} `json:"signtype"`
  9148. WarnMsg interface{} `json:"warn_msg"`
  9149. }
  9150. type ResultTwo struct {
  9151. ErrMsg string `json:"err_msg"`
  9152. InfRefmsgid string `json:"inf_refmsgid"`
  9153. Infcode int64 `json:"infcode"`
  9154. Output struct {
  9155. Baseinfo struct {
  9156. Age float64 `json:"age"`
  9157. Brdy string `json:"brdy"`
  9158. Certno string `json:"certno"`
  9159. Gend string `json:"gend"`
  9160. Naty string `json:"naty"`
  9161. PsnCertType string `json:"psn_cert_type"`
  9162. PsnName string `json:"psn_name"`
  9163. PsnNo string `json:"psn_no"`
  9164. } `json:"baseinfo"`
  9165. Idetinfo []interface{} `json:"idetinfo"`
  9166. Iinfo []struct {
  9167. Balc float64 `json:"balc"`
  9168. CvlservFlag string `json:"cvlserv_flag"`
  9169. EmpName string `json:"emp_name"`
  9170. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9171. Insutype string `json:"insutype"`
  9172. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9173. PausInsuDate string `json:"paus_insu_date"`
  9174. PsnInsuDate string `json:"psn_insu_date"`
  9175. PsnInsuStas string `json:"psn_insu_stas"`
  9176. PsnType string `json:"psn_type"`
  9177. } `json:"insuinfo"`
  9178. } `json:"output"`
  9179. RefmsgTime string `json:"refmsg_time"`
  9180. RespondTime string `json:"respond_time"`
  9181. Signtype interface{} `json:"signtype"`
  9182. WarnInfo interface{} `json:"warn_info"`
  9183. }
  9184. type ResultTwo10265 struct {
  9185. ErrMsg string `json:"err_msg"`
  9186. InfRefmsgid string `json:"inf_refmsgid"`
  9187. Infcode string `json:"infcode"`
  9188. Output struct {
  9189. Baseinfo struct {
  9190. Age float64 `json:"age"`
  9191. Brdy string `json:"brdy"`
  9192. Certno string `json:"certno"`
  9193. Gend string `json:"gend"`
  9194. Naty string `json:"naty"`
  9195. PsnCertType string `json:"psn_cert_type"`
  9196. PsnName string `json:"psn_name"`
  9197. PsnNo string `json:"psn_no"`
  9198. } `json:"baseinfo"`
  9199. Idetinfo []interface{} `json:"idetinfo"`
  9200. Iinfo []struct {
  9201. Balc float64 `json:"balc"`
  9202. CvlservFlag string `json:"cvlserv_flag"`
  9203. EmpName string `json:"emp_name"`
  9204. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9205. Insutype string `json:"insutype"`
  9206. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9207. PausInsuDate string `json:"paus_insu_date"`
  9208. PsnInsuDate string `json:"psn_insu_date"`
  9209. PsnInsuStas string `json:"psn_insu_stas"`
  9210. PsnType string `json:"psn_type"`
  9211. } `json:"insuinfo"`
  9212. } `json:"output"`
  9213. RefmsgTime string `json:"refmsg_time"`
  9214. RespondTime string `json:"respond_time"`
  9215. Signtype interface{} `json:"signtype"`
  9216. WarnInfo interface{} `json:"warn_info"`
  9217. }
  9218. type ResultThree struct {
  9219. Cainfo interface{} `json:"cainfo"`
  9220. ErrMsg string `json:"err_msg"`
  9221. InfRefmsgid string `json:"inf_refmsgid"`
  9222. Infcode int64 `json:"infcode"`
  9223. Output struct {
  9224. Data struct {
  9225. IptOtpNo string `json:"ipt_otp_no"`
  9226. MdtrtID string `json:"mdtrt_id"`
  9227. PsnNo string `json:"psn_no"`
  9228. } `json:"data"`
  9229. } `json:"output"`
  9230. RefmsgTime string `json:"refmsg_time"`
  9231. RespondTime string `json:"respond_time"`
  9232. Signtype interface{} `json:"signtype"`
  9233. WarnMsg interface{} `json:"warn_msg"`
  9234. }
  9235. type ResultThree10265 struct {
  9236. Cainfo interface{} `json:"cainfo"`
  9237. ErrMsg string `json:"err_msg"`
  9238. InfRefmsgid string `json:"inf_refmsgid"`
  9239. Infcode string `json:"infcode"`
  9240. Output struct {
  9241. Data struct {
  9242. IptOtpNo string `json:"ipt_otp_no"`
  9243. MdtrtID string `json:"mdtrt_id"`
  9244. PsnNo string `json:"psn_no"`
  9245. } `json:"data"`
  9246. } `json:"output"`
  9247. RefmsgTime string `json:"refmsg_time"`
  9248. RespondTime string `json:"respond_time"`
  9249. Signtype interface{} `json:"signtype"`
  9250. WarnMsg interface{} `json:"warn_msg"`
  9251. }
  9252. type ResultFour struct {
  9253. Cainfo string `json:"cainfo"`
  9254. ErrMsg string `json:"err_msg"`
  9255. InfRefmsgid string `json:"inf_refmsgid"`
  9256. Infcode int64 `json:"infcode"`
  9257. Output struct {
  9258. Result []struct {
  9259. BasMednFlag string `json:"bas_medn_flag"`
  9260. ChldMedcFlag string `json:"chld_medc_flag"`
  9261. ChrgitmLv string `json:"chrgitm_lv"`
  9262. Cnt float64 `json:"cnt"`
  9263. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  9264. DrtReimFlag string `json:"drt_reim_flag"`
  9265. FeedetlSn string `json:"feedetl_sn"`
  9266. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9267. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  9268. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9269. ListSpItemFlag string `json:"list_sp_item_flag"`
  9270. LmtUsedFlag string `json:"lmt_used_flag"`
  9271. MedChrgitmType string `json:"med_chrgitm_type"`
  9272. Memo string `json:"memo"`
  9273. OverlmtAmt float64 `json:"overlmt_amt"`
  9274. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9275. Pric float64 `json:"pric"`
  9276. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  9277. SelfpayProp float64 `json:"selfpay_prop"`
  9278. } `json:"result"`
  9279. } `json:"output"`
  9280. RefmsgTime string `json:"refmsg_time"`
  9281. RespondTime string `json:"respond_time"`
  9282. Signtype string `json:"signtype"`
  9283. WarnMsg string `json:"warn_msg"`
  9284. }
  9285. type ResultFour10265 struct {
  9286. Cainfo string `json:"cainfo"`
  9287. ErrMsg string `json:"err_msg"`
  9288. InfRefmsgid string `json:"inf_refmsgid"`
  9289. Infcode string `json:"infcode"`
  9290. Output struct {
  9291. Result []struct {
  9292. BasMednFlag string `json:"bas_medn_flag"`
  9293. ChldMedcFlag string `json:"chld_medc_flag"`
  9294. ChrgitmLv string `json:"chrgitm_lv"`
  9295. Cnt float64 `json:"cnt"`
  9296. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  9297. DrtReimFlag string `json:"drt_reim_flag"`
  9298. FeedetlSn string `json:"feedetl_sn"`
  9299. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9300. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  9301. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9302. ListSpItemFlag string `json:"list_sp_item_flag"`
  9303. LmtUsedFlag string `json:"lmt_used_flag"`
  9304. MedChrgitmType string `json:"med_chrgitm_type"`
  9305. Memo string `json:"memo"`
  9306. OverlmtAmt float64 `json:"overlmt_amt"`
  9307. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9308. Pric float64 `json:"pric"`
  9309. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  9310. SelfpayProp float64 `json:"selfpay_prop"`
  9311. } `json:"result"`
  9312. } `json:"output"`
  9313. RefmsgTime string `json:"refmsg_time"`
  9314. RespondTime string `json:"respond_time"`
  9315. Signtype string `json:"signtype"`
  9316. WarnMsg string `json:"warn_msg"`
  9317. }
  9318. type ResultMemo struct {
  9319. InsuAdmdvs string `json:"insuAdmdvs"`
  9320. }
  9321. // [{"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}]
  9322. type ResultIDInfo struct {
  9323. Begntime string `json:"begntime"`
  9324. Endtime string `json:"endtime"`
  9325. Memo string `json:"memo"`
  9326. }
  9327. type ResultFive struct {
  9328. Balc float64 `json:"balc"`
  9329. CvlservFlag string `json:"cvlserv_flag"`
  9330. EmpName string `json:"emp_name"`
  9331. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9332. Insutype string `json:"insutype"`
  9333. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9334. PausInsuDate string `json:"paus_insu_date"`
  9335. PsnInsuDate string `json:"psn_insu_date"`
  9336. PsnInsuStas string `json:"psn_insu_stas"`
  9337. PsnType string `json:"psn_type"`
  9338. }
  9339. type ResultSix struct {
  9340. Cainfo interface{} `json:"cainfo"`
  9341. ErrMsg string `json:"err_msg"`
  9342. InfRefmsgid string `json:"inf_refmsgid"`
  9343. Infcode int64 `json:"infcode"`
  9344. Output struct {
  9345. } `json:"output"`
  9346. RefmsgTime string `json:"refmsg_time"`
  9347. RespondTime string `json:"respond_time"`
  9348. Signtype interface{} `json:"signtype"`
  9349. WarnMsg interface{} `json:"warn_msg"`
  9350. }
  9351. type ResultSix10265 struct {
  9352. Cainfo interface{} `json:"cainfo"`
  9353. ErrMsg string `json:"err_msg"`
  9354. InfRefmsgid string `json:"inf_refmsgid"`
  9355. Infcode string `json:"infcode"`
  9356. Output struct {
  9357. } `json:"output"`
  9358. RefmsgTime string `json:"refmsg_time"`
  9359. RespondTime string `json:"respond_time"`
  9360. Signtype interface{} `json:"signtype"`
  9361. WarnMsg interface{} `json:"warn_msg"`
  9362. }
  9363. type ResultSeven struct {
  9364. Cainfo string `json:"cainfo"`
  9365. ErrMsg string `json:"err_msg"`
  9366. InfRefmsgid string `json:"inf_refmsgid"`
  9367. Infcode int64 `json:"infcode"`
  9368. Output struct {
  9369. Setldetail []interface{} `json:"setldetail"`
  9370. Setlinfo struct {
  9371. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9372. AcctPay float64 `json:"acct_pay"`
  9373. ActPayDedc float64 `json:"act_pay_dedc"`
  9374. Age float64 `json:"age"`
  9375. Balc float64 `json:"balc"`
  9376. Brdy string `json:"brdy"`
  9377. Certno string `json:"certno"`
  9378. ClrOptins string `json:"clr_optins"`
  9379. ClrType string `json:"clr_type"`
  9380. ClrWay string `json:"clr_way"`
  9381. CvlservFlag string `json:"cvlserv_flag"`
  9382. CvlservPay float64 `json:"cvlserv_pay"`
  9383. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9384. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9385. Gend string `json:"gend"`
  9386. HifesPay float64 `json:"hifes_pay"`
  9387. HifmiPay float64 `json:"hifmi_pay"`
  9388. HifpPay float64 `json:"hifp_pay"`
  9389. HospPartAmt float64 `json:"hosp_part_amt"`
  9390. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9391. Insutype string `json:"insutype"`
  9392. MafPay float64 `json:"maf_pay"`
  9393. MdtrtCertType string `json:"mdtrt_cert_type"`
  9394. HifobPay float64 `json:"hifob_pay"`
  9395. MdtrtID string `json:"mdtrt_id"`
  9396. MedType string `json:"med_type"`
  9397. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9398. MedinsSetlID string `json:"medins_setl_id"`
  9399. Naty string `json:"naty"`
  9400. OthPay float64 `json:"oth_pay"`
  9401. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9402. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9403. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9404. PsnCashPay float64 `json:"psn_cash_pay"`
  9405. PsnCertType string `json:"psn_cert_type"`
  9406. PsnName string `json:"psn_name"`
  9407. PsnNo string `json:"psn_no"`
  9408. PsnPartAmt float64 `json:"psn_part_amt"`
  9409. PsnType string `json:"psn_type"`
  9410. SetlID string `json:"setl_id"`
  9411. SetlTime string `json:"setl_time"`
  9412. } `json:"setlinfo"`
  9413. } `json:"output"`
  9414. RefmsgTime string `json:"refmsg_time"`
  9415. RespondTime string `json:"respond_time"`
  9416. Signtype interface{} `json:"signtype"`
  9417. WarnMsg interface{} `json:"warn_msg"`
  9418. }
  9419. type ResultSeven10265 struct {
  9420. Cainfo string `json:"cainfo"`
  9421. ErrMsg string `json:"err_msg"`
  9422. InfRefmsgid string `json:"inf_refmsgid"`
  9423. Infcode string `json:"infcode"`
  9424. Output struct {
  9425. Setldetail []interface{} `json:"setldetail"`
  9426. Setlinfo struct {
  9427. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9428. AcctPay float64 `json:"acct_pay"`
  9429. ActPayDedc float64 `json:"act_pay_dedc"`
  9430. Age float64 `json:"age"`
  9431. Balc float64 `json:"balc"`
  9432. Brdy string `json:"brdy"`
  9433. Certno string `json:"certno"`
  9434. ClrOptins string `json:"clr_optins"`
  9435. ClrType string `json:"clr_type"`
  9436. ClrWay string `json:"clr_way"`
  9437. CvlservFlag string `json:"cvlserv_flag"`
  9438. CvlservPay float64 `json:"cvlserv_pay"`
  9439. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9440. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9441. Gend string `json:"gend"`
  9442. HifesPay float64 `json:"hifes_pay"`
  9443. HifmiPay float64 `json:"hifmi_pay"`
  9444. HifpPay float64 `json:"hifp_pay"`
  9445. HospPartAmt float64 `json:"hosp_part_amt"`
  9446. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9447. Insutype string `json:"insutype"`
  9448. MafPay float64 `json:"maf_pay"`
  9449. MdtrtCertType string `json:"mdtrt_cert_type"`
  9450. HifobPay float64 `json:"hifob_pay"`
  9451. MdtrtID string `json:"mdtrt_id"`
  9452. MedType string `json:"med_type"`
  9453. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9454. MedinsSetlID string `json:"medins_setl_id"`
  9455. Naty string `json:"naty"`
  9456. OthPay float64 `json:"oth_pay"`
  9457. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9458. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9459. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9460. PsnCashPay float64 `json:"psn_cash_pay"`
  9461. PsnCertType string `json:"psn_cert_type"`
  9462. PsnName string `json:"psn_name"`
  9463. PsnNo string `json:"psn_no"`
  9464. PsnPartAmt float64 `json:"psn_part_amt"`
  9465. PsnType string `json:"psn_type"`
  9466. SetlID string `json:"setl_id"`
  9467. SetlTime string `json:"setl_time"`
  9468. } `json:"setlinfo"`
  9469. } `json:"output"`
  9470. RefmsgTime string `json:"refmsg_time"`
  9471. RespondTime string `json:"respond_time"`
  9472. Signtype interface{} `json:"signtype"`
  9473. WarnMsg interface{} `json:"warn_msg"`
  9474. }
  9475. type ResultSeven10265Two struct {
  9476. Cainfo string `json:"cainfo"`
  9477. ErrMsg string `json:"err_msg"`
  9478. InfRefmsgid string `json:"inf_refmsgid"`
  9479. Infcode string `json:"infcode"`
  9480. Output struct {
  9481. Setldetail []interface{} `json:"setldetail"`
  9482. Setlinfo struct {
  9483. AcctMulaidPay string `json:"acct_mulaid_pay"`
  9484. AcctPay float64 `json:"acct_pay"`
  9485. ActPayDedc float64 `json:"act_pay_dedc"`
  9486. Age float64 `json:"age"`
  9487. Balc float64 `json:"balc"`
  9488. Brdy string `json:"brdy"`
  9489. Certno string `json:"certno"`
  9490. ClrOptins string `json:"clr_optins"`
  9491. ClrType string `json:"clr_type"`
  9492. ClrWay string `json:"clr_way"`
  9493. CvlservFlag string `json:"cvlserv_flag"`
  9494. CvlservPay float64 `json:"cvlserv_pay"`
  9495. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9496. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9497. Gend string `json:"gend"`
  9498. HifesPay float64 `json:"hifes_pay"`
  9499. HifmiPay float64 `json:"hifmi_pay"`
  9500. HifpPay float64 `json:"hifp_pay"`
  9501. HospPartAmt string `json:"hosp_part_amt"`
  9502. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9503. Insutype string `json:"insutype"`
  9504. MafPay float64 `json:"maf_pay"`
  9505. MdtrtCertType string `json:"mdtrt_cert_type"`
  9506. HifobPay float64 `json:"hifob_pay"`
  9507. MdtrtID string `json:"mdtrt_id"`
  9508. MedType string `json:"med_type"`
  9509. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9510. MedinsSetlID string `json:"medins_setl_id"`
  9511. Naty string `json:"naty"`
  9512. OthPay float64 `json:"oth_pay"`
  9513. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9514. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  9515. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9516. PsnCashPay float64 `json:"psn_cash_pay"`
  9517. PsnCertType string `json:"psn_cert_type"`
  9518. PsnName string `json:"psn_name"`
  9519. PsnNo string `json:"psn_no"`
  9520. PsnPartAmt float64 `json:"psn_part_amt"`
  9521. PsnType string `json:"psn_type"`
  9522. SetlID string `json:"setl_id"`
  9523. SetlTime string `json:"setl_time"`
  9524. } `json:"setlinfo"`
  9525. } `json:"output"`
  9526. RefmsgTime string `json:"refmsg_time"`
  9527. RespondTime string `json:"respond_time"`
  9528. Signtype interface{} `json:"signtype"`
  9529. WarnMsg interface{} `json:"warn_msg"`
  9530. }
  9531. type ResultEight struct {
  9532. Cainfo string `json:"cainfo"`
  9533. ErrMsg string `json:"err_msg"`
  9534. InfRefmsgid string `json:"inf_refmsgid"`
  9535. Infcode int64 `json:"infcode"`
  9536. Output struct {
  9537. Stmtinfo struct {
  9538. SetlOptins string `json:"setl_optins"`
  9539. StmtRslt string `json:"stmt_rslt"`
  9540. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  9541. } `json:"stmtinfo"`
  9542. } `json:"output"`
  9543. RefmsgTime string `json:"refmsg_time"`
  9544. RespondTime string `json:"respond_time"`
  9545. Signtype interface{} `json:"signtype"`
  9546. WarnMsg interface{} `json:"warn_msg"`
  9547. }
  9548. type ResultEightFor10188 struct {
  9549. Cainfo string `json:"cainfo"`
  9550. ErrMsg string `json:"err_msg"`
  9551. InfRefmsgid string `json:"inf_refmsgid"`
  9552. Infcode string `json:"infcode"`
  9553. Output struct {
  9554. Stmtinfo struct {
  9555. SetlOptins string `json:"setl_optins"`
  9556. StmtRslt string `json:"stmt_rslt"`
  9557. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  9558. } `json:"stmtinfo"`
  9559. } `json:"output"`
  9560. RefmsgTime string `json:"refmsg_time"`
  9561. RespondTime string `json:"respond_time"`
  9562. Signtype interface{} `json:"signtype"`
  9563. WarnMsg interface{} `json:"warn_msg"`
  9564. }
  9565. type ResultNine struct {
  9566. Cainfo string `json:"cainfo"`
  9567. ErrMsg string `json:"err_msg"`
  9568. InfRefmsgid string `json:"inf_refmsgid"`
  9569. Infcode int64 `json:"infcode"`
  9570. Output struct {
  9571. FileQuryNo string `json:"file_qury_no"`
  9572. } `json:"output"`
  9573. RefmsgTime string `json:"refmsg_time"`
  9574. RespondTime string `json:"respond_time"`
  9575. Signtype interface{} `json:"signtype"`
  9576. WarnMsg interface{} `json:"warn_msg"`
  9577. }
  9578. type ResultTen struct {
  9579. Cainfo string `json:"cainfo"`
  9580. ErrMsg string `json:"err_msg"`
  9581. InfRefmsgid string `json:"inf_refmsgid"`
  9582. Infcode int64 `json:"infcode"`
  9583. Output struct {
  9584. DldEndtime string `json:"dld_endtime"`
  9585. FileQuryNo string `json:"file_qury_no"`
  9586. Filename string `json:"filename"`
  9587. } `json:"output"`
  9588. RefmsgTime string `json:"refmsg_time"`
  9589. RespondTime string `json:"respond_time"`
  9590. Signtype interface{} `json:"signtype"`
  9591. WarnMsg interface{} `json:"warn_msg"`
  9592. }
  9593. //type Autogenerated struct {
  9594. // Output struct {
  9595. // Setlinfo struct {
  9596. // SetlTime string `json:"setl_time"`
  9597. // CvlservPay float64 `json:"cvlserv_pay"`
  9598. // Year string `json:"year"`
  9599. // MedType string `json:"med_type"`
  9600. // PsnPay float64 `json:"psn_pay"`
  9601. // OpterID string `json:"opter_id"`
  9602. // Begndate string `json:"begndate"`
  9603. // FlxempeFlag string `json:"flxempe_flag"`
  9604. // HifmiPay float64 `json:"hifmi_pay"`
  9605. // PsnNo string `json:"psn_no"`
  9606. // ActPayDedc float64 `json:"act_pay_dedc"`
  9607. // MedinsSetlID interface{} `json:"medins_setl_id"`
  9608. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9609. // ClrWay string `json:"clr_way"`
  9610. // OthPay float64 `json:"oth_pay"`
  9611. // Gend string `json:"gend"`
  9612. // MdtrtID string `json:"mdtrt_id"`
  9613. // AcctPay float64 `json:"acct_pay"`
  9614. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  9615. // Insutype string `json:"insutype"`
  9616. // Invono interface{} `json:"invono"`
  9617. // Enddate string `json:"enddate"`
  9618. // CashPayamt float64 `json:"cash_payamt"`
  9619. // PsnType string `json:"psn_type"`
  9620. // FixmedinsName string `json:"fixmedins_name"`
  9621. // HifpPay float64 `json:"hifp_pay"`
  9622. // NewFlag interface{} `json:"new_flag"`
  9623. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9624. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  9625. // PayLoc string `json:"pay_loc"`
  9626. // ClrType string `json:"clr_type"`
  9627. // RefdSetlFlag string `json:"refd_setl_flag"`
  9628. // CvlservFlag string `json:"cvlserv_flag"`
  9629. // EmpName string `json:"emp_name"`
  9630. // Brdy string `json:"brdy"`
  9631. // Naty string `json:"naty"`
  9632. // Certno string `json:"certno"`
  9633. // DiseCode string `json:"dise_code"`
  9634. // FixmedinsCode string `json:"fixmedins_code"`
  9635. // DedcHospLv string `json:"dedc_hosp_lv"`
  9636. // OpterName string `json:"opter_name"`
  9637. // Balc float64 `json:"balc"`
  9638. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9639. // PsnCertType string `json:"psn_cert_type"`
  9640. // HifobPay float64 `json:"hifob_pay"`
  9641. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  9642. // HifesPay float64 `json:"hifes_pay"`
  9643. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9644. // OptTime string `json:"opt_time"`
  9645. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9646. // SetlID string `json:"setl_id"`
  9647. // MafPay float64 `json:"maf_pay"`
  9648. // PsnName string `json:"psn_name"`
  9649. // InsuOptins interface{} `json:"insu_optins"`
  9650. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9651. // ClrOptins string `json:"clr_optins"`
  9652. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9653. // DiseName string `json:"dise_name"`
  9654. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9655. // Age float64 `json:"age"`
  9656. // DtrtCertType string `json:"dtrt_cert_type"`
  9657. // HospLv string `json:"hosp_lv"`
  9658. // } `json:"setlinfo"`
  9659. // Setldetail []struct {
  9660. // FundPayType string `json:"fund_pay_type"`
  9661. // FundPayamt float64 `json:"fund_payamt"`
  9662. // SetlProcInfo interface{} `json:"setl_proc_info"`
  9663. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  9664. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  9665. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  9666. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9667. // } `json:"setldetail"`
  9668. // } `json:"output"`
  9669. // Infcode int `json:"infcode"`
  9670. // WarnMsg interface{} `json:"warn_msg"`
  9671. // Cainfo interface{} `json:"cainfo"`
  9672. // ErrMsg interface{} `json:"err_msg"`
  9673. // RefmsgTime string `json:"refmsg_time"`
  9674. // Signtype interface{} `json:"signtype"`
  9675. // RespondTime string `json:"respond_time"`
  9676. // InfRefmsgid string `json:"inf_refmsgid"`
  9677. //}
  9678. type ResultEleven struct {
  9679. Cainfo string `json:"cainfo"`
  9680. ErrMsg string `json:"err_msg"`
  9681. InfRefmsgid string `json:"inf_refmsgid"`
  9682. Infcode int64 `json:"infcode"`
  9683. Output struct {
  9684. Setlinfo struct {
  9685. SetlTime string `json:"setl_time"`
  9686. CvlservPay float64 `json:"cvlserv_pay"`
  9687. Year string `json:"year"`
  9688. MedType string `json:"med_type"`
  9689. PsnPay float64 `json:"psn_pay"`
  9690. OpterID string `json:"opter_id"`
  9691. Begndate string `json:"begndate"`
  9692. FlxempeFlag string `json:"flxempe_flag"`
  9693. HifmiPay float64 `json:"hifmi_pay"`
  9694. PsnNo string `json:"psn_no"`
  9695. ActPayDedc float64 `json:"act_pay_dedc"`
  9696. MedinsSetlID interface{} `json:"medins_setl_id"`
  9697. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9698. ClrWay string `json:"clr_way"`
  9699. OthPay float64 `json:"oth_pay"`
  9700. Gend string `json:"gend"`
  9701. MdtrtID string `json:"mdtrt_id"`
  9702. AcctPay float64 `json:"acct_pay"`
  9703. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9704. Insutype string `json:"insutype"`
  9705. Invono interface{} `json:"invono"`
  9706. Enddate string `json:"enddate"`
  9707. CashPayamt float64 `json:"cash_payamt"`
  9708. PsnType string `json:"psn_type"`
  9709. FixmedinsName string `json:"fixmedins_name"`
  9710. HifpPay float64 `json:"hifp_pay"`
  9711. NewFlag interface{} `json:"new_flag"`
  9712. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9713. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9714. PayLoc string `json:"pay_loc"`
  9715. ClrType string `json:"clr_type"`
  9716. RefdSetlFlag string `json:"refd_setl_flag"`
  9717. CvlservFlag string `json:"cvlserv_flag"`
  9718. EmpName string `json:"emp_name"`
  9719. Brdy string `json:"brdy"`
  9720. Naty string `json:"naty"`
  9721. Certno string `json:"certno"`
  9722. DiseCode string `json:"dise_code"`
  9723. FixmedinsCode string `json:"fixmedins_code"`
  9724. DedcHospLv string `json:"dedc_hosp_lv"`
  9725. OpterName string `json:"opter_name"`
  9726. Balc float64 `json:"balc"`
  9727. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9728. PsnCertType string `json:"psn_cert_type"`
  9729. HifobPay float64 `json:"hifob_pay"`
  9730. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9731. HifesPay float64 `json:"hifes_pay"`
  9732. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9733. OptTime string `json:"opt_time"`
  9734. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9735. SetlID string `json:"setl_id"`
  9736. MafPay float64 `json:"maf_pay"`
  9737. PsnName string `json:"psn_name"`
  9738. InsuOptins interface{} `json:"insu_optins"`
  9739. PrefFundPay interface{} `json:"pref_fund_pay"`
  9740. ClrOptins string `json:"clr_optins"`
  9741. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9742. DiseName string `json:"dise_name"`
  9743. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9744. Age float64 `json:"age"`
  9745. DtrtCertType string `json:"dtrt_cert_type"`
  9746. HospLv string `json:"hosp_lv"`
  9747. PsnCashPay float64
  9748. } `json:"setlinfo"`
  9749. } `json:"output"`
  9750. RefmsgTime string `json:"refmsg_time"`
  9751. RespondTime string `json:"respond_time"`
  9752. Signtype interface{} `json:"signtype"`
  9753. WarnMsg interface{} `json:"warn_msg"`
  9754. }
  9755. type ResultEleven10265 struct {
  9756. Cainfo string `json:"cainfo"`
  9757. ErrMsg string `json:"err_msg"`
  9758. InfRefmsgid string `json:"inf_refmsgid"`
  9759. Infcode string `json:"infcode"`
  9760. Output struct {
  9761. Setlinfo struct {
  9762. SetlTime string `json:"setl_time"`
  9763. CvlservPay float64 `json:"cvlserv_pay"`
  9764. Year string `json:"year"`
  9765. MedType string `json:"med_type"`
  9766. PsnPay float64 `json:"psn_pay"`
  9767. OpterID string `json:"opter_id"`
  9768. Begndate string `json:"begndate"`
  9769. FlxempeFlag string `json:"flxempe_flag"`
  9770. HifmiPay float64 `json:"hifmi_pay"`
  9771. PsnNo string `json:"psn_no"`
  9772. ActPayDedc float64 `json:"act_pay_dedc"`
  9773. MedinsSetlID interface{} `json:"medins_setl_id"`
  9774. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9775. ClrWay string `json:"clr_way"`
  9776. OthPay float64 `json:"oth_pay"`
  9777. Gend string `json:"gend"`
  9778. MdtrtID string `json:"mdtrt_id"`
  9779. AcctPay float64 `json:"acct_pay"`
  9780. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9781. Insutype string `json:"insutype"`
  9782. Invono interface{} `json:"invono"`
  9783. Enddate string `json:"enddate"`
  9784. CashPayamt float64 `json:"cash_payamt"`
  9785. PsnType string `json:"psn_type"`
  9786. FixmedinsName string `json:"fixmedins_name"`
  9787. HifpPay float64 `json:"hifp_pay"`
  9788. NewFlag interface{} `json:"new_flag"`
  9789. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9790. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9791. PayLoc string `json:"pay_loc"`
  9792. ClrType string `json:"clr_type"`
  9793. RefdSetlFlag string `json:"refd_setl_flag"`
  9794. CvlservFlag string `json:"cvlserv_flag"`
  9795. EmpName string `json:"emp_name"`
  9796. Brdy string `json:"brdy"`
  9797. Naty string `json:"naty"`
  9798. Certno string `json:"certno"`
  9799. DiseCode string `json:"dise_code"`
  9800. FixmedinsCode string `json:"fixmedins_code"`
  9801. DedcHospLv string `json:"dedc_hosp_lv"`
  9802. OpterName string `json:"opter_name"`
  9803. Balc float64 `json:"balc"`
  9804. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9805. PsnCertType string `json:"psn_cert_type"`
  9806. HifobPay float64 `json:"hifob_pay"`
  9807. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9808. HifesPay float64 `json:"hifes_pay"`
  9809. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9810. OptTime string `json:"opt_time"`
  9811. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9812. SetlID string `json:"setl_id"`
  9813. MafPay float64 `json:"maf_pay"`
  9814. PsnName string `json:"psn_name"`
  9815. InsuOptins interface{} `json:"insu_optins"`
  9816. PrefFundPay interface{} `json:"pref_fund_pay"`
  9817. ClrOptins string `json:"clr_optins"`
  9818. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9819. DiseName string `json:"dise_name"`
  9820. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9821. Age float64 `json:"age"`
  9822. DtrtCertType string `json:"dtrt_cert_type"`
  9823. HospLv string `json:"hosp_lv"`
  9824. PsnCashPay float64
  9825. } `json:"setlinfo"`
  9826. } `json:"output"`
  9827. RefmsgTime string `json:"refmsg_time"`
  9828. RespondTime string `json:"respond_time"`
  9829. Signtype interface{} `json:"signtype"`
  9830. WarnMsg interface{} `json:"warn_msg"`
  9831. }
  9832. type ResultTwelve struct {
  9833. Cainfo string `json:"cainfo"`
  9834. ErrMsg string `json:"err_msg"`
  9835. InfRefmsgid string `json:"inf_refmsgid"`
  9836. Infcode int64 `json:"infcode"`
  9837. Output struct {
  9838. MdtrtId string `json:"mdtrt_id"`
  9839. ChrgBchno string `json:"chrg_bchno"`
  9840. PsnNo string `json:"psn_no"`
  9841. } `json:"output"`
  9842. RefmsgTime string `json:"refmsg_time"`
  9843. RespondTime string `json:"respond_time"`
  9844. Signtype interface{} `json:"signtype"`
  9845. WarnMsg interface{} `json:"warn_msg"`
  9846. }
  9847. type ResultThirteen struct {
  9848. ErrMsg string `json:"err_msg"`
  9849. InfRefmsgid string `json:"inf_refmsgid"`
  9850. Infcode int64 `json:"infcode"`
  9851. Output struct {
  9852. Result struct {
  9853. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9854. } `json:"result"`
  9855. } `json:"output"`
  9856. RefmsgTime string `json:"refmsg_time"`
  9857. RespondTime string `json:"respond_time"`
  9858. Signtype interface{} `json:"signtype"`
  9859. WarnInfo interface{} `json:"warn_info"`
  9860. }
  9861. type ResultThirteen10265 struct {
  9862. ErrMsg string `json:"err_msg"`
  9863. InfRefmsgid string `json:"inf_refmsgid"`
  9864. Infcode string `json:"infcode"`
  9865. Output struct {
  9866. Result struct {
  9867. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9868. } `json:"result"`
  9869. } `json:"output"`
  9870. RefmsgTime string `json:"refmsg_time"`
  9871. RespondTime string `json:"respond_time"`
  9872. Signtype interface{} `json:"signtype"`
  9873. WarnInfo interface{} `json:"warn_info"`
  9874. }
  9875. type ResultFourteen struct {
  9876. ErrMsg string `json:"err_msg"`
  9877. InfRefmsgid string `json:"inf_refmsgid"`
  9878. Infcode int64 `json:"infcode"`
  9879. Output struct {
  9880. } `json:"output"`
  9881. RefmsgTime string `json:"refmsg_time"`
  9882. RespondTime string `json:"respond_time"`
  9883. Signtype interface{} `json:"signtype"`
  9884. WarnInfo interface{} `json:"warn_info"`
  9885. }
  9886. type ResultFourteen10265 struct {
  9887. ErrMsg string `json:"err_msg"`
  9888. InfRefmsgid string `json:"inf_refmsgid"`
  9889. Infcode string `json:"infcode"`
  9890. Output struct {
  9891. } `json:"output"`
  9892. RefmsgTime string `json:"refmsg_time"`
  9893. RespondTime string `json:"respond_time"`
  9894. Signtype interface{} `json:"signtype"`
  9895. WarnInfo interface{} `json:"warn_info"`
  9896. }
  9897. type ResultSixteen struct {
  9898. Cainfo string `json:"cainfo"`
  9899. ErrMsg string `json:"err_msg"`
  9900. InfRefmsgid string `json:"inf_refmsgid"`
  9901. Infcode int64 `json:"infcode"`
  9902. Output struct {
  9903. Setldetail []interface{} `json:"setldetail"`
  9904. Setlinfo struct {
  9905. MdtrtID string `json:"mdtrt_id"`
  9906. SetlID string `json:"setl_id"`
  9907. ClrOptins string `json:"clr_optins"`
  9908. SetlTime string `json:"setl_time"`
  9909. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9910. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9911. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9912. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9913. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9914. ActPayDedc float64 `json:"act_pay_dedc"`
  9915. HifpPay float64 `json:"hifp_pay"`
  9916. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9917. Lfpay float64 `json:"selfpay"`
  9918. CvlservPay float64 `json:"cvlserv_pay"`
  9919. HifesPay float64 `json:"hifes_pay"`
  9920. HifmiPay float64 `json:"hifmi_pay"`
  9921. HifobPay float64 `json:"hifob_pay"`
  9922. MafPay float64 `json:"maf_pay"`
  9923. OthPay float64 `json:"oth_pay"`
  9924. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9925. PsnPartAmt float64 `json:"psn_part_amt"`
  9926. AcctPay float64 `json:"acct_pay"`
  9927. Balc float64 `json:"balc"`
  9928. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9929. HospPartAmt float64 `json:"hosp_part_amt"`
  9930. MedinsSetlID string `json:"medins_setl_id"`
  9931. PdnCashPay string `json:"pdn_cash_pay"`
  9932. } `json:"setlinfo"`
  9933. } `json:"output"`
  9934. RefmsgTime string `json:"refmsg_time"`
  9935. RespondTime string `json:"respond_time"`
  9936. Signtype interface{} `json:"signtype"`
  9937. WarnMsg interface{} `json:"warn_msg"`
  9938. }
  9939. type ResultSixteen10265 struct {
  9940. Cainfo string `json:"cainfo"`
  9941. ErrMsg string `json:"err_msg"`
  9942. InfRefmsgid string `json:"inf_refmsgid"`
  9943. Infcode string `json:"infcode"`
  9944. Output struct {
  9945. Setldetail []interface{} `json:"setldetail"`
  9946. Setlinfo struct {
  9947. MdtrtID string `json:"mdtrt_id"`
  9948. SetlID string `json:"setl_id"`
  9949. ClrOptins string `json:"clr_optins"`
  9950. SetlTime string `json:"setl_time"`
  9951. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9952. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9953. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9954. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9955. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9956. ActPayDedc float64 `json:"act_pay_dedc"`
  9957. HifpPay float64 `json:"hifp_pay"`
  9958. PoolPropSe float64 `json:"pool_prop_selfpay"`
  9959. Lfpay float64 `json:"selfpay"`
  9960. CvlservPay float64 `json:"cvlserv_pay"`
  9961. HifesPay float64 `json:"hifes_pay"`
  9962. HifmiPay float64 `json:"hifmi_pay"`
  9963. HifobPay float64 `json:"hifob_pay"`
  9964. MafPay float64 `json:"maf_pay"`
  9965. OthPay float64 `json:"oth_pay"`
  9966. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9967. PsnPartAmt float64 `json:"psn_part_amt"`
  9968. AcctPay float64 `json:"acct_pay"`
  9969. Balc float64 `json:"balc"`
  9970. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9971. HospPartAmt float64 `json:"hosp_part_amt"`
  9972. MedinsSetlID string `json:"medins_setl_id"`
  9973. PdnCashPay string `json:"pdn_cash_pay"`
  9974. } `json:"setlinfo"`
  9975. } `json:"output"`
  9976. RefmsgTime string `json:"refmsg_time"`
  9977. RespondTime string `json:"respond_time"`
  9978. Signtype interface{} `json:"signtype"`
  9979. WarnMsg interface{} `json:"warn_msg"`
  9980. }
  9981. type ResultSixteen10265Two struct {
  9982. Cainfo string `json:"cainfo"`
  9983. ErrMsg string `json:"err_msg"`
  9984. InfRefmsgid string `json:"inf_refmsgid"`
  9985. Infcode string `json:"infcode"`
  9986. Output struct {
  9987. Setldetail []interface{} `json:"setldetail"`
  9988. Setlinfo interface{} `json:"setlinfo"`
  9989. } `json:"output"`
  9990. RefmsgTime string `json:"refmsg_time"`
  9991. RespondTime string `json:"respond_time"`
  9992. Signtype interface{} `json:"signtype"`
  9993. WarnMsg interface{} `json:"warn_msg"`
  9994. }
  9995. type ResultSeventeen struct {
  9996. ErrMsg string `json:"err_msg"`
  9997. InfRefmsgid string `json:"inf_refmsgid"`
  9998. Infcode int64 `json:"infcode"`
  9999. Output struct {
  10000. SetlListId string `json:"setl_list_id"`
  10001. } `json:"output"`
  10002. RefmsgTime string `json:"refmsg_time"`
  10003. RespondTime string `json:"respond_time"`
  10004. Signtype string `json:"signtype"`
  10005. WarnInfo string `json:"warn_info"`
  10006. }
  10007. type ResultSeventeenOther struct {
  10008. ErrMsg string `json:"err_msg"`
  10009. InfRefmsgid string `json:"inf_refmsgid"`
  10010. Infcode string `json:"infcode"`
  10011. Output struct {
  10012. SetlListId string `json:"setl_list_id"`
  10013. } `json:"output"`
  10014. RefmsgTime string `json:"refmsg_time"`
  10015. RespondTime string `json:"respond_time"`
  10016. Signtype string `json:"signtype"`
  10017. WarnInfo string `json:"warn_info"`
  10018. }
  10019. type Result90991 struct {
  10020. ErrMsg string `json:"err_msg"`
  10021. InfRefmsgid string `json:"inf_refmsgid"`
  10022. Infcode int64 `json:"infcode"`
  10023. Output struct {
  10024. Result struct {
  10025. PsnNo string `json:"psn_no"`
  10026. CardStat string `json:"card_stat"`
  10027. Certno string `json:"certno"`
  10028. PsnName string `json:"psn_name"`
  10029. CheckStat string `json:"check_stat"`
  10030. SscnoCheckStat string `json:"sscno_check_stat"`
  10031. } `json:"result"`
  10032. } `json:"output"`
  10033. RefmsgTime string `json:"refmsg_time"`
  10034. RespondTime string `json:"respond_time"`
  10035. Signtype interface{} `json:"signtype"`
  10036. WarnInfo interface{} `json:"warn_info"`
  10037. }
  10038. type Result90100 struct {
  10039. ErrMsg string `json:"err_msg"`
  10040. InfRefmsgid string `json:"inf_refmsgid"`
  10041. Infcode int64 `json:"infcode"`
  10042. Output struct {
  10043. PoolareaNo string `json:"poolarea_no"`
  10044. PoolareaNoName string `json:"poolarea_no_name"`
  10045. Insutype string `json:"insutype"`
  10046. InsutypeName string `json:"insutype_name"`
  10047. ClctType string `json:"clct_type"`
  10048. ClctTypeName string `json:"clct_type_name"`
  10049. ClctFlag string `json:"clct_flag"`
  10050. ClctFlagName string `json:"clct_flag_name"`
  10051. AccrymBegn string `json:"accrym_begn"`
  10052. AccrymEnd string `json:"accrym_end"`
  10053. ClctTime string `json:"clct_time"`
  10054. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  10055. } `json:"output"`
  10056. RefmsgTime string `json:"refmsg_time"`
  10057. RespondTime string `json:"respond_time"`
  10058. Signtype interface{} `json:"signtype"`
  10059. WarnInfo interface{} `json:"warn_info"`
  10060. }
  10061. type Custom struct {
  10062. DetItemFeeSumamt string
  10063. Cut string
  10064. FeedetlSn string
  10065. Price string
  10066. MedListCodg string
  10067. Type int64
  10068. AdviceId int64
  10069. ProjectId int64
  10070. ItemId int64
  10071. }
  10072. type Result5301 struct {
  10073. ErrMsg string `json:"err_msg"`
  10074. InfRefmsgid string `json:"inf_refmsgid"`
  10075. Infcode int64 `json:"infcode"`
  10076. Output struct {
  10077. Result []struct {
  10078. OpspDiseCode string `json:"opsp_dise_code"`
  10079. OpspDiseName string `json:"opsp_dise_name"`
  10080. Begndate string `json:"begndate"`
  10081. Enddate string `json:"enddate"`
  10082. } `json:"feedetail"`
  10083. } `json:"output"`
  10084. RefmsgTime string `json:"refmsg_time"`
  10085. RespondTime string `json:"respond_time"`
  10086. Signtype interface{} `json:"signtype"`
  10087. WarnInfo interface{} `json:"warn_info"`
  10088. }
  10089. type Result5301For10265 struct {
  10090. ErrMsg string `json:"err_msg"`
  10091. InfRefmsgid string `json:"inf_refmsgid"`
  10092. Infcode string `json:"infcode"`
  10093. Output struct {
  10094. Result []struct {
  10095. OpspDiseCode string `json:"opsp_dise_code"`
  10096. OpspDiseName string `json:"opsp_dise_name"`
  10097. Begndate string `json:"begndate"`
  10098. Enddate string `json:"enddate"`
  10099. } `json:"feedetail"`
  10100. } `json:"output"`
  10101. RefmsgTime string `json:"refmsg_time"`
  10102. RespondTime string `json:"respond_time"`
  10103. Signtype interface{} `json:"signtype"`
  10104. WarnInfo interface{} `json:"warn_info"`
  10105. }
  10106. //获取个人信息----挂号-----上传就诊信息
  10107. func (c *HisApiController) GetRegisterInfo() {
  10108. id, _ := c.GetInt64("id")
  10109. record_time := c.GetString("record_time")
  10110. settlementValue, _ := c.GetInt64("settlement_value")
  10111. medical_insurance_card := c.GetString("medical_insurance_card")
  10112. name := c.GetString("name")
  10113. id_card_type, _ := c.GetInt64("id_card_type")
  10114. certificates, _ := c.GetInt64("certificates")
  10115. medical_care, _ := c.GetInt64("medical_care")
  10116. birthday := c.GetString("birthday")
  10117. id_card := c.GetString("id_card")
  10118. register_type, _ := c.GetInt64("register")
  10119. doctor, _ := c.GetInt64("doctor")
  10120. department, _ := c.GetInt64("department")
  10121. gender, _ := c.GetInt64("sex")
  10122. registration_fee, _ := c.GetFloat("registration_fee")
  10123. medical_expenses, _ := c.GetFloat("medical_expenses")
  10124. social_type, _ := c.GetInt64("social_type")
  10125. admin_user_id, _ := c.GetInt64("admin_user_id")
  10126. insuplc_admdvs := c.GetString("insuplc_admdvs")
  10127. mdtrt_type := c.GetString("mdtrt_type")
  10128. timeLayout := "2006-01-02"
  10129. loc, _ := time.LoadLocation("Local")
  10130. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  10131. birthUnix := birthdays.Unix()
  10132. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10133. if err != nil {
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10135. return
  10136. }
  10137. recordDateTime := theTime.Unix()
  10138. adminInfo := c.GetAdminUserInfo()
  10139. var patient service.Patients
  10140. if id == 0 {
  10141. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  10142. } else {
  10143. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  10144. }
  10145. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10146. if patientPrescription.ID == 0 {
  10147. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10148. }
  10149. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10150. if patient.ID == 0 {
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10152. return
  10153. }
  10154. if len(patient.IdCardNo) == 0 {
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10156. return
  10157. }
  10158. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10159. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  10160. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  10161. //就诊结算未完成,不能进行二次挂号
  10162. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  10163. if len(his) >= 1 {
  10164. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  10165. if len(his) >= 1 && order.ID == 0 {
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  10167. return
  10168. }
  10169. }
  10170. //var register_log string
  10171. if config.IsOpen == 1 {
  10172. var res ResultTwo
  10173. var res10265 ResultTwo10265
  10174. var PsnNo string
  10175. var PsnCertType string
  10176. var Certno string
  10177. var PsnName string
  10178. var Gend string
  10179. var Naty string
  10180. var Brdy string
  10181. var Age float64
  10182. var infoStr string
  10183. var idetinfoStr string
  10184. var infocode int64
  10185. var verify_number string
  10186. fmt.Println(verify_number)
  10187. if miConfig.MdtrtareaAdmvs == "421300" {
  10188. psn_info, _ := service.GetPsnByPatientId(id)
  10189. PsnNo = psn_info.PsnNo
  10190. PsnCertType = psn_info.PsnCertType
  10191. Certno = psn_info.Certno
  10192. PsnName = psn_info.PsnName
  10193. Gend = psn_info.Gend
  10194. Naty = psn_info.Naty
  10195. Brdy = psn_info.Brdy
  10196. Age = psn_info.Age
  10197. infoStr = psn_info.Insuinfo
  10198. idetinfoStr = psn_info.Idetinfo
  10199. infocode = 0
  10200. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10201. psn_info, _ := service.GetPsnByPatientId(id)
  10202. PsnNo = psn_info.PsnNo
  10203. PsnCertType = psn_info.PsnCertType
  10204. Certno = psn_info.Certno
  10205. PsnName = psn_info.PsnName
  10206. Gend = psn_info.Gend
  10207. Naty = psn_info.Naty
  10208. Brdy = psn_info.Brdy
  10209. Age = psn_info.Age
  10210. infoStr = psn_info.Insuinfo
  10211. idetinfoStr = psn_info.Idetinfo
  10212. infocode = 0
  10213. verify_number = psn_info.VerifyNumber
  10214. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10215. psn_info, _ := service.GetPsnByPatientId(id)
  10216. PsnNo = psn_info.PsnNo
  10217. PsnCertType = psn_info.PsnCertType
  10218. Certno = psn_info.Certno
  10219. PsnName = psn_info.PsnName
  10220. Gend = psn_info.Gend
  10221. Naty = psn_info.Naty
  10222. Brdy = psn_info.Brdy
  10223. Age = psn_info.Age
  10224. infoStr = psn_info.Insuinfo
  10225. idetinfoStr = psn_info.Idetinfo
  10226. infocode = 0
  10227. verify_number = psn_info.VerifyNumber
  10228. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10229. if id_card_type == 1 {
  10230. psn_info, _ := service.GetPsnByPatientId(id)
  10231. PsnNo = psn_info.PsnNo
  10232. PsnCertType = psn_info.PsnCertType
  10233. Certno = psn_info.Certno
  10234. PsnName = psn_info.PsnName
  10235. Gend = psn_info.Gend
  10236. Naty = psn_info.Naty
  10237. Brdy = psn_info.Brdy
  10238. Age = psn_info.Age
  10239. infoStr = psn_info.Insuinfo
  10240. idetinfoStr = psn_info.Idetinfo
  10241. infocode = 0
  10242. verify_number = psn_info.VerifyNumber
  10243. } else if id_card_type == 2 {
  10244. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  10245. fmt.Println(errMsgLog)
  10246. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10248. utils.ErrorLog("解析失败:%v", err)
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10250. return
  10251. }
  10252. PsnNo = res.Output.Baseinfo.PsnNo
  10253. PsnCertType = res.Output.Baseinfo.PsnCertType
  10254. Certno = res.Output.Baseinfo.Certno
  10255. PsnName = res.Output.Baseinfo.PsnName
  10256. Gend = res.Output.Baseinfo.Gend
  10257. Naty = res.Output.Baseinfo.Naty
  10258. Brdy = res.Output.Baseinfo.Brdy
  10259. Age = res.Output.Baseinfo.Age
  10260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10262. infoStr = string(Iinfos)
  10263. idetinfoStr = string(Idetinfos)
  10264. infocode = res.Infcode
  10265. }
  10266. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10267. if id_card_type == 1 {
  10268. psn_info, _ := service.GetPsnByPatientId(id)
  10269. PsnNo = psn_info.PsnNo
  10270. PsnCertType = psn_info.PsnCertType
  10271. Certno = psn_info.Certno
  10272. PsnName = psn_info.PsnName
  10273. Gend = psn_info.Gend
  10274. Naty = psn_info.Naty
  10275. Brdy = psn_info.Brdy
  10276. Age = psn_info.Age
  10277. infoStr = psn_info.Insuinfo
  10278. idetinfoStr = psn_info.Idetinfo
  10279. infocode = 0
  10280. verify_number = psn_info.VerifyNumber
  10281. } else if id_card_type == 2 {
  10282. 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, "")
  10283. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10285. utils.ErrorLog("解析失败:%v", err)
  10286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. return
  10288. }
  10289. PsnNo = res.Output.Baseinfo.PsnNo
  10290. PsnCertType = res.Output.Baseinfo.PsnCertType
  10291. Certno = res.Output.Baseinfo.Certno
  10292. PsnName = res.Output.Baseinfo.PsnName
  10293. Gend = res.Output.Baseinfo.Gend
  10294. Naty = res.Output.Baseinfo.Naty
  10295. Brdy = res.Output.Baseinfo.Brdy
  10296. Age = res.Output.Baseinfo.Age
  10297. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10298. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10299. infoStr = string(Iinfos)
  10300. idetinfoStr = string(Idetinfos)
  10301. infocode = res.Infcode
  10302. }
  10303. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10304. if id_card_type == 1 {
  10305. psn_info, _ := service.GetPsnByPatientId(id)
  10306. PsnNo = psn_info.PsnNo
  10307. PsnCertType = psn_info.PsnCertType
  10308. Certno = psn_info.Certno
  10309. PsnName = psn_info.PsnName
  10310. Gend = psn_info.Gend
  10311. Naty = psn_info.Naty
  10312. Brdy = psn_info.Brdy
  10313. Age = psn_info.Age
  10314. infoStr = psn_info.Insuinfo
  10315. idetinfoStr = psn_info.Idetinfo
  10316. infocode = 0
  10317. verify_number = psn_info.VerifyNumber
  10318. } else if id_card_type == 2 {
  10319. 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)
  10320. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10322. utils.ErrorLog("解析失败:%v", err)
  10323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10324. return
  10325. }
  10326. PsnNo = res.Output.Baseinfo.PsnNo
  10327. PsnCertType = res.Output.Baseinfo.PsnCertType
  10328. Certno = res.Output.Baseinfo.Certno
  10329. PsnName = res.Output.Baseinfo.PsnName
  10330. Gend = res.Output.Baseinfo.Gend
  10331. Naty = res.Output.Baseinfo.Naty
  10332. Brdy = res.Output.Baseinfo.Brdy
  10333. Age = res.Output.Baseinfo.Age
  10334. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10335. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10336. infoStr = string(Iinfos)
  10337. idetinfoStr = string(Idetinfos)
  10338. infocode = res.Infcode
  10339. } else if id_card_type == 4 {
  10340. psn_info, _ := service.GetPsnByPatientId(id)
  10341. PsnNo = psn_info.PsnNo
  10342. PsnCertType = psn_info.PsnCertType
  10343. Certno = psn_info.Certno
  10344. PsnName = psn_info.PsnName
  10345. Gend = psn_info.Gend
  10346. Naty = psn_info.Naty
  10347. Brdy = psn_info.Brdy
  10348. Age = psn_info.Age
  10349. infoStr = psn_info.Insuinfo
  10350. idetinfoStr = psn_info.Idetinfo
  10351. infocode = 0
  10352. verify_number = psn_info.VerifyNumber
  10353. }
  10354. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10355. var result string
  10356. var requestLog string
  10357. 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), "")
  10358. if id_card_type == 4 {
  10359. psn_info, _ := service.GetPsnByPatientId(id)
  10360. PsnNo = psn_info.PsnNo
  10361. PsnCertType = psn_info.PsnCertType
  10362. Certno = psn_info.Certno
  10363. PsnName = psn_info.PsnName
  10364. Gend = psn_info.Gend
  10365. Naty = psn_info.Naty
  10366. Brdy = psn_info.Brdy
  10367. Age = psn_info.Age
  10368. infoStr = psn_info.Insuinfo
  10369. idetinfoStr = psn_info.Idetinfo
  10370. infocode = 0
  10371. verify_number = psn_info.VerifyNumber
  10372. } else {
  10373. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10374. if miConfig.Code == "H15049901371" {
  10375. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10376. utils.ErrorLog("解析失败:%v", err)
  10377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10378. return
  10379. }
  10380. res.ErrMsg = res10265.ErrMsg
  10381. res.Output = res10265.Output
  10382. res.InfRefmsgid = res10265.InfRefmsgid
  10383. } else {
  10384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10385. utils.ErrorLog("解析失败:%v", err)
  10386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10387. return
  10388. }
  10389. }
  10390. PsnNo = res.Output.Baseinfo.PsnNo
  10391. PsnCertType = res.Output.Baseinfo.PsnCertType
  10392. Certno = res.Output.Baseinfo.Certno
  10393. PsnName = res.Output.Baseinfo.PsnName
  10394. Gend = res.Output.Baseinfo.Gend
  10395. Naty = res.Output.Baseinfo.Naty
  10396. Brdy = res.Output.Baseinfo.Brdy
  10397. Age = res.Output.Baseinfo.Age
  10398. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10399. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10400. infoStr = string(Iinfos)
  10401. idetinfoStr = string(Idetinfos)
  10402. if miConfig.Code == "H15049901371" {
  10403. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  10404. } else {
  10405. infocode = res.Infcode
  10406. }
  10407. }
  10408. } else {
  10409. var result string
  10410. var requestLog string
  10411. //if miConfig.UserOrgId == 10138 {
  10412. if id_card_type != 4 || id_card_type != 1 {
  10413. var insa string
  10414. if len(patient.InsuplcAdmdvs) > 0 {
  10415. insa = patient.InsuplcAdmdvs
  10416. } else {
  10417. insa = miConfig.InsuplcAdmdvs
  10418. }
  10419. //psn_info, _ := service.GetPsnByPatientId(id)
  10420. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  10421. 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)
  10422. }
  10423. //}
  10424. //else {
  10425. // var insa string
  10426. // if len(patient.InsuplcAdmdvs) > 0 {
  10427. // insa = patient.InsuplcAdmdvs
  10428. // } else {
  10429. // insa = miConfig.InsuplcAdmdvs
  10430. // }
  10431. // 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)
  10432. //}
  10433. if id_card_type == 4 || id_card_type == 1 {
  10434. psn_info, _ := service.GetPsnByPatientId(id)
  10435. PsnNo = psn_info.PsnNo
  10436. PsnCertType = psn_info.PsnCertType
  10437. Certno = psn_info.Certno
  10438. PsnName = psn_info.PsnName
  10439. Gend = psn_info.Gend
  10440. Naty = psn_info.Naty
  10441. Brdy = psn_info.Brdy
  10442. Age = psn_info.Age
  10443. infoStr = psn_info.Insuinfo
  10444. idetinfoStr = psn_info.Idetinfo
  10445. infocode = 0
  10446. verify_number = psn_info.VerifyNumber
  10447. } else {
  10448. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10449. if miConfig.Code == "H15049901371" {
  10450. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10451. utils.ErrorLog("解析失败:%v", err)
  10452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10453. return
  10454. }
  10455. res.ErrMsg = res10265.ErrMsg
  10456. res.Output = res10265.Output
  10457. res.InfRefmsgid = res10265.InfRefmsgid
  10458. } else {
  10459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10460. utils.ErrorLog("解析失败:%v", err)
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10462. return
  10463. }
  10464. }
  10465. PsnNo = res.Output.Baseinfo.PsnNo
  10466. PsnCertType = res.Output.Baseinfo.PsnCertType
  10467. Certno = res.Output.Baseinfo.Certno
  10468. PsnName = res.Output.Baseinfo.PsnName
  10469. Gend = res.Output.Baseinfo.Gend
  10470. Naty = res.Output.Baseinfo.Naty
  10471. Brdy = res.Output.Baseinfo.Brdy
  10472. Age = res.Output.Baseinfo.Age
  10473. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10474. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10475. infoStr = string(Iinfos)
  10476. idetinfoStr = string(Idetinfos)
  10477. if miConfig.Code == "H15049901371" {
  10478. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  10479. } else {
  10480. infocode = res.Infcode
  10481. }
  10482. }
  10483. }
  10484. if infocode == 0 {
  10485. his := models.VMHisPatient{
  10486. Name: name,
  10487. Gender: gender,
  10488. Birthday: birthUnix,
  10489. MedicalTreatmentType: medical_care,
  10490. IdType: certificates,
  10491. IdCardNo: id_card,
  10492. BalanceAccountsType: settlementValue,
  10493. SocialType: social_type,
  10494. MedicalInsuranceNumber: medical_insurance_card,
  10495. RegisterType: register_type,
  10496. RegisterCost: registration_fee,
  10497. TreatmentCost: medical_expenses,
  10498. Status: 1,
  10499. Ctime: time.Now().Unix(),
  10500. Mtime: time.Now().Unix(),
  10501. PsnNo: PsnNo,
  10502. PsnCertType: PsnCertType,
  10503. Certno: Certno,
  10504. PsnName: PsnName,
  10505. Gend: Gend,
  10506. Naty: Naty,
  10507. Brdy: Brdy,
  10508. Age: Age,
  10509. Iinfo: infoStr,
  10510. Idetinfo: idetinfoStr,
  10511. PatientId: patient.ID,
  10512. RecordDate: theTime.Unix(),
  10513. UserOrgId: adminInfo.CurrentOrgId,
  10514. AdminUserId: admin_user_id,
  10515. IsReturn: 1,
  10516. IdCardType: id_card_type,
  10517. Doctor: doctor,
  10518. Departments: department,
  10519. MdtrtGrpType: mdtrt_type,
  10520. }
  10521. timestamp := time.Now().Unix()
  10522. tempTime := time.Unix(timestamp, 0)
  10523. timeFormat := tempTime.Format("20060102150405")
  10524. chrgBchno := rand.Intn(100000) + 10000
  10525. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10526. his.Number = ipt_otp_no
  10527. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  10528. department, _ := service.GetDepartMentDetail(department)
  10529. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  10530. IdCardNo := ""
  10531. if id_card_type == 1 {
  10532. // IdCardNo = medical_insurance_card
  10533. IdCardNo = patient.IdCardNo
  10534. } else {
  10535. IdCardNo = patient.IdCardNo
  10536. }
  10537. var rf []*ResultFive
  10538. json.Unmarshal([]byte(his.Iinfo), &rf)
  10539. var insutypes []*ResultFive
  10540. var insutype string
  10541. var insuplc_admdvs_temp string
  10542. var is390 int = 0
  10543. var is310 int = 0
  10544. for _, item := range rf {
  10545. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10546. insutypes = append(insutypes, item)
  10547. }
  10548. }
  10549. if len(insutypes) == 1 {
  10550. insutype = insutypes[0].Insutype
  10551. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10552. } else {
  10553. for _, i := range insutypes {
  10554. if i.Insutype == "390" {
  10555. is390 = 1
  10556. }
  10557. if i.Insutype == "310" {
  10558. is310 = 1
  10559. }
  10560. }
  10561. }
  10562. if is390 == 1 {
  10563. insutype = "390"
  10564. }
  10565. if is310 == 1 {
  10566. insutype = "310"
  10567. }
  10568. fmt.Println(social_type)
  10569. if social_type > 0 {
  10570. insutype = strconv.FormatInt(social_type, 10)
  10571. }
  10572. var infocode int64
  10573. var resThree ResultThree
  10574. var resThree10265 ResultThree10265
  10575. if len(insuplc_admdvs) == 0 {
  10576. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  10577. } else {
  10578. insuplc_admdvs_temp = insuplc_admdvs
  10579. }
  10580. if miConfig.MdtrtareaAdmvs == "421300" {
  10581. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  10582. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  10583. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10584. "&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
  10585. resp, requestErr := http.Get(api)
  10586. if requestErr != nil {
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10588. return
  10589. }
  10590. body, ioErr := ioutil.ReadAll(resp.Body)
  10591. if ioErr != nil {
  10592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10594. return
  10595. }
  10596. var respJSON map[string]interface{}
  10597. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10600. return
  10601. }
  10602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10603. result, _ := json.Marshal(respJSON)
  10604. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10605. utils.ErrorLog("解析失败:%v", err)
  10606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10607. return
  10608. }
  10609. infocode = resThree.Infcode
  10610. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10611. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  10612. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  10613. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10614. "&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
  10615. resp, requestErr := http.Get(api)
  10616. if requestErr != nil {
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10618. return
  10619. }
  10620. body, ioErr := ioutil.ReadAll(resp.Body)
  10621. if ioErr != nil {
  10622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10624. return
  10625. }
  10626. var respJSON map[string]interface{}
  10627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10630. return
  10631. }
  10632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10633. result, _ := json.Marshal(respJSON)
  10634. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10635. utils.ErrorLog("解析失败:%v", err)
  10636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10637. return
  10638. }
  10639. infocode = resThree.Infcode
  10640. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10641. psn_info, _ := service.GetPsnByPatientId(id)
  10642. his.PsnNo = psn_info.PsnNo
  10643. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10644. var cert_no string
  10645. if id_card_type == 3 {
  10646. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  10647. cert_no = IdCardNo
  10648. } else if id_card_type == 4 {
  10649. cert_no = IdCardNo
  10650. psn_info.VerifyNumber = psn_info.VerifyNumber
  10651. } else {
  10652. bas := strings.Split(psn_info.CardInfo, "|")
  10653. cert_no = bas[2]
  10654. }
  10655. var hisPrescription []*models.HisPrescription
  10656. for _, item := range rf {
  10657. if item.Insutype == insutype {
  10658. //insuplc_admdvs = item.InsuplcAdmdvs
  10659. his.InsuplcAdmdvs = insuplc_admdvs
  10660. }
  10661. }
  10662. his.Insutype = insutype
  10663. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  10664. fmt.Println(res3101)
  10665. fmt.Println(res3101.Infcode)
  10666. if res3101.Infcode == "0" {
  10667. fmt.Println("33333333")
  10668. if len(res3101.Output.Result) > 0 {
  10669. fmt.Println("222222")
  10670. for _, item := range res3101.Output.Result {
  10671. if len(res3101.ErrMsg) == 0 {
  10672. res3101.ErrMsg = item.VolaCont
  10673. } else {
  10674. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  10675. }
  10676. }
  10677. c.ServeSuccessJSON(map[string]interface{}{
  10678. "failed_code": -10,
  10679. "msg": res3101.ErrMsg,
  10680. })
  10681. return
  10682. } else {
  10683. fmt.Println("11111")
  10684. var api string
  10685. if miConfig.MdtrtareaAdmvs == "320921" {
  10686. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10687. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10688. "&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
  10689. } else {
  10690. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10691. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10692. "&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
  10693. }
  10694. resp, requestErr := http.Get(api)
  10695. if requestErr != nil {
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10697. return
  10698. }
  10699. body, ioErr := ioutil.ReadAll(resp.Body)
  10700. if ioErr != nil {
  10701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10703. return
  10704. }
  10705. var respJSON map[string]interface{}
  10706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10709. return
  10710. }
  10711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10712. result, _ := json.Marshal(respJSON)
  10713. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10714. utils.ErrorLog("解析失败:%v", err)
  10715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10716. return
  10717. }
  10718. resThree.ErrMsg = resThree10265.ErrMsg
  10719. resThree.Output = resThree10265.Output
  10720. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10721. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10722. }
  10723. } else if res3101.Infcode != "0" {
  10724. c.ServeSuccessJSON(map[string]interface{}{
  10725. "failed_code": -10,
  10726. "msg": res3101.ErrMsg,
  10727. })
  10728. return
  10729. }
  10730. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10731. psn_info, _ := service.GetPsnByPatientId(id)
  10732. var cert_no string
  10733. if id_card_type == 1 {
  10734. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10735. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10736. } else if id_card_type == 4 {
  10737. cert_no = psn_info.VerifyNumber
  10738. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10739. } else {
  10740. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10741. cert_no = psn_info.VerifyNumber
  10742. }
  10743. 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)
  10744. saveLog(result, requestLog, "2201", "挂号")
  10745. if miConfig.Code == "H15049901371" {
  10746. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10747. utils.ErrorLog("解析失败:%v", err)
  10748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10749. return
  10750. }
  10751. resThree.ErrMsg = resThree10265.ErrMsg
  10752. resThree.Output = resThree10265.Output
  10753. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10754. } else {
  10755. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10756. utils.ErrorLog("解析失败:%v", err)
  10757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10758. return
  10759. }
  10760. }
  10761. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10762. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  10763. psn_info, _ := service.GetPsnByPatientId(id)
  10764. var result string
  10765. var requestLog string
  10766. if id_card_type == 1 {
  10767. bas := strings.Split(psn_info.CardInfo, "|")
  10768. basNumber := bas[2]
  10769. card_sn := bas[3]
  10770. 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)
  10771. saveLog(result, requestLog, "2201A", "挂号")
  10772. } else if id_card_type == 2 {
  10773. 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, "", "")
  10774. saveLog(result, requestLog, "2201A", "挂号")
  10775. } else {
  10776. 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, "", "")
  10777. saveLog(result, requestLog, "2201A", "挂号")
  10778. }
  10779. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10780. utils.ErrorLog("解析失败:%v", err)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. infocode = resThree.Infcode
  10785. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  10786. psn_info, _ := service.GetPsnByPatientId(id)
  10787. var result string
  10788. var requestLog string
  10789. if id_card_type == 1 {
  10790. bas := strings.Split(psn_info.CardInfo, "|")
  10791. basNumber := bas[2]
  10792. card_sn := bas[3]
  10793. 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)
  10794. saveLog(result, requestLog, "2201A", "挂号")
  10795. } else if id_card_type == 2 {
  10796. 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, "", "")
  10797. saveLog(result, requestLog, "2201A", "挂号")
  10798. } else {
  10799. 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, "", "")
  10800. saveLog(result, requestLog, "2201A", "挂号")
  10801. }
  10802. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10803. utils.ErrorLog("解析失败:%v", err)
  10804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10805. return
  10806. }
  10807. infocode = resThree.Infcode
  10808. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10809. psn_info, _ := service.GetPsnByPatientId(id)
  10810. 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)
  10811. saveLog(result, requestLog, "2201A", "挂号")
  10812. if miConfig.Code == "H15049901371" {
  10813. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10814. utils.ErrorLog("解析失败:%v", err)
  10815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10816. return
  10817. }
  10818. resThree.ErrMsg = resThree10265.ErrMsg
  10819. resThree.Output = resThree10265.Output
  10820. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10821. } else {
  10822. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10823. utils.ErrorLog("解析失败:%v", err)
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10825. return
  10826. }
  10827. }
  10828. if miConfig.Code == "H15049901371" {
  10829. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10830. } else {
  10831. infocode = resThree.Infcode
  10832. }
  10833. } else {
  10834. psn_info, _ := service.GetPsnByPatientId(id)
  10835. if id_card_type == 4 || id_card_type == 1 {
  10836. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10837. }
  10838. var rf []*ResultFive
  10839. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  10840. var insutypes []*ResultFive
  10841. var insutype string
  10842. var is390 int = 0
  10843. var is310 int = 0
  10844. for _, item := range rf {
  10845. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10846. insutypes = append(insutypes, item)
  10847. }
  10848. }
  10849. if len(insutypes) == 1 {
  10850. insutype = insutypes[0].Insutype
  10851. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10852. } else {
  10853. for _, i := range insutypes {
  10854. if i.Insutype == "390" {
  10855. is390 = 1
  10856. }
  10857. if i.Insutype == "310" {
  10858. is310 = 1
  10859. }
  10860. }
  10861. }
  10862. if is390 == 1 {
  10863. insutype = "390"
  10864. }
  10865. if is310 == 1 {
  10866. insutype = "310"
  10867. }
  10868. fmt.Println(len(insutypes))
  10869. if len(insutypes) == 0 {
  10870. for index, item := range rf {
  10871. if index == 0 {
  10872. insutype = item.Insutype
  10873. insuplc_admdvs = item.InsuplcAdmdvs
  10874. }
  10875. }
  10876. fmt.Println(insutype)
  10877. fmt.Println(insuplc_admdvs)
  10878. }
  10879. if social_type > 0 {
  10880. insutype = strconv.FormatInt(social_type, 10)
  10881. }
  10882. 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)
  10883. saveLog(result, requestLog, "2201A", "挂号")
  10884. if miConfig.Code == "H15049901371" {
  10885. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10886. utils.ErrorLog("解析失败:%v", err)
  10887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10888. return
  10889. }
  10890. resThree.ErrMsg = resThree10265.ErrMsg
  10891. resThree.Output = resThree10265.Output
  10892. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10893. } else {
  10894. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10895. utils.ErrorLog("解析失败:%v", err)
  10896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10897. return
  10898. }
  10899. }
  10900. if miConfig.Code == "H15049901371" {
  10901. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10902. } else {
  10903. infocode = resThree.Infcode
  10904. }
  10905. }
  10906. if infocode != 0 {
  10907. adminUser := c.GetAdminUserInfo()
  10908. errlog := &models.HisOrderError{
  10909. UserOrgId: adminUser.CurrentOrgId,
  10910. Ctime: time.Now().Unix(),
  10911. Mtime: time.Now().Unix(),
  10912. ErrMsg: resThree.ErrMsg,
  10913. Status: 1,
  10914. PatientId: id,
  10915. RecordTime: recordDateTime,
  10916. Stage: 2,
  10917. }
  10918. service.CreateErrMsgLog(errlog)
  10919. c.ServeSuccessJSON(map[string]interface{}{
  10920. "failed_code": -10,
  10921. "msg": resThree.ErrMsg,
  10922. })
  10923. return
  10924. }
  10925. his.Number = resThree.Output.Data.MdtrtID
  10926. his.PsnNo = resThree.Output.Data.PsnNo
  10927. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  10928. his.IdCardNo = patient.IdCardNo
  10929. his.PhoneNumber = patient.Phone
  10930. his.UserOrgId = adminInfo.CurrentOrgId
  10931. his.Insutype = insutype
  10932. his.Ctime = time.Now().Unix()
  10933. his.Mtime = time.Now().Unix()
  10934. his.InsuplcAdmdvs = insuplc_admdvs_temp
  10935. his.Status = 1
  10936. his.MdtrtGrpType = mdtrt_type
  10937. service.UpdateHisPatientStatus(&his)
  10938. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  10939. c.ServeSuccessJSON(map[string]interface{}{
  10940. "his_info": his,
  10941. })
  10942. } else {
  10943. adminUser := c.GetAdminUserInfo()
  10944. errlog := &models.HisOrderError{
  10945. UserOrgId: adminUser.CurrentOrgId,
  10946. Ctime: time.Now().Unix(),
  10947. Mtime: time.Now().Unix(),
  10948. ErrMsg: res.ErrMsg,
  10949. Status: 1,
  10950. PatientId: id,
  10951. RecordTime: recordDateTime,
  10952. Stage: 1,
  10953. }
  10954. service.CreateErrMsgLog(errlog)
  10955. c.ServeSuccessJSON(map[string]interface{}{
  10956. "failed_code": -10,
  10957. "msg": res.ErrMsg,
  10958. })
  10959. return
  10960. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10961. }
  10962. }
  10963. }
  10964. func (c *HisApiController) GetUploadInfo() {
  10965. id, _ := c.GetInt64("id")
  10966. record_time := c.GetString("record_time")
  10967. his_patient_id, _ := c.GetInt64("his_patient_id")
  10968. order_id, _ := c.GetInt64("order_id")
  10969. pay_way, _ := c.GetInt64("pay_way")
  10970. pay_ways := c.GetString("pay_ways")
  10971. oth_desc := c.GetString("oth_desc")
  10972. pay_price, _ := c.GetFloat("pay_price")
  10973. pay_card_no := c.GetString("pay_card_no")
  10974. discount_price, _ := c.GetFloat("discount_price")
  10975. preferential_price, _ := c.GetFloat("preferential_price")
  10976. reality_price, _ := c.GetFloat("reality_price")
  10977. found_price, _ := c.GetFloat("found_price")
  10978. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  10979. private_price, _ := c.GetFloat("private_price")
  10980. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10981. admin_user_id, _ := c.GetInt64("admin_user_id")
  10982. fapiao_code := c.GetString("fapiao_code")
  10983. fapiao_number := c.GetString("fapiao_number")
  10984. diagnosis_id := c.GetString("diagnosis")
  10985. sick_type, _ := c.GetInt64("sick_type")
  10986. reg_type, _ := c.GetInt64("p_type")
  10987. begin_time := c.GetString("begin_time")
  10988. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  10989. cash_pay := c.GetString("cash_pay")
  10990. band_card_pay := c.GetString("band_card_pay")
  10991. wechat_pay := c.GetString("wechat_pay")
  10992. ali_pay := c.GetString("ali_pay")
  10993. jifen_pay := c.GetString("jifen_pay")
  10994. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  10995. fmt.Println(acct_used_flag)
  10996. id_str := c.GetString("ids")
  10997. ids_arr := strings.Split(id_str, ",")
  10998. timeLayout := "2006-01-02"
  10999. loc, _ := time.LoadLocation("Local")
  11000. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11001. if err != nil {
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11003. return
  11004. }
  11005. recordDateTime := theTime.Unix()
  11006. adminUser := c.GetAdminUserInfo()
  11007. var tempOrder models.HisOrder
  11008. tempOrder, _ = service.GetHisOrderByID(order_id)
  11009. var prescriptions []*models.HisPrescription
  11010. var start_time int64
  11011. var end_time int64
  11012. //押金模块
  11013. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  11014. tmp_decimal := c.GetString("tmp_decimal")
  11015. var decimal float64 //本次使用的押金
  11016. var errmsg error
  11017. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  11018. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  11019. return
  11020. }
  11021. if len(tmp_decimal) > 0 {
  11022. if tmp_decimal[0] == 45 {
  11023. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  11024. return
  11025. }
  11026. }
  11027. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  11028. fmt.Println(errs)
  11029. decimal = tt
  11030. //if adminUser.CurrentOrgId == 10106{
  11031. // if len(fapiao_code) == 0{
  11032. // fapiao_code = "144072080589"
  11033. // }
  11034. // if len(fapiao_number) == 0{
  11035. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  11036. // if order.ID == 0{
  11037. // fapiao_number = "00001520"
  11038. // }else{
  11039. // //fapiao_code = "00001520"
  11040. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  11041. // var zero string
  11042. // if fpNumber >= 1000{
  11043. // zero = "0000" + strconv.Itoa(fpNumber)
  11044. // }else if fpNumber >= 10000{
  11045. // zero = "000" + strconv.Itoa(fpNumber)
  11046. // } else if fpNumber >= 100000{
  11047. // zero = "00" + strconv.Itoa(fpNumber)
  11048. // } else if fpNumber >= 1000000{
  11049. // zero = "0" + strconv.Itoa(fpNumber)
  11050. // }else {
  11051. // zero = strconv.Itoa(fpNumber)
  11052. // }
  11053. // fapiao_number = zero
  11054. // }
  11055. // }
  11056. //}
  11057. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11058. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11059. var patientPrescription models.HisPrescriptionInfo
  11060. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11061. if patientPrescription.ID == 0 {
  11062. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11063. }
  11064. //if patientPrescription.Do
  11065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11066. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11067. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11068. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11069. var config []*models.HisXtDiagnoseConfig
  11070. for _, item := range diagnosis_ids {
  11071. id, _ := strconv.ParseInt(item, 10, 64)
  11072. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11073. config = append(config, &diagnosisConfig)
  11074. }
  11075. sickConfig, _ := service.FindSickById(sick_type)
  11076. //if tempOrder.ID == 0 {
  11077. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  11078. //}
  11079. if tempOrder.ID == 0 {
  11080. var result string
  11081. var requestLog string
  11082. var res2 ResultSix
  11083. var ressix10265 ResultSix10265
  11084. if miConfig.MdtrtareaAdmvs == "421300" {
  11085. data := make(map[string]interface{})
  11086. client := &http.Client{}
  11087. data["psn_no"] = his.PsnNo
  11088. data["mdtrt_id"] = his.Number
  11089. data["opter"] = roles.UserName
  11090. data["org_name"] = miConfig.OrgName
  11091. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11092. data["doctor_id"] = doctor_info.DoctorNumber
  11093. data["doctor_name"] = doctor_info.UserName
  11094. data["department"] = department.Name
  11095. data["fixmedins_code"] = miConfig.Code
  11096. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11097. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11098. data["secret_key"] = miConfig.SecretKey
  11099. data["sick_code"] = sickConfig.CountryCode
  11100. data["sick_name"] = sickConfig.ClassName
  11101. data["dept"] = strconv.FormatInt(department.ID, 10)
  11102. data["config"] = config
  11103. data["begin_time"] = begin_time
  11104. bytesData, _ := json.Marshal(data)
  11105. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11106. resp, _ := client.Do(req)
  11107. defer resp.Body.Close()
  11108. body, ioErr := ioutil.ReadAll(resp.Body)
  11109. if ioErr != nil {
  11110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11112. return
  11113. }
  11114. var respJSON map[string]interface{}
  11115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11118. return
  11119. }
  11120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11121. userJSONBytes, _ := json.Marshal(respJSON)
  11122. fmt.Println("log")
  11123. fmt.Println(string(userJSONBytes))
  11124. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11125. utils.ErrorLog("解析失败:%v", err)
  11126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11127. return
  11128. }
  11129. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11130. data := make(map[string]interface{})
  11131. client := &http.Client{}
  11132. data["psn_no"] = his.PsnNo
  11133. data["mdtrt_id"] = his.Number
  11134. data["doctor"] = roles.UserName
  11135. data["department"] = department.Name
  11136. data["org_name"] = miConfig.OrgName
  11137. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11138. data["doctor_id"] = doctor_info.DoctorNumber
  11139. data["new_doctor_name"] = doctor_info.UserName
  11140. data["fixmedins_code"] = miConfig.Code
  11141. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11143. data["secret_key"] = miConfig.SecretKey
  11144. data["sick_code"] = sickConfig.CountryCode
  11145. data["sick_name"] = sickConfig.ClassName
  11146. data["url"] = miConfig.Url
  11147. data["ak"] = miConfig.AccessKey
  11148. data["begin_time"] = begin_time
  11149. data["cainfo"] = miConfig.Cainfo
  11150. data["dept"] = strconv.FormatInt(department.ID, 10)
  11151. data["config"] = config
  11152. bytesData, _ := json.Marshal(data)
  11153. var req *http.Request
  11154. if miConfig.MdtrtareaAdmvs == "320921" {
  11155. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11156. //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 +
  11157. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  11158. } else {
  11159. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11160. }
  11161. resp, _ := client.Do(req)
  11162. defer resp.Body.Close()
  11163. body, ioErr := ioutil.ReadAll(resp.Body)
  11164. if ioErr != nil {
  11165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11167. return
  11168. }
  11169. var respJSON map[string]interface{}
  11170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11173. return
  11174. }
  11175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11176. userJSONBytes, _ := json.Marshal(respJSON)
  11177. fmt.Println("log")
  11178. fmt.Println(string(userJSONBytes))
  11179. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  11180. utils.ErrorLog("解析失败:%v", err)
  11181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11182. return
  11183. }
  11184. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11185. res2.Output = ressix10265.Output
  11186. res2.ErrMsg = ressix10265.ErrMsg
  11187. res2.Cainfo = ressix10265.Cainfo
  11188. res2.WarnMsg = ressix10265.WarnMsg
  11189. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11190. res2.Infcode = infocode
  11191. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11192. data := make(map[string]interface{})
  11193. client := &http.Client{}
  11194. data["psn_no"] = his.PsnNo
  11195. data["mdtrt_id"] = his.Number
  11196. data["doctor"] = roles.UserName
  11197. data["department"] = department.Name
  11198. data["org_name"] = miConfig.OrgName
  11199. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11200. data["doctor_id"] = doctor_info.DoctorNumber
  11201. data["new_doctor_name"] = doctor_info.UserName
  11202. data["fixmedins_code"] = miConfig.Code
  11203. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11204. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11205. data["secret_key"] = miConfig.SecretKey
  11206. data["sick_code"] = sickConfig.CountryCode
  11207. data["sick_name"] = sickConfig.ClassName
  11208. data["url"] = miConfig.Url
  11209. data["ak"] = miConfig.AccessKey
  11210. data["begin_time"] = begin_time
  11211. data["cainfo"] = miConfig.Cainfo
  11212. data["dept"] = strconv.FormatInt(department.ID, 10)
  11213. data["config"] = config
  11214. bytesData, _ := json.Marshal(data)
  11215. var req *http.Request
  11216. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  11217. resp, _ := client.Do(req)
  11218. defer resp.Body.Close()
  11219. body, ioErr := ioutil.ReadAll(resp.Body)
  11220. if ioErr != nil {
  11221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11223. return
  11224. }
  11225. var respJSON map[string]interface{}
  11226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11229. return
  11230. }
  11231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11232. userJSONBytes, _ := json.Marshal(respJSON)
  11233. fmt.Println("log")
  11234. fmt.Println(string(userJSONBytes))
  11235. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  11236. utils.ErrorLog("解析失败:%v", err)
  11237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11238. return
  11239. }
  11240. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11241. res2.Output = ressix10265.Output
  11242. res2.ErrMsg = ressix10265.ErrMsg
  11243. res2.Cainfo = ressix10265.Cainfo
  11244. res2.WarnMsg = ressix10265.WarnMsg
  11245. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11246. res2.Infcode = infocode
  11247. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11248. 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)
  11249. saveLog(result, requestLog, "2203", "上传就诊信息")
  11250. var respJSON2 map[string]interface{}
  11251. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11254. return
  11255. }
  11256. userJSONBytes2, _ := json.Marshal(respJSON2)
  11257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11258. utils.ErrorLog("解析失败:%v", err)
  11259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11260. return
  11261. }
  11262. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11263. fmt.Println(result2)
  11264. fmt.Println(src_request)
  11265. } else {
  11266. if miConfig.MdtrtareaAdmvs == "440781" { //
  11267. 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)
  11268. } else {
  11269. if miConfig.Code == "H15049901371" {
  11270. //赤峰地区国家医保医疗类别
  11271. //职工透析:医疗类别选特殊情况门诊990502
  11272. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11273. var med_type string
  11274. if his.Insutype == "390" {
  11275. if reg_type == 14 {
  11276. med_type = "9933"
  11277. } else if reg_type == 11 {
  11278. med_type = "11"
  11279. }
  11280. } else if his.Insutype == "310" {
  11281. if reg_type == 14 {
  11282. med_type = "990502"
  11283. } else if reg_type == 11 {
  11284. med_type = "11"
  11285. }
  11286. }
  11287. 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)
  11288. } else {
  11289. 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)
  11290. }
  11291. }
  11292. saveLog(result, requestLog, "2203", "上传就诊信息")
  11293. var respJSON2 map[string]interface{}
  11294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11297. return
  11298. }
  11299. userJSONBytes2, _ := json.Marshal(respJSON2)
  11300. if miConfig.Code == "H15049901371" {
  11301. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  11302. utils.ErrorLog("解析失败:%v", err)
  11303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11304. return
  11305. }
  11306. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11307. res2.Output = ressix10265.Output
  11308. res2.ErrMsg = ressix10265.ErrMsg
  11309. res2.Cainfo = ressix10265.Cainfo
  11310. res2.WarnMsg = ressix10265.WarnMsg
  11311. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11312. res2.Infcode = infocode
  11313. } else {
  11314. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11315. utils.ErrorLog("解析失败:%v", err)
  11316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11317. return
  11318. }
  11319. }
  11320. }
  11321. if res2.Infcode != 0 {
  11322. adminUser := c.GetAdminUserInfo()
  11323. errlog := &models.HisOrderError{
  11324. UserOrgId: adminUser.CurrentOrgId,
  11325. Ctime: time.Now().Unix(),
  11326. Mtime: time.Now().Unix(),
  11327. ErrMsg: res2.ErrMsg,
  11328. Status: 1,
  11329. PatientId: id,
  11330. RecordTime: recordDateTime,
  11331. Stage: 3,
  11332. }
  11333. service.CreateErrMsgLog(errlog)
  11334. c.ServeSuccessJSON(map[string]interface{}{
  11335. "failed_code": -10,
  11336. "msg": res2.ErrMsg,
  11337. })
  11338. return
  11339. } else {
  11340. his.Diagnosis = diagnosis_id
  11341. his.SickType = sickConfig.ID
  11342. //var p_type int64
  11343. //if reg_type == 1111 || reg_type == 1112 {
  11344. // p_type = 11
  11345. //
  11346. //}
  11347. his.PType = fmt.Sprintf("%d", reg_type)
  11348. service.UpdateHisPatientThree(&his)
  11349. data := make(map[string]interface{})
  11350. if settle_accounts_type == 1 { //日结
  11351. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11352. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11353. } else {
  11354. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11355. }
  11356. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  11357. data["pre"] = prescriptions
  11358. } else { //月结
  11359. start_time_str := c.GetString("start_time")
  11360. end_time_str := c.GetString("end_time")
  11361. timeLayout := "2006-01-02"
  11362. loc, _ := time.LoadLocation("Local")
  11363. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11364. if err != nil {
  11365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11366. return
  11367. }
  11368. recordStartTime := theStartTime.Unix()
  11369. start_time = recordStartTime
  11370. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11371. if err != nil {
  11372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11373. return
  11374. }
  11375. recordEndTime := theEndTime.Unix()
  11376. end_time = recordEndTime
  11377. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11378. data["pre"] = prescriptions
  11379. }
  11380. timestamp := time.Now().Unix()
  11381. tempTime := time.Unix(timestamp, 0)
  11382. timeFormat := tempTime.Format("20060102150405")
  11383. chrgBchno := rand.Intn(100000) + 10000
  11384. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11385. strconv.FormatInt(his.PatientId, 10)
  11386. client := &http.Client{}
  11387. data["psn_no"] = his.PsnNo
  11388. data["mdtrt_id"] = his.Number
  11389. data["chrg_bchno"] = chrg_bchno
  11390. data["org_name"] = miConfig.OrgName
  11391. data["doctor"] = doctor_info.UserName
  11392. data["doctor_id"] = doctor_info.DoctorNumber
  11393. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  11394. data["fixmedins_code"] = miConfig.Code
  11395. data["opter"] = roles.UserName
  11396. data["dept_code"] = department.Number
  11397. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11398. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11399. data["secret_key"] = miConfig.SecretKey
  11400. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11401. data["url"] = miConfig.Url
  11402. data["ak"] = miConfig.AccessKey
  11403. data["new_doctor_name"] = patientPrescription.Doctor
  11404. data["diag_code"] = sickConfig.CountryCode
  11405. data["cainfo"] = miConfig.Cainfo
  11406. data["opter"] = roles.UserName
  11407. var ids []int64
  11408. for _, item := range prescriptions {
  11409. ids = append(ids, item.ID)
  11410. }
  11411. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11412. if config.IsOpen == 1 { //对接了医保,走医保流程
  11413. var res ResultFour
  11414. var resFour10265 ResultFour10265
  11415. if miConfig.MdtrtareaAdmvs == "421300" {
  11416. bytesData, _ := json.Marshal(data)
  11417. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11418. resp, _ := client.Do(req)
  11419. defer resp.Body.Close()
  11420. body, ioErr := ioutil.ReadAll(resp.Body)
  11421. if ioErr != nil {
  11422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return
  11425. }
  11426. var respJSON map[string]interface{}
  11427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11430. return
  11431. }
  11432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11433. userJSONBytes, _ := json.Marshal(respJSON)
  11434. fmt.Println("log")
  11435. fmt.Println(string(userJSONBytes))
  11436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11437. utils.ErrorLog("解析失败:%v", err)
  11438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11439. return
  11440. }
  11441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11442. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11443. if result3101.Infcode == "0" {
  11444. if len(result3101.Output.Result) > 0 {
  11445. var errMsgs []string
  11446. for _, item := range result3101.Output.Result {
  11447. errMsgs = append(errMsgs, item.VolaCont)
  11448. }
  11449. c.ServeSuccessJSON(map[string]interface{}{
  11450. "failed_code": -10,
  11451. "msg": errMsgs,
  11452. })
  11453. return
  11454. }
  11455. }
  11456. if miConfig.MdtrtareaAdmvs == "320921" {
  11457. data["doctor_id"] = "D320923012139"
  11458. } else {
  11459. data["doctor_id"] = "D371621008686"
  11460. }
  11461. bytesData, _ := json.Marshal(data)
  11462. var req *http.Request
  11463. if miConfig.MdtrtareaAdmvs == "320921" {
  11464. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11465. } else {
  11466. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11467. }
  11468. resp, _ := client.Do(req)
  11469. defer resp.Body.Close()
  11470. body, ioErr := ioutil.ReadAll(resp.Body)
  11471. if ioErr != nil {
  11472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11474. return
  11475. }
  11476. var respJSON map[string]interface{}
  11477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11480. return
  11481. }
  11482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11483. userJSONBytes, _ := json.Marshal(respJSON)
  11484. fmt.Println("log")
  11485. fmt.Println(string(userJSONBytes))
  11486. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11487. utils.ErrorLog("解析失败:%v", err)
  11488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11489. return
  11490. }
  11491. res.InfRefmsgid = resFour10265.InfRefmsgid
  11492. res.Output = resFour10265.Output
  11493. res.ErrMsg = resFour10265.ErrMsg
  11494. res.Cainfo = resFour10265.Cainfo
  11495. res.WarnMsg = resFour10265.WarnMsg
  11496. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11497. res.Infcode = infocode
  11498. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11499. data["doctor_id"] = doctor_info.DoctorNumber
  11500. bytesData, _ := json.Marshal(data)
  11501. var req *http.Request
  11502. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  11503. resp, _ := client.Do(req)
  11504. defer resp.Body.Close()
  11505. body, ioErr := ioutil.ReadAll(resp.Body)
  11506. if ioErr != nil {
  11507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11509. return
  11510. }
  11511. var respJSON map[string]interface{}
  11512. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11515. return
  11516. }
  11517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11518. userJSONBytes, _ := json.Marshal(respJSON)
  11519. fmt.Println("log")
  11520. fmt.Println(string(userJSONBytes))
  11521. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11522. utils.ErrorLog("解析失败:%v", err)
  11523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11524. return
  11525. }
  11526. res.InfRefmsgid = resFour10265.InfRefmsgid
  11527. res.Output = resFour10265.Output
  11528. res.ErrMsg = resFour10265.ErrMsg
  11529. res.Cainfo = resFour10265.Cainfo
  11530. res.WarnMsg = resFour10265.WarnMsg
  11531. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11532. res.Infcode = infocode
  11533. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11534. 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)
  11535. var dat map[string]interface{}
  11536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11537. fmt.Println(dat)
  11538. } else {
  11539. fmt.Println(err)
  11540. }
  11541. saveLog(result, request_log, "2204", "上传费用明细")
  11542. userJSONBytes, _ := json.Marshal(dat)
  11543. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11544. utils.ErrorLog("解析失败:%v", err)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. res.InfRefmsgid = resFour10265.InfRefmsgid
  11549. res.Output = resFour10265.Output
  11550. res.ErrMsg = resFour10265.ErrMsg
  11551. res.Cainfo = resFour10265.Cainfo
  11552. res.WarnMsg = resFour10265.WarnMsg
  11553. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11554. res.Infcode = infocode
  11555. } else {
  11556. if miConfig.Code == "H15049901371" {
  11557. 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)
  11558. var dat map[string]interface{}
  11559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11560. fmt.Println(dat)
  11561. } else {
  11562. fmt.Println(err)
  11563. }
  11564. saveLog(result, request_log, "2204", "上传费用明细")
  11565. userJSONBytes, _ := json.Marshal(dat)
  11566. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11567. utils.ErrorLog("解析失败:%v", err)
  11568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11569. return
  11570. }
  11571. res.InfRefmsgid = resFour10265.InfRefmsgid
  11572. res.Output = resFour10265.Output
  11573. res.ErrMsg = resFour10265.ErrMsg
  11574. res.Cainfo = resFour10265.Cainfo
  11575. res.WarnMsg = resFour10265.WarnMsg
  11576. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11577. res.Infcode = infocode
  11578. } else {
  11579. 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)
  11580. var dat map[string]interface{}
  11581. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11582. fmt.Println(dat)
  11583. } else {
  11584. fmt.Println(err)
  11585. }
  11586. saveLog(result, request_log, "2204", "上传费用明细")
  11587. userJSONBytes, _ := json.Marshal(dat)
  11588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11589. utils.ErrorLog("解析失败:%v", err)
  11590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11591. return
  11592. }
  11593. }
  11594. }
  11595. if res.Infcode == 0 {
  11596. order := &models.HisOrder{
  11597. UserOrgId: adminUser.CurrentOrgId,
  11598. HisPatientId: his.ID,
  11599. PatientId: his.PatientId,
  11600. SettleAccountsDate: recordDateTime,
  11601. MdtrtId: his.Number,
  11602. PsnNo: his.PsnNo,
  11603. MedType: strconv.FormatInt(reg_type, 10),
  11604. Ctime: time.Now().Unix(),
  11605. Mtime: time.Now().Unix(),
  11606. Status: 1,
  11607. Number: chrg_bchno,
  11608. Infcode: res.Infcode,
  11609. WarnMsg: res.WarnMsg,
  11610. Cainfo: res.Cainfo,
  11611. ErrMsg: res.ErrMsg,
  11612. RespondTime: res.RefmsgTime,
  11613. InfRefmsgid: res.InfRefmsgid,
  11614. OrderStatus: 1,
  11615. PayWay: pay_way,
  11616. PayWays: pay_ways,
  11617. OthDesc: oth_desc,
  11618. PayPrice: pay_price,
  11619. PayCardNo: pay_card_no,
  11620. DiscountPrice: discount_price,
  11621. PreferentialPrice: preferential_price,
  11622. RealityPrice: reality_price,
  11623. FoundPrice: found_price,
  11624. MedicalInsurancePrice: medical_insurance_price,
  11625. PrivatePrice: private_price,
  11626. IsMedicineInsurance: 1,
  11627. SettleType: settle_accounts_type,
  11628. SettleStartTime: start_time,
  11629. SettleEndTime: end_time,
  11630. Creator: roles.AdminUserId,
  11631. Modify: roles.AdminUserId,
  11632. FaPiaoNumber: fapiao_number,
  11633. FaPiaoCode: fapiao_code,
  11634. PType: 2,
  11635. Diagnosis: diagnosis_id,
  11636. CashPay: cash_pay,
  11637. WechatPay: wechat_pay,
  11638. AliPay: ali_pay,
  11639. JifenPay: jifen_pay,
  11640. BandCardPay: band_card_pay,
  11641. }
  11642. err = service.CreateOrder(order)
  11643. if err != nil {
  11644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11645. return
  11646. }
  11647. for _, item := range res.Output.Result {
  11648. temp := strings.Split(item.FeedetlSn, "-")
  11649. var advice_id int64 = 0
  11650. var project_id int64 = 0
  11651. var types int64 = 0
  11652. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11653. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11654. if temp[1] == "1" {
  11655. advice_id = id
  11656. project_id = 0
  11657. } else if temp[1] == "2" {
  11658. advice_id = 0
  11659. project_id = id
  11660. }
  11661. if item.MedChrgitmType == "9" {
  11662. item.MedChrgitmType = "09"
  11663. }
  11664. info := &models.HisOrderInfo{
  11665. OrderNumber: order.Number,
  11666. FeedetlSn: item.FeedetlSn,
  11667. UploadDate: time.Now().Unix(),
  11668. AdviceId: advice_id,
  11669. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11670. Cnt: item.Cnt,
  11671. Pric: float64(item.Pric),
  11672. PatientId: his.PatientId,
  11673. PricUplmtAmt: item.PricUplmtAmt,
  11674. SelfpayProp: item.SelfpayProp,
  11675. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11676. OverlmtAmt: item.OverlmtAmt,
  11677. PreselfpayAmt: item.PreselfpayAmt,
  11678. BasMednFlag: item.BasMednFlag,
  11679. MedChrgitmType: item.MedChrgitmType,
  11680. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11681. Status: 1,
  11682. Memo: item.Memo,
  11683. Mtime: time.Now().Unix(),
  11684. InscpScpAmt: item.InscpScpAmt,
  11685. DrtReimFlag: item.DrtReimFlag,
  11686. Ctime: time.Now().Unix(),
  11687. ListSpItemFlag: item.ListSpItemFlag,
  11688. ChldMedcFlag: item.ChldMedcFlag,
  11689. LmtUsedFlag: item.LmtUsedFlag,
  11690. ChrgitmLv: item.ChrgitmLv,
  11691. UserOrgId: adminUser.CurrentOrgId,
  11692. HisPatientId: his.ID,
  11693. OrderId: order.ID,
  11694. ProjectId: project_id,
  11695. Type: types,
  11696. }
  11697. service.CreateOrderInfo(info)
  11698. }
  11699. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11700. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11701. var total float64
  11702. for _, item := range prescriptions {
  11703. if item.Type == 1 { //药品
  11704. for _, subItem := range item.HisDoctorAdviceInfo {
  11705. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11706. total_one := price * subItem.PrescribingNumber
  11707. total = total + total_one
  11708. }
  11709. }
  11710. if item.Type == 2 { //项目
  11711. for _, subItem := range item.HisPrescriptionProject {
  11712. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11713. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11714. total_one := price * cnt
  11715. total = total + total_one
  11716. }
  11717. }
  11718. }
  11719. allTotal := fmt.Sprintf("%f", total)
  11720. //if adminUser.CurrentOrgId == 9919 {
  11721. //
  11722. // allTotal = fmt.Sprintf("%.2f", total)
  11723. //
  11724. //} else {
  11725. //
  11726. // allTotal = fmt.Sprintf("%.2f", total)
  11727. //
  11728. //}
  11729. if res.Infcode == 0 {
  11730. var rf []*ResultFive
  11731. json.Unmarshal([]byte(his.Iinfo), &rf)
  11732. chrg_bchno := chrg_bchno
  11733. cert_no := his.Certno
  11734. var insutypes []string
  11735. var insutype string
  11736. var is390 int = 0
  11737. var is310 int = 0
  11738. for _, item := range rf {
  11739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11740. insutypes = append(insutypes, item.Insutype)
  11741. }
  11742. }
  11743. if len(insutypes) == 1 {
  11744. insutype = insutypes[0]
  11745. } else {
  11746. for _, i := range insutypes {
  11747. if i == "390" {
  11748. is390 = 1
  11749. }
  11750. if i == "310" {
  11751. is310 = 1
  11752. }
  11753. }
  11754. }
  11755. if is390 == 1 {
  11756. insutype = "390"
  11757. }
  11758. if is310 == 1 {
  11759. insutype = "310"
  11760. }
  11761. if len(insutypes) == 0 {
  11762. insutype = "310"
  11763. }
  11764. if len(insutypes) == 2 {
  11765. insutype = strconv.FormatInt(his.SocialType, 10)
  11766. }
  11767. insutype = strconv.FormatInt(his.SocialType, 10)
  11768. //insutype = "390"
  11769. if his.IdCardType == 1 {
  11770. // cert_no = his.MedicalInsuranceNumber
  11771. cert_no = his.Certno
  11772. } else {
  11773. cert_no = his.Certno
  11774. }
  11775. var res ResultSeven
  11776. var resSeven10265 ResultSeven10265
  11777. var src_resquest string
  11778. var result2 string
  11779. if miConfig.MdtrtareaAdmvs == "421300" {
  11780. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11781. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11782. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11784. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11785. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11786. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  11787. resp, requestErr := http.Get(api)
  11788. if requestErr != nil {
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return
  11791. }
  11792. body, ioErr := ioutil.ReadAll(resp.Body)
  11793. if ioErr != nil {
  11794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11796. return
  11797. }
  11798. var respJSON map[string]interface{}
  11799. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11802. return
  11803. }
  11804. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11805. result, _ := json.Marshal(respJSON)
  11806. if miConfig.Code == "H15049901371" {
  11807. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11808. utils.ErrorLog("解析失败:%v", err)
  11809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11810. return
  11811. }
  11812. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11813. res.Output = resSeven10265.Output
  11814. res.ErrMsg = resSeven10265.ErrMsg
  11815. res.Cainfo = resSeven10265.Cainfo
  11816. res.WarnMsg = resSeven10265.WarnMsg
  11817. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11818. res.Infcode = infocode
  11819. } else {
  11820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11821. utils.ErrorLog("解析失败:%v", err)
  11822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11823. return
  11824. }
  11825. }
  11826. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11827. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  11828. if result3101.Infcode == "0" {
  11829. if len(result3101.Output.Result) > 0 {
  11830. var errMsgs []string
  11831. for _, item := range result3101.Output.Result {
  11832. errMsgs = append(errMsgs, item.VolaCont)
  11833. }
  11834. c.ServeSuccessJSON(map[string]interface{}{
  11835. "failed_code": -10,
  11836. "msg": errMsgs,
  11837. })
  11838. return
  11839. } else {
  11840. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11841. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11842. bas := strings.Split(psn_info.CardInfo, "|")
  11843. if his.IdCardType == 1 {
  11844. cert_no = bas[2]
  11845. } else if his.IdCardType == 3 {
  11846. cert_no = his.Certno
  11847. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11848. } else if his.IdCardType == 4 {
  11849. cert_no = his.Certno
  11850. psn_info.VerifyNumber = psn_info.VerifyNumber
  11851. }
  11852. var api string
  11853. if miConfig.MdtrtareaAdmvs == "320921" {
  11854. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11855. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11856. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11857. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11858. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11859. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11860. "&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
  11861. } else {
  11862. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11863. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11864. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11865. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11866. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11867. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11868. "&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
  11869. }
  11870. resp, requestErr := http.Get(api)
  11871. if requestErr != nil {
  11872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11873. return
  11874. }
  11875. body, ioErr := ioutil.ReadAll(resp.Body)
  11876. if ioErr != nil {
  11877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11879. return
  11880. }
  11881. var respJSON map[string]interface{}
  11882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11885. return
  11886. }
  11887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11888. result, _ := json.Marshal(respJSON)
  11889. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11890. utils.ErrorLog("解析失败:%v", err)
  11891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11892. return
  11893. }
  11894. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11895. res.Output = resSeven10265.Output
  11896. res.ErrMsg = resSeven10265.ErrMsg
  11897. res.Cainfo = resSeven10265.Cainfo
  11898. res.WarnMsg = resSeven10265.WarnMsg
  11899. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11900. res.Infcode = infocode
  11901. }
  11902. }
  11903. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11904. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11905. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11906. bas := strings.Split(psn_info.CardInfo, "|")
  11907. if his.IdCardType == 1 {
  11908. cert_no = bas[2]
  11909. } else if his.IdCardType == 3 {
  11910. cert_no = his.Certno
  11911. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  11912. } else if his.IdCardType == 4 {
  11913. cert_no = his.Certno
  11914. psn_info.VerifyNumber = psn_info.VerifyNumber
  11915. }
  11916. var api string
  11917. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11918. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11919. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11920. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11921. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11922. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11923. "&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
  11924. resp, requestErr := http.Get(api)
  11925. if requestErr != nil {
  11926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11927. return
  11928. }
  11929. body, ioErr := ioutil.ReadAll(resp.Body)
  11930. if ioErr != nil {
  11931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11933. return
  11934. }
  11935. var respJSON map[string]interface{}
  11936. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11939. return
  11940. }
  11941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11942. result, _ := json.Marshal(respJSON)
  11943. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11944. utils.ErrorLog("解析失败:%v", err)
  11945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11946. return
  11947. }
  11948. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11949. res.Output = resSeven10265.Output
  11950. res.ErrMsg = resSeven10265.ErrMsg
  11951. res.Cainfo = resSeven10265.Cainfo
  11952. res.WarnMsg = resSeven10265.WarnMsg
  11953. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11954. res.Infcode = infocode
  11955. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11956. var cert_no string
  11957. if his.IdCardType == 4 {
  11958. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11959. cert_no = psn_info.VerifyNumber
  11960. 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)
  11961. } else if his.IdCardType == 1 {
  11962. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11963. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  11964. 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)
  11965. }
  11966. //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)
  11967. var dat map[string]interface{}
  11968. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11969. fmt.Println(dat)
  11970. } else {
  11971. fmt.Println(err)
  11972. }
  11973. saveLog(result2, src_resquest, "2207", "结算")
  11974. userJSONBytes, _ := json.Marshal(dat)
  11975. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11976. utils.ErrorLog("解析失败:%v", err)
  11977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11978. return
  11979. }
  11980. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11981. res.Output = resSeven10265.Output
  11982. res.ErrMsg = resSeven10265.ErrMsg
  11983. res.Cainfo = resSeven10265.Cainfo
  11984. res.WarnMsg = resSeven10265.WarnMsg
  11985. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11986. res.Infcode = infocode
  11987. } else {
  11988. if miConfig.Code == "H15049901371" {
  11989. //赤峰地区国家医保医疗类别
  11990. //职工透析:医疗类别选特殊情况门诊990502
  11991. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11992. var med_type string
  11993. if his.Insutype == "390" {
  11994. if reg_type == 14 {
  11995. med_type = "9933"
  11996. } else if reg_type == 11 {
  11997. med_type = "11"
  11998. }
  11999. } else if his.Insutype == "310" {
  12000. if reg_type == 14 {
  12001. med_type = "990502"
  12002. } else if reg_type == 11 {
  12003. med_type = "11"
  12004. }
  12005. }
  12006. 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, "")
  12007. } else {
  12008. if his.IdCardType == 4 {
  12009. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12010. var token string
  12011. token = psn_info.VerifyNumber
  12012. 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)
  12013. } else {
  12014. 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, "")
  12015. }
  12016. }
  12017. //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)
  12018. var dat map[string]interface{}
  12019. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12020. fmt.Println(dat)
  12021. } else {
  12022. fmt.Println(err)
  12023. }
  12024. saveLog(result2, src_resquest, "2207", "结算")
  12025. userJSONBytes, _ := json.Marshal(dat)
  12026. if miConfig.Code == "H15049901371" {
  12027. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12028. utils.ErrorLog("解析失败:%v", err)
  12029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12030. return
  12031. }
  12032. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12033. res.Output = resSeven10265.Output
  12034. res.ErrMsg = resSeven10265.ErrMsg
  12035. res.Cainfo = resSeven10265.Cainfo
  12036. res.WarnMsg = resSeven10265.WarnMsg
  12037. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12038. res.Infcode = infocode
  12039. } else {
  12040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12041. utils.ErrorLog("解析失败:%v", err)
  12042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12043. return
  12044. }
  12045. }
  12046. }
  12047. if res.Infcode != 0 {
  12048. errlog := &models.HisOrderError{
  12049. UserOrgId: adminUser.CurrentOrgId,
  12050. Ctime: time.Now().Unix(),
  12051. Mtime: time.Now().Unix(),
  12052. Number: chrg_bchno,
  12053. ErrMsg: res.ErrMsg,
  12054. Status: 1,
  12055. PatientId: id,
  12056. RecordTime: recordDateTime,
  12057. Stage: 6,
  12058. }
  12059. service.CreateErrMsgLog(errlog)
  12060. c.ServeSuccessJSON(map[string]interface{}{
  12061. "failed_code": -10,
  12062. "msg": res.ErrMsg,
  12063. })
  12064. return
  12065. } else {
  12066. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12067. order.OrderStatus = 2
  12068. order.Status = 1
  12069. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12070. order.SetlId = res.Output.Setlinfo.SetlID
  12071. order.PsnNo = res.Output.Setlinfo.PsnNo
  12072. order.PsnName = res.Output.Setlinfo.PsnName
  12073. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12074. order.Certno = res.Output.Setlinfo.Certno
  12075. order.Gend = res.Output.Setlinfo.Gend
  12076. order.Naty = res.Output.Setlinfo.Naty
  12077. order.Age = res.Output.Setlinfo.Age
  12078. order.Insutype = res.Output.Setlinfo.Insutype
  12079. order.PsnType = res.Output.Setlinfo.PsnType
  12080. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12081. order.SetlTime = res.Output.Setlinfo.SetlTime
  12082. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12083. if res.Output.Setlinfo.MedType == "140101" {
  12084. order.MedType = "14"
  12085. } else {
  12086. order.MedType = res.Output.Setlinfo.MedType
  12087. }
  12088. if reg_type == 1112 {
  12089. order.MedType = "1112"
  12090. }
  12091. if reg_type == 1111 {
  12092. order.MedType = "1111"
  12093. }
  12094. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12095. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12096. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12097. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12098. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12099. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12100. order.HifpPay = res.Output.Setlinfo.HifpPay
  12101. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12102. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12103. order.HifesPay = res.Output.Setlinfo.HifesPay
  12104. order.HifobPay = res.Output.Setlinfo.HifobPay
  12105. order.MafPay = res.Output.Setlinfo.MafPay
  12106. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12107. order.OthPay = res.Output.Setlinfo.OthPay
  12108. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12109. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12110. order.AcctPay = res.Output.Setlinfo.AcctPay
  12111. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12112. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12113. order.Balc = res.Output.Setlinfo.Balc
  12114. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12115. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12116. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12117. order.ClrType = res.Output.Setlinfo.ClrType
  12118. order.ClrWay = res.Output.Setlinfo.ClrWay
  12119. order.Creator = order.Creator
  12120. order.Modify = roles.AdminUserId
  12121. order.RequestLog = src_resquest
  12122. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12123. detailStr := string(setlDetail)
  12124. order.SetlDetail = detailStr
  12125. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12126. err = service.UpDateOrder(order)
  12127. if err == nil {
  12128. //判断是否使用了押金
  12129. if dec_way == "true" {
  12130. tmpstring := strconv.FormatInt(order.ID, 10)
  12131. order.Decimal = decimal
  12132. service.UpDateOrder(order)
  12133. //扣押金
  12134. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  12135. if errmsg != nil {
  12136. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  12137. return
  12138. }
  12139. }
  12140. c.ServeSuccessJSON(map[string]interface{}{
  12141. "msg": "结算成功",
  12142. })
  12143. } else {
  12144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12145. return
  12146. }
  12147. }
  12148. } else {
  12149. adminUser := c.GetAdminUserInfo()
  12150. errlog := &models.HisOrderError{
  12151. UserOrgId: adminUser.CurrentOrgId,
  12152. Ctime: time.Now().Unix(),
  12153. Mtime: time.Now().Unix(),
  12154. ErrMsg: res.ErrMsg,
  12155. Status: 1,
  12156. PatientId: id,
  12157. RecordTime: recordDateTime,
  12158. Stage: 4,
  12159. }
  12160. service.CreateErrMsgLog(errlog)
  12161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12162. return
  12163. }
  12164. } else {
  12165. adminUser := c.GetAdminUserInfo()
  12166. errlog := &models.HisOrderError{
  12167. UserOrgId: adminUser.CurrentOrgId,
  12168. Ctime: time.Now().Unix(),
  12169. Mtime: time.Now().Unix(),
  12170. ErrMsg: res.ErrMsg,
  12171. Status: 1,
  12172. PatientId: id,
  12173. RecordTime: recordDateTime,
  12174. Stage: 4,
  12175. }
  12176. service.CreateErrMsgLog(errlog)
  12177. c.ServeSuccessJSON(map[string]interface{}{
  12178. "failed_code": -10,
  12179. "msg": res.ErrMsg,
  12180. })
  12181. return
  12182. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  12183. //return
  12184. }
  12185. }
  12186. }
  12187. } else if tempOrder.ID > 0 {
  12188. if tempOrder.IsPre == 1 {
  12189. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  12190. var rf []*ResultFive
  12191. json.Unmarshal([]byte(his.Iinfo), &rf)
  12192. chrg_bchno := tempOrder.Number
  12193. cert_no := his.Certno
  12194. var insutypes []string
  12195. var insutype string
  12196. var is390 int = 0
  12197. var is310 int = 0
  12198. for _, item := range rf {
  12199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12200. insutypes = append(insutypes, item.Insutype)
  12201. }
  12202. }
  12203. if len(insutypes) == 1 {
  12204. insutype = insutypes[0]
  12205. } else {
  12206. for _, i := range insutypes {
  12207. if i == "390" {
  12208. is390 = 1
  12209. }
  12210. if i == "310" {
  12211. is310 = 1
  12212. }
  12213. }
  12214. }
  12215. if is390 == 1 {
  12216. insutype = "390"
  12217. }
  12218. if is310 == 1 {
  12219. insutype = "310"
  12220. }
  12221. if len(insutypes) == 0 {
  12222. insutype = "310"
  12223. }
  12224. if len(insutypes) == 2 {
  12225. insutype = strconv.FormatInt(his.SocialType, 10)
  12226. }
  12227. //insutype = "390"
  12228. if his.IdCardType == 1 {
  12229. // cert_no = his.MedicalInsuranceNumber
  12230. cert_no = his.Certno
  12231. } else {
  12232. cert_no = his.Certno
  12233. }
  12234. var res ResultSeven
  12235. var resSeven10265 ResultSeven10265
  12236. var src_resquest string
  12237. var result2 string
  12238. if miConfig.MdtrtareaAdmvs == "421300" {
  12239. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12240. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12241. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12242. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12243. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12244. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12245. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  12246. resp, requestErr := http.Get(api)
  12247. if requestErr != nil {
  12248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12249. return
  12250. }
  12251. body, ioErr := ioutil.ReadAll(resp.Body)
  12252. if ioErr != nil {
  12253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12255. return
  12256. }
  12257. var respJSON map[string]interface{}
  12258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12261. return
  12262. }
  12263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12264. result, _ := json.Marshal(respJSON)
  12265. fmt.Println("log")
  12266. fmt.Println(string(result))
  12267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12268. utils.ErrorLog("解析失败:%v", err)
  12269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12270. return
  12271. }
  12272. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12273. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  12274. if result3101.Infcode == "0" {
  12275. if len(result3101.Output.Result) > 0 {
  12276. var errMsgs []string
  12277. for _, item := range result3101.Output.Result {
  12278. errMsgs = append(errMsgs, item.VolaCont)
  12279. }
  12280. c.ServeSuccessJSON(map[string]interface{}{
  12281. "failed_code": -10,
  12282. "msg": errMsgs,
  12283. })
  12284. return
  12285. } else {
  12286. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12287. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12288. bas := strings.Split(psn_info.CardInfo, "|")
  12289. if his.IdCardType == 1 {
  12290. cert_no = bas[2]
  12291. } else if his.IdCardType == 3 {
  12292. cert_no = his.Certno
  12293. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  12294. } else if his.IdCardType == 4 {
  12295. cert_no = his.Certno
  12296. psn_info.VerifyNumber = psn_info.VerifyNumber
  12297. }
  12298. //江苏地区国家医保医疗类别
  12299. //职工透析:医疗类别选特殊情况门诊9933
  12300. //居民血透门慢: 医疗类别选门诊慢病1402
  12301. //var med_type string
  12302. //if his.Insutype == "310" {
  12303. // if reg_type == 14 {
  12304. // med_type = "9933"
  12305. // } else if reg_type == 11 {
  12306. // med_type = "11"
  12307. //
  12308. // }
  12309. //} else if his.Insutype == "390" {
  12310. // if reg_type == 14 {
  12311. // med_type = "1402"
  12312. // } else if reg_type == 11 {
  12313. // med_type = "11"
  12314. // }
  12315. //}
  12316. var api string
  12317. if miConfig.MdtrtareaAdmvs == "320921" {
  12318. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12319. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12320. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12322. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12323. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12324. "&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
  12325. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12326. } else {
  12327. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12328. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12329. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12330. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12331. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12332. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12333. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12334. "&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
  12335. }
  12336. resp, requestErr := http.Get(api)
  12337. if requestErr != nil {
  12338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. return
  12340. }
  12341. body, ioErr := ioutil.ReadAll(resp.Body)
  12342. if ioErr != nil {
  12343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12345. return
  12346. }
  12347. var respJSON map[string]interface{}
  12348. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12351. return
  12352. }
  12353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12354. result, _ := json.Marshal(respJSON)
  12355. fmt.Println("log")
  12356. fmt.Println(string(result))
  12357. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12358. utils.ErrorLog("解析失败:%v", err)
  12359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12360. return
  12361. }
  12362. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12363. res.Output = resSeven10265.Output
  12364. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12365. res.ErrMsg = resSeven10265.ErrMsg
  12366. res.Cainfo = resSeven10265.Cainfo
  12367. res.WarnMsg = resSeven10265.WarnMsg
  12368. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12369. res.Infcode = infocode
  12370. }
  12371. }
  12372. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12373. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12374. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12375. bas := strings.Split(psn_info.CardInfo, "|")
  12376. if his.IdCardType == 1 {
  12377. cert_no = bas[2]
  12378. } else if his.IdCardType == 3 {
  12379. cert_no = his.Certno
  12380. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  12381. } else if his.IdCardType == 4 {
  12382. cert_no = his.Certno
  12383. psn_info.VerifyNumber = psn_info.VerifyNumber
  12384. }
  12385. var api string
  12386. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12387. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12388. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12389. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12390. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12391. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12392. "&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
  12393. resp, requestErr := http.Get(api)
  12394. if requestErr != nil {
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. body, ioErr := ioutil.ReadAll(resp.Body)
  12399. if ioErr != nil {
  12400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. var respJSON map[string]interface{}
  12405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12408. return
  12409. }
  12410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12411. result, _ := json.Marshal(respJSON)
  12412. fmt.Println("log")
  12413. fmt.Println(string(result))
  12414. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12415. utils.ErrorLog("解析失败:%v", err)
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12417. return
  12418. }
  12419. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12420. res.Output = resSeven10265.Output
  12421. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12422. res.ErrMsg = resSeven10265.ErrMsg
  12423. res.Cainfo = resSeven10265.Cainfo
  12424. res.WarnMsg = resSeven10265.WarnMsg
  12425. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12426. res.Infcode = infocode
  12427. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12428. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12429. var cert_no string
  12430. if his.IdCardType == 1 {
  12431. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12432. } else {
  12433. cert_no = psn_info.VerifyNumber
  12434. }
  12435. 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)
  12436. var dat map[string]interface{}
  12437. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12438. fmt.Println(dat)
  12439. } else {
  12440. fmt.Println(err)
  12441. }
  12442. saveLog(result2, src_resquest, "2207", "结算")
  12443. userJSONBytes, _ := json.Marshal(dat)
  12444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12445. utils.ErrorLog("解析失败:%v", err)
  12446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12447. return
  12448. }
  12449. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12450. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12451. var cert_no string
  12452. if his.IdCardType == 1 {
  12453. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12454. } else if his.IdCardType == 2 {
  12455. cert_no = his.IdCardNo
  12456. } else {
  12457. cert_no = psn_info.VerifyNumber
  12458. }
  12459. 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, "")
  12460. var dat map[string]interface{}
  12461. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12462. fmt.Println(dat)
  12463. } else {
  12464. fmt.Println(err)
  12465. }
  12466. saveLog(result2, src_resquest, "2207", "结算")
  12467. userJSONBytes, _ := json.Marshal(dat)
  12468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12469. utils.ErrorLog("解析失败:%v", err)
  12470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12471. return
  12472. }
  12473. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12474. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12475. var cert_no string
  12476. if his.IdCardType == 1 {
  12477. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12478. } else if his.IdCardType == 2 {
  12479. cert_no = his.IdCardNo
  12480. } else {
  12481. cert_no = psn_info.VerifyNumber
  12482. }
  12483. 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, "")
  12484. var dat map[string]interface{}
  12485. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12486. fmt.Println(dat)
  12487. } else {
  12488. fmt.Println(err)
  12489. }
  12490. saveLog(result2, src_resquest, "2207", "结算")
  12491. userJSONBytes, _ := json.Marshal(dat)
  12492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12493. utils.ErrorLog("解析失败:%v", err)
  12494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12495. return
  12496. }
  12497. } else {
  12498. var src_resquest string
  12499. if miConfig.Code == "H15049901371" {
  12500. //赤峰地区国家医保医疗类别
  12501. //职工透析:医疗类别选特殊情况门诊990502
  12502. //居民定额血透门慢: 医疗类别选门诊慢病140104
  12503. var med_type string
  12504. if his.Insutype == "390" {
  12505. if reg_type == 14 {
  12506. med_type = "9933"
  12507. } else if reg_type == 11 {
  12508. med_type = "11"
  12509. }
  12510. } else if his.Insutype == "310" {
  12511. if reg_type == 14 {
  12512. med_type = "990502"
  12513. } else if reg_type == 11 {
  12514. med_type = "11"
  12515. }
  12516. }
  12517. 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, "")
  12518. } else {
  12519. if his.IdCardType == 4 {
  12520. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12521. token := psn_info.VerifyNumber
  12522. 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)
  12523. } else {
  12524. 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, "")
  12525. }
  12526. }
  12527. var dat map[string]interface{}
  12528. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12529. fmt.Println(dat)
  12530. } else {
  12531. fmt.Println(err)
  12532. }
  12533. saveLog(result2, src_resquest, "2207", "结算")
  12534. userJSONBytes, _ := json.Marshal(dat)
  12535. if miConfig.Code == "H15049901371" {
  12536. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12537. utils.ErrorLog("解析失败:%v", err)
  12538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12539. return
  12540. }
  12541. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12542. res.Output = resSeven10265.Output
  12543. res.ErrMsg = resSeven10265.ErrMsg
  12544. res.Cainfo = resSeven10265.Cainfo
  12545. res.WarnMsg = resSeven10265.WarnMsg
  12546. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12547. res.Infcode = infocode
  12548. } else {
  12549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12550. utils.ErrorLog("解析失败:%v", err)
  12551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12552. return
  12553. }
  12554. }
  12555. }
  12556. if res.Infcode != 0 {
  12557. errlog := &models.HisOrderError{
  12558. UserOrgId: adminUser.CurrentOrgId,
  12559. Ctime: time.Now().Unix(),
  12560. Mtime: time.Now().Unix(),
  12561. Number: chrg_bchno,
  12562. ErrMsg: res.ErrMsg,
  12563. Status: 1,
  12564. PatientId: id,
  12565. RecordTime: recordDateTime,
  12566. Stage: 6,
  12567. }
  12568. service.CreateErrMsgLog(errlog)
  12569. c.ServeSuccessJSON(map[string]interface{}{
  12570. "failed_code": -10,
  12571. "msg": res.ErrMsg,
  12572. })
  12573. return
  12574. } else {
  12575. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12576. order.OrderStatus = 2
  12577. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12578. order.SetlId = res.Output.Setlinfo.SetlID
  12579. order.PsnNo = res.Output.Setlinfo.PsnNo
  12580. order.PsnName = res.Output.Setlinfo.PsnName
  12581. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12582. order.Certno = res.Output.Setlinfo.Certno
  12583. order.Gend = res.Output.Setlinfo.Gend
  12584. order.Naty = res.Output.Setlinfo.Naty
  12585. order.Age = res.Output.Setlinfo.Age
  12586. order.Insutype = res.Output.Setlinfo.Insutype
  12587. order.PsnType = res.Output.Setlinfo.PsnType
  12588. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12589. order.SetlTime = res.Output.Setlinfo.SetlTime
  12590. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12591. order.PayWays = pay_ways
  12592. order.AcctUsedFlag = acct_used_flag
  12593. order.WechatPay = wechat_pay
  12594. order.AliPay = ali_pay
  12595. order.JifenPay = jifen_pay
  12596. order.BandCardPay = band_card_pay
  12597. order.CashPay = cash_pay
  12598. order.OthDesc = oth_desc
  12599. //order.MedType = res.Output.Setlinfo.MedType
  12600. if reg_type == 1112 {
  12601. order.MedType = "1112"
  12602. }
  12603. if reg_type == 1111 {
  12604. order.MedType = "1111"
  12605. }
  12606. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12607. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12608. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12609. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12610. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12611. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12612. order.HifpPay = res.Output.Setlinfo.HifpPay
  12613. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12614. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12615. order.HifesPay = res.Output.Setlinfo.HifesPay
  12616. order.HifobPay = res.Output.Setlinfo.HifobPay
  12617. order.MafPay = res.Output.Setlinfo.MafPay
  12618. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12619. order.OthPay = res.Output.Setlinfo.OthPay
  12620. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12621. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12622. order.AcctPay = res.Output.Setlinfo.AcctPay
  12623. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12624. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12625. order.Balc = res.Output.Setlinfo.Balc
  12626. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12627. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12628. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12629. order.ClrWay = res.Output.Setlinfo.ClrWay
  12630. order.Creator = order.Creator
  12631. order.Modify = roles.AdminUserId
  12632. order.RequestLog = src_resquest
  12633. order.Diagnosis = diagnosis_id
  12634. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12635. detailStr := string(setlDetail)
  12636. order.SetlDetail = detailStr
  12637. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12638. err = service.UpDateOrder(order)
  12639. if err == nil {
  12640. //判断是否使用了押金
  12641. if dec_way == "true" {
  12642. tmpstring := strconv.FormatInt(order.ID, 10)
  12643. //扣押金
  12644. order.Decimal = decimal
  12645. service.UpDateOrder(order)
  12646. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  12647. if errmsg != nil {
  12648. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  12649. return
  12650. }
  12651. }
  12652. c.ServeSuccessJSON(map[string]interface{}{
  12653. "msg": "结算成功",
  12654. })
  12655. } else {
  12656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12657. return
  12658. }
  12659. }
  12660. }
  12661. }
  12662. }
  12663. //func (c *HisApiController) GetPreUploadInfo() {
  12664. // id, _ := c.GetInt64("id")
  12665. // record_time := c.GetString("record_time")
  12666. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  12667. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12668. //
  12669. // timeLayout := "2006-01-02"
  12670. // loc, _ := time.LoadLocation("Local")
  12671. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12672. // if err != nil {
  12673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12674. // return
  12675. // }
  12676. // recordDateTime := theTime.Unix()
  12677. // adminUser := c.GetAdminUserInfo()
  12678. //
  12679. // var prescriptions []*models.HisPrescription
  12680. //
  12681. // var start_time int64
  12682. // var end_time int64
  12683. //
  12684. // data := make(map[string]interface{})
  12685. // if settle_accounts_type == 1 { //日结
  12686. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  12687. // data["pre"] = prescriptions
  12688. //
  12689. // } else { //月结
  12690. // start_time_str := c.GetString("start_time")
  12691. // end_time_str := c.GetString("end_time")
  12692. // timeLayout := "2006-01-02"
  12693. // loc, _ := time.LoadLocation("Local")
  12694. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  12695. // if err != nil {
  12696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12697. // return
  12698. // }
  12699. // recordStartTime := theStartTime.Unix()
  12700. // start_time = recordStartTime
  12701. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  12702. // if err != nil {
  12703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12704. // return
  12705. // }
  12706. // recordEndTime := theEndTime.Unix()
  12707. // end_time = recordEndTime
  12708. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  12709. // data["pre"] = prescriptions
  12710. //
  12711. // }
  12712. //
  12713. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12714. //
  12715. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12716. // timestamp := time.Now().Unix()
  12717. // tempTime := time.Unix(timestamp, 0)
  12718. // timeFormat := tempTime.Format("20060102150405")
  12719. // chrgBchno := rand.Intn(100000) + 10000
  12720. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  12721. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12722. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12723. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12724. // strconv.FormatInt(his.PatientId, 10)
  12725. // client := &http.Client{}
  12726. // data["psn_no"] = his.PsnNo
  12727. // data["mdtrt_id"] = his.Number
  12728. // data["chrg_bchno"] = chrg_bchno
  12729. // data["org_name"] = miConfig.OrgName
  12730. // data["doctor"] = roles.UserName
  12731. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  12732. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  12733. // data["fixmedins_code"] = miConfig.Code
  12734. // data["dept_code"] = department.Number
  12735. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  12736. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12737. // data["secret_key"] = miConfig.SecretKey
  12738. // var ids []int64
  12739. //
  12740. // for _, item := range prescriptions {
  12741. // ids = append(ids, item.ID)
  12742. // }
  12743. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12744. // if config.IsOpen == 1 { //对接了医保,走医保流程
  12745. // bytesData, _ := json.Marshal(data)
  12746. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  12747. // resp, _ := client.Do(req)
  12748. // defer resp.Body.Close()
  12749. // body, ioErr := ioutil.ReadAll(resp.Body)
  12750. // if ioErr != nil {
  12751. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12753. // return
  12754. // }
  12755. // var respJSON map[string]interface{}
  12756. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12759. // return
  12760. // }
  12761. //
  12762. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12763. // userJSONBytes, _ := json.Marshal(respJSON)
  12764. // var res ResultFour
  12765. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12766. // utils.ErrorLog("解析失败:%v", err)
  12767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12768. // return
  12769. // }
  12770. //
  12771. // if res.Infcode == 0 {
  12772. // order := &models.HisOrder{
  12773. // UserOrgId: adminUser.CurrentOrgId,
  12774. // HisPatientId: his.ID,
  12775. // PatientId: his.PatientId,
  12776. // SettleAccountsDate: recordDateTime,
  12777. // Ctime: time.Now().Unix(),
  12778. // Mtime: time.Now().Unix(),
  12779. // Status: 1,
  12780. // Number: chrg_bchno,
  12781. // Infcode: res.Infcode,
  12782. // WarnMsg: res.WarnMsg,
  12783. // Cainfo: res.Cainfo,
  12784. // ErrMsg: res.ErrMsg,
  12785. // RespondTime: res.RefmsgTime,
  12786. // InfRefmsgid: res.InfRefmsgid,
  12787. // OrderStatus: 1,
  12788. // IsMedicineInsurance: 1,
  12789. // SettleType: settle_accounts_type,
  12790. // SettleStartTime: start_time,
  12791. // SettleEndTime: end_time,
  12792. // Creator: roles.ID,
  12793. // Modify: roles.ID,
  12794. // PType: 2,
  12795. // }
  12796. // err = service.CreateOrder(order)
  12797. // if err != nil {
  12798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  12799. // return
  12800. // }
  12801. //
  12802. // for _, item := range res.Output.Result {
  12803. // temp := strings.Split(item.FeedetlSn, "-")
  12804. // var advice_id int64 = 0
  12805. // var project_id int64 = 0
  12806. // var types int64 = 0
  12807. //
  12808. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  12809. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  12810. //
  12811. // if temp[1] == "1" {
  12812. // advice_id = id
  12813. // project_id = 0
  12814. // } else if temp[1] == "2" {
  12815. // advice_id = 0
  12816. // project_id = id
  12817. // }
  12818. //
  12819. // info := &models.HisOrderInfo{
  12820. // OrderNumber: order.Number,
  12821. // FeedetlSn: item.FeedetlSn,
  12822. // UploadDate: time.Now().Unix(),
  12823. // AdviceId: advice_id,
  12824. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  12825. // Cnt: item.Cnt,
  12826. // Pric: float64(item.Pric),
  12827. // PatientId: his.PatientId,
  12828. // PricUplmtAmt: item.PricUplmtAmt,
  12829. // SelfpayProp: item.SelfpayProp,
  12830. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  12831. // OverlmtAmt: item.OverlmtAmt,
  12832. // PreselfpayAmt: item.PreselfpayAmt,
  12833. // BasMednFlag: item.BasMednFlag,
  12834. // MedChrgitmType: item.MedChrgitmType,
  12835. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  12836. // Status: 1,
  12837. // Memo: item.Memo,
  12838. // Mtime: time.Now().Unix(),
  12839. // InscpScpAmt: item.InscpScpAmt,
  12840. // DrtReimFlag: item.DrtReimFlag,
  12841. // Ctime: time.Now().Unix(),
  12842. // ListSpItemFlag: item.ListSpItemFlag,
  12843. // ChldMedcFlag: item.ChldMedcFlag,
  12844. // LmtUsedFlag: item.LmtUsedFlag,
  12845. // ChrgitmLv: item.ChrgitmLv,
  12846. // UserOrgId: adminUser.CurrentOrgId,
  12847. // HisPatientId: his.ID,
  12848. // OrderId: order.ID,
  12849. // ProjectId: project_id,
  12850. // Type: types,
  12851. // }
  12852. // service.CreateOrderInfo(info)
  12853. //
  12854. // }
  12855. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12856. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  12857. //
  12858. // var total float64
  12859. // for _, item := range prescriptions {
  12860. // if item.Type == 1 { //药品
  12861. // for _, subItem := range item.HisDoctorAdviceInfo {
  12862. // total = total + (subItem.Price * subItem.PrescribingNumber)
  12863. // }
  12864. // }
  12865. // if item.Type == 2 { //项目
  12866. // for _, subItem := range item.HisPrescriptionProject {
  12867. // total = total + (subItem.Price * float64(subItem.Count))
  12868. // }
  12869. // }
  12870. // }
  12871. //
  12872. // for _, item := range prescriptions {
  12873. // for _, subItem := range item.HisAdditionalCharge {
  12874. // total = total + (subItem.Price * float64(subItem.Count))
  12875. // }
  12876. // }
  12877. //
  12878. // allTotal := fmt.Sprintf("%.2f", total)
  12879. // if res.Infcode == 0 {
  12880. // var rf []*ResultFive
  12881. // json.Unmarshal([]byte(his.Iinfo), &rf)
  12882. // psn_no := his.PsnNo
  12883. // mdtrt_id := his.Number
  12884. // chrg_bchno := chrg_bchno
  12885. // cert_no := his.Certno
  12886. // insutype := rf[0].Insutype
  12887. //
  12888. // if his.IdCardType == 1 {
  12889. // cert_no = his.MedicalInsuranceNumber
  12890. //
  12891. // } else {
  12892. //
  12893. // cert_no = his.Certno
  12894. //
  12895. // }
  12896. //
  12897. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  12898. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  12899. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  12900. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  12901. // resp, requestErr := http.Get(api)
  12902. // if requestErr != nil {
  12903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. // return
  12905. // }
  12906. // defer resp.Body.Close()
  12907. // body, ioErr := ioutil.ReadAll(resp.Body)
  12908. // if ioErr != nil {
  12909. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. // return
  12912. // }
  12913. // var respJSON map[string]interface{}
  12914. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12915. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. // return
  12918. // }
  12919. // fmt.Println(respJSON)
  12920. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12921. // userJSONBytes, _ := json.Marshal(respJSON)
  12922. // var res ResultSeven
  12923. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12924. // utils.ErrorLog("解析失败:%v", err)
  12925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12926. // return
  12927. // }
  12928. // if res.Infcode != 0 {
  12929. // errlog := &models.HisOrderError{
  12930. // UserOrgId: adminUser.CurrentOrgId,
  12931. // Ctime: time.Now().Unix(),
  12932. // Mtime: time.Now().Unix(),
  12933. // Number: chrg_bchno,
  12934. // ErrMsg: res.ErrMsg,
  12935. // Status: 1,
  12936. // PatientId: id,
  12937. // RecordTime: recordDateTime,
  12938. // Stage: 7,
  12939. // }
  12940. // service.CreateErrMsgLog(errlog)
  12941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12942. // return
  12943. // } else {
  12944. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12945. // order.OrderStatus = 1
  12946. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12947. // order.SetlId = res.Output.Setlinfo.SetlID
  12948. // order.PsnNo = res.Output.Setlinfo.PsnNo
  12949. // order.PsnName = res.Output.Setlinfo.PsnName
  12950. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12951. // order.Certno = res.Output.Setlinfo.Certno
  12952. // order.Gend = res.Output.Setlinfo.Gend
  12953. // order.Naty = res.Output.Setlinfo.Naty
  12954. // order.Age = res.Output.Setlinfo.Age
  12955. // order.Insutype = res.Output.Setlinfo.Insutype
  12956. // order.PsnType = res.Output.Setlinfo.PsnType
  12957. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12958. // order.SetlTime = res.Output.Setlinfo.SetlTime
  12959. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12960. // order.MedType = res.Output.Setlinfo.MedType
  12961. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12962. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12963. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12964. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12965. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12966. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12967. // order.HifpPay = res.Output.Setlinfo.HifpPay
  12968. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12969. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12970. // order.HifesPay = res.Output.Setlinfo.HifesPay
  12971. // order.HifobPay = res.Output.Setlinfo.HifobPay
  12972. // order.MafPay = res.Output.Setlinfo.MafPay
  12973. // order.OthPay = res.Output.Setlinfo.OthPay
  12974. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12975. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12976. // order.AcctPay = res.Output.Setlinfo.AcctPay
  12977. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12978. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12979. // order.Balc = res.Output.Setlinfo.Balc
  12980. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12981. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12982. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12983. // order.ClrWay = res.Output.Setlinfo.ClrWay
  12984. // order.Creator = order.Creator
  12985. // order.Modify = roles.ID
  12986. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12987. // detailStr := string(setlDetail)
  12988. // order.SetlDetail = detailStr
  12989. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12990. // err = service.UpDateOrder(order)
  12991. // if err == nil {
  12992. // c.ServeSuccessJSON(map[string]interface{}{
  12993. // "msg": "预结算成功",
  12994. // })
  12995. // } else {
  12996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12997. // return
  12998. // }
  12999. // }
  13000. // } else {
  13001. // adminUser := c.GetAdminUserInfo()
  13002. // errlog := &models.HisOrderError{
  13003. // UserOrgId: adminUser.CurrentOrgId,
  13004. // Ctime: time.Now().Unix(),
  13005. // Mtime: time.Now().Unix(),
  13006. // ErrMsg: res.ErrMsg,
  13007. // Status: 1,
  13008. // PatientId: id,
  13009. // RecordTime: recordDateTime,
  13010. // Stage: 4,
  13011. // }
  13012. // service.CreateErrMsgLog(errlog)
  13013. //
  13014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  13015. // return
  13016. // }
  13017. // } else {
  13018. // adminUser := c.GetAdminUserInfo()
  13019. // errlog := &models.HisOrderError{
  13020. // UserOrgId: adminUser.CurrentOrgId,
  13021. // Ctime: time.Now().Unix(),
  13022. // Mtime: time.Now().Unix(),
  13023. // ErrMsg: res.ErrMsg,
  13024. // Status: 1,
  13025. // PatientId: id,
  13026. // RecordTime: recordDateTime,
  13027. // Stage: 4,
  13028. // }
  13029. // service.CreateErrMsgLog(errlog)
  13030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  13031. // return
  13032. // }
  13033. //
  13034. // } else {
  13035. // var total float64
  13036. // for _, item := range prescriptions {
  13037. // if item.Type == 1 { //药品
  13038. // for _, subItem := range item.HisDoctorAdviceInfo {
  13039. // total = total + (subItem.Price * subItem.PrescribingNumber)
  13040. // }
  13041. // }
  13042. // if item.Type == 2 { //项目
  13043. // for _, subItem := range item.HisPrescriptionProject {
  13044. // total = total + (subItem.Price * float64(subItem.Count))
  13045. // }
  13046. // }
  13047. //
  13048. // for _, subItem := range item.HisAdditionalCharge {
  13049. // total = total + (subItem.Price * float64(subItem.Count))
  13050. // }
  13051. // }
  13052. //
  13053. // allTotal := fmt.Sprintf("%.2f", total)
  13054. // totals, _ := strconv.ParseFloat(allTotal, 64)
  13055. // order := &models.HisOrder{
  13056. // UserOrgId: adminUser.CurrentOrgId,
  13057. // HisPatientId: his.ID,
  13058. // PatientId: id,
  13059. // SettleAccountsDate: recordDateTime,
  13060. // Ctime: time.Now().Unix(),
  13061. // Mtime: time.Now().Unix(),
  13062. // Status: 1,
  13063. // OrderStatus: 2,
  13064. // Number: chrg_bchno,
  13065. // MedfeeSumamt: totals,
  13066. // }
  13067. // err = service.CreateOrder(order)
  13068. // if err != nil {
  13069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  13070. // return
  13071. // }
  13072. //
  13073. // var customs []*Custom
  13074. // for _, item := range prescriptions {
  13075. //
  13076. // if item.Type == 1 { //药品
  13077. // for _, subItem := range item.HisDoctorAdviceInfo {
  13078. // cus := &Custom{
  13079. // AdviceId: subItem.ID,
  13080. // ProjectId: 0,
  13081. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  13082. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  13083. // FeedetlSn: subItem.FeedetlSn,
  13084. // Price: fmt.Sprintf("%.2f", subItem.Price),
  13085. // MedListCodg: subItem.MedListCodg,
  13086. // Type: 1,
  13087. // }
  13088. // customs = append(customs, cus)
  13089. // }
  13090. // }
  13091. //
  13092. // if item.Type == 2 { //项目
  13093. // for _, subItem := range item.HisPrescriptionProject {
  13094. //
  13095. // cus := &Custom{
  13096. // AdviceId: 0,
  13097. // ProjectId: subItem.ID,
  13098. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  13099. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  13100. // FeedetlSn: subItem.FeedetlSn,
  13101. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  13102. // MedListCodg: subItem.MedListCodg,
  13103. // Type: 2,
  13104. // }
  13105. //
  13106. // customs = append(customs, cus)
  13107. // }
  13108. // }
  13109. //
  13110. // for _, item := range item.HisAdditionalCharge {
  13111. // cus := &Custom{
  13112. // ItemId: item.ID,
  13113. // AdviceId: 0,
  13114. // ProjectId: 0,
  13115. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  13116. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  13117. // FeedetlSn: item.FeedetlSn,
  13118. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  13119. // MedListCodg: item.XtHisAddtionConfig.Code,
  13120. // Type: 3,
  13121. // }
  13122. //
  13123. // customs = append(customs, cus)
  13124. // }
  13125. //
  13126. // }
  13127. //
  13128. // for _, item := range customs {
  13129. // var advice_id int64 = 0
  13130. // var project_id int64 = 0
  13131. // var item_id int64 = 0
  13132. //
  13133. // var types int64 = 0
  13134. //
  13135. // if item.Type == 1 {
  13136. // advice_id = item.AdviceId
  13137. // project_id = 0
  13138. // item_id = 0
  13139. // } else if item.Type == 2 {
  13140. // advice_id = 0
  13141. // item_id = 0
  13142. //
  13143. // project_id = item.ProjectId
  13144. // } else if item.Type == 3 {
  13145. // advice_id = 0
  13146. // item_id = item.ItemId
  13147. // project_id = 0
  13148. // }
  13149. //
  13150. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  13151. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  13152. // pric, _ := strconv.ParseFloat(item.Price, 32)
  13153. //
  13154. // info := &models.HisOrderInfo{
  13155. // OrderNumber: order.Number,
  13156. // UploadDate: time.Now().Unix(),
  13157. // AdviceId: advice_id,
  13158. // DetItemFeeSumamt: detItemFeeSumamt,
  13159. // Cnt: cut,
  13160. // Pric: pric,
  13161. // PatientId: id,
  13162. // Status: 1,
  13163. // Mtime: time.Now().Unix(),
  13164. // Ctime: time.Now().Unix(),
  13165. // UserOrgId: adminUser.CurrentOrgId,
  13166. // HisPatientId: his.ID,
  13167. // OrderId: order.ID,
  13168. // ProjectId: project_id,
  13169. // Type: types,
  13170. // ItemId: item_id,
  13171. // }
  13172. // service.CreateOrderInfo(info)
  13173. // }
  13174. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13175. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13176. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  13177. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  13178. // if err == nil {
  13179. // c.ServeSuccessJSON(map[string]interface{}{
  13180. // "msg": "结算成功",
  13181. // })
  13182. // } else {
  13183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  13184. // return
  13185. // }
  13186. // }
  13187. //}
  13188. // 上传明细-预结算-
  13189. func (c *HisApiController) GetPreUploadInfo() {
  13190. id, _ := c.GetInt64("id")
  13191. record_time := c.GetString("record_time")
  13192. his_patient_id, _ := c.GetInt64("his_patient_id")
  13193. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  13194. admin_user_id, _ := c.GetInt64("admin_user_id")
  13195. diagnosis_id := c.GetString("diagnosis")
  13196. sick_type, _ := c.GetInt64("sick_type")
  13197. reg_type, _ := c.GetInt64("p_type")
  13198. begin_time := c.GetString("begin_time")
  13199. acct_used_flag := c.GetString("acct_used_flag")
  13200. id_str := c.GetString("ids")
  13201. ids_arr := strings.Split(id_str, ",")
  13202. timeLayout := "2006-01-02"
  13203. loc, _ := time.LoadLocation("Local")
  13204. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13205. if err != nil {
  13206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13207. return
  13208. }
  13209. recordDateTime := theTime.Unix()
  13210. adminUser := c.GetAdminUserInfo()
  13211. diagnosis_ids := strings.Split(diagnosis_id, ",")
  13212. var config []*models.HisXtDiagnoseConfig
  13213. for _, item := range diagnosis_ids {
  13214. id, _ := strconv.ParseInt(item, 10, 64)
  13215. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13216. config = append(config, &diagnosisConfig)
  13217. }
  13218. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13219. sickConfig, _ := service.FindSickById(sick_type)
  13220. var prescriptions []*models.HisPrescription
  13221. var start_time int64
  13222. var end_time int64
  13223. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13224. fmt.Println(his_patient_id)
  13225. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13226. timestamp := time.Now().Unix()
  13227. tempTime := time.Unix(timestamp, 0)
  13228. timeFormat := tempTime.Format("20060102150405")
  13229. chrgBchno := rand.Intn(100000) + 10000
  13230. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  13231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13232. var patientPrescription models.HisPrescriptionInfo
  13233. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13234. if patientPrescription.ID == 0 {
  13235. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  13236. }
  13237. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13238. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13239. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13240. strconv.FormatInt(his.PatientId, 10)
  13241. var res2 ResultSix
  13242. var resSix10265 ResultSix10265
  13243. //var time_stamp string
  13244. if miConfig.MdtrtareaAdmvs == "421300" {
  13245. data := make(map[string]interface{})
  13246. client := &http.Client{}
  13247. data["psn_no"] = his.PsnNo
  13248. data["mdtrt_id"] = his.Number
  13249. data["department"] = department.Name
  13250. data["org_name"] = miConfig.OrgName
  13251. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13252. data["doctor_id"] = doctor_info.DoctorNumber
  13253. data["doctor_name"] = roles.UserName
  13254. data["fixmedins_code"] = miConfig.Code
  13255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13257. data["secret_key"] = miConfig.SecretKey
  13258. data["sick_code"] = sickConfig.CountryCode
  13259. data["sick_name"] = sickConfig.ClassName
  13260. data["begin_time"] = begin_time
  13261. data["dept"] = strconv.FormatInt(department.ID, 10)
  13262. data["config"] = config
  13263. data["opter"] = roles.UserName
  13264. fmt.Println(data)
  13265. bytesData, _ := json.Marshal(data)
  13266. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  13267. resp, _ := client.Do(req)
  13268. defer resp.Body.Close()
  13269. body, ioErr := ioutil.ReadAll(resp.Body)
  13270. if ioErr != nil {
  13271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13273. return
  13274. }
  13275. var respJSON map[string]interface{}
  13276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13279. return
  13280. }
  13281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13282. userJSONBytes, _ := json.Marshal(respJSON)
  13283. fmt.Println("log")
  13284. fmt.Println(string(userJSONBytes))
  13285. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13286. utils.ErrorLog("解析失败:%v", err)
  13287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13288. return
  13289. }
  13290. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13291. data := make(map[string]interface{})
  13292. client := &http.Client{}
  13293. data["psn_no"] = his.PsnNo
  13294. data["mdtrt_id"] = his.Number
  13295. data["doctor"] = roles.UserName
  13296. data["department"] = department.Name
  13297. data["org_name"] = miConfig.OrgName
  13298. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13299. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  13300. data["fixmedins_code"] = miConfig.Code
  13301. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13302. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13303. data["secret_key"] = miConfig.SecretKey
  13304. data["sick_code"] = sickConfig.CountryCode
  13305. data["sick_name"] = sickConfig.ClassName
  13306. data["begin_time"] = begin_time
  13307. data["dept"] = strconv.FormatInt(department.ID, 10)
  13308. data["config"] = config
  13309. data["url"] = miConfig.Url
  13310. data["ak"] = miConfig.AccessKey
  13311. data["cainfo"] = miConfig.Cainfo
  13312. bytesData, _ := json.Marshal(data)
  13313. var req *http.Request
  13314. if miConfig.MdtrtareaAdmvs == "320921" {
  13315. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13316. } else {
  13317. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13318. }
  13319. resp, _ := client.Do(req)
  13320. defer resp.Body.Close()
  13321. body, ioErr := ioutil.ReadAll(resp.Body)
  13322. if ioErr != nil {
  13323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13325. return
  13326. }
  13327. var respJSON map[string]interface{}
  13328. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13331. return
  13332. }
  13333. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  13334. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  13335. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  13336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13337. userJSONBytes, _ := json.Marshal(respJSON)
  13338. fmt.Println("log")
  13339. fmt.Println(string(userJSONBytes))
  13340. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13341. utils.ErrorLog("解析失败:%v", err)
  13342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13343. return
  13344. }
  13345. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13346. res2.Output = resSix10265.Output
  13347. res2.ErrMsg = resSix10265.ErrMsg
  13348. res2.Cainfo = resSix10265.Cainfo
  13349. res2.WarnMsg = resSix10265.WarnMsg
  13350. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13351. res2.Infcode = infocode
  13352. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13353. data := make(map[string]interface{})
  13354. client := &http.Client{}
  13355. data["psn_no"] = his.PsnNo
  13356. data["mdtrt_id"] = his.Number
  13357. data["doctor"] = roles.UserName
  13358. data["department"] = department.Name
  13359. data["org_name"] = miConfig.OrgName
  13360. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13361. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  13362. data["fixmedins_code"] = miConfig.Code
  13363. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13364. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13365. data["secret_key"] = miConfig.SecretKey
  13366. data["sick_code"] = sickConfig.CountryCode
  13367. data["sick_name"] = sickConfig.ClassName
  13368. data["begin_time"] = begin_time
  13369. data["dept"] = strconv.FormatInt(department.ID, 10)
  13370. data["config"] = config
  13371. data["url"] = miConfig.Url
  13372. data["ak"] = miConfig.AccessKey
  13373. data["cainfo"] = miConfig.Cainfo
  13374. bytesData, _ := json.Marshal(data)
  13375. var req *http.Request
  13376. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  13377. resp, _ := client.Do(req)
  13378. defer resp.Body.Close()
  13379. body, ioErr := ioutil.ReadAll(resp.Body)
  13380. if ioErr != nil {
  13381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13383. return
  13384. }
  13385. var respJSON map[string]interface{}
  13386. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13389. return
  13390. }
  13391. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  13392. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  13393. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  13394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13395. userJSONBytes, _ := json.Marshal(respJSON)
  13396. fmt.Println("log")
  13397. fmt.Println(string(userJSONBytes))
  13398. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13399. utils.ErrorLog("解析失败:%v", err)
  13400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13401. return
  13402. }
  13403. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13404. res2.Output = resSix10265.Output
  13405. res2.ErrMsg = resSix10265.ErrMsg
  13406. res2.Cainfo = resSix10265.Cainfo
  13407. res2.WarnMsg = resSix10265.WarnMsg
  13408. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13409. res2.Infcode = infocode
  13410. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13411. 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)
  13412. saveLog(result, requestLog, "2203", "上传就诊信息")
  13413. var respJSON2 map[string]interface{}
  13414. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13417. return
  13418. }
  13419. userJSONBytes2, _ := json.Marshal(respJSON2)
  13420. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13421. utils.ErrorLog("解析失败:%v", err)
  13422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13423. return
  13424. }
  13425. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13426. var result string
  13427. var requestLog string
  13428. 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, "")
  13429. saveLog(result, requestLog, "2203", "上传就诊信息")
  13430. var respJSON2 map[string]interface{}
  13431. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13434. return
  13435. }
  13436. userJSONBytes2, _ := json.Marshal(respJSON2)
  13437. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13438. utils.ErrorLog("解析失败:%v", err)
  13439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13440. return
  13441. }
  13442. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13443. var result string
  13444. var requestLog string
  13445. 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, "")
  13446. saveLog(result, requestLog, "2203", "上传就诊信息")
  13447. var respJSON2 map[string]interface{}
  13448. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13451. return
  13452. }
  13453. userJSONBytes2, _ := json.Marshal(respJSON2)
  13454. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13455. utils.ErrorLog("解析失败:%v", err)
  13456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13457. return
  13458. }
  13459. } else {
  13460. var result string
  13461. var requestLog string
  13462. if miConfig.MdtrtareaAdmvs == "440781" { //
  13463. 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)
  13464. } else {
  13465. if miConfig.Code == "H15049901371" {
  13466. //赤峰地区国家医保医疗类别
  13467. //职工透析:医疗类别选特殊情况门诊990502
  13468. //居民定额血透门慢: 医疗类别选门诊慢病140104
  13469. var med_type string
  13470. if his.Insutype == "390" {
  13471. if reg_type == 14 {
  13472. med_type = "9933"
  13473. } else if reg_type == 11 {
  13474. med_type = "11"
  13475. }
  13476. } else if his.Insutype == "310" {
  13477. if reg_type == 14 {
  13478. med_type = "990502"
  13479. } else if reg_type == 11 {
  13480. med_type = "11"
  13481. }
  13482. }
  13483. 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)
  13484. } else {
  13485. 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)
  13486. }
  13487. saveLog(result, requestLog, "2203", "上传就诊信息")
  13488. var respJSON2 map[string]interface{}
  13489. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13492. return
  13493. }
  13494. userJSONBytes2, _ := json.Marshal(respJSON2)
  13495. if miConfig.Code == "H15049901371" {
  13496. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  13497. utils.ErrorLog("解析失败:%v", err)
  13498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13499. return
  13500. }
  13501. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13502. res2.Output = resSix10265.Output
  13503. res2.ErrMsg = resSix10265.ErrMsg
  13504. res2.Cainfo = resSix10265.Cainfo
  13505. res2.WarnMsg = resSix10265.WarnMsg
  13506. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13507. res2.Infcode = infocode
  13508. } else {
  13509. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13510. utils.ErrorLog("解析失败:%v", err)
  13511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13512. return
  13513. }
  13514. }
  13515. }
  13516. }
  13517. if res2.Infcode != 0 {
  13518. adminUser := c.GetAdminUserInfo()
  13519. errlog := &models.HisOrderError{
  13520. UserOrgId: adminUser.CurrentOrgId,
  13521. Ctime: time.Now().Unix(),
  13522. Mtime: time.Now().Unix(),
  13523. ErrMsg: res2.ErrMsg,
  13524. Status: 1,
  13525. PatientId: id,
  13526. RecordTime: recordDateTime,
  13527. Stage: 3,
  13528. }
  13529. service.CreateErrMsgLog(errlog)
  13530. c.ServeSuccessJSON(map[string]interface{}{
  13531. "failed_code": -10,
  13532. "msg": res2.ErrMsg,
  13533. })
  13534. return
  13535. } else {
  13536. his.Diagnosis = diagnosis_id
  13537. his.SickType = sickConfig.ID
  13538. his.PType = fmt.Sprintf("%d", reg_type)
  13539. service.UpdateHisPatientThree(&his)
  13540. data := make(map[string]interface{})
  13541. if settle_accounts_type == 1 { //日结
  13542. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  13543. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  13544. } else {
  13545. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  13546. }
  13547. data["pre"] = prescriptions
  13548. } else { //月结
  13549. start_time_str := c.GetString("start_time")
  13550. end_time_str := c.GetString("end_time")
  13551. timeLayout := "2006-01-02"
  13552. loc, _ := time.LoadLocation("Local")
  13553. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  13554. if err != nil {
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13556. return
  13557. }
  13558. recordStartTime := theStartTime.Unix()
  13559. start_time = recordStartTime
  13560. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  13561. if err != nil {
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13563. return
  13564. }
  13565. recordEndTime := theEndTime.Unix()
  13566. end_time = recordEndTime
  13567. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  13568. data["pre"] = prescriptions
  13569. }
  13570. client := &http.Client{}
  13571. data["psn_no"] = his.PsnNo
  13572. data["mdtrt_id"] = his.Number
  13573. data["chrg_bchno"] = chrg_bchno
  13574. data["org_name"] = miConfig.OrgName
  13575. data["doctor"] = doctor_info.UserName
  13576. data["doctor_id"] = doctor_info.DoctorNumber
  13577. data["dept"] = department.Name
  13578. data["fixmedins_code"] = miConfig.Code
  13579. data["opter"] = roles.UserName
  13580. data["dept_code"] = department.Number
  13581. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13582. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13583. data["secret_key"] = miConfig.SecretKey
  13584. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  13585. data["url"] = miConfig.Url
  13586. data["ak"] = miConfig.AccessKey
  13587. data["new_doctor_name"] = patientPrescription.Doctor
  13588. data["diag_code"] = sickConfig.CountryCode
  13589. data["cainfo"] = miConfig.Cainfo
  13590. data["opter"] = roles.UserName
  13591. var ids []int64
  13592. for _, item := range prescriptions {
  13593. ids = append(ids, item.ID)
  13594. }
  13595. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13596. if config.IsOpen == 1 { //对接了医保,走医保流程
  13597. var res ResultFour
  13598. var resFour10265 ResultFour10265
  13599. if miConfig.MdtrtareaAdmvs == "421300" {
  13600. bytesData, _ := json.Marshal(data)
  13601. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  13602. resp, _ := client.Do(req)
  13603. defer resp.Body.Close()
  13604. body, ioErr := ioutil.ReadAll(resp.Body)
  13605. if ioErr != nil {
  13606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13608. return
  13609. }
  13610. var respJSON map[string]interface{}
  13611. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13614. return
  13615. }
  13616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13617. userJSONBytes, _ := json.Marshal(respJSON)
  13618. fmt.Println("log")
  13619. fmt.Println(string(userJSONBytes))
  13620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13621. utils.ErrorLog("解析失败:%v", err)
  13622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13623. return
  13624. }
  13625. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13626. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  13627. if result3101.Infcode == "0" {
  13628. if len(result3101.Output.Result) > 0 {
  13629. var errMsgs []string
  13630. for _, item := range result3101.Output.Result {
  13631. errMsgs = append(errMsgs, item.VolaCont)
  13632. }
  13633. c.ServeSuccessJSON(map[string]interface{}{
  13634. "failed_code": -10,
  13635. "msg": errMsgs,
  13636. })
  13637. return
  13638. } else {
  13639. if miConfig.MdtrtareaAdmvs == "320921" {
  13640. data["doctor_id"] = "D320923012139"
  13641. } else {
  13642. data["doctor_id"] = "D371621008686"
  13643. }
  13644. bytesData, _ := json.Marshal(data)
  13645. var req *http.Request
  13646. if miConfig.MdtrtareaAdmvs == "320921" {
  13647. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13648. } else {
  13649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13650. }
  13651. resp, _ := client.Do(req)
  13652. defer resp.Body.Close()
  13653. body, ioErr := ioutil.ReadAll(resp.Body)
  13654. if ioErr != nil {
  13655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13657. return
  13658. }
  13659. var respJSON map[string]interface{}
  13660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13663. return
  13664. }
  13665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13666. userJSONBytes, _ := json.Marshal(respJSON)
  13667. fmt.Println("log")
  13668. fmt.Println(string(userJSONBytes))
  13669. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13670. utils.ErrorLog("解析失败:%v", err)
  13671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13672. return
  13673. }
  13674. res.InfRefmsgid = resFour10265.InfRefmsgid
  13675. res.Output = resFour10265.Output
  13676. res.ErrMsg = resFour10265.ErrMsg
  13677. res.Cainfo = resFour10265.Cainfo
  13678. res.WarnMsg = resFour10265.WarnMsg
  13679. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13680. res.Infcode = infocode
  13681. }
  13682. }
  13683. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13684. data["doctor_id"] = doctor_info.DoctorNumber
  13685. bytesData, _ := json.Marshal(data)
  13686. var req *http.Request
  13687. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  13688. resp, _ := client.Do(req)
  13689. defer resp.Body.Close()
  13690. body, ioErr := ioutil.ReadAll(resp.Body)
  13691. if ioErr != nil {
  13692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13694. return
  13695. }
  13696. var respJSON map[string]interface{}
  13697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13700. return
  13701. }
  13702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13703. userJSONBytes, _ := json.Marshal(respJSON)
  13704. fmt.Println("log")
  13705. fmt.Println(string(userJSONBytes))
  13706. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13707. utils.ErrorLog("解析失败:%v", err)
  13708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13709. return
  13710. }
  13711. res.InfRefmsgid = resFour10265.InfRefmsgid
  13712. res.Output = resFour10265.Output
  13713. res.ErrMsg = resFour10265.ErrMsg
  13714. res.Cainfo = resFour10265.Cainfo
  13715. res.WarnMsg = resFour10265.WarnMsg
  13716. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13717. res.Infcode = infocode
  13718. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13719. 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)
  13720. var dat map[string]interface{}
  13721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13722. fmt.Println(dat)
  13723. } else {
  13724. fmt.Println(err)
  13725. }
  13726. saveLog(result, request_log, "2204", "上传费用明细")
  13727. userJSONBytes, _ := json.Marshal(dat)
  13728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13729. utils.ErrorLog("解析失败:%v", err)
  13730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13731. return
  13732. }
  13733. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13734. 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, "", "")
  13735. var dat map[string]interface{}
  13736. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13737. fmt.Println(dat)
  13738. } else {
  13739. fmt.Println(err)
  13740. }
  13741. saveLog(result, request_log, "2204", "上传费用明细")
  13742. userJSONBytes, _ := json.Marshal(dat)
  13743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13744. utils.ErrorLog("解析失败:%v", err)
  13745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13746. return
  13747. }
  13748. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13749. 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, "", "")
  13750. var dat map[string]interface{}
  13751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13752. fmt.Println(dat)
  13753. } else {
  13754. fmt.Println(err)
  13755. }
  13756. saveLog(result, request_log, "2204", "上传费用明细")
  13757. userJSONBytes, _ := json.Marshal(dat)
  13758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13759. utils.ErrorLog("解析失败:%v", err)
  13760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13761. return
  13762. }
  13763. } else {
  13764. if miConfig.Code == "H15049901371" {
  13765. 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)
  13766. var dat map[string]interface{}
  13767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13768. fmt.Println(dat)
  13769. } else {
  13770. fmt.Println(err)
  13771. }
  13772. saveLog(result, request_log, "2204", "上传费用明细")
  13773. userJSONBytes, _ := json.Marshal(dat)
  13774. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13775. utils.ErrorLog("解析失败:%v", err)
  13776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13777. return
  13778. }
  13779. res.InfRefmsgid = resFour10265.InfRefmsgid
  13780. res.Output = resFour10265.Output
  13781. res.ErrMsg = resFour10265.ErrMsg
  13782. res.Cainfo = resFour10265.Cainfo
  13783. res.WarnMsg = resFour10265.WarnMsg
  13784. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13785. res.Infcode = infocode
  13786. } else {
  13787. 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)
  13788. var dat map[string]interface{}
  13789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13790. fmt.Println(dat)
  13791. } else {
  13792. fmt.Println(err)
  13793. }
  13794. saveLog(result, request_log, "2204", "上传费用明细")
  13795. userJSONBytes, _ := json.Marshal(dat)
  13796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13797. utils.ErrorLog("解析失败:%v", err)
  13798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13799. return
  13800. }
  13801. }
  13802. }
  13803. var total_two float64
  13804. if res.Infcode == 0 {
  13805. order := &models.HisOrder{
  13806. UserOrgId: adminUser.CurrentOrgId,
  13807. HisPatientId: his.ID,
  13808. PatientId: his.PatientId,
  13809. SettleAccountsDate: recordDateTime,
  13810. Ctime: time.Now().Unix(),
  13811. Mtime: time.Now().Unix(),
  13812. MdtrtId: his.Number,
  13813. PsnNo: his.PsnNo,
  13814. MedType: strconv.FormatInt(reg_type, 10),
  13815. Status: 1,
  13816. Number: chrg_bchno,
  13817. Infcode: res.Infcode,
  13818. WarnMsg: res.WarnMsg,
  13819. Cainfo: res.Cainfo,
  13820. ErrMsg: res.ErrMsg,
  13821. RespondTime: res.RefmsgTime,
  13822. InfRefmsgid: res.InfRefmsgid,
  13823. OrderStatus: 1,
  13824. IsMedicineInsurance: 1,
  13825. SettleType: settle_accounts_type,
  13826. SettleStartTime: start_time,
  13827. SettleEndTime: end_time,
  13828. Creator: roles.AdminUserId,
  13829. Modify: roles.AdminUserId,
  13830. PType: 2,
  13831. Diagnosis: diagnosis_id,
  13832. }
  13833. err = service.CreateOrder(order)
  13834. if err != nil {
  13835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  13836. return
  13837. }
  13838. for _, item := range res.Output.Result {
  13839. temp := strings.Split(item.FeedetlSn, "-")
  13840. var advice_id int64 = 0
  13841. var project_id int64 = 0
  13842. var types int64 = 0
  13843. id, _ := strconv.ParseInt(temp[2], 10, 64)
  13844. types, _ = strconv.ParseInt(temp[1], 10, 64)
  13845. if temp[1] == "1" {
  13846. advice_id = id
  13847. project_id = 0
  13848. } else if temp[1] == "2" {
  13849. advice_id = 0
  13850. project_id = id
  13851. }
  13852. total_two = total_two + item.DetItemFeeSumamt
  13853. info := &models.HisOrderInfo{
  13854. OrderNumber: order.Number,
  13855. FeedetlSn: item.FeedetlSn,
  13856. UploadDate: time.Now().Unix(),
  13857. AdviceId: advice_id,
  13858. DetItemFeeSumamt: item.DetItemFeeSumamt,
  13859. Cnt: item.Cnt,
  13860. Pric: float64(item.Pric),
  13861. PatientId: his.PatientId,
  13862. PricUplmtAmt: item.PricUplmtAmt,
  13863. SelfpayProp: item.SelfpayProp,
  13864. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  13865. OverlmtAmt: item.OverlmtAmt,
  13866. PreselfpayAmt: item.PreselfpayAmt,
  13867. BasMednFlag: item.BasMednFlag,
  13868. MedChrgitmType: item.MedChrgitmType,
  13869. HiNegoDrugFlag: item.HiNegoDrugFlag,
  13870. Status: 1,
  13871. Memo: item.Memo,
  13872. Mtime: time.Now().Unix(),
  13873. InscpScpAmt: item.InscpScpAmt,
  13874. DrtReimFlag: item.DrtReimFlag,
  13875. Ctime: time.Now().Unix(),
  13876. ListSpItemFlag: item.ListSpItemFlag,
  13877. ChldMedcFlag: item.ChldMedcFlag,
  13878. LmtUsedFlag: item.LmtUsedFlag,
  13879. ChrgitmLv: item.ChrgitmLv,
  13880. UserOrgId: adminUser.CurrentOrgId,
  13881. HisPatientId: his.ID,
  13882. OrderId: order.ID,
  13883. ProjectId: project_id,
  13884. Type: types,
  13885. }
  13886. service.CreateOrderInfo(info)
  13887. }
  13888. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13889. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  13890. var total float64
  13891. for _, item := range prescriptions {
  13892. if item.Type == 1 { //药品
  13893. for _, subItem := range item.HisDoctorAdviceInfo {
  13894. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  13895. total_one := price * subItem.PrescribingNumber
  13896. fmt.Println("subItem")
  13897. fmt.Println(subItem.Price)
  13898. fmt.Println("price")
  13899. fmt.Println(price)
  13900. fmt.Println("total_one")
  13901. fmt.Println(total_one)
  13902. total = total + total_one
  13903. fmt.Println(total)
  13904. }
  13905. }
  13906. if item.Type == 2 { //项目
  13907. for _, subItem := range item.HisPrescriptionProject {
  13908. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  13909. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  13910. total_one := price * cnt
  13911. total = total + total_one
  13912. }
  13913. }
  13914. }
  13915. allTotal := fmt.Sprintf("%2f", total)
  13916. if res.Infcode == 0 {
  13917. var rf []*ResultFive
  13918. json.Unmarshal([]byte(his.Iinfo), &rf)
  13919. chrg_bchno := chrg_bchno
  13920. cert_no := his.Certno
  13921. var insutypes []string
  13922. var insutype string
  13923. var is390 int = 0
  13924. var is310 int = 0
  13925. for _, item := range rf {
  13926. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13927. insutypes = append(insutypes, item.Insutype)
  13928. }
  13929. }
  13930. if len(insutypes) == 1 {
  13931. insutype = insutypes[0]
  13932. } else {
  13933. for _, i := range insutypes {
  13934. if i == "390" {
  13935. is390 = 1
  13936. }
  13937. if i == "310" {
  13938. is310 = 1
  13939. }
  13940. }
  13941. }
  13942. if is390 == 1 {
  13943. insutype = "390"
  13944. }
  13945. if is310 == 1 {
  13946. insutype = "310"
  13947. }
  13948. if len(insutypes) == 0 {
  13949. insutype = "390"
  13950. }
  13951. if len(insutypes) == 2 {
  13952. insutype = strconv.FormatInt(his.SocialType, 10)
  13953. }
  13954. //insutype = "390"
  13955. if his.IdCardType == 1 {
  13956. cert_no = his.MedicalInsuranceNumber
  13957. } else {
  13958. cert_no = his.Certno
  13959. }
  13960. var res ResultSeven
  13961. var resSeven10265 ResultSeven10265
  13962. var resSeven10265Two ResultSeven10265Two
  13963. if miConfig.MdtrtareaAdmvs == "421300" {
  13964. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  13965. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  13966. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13968. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  13969. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  13970. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  13971. resp, requestErr := http.Get(api)
  13972. if requestErr != nil {
  13973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13974. return
  13975. }
  13976. body, ioErr := ioutil.ReadAll(resp.Body)
  13977. if ioErr != nil {
  13978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13980. return
  13981. }
  13982. var respJSON map[string]interface{}
  13983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13986. return
  13987. }
  13988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13989. result, _ := json.Marshal(respJSON)
  13990. fmt.Println("log")
  13991. fmt.Println(string(result))
  13992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13993. utils.ErrorLog("解析失败:%v", err)
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13995. return
  13996. }
  13997. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13998. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  13999. if result3101.Infcode == "0" {
  14000. if len(result3101.Output.Result) > 0 {
  14001. var errMsgs []string
  14002. for _, item := range result3101.Output.Result {
  14003. errMsgs = append(errMsgs, item.VolaCont)
  14004. }
  14005. c.ServeSuccessJSON(map[string]interface{}{
  14006. "failed_code": -10,
  14007. "msg": errMsgs,
  14008. })
  14009. return
  14010. } else {
  14011. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14012. if his.IdCardType != 4 {
  14013. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  14014. bas := strings.Split(psn_info.CardInfo, "|")
  14015. if his.IdCardType == 1 {
  14016. cert_no = bas[2]
  14017. } else {
  14018. cert_no = bas[1]
  14019. }
  14020. } else {
  14021. cert_no = his.Certno
  14022. }
  14023. //江苏地区国家医保医疗类别
  14024. //职工透析:医疗类别选特殊情况门诊9933
  14025. //居民血透门慢: 医疗类别选门诊慢病1402
  14026. //var med_type string
  14027. //if his.Insutype == "310" {
  14028. // if reg_type == 14 {
  14029. // med_type = "9933"
  14030. // } else if reg_type == 11 {
  14031. // med_type = "11"
  14032. //
  14033. // }
  14034. //} else if his.Insutype == "390" {
  14035. // if reg_type == 14 {
  14036. // med_type = "1402"
  14037. // } else if reg_type == 11 {
  14038. // med_type = "11"
  14039. // }
  14040. //}
  14041. var api string
  14042. if miConfig.MdtrtareaAdmvs == "320921" {
  14043. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14044. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14045. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14047. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14048. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14049. "&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
  14050. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14051. } else {
  14052. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14053. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14054. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14055. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14056. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14057. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14058. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14059. "&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
  14060. }
  14061. resp, requestErr := http.Get(api)
  14062. if requestErr != nil {
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14064. return
  14065. }
  14066. body, ioErr := ioutil.ReadAll(resp.Body)
  14067. if ioErr != nil {
  14068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. var respJSON map[string]interface{}
  14073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14076. return
  14077. }
  14078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14079. result, _ := json.Marshal(respJSON)
  14080. fmt.Println("log")
  14081. fmt.Println(string(result))
  14082. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  14083. utils.ErrorLog("解析失败:%v", err)
  14084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14085. return
  14086. }
  14087. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  14088. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  14089. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  14090. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  14091. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14092. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  14093. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  14094. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  14095. res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  14096. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  14097. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  14098. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14099. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  14100. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  14101. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14102. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  14103. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  14104. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  14105. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  14106. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  14107. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  14108. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14109. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  14110. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  14111. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  14112. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  14113. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  14114. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  14115. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  14116. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  14117. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  14118. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  14119. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  14120. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  14121. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  14122. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14123. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  14124. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  14125. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  14126. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14127. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  14128. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  14129. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  14130. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  14131. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  14132. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  14133. res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  14134. res.ErrMsg = resSeven10265Two.ErrMsg
  14135. res.Cainfo = resSeven10265Two.Cainfo
  14136. res.WarnMsg = resSeven10265Two.WarnMsg
  14137. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  14138. res.Infcode = infocode
  14139. }
  14140. }
  14141. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14142. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14143. if his.IdCardType != 4 {
  14144. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  14145. bas := strings.Split(psn_info.CardInfo, "|")
  14146. if his.IdCardType == 1 {
  14147. cert_no = bas[2]
  14148. } else {
  14149. cert_no = bas[1]
  14150. }
  14151. } else {
  14152. cert_no = his.Certno
  14153. }
  14154. var api string
  14155. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14156. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14161. "&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
  14162. resp, requestErr := http.Get(api)
  14163. if requestErr != nil {
  14164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14165. return
  14166. }
  14167. body, ioErr := ioutil.ReadAll(resp.Body)
  14168. if ioErr != nil {
  14169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14171. return
  14172. }
  14173. var respJSON map[string]interface{}
  14174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14177. return
  14178. }
  14179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14180. result, _ := json.Marshal(respJSON)
  14181. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  14182. utils.ErrorLog("解析失败:%v", err)
  14183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14184. return
  14185. }
  14186. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  14187. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  14188. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  14189. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  14190. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14191. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  14192. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  14193. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  14194. res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  14195. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  14196. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  14197. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14198. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  14199. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  14200. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14201. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  14202. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  14203. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  14204. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  14205. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  14206. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  14207. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14208. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  14209. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  14210. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  14211. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  14212. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  14213. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  14214. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  14215. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  14216. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  14217. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  14218. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  14219. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  14220. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  14221. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14222. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  14223. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  14224. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  14225. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14226. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  14227. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  14228. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  14229. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  14230. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  14231. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  14232. res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  14233. res.ErrMsg = resSeven10265Two.ErrMsg
  14234. res.Cainfo = resSeven10265Two.Cainfo
  14235. res.WarnMsg = resSeven10265Two.WarnMsg
  14236. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  14237. res.Infcode = infocode
  14238. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14239. acct_used_flag := "1"
  14240. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  14241. var result string
  14242. var request_log string
  14243. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  14244. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  14245. } else {
  14246. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  14247. }
  14248. var dat map[string]interface{}
  14249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14250. fmt.Println(dat)
  14251. } else {
  14252. fmt.Println(err)
  14253. }
  14254. saveLog(result, request_log, "2206", "预结算")
  14255. userJSONBytes, _ := json.Marshal(dat)
  14256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14257. utils.ErrorLog("解析失败:%v", err)
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14262. var result string
  14263. var request_log string
  14264. if his.IdCardType == 2 {
  14265. 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, "")
  14266. } else if his.IdCardType == 1 {
  14267. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14268. bas := strings.Split(psn_info.CardInfo, "|")
  14269. basNumber := bas[2]
  14270. card_sn := bas[3]
  14271. 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)
  14272. } else {
  14273. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14274. 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, "")
  14275. }
  14276. var dat map[string]interface{}
  14277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14278. fmt.Println(dat)
  14279. } else {
  14280. fmt.Println(err)
  14281. }
  14282. saveLog(result, request_log, "2206", "预结算")
  14283. userJSONBytes, _ := json.Marshal(dat)
  14284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14285. utils.ErrorLog("解析失败:%v", err)
  14286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14287. return
  14288. }
  14289. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14290. var result string
  14291. var request_log string
  14292. if his.IdCardType == 2 {
  14293. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", "1")
  14294. } else if his.IdCardType == 1 {
  14295. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14296. bas := strings.Split(psn_info.CardInfo, "|")
  14297. basNumber := bas[2]
  14298. card_sn := bas[3]
  14299. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "1")
  14300. } else {
  14301. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14302. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "1")
  14303. }
  14304. var dat map[string]interface{}
  14305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14306. fmt.Println(dat)
  14307. } else {
  14308. fmt.Println(err)
  14309. }
  14310. saveLog(result, request_log, "2206", "预结算")
  14311. userJSONBytes, _ := json.Marshal(dat)
  14312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14313. utils.ErrorLog("解析失败:%v", err)
  14314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14315. return
  14316. }
  14317. } else {
  14318. var result string
  14319. var request_log string
  14320. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14321. allTotal = fmt.Sprintf("%2f", total_two)
  14322. if his.IdCardType == 4 {
  14323. 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)
  14324. } else {
  14325. 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)
  14326. }
  14327. var dat map[string]interface{}
  14328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14329. fmt.Println(dat)
  14330. } else {
  14331. fmt.Println(err)
  14332. }
  14333. saveLog(result, request_log, "2206", "预结算")
  14334. //userJSONBytes, _ := json.Marshal(dat)
  14335. //
  14336. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14337. // utils.ErrorLog("解析失败:%v", err)
  14338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14339. // return
  14340. //}
  14341. userJSONBytes, _ := json.Marshal(dat)
  14342. if miConfig.Code == "H15049901371" {
  14343. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  14344. utils.ErrorLog("解析失败:%v", err)
  14345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14346. return
  14347. }
  14348. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14349. res.Output = resSeven10265.Output
  14350. res.ErrMsg = resSeven10265.ErrMsg
  14351. res.Cainfo = resSeven10265.Cainfo
  14352. res.WarnMsg = resSeven10265.WarnMsg
  14353. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14354. res.Infcode = infocode
  14355. } else {
  14356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14357. utils.ErrorLog("解析失败:%v", err)
  14358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14359. return
  14360. }
  14361. }
  14362. }
  14363. if res.Infcode != 0 {
  14364. errlog := &models.HisOrderError{
  14365. UserOrgId: adminUser.CurrentOrgId,
  14366. Ctime: time.Now().Unix(),
  14367. Mtime: time.Now().Unix(),
  14368. Number: chrg_bchno,
  14369. ErrMsg: res.ErrMsg,
  14370. Status: 1,
  14371. PatientId: id,
  14372. RecordTime: recordDateTime,
  14373. Stage: 20,
  14374. }
  14375. service.CreateErrMsgLog(errlog)
  14376. c.ServeSuccessJSON(map[string]interface{}{
  14377. "failed_code": -10,
  14378. "msg": res.ErrMsg,
  14379. })
  14380. return
  14381. } else {
  14382. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  14383. order.OrderStatus = 1
  14384. order.IsPre = 1
  14385. order.Status = 1
  14386. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  14387. order.SetlId = res.Output.Setlinfo.SetlID
  14388. order.PsnNo = res.Output.Setlinfo.PsnNo
  14389. order.PsnName = res.Output.Setlinfo.PsnName
  14390. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  14391. order.Certno = res.Output.Setlinfo.Certno
  14392. order.Gend = res.Output.Setlinfo.Gend
  14393. order.Naty = res.Output.Setlinfo.Naty
  14394. order.Age = res.Output.Setlinfo.Age
  14395. order.Insutype = res.Output.Setlinfo.Insutype
  14396. order.PsnType = res.Output.Setlinfo.PsnType
  14397. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  14398. order.SetlTime = res.Output.Setlinfo.SetlTime
  14399. order.AcctUsedFlag = acct_used_flag
  14400. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  14401. if res.Output.Setlinfo.MedType == "140101" {
  14402. order.MedType = "14"
  14403. } else {
  14404. order.MedType = res.Output.Setlinfo.MedType
  14405. }
  14406. if reg_type == 1112 {
  14407. order.MedType = "1112"
  14408. }
  14409. if reg_type == 1111 {
  14410. order.MedType = "1111"
  14411. }
  14412. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  14413. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  14414. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  14415. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  14416. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  14417. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  14418. order.HifpPay = res.Output.Setlinfo.HifpPay
  14419. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  14420. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  14421. order.HifesPay = res.Output.Setlinfo.HifesPay
  14422. order.HifobPay = res.Output.Setlinfo.HifobPay
  14423. order.MafPay = res.Output.Setlinfo.MafPay
  14424. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  14425. order.OthPay = res.Output.Setlinfo.OthPay
  14426. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  14427. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  14428. order.AcctPay = res.Output.Setlinfo.AcctPay
  14429. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  14430. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  14431. order.Balc = res.Output.Setlinfo.Balc
  14432. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  14433. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  14434. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  14435. order.ClrWay = res.Output.Setlinfo.ClrWay
  14436. order.Creator = order.Creator
  14437. order.Modify = roles.AdminUserId
  14438. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  14439. detailStr := string(setlDetail)
  14440. order.SetlDetail = detailStr
  14441. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  14442. err = service.UpDateOrder(order)
  14443. if err == nil {
  14444. c.ServeSuccessJSON(map[string]interface{}{
  14445. "msg": "预结算成功",
  14446. })
  14447. } else {
  14448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  14449. return
  14450. }
  14451. }
  14452. } else {
  14453. adminUser := c.GetAdminUserInfo()
  14454. errlog := &models.HisOrderError{
  14455. UserOrgId: adminUser.CurrentOrgId,
  14456. Ctime: time.Now().Unix(),
  14457. Mtime: time.Now().Unix(),
  14458. ErrMsg: res.ErrMsg,
  14459. Status: 1,
  14460. PatientId: id,
  14461. RecordTime: recordDateTime,
  14462. Stage: 4,
  14463. }
  14464. service.CreateErrMsgLog(errlog)
  14465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  14466. return
  14467. }
  14468. } else {
  14469. adminUser := c.GetAdminUserInfo()
  14470. errlog := &models.HisOrderError{
  14471. UserOrgId: adminUser.CurrentOrgId,
  14472. Ctime: time.Now().Unix(),
  14473. Mtime: time.Now().Unix(),
  14474. ErrMsg: res.ErrMsg,
  14475. Status: 1,
  14476. PatientId: id,
  14477. RecordTime: recordDateTime,
  14478. Stage: 4,
  14479. }
  14480. service.CreateErrMsgLog(errlog)
  14481. c.ServeSuccessJSON(map[string]interface{}{
  14482. "failed_code": -10,
  14483. "msg": res.ErrMsg,
  14484. })
  14485. return
  14486. }
  14487. }
  14488. }
  14489. }
  14490. // 退款
  14491. func (c *HisApiController) Refund() {
  14492. order_id, _ := c.GetInt64("order_id")
  14493. admin_user_id, _ := c.GetInt64("admin_user_id")
  14494. adminUser := c.GetAdminUserInfo()
  14495. var order models.HisOrder
  14496. order, _ = service.GetHisOrderByID(order_id)
  14497. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14498. if order.ID == 0 {
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14500. return
  14501. }
  14502. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14503. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14504. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14505. if config.IsOpen == 1 { //对接了医保,走医保流程
  14506. var res ResultSixteen
  14507. var resSixteen10265 ResultSixteen10265
  14508. var resSixteen10265Two ResultSixteen10265Two
  14509. var src_resquest string
  14510. var result string
  14511. if miConfig.MdtrtareaAdmvs == "421300" {
  14512. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  14513. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14514. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14515. resp3, requestErr3 := http.Get(api3)
  14516. if requestErr3 != nil {
  14517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14518. return
  14519. }
  14520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14521. if ioErr3 != nil {
  14522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14524. return
  14525. }
  14526. var respJSON3 map[string]interface{}
  14527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14530. return
  14531. }
  14532. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14533. userJSONBytes3, _ := json.Marshal(respJSON3)
  14534. fmt.Println("log")
  14535. fmt.Println(string(userJSONBytes3))
  14536. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  14537. utils.ErrorLog("解析失败:%v", err)
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14539. return
  14540. }
  14541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14542. var api3 string
  14543. if miConfig.MdtrtareaAdmvs == "320921" {
  14544. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  14545. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14547. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14548. } else {
  14549. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14550. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  14551. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14553. }
  14554. resp3, requestErr3 := http.Get(api3)
  14555. if requestErr3 != nil {
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14560. if ioErr3 != nil {
  14561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14563. return
  14564. }
  14565. var respJSON3 map[string]interface{}
  14566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14569. return
  14570. }
  14571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14572. userJSONBytes3, _ := json.Marshal(respJSON3)
  14573. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  14574. utils.ErrorLog("解析失败:%v", err)
  14575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14576. return
  14577. }
  14578. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14579. res.Output = resSixteen10265.Output
  14580. res.ErrMsg = resSixteen10265.ErrMsg
  14581. res.Cainfo = resSixteen10265.Cainfo
  14582. res.WarnMsg = resSixteen10265.WarnMsg
  14583. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14584. res.Infcode = infocode
  14585. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14586. var api3 string
  14587. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  14588. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14589. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14590. resp3, requestErr3 := http.Get(api3)
  14591. if requestErr3 != nil {
  14592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14593. return
  14594. }
  14595. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14596. if ioErr3 != nil {
  14597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. var respJSON3 map[string]interface{}
  14602. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14605. return
  14606. }
  14607. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14608. userJSONBytes3, _ := json.Marshal(respJSON3)
  14609. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  14610. utils.ErrorLog("解析失败:%v", err)
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14612. return
  14613. }
  14614. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14615. res.Output = resSixteen10265.Output
  14616. res.ErrMsg = resSixteen10265.ErrMsg
  14617. res.Cainfo = resSixteen10265.Cainfo
  14618. res.WarnMsg = resSixteen10265.WarnMsg
  14619. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14620. res.Infcode = infocode
  14621. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14622. 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)
  14623. var dat map[string]interface{}
  14624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14625. fmt.Println(dat)
  14626. } else {
  14627. fmt.Println(err)
  14628. }
  14629. saveLog(result, src_resquest, "2208", "退费")
  14630. userJSONBytes, _ := json.Marshal(dat)
  14631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14632. utils.ErrorLog("解析失败:%v", err)
  14633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14634. return
  14635. }
  14636. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14637. 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, "")
  14638. var dat map[string]interface{}
  14639. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14640. fmt.Println(dat)
  14641. } else {
  14642. fmt.Println(err)
  14643. }
  14644. saveLog(result, src_resquest, "2208", "退费")
  14645. userJSONBytes, _ := json.Marshal(dat)
  14646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14647. utils.ErrorLog("解析失败:%v", err)
  14648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14649. return
  14650. }
  14651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14652. 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, "")
  14653. var dat map[string]interface{}
  14654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14655. fmt.Println(dat)
  14656. } else {
  14657. fmt.Println(err)
  14658. }
  14659. saveLog(result, src_resquest, "2208", "退费")
  14660. userJSONBytes, _ := json.Marshal(dat)
  14661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14662. utils.ErrorLog("解析失败:%v", err)
  14663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14664. return
  14665. }
  14666. } else {
  14667. if miConfig.Code == "H15049901371" {
  14668. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  14669. var dat map[string]interface{}
  14670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14671. fmt.Println(dat)
  14672. } else {
  14673. fmt.Println(err)
  14674. }
  14675. saveLog(result, src_resquest, "2208", "退费")
  14676. userJSONBytes, _ := json.Marshal(dat)
  14677. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  14678. utils.ErrorLog("解析失败:%v", err)
  14679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14680. return
  14681. }
  14682. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14683. res.Output = resSixteen10265.Output
  14684. res.ErrMsg = resSixteen10265.ErrMsg
  14685. res.Cainfo = resSixteen10265.Cainfo
  14686. res.WarnMsg = resSixteen10265.WarnMsg
  14687. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14688. res.Infcode = infocode
  14689. } else {
  14690. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  14691. var dat map[string]interface{}
  14692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14693. fmt.Println(dat)
  14694. } else {
  14695. fmt.Println(err)
  14696. }
  14697. saveLog(result, src_resquest, "2208", "退费")
  14698. userJSONBytes, _ := json.Marshal(dat)
  14699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14700. utils.ErrorLog("解析失败:%v", err)
  14701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14702. return
  14703. }
  14704. }
  14705. }
  14706. if res.Infcode == 0 {
  14707. var res2 ResultSix
  14708. var resSix10265 ResultSix10265
  14709. if miConfig.MdtrtareaAdmvs == "421300" {
  14710. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  14711. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14713. resp3, requestErr3 := http.Get(api3)
  14714. if requestErr3 != nil {
  14715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14716. return
  14717. }
  14718. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14719. if ioErr3 != nil {
  14720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14722. return
  14723. }
  14724. var respJSON3 map[string]interface{}
  14725. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14728. return
  14729. }
  14730. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14731. userJSONBytes3, _ := json.Marshal(respJSON3)
  14732. fmt.Println("log")
  14733. fmt.Println(string(userJSONBytes3))
  14734. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  14735. utils.ErrorLog("解析失败:%v", err)
  14736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14737. return
  14738. }
  14739. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14740. var api3 string
  14741. if miConfig.MdtrtareaAdmvs == "320921" {
  14742. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14743. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14745. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14746. } else {
  14747. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14748. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  14749. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14751. }
  14752. resp3, requestErr3 := http.Get(api3)
  14753. if requestErr3 != nil {
  14754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14755. return
  14756. }
  14757. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14758. if ioErr3 != nil {
  14759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14761. return
  14762. }
  14763. var respJSON3 map[string]interface{}
  14764. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14767. return
  14768. }
  14769. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14770. userJSONBytes3, _ := json.Marshal(respJSON3)
  14771. fmt.Println("log")
  14772. fmt.Println(string(userJSONBytes3))
  14773. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  14774. utils.ErrorLog("解析失败:%v", err)
  14775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14776. return
  14777. }
  14778. res2.InfRefmsgid = resSix10265.InfRefmsgid
  14779. res2.Output = resSix10265.Output
  14780. res2.ErrMsg = resSix10265.ErrMsg
  14781. res2.Cainfo = resSix10265.Cainfo
  14782. res2.WarnMsg = resSix10265.WarnMsg
  14783. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14784. res2.Infcode = infocode
  14785. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14786. var api3 string
  14787. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  14788. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14790. resp3, requestErr3 := http.Get(api3)
  14791. if requestErr3 != nil {
  14792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14793. return
  14794. }
  14795. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14796. if ioErr3 != nil {
  14797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14799. return
  14800. }
  14801. var respJSON3 map[string]interface{}
  14802. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14805. return
  14806. }
  14807. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14808. userJSONBytes3, _ := json.Marshal(respJSON3)
  14809. fmt.Println("log")
  14810. fmt.Println(string(userJSONBytes3))
  14811. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  14812. utils.ErrorLog("解析失败:%v", err)
  14813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14814. return
  14815. }
  14816. res2.InfRefmsgid = resSix10265.InfRefmsgid
  14817. res2.Output = resSix10265.Output
  14818. res2.ErrMsg = resSix10265.ErrMsg
  14819. res2.Cainfo = resSix10265.Cainfo
  14820. res2.WarnMsg = resSix10265.WarnMsg
  14821. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14822. res2.Infcode = infocode
  14823. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14824. 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)
  14825. var dat map[string]interface{}
  14826. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14827. fmt.Println(dat)
  14828. } else {
  14829. fmt.Println(err)
  14830. }
  14831. saveLog(result2, src_request, "2205", "撤销明细")
  14832. userJSONBytes, _ := json.Marshal(dat)
  14833. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14834. utils.ErrorLog("解析失败:%v", err)
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14836. return
  14837. }
  14838. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14839. 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, "")
  14840. var dat map[string]interface{}
  14841. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14842. fmt.Println(dat)
  14843. } else {
  14844. fmt.Println(err)
  14845. }
  14846. saveLog(result2, src_request, "2205", "撤销明细")
  14847. userJSONBytes, _ := json.Marshal(dat)
  14848. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14849. utils.ErrorLog("解析失败:%v", err)
  14850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14851. return
  14852. }
  14853. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14854. 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, "")
  14855. var dat map[string]interface{}
  14856. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14857. fmt.Println(dat)
  14858. } else {
  14859. fmt.Println(err)
  14860. }
  14861. saveLog(result2, src_request, "2205", "撤销明细")
  14862. userJSONBytes, _ := json.Marshal(dat)
  14863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14864. utils.ErrorLog("解析失败:%v", err)
  14865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14866. return
  14867. }
  14868. } else {
  14869. if miConfig.Code == "H15049901371" {
  14870. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  14871. var dat map[string]interface{}
  14872. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14873. fmt.Println(dat)
  14874. } else {
  14875. fmt.Println(err)
  14876. }
  14877. saveLog(result2, src_request, "2205", "撤销明细")
  14878. userJSONBytes, _ := json.Marshal(dat)
  14879. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  14880. utils.ErrorLog("解析失败:%v", err)
  14881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14882. return
  14883. }
  14884. res2.InfRefmsgid = resSix10265.InfRefmsgid
  14885. res2.Output = resSix10265.Output
  14886. res2.ErrMsg = resSix10265.ErrMsg
  14887. res2.Cainfo = resSix10265.Cainfo
  14888. res2.WarnMsg = resSix10265.WarnMsg
  14889. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14890. res2.Infcode = infocode
  14891. } else {
  14892. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  14893. var dat map[string]interface{}
  14894. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14895. fmt.Println(dat)
  14896. } else {
  14897. fmt.Println(err)
  14898. }
  14899. saveLog(result2, src_request, "2205", "撤销明细")
  14900. userJSONBytes, _ := json.Marshal(dat)
  14901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14902. utils.ErrorLog("解析失败:%v", err)
  14903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14904. return
  14905. }
  14906. }
  14907. }
  14908. if res2.Infcode == 0 {
  14909. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  14910. if err == nil {
  14911. //当押金不为零时产生退费记录
  14912. if order.Decimal != 0 {
  14913. tmp := strconv.FormatInt(order.ID, 10)
  14914. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  14915. if err != nil {
  14916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14917. return
  14918. }
  14919. }
  14920. c.ServeSuccessJSON(map[string]interface{}{
  14921. "msg": "退费成功",
  14922. })
  14923. } else {
  14924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14925. return
  14926. }
  14927. } else {
  14928. c.ServeSuccessJSON(map[string]interface{}{
  14929. "code": -10,
  14930. "msg": res2.ErrMsg,
  14931. })
  14932. }
  14933. } else {
  14934. c.ServeSuccessJSON(map[string]interface{}{
  14935. "code": -10,
  14936. "msg": res.ErrMsg,
  14937. })
  14938. }
  14939. }
  14940. }
  14941. func (c *HisApiController) RefundNumber() {
  14942. record_time := c.GetString("record_time")
  14943. //patient_id, _ := c.GetInt64("patient_id")
  14944. admin_user_id, _ := c.GetInt64("admin_user_id")
  14945. his_patient_id, _ := c.GetInt64("id")
  14946. timeLayout := "2006-01-02"
  14947. loc, _ := time.LoadLocation("Local")
  14948. adminUser := c.GetAdminUserInfo()
  14949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14950. fmt.Println(err)
  14951. if err != nil {
  14952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14953. return
  14954. }
  14955. recordDateTime := theTime.Unix()
  14956. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  14957. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  14958. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  14959. //order, _ := service.GetHisOrderByID(order_id)
  14960. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14961. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14962. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14963. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  14964. if count > 0 {
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  14966. return
  14967. }
  14968. if config.IsOpen == 1 { //对接了医保,走医保流程
  14969. var res2 ResultSix
  14970. var resSix10265 ResultSix10265
  14971. if miConfig.MdtrtareaAdmvs == "421300" {
  14972. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  14973. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14975. resp3, requestErr3 := http.Get(api3)
  14976. if requestErr3 != nil {
  14977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14978. return
  14979. }
  14980. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14981. if ioErr3 != nil {
  14982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14984. return
  14985. }
  14986. var respJSON3 map[string]interface{}
  14987. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14990. return
  14991. }
  14992. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14993. userJSONBytes3, _ := json.Marshal(respJSON3)
  14994. fmt.Println("log")
  14995. fmt.Println(string(userJSONBytes3))
  14996. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  14997. utils.ErrorLog("解析失败:%v", err)
  14998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14999. return
  15000. }
  15001. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15002. var api3 string
  15003. if miConfig.MdtrtareaAdmvs == "320921" {
  15004. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  15005. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15006. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15007. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15008. } else {
  15009. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15010. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  15011. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15012. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15013. }
  15014. resp3, requestErr3 := http.Get(api3)
  15015. if requestErr3 != nil {
  15016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15017. return
  15018. }
  15019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15020. if ioErr3 != nil {
  15021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15023. return
  15024. }
  15025. var respJSON3 map[string]interface{}
  15026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15029. return
  15030. }
  15031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15032. userJSONBytes3, _ := json.Marshal(respJSON3)
  15033. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15034. utils.ErrorLog("解析失败:%v", err)
  15035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15036. return
  15037. }
  15038. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15039. res2.Output = resSix10265.Output
  15040. res2.ErrMsg = resSix10265.ErrMsg
  15041. res2.Cainfo = resSix10265.Cainfo
  15042. res2.WarnMsg = resSix10265.WarnMsg
  15043. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15044. res2.Infcode = infocode
  15045. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15046. var api3 string
  15047. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  15048. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15049. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15050. resp3, requestErr3 := http.Get(api3)
  15051. if requestErr3 != nil {
  15052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15053. return
  15054. }
  15055. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15056. if ioErr3 != nil {
  15057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15059. return
  15060. }
  15061. var respJSON3 map[string]interface{}
  15062. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15065. return
  15066. }
  15067. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15068. userJSONBytes3, _ := json.Marshal(respJSON3)
  15069. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15070. utils.ErrorLog("解析失败:%v", err)
  15071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15072. return
  15073. }
  15074. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15075. res2.Output = resSix10265.Output
  15076. res2.ErrMsg = resSix10265.ErrMsg
  15077. res2.Cainfo = resSix10265.Cainfo
  15078. res2.WarnMsg = resSix10265.WarnMsg
  15079. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15080. res2.Infcode = infocode
  15081. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15082. 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)
  15083. var dat map[string]interface{}
  15084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15085. fmt.Println(dat)
  15086. } else {
  15087. fmt.Println(err)
  15088. }
  15089. saveLog(result, request, "2202", "退号")
  15090. userJSONBytes, _ := json.Marshal(dat)
  15091. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15092. utils.ErrorLog("解析失败:%v", err)
  15093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15094. return
  15095. }
  15096. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15097. 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, "")
  15098. var dat map[string]interface{}
  15099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15100. fmt.Println(dat)
  15101. } else {
  15102. fmt.Println(err)
  15103. }
  15104. saveLog(result, request, "2202", "退号")
  15105. userJSONBytes, _ := json.Marshal(dat)
  15106. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15107. utils.ErrorLog("解析失败:%v", err)
  15108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15109. return
  15110. }
  15111. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15112. 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, "")
  15113. var dat map[string]interface{}
  15114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15115. fmt.Println(dat)
  15116. } else {
  15117. fmt.Println(err)
  15118. }
  15119. saveLog(result, request, "2202", "退号")
  15120. userJSONBytes, _ := json.Marshal(dat)
  15121. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15122. utils.ErrorLog("解析失败:%v", err)
  15123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15124. return
  15125. }
  15126. } else {
  15127. var api3 string
  15128. if miConfig.Code == "H15049901371" {
  15129. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  15130. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15132. } else {
  15133. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  15134. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15135. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15136. }
  15137. resp3, requestErr3 := http.Get(api3)
  15138. if requestErr3 != nil {
  15139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15140. return
  15141. }
  15142. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15143. if ioErr3 != nil {
  15144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. return
  15147. }
  15148. var respJSON3 map[string]interface{}
  15149. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15155. userJSONBytes3, _ := json.Marshal(respJSON3)
  15156. if miConfig.Code == "H15049901371" {
  15157. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15158. utils.ErrorLog("解析失败:%v", err)
  15159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15160. return
  15161. }
  15162. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15163. res2.Output = resSix10265.Output
  15164. res2.ErrMsg = resSix10265.ErrMsg
  15165. res2.Cainfo = resSix10265.Cainfo
  15166. res2.WarnMsg = resSix10265.WarnMsg
  15167. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15168. res2.Infcode = infocode
  15169. } else {
  15170. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15171. utils.ErrorLog("解析失败:%v", err)
  15172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15173. return
  15174. }
  15175. }
  15176. }
  15177. if res2.Infcode == 0 {
  15178. if err == nil {
  15179. c.ServeSuccessJSON(map[string]interface{}{
  15180. "msg": "退号成功",
  15181. })
  15182. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  15183. } else {
  15184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15185. return
  15186. }
  15187. } else {
  15188. c.ServeSuccessJSON(map[string]interface{}{
  15189. "code": -10,
  15190. "msg": res2.ErrMsg,
  15191. })
  15192. }
  15193. } else {
  15194. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  15195. //if err == nil {
  15196. // c.ServeSuccessJSON(map[string]interface{}{
  15197. // "msg": "退费成功",
  15198. // })
  15199. //} else {
  15200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15201. // return
  15202. //}
  15203. }
  15204. }
  15205. func (c *HisApiController) RefundDetail() {
  15206. order_id, _ := c.GetInt64("order_id")
  15207. admin_user_id, _ := c.GetInt64("admin_user_id")
  15208. //his_patient_id, _ := c.GetInt64("his_patient_id")
  15209. number := c.GetString("number")
  15210. record_time := c.GetString("record_time")
  15211. patient_id, _ := c.GetInt64("patient_id")
  15212. //med_type, _ := c.GetInt64("med_type")
  15213. timeLayout := "2006-01-02"
  15214. loc, _ := time.LoadLocation("Local")
  15215. adminUser := c.GetAdminUserInfo()
  15216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15217. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15218. fmt.Println(err)
  15219. if err != nil {
  15220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15221. return
  15222. }
  15223. recordDateTime := theTime.Unix()
  15224. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  15225. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  15226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15228. var order models.HisOrder
  15229. order, _ = service.GetHisOrderByID(order_id)
  15230. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15231. if config.IsOpen == 1 { //对接了医保,走医保流程
  15232. var res2 ResultSix
  15233. if miConfig.MdtrtareaAdmvs == "421300" {
  15234. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  15235. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15236. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15237. resp3, requestErr3 := http.Get(api3)
  15238. if requestErr3 != nil {
  15239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15240. return
  15241. }
  15242. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15243. if ioErr3 != nil {
  15244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15246. return
  15247. }
  15248. var respJSON3 map[string]interface{}
  15249. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15252. return
  15253. }
  15254. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15255. userJSONBytes3, _ := json.Marshal(respJSON3)
  15256. fmt.Println("log")
  15257. fmt.Println(string(userJSONBytes3))
  15258. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15259. utils.ErrorLog("解析失败:%v", err)
  15260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15261. return
  15262. }
  15263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15264. if err == nil {
  15265. c.ServeSuccessJSON(map[string]interface{}{
  15266. "msg": "撤销明细成功",
  15267. })
  15268. return
  15269. } else {
  15270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15271. return
  15272. }
  15273. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15274. var resSix10265 ResultSix10265
  15275. var api3 string
  15276. if miConfig.MdtrtareaAdmvs == "320921" {
  15277. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15278. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15280. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15281. } else {
  15282. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15283. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15286. }
  15287. resp3, requestErr3 := http.Get(api3)
  15288. if requestErr3 != nil {
  15289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15290. return
  15291. }
  15292. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15293. if ioErr3 != nil {
  15294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15296. return
  15297. }
  15298. var respJSON3 map[string]interface{}
  15299. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15302. return
  15303. }
  15304. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15305. userJSONBytes3, _ := json.Marshal(respJSON3)
  15306. fmt.Println("log")
  15307. fmt.Println(string(userJSONBytes3))
  15308. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15309. utils.ErrorLog("解析失败:%v", err)
  15310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15311. return
  15312. }
  15313. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15314. res2.Output = resSix10265.Output
  15315. res2.ErrMsg = resSix10265.ErrMsg
  15316. res2.Cainfo = resSix10265.Cainfo
  15317. res2.WarnMsg = resSix10265.WarnMsg
  15318. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15319. res2.Infcode = infocode
  15320. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15321. if err == nil {
  15322. c.ServeSuccessJSON(map[string]interface{}{
  15323. "msg": "撤销明细成功",
  15324. })
  15325. return
  15326. } else {
  15327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15328. return
  15329. }
  15330. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15331. var resSix10265 ResultSix10265
  15332. var api3 string
  15333. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  15334. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15335. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15336. resp3, requestErr3 := http.Get(api3)
  15337. if requestErr3 != nil {
  15338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15339. return
  15340. }
  15341. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15342. if ioErr3 != nil {
  15343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15345. return
  15346. }
  15347. var respJSON3 map[string]interface{}
  15348. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15351. return
  15352. }
  15353. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15354. userJSONBytes3, _ := json.Marshal(respJSON3)
  15355. fmt.Println("log")
  15356. fmt.Println(string(userJSONBytes3))
  15357. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15358. utils.ErrorLog("解析失败:%v", err)
  15359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15360. return
  15361. }
  15362. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15363. res2.Output = resSix10265.Output
  15364. res2.ErrMsg = resSix10265.ErrMsg
  15365. res2.Cainfo = resSix10265.Cainfo
  15366. res2.WarnMsg = resSix10265.WarnMsg
  15367. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15368. res2.Infcode = infocode
  15369. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15370. if err == nil {
  15371. c.ServeSuccessJSON(map[string]interface{}{
  15372. "msg": "撤销明细成功",
  15373. })
  15374. return
  15375. } else {
  15376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15377. return
  15378. }
  15379. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15380. 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)
  15381. var dat map[string]interface{}
  15382. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15383. fmt.Println(dat)
  15384. } else {
  15385. fmt.Println(err)
  15386. }
  15387. saveLog(result2, src_request, "2205", "撤销明细")
  15388. userJSONBytes, _ := json.Marshal(dat)
  15389. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15390. utils.ErrorLog("解析失败:%v", err)
  15391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15392. return
  15393. }
  15394. if res2.Infcode == 0 {
  15395. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15396. if err == nil {
  15397. c.ServeSuccessJSON(map[string]interface{}{
  15398. "msg": "撤销明细成功",
  15399. })
  15400. return
  15401. } else {
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15403. return
  15404. }
  15405. } else {
  15406. c.ServeSuccessJSON(map[string]interface{}{
  15407. "code": -10,
  15408. "msg": res2.ErrMsg,
  15409. })
  15410. }
  15411. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15412. 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, "")
  15413. var dat map[string]interface{}
  15414. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15415. fmt.Println(dat)
  15416. } else {
  15417. fmt.Println(err)
  15418. }
  15419. saveLog(result2, src_request, "2205", "撤销明细")
  15420. userJSONBytes, _ := json.Marshal(dat)
  15421. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15422. utils.ErrorLog("解析失败:%v", err)
  15423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15424. return
  15425. }
  15426. if res2.Infcode == 0 {
  15427. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15428. if err == nil {
  15429. c.ServeSuccessJSON(map[string]interface{}{
  15430. "msg": "撤销明细成功",
  15431. })
  15432. return
  15433. } else {
  15434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15435. return
  15436. }
  15437. } else {
  15438. c.ServeSuccessJSON(map[string]interface{}{
  15439. "code": -10,
  15440. "msg": res2.ErrMsg,
  15441. })
  15442. }
  15443. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15444. 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, "")
  15445. var dat map[string]interface{}
  15446. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15447. fmt.Println(dat)
  15448. } else {
  15449. fmt.Println(err)
  15450. }
  15451. saveLog(result2, src_request, "2205", "撤销明细")
  15452. userJSONBytes, _ := json.Marshal(dat)
  15453. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15454. utils.ErrorLog("解析失败:%v", err)
  15455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15456. return
  15457. }
  15458. if res2.Infcode == 0 {
  15459. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15460. if err == nil {
  15461. c.ServeSuccessJSON(map[string]interface{}{
  15462. "msg": "撤销明细成功",
  15463. })
  15464. return
  15465. } else {
  15466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15467. return
  15468. }
  15469. } else {
  15470. c.ServeSuccessJSON(map[string]interface{}{
  15471. "code": -10,
  15472. "msg": res2.ErrMsg,
  15473. })
  15474. }
  15475. } else {
  15476. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  15477. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15479. resp2, requestErr2 := http.Get(api2)
  15480. if requestErr2 != nil {
  15481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15482. return
  15483. }
  15484. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  15485. if ioErr2 != nil {
  15486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  15487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15488. return
  15489. }
  15490. var respJSON2 map[string]interface{}
  15491. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  15492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15494. return
  15495. }
  15496. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15497. if err == nil {
  15498. c.ServeSuccessJSON(map[string]interface{}{
  15499. "msg": "撤销明细成功",
  15500. })
  15501. return
  15502. } else {
  15503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15504. return
  15505. }
  15506. }
  15507. } else {
  15508. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15509. if err == nil {
  15510. c.ServeSuccessJSON(map[string]interface{}{
  15511. "msg": "退费成功",
  15512. })
  15513. } else {
  15514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15515. return
  15516. }
  15517. }
  15518. }
  15519. // 对账
  15520. func (c *HisApiController) GetCheckAccount() {
  15521. start_time := c.GetString("start_time")
  15522. end_time := c.GetString("end_time")
  15523. insutype := c.GetString("insutype")
  15524. clr_type := c.GetString("clr_type")
  15525. clr_org := c.GetString("clr_optins")
  15526. admin_user_id, _ := c.GetInt64("admin_user_id")
  15527. adminUser := c.GetAdminUserInfo()
  15528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15530. if len(clr_org) == 0 {
  15531. clr_org = miConfig.MdtrtareaAdmvs
  15532. }
  15533. timeLayout := "2006-01-02"
  15534. loc, _ := time.LoadLocation("Local")
  15535. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  15536. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  15537. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  15538. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  15539. fixmedins_setl_cnt := int64(len(orders))
  15540. var medfee_sumamt float64
  15541. var acct_pay float64
  15542. var fund_pay_sumamt float64
  15543. for _, item := range orders {
  15544. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  15545. acct_pay = acct_pay + item.AcctPay
  15546. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  15547. }
  15548. var user_name string
  15549. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15550. if role.ID == 0 {
  15551. user_name = "xxx"
  15552. } else {
  15553. user_name = role.UserName
  15554. }
  15555. var res ResultEight
  15556. var res10188 ResultEightFor10188
  15557. if config.IsOpen == 1 {
  15558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15559. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  15560. "insutype=" + insutype +
  15561. "&clr_type=" + clr_type +
  15562. "&setl_optins=" + clr_org +
  15563. "&stmt_begndate=" + start_time +
  15564. "&stm_enddate=" + end_time +
  15565. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  15566. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  15567. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  15568. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  15569. "&fixmedins_code=" + miConfig.Code +
  15570. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15571. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15572. "&secret_key=" + miConfig.SecretKey +
  15573. "&org_name=" + miConfig.OrgName +
  15574. "&doctor=" + user_name +
  15575. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15576. fmt.Println(api)
  15577. resp, requestErr := http.Get(api)
  15578. if requestErr != nil {
  15579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15580. return
  15581. }
  15582. body, ioErr := ioutil.ReadAll(resp.Body)
  15583. fmt.Println(body)
  15584. if ioErr != nil {
  15585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. var respJSON map[string]interface{}
  15590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15593. return
  15594. }
  15595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15596. userJSONBytes, _ := json.Marshal(respJSON)
  15597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15598. utils.ErrorLog("解析失败:%v", err)
  15599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15600. return
  15601. }
  15602. res.InfRefmsgid = res10188.InfRefmsgid
  15603. res.Output = res10188.Output
  15604. res.ErrMsg = res10188.ErrMsg
  15605. res.Cainfo = res10188.Cainfo
  15606. res.WarnMsg = res10188.WarnMsg
  15607. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  15608. res.Infcode = infocode
  15609. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15610. if clr_type == "11" {
  15611. fixmedins_setl_cnt = 0
  15612. }
  15613. //if clr_type == "21" {
  15614. // clr_type = "22"
  15615. //}
  15616. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  15617. "insutype=" + insutype +
  15618. "&clr_type=" + clr_type +
  15619. "&setl_optins=" + clr_org +
  15620. "&stmt_begndate=" + start_time +
  15621. "&stm_enddate=" + end_time +
  15622. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  15623. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  15624. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  15625. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  15626. "&fixmedins_code=" + miConfig.Code +
  15627. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15628. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15629. "&secret_key=" + miConfig.SecretKey +
  15630. "&org_name=" + miConfig.OrgName +
  15631. "&doctor=" + user_name
  15632. resp, requestErr := http.Get(api)
  15633. if requestErr != nil {
  15634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15635. return
  15636. }
  15637. body, ioErr := ioutil.ReadAll(resp.Body)
  15638. if ioErr != nil {
  15639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15641. return
  15642. }
  15643. var respJSON map[string]interface{}
  15644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15647. return
  15648. }
  15649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15650. result, _ := json.Marshal(respJSON)
  15651. fmt.Println("log")
  15652. fmt.Println(string(result))
  15653. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  15654. utils.ErrorLog("解析失败:%v", err)
  15655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15656. return
  15657. }
  15658. res.InfRefmsgid = res10188.InfRefmsgid
  15659. res.Output = res10188.Output
  15660. res.ErrMsg = res10188.ErrMsg
  15661. res.Cainfo = res10188.Cainfo
  15662. res.WarnMsg = res10188.WarnMsg
  15663. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  15664. res.Infcode = infocode
  15665. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15666. var baseParams models.BaseParams
  15667. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15668. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15669. baseParams.SecretKey = miConfig.SecretKey
  15670. baseParams.OrgName = miConfig.OrgName
  15671. baseParams.FixmedinsCode = miConfig.Code
  15672. baseParams.EncKey = miConfig.EncKey
  15673. baseParams.AppSecret = miConfig.AppSecret
  15674. baseParams.SignKey = miConfig.SignKey
  15675. baseParams.AppID = miConfig.Code
  15676. baseParams.Doctor = role.UserName
  15677. baseParams.RequestUrl = miConfig.Url
  15678. businessParams := models.BusinessParams{
  15679. Insutype: insutype,
  15680. ClrType: clr_type,
  15681. SetlOptins: clr_org,
  15682. StmtBegndate: start_time,
  15683. StmtEnddate: end_time,
  15684. MedfeeSumamt: medfee_sumamt,
  15685. FundPaySumamt: fund_pay_sumamt,
  15686. AcctPay: acct_pay,
  15687. FixmedinsSetlCnt: fixmedins_setl_cnt,
  15688. }
  15689. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  15690. fmt.Println(requestLog)
  15691. fmt.Println(result)
  15692. fmt.Println(err_msg)
  15693. var dat map[string]interface{}
  15694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15695. fmt.Println(dat)
  15696. } else {
  15697. fmt.Println(err)
  15698. }
  15699. userJSONBytes, _ := json.Marshal(dat)
  15700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15701. utils.ErrorLog("解析失败:%v", err)
  15702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15703. return
  15704. }
  15705. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15706. var baseParams models.BaseParams
  15707. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15708. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15709. baseParams.SecretKey = miConfig.SecretKey
  15710. baseParams.OrgName = miConfig.OrgName
  15711. baseParams.FixmedinsCode = miConfig.Code
  15712. baseParams.EncKey = miConfig.EncKey
  15713. baseParams.AppSecret = miConfig.AppSecret
  15714. baseParams.SignKey = miConfig.SignKey
  15715. baseParams.AppID = miConfig.Code
  15716. baseParams.Doctor = role.UserName
  15717. baseParams.RequestUrl = miConfig.Url
  15718. baseParams.AccessKey = miConfig.AccessKey
  15719. businessParams := models.BusinessParams{
  15720. Insutype: insutype,
  15721. ClrType: clr_type,
  15722. SetlOptins: "430822",
  15723. StmtBegndate: start_time,
  15724. StmtEnddate: end_time,
  15725. MedfeeSumamt: medfee_sumamt,
  15726. FundPaySumamt: fund_pay_sumamt,
  15727. AcctPay: acct_pay,
  15728. FixmedinsSetlCnt: fixmedins_setl_cnt,
  15729. }
  15730. 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)
  15731. fmt.Println(requestLog)
  15732. fmt.Println(result)
  15733. var dat map[string]interface{}
  15734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15735. fmt.Println(dat)
  15736. } else {
  15737. fmt.Println(err)
  15738. }
  15739. userJSONBytes, _ := json.Marshal(dat)
  15740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15741. utils.ErrorLog("解析失败:%v", err)
  15742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15743. return
  15744. }
  15745. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15746. var baseParams models.BaseParams
  15747. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15748. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15749. baseParams.SecretKey = miConfig.SecretKey
  15750. baseParams.OrgName = miConfig.OrgName
  15751. baseParams.FixmedinsCode = miConfig.Code
  15752. baseParams.EncKey = miConfig.EncKey
  15753. baseParams.AppSecret = miConfig.AppSecret
  15754. baseParams.SignKey = miConfig.SignKey
  15755. baseParams.AppID = miConfig.Code
  15756. baseParams.Doctor = role.UserName
  15757. baseParams.RequestUrl = miConfig.Url
  15758. businessParams := models.BusinessParams{
  15759. Insutype: insutype,
  15760. ClrType: clr_type,
  15761. SetlOptins: clr_org,
  15762. StmtBegndate: start_time,
  15763. StmtEnddate: end_time,
  15764. MedfeeSumamt: medfee_sumamt,
  15765. FundPaySumamt: fund_pay_sumamt,
  15766. AcctPay: acct_pay,
  15767. FixmedinsSetlCnt: fixmedins_setl_cnt,
  15768. }
  15769. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  15770. fmt.Println(requestLog)
  15771. fmt.Println(result)
  15772. fmt.Println(err_msg)
  15773. var dat map[string]interface{}
  15774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15775. fmt.Println(dat)
  15776. } else {
  15777. fmt.Println(err)
  15778. }
  15779. userJSONBytes, _ := json.Marshal(dat)
  15780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15781. utils.ErrorLog("解析失败:%v", err)
  15782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15783. return
  15784. }
  15785. } else {
  15786. if len(clr_type) == 0 {
  15787. clr_type = "11"
  15788. }
  15789. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  15790. "insutype=" + insutype +
  15791. "&clr_type=" + clr_type +
  15792. "&setl_optins=" + clr_org +
  15793. "&stmt_begndate=" + start_time +
  15794. "&stm_enddate=" + end_time +
  15795. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  15796. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  15797. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  15798. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  15799. "&fixmedins_code=" + miConfig.Code +
  15800. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15801. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15802. "&secret_key=" + miConfig.SecretKey +
  15803. "&org_name=" + miConfig.OrgName +
  15804. "&doctor=" + user_name
  15805. fmt.Println(api)
  15806. resp, requestErr := http.Get(api)
  15807. if requestErr != nil {
  15808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15809. return
  15810. }
  15811. body, ioErr := ioutil.ReadAll(resp.Body)
  15812. fmt.Println(body)
  15813. if ioErr != nil {
  15814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15816. return
  15817. }
  15818. var respJSON map[string]interface{}
  15819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15822. return
  15823. }
  15824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15825. userJSONBytes, _ := json.Marshal(respJSON)
  15826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15827. utils.ErrorLog("解析失败:%v", err)
  15828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15829. return
  15830. }
  15831. }
  15832. if res.Infcode == 0 {
  15833. if res.Output.Stmtinfo.StmtRslt == "0" {
  15834. micc := &models.MedicalInsuranceCostCompare{
  15835. StartTime: startime.Unix(),
  15836. EndTime: endtime.Unix(),
  15837. Insutype: insutype,
  15838. CheckType: 1,
  15839. Num: fixmedins_setl_cnt,
  15840. Mtime: time.Now().Unix(),
  15841. Status: 1,
  15842. UserOrgId: adminUser.CurrentOrgId,
  15843. CostTotal: medfee_sumamt,
  15844. FuncTotal: fund_pay_sumamt,
  15845. PsnPay: acct_pay,
  15846. Creator: admin_user_id,
  15847. Ctime: time.Now().Unix(),
  15848. ClrType: clr_type,
  15849. }
  15850. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  15851. if err == nil {
  15852. c.ServeSuccessJSON(map[string]interface{}{
  15853. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  15854. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  15855. })
  15856. } else {
  15857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15858. }
  15859. } else {
  15860. c.ServeSuccessJSON(map[string]interface{}{
  15861. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  15862. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  15863. })
  15864. }
  15865. } else {
  15866. c.ServeSuccessJSON(map[string]interface{}{
  15867. "code": -10,
  15868. "msg": res.ErrMsg,
  15869. })
  15870. }
  15871. }
  15872. }
  15873. func (c *HisApiController) Check310() {
  15874. adminUser := c.GetAdminUserInfo()
  15875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15876. var user_name string
  15877. user_name = "高慧裕"
  15878. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  15879. "insutype=" + "310" +
  15880. "&clr_type=" + "" +
  15881. "&setl_optins=" + "441202" +
  15882. "&stmt_begndate=" + "2022-03-01" +
  15883. "&stm_enddate=" + "2022-03-31" +
  15884. "&medfee_sumamt=" + "194930.12" +
  15885. "&fund_pay_sumamt=" + "188741.46" +
  15886. "&acct_pay=" + "0" +
  15887. "&fixmedins_setl_cnt=" + "452" +
  15888. "&fixmedins_code=" + miConfig.Code +
  15889. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15890. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15891. "&secret_key=" + miConfig.SecretKey +
  15892. "&org_name=" + miConfig.OrgName +
  15893. "&doctor=" + user_name
  15894. fmt.Println(api)
  15895. resp, requestErr := http.Get(api)
  15896. if requestErr != nil {
  15897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15898. return
  15899. }
  15900. body, ioErr := ioutil.ReadAll(resp.Body)
  15901. fmt.Println(body)
  15902. if ioErr != nil {
  15903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15905. return
  15906. }
  15907. var respJSON map[string]interface{}
  15908. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15911. return
  15912. }
  15913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15914. userJSONBytes, _ := json.Marshal(respJSON)
  15915. var res ResultEight
  15916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15917. utils.ErrorLog("解析失败:%v", err)
  15918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15919. return
  15920. }
  15921. }
  15922. func (c *HisApiController) Check390() {
  15923. adminUser := c.GetAdminUserInfo()
  15924. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15925. var user_name string
  15926. user_name = "高慧裕"
  15927. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  15928. "insutype=" + "390" +
  15929. "&clr_type=" + "" +
  15930. "&setl_optins=" + "441202" +
  15931. "&stmt_begndate=" + "2022-03-01" +
  15932. "&stm_enddate=" + "2022-03-31" +
  15933. "&medfee_sumamt=" + "1068448.89" +
  15934. "&fund_pay_sumamt=" + "1014677.62" +
  15935. "&acct_pay=" + "0" +
  15936. "&fixmedins_setl_cnt=" + "1950" +
  15937. "&fixmedins_code=" + miConfig.Code +
  15938. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15939. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15940. "&secret_key=" + miConfig.SecretKey +
  15941. "&org_name=" + miConfig.OrgName +
  15942. "&doctor=" + user_name
  15943. fmt.Println(api)
  15944. resp, requestErr := http.Get(api)
  15945. if requestErr != nil {
  15946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15947. return
  15948. }
  15949. body, ioErr := ioutil.ReadAll(resp.Body)
  15950. fmt.Println(body)
  15951. if ioErr != nil {
  15952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15954. return
  15955. }
  15956. var respJSON map[string]interface{}
  15957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15960. return
  15961. }
  15962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15963. userJSONBytes, _ := json.Marshal(respJSON)
  15964. var res ResultEight
  15965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15966. utils.ErrorLog("解析失败:%v", err)
  15967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15968. return
  15969. }
  15970. }
  15971. // 对账明细
  15972. func (c *HisApiController) GetCheckDetailAccount() {
  15973. start_time := c.GetString("start_time")
  15974. end_time := c.GetString("end_time")
  15975. admin_user_id, _ := c.GetInt64("admin_user_id")
  15976. adminUser := c.GetAdminUserInfo()
  15977. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15978. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15979. timeLayout := "2006-01-02"
  15980. loc, _ := time.LoadLocation("Local")
  15981. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  15982. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  15983. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  15984. rand.Seed(time.Now().UnixNano())
  15985. num := rand.Intn(30000)
  15986. Mkdir(miConfig.OrgName)
  15987. file := strconv.FormatInt(int64(num), 10)
  15988. file_name := file + ".txt"
  15989. zip_name := file + ".zip"
  15990. zip_path := miConfig.OrgName + "/" + zip_name
  15991. file_path := miConfig.OrgName + "/" + file_name
  15992. decimal.DivisionPrecision = 2
  15993. var medfee_sumamt float64
  15994. var psn_cash_pay float64
  15995. var fund_pay_sumamt float64
  15996. fixmedins_setl_cnt := int64(len(orders))
  15997. for _, item := range orders {
  15998. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  15999. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  16000. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16001. }
  16002. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  16003. defer f.Close()
  16004. if err != nil {
  16005. fmt.Println(err.Error())
  16006. } else {
  16007. for _, item := range orders {
  16008. var refd_setl_flag string
  16009. if item.OrderStatus == 2 {
  16010. refd_setl_flag = "0"
  16011. var str string
  16012. str = item.SetlId + " " +
  16013. item.MdtrtId + " " +
  16014. item.PsnNo + " " +
  16015. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  16016. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  16017. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  16018. _, err = f.Write([]byte(str))
  16019. }
  16020. if item.OrderStatus == 3 {
  16021. var str string
  16022. str = item.SetlId + " " +
  16023. item.MdtrtId + " " +
  16024. item.PsnNo + " " +
  16025. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  16026. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  16027. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  16028. _, err = f.Write([]byte(str))
  16029. var str2 string
  16030. str2 = item.SetlId + " " +
  16031. item.MdtrtId + " " +
  16032. item.PsnNo + " " +
  16033. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  16034. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  16035. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  16036. _, err = f.Write([]byte(str2))
  16037. }
  16038. }
  16039. }
  16040. Zip(file_path, zip_path)
  16041. fmt.Println(ReadFile(zip_path))
  16042. fmt.Println(string(ReadFile(zip_path)))
  16043. if config.IsOpen == 1 {
  16044. var user_name string
  16045. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16046. if role.ID == 0 {
  16047. user_name = "管理员"
  16048. } else {
  16049. user_name = role.UserName
  16050. }
  16051. baseParams := models.BaseParams{
  16052. SecretKey: miConfig.SecretKey,
  16053. FixmedinsCode: miConfig.Code,
  16054. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16055. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16056. OrgName: miConfig.OrgName,
  16057. Doctor: user_name,
  16058. }
  16059. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  16060. var dat map[string]interface{}
  16061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16062. fmt.Println(dat)
  16063. } else {
  16064. fmt.Println(err)
  16065. }
  16066. userJSONBytes, _ := json.Marshal(dat)
  16067. var res ResultNine
  16068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16069. utils.ErrorLog("解析失败:%v", err)
  16070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16071. return
  16072. }
  16073. if res.Infcode == 0 {
  16074. fileNo := res.Output.FileQuryNo
  16075. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  16076. "file_qury_no=" + fileNo +
  16077. "&setl_optins=" + "定点医保中心" +
  16078. "&stmt_begndate=" + start_time +
  16079. "&stm_enddate=" + end_time +
  16080. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  16081. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  16082. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  16083. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  16084. "&fixmedins_code=" + miConfig.Code +
  16085. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  16086. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16087. "&secret_key=" + miConfig.SecretKey +
  16088. "&org_name=" + miConfig.OrgName +
  16089. "&doctor=" + user_name
  16090. resp, requestErr := http.Get(api)
  16091. if requestErr != nil {
  16092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16093. return
  16094. }
  16095. body, ioErr := ioutil.ReadAll(resp.Body)
  16096. if ioErr != nil {
  16097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16099. return
  16100. }
  16101. var respJSON map[string]interface{}
  16102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16105. return
  16106. }
  16107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16108. userJSONBytes, _ := json.Marshal(respJSON)
  16109. var res ResultTen
  16110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16111. utils.ErrorLog("解析失败:%v", err)
  16112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16113. return
  16114. }
  16115. if res.Infcode == 0 {
  16116. service.Gdyb9102(baseParams, zip_name, fileNo)
  16117. micc := &models.MedicalInsuranceCostCompare{
  16118. StartTime: startime.Unix(),
  16119. EndTime: endtime.Unix(),
  16120. Insutype: "0",
  16121. CheckType: 2,
  16122. Num: fixmedins_setl_cnt,
  16123. Mtime: time.Now().Unix(),
  16124. Status: 1,
  16125. UserOrgId: adminUser.CurrentOrgId,
  16126. CostTotal: medfee_sumamt,
  16127. FuncTotal: fund_pay_sumamt,
  16128. PsnPay: psn_cash_pay,
  16129. Creator: admin_user_id,
  16130. Ctime: time.Now().Unix(),
  16131. }
  16132. service.CreateMedicalInsuranceCostCompareRecord(micc)
  16133. c.ServeSuccessJSON(map[string]interface{}{
  16134. "msg": "明细对账成功",
  16135. })
  16136. }
  16137. } else {
  16138. }
  16139. }
  16140. }
  16141. type CustomOrderInfo struct {
  16142. Name string
  16143. Spec string
  16144. Unit string
  16145. Count float64
  16146. Price float64
  16147. Total float64
  16148. }
  16149. func (c *HisApiController) GetBatchSettleAccounts() {
  16150. admin_user_id, _ := c.GetInt64("admin_user_id")
  16151. order_ids := c.GetString("order_ids")
  16152. order_ids_arr := strings.Split(order_ids, ",")
  16153. data3 := []map[string]interface{}{}
  16154. for _, item := range order_ids_arr {
  16155. id, _ := strconv.ParseInt(item, 10, 64)
  16156. order_id := id
  16157. adminUser := c.GetAdminUserInfo()
  16158. order, _ := service.GetHisOrderByID(order_id)
  16159. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16160. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  16161. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  16162. orderInfos = append(orderInfos, orderInfos_two...)
  16163. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  16164. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  16165. var diagnosis_ids []string
  16166. if his.ID > 0 {
  16167. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  16168. } else {
  16169. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  16170. }
  16171. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  16172. var dia_config []*models.HisXtDiagnoseConfig
  16173. var name string
  16174. for _, item := range diagnosis_ids {
  16175. id, _ := strconv.ParseInt(item, 10, 64)
  16176. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16177. dia_config = append(dia_config, &diagnosisConfig)
  16178. if len(name) == 0 {
  16179. name = diagnosisConfig.ClassName
  16180. } else {
  16181. name = name + "," + diagnosisConfig.ClassName
  16182. }
  16183. }
  16184. var bedCostTotal float64 = 0 //床位总费
  16185. var bedCostSelfTotal float64 = 0 //床位自费
  16186. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16187. var bedSelfTotal float64 = 0 //床位部分项目自费
  16188. var bedInscpTotal float64 = 0 //床位部分项目自费
  16189. var operationCostTotal float64 = 0 //手术费
  16190. var operationCostSelfTotal float64 = 0 //手术费
  16191. var operationCostPartSelfTotal float64 = 0 //手术费
  16192. var operationSelfTotal float64 = 0 //床位部分项目自费
  16193. var operationInscpTotal float64 = 0 //床位部分项目自费
  16194. var otherCostTotal float64 = 0 //其他费用
  16195. var otherCostSelfTotal float64 = 0 //其他费用
  16196. var otherCostPartSelfTotal float64 = 0 //其他费用
  16197. var otherSelfTotal float64 = 0 //床位部分项目自费
  16198. var otherInscpTotal float64 = 0 //床位部分项目自费
  16199. var materialCostTotal float64 = 0 //材料费
  16200. var materialCostSelfTotal float64 = 0 //材料费
  16201. var materialCostPartSelfTotal float64 = 0 //材料费
  16202. var materialSelfTotal float64 = 0 //床位部分项目自费
  16203. var materialInscpTotal float64 = 0 //床位部分项目自费
  16204. var westernMedicineCostTotal float64 = 0 //西药费
  16205. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16206. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16207. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  16208. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  16209. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16210. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16211. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16212. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  16213. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  16214. var checkCostTotal float64 = 0 //检查费
  16215. var checkCostSelfTotal float64 = 0 //检查费
  16216. var checkCostPartSelfTotal float64 = 0 //检查费
  16217. var checkSelfTotal float64 = 0 //床位部分项目自费
  16218. var checkInscpTotal float64 = 0 //床位部分项目自费
  16219. var laboratoryCostTotal float64 = 0 //化验费
  16220. var laboratoryCostSelfTotal float64 = 0 //化验费
  16221. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16222. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  16223. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  16224. var treatCostTotal float64 = 0 //治疗费用
  16225. var treatCostSelfTotal float64 = 0 //治疗费用
  16226. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16227. var treatSelfTotal float64 = 0 //床位部分项目自费
  16228. var treatInscpTotal float64 = 0 //床位部分项目自费
  16229. decimal.DivisionPrecision = 2
  16230. for _, item := range orderInfos {
  16231. if item.MedChrgitmType == "01" { //床位费
  16232. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16233. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16234. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16235. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16236. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16237. }
  16238. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  16239. if item.MedChrgitmType == "03" { //检查费
  16240. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16241. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16242. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16243. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16244. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16245. }
  16246. } else {
  16247. if item.MedChrgitmType == "03" { //检查费
  16248. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16249. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16250. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16251. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16252. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16253. }
  16254. }
  16255. if item.MedChrgitmType == "04" { //化验费
  16256. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16257. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16258. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16259. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16260. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16261. }
  16262. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  16263. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16264. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16265. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16266. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16267. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16268. }
  16269. if item.MedChrgitmType == "06" { //手术费
  16270. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16271. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16272. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16273. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16274. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16275. }
  16276. if item.MedChrgitmType == "08" { //材料费
  16277. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16278. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16279. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16280. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16281. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16282. }
  16283. if item.MedChrgitmType == "09" { //西药费
  16284. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16285. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16286. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16287. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16288. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16289. }
  16290. if item.MedChrgitmType == "11" { //中成费
  16291. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16292. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16293. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16294. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16295. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16296. }
  16297. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  16298. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16299. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16300. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16301. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16302. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16303. }
  16304. }
  16305. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16306. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16307. var user_name string
  16308. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16309. if role.ID == 0 {
  16310. user_name = "管理员"
  16311. } else {
  16312. user_name = role.UserName
  16313. }
  16314. baseParams := models.BaseParams{
  16315. SecretKey: miConfig.SecretKey,
  16316. FixmedinsCode: miConfig.Code,
  16317. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16318. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16319. OrgName: miConfig.OrgName,
  16320. Doctor: user_name,
  16321. RequestUrl: miConfig.Url,
  16322. AccessKey: miConfig.AccessKey,
  16323. }
  16324. businessParams := models.BusinessParams{
  16325. PsnNo: order.PsnNo,
  16326. MdtrtId: order.MdtrtId,
  16327. SetlId: order.SetlId,
  16328. }
  16329. var res ResultEleven
  16330. var resEleven10265 ResultEleven10265
  16331. if config.IsOpen == 1 {
  16332. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  16333. result := service.Gdyb5203(baseParams, businessParams)
  16334. //service.Gdyb5204(baseParams, businessParams)
  16335. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  16336. var dat map[string]interface{}
  16337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16338. fmt.Println(dat)
  16339. } else {
  16340. fmt.Println(err)
  16341. }
  16342. userJSONBytes, _ := json.Marshal(dat)
  16343. if miConfig.Code == "H15049901371" {
  16344. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  16345. utils.ErrorLog("解析失败:%v", err)
  16346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16347. return
  16348. }
  16349. res.InfRefmsgid = resEleven10265.InfRefmsgid
  16350. res.Output = resEleven10265.Output
  16351. res.ErrMsg = resEleven10265.ErrMsg
  16352. res.Cainfo = resEleven10265.Cainfo
  16353. res.WarnMsg = resEleven10265.WarnMsg
  16354. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  16355. res.Infcode = infocode
  16356. } else {
  16357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16358. utils.ErrorLog("解析失败:%v", err)
  16359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16360. return
  16361. }
  16362. }
  16363. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16364. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  16365. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  16366. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  16367. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  16368. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16369. var doctor_name string
  16370. if roles.ID == 0 {
  16371. doctor_name = "管理员"
  16372. } else {
  16373. doctor_name = roles.UserName
  16374. }
  16375. yiliao_leibie := ""
  16376. switch order.MedType {
  16377. case "11":
  16378. yiliao_leibie = "普通门诊"
  16379. break
  16380. case "12":
  16381. yiliao_leibie = "门诊挂号"
  16382. break
  16383. case "13":
  16384. yiliao_leibie = "急诊"
  16385. break
  16386. case "14":
  16387. yiliao_leibie = "门诊特殊病"
  16388. break
  16389. case "15":
  16390. yiliao_leibie = "门诊统筹"
  16391. break
  16392. case "16":
  16393. yiliao_leibie = "门诊慢性病"
  16394. break
  16395. case "21":
  16396. yiliao_leibie = "普通住院"
  16397. break
  16398. }
  16399. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  16400. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  16401. if res.Infcode == 0 {
  16402. data2 := map[string]interface{}{
  16403. "diagnosis": name,
  16404. "order_infos": orderInfos,
  16405. "number": order.MdtrtId,
  16406. "date": order.SettleAccountsDate,
  16407. "charge_admin": charge_admin,
  16408. "printor_admin": printor_admin,
  16409. "info": res.Output.Setlinfo,
  16410. "order": order,
  16411. "bedCostTotal": bedCostTotal,
  16412. "bedCostSelfTotal": bedCostSelfTotal,
  16413. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  16414. "bedSelfTotal": bedSelfTotal,
  16415. "bedInscpTotal": bedInscpTotal,
  16416. "operationCostTotal": operationCostTotal,
  16417. "operationCostSelfTotal": operationCostSelfTotal,
  16418. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  16419. "operationSelfTotal": operationSelfTotal,
  16420. "operationInscpTotal": operationInscpTotal,
  16421. "otherCostTotal": otherCostTotal,
  16422. "otherCostSelfTotal": otherCostSelfTotal,
  16423. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  16424. "otherSelfTotal": otherSelfTotal,
  16425. "otherInscpTotal": otherInscpTotal,
  16426. "materialCostTotal": materialCostTotal,
  16427. "materialCostSelfTotal": materialCostSelfTotal,
  16428. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  16429. "materialSelfTotal": materialSelfTotal,
  16430. "materialInscpTotal": materialInscpTotal,
  16431. "westernMedicineCostTotal": westernMedicineCostTotal,
  16432. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  16433. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  16434. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  16435. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  16436. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  16437. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  16438. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  16439. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  16440. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  16441. "checkCostTotal": checkCostTotal,
  16442. "checkCostSelfTotal": checkCostSelfTotal,
  16443. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  16444. "checkSelfTotal": checkSelfTotal,
  16445. "checkInscpTotal": checkInscpTotal,
  16446. "laboratoryCostTotal": laboratoryCostTotal,
  16447. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  16448. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  16449. "laboratorySelfTotal": laboratorySelfTotal,
  16450. "laboratoryInscpTotal": laboratoryInscpTotal,
  16451. "treatCostTotal": treatCostTotal,
  16452. "treatCostSelfTotal": treatCostSelfTotal,
  16453. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  16454. "treatSelfTotal": treatSelfTotal,
  16455. "treatInscpTotal": treatInscpTotal,
  16456. "doctor_info": doctor_info,
  16457. "doctor_code": adminRole_two.DoctorCode,
  16458. "doctor_name": doctor_name,
  16459. "health_card_no": order.PsnNo,
  16460. "department": departments.Name,
  16461. "yiliao_leibie": yiliao_leibie,
  16462. "after_money": order.AccountPrice,
  16463. "patient": patient,
  16464. "org_name": miConfig.OrgName,
  16465. "org_code": miConfig.Code,
  16466. "order_number": order.Number,
  16467. "his_hospital": his_hospital,
  16468. "his": his,
  16469. "dia_config": dia_config,
  16470. "psn_cash_pay": order.PsnCashPay,
  16471. //"check_order_info": cus_slice,
  16472. }
  16473. data3 = append(data3, data2)
  16474. }
  16475. }
  16476. }
  16477. c.ServeSuccessJSON(map[string]interface{}{
  16478. "infos": data3,
  16479. })
  16480. }
  16481. func (c *HisApiController) GetSettleAccounts() {
  16482. //id, _ := c.GetInt64("id")
  16483. //record_time := c.GetString("record_time")
  16484. order_id, _ := c.GetInt64("order_id")
  16485. admin_user_id, _ := c.GetInt64("admin_user_id")
  16486. //timeLayout := "2006-01-02"
  16487. //loc, _ := time.LoadLocation("Local")
  16488. //
  16489. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16490. //if err != nil {
  16491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16492. // return
  16493. //}
  16494. //recordDateTime := theTime.Unix()
  16495. adminUser := c.GetAdminUserInfo()
  16496. order, _ := service.GetHisOrderByID(order_id)
  16497. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16498. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  16499. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  16500. orderInfos = append(orderInfos, orderInfos_two...)
  16501. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  16502. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  16503. var diagnosis_ids []string
  16504. if his.ID > 0 {
  16505. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  16506. } else {
  16507. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  16508. }
  16509. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  16510. var dia_config []*models.HisXtDiagnoseConfig
  16511. var name string
  16512. for _, item := range diagnosis_ids {
  16513. id, _ := strconv.ParseInt(item, 10, 64)
  16514. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16515. dia_config = append(dia_config, &diagnosisConfig)
  16516. if len(name) == 0 {
  16517. name = diagnosisConfig.ClassName
  16518. } else {
  16519. name = name + "," + diagnosisConfig.ClassName
  16520. }
  16521. }
  16522. var bedCostTotal float64 = 0 //床位总费
  16523. var bedCostSelfTotal float64 = 0 //床位自费
  16524. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16525. var bedSelfTotal float64 = 0 //床位部分项目自费
  16526. var bedInscpTotal float64 = 0 //床位部分项目自费
  16527. var operationCostTotal float64 = 0 //手术费
  16528. var operationCostSelfTotal float64 = 0 //手术费
  16529. var operationCostPartSelfTotal float64 = 0 //手术费
  16530. var operationSelfTotal float64 = 0 //床位部分项目自费
  16531. var operationInscpTotal float64 = 0 //床位部分项目自费
  16532. var otherCostTotal float64 = 0 //其他费用
  16533. var otherCostSelfTotal float64 = 0 //其他费用
  16534. var otherCostPartSelfTotal float64 = 0 //其他费用
  16535. var otherSelfTotal float64 = 0 //床位部分项目自费
  16536. var otherInscpTotal float64 = 0 //床位部分项目自费
  16537. var materialCostTotal float64 = 0 //材料费
  16538. var materialCostSelfTotal float64 = 0 //材料费
  16539. var materialCostPartSelfTotal float64 = 0 //材料费
  16540. var materialSelfTotal float64 = 0 //床位部分项目自费
  16541. var materialInscpTotal float64 = 0 //床位部分项目自费
  16542. var westernMedicineCostTotal float64 = 0 //西药费
  16543. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16544. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16545. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  16546. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  16547. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16548. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16549. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16550. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  16551. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  16552. var checkCostTotal float64 = 0 //检查费
  16553. var checkCostSelfTotal float64 = 0 //检查费
  16554. var checkCostPartSelfTotal float64 = 0 //检查费
  16555. var checkSelfTotal float64 = 0 //床位部分项目自费
  16556. var checkInscpTotal float64 = 0 //床位部分项目自费
  16557. var laboratoryCostTotal float64 = 0 //化验费
  16558. var laboratoryCostSelfTotal float64 = 0 //化验费
  16559. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16560. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  16561. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  16562. var treatCostTotal float64 = 0 //治疗费用
  16563. var treatCostSelfTotal float64 = 0 //治疗费用
  16564. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16565. var treatSelfTotal float64 = 0 //床位部分项目自费
  16566. var treatInscpTotal float64 = 0 //床位部分项目自费
  16567. decimal.DivisionPrecision = 2
  16568. for _, item := range orderInfos {
  16569. if item.MedChrgitmType == "01" { //床位费
  16570. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16571. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16572. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16573. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16574. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16575. }
  16576. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  16577. if item.MedChrgitmType == "03" { //检查费
  16578. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16579. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16580. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16581. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16582. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16583. }
  16584. } else {
  16585. if item.MedChrgitmType == "03" { //检查费
  16586. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16587. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16588. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16589. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16590. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16591. }
  16592. }
  16593. if item.MedChrgitmType == "04" { //化验费
  16594. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16595. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16596. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16597. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16598. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16599. }
  16600. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  16601. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16602. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16603. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16604. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16605. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16606. }
  16607. if item.MedChrgitmType == "06" { //手术费
  16608. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16609. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16610. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16611. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16612. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16613. }
  16614. if item.MedChrgitmType == "08" { //材料费
  16615. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16616. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16617. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16618. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16619. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16620. }
  16621. if item.MedChrgitmType == "09" { //西药费
  16622. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16623. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16624. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16625. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16626. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16627. }
  16628. if item.MedChrgitmType == "11" { //中成费
  16629. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16630. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16631. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16632. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16633. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16634. }
  16635. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  16636. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16637. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16638. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16639. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16640. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16641. }
  16642. }
  16643. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16644. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16645. var user_name string
  16646. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16647. if role.ID == 0 {
  16648. user_name = "管理员"
  16649. } else {
  16650. user_name = role.UserName
  16651. }
  16652. baseParams := models.BaseParams{
  16653. SecretKey: miConfig.SecretKey,
  16654. FixmedinsCode: miConfig.Code,
  16655. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16656. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16657. OrgName: miConfig.OrgName,
  16658. Doctor: user_name,
  16659. RequestUrl: miConfig.Url,
  16660. AccessKey: miConfig.AccessKey,
  16661. }
  16662. businessParams := models.BusinessParams{
  16663. PsnNo: order.PsnNo,
  16664. MdtrtId: order.MdtrtId,
  16665. SetlId: order.SetlId,
  16666. }
  16667. var res ResultEleven
  16668. var resEleven10265 ResultEleven10265
  16669. if config.IsOpen == 1 {
  16670. if miConfig.MdtrtareaAdmvs == "421300" {
  16671. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16672. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16673. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  16674. resp, requestErr := http.Get(api)
  16675. if requestErr != nil {
  16676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16677. return
  16678. }
  16679. body, ioErr := ioutil.ReadAll(resp.Body)
  16680. if ioErr != nil {
  16681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16683. return
  16684. }
  16685. var respJSON map[string]interface{}
  16686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16689. return
  16690. }
  16691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16692. result, _ := json.Marshal(respJSON)
  16693. fmt.Println("log")
  16694. fmt.Println(string(result))
  16695. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16696. utils.ErrorLog("解析失败:%v", err)
  16697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16698. return
  16699. }
  16700. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16701. var api string
  16702. if miConfig.MdtrtareaAdmvs == "320921" {
  16703. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16704. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16705. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  16706. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16707. } else {
  16708. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16709. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16710. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  16712. }
  16713. resp, requestErr := http.Get(api)
  16714. if requestErr != nil {
  16715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16716. return
  16717. }
  16718. body, ioErr := ioutil.ReadAll(resp.Body)
  16719. if ioErr != nil {
  16720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16722. return
  16723. }
  16724. var respJSON map[string]interface{}
  16725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16728. return
  16729. }
  16730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16731. result, _ := json.Marshal(respJSON)
  16732. fmt.Println("log")
  16733. fmt.Println(string(result))
  16734. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  16735. utils.ErrorLog("解析失败:%v", err)
  16736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16737. return
  16738. }
  16739. res.InfRefmsgid = resEleven10265.InfRefmsgid
  16740. res.Output = resEleven10265.Output
  16741. res.ErrMsg = resEleven10265.ErrMsg
  16742. res.Cainfo = resEleven10265.Cainfo
  16743. res.WarnMsg = resEleven10265.WarnMsg
  16744. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  16745. res.Infcode = infocode
  16746. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16747. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  16748. saveLog(result, requestLog, "5203", "结算单")
  16749. var dat map[string]interface{}
  16750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16751. fmt.Println(dat)
  16752. } else {
  16753. fmt.Println(err)
  16754. }
  16755. userJSONBytes, _ := json.Marshal(dat)
  16756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16757. utils.ErrorLog("解析失败:%v", err)
  16758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16759. return
  16760. }
  16761. } else if miConfig.MdtrtareaAdmvs == "360399" {
  16762. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  16763. saveLog(result, requestLog, "5203", "结算单")
  16764. var dat map[string]interface{}
  16765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16766. fmt.Println(dat)
  16767. } else {
  16768. fmt.Println(err)
  16769. }
  16770. userJSONBytes, _ := json.Marshal(dat)
  16771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16772. utils.ErrorLog("解析失败:%v", err)
  16773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16774. return
  16775. }
  16776. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16777. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  16778. saveLog(result, requestLog, "5203", "结算单")
  16779. var dat map[string]interface{}
  16780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16781. fmt.Println(dat)
  16782. } else {
  16783. fmt.Println(err)
  16784. }
  16785. userJSONBytes, _ := json.Marshal(dat)
  16786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16787. utils.ErrorLog("解析失败:%v", err)
  16788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16789. return
  16790. }
  16791. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16792. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16793. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  16795. resp, requestErr := http.Get(api)
  16796. if requestErr != nil {
  16797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16798. return
  16799. }
  16800. body, ioErr := ioutil.ReadAll(resp.Body)
  16801. if ioErr != nil {
  16802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16804. return
  16805. }
  16806. var respJSON map[string]interface{}
  16807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16810. return
  16811. }
  16812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16813. result, _ := json.Marshal(respJSON)
  16814. fmt.Println("log")
  16815. fmt.Println(string(result))
  16816. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  16817. utils.ErrorLog("解析失败:%v", err)
  16818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16819. return
  16820. }
  16821. res.InfRefmsgid = resEleven10265.InfRefmsgid
  16822. res.Output = resEleven10265.Output
  16823. res.ErrMsg = resEleven10265.ErrMsg
  16824. res.Cainfo = resEleven10265.Cainfo
  16825. res.WarnMsg = resEleven10265.WarnMsg
  16826. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  16827. res.Infcode = infocode
  16828. } else {
  16829. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  16830. result := service.Gdyb5203(baseParams, businessParams)
  16831. //service.Gdyb5204(baseParams, businessParams)
  16832. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  16833. var dat map[string]interface{}
  16834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16835. fmt.Println(dat)
  16836. } else {
  16837. fmt.Println(err)
  16838. }
  16839. userJSONBytes, _ := json.Marshal(dat)
  16840. if miConfig.Code == "H15049901371" {
  16841. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  16842. utils.ErrorLog("解析失败:%v", err)
  16843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16844. return
  16845. }
  16846. res.InfRefmsgid = resEleven10265.InfRefmsgid
  16847. res.Output = resEleven10265.Output
  16848. res.ErrMsg = resEleven10265.ErrMsg
  16849. res.Cainfo = resEleven10265.Cainfo
  16850. res.WarnMsg = resEleven10265.WarnMsg
  16851. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  16852. res.Infcode = infocode
  16853. } else {
  16854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16855. utils.ErrorLog("解析失败:%v", err)
  16856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16857. return
  16858. }
  16859. }
  16860. }
  16861. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16862. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  16863. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  16864. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  16865. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  16866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16867. var doctor_name string
  16868. if roles.ID == 0 {
  16869. doctor_name = "管理员"
  16870. } else {
  16871. doctor_name = roles.UserName
  16872. }
  16873. yiliao_leibie := ""
  16874. switch order.MedType {
  16875. case "11":
  16876. yiliao_leibie = "普通门诊"
  16877. break
  16878. case "12":
  16879. yiliao_leibie = "门诊挂号"
  16880. break
  16881. case "13":
  16882. yiliao_leibie = "急诊"
  16883. break
  16884. case "14":
  16885. yiliao_leibie = "门诊特殊病"
  16886. break
  16887. case "15":
  16888. yiliao_leibie = "门诊统筹"
  16889. break
  16890. case "16":
  16891. yiliao_leibie = "门诊慢性病"
  16892. break
  16893. case "21":
  16894. yiliao_leibie = "普通住院"
  16895. break
  16896. }
  16897. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  16898. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  16899. if res.Infcode == 0 {
  16900. c.ServeSuccessJSON(map[string]interface{}{
  16901. "diagnosis": name,
  16902. "order_infos": orderInfos,
  16903. "number": order.MdtrtId,
  16904. "date": order.SettleAccountsDate,
  16905. "charge_admin": charge_admin,
  16906. "printor_admin": printor_admin,
  16907. "info": res.Output.Setlinfo,
  16908. "order": order,
  16909. "bedCostTotal": bedCostTotal,
  16910. "bedCostSelfTotal": bedCostSelfTotal,
  16911. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  16912. "bedSelfTotal": bedSelfTotal,
  16913. "bedInscpTotal": bedInscpTotal,
  16914. "operationCostTotal": operationCostTotal,
  16915. "operationCostSelfTotal": operationCostSelfTotal,
  16916. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  16917. "operationSelfTotal": operationSelfTotal,
  16918. "operationInscpTotal": operationInscpTotal,
  16919. "otherCostTotal": otherCostTotal,
  16920. "otherCostSelfTotal": otherCostSelfTotal,
  16921. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  16922. "otherSelfTotal": otherSelfTotal,
  16923. "otherInscpTotal": otherInscpTotal,
  16924. "materialCostTotal": materialCostTotal,
  16925. "materialCostSelfTotal": materialCostSelfTotal,
  16926. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  16927. "materialSelfTotal": materialSelfTotal,
  16928. "materialInscpTotal": materialInscpTotal,
  16929. "westernMedicineCostTotal": westernMedicineCostTotal,
  16930. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  16931. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  16932. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  16933. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  16934. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  16935. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  16936. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  16937. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  16938. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  16939. "checkCostTotal": checkCostTotal,
  16940. "checkCostSelfTotal": checkCostSelfTotal,
  16941. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  16942. "checkSelfTotal": checkSelfTotal,
  16943. "checkInscpTotal": checkInscpTotal,
  16944. "laboratoryCostTotal": laboratoryCostTotal,
  16945. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  16946. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  16947. "laboratorySelfTotal": laboratorySelfTotal,
  16948. "laboratoryInscpTotal": laboratoryInscpTotal,
  16949. "treatCostTotal": treatCostTotal,
  16950. "treatCostSelfTotal": treatCostSelfTotal,
  16951. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  16952. "treatSelfTotal": treatSelfTotal,
  16953. "treatInscpTotal": treatInscpTotal,
  16954. "doctor_info": doctor_info,
  16955. "doctor_code": adminRole_two.DoctorCode,
  16956. "doctor_name": doctor_name,
  16957. "health_card_no": order.PsnNo,
  16958. "department": departments.Name,
  16959. "yiliao_leibie": yiliao_leibie,
  16960. "after_money": order.AccountPrice,
  16961. "patient": patient,
  16962. "org_name": miConfig.OrgName,
  16963. "org_code": miConfig.Code,
  16964. "order_number": order.Number,
  16965. "his_hospital": his_hospital,
  16966. "his": his,
  16967. "dia_config": dia_config,
  16968. "psn_cash_pay": order.PsnCashPay,
  16969. //"check_order_info": cus_slice,
  16970. })
  16971. }
  16972. }
  16973. }
  16974. func (c *HisApiController) CheckTreatment() {
  16975. patient_id, _ := c.GetInt64("patient_id")
  16976. id_card_no := c.GetString("id_card_no")
  16977. insutype := c.GetString("insutype")
  16978. med_type := c.GetString("med_type")
  16979. admin_user_id, _ := c.GetInt64("admin_user_id")
  16980. adminUser := c.GetAdminUserInfo()
  16981. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  16982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16983. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16984. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16985. if miConfig.MdtrtareaAdmvs == "421300" {
  16986. var res ResultTwo
  16987. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  16988. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16989. "&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)
  16990. resp, requestErr := http.Get(api)
  16991. if requestErr != nil {
  16992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16993. return
  16994. }
  16995. body, ioErr := ioutil.ReadAll(resp.Body)
  16996. if ioErr != nil {
  16997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16999. return
  17000. }
  17001. var respJSON map[string]interface{}
  17002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17005. return
  17006. }
  17007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17008. result, _ := json.Marshal(respJSON)
  17009. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17010. utils.ErrorLog("解析失败:%v", err)
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17012. return
  17013. }
  17014. if res.Infcode == 0 {
  17015. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  17016. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17017. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  17018. resp, requestErr := http.Get(api)
  17019. if requestErr != nil {
  17020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17021. return
  17022. }
  17023. body, ioErr := ioutil.ReadAll(resp.Body)
  17024. if ioErr != nil {
  17025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17027. return
  17028. }
  17029. var respJSON map[string]interface{}
  17030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17033. return
  17034. }
  17035. var res Result2001
  17036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17037. result2, _ := json.Marshal(respJSON)
  17038. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17039. utils.ErrorLog("解析失败:%v", err)
  17040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17041. return
  17042. }
  17043. if res.Infcode == 0 {
  17044. c.ServeSuccessJSON(map[string]interface{}{
  17045. "msg": res.Output.Trtinfo,
  17046. })
  17047. }
  17048. } else {
  17049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17050. return
  17051. }
  17052. } else {
  17053. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  17054. var dat map[string]interface{}
  17055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17056. fmt.Println(dat)
  17057. } else {
  17058. fmt.Println(err)
  17059. }
  17060. userJSONBytes, _ := json.Marshal(dat)
  17061. var res ResultTwo
  17062. var res10265 ResultTwo10265
  17063. if miConfig.Code == "H15049901371" {
  17064. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  17065. utils.ErrorLog("解析失败:%v", err)
  17066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17067. return
  17068. }
  17069. res.ErrMsg = res10265.ErrMsg
  17070. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17071. res.Infcode = infocode
  17072. res.Output = res10265.Output
  17073. res.InfRefmsgid = res10265.InfRefmsgid
  17074. } else {
  17075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17076. utils.ErrorLog("解析失败:%v", err)
  17077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17078. return
  17079. }
  17080. }
  17081. var user_name string
  17082. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  17083. if role.ID == 0 {
  17084. user_name = "xxx"
  17085. } else {
  17086. user_name = role.UserName
  17087. }
  17088. baseParams := models.BaseParams{
  17089. SecretKey: miConfig.SecretKey,
  17090. FixmedinsCode: miConfig.Code,
  17091. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17092. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17093. OrgName: miConfig.OrgName,
  17094. Doctor: user_name,
  17095. }
  17096. if config.IsOpen == 1 {
  17097. if miConfig.Code == "H15049901371" {
  17098. if med_type == "14" {
  17099. if insutype == "390" {
  17100. med_type = "9933"
  17101. } else if insutype == "310" {
  17102. med_type = "990502"
  17103. }
  17104. } else if med_type == "11" {
  17105. med_type = "11"
  17106. }
  17107. }
  17108. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  17109. var dat map[string]interface{}
  17110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17111. fmt.Println(dat)
  17112. } else {
  17113. fmt.Println(err)
  17114. }
  17115. var res Result2001
  17116. var res10265 Result2001Org10265
  17117. if miConfig.Code == "H15049901371" {
  17118. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17119. utils.ErrorLog("解析失败:%v", err)
  17120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17121. return
  17122. }
  17123. res.ErrMsg = res10265.ErrMsg
  17124. res.Output = res10265.Output
  17125. res.InfRefmsgid = res10265.InfRefmsgid
  17126. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17127. res.Infcode = infocode
  17128. } else {
  17129. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17130. utils.ErrorLog("解析失败:%v", err)
  17131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17132. return
  17133. }
  17134. }
  17135. if res.Infcode == 0 {
  17136. c.ServeSuccessJSON(map[string]interface{}{
  17137. "msg": res.Output.Trtinfo,
  17138. })
  17139. }
  17140. }
  17141. }
  17142. }
  17143. //func (c *HisApiController) PutRecord() {
  17144. // id, _ := c.GetInt64("id")
  17145. // record_time := c.GetString("record_time")
  17146. // timeLayout := "2006-01-02"
  17147. // loc, _ := time.LoadLocation("Local")
  17148. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17149. // if err != nil {
  17150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17151. // return
  17152. // }
  17153. // recordDateTime := theTime.Unix()
  17154. //
  17155. // adminInfo := c.GetAdminUserInfo()
  17156. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  17157. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17158. //
  17159. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17160. //
  17161. // fmt.Println(miConfig.SecretKey)
  17162. //
  17163. // if patient == nil {
  17164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17165. // return
  17166. // }
  17167. // if len(patient.IdCardNo) == 0 {
  17168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17169. // return
  17170. // }
  17171. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17172. // if config.IsOpen == 1 {
  17173. // 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
  17174. // resp, requestErr := http.Get(api)
  17175. // if requestErr != nil {
  17176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17177. // return
  17178. // }
  17179. // defer resp.Body.Close()
  17180. // body, ioErr := ioutil.ReadAll(resp.Body)
  17181. // if ioErr != nil {
  17182. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17184. // return
  17185. // }
  17186. // var respJSON map[string]interface{}
  17187. //
  17188. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17189. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17191. // return
  17192. // }
  17193. //
  17194. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17195. // userJSONBytes, _ := json.Marshal(userJSON)
  17196. // var res ResultTwo
  17197. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17198. // utils.ErrorLog("解析失败:%v", err)
  17199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17200. // return
  17201. // }
  17202. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17203. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17204. // infoStr := string(Iinfos)
  17205. // idetinfoStr := string(Idetinfos)
  17206. //
  17207. // if res.Infcode == 0 {
  17208. // his := models.VMHisPatient{
  17209. // Status: 1,
  17210. // Ctime: time.Now().Unix(),
  17211. // Mtime: time.Now().Unix(),
  17212. // PsnNo: res.Output.Baseinfo.PsnNo,
  17213. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17214. // Certno: res.Output.Baseinfo.Certno,
  17215. // PsnName: res.Output.Baseinfo.PsnName,
  17216. // Gend: res.Output.Baseinfo.Gend,
  17217. // Naty: res.Output.Baseinfo.Naty,
  17218. // Brdy: res.Output.Baseinfo.Brdy,
  17219. // Age: res.Output.Baseinfo.Age,
  17220. // Iinfo: infoStr,
  17221. // Idetinfo: idetinfoStr,
  17222. // PatientId: patient.ID,
  17223. // RecordDate: theTime.Unix(),
  17224. // UserOrgId: adminInfo.CurrentOrgId,
  17225. // AdminUserId: adminInfo.AdminUser.Id,
  17226. // IsReturn: 1,
  17227. // }
  17228. //
  17229. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  17230. // //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")
  17231. // //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")
  17232. //
  17233. // //var dat map[string]interface{}
  17234. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17235. // // fmt.Println(dat)
  17236. // //} else {
  17237. // // fmt.Println(err)
  17238. // //}
  17239. //
  17240. // var dat2 map[string]interface{}
  17241. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17242. // fmt.Println(dat2)
  17243. // } else {
  17244. // fmt.Println(err)
  17245. // }
  17246. //
  17247. // } else {
  17248. // adminUser := c.GetAdminUserInfo()
  17249. // errlog := &models.HisOrderError{
  17250. // UserOrgId: adminUser.CurrentOrgId,
  17251. // Ctime: time.Now().Unix(),
  17252. // Mtime: time.Now().Unix(),
  17253. // ErrMsg: res.ErrMsg,
  17254. // Status: 1,
  17255. // PatientId: id,
  17256. // RecordTime: recordDateTime,
  17257. // Stage: 1,
  17258. // }
  17259. // service.CreateErrMsgLog(errlog)
  17260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17261. // return
  17262. // }
  17263. // }
  17264. //
  17265. //}
  17266. //func (c *HisApiController) GetUploadDiag() {
  17267. // id, _ := c.GetInt64("id")
  17268. // record_time := c.GetString("record_time")
  17269. //
  17270. // diagnosis_id, _ := c.GetInt64("diagnosis")
  17271. // sick_type, _ := c.GetInt64("sick_type")
  17272. // reg_type, _ := c.GetInt64("reg_type")
  17273. //
  17274. // timeLayout := "2006-01-02"
  17275. // loc, _ := time.LoadLocation("Local")
  17276. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17277. // if err != nil {
  17278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17279. // return
  17280. // }
  17281. //
  17282. // var patientPrescription models.HisPrescriptionInfo
  17283. // recordDateTime := theTime.Unix()
  17284. // adminInfo := c.GetAdminUserInfo()
  17285. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17286. //
  17287. // if patientPrescription.ID == 0 {
  17288. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17289. // }
  17290. //
  17291. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17292. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  17293. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17294. // sickConfig, _ := service.FindSickById(sick_type)
  17295. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17296. //
  17297. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  17298. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  17299. // "&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 +
  17300. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  17301. // resp2, requestErr2 := http.Get(api2)
  17302. // if requestErr2 != nil {
  17303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17304. // return
  17305. // }
  17306. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  17307. // if ioErr2 != nil {
  17308. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  17309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17310. // return
  17311. // }
  17312. // var respJSON2 map[string]interface{}
  17313. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  17314. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17316. // return
  17317. // }
  17318. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17319. // userJSONBytes2, _ := json.Marshal(respJSON2)
  17320. //
  17321. // var res2 ResultSix
  17322. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17323. // utils.ErrorLog("解析失败:%v", err)
  17324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17325. // return
  17326. // }
  17327. // if res2.Infcode != 0 {
  17328. // adminUser := c.GetAdminUserInfo()
  17329. // errlog := &models.HisOrderError{
  17330. // UserOrgId: adminUser.CurrentOrgId,
  17331. // Ctime: time.Now().Unix(),
  17332. // Mtime: time.Now().Unix(),
  17333. // ErrMsg: res2.ErrMsg,
  17334. // Status: 1,
  17335. // PatientId: id,
  17336. // RecordTime: recordDateTime,
  17337. // Stage: 3,
  17338. // }
  17339. // service.CreateErrMsgLog(errlog)
  17340. //
  17341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  17342. // return
  17343. // }
  17344. //
  17345. // c.ServeSuccessJSON(map[string]interface{}{
  17346. // "msg": "上传成功",
  17347. // })
  17348. //
  17349. //}
  17350. type QueryResult struct {
  17351. ID int64
  17352. Name string
  17353. Code string
  17354. List_type_code string
  17355. }
  17356. func (c *HisApiController) GetCheckCode() {
  17357. ids_str := c.GetString("ids")
  17358. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  17359. ids_arr := strings.Split(ids_str, ",")
  17360. var queryResult []QueryResult
  17361. ids := make([]int64, 0)
  17362. for _, item := range ids_arr {
  17363. id, _ := strconv.ParseInt(item, 10, 64)
  17364. ids = append(ids, id)
  17365. }
  17366. if record_type == 1 {
  17367. drugs, _ := service.GetBatchDrugList(ids)
  17368. for _, item := range drugs {
  17369. result := QueryResult{
  17370. ID: item.ID,
  17371. Name: item.DrugName,
  17372. Code: item.MedicalInsuranceNumber,
  17373. List_type_code: "101",
  17374. }
  17375. queryResult = append(queryResult, result)
  17376. }
  17377. } else if record_type == 2 {
  17378. goods, _ := service.GetBatchGoodInformationList(ids)
  17379. for _, item := range goods {
  17380. result := QueryResult{
  17381. ID: item.ID,
  17382. Name: item.GoodName,
  17383. Code: item.MedicalInsuranceNumber,
  17384. List_type_code: "301",
  17385. }
  17386. queryResult = append(queryResult, result)
  17387. }
  17388. } else if record_type == 3 {
  17389. projects, _ := service.GetBathchMyPorjecgList(ids)
  17390. for _, item := range projects {
  17391. result := QueryResult{
  17392. ID: item.ID,
  17393. Name: item.ProjectName,
  17394. Code: item.MedicalCode,
  17395. List_type_code: "201",
  17396. }
  17397. queryResult = append(queryResult, result)
  17398. }
  17399. }
  17400. admin_user_id, _ := c.GetInt64("admin_user_id")
  17401. adminUser := c.GetAdminUserInfo()
  17402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17403. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17404. var user_name string
  17405. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17406. if role.ID == 0 {
  17407. user_name = "xxx"
  17408. } else {
  17409. user_name = role.UserName
  17410. }
  17411. baseParams := &models.BaseParams{
  17412. SecretKey: miConfig.SecretKey,
  17413. FixmedinsCode: miConfig.Code,
  17414. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17415. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17416. OrgName: miConfig.OrgName,
  17417. Doctor: user_name,
  17418. }
  17419. if config.IsOpen == 1 {
  17420. for _, item := range queryResult {
  17421. var result string
  17422. if record_type == 1 {
  17423. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17424. } else if record_type == 2 {
  17425. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17426. } else if record_type == 3 {
  17427. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17428. }
  17429. var dat map[string]interface{}
  17430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17431. fmt.Println(dat)
  17432. } else {
  17433. fmt.Println(err)
  17434. }
  17435. userJSONBytes, _ := json.Marshal(dat)
  17436. var res ResultSix
  17437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17438. utils.ErrorLog("解析失败:%v", err)
  17439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17440. return
  17441. }
  17442. if res.Infcode == 0 {
  17443. if record_type == 1 {
  17444. service.UpdateBaseDrugById(item.ID)
  17445. } else if record_type == 2 {
  17446. service.UpdateGoodInformaitonByDetail(item.ID)
  17447. } else if record_type == 3 {
  17448. service.UpdateProjectById(item.ID)
  17449. }
  17450. c.ServeSuccessJSON(map[string]interface{}{
  17451. "failed_code": 0,
  17452. "msg": "目录对照成功",
  17453. })
  17454. } else {
  17455. c.ServeSuccessJSON(map[string]interface{}{
  17456. "failed_code": -10,
  17457. "msg": res.ErrMsg,
  17458. })
  17459. }
  17460. }
  17461. }
  17462. }
  17463. func (c *HisApiController) UnCheckCode() {
  17464. ids_str := c.GetString("ids")
  17465. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  17466. admin_user_id, _ := c.GetInt64("admin_user_id")
  17467. ids_arr := strings.Split(ids_str, ",")
  17468. var queryResult []QueryResult
  17469. ids := make([]int64, 0)
  17470. for _, item := range ids_arr {
  17471. id, _ := strconv.ParseInt(item, 10, 64)
  17472. ids = append(ids, id)
  17473. }
  17474. if record_type == 1 {
  17475. drugs, _ := service.GetBatchDrugList(ids)
  17476. for _, item := range drugs {
  17477. result := QueryResult{
  17478. ID: item.ID,
  17479. Name: item.DrugName,
  17480. Code: item.MedicalInsuranceNumber,
  17481. List_type_code: "101",
  17482. }
  17483. queryResult = append(queryResult, result)
  17484. }
  17485. } else if record_type == 2 {
  17486. goods, _ := service.GetBatchGoodInformationList(ids)
  17487. for _, item := range goods {
  17488. result := QueryResult{
  17489. ID: item.ID,
  17490. Name: item.GoodName,
  17491. Code: item.MedicalInsuranceNumber,
  17492. List_type_code: "301",
  17493. }
  17494. queryResult = append(queryResult, result)
  17495. }
  17496. } else if record_type == 3 {
  17497. projects, _ := service.GetBathchMyPorjecgList(ids)
  17498. for _, item := range projects {
  17499. result := QueryResult{
  17500. ID: item.ID,
  17501. Name: item.ProjectName,
  17502. Code: item.MedicalCode,
  17503. List_type_code: "201",
  17504. }
  17505. queryResult = append(queryResult, result)
  17506. }
  17507. }
  17508. adminUser := c.GetAdminUserInfo()
  17509. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17510. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17511. var user_name string
  17512. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17513. if role.ID == 0 {
  17514. user_name = "xxx"
  17515. } else {
  17516. user_name = role.UserName
  17517. }
  17518. baseParams := &models.BaseParams{
  17519. SecretKey: miConfig.SecretKey,
  17520. FixmedinsCode: miConfig.Code,
  17521. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17522. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17523. OrgName: miConfig.OrgName,
  17524. Doctor: user_name,
  17525. }
  17526. if config.IsOpen == 1 {
  17527. for _, item := range queryResult {
  17528. var result string
  17529. if record_type == 1 {
  17530. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17531. } else if record_type == 2 {
  17532. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17533. } else if record_type == 3 {
  17534. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17535. }
  17536. var dat2 map[string]interface{}
  17537. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  17538. fmt.Println(dat2)
  17539. } else {
  17540. fmt.Println(err)
  17541. }
  17542. userJSONBytes, _ := json.Marshal(dat2)
  17543. var res ResultSix
  17544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17545. utils.ErrorLog("解析失败:%v", err)
  17546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17547. return
  17548. }
  17549. if res.Infcode == 0 {
  17550. if record_type == 1 {
  17551. service.UpdateDrugByIdDetail(item.ID)
  17552. } else if record_type == 2 {
  17553. service.UpdateGoodInfoById(item.ID)
  17554. } else if record_type == 3 {
  17555. service.UpdateMyProjectById(item.ID)
  17556. }
  17557. c.ServeSuccessJSON(map[string]interface{}{
  17558. "failed_code": 0,
  17559. "msg": "撤销目录对照成功",
  17560. })
  17561. } else {
  17562. c.ServeSuccessJSON(map[string]interface{}{
  17563. "failed_code": -10,
  17564. "msg": res.ErrMsg,
  17565. })
  17566. }
  17567. }
  17568. }
  17569. }
  17570. func (c *HisApiController) GetPatientInfo() {
  17571. id_card_no := c.GetString("id_card_no")
  17572. admin_user_id, _ := c.GetInt64("admin_user_id")
  17573. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  17574. if patient.ID == 0 {
  17575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17576. return
  17577. }
  17578. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17579. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17580. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  17581. if config.IsOpen == 1 {
  17582. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  17583. var dat map[string]interface{}
  17584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17585. fmt.Println(dat)
  17586. } else {
  17587. fmt.Println(err)
  17588. }
  17589. userJSONBytes, _ := json.Marshal(dat)
  17590. var res ResultTwo
  17591. var res10265 ResultTwo10265
  17592. if miConfig.Code == "H15049901371" {
  17593. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  17594. utils.ErrorLog("解析失败:%v", err)
  17595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17596. return
  17597. }
  17598. res.ErrMsg = res10265.ErrMsg
  17599. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17600. res.Infcode = infocode
  17601. res.Output = res10265.Output
  17602. res.InfRefmsgid = res10265.InfRefmsgid
  17603. } else {
  17604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17605. utils.ErrorLog("解析失败:%v", err)
  17606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17607. return
  17608. }
  17609. }
  17610. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17611. // utils.ErrorLog("解析失败:%v", err)
  17612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17613. // return
  17614. //}
  17615. for index, item := range res.Output.Iinfo {
  17616. if item.PsnInsuStas == "2" {
  17617. fmt.Println("--------")
  17618. res.Output.Iinfo[index].Insutype = "300"
  17619. res.Output.Iinfo[index].PsnInsuStas = "1"
  17620. }
  17621. }
  17622. fmt.Println(res.Output.Iinfo)
  17623. if res.Infcode != 0 {
  17624. c.ServeSuccessJSON(map[string]interface{}{
  17625. "failed_code": -10,
  17626. "msg": res.ErrMsg,
  17627. })
  17628. } else {
  17629. c.ServeSuccessJSON(map[string]interface{}{
  17630. "failed_code": 0,
  17631. "info": res,
  17632. })
  17633. }
  17634. }
  17635. }
  17636. func (c *HisApiController) PsnPutOnRecord() {
  17637. record_type, _ := c.GetInt64("type")
  17638. patient_id, _ := c.GetInt64("patient_id")
  17639. admin_user_id, _ := c.GetInt64("admin_user_id")
  17640. start_time := c.GetString("start_time")
  17641. end_time := c.GetString("end_time")
  17642. adminUser := c.GetAdminUserInfo()
  17643. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17644. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17645. var patients []*models.Patients
  17646. if record_type == 1 { //全部备案
  17647. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  17648. patients = append(patients, patient...)
  17649. } else { //单个备案
  17650. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  17651. patients = append(patients, patient)
  17652. }
  17653. var user_name string
  17654. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17655. if role.ID == 0 {
  17656. user_name = "xxx"
  17657. } else {
  17658. user_name = role.UserName
  17659. }
  17660. if config.IsOpen == 1 {
  17661. for _, item := range patients {
  17662. 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
  17663. resp, requestErr := http.Get(api)
  17664. if requestErr != nil {
  17665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17666. return
  17667. }
  17668. defer resp.Body.Close()
  17669. body, ioErr := ioutil.ReadAll(resp.Body)
  17670. if ioErr != nil {
  17671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17673. return
  17674. }
  17675. var respJSON map[string]interface{}
  17676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17679. return
  17680. }
  17681. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17682. userJSONBytes, _ := json.Marshal(userJSON)
  17683. var res ResultTwo
  17684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17685. utils.ErrorLog("解析失败:%v", err)
  17686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17687. return
  17688. }
  17689. if res.Infcode == 0 {
  17690. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  17691. var dat map[string]interface{}
  17692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17693. fmt.Println(dat)
  17694. } else {
  17695. fmt.Println(err)
  17696. }
  17697. userJSONBytes, _ := json.Marshal(dat)
  17698. var res2 ResultThirteen
  17699. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17700. utils.ErrorLog("解析失败:%v", err)
  17701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17702. return
  17703. }
  17704. if res2.Infcode == 0 {
  17705. psnResult := &models.GdybPsnRecord{
  17706. UserOrgId: adminUser.CurrentOrgId,
  17707. PatientId: item.ID,
  17708. PsnNo: res.Output.Baseinfo.PsnNo,
  17709. Ctime: time.Now().Unix(),
  17710. Mtime: time.Now().Unix(),
  17711. Status: 1,
  17712. IsCancel: 1,
  17713. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  17714. }
  17715. service.CreatePsnRecord(psnResult)
  17716. } else {
  17717. c.ServeSuccessJSON(map[string]interface{}{
  17718. "failed_code": -10,
  17719. "msg": res2.ErrMsg,
  17720. })
  17721. return
  17722. }
  17723. }
  17724. }
  17725. }
  17726. }
  17727. func (c *HisApiController) PsnUnPutOnRecord() {
  17728. id, _ := c.GetInt64("id")
  17729. //record_type, _ := c.GetInt64("type")
  17730. admin_user_id, _ := c.GetInt64("admin_user_id")
  17731. adminUser := c.GetAdminUserInfo()
  17732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17733. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17734. var user_name string
  17735. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17736. if role.ID == 0 {
  17737. user_name = "xxx"
  17738. } else {
  17739. user_name = role.UserName
  17740. }
  17741. psn_record, _ := service.GetPsnRecordById(id)
  17742. if psn_record.ID == 0 {
  17743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  17744. return
  17745. }
  17746. if config.IsOpen == 1 {
  17747. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  17748. var dat map[string]interface{}
  17749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17750. fmt.Println(dat)
  17751. } else {
  17752. fmt.Println(err)
  17753. }
  17754. userJSONBytes, _ := json.Marshal(dat)
  17755. var res ResultFourteen
  17756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17757. utils.ErrorLog("解析失败:%v", err)
  17758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17759. return
  17760. }
  17761. if res.Infcode == 0 {
  17762. psn_record.IsCancel = 2
  17763. service.CreatePsnRecord(&psn_record)
  17764. } else {
  17765. c.ServeSuccessJSON(map[string]interface{}{
  17766. "failed_code": -10,
  17767. "msg": res.ErrMsg,
  17768. })
  17769. return
  17770. }
  17771. }
  17772. }
  17773. func (c *HisApiController) PsnPutNCDSOnRecord() {
  17774. patient_id, _ := c.GetInt64("patient_id")
  17775. insutype_two := c.GetString("insutype")
  17776. psn_no := c.GetString("psn_no")
  17777. doctor_id, _ := c.GetInt64("doctor_id")
  17778. sick_id, _ := c.GetInt64("sick_id")
  17779. department_id, _ := c.GetInt64("department_id")
  17780. start_time := c.GetString("start_time")
  17781. end_time := c.GetString("end_time")
  17782. check_time := c.GetString("check_time")
  17783. hospital_code := c.GetString("hospital_code")
  17784. hospital_name := c.GetString("hospital_name")
  17785. adminUser := c.GetAdminUserInfo()
  17786. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  17787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17789. sick, _ := service.FindSickById(sick_id)
  17790. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  17791. if len(hospital_code) == 0 {
  17792. hospital_code = miConfig.Code
  17793. }
  17794. if len(hospital_name) == 0 {
  17795. hospital_name = miConfig.OrgName
  17796. }
  17797. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  17798. var res ResultTwo
  17799. var res10265 ResultTwo10265
  17800. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17801. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  17802. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  17803. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  17804. "&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
  17805. resp, requestErr := http.Get(api)
  17806. if requestErr != nil {
  17807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17808. return
  17809. }
  17810. body, ioErr := ioutil.ReadAll(resp.Body)
  17811. if ioErr != nil {
  17812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17814. return
  17815. }
  17816. var respJSON map[string]interface{}
  17817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17820. return
  17821. }
  17822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17823. result, _ := json.Marshal(respJSON)
  17824. fmt.Println("log")
  17825. fmt.Println(string(result))
  17826. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17827. utils.ErrorLog("解析失败:%v", err)
  17828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17829. return
  17830. }
  17831. res.ErrMsg = res10265.ErrMsg
  17832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17833. res.Infcode = infocode
  17834. res.Output = res10265.Output
  17835. res.InfRefmsgid = res10265.InfRefmsgid
  17836. } else {
  17837. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  17838. if miConfig.Code == "H15049901371" {
  17839. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17840. utils.ErrorLog("解析失败:%v", err)
  17841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17842. return
  17843. }
  17844. res.ErrMsg = res10265.ErrMsg
  17845. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17846. res.Infcode = infocode
  17847. res.Output = res10265.Output
  17848. res.InfRefmsgid = res10265.InfRefmsgid
  17849. } else {
  17850. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17851. utils.ErrorLog("解析失败:%v", err)
  17852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17853. return
  17854. }
  17855. }
  17856. }
  17857. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17858. infoStr := string(Iinfos)
  17859. var rf []*ResultFive
  17860. json.Unmarshal([]byte(infoStr), &rf)
  17861. var insuplc_admdvs string
  17862. var insutype string
  17863. var is390 int = 0
  17864. var is310 int = 0
  17865. var insutypes []*ResultFive
  17866. for _, item := range rf {
  17867. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17868. insutypes = append(insutypes, item)
  17869. }
  17870. }
  17871. if len(insutypes) == 1 {
  17872. insutype = insutypes[0].Insutype
  17873. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17874. } else {
  17875. for _, i := range insutypes {
  17876. if i.Insutype == "390" {
  17877. is390 = 1
  17878. }
  17879. if i.Insutype == "310" {
  17880. is310 = 1
  17881. }
  17882. }
  17883. }
  17884. if is390 == 1 {
  17885. insutype = "390"
  17886. }
  17887. if is310 == 1 {
  17888. insutype = "310"
  17889. }
  17890. if len(insutypes) == 2 {
  17891. insutype = insutype_two
  17892. }
  17893. if len(insutypes) == 0 {
  17894. insutype = "310"
  17895. }
  17896. insutype = insutype_two
  17897. fmt.Println(insutype)
  17898. for _, item := range rf {
  17899. fmt.Println(item.Insutype)
  17900. fmt.Println(insutype)
  17901. if item.Insutype == insutype {
  17902. fmt.Println(item.Insutype)
  17903. fmt.Println(insutype)
  17904. insuplc_admdvs = item.InsuplcAdmdvs
  17905. }
  17906. }
  17907. fmt.Println(insuplc_admdvs)
  17908. var res2 ResultThirteen
  17909. var res10265_2 ResultThirteen10265
  17910. if config.IsOpen == 1 {
  17911. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17912. } else {
  17913. 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)
  17914. var dat map[string]interface{}
  17915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17916. fmt.Println(dat)
  17917. } else {
  17918. fmt.Println(err)
  17919. }
  17920. userJSONBytes, _ := json.Marshal(dat)
  17921. if miConfig.Code == "H15049901371" {
  17922. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  17923. utils.ErrorLog("解析失败:%v", err)
  17924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17925. return
  17926. }
  17927. res2.ErrMsg = res10265_2.ErrMsg
  17928. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  17929. res2.Infcode = infocode
  17930. res2.Output = res10265_2.Output
  17931. res2.InfRefmsgid = res10265_2.InfRefmsgid
  17932. } else {
  17933. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17934. utils.ErrorLog("解析失败:%v", err)
  17935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17936. return
  17937. }
  17938. }
  17939. }
  17940. if res2.Infcode == 0 {
  17941. psnResult := &models.GdybPsnNcdsRecord{
  17942. UserOrgId: adminUser.CurrentOrgId,
  17943. PatientId: patient.ID,
  17944. PsnNo: psn_no,
  17945. DoctorId: doctor.AdminUserId,
  17946. DepartmentId: department_id,
  17947. SickType: sick_id,
  17948. Insutype: insutype,
  17949. Ctime: time.Now().Unix(),
  17950. Mtime: time.Now().Unix(),
  17951. Status: 1,
  17952. IsCancel: 1,
  17953. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  17954. }
  17955. service.CreatePsnNCDSRecord(psnResult)
  17956. c.ServeSuccessJSON(map[string]interface{}{
  17957. "failed_code": 0,
  17958. "msg": "备案成功",
  17959. "result": psnResult,
  17960. })
  17961. } else {
  17962. c.ServeSuccessJSON(map[string]interface{}{
  17963. "failed_code": -10,
  17964. "msg": res2.ErrMsg,
  17965. })
  17966. return
  17967. }
  17968. }
  17969. }
  17970. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  17971. id, _ := c.GetInt64("id")
  17972. admin_user_id, _ := c.GetInt64("admin_user_id")
  17973. adminUser := c.GetAdminUserInfo()
  17974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17975. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17976. //config, _ := service.Ge(adminUser.CurrentOrgId)
  17977. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  17978. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17979. //var user_name string
  17980. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17981. //if role.ID == 0 {
  17982. // user_name = "xxx"
  17983. //} else {
  17984. // user_name = role.UserName
  17985. //}
  17986. psn_record, _ := service.GetPsnNCDSRecordById(id)
  17987. if psn_record.ID == 0 {
  17988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  17989. return
  17990. }
  17991. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  17992. var res ResultTwo
  17993. var res10265 ResultTwo10265
  17994. if miConfig.Code == "H15049901371" {
  17995. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17996. utils.ErrorLog("解析失败:%v", err)
  17997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17998. return
  17999. }
  18000. res.ErrMsg = res10265.ErrMsg
  18001. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18002. res.Infcode = infocode
  18003. res.Output = res10265.Output
  18004. res.InfRefmsgid = res10265.InfRefmsgid
  18005. } else {
  18006. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18007. utils.ErrorLog("解析失败:%v", err)
  18008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18009. return
  18010. }
  18011. }
  18012. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18013. infoStr := string(Iinfos)
  18014. var rf []*ResultFive
  18015. json.Unmarshal([]byte(infoStr), &rf)
  18016. var insuplc_admdvs string
  18017. var insutype string
  18018. var is390 int = 0
  18019. var is310 int = 0
  18020. var insutypes []*ResultFive
  18021. for _, item := range rf {
  18022. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18023. insutypes = append(insutypes, item)
  18024. }
  18025. }
  18026. if len(insutypes) == 1 {
  18027. insutype = insutypes[0].Insutype
  18028. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18029. } else {
  18030. for _, i := range insutypes {
  18031. if i.Insutype == "390" {
  18032. is390 = 1
  18033. }
  18034. if i.Insutype == "310" {
  18035. is310 = 1
  18036. }
  18037. }
  18038. }
  18039. if is390 == 1 {
  18040. insutype = "390"
  18041. }
  18042. if is310 == 1 {
  18043. insutype = "310"
  18044. }
  18045. if len(insutypes) == 0 {
  18046. insutype = "310"
  18047. }
  18048. insutype = psn_record.Insutype
  18049. for _, item := range rf {
  18050. if item.Insutype == insutype {
  18051. insuplc_admdvs = item.InsuplcAdmdvs
  18052. }
  18053. }
  18054. if config.IsOpen == 1 {
  18055. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  18056. var dat map[string]interface{}
  18057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18058. fmt.Println(dat)
  18059. } else {
  18060. fmt.Println(err)
  18061. }
  18062. userJSONBytes, _ := json.Marshal(dat)
  18063. var res ResultFourteen
  18064. var res10265 ResultFourteen10265
  18065. if miConfig.Code == "H15049901371" {
  18066. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  18067. utils.ErrorLog("解析失败:%v", err)
  18068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18069. return
  18070. }
  18071. res.ErrMsg = res10265.ErrMsg
  18072. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18073. res.Infcode = infocode
  18074. res.Output = res10265.Output
  18075. res.InfRefmsgid = res10265.InfRefmsgid
  18076. } else {
  18077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18078. utils.ErrorLog("解析失败:%v", err)
  18079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18080. return
  18081. }
  18082. }
  18083. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18084. // utils.ErrorLog("解析失败:%v", err)
  18085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18086. // return
  18087. //}
  18088. if res.Infcode == 0 {
  18089. psn_record.IsCancel = 2
  18090. service.CreatePsnNCDSRecord(&psn_record)
  18091. c.ServeSuccessJSON(map[string]interface{}{
  18092. "failed_code": 0,
  18093. "msg": "撤销备案成功",
  18094. })
  18095. } else {
  18096. c.ServeSuccessJSON(map[string]interface{}{
  18097. "failed_code": -10,
  18098. "msg": res.ErrMsg,
  18099. })
  18100. return
  18101. }
  18102. }
  18103. }
  18104. func (c *HisApiController) TestTest() {
  18105. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  18106. fmt.Println(patient.Iinfo)
  18107. }
  18108. type CustomData struct {
  18109. MsgId string
  18110. PsnNo string
  18111. Info string
  18112. }
  18113. func (c *HisApiController) ReversalData() {
  18114. var customData []*CustomData
  18115. custom := &CustomData{
  18116. MsgId: "H44022900158202103301714472004",
  18117. PsnNo: "44020000001101329945",
  18118. Info: "2207",
  18119. }
  18120. customData = append(customData, custom)
  18121. custom1 := &CustomData{
  18122. MsgId: "H4402290015820210330172057803",
  18123. PsnNo: "44020000001101161813",
  18124. Info: "2207",
  18125. }
  18126. customData = append(customData, custom1)
  18127. custom2 := &CustomData{
  18128. MsgId: "H44022900158202103301705198813",
  18129. PsnNo: "44190000133097375417",
  18130. Info: "2207",
  18131. }
  18132. customData = append(customData, custom2)
  18133. custom3 := &CustomData{
  18134. MsgId: "H44022900158202103301715524756",
  18135. PsnNo: "44020000001100187221",
  18136. Info: "2207",
  18137. }
  18138. customData = append(customData, custom3)
  18139. custom4 := &CustomData{
  18140. MsgId: "H44022900158202103301730376224",
  18141. PsnNo: "44020000001101959155",
  18142. Info: "2207",
  18143. }
  18144. customData = append(customData, custom4)
  18145. custom5 := &CustomData{
  18146. MsgId: "H44022900158202103301748008725",
  18147. PsnNo: "44020000001104246641",
  18148. Info: "2207",
  18149. }
  18150. customData = append(customData, custom5)
  18151. custom6 := &CustomData{
  18152. MsgId: "H44022900158202103301718096755",
  18153. PsnNo: "44020000001102211860",
  18154. Info: "2207",
  18155. }
  18156. customData = append(customData, custom6)
  18157. custom7 := &CustomData{
  18158. MsgId: "H44022900158202103301736551640",
  18159. PsnNo: "44020000001102687718",
  18160. Info: "2207",
  18161. }
  18162. customData = append(customData, custom7)
  18163. custom8 := &CustomData{
  18164. MsgId: "H44022900158202103301743097676",
  18165. PsnNo: "44020000001102127785",
  18166. Info: "2207",
  18167. }
  18168. customData = append(customData, custom8)
  18169. custom9 := &CustomData{
  18170. MsgId: "H44022900158202103301712304203",
  18171. PsnNo: "44020000001101518097",
  18172. Info: "2207",
  18173. }
  18174. customData = append(customData, custom9)
  18175. custom10 := &CustomData{
  18176. MsgId: "H44022900158202103301738448785",
  18177. PsnNo: "44020000001100500813",
  18178. Info: "2207",
  18179. }
  18180. customData = append(customData, custom10)
  18181. custom11 := &CustomData{
  18182. MsgId: "H44022900158202103301732455843",
  18183. PsnNo: "44020000001102690557",
  18184. Info: "2207",
  18185. }
  18186. customData = append(customData, custom11)
  18187. custom12 := &CustomData{
  18188. MsgId: "H44022900158202103301745421708",
  18189. PsnNo: "44020000001102211928",
  18190. Info: "2207",
  18191. }
  18192. customData = append(customData, custom12)
  18193. custom1212 := &CustomData{
  18194. MsgId: "H440229001582021033017351627",
  18195. PsnNo: "44020000001102481733",
  18196. Info: "2207",
  18197. }
  18198. customData = append(customData, custom1212)
  18199. custom13 := &CustomData{
  18200. MsgId: "H44022900158202103301740327951",
  18201. PsnNo: "44020000001103174866",
  18202. Info: "2207",
  18203. }
  18204. customData = append(customData, custom13)
  18205. custom14 := &CustomData{
  18206. MsgId: "H4402290015820210330174922668",
  18207. PsnNo: "44020000001102927272",
  18208. Info: "2207",
  18209. }
  18210. customData = append(customData, custom14)
  18211. custom15 := &CustomData{
  18212. MsgId: "H44022900158202103301752362273",
  18213. PsnNo: "44020000001102942890",
  18214. Info: "2207",
  18215. }
  18216. customData = append(customData, custom15)
  18217. custom16 := &CustomData{
  18218. MsgId: "H44022900158202103301751082917",
  18219. PsnNo: "44020000001101662162",
  18220. Info: "2207",
  18221. }
  18222. customData = append(customData, custom16)
  18223. custom17 := &CustomData{
  18224. MsgId: "H44022900158202103301754147728",
  18225. PsnNo: "44020000000229014511",
  18226. Info: "2207",
  18227. }
  18228. customData = append(customData, custom17)
  18229. adminUser := c.GetAdminUserInfo()
  18230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18231. for _, item := range customData {
  18232. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  18233. fmt.Println(result)
  18234. }
  18235. }
  18236. func (c *HisApiController) GetAllopatry() {
  18237. year := c.GetString("year")
  18238. month := c.GetString("month")
  18239. admin_user_id, _ := c.GetInt64("admin_user_id")
  18240. adminUser := c.GetAdminUserInfo()
  18241. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18242. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18243. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18244. var dat map[string]interface{}
  18245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18246. fmt.Println(dat)
  18247. } else {
  18248. fmt.Println(err)
  18249. }
  18250. userJSONBytes, _ := json.Marshal(dat)
  18251. var res models.Result9001
  18252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18253. utils.ErrorLog("解析失败:%v", err)
  18254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18255. return
  18256. }
  18257. fmt.Println(res.Output.Signinoutb)
  18258. fmt.Println(res.Output.Signinoutb.SignNo)
  18259. fmt.Println(string(userJSONBytes))
  18260. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  18261. var dat3 map[string]interface{}
  18262. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  18263. fmt.Println(dat3)
  18264. } else {
  18265. fmt.Println(err)
  18266. }
  18267. userJSONBytes3, _ := json.Marshal(dat3)
  18268. var res3 models.Result3260
  18269. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  18270. utils.ErrorLog("解析失败:%v", err)
  18271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18272. return
  18273. }
  18274. var curpage int
  18275. var pagesize int = 100
  18276. var start int = 1
  18277. //var stop int
  18278. //pagecount := 10
  18279. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  18280. for curpage = 1; curpage <= pagecount; curpage++ {
  18281. if curpage == 1 {
  18282. start = 0
  18283. } else {
  18284. start = (curpage-1)*pagesize + 1
  18285. }
  18286. fmt.Println(start)
  18287. //stop = curpage * pagesize
  18288. //if stop > int(res3.Output.Totalrow) {
  18289. // stop =int(res3.Output.Totalrow)
  18290. //}
  18291. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  18292. var dat2 map[string]interface{}
  18293. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18294. fmt.Println(dat)
  18295. } else {
  18296. fmt.Println(err)
  18297. }
  18298. userJSONBytes2, _ := json.Marshal(dat2)
  18299. var res2 models.Result3260
  18300. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18301. utils.ErrorLog("解析失败:%v", err)
  18302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18303. return
  18304. }
  18305. if res2.Infcode == 0 {
  18306. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18307. var dat2 map[string]interface{}
  18308. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  18309. fmt.Println(dat)
  18310. } else {
  18311. fmt.Println(err)
  18312. }
  18313. //c.ServeSuccessJSON(map[string]interface{}{
  18314. // "list": res2.Output.Data,
  18315. //})
  18316. //continue
  18317. }
  18318. }
  18319. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  18320. //var dat2 map[string]interface{}
  18321. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18322. // fmt.Println(dat)
  18323. //} else {
  18324. // fmt.Println(err)
  18325. //}
  18326. //userJSONBytes2, _ := json.Marshal(dat2)
  18327. //var res2 models.Result3260
  18328. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18329. // utils.ErrorLog("解析失败:%v", err)
  18330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18331. // return
  18332. //}
  18333. //if res2.Infcode == 0 {
  18334. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18335. // var dat2 map[string]interface{}
  18336. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  18337. // fmt.Println(dat)
  18338. // } else {
  18339. // fmt.Println(err)
  18340. // }
  18341. // c.ServeSuccessJSON(map[string]interface{}{
  18342. // "list": res2.Output.Data,
  18343. // })
  18344. //}
  18345. }
  18346. func (c *HisApiController) ComfirmAllopatry() {
  18347. year := c.GetString("year")
  18348. month := c.GetString("month")
  18349. admin_user_id, _ := c.GetInt64("admin_user_id")
  18350. adminUser := c.GetAdminUserInfo()
  18351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18352. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18353. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18354. var dat map[string]interface{}
  18355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18356. fmt.Println(dat)
  18357. } else {
  18358. fmt.Println(err)
  18359. }
  18360. userJSONBytes, _ := json.Marshal(dat)
  18361. var res models.Result9001
  18362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18363. utils.ErrorLog("解析失败:%v", err)
  18364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18365. return
  18366. }
  18367. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  18368. var dat2 map[string]interface{}
  18369. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18370. fmt.Println(dat)
  18371. } else {
  18372. fmt.Println(err)
  18373. }
  18374. userJSONBytes2, _ := json.Marshal(dat2)
  18375. var res2 models.Result3260
  18376. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18377. utils.ErrorLog("解析失败:%v", err)
  18378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18379. return
  18380. }
  18381. //if res2.Infcode == 0 {
  18382. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18383. // var dat map[string]interface{}
  18384. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18385. // fmt.Println(dat)
  18386. // } else {
  18387. // fmt.Println(err)
  18388. // }
  18389. // userJSONBytes, _ := json.Marshal(dat)
  18390. // var res3 models.Result3261
  18391. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  18392. // utils.ErrorLog("解析失败:%v", err)
  18393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18394. // return
  18395. // }
  18396. //
  18397. // if res3.Infcode == 0 {
  18398. // record := &models.HisYidiClearRecord{
  18399. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18400. // Ctime: time.Now().Unix(),
  18401. // Mtime: time.Now().Unix(),
  18402. // Status: 1,
  18403. // MsgId: msgId,
  18404. // }
  18405. // service.SaveClearRecord(record)
  18406. // c.ServeSuccessJSON(map[string]interface{}{
  18407. // "msg": "提取成功",
  18408. // })
  18409. // }
  18410. //}
  18411. }
  18412. func (c *HisApiController) RefundAllopatry() {
  18413. year := c.GetString("year")
  18414. month := c.GetString("month")
  18415. //id, _ := c.GetInt64("id")
  18416. admin_user_id, _ := c.GetInt64("admin_user_id")
  18417. adminUser := c.GetAdminUserInfo()
  18418. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18419. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18420. //record, _ := service.GetClearRecordById(id)
  18421. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18422. var dat map[string]interface{}
  18423. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18424. fmt.Println(dat)
  18425. } else {
  18426. fmt.Println(err)
  18427. }
  18428. userJSONBytes, _ := json.Marshal(dat)
  18429. var res models.Result9001
  18430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18431. utils.ErrorLog("解析失败:%v", err)
  18432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18433. return
  18434. }
  18435. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  18436. var dat2 map[string]interface{}
  18437. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  18438. fmt.Println(dat)
  18439. } else {
  18440. fmt.Println(err)
  18441. }
  18442. userJSONBytes2, _ := json.Marshal(dat2)
  18443. var empty ResultFourteen
  18444. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  18445. utils.ErrorLog("解析失败:%v", err)
  18446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18447. return
  18448. }
  18449. if empty.Infcode == 0 {
  18450. c.ServeSuccessJSON(map[string]interface{}{
  18451. "msg": "撤销成功",
  18452. })
  18453. return
  18454. }
  18455. }
  18456. func (c *HisApiController) ReversalOtherData() {
  18457. var customData []*CustomData
  18458. custom := &CustomData{
  18459. MsgId: "H44022900158202103301714472004",
  18460. PsnNo: "44020000001101329945",
  18461. Info: "2208",
  18462. }
  18463. customData = append(customData, custom)
  18464. custom1 := &CustomData{
  18465. MsgId: "H4402290015820210330172057803",
  18466. PsnNo: "44020000001101161813",
  18467. Info: "2208",
  18468. }
  18469. customData = append(customData, custom1)
  18470. custom2 := &CustomData{
  18471. MsgId: "H44022900158202103301705198813",
  18472. PsnNo: "44190000133097375417",
  18473. Info: "2208",
  18474. }
  18475. customData = append(customData, custom2)
  18476. custom3 := &CustomData{
  18477. MsgId: "H44022900158202103301715524756",
  18478. PsnNo: "44020000001100187221",
  18479. Info: "2208",
  18480. }
  18481. customData = append(customData, custom3)
  18482. custom4 := &CustomData{
  18483. MsgId: "H44022900158202103301730376224",
  18484. PsnNo: "44020000001101959155",
  18485. Info: "2208",
  18486. }
  18487. customData = append(customData, custom4)
  18488. custom5 := &CustomData{
  18489. MsgId: "H44022900158202103301748008725",
  18490. PsnNo: "44020000001104246641",
  18491. Info: "2208",
  18492. }
  18493. customData = append(customData, custom5)
  18494. custom6 := &CustomData{
  18495. MsgId: "H44022900158202103301718096755",
  18496. PsnNo: "44020000001102211860",
  18497. Info: "2208",
  18498. }
  18499. customData = append(customData, custom6)
  18500. custom7 := &CustomData{
  18501. MsgId: "H44022900158202103301736551640",
  18502. PsnNo: "44020000001102687718",
  18503. Info: "2208",
  18504. }
  18505. customData = append(customData, custom7)
  18506. custom8 := &CustomData{
  18507. MsgId: "H44022900158202103301743097676",
  18508. PsnNo: "44020000001102127785",
  18509. Info: "2208",
  18510. }
  18511. customData = append(customData, custom8)
  18512. custom9 := &CustomData{
  18513. MsgId: "H44022900158202103301712304203",
  18514. PsnNo: "44020000001101518097",
  18515. Info: "2208",
  18516. }
  18517. customData = append(customData, custom9)
  18518. custom10 := &CustomData{
  18519. MsgId: "H44022900158202103301738448785",
  18520. PsnNo: "44020000001100500813",
  18521. Info: "2208",
  18522. }
  18523. customData = append(customData, custom10)
  18524. custom11 := &CustomData{
  18525. MsgId: "H44022900158202103301732455843",
  18526. PsnNo: "44020000001102690557",
  18527. Info: "2208",
  18528. }
  18529. customData = append(customData, custom11)
  18530. custom12 := &CustomData{
  18531. MsgId: "H44022900158202103301745421708",
  18532. PsnNo: "44020000001102211928",
  18533. Info: "2208",
  18534. }
  18535. customData = append(customData, custom12)
  18536. custom1212 := &CustomData{
  18537. MsgId: "H440229001582021033017351627",
  18538. PsnNo: "44020000001102481733",
  18539. Info: "2208",
  18540. }
  18541. customData = append(customData, custom1212)
  18542. custom13 := &CustomData{
  18543. MsgId: "H44022900158202103301740327951",
  18544. PsnNo: "44020000001103174866",
  18545. Info: "2208",
  18546. }
  18547. customData = append(customData, custom13)
  18548. custom14 := &CustomData{
  18549. MsgId: "H4402290015820210330174922668",
  18550. PsnNo: "44020000001102927272",
  18551. Info: "2208",
  18552. }
  18553. customData = append(customData, custom14)
  18554. custom15 := &CustomData{
  18555. MsgId: "H44022900158202103301752362273",
  18556. PsnNo: "44020000001102942890",
  18557. Info: "2208",
  18558. }
  18559. customData = append(customData, custom15)
  18560. custom16 := &CustomData{
  18561. MsgId: "H44022900158202103301751082917",
  18562. PsnNo: "44020000001101662162",
  18563. Info: "2208",
  18564. }
  18565. customData = append(customData, custom16)
  18566. custom17 := &CustomData{
  18567. MsgId: "H44022900158202103301754147728",
  18568. PsnNo: "44020000000229014511",
  18569. Info: "2208",
  18570. }
  18571. customData = append(customData, custom17)
  18572. adminUser := c.GetAdminUserInfo()
  18573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18574. for _, item := range customData {
  18575. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  18576. fmt.Println(result)
  18577. }
  18578. }
  18579. func PathExists(path string) (bool, error) {
  18580. _, err := os.Stat(path)
  18581. if err == nil {
  18582. return true, nil
  18583. }
  18584. if os.IsNotExist(err) {
  18585. return false, nil
  18586. }
  18587. return false, err
  18588. }
  18589. // 创建文件夹
  18590. func Mkdir(dir string) {
  18591. // 创建文件夹
  18592. exist, err := PathExists(dir)
  18593. if err != nil {
  18594. fmt.Println(err.Error())
  18595. } else {
  18596. if exist {
  18597. fmt.Println(dir + "文件夹已存在!")
  18598. } else {
  18599. // 文件夹名称,权限
  18600. err := os.Mkdir(dir, os.ModePerm)
  18601. if err != nil {
  18602. fmt.Println(dir+"文件夹创建失败:", err.Error())
  18603. } else {
  18604. fmt.Println(dir + "文件夹创建成功!")
  18605. }
  18606. }
  18607. }
  18608. }
  18609. // 压缩文件
  18610. func Zip(srcFile string, destZip string) error {
  18611. zipfile, err := os.Create(destZip)
  18612. if err != nil {
  18613. return err
  18614. }
  18615. defer zipfile.Close()
  18616. archive := zip.NewWriter(zipfile)
  18617. defer archive.Close()
  18618. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  18619. if err != nil {
  18620. return err
  18621. }
  18622. header, err := zip.FileInfoHeader(info)
  18623. if err != nil {
  18624. return err
  18625. }
  18626. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  18627. // header.Name = path
  18628. if info.IsDir() {
  18629. header.Name += "/"
  18630. } else {
  18631. header.Method = zip.Deflate
  18632. }
  18633. writer, err := archive.CreateHeader(header)
  18634. if err != nil {
  18635. return err
  18636. }
  18637. if !info.IsDir() {
  18638. file, err := os.Open(path)
  18639. if err != nil {
  18640. return err
  18641. }
  18642. defer file.Close()
  18643. _, err = io.Copy(writer, file)
  18644. }
  18645. return err
  18646. })
  18647. return err
  18648. }
  18649. func ReadFile(filePath string) []byte {
  18650. f, err := os.Open(filePath)
  18651. if err != nil {
  18652. fmt.Println("read file fail", err)
  18653. return nil
  18654. }
  18655. defer f.Close()
  18656. fd, err := ioutil.ReadAll(f)
  18657. if err != nil {
  18658. fmt.Println("read to fd fail", err)
  18659. return nil
  18660. }
  18661. return fd
  18662. }
  18663. func saveLog(result string, request string, infno string, desc string) {
  18664. org_id, _ := beego.AppConfig.Int64("org_id")
  18665. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18666. dir := miConfig.OrgName + "日志"
  18667. utils.Mkdir(dir)
  18668. month := time.Unix(1557042972, 0).Format("1")
  18669. year := time.Now().Format("2006")
  18670. month = time.Now().Format("01")
  18671. day := time.Now().Format("02")
  18672. hour := time.Now().Format("15")
  18673. min := time.Now().Format("04")
  18674. sec := time.Now().Format("05")
  18675. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  18676. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  18677. file_name := file + ".txt"
  18678. file_path := miConfig.OrgName + "日志" + "/" + file_name
  18679. exist, _ := utils.PathExists(file_path)
  18680. if exist { //存在
  18681. fmt.Println("存在")
  18682. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  18683. if err != nil {
  18684. fmt.Println("read fail")
  18685. }
  18686. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  18687. n, _ := f.Seek(0, 2)
  18688. _, err = f.WriteAt([]byte(content), n)
  18689. } else { //不存在
  18690. fmt.Println("文件不存在,创建文件")
  18691. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  18692. defer f.Close()
  18693. if err != nil {
  18694. } else {
  18695. _, err = f.Write([]byte("记录日志"))
  18696. }
  18697. }
  18698. }
  18699. type Charset string
  18700. const (
  18701. UTF8 = Charset("UTF-8")
  18702. GB18030 = Charset("GB18030")
  18703. )
  18704. func ConvertToString(src string, srcCode string, tagCode string) string {
  18705. srcCoder := mahonia.NewDecoder(srcCode)
  18706. srcResult := srcCoder.ConvertString(src)
  18707. tagCoder := mahonia.NewDecoder(tagCode)
  18708. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  18709. result := string(cdata)
  18710. return result
  18711. }
  18712. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  18713. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  18714. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18715. var token string
  18716. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18717. var api string
  18718. if miConfig.MdtrtareaAdmvs == "320921" {
  18719. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18720. "&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
  18721. fmt.Println(api)
  18722. } else {
  18723. 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 +
  18724. "&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
  18725. }
  18726. resp, requestErr := http.Get(api)
  18727. if requestErr != nil {
  18728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18729. return ""
  18730. }
  18731. body, ioErr := ioutil.ReadAll(resp.Body)
  18732. if ioErr != nil {
  18733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18735. return ""
  18736. }
  18737. var respJSON map[string]interface{}
  18738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18741. return ""
  18742. }
  18743. var status string
  18744. status = respJSON["data"].(map[string]interface{})["status"].(string)
  18745. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  18746. var res ResultTwo //1101结果
  18747. var res10265 ResultTwo10265 //1101结果
  18748. if status == "0" { //读卡成功
  18749. var card_info string //卡信息
  18750. var busi_card_info string
  18751. token = respJSON["data"].(map[string]interface{})["token"].(string)
  18752. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  18753. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  18754. fmt.Println(card_info)
  18755. fmt.Println(busi_card_info)
  18756. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  18757. result, _ := json.Marshal(respJSON)
  18758. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18759. utils.ErrorLog("解析失败:%v", err)
  18760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18761. return ""
  18762. }
  18763. res.ErrMsg = res10265.ErrMsg
  18764. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18765. res.Infcode = infocode
  18766. res.Output = res10265.Output
  18767. res.InfRefmsgid = res10265.InfRefmsgid
  18768. if res.Infcode == 0 {
  18769. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18770. if err == gorm.ErrRecordNotFound {
  18771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18772. return ""
  18773. } else if err != nil {
  18774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18775. return ""
  18776. } else {
  18777. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18778. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18779. infoStr := string(Iinfos)
  18780. idetinfoStr := string(Idetinfos)
  18781. psn := &models.HisPsn{
  18782. PsnNo: res.Output.Baseinfo.PsnNo,
  18783. Age: res.Output.Baseinfo.Age,
  18784. PatientId: patient.ID,
  18785. Certno: res.Output.Baseinfo.Certno,
  18786. Brdy: res.Output.Baseinfo.Brdy,
  18787. Gend: res.Output.Baseinfo.Gend,
  18788. Naty: res.Output.Baseinfo.Naty,
  18789. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18790. PsnName: res.Output.Baseinfo.PsnName,
  18791. Idetinfo: idetinfoStr,
  18792. Insuinfo: infoStr,
  18793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18794. CardInfo: card_info,
  18795. VerifyNumber: token,
  18796. }
  18797. service.CreateHisPsn(psn)
  18798. return token
  18799. }
  18800. }
  18801. } else {
  18802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18803. return ""
  18804. }
  18805. } else { //读卡失败
  18806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18807. return ""
  18808. }
  18809. return token
  18810. }
  18811. func DeleteExtraSpaceTwo(s string) string {
  18812. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  18813. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  18814. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  18815. reg, _ := regexp.Compile(regstr) //编译正则表达式
  18816. s2 := make([]byte, len(s1)) //定义字符数组切片
  18817. copy(s2, s1) //将字符串复制到切片
  18818. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  18819. for len(spc_index) > 0 { //找到适配项
  18820. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  18821. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  18822. }
  18823. return string(s2)
  18824. }
  18825. func Remove0000(s string) string {
  18826. str := make([]rune, 0, len(s))
  18827. for _, v := range []rune(s) {
  18828. if v == 0 {
  18829. continue
  18830. }
  18831. str = append(str, v)
  18832. }
  18833. return string(str)
  18834. }
  18835. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  18836. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  18837. readCard := DllDef.MustFindProc("EcQuery")
  18838. pCardInfo := make([]byte, 8192)
  18839. pBusiCardInfo := make([]byte, 8192)
  18840. data := make(map[string]interface{})
  18841. //pData := make(map[string]interface{})
  18842. inputData := make(map[string]interface{})
  18843. inputData["orgId"] = code
  18844. inputData["businessType"] = "01101"
  18845. inputData["operatorId"] = operator_id
  18846. inputData["operatorName"] = operator_name
  18847. inputData["officeId"] = "001"
  18848. inputData["officeName"] = "血透室"
  18849. //
  18850. data["data"] = inputData
  18851. data["transType"] = "ec.query"
  18852. data["orgId"] = code
  18853. bytesData, _ := json.Marshal(data)
  18854. pCardInfo = bytesData
  18855. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18856. fmt.Println(ret2)
  18857. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  18858. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18859. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  18860. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18861. if ret2 != 0 {
  18862. return "", ""
  18863. }
  18864. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  18865. }
  18866. func DeleteExtraSpace(s string) string {
  18867. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  18868. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  18869. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  18870. reg, _ := regexp.Compile(regstr) //编译正则表达式
  18871. s2 := make([]byte, len(s1)) //定义字符数组切片
  18872. copy(s2, s1) //将字符串复制到切片
  18873. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  18874. for len(spc_index) > 0 { //找到适配项
  18875. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  18876. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  18877. }
  18878. return string(s2)
  18879. }
  18880. // 对账
  18881. func (c *HisApiController) Post3202() {
  18882. start_time := c.GetString("start_time")
  18883. end_time := c.GetString("end_time")
  18884. //insutype := c.GetString("insutype")
  18885. clr_type := c.GetString("clr_type")
  18886. clr_org := c.GetString("clr_optins")
  18887. admin_user_id, _ := c.GetInt64("admin_user_id")
  18888. adminUser := c.GetAdminUserInfo()
  18889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18891. if len(clr_org) == 0 {
  18892. clr_org = miConfig.MdtrtareaAdmvs
  18893. }
  18894. timeLayout := "2006-01-02"
  18895. loc, _ := time.LoadLocation("Local")
  18896. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  18897. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  18898. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  18899. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  18900. //fixmedins_setl_cnt := int64(len(orders))
  18901. var medfee_sumamt float64
  18902. var acct_pay float64
  18903. var fund_pay_sumamt float64
  18904. for _, item := range orders {
  18905. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  18906. acct_pay = acct_pay + item.AcctPay
  18907. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  18908. }
  18909. //var medfee_sumamt_two float64
  18910. //var acct_pay_two float64
  18911. //var fund_pay_sumamt_two float64
  18912. //for _, item := range orders_two {
  18913. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  18914. // acct_pay_two = acct_pay_two + item.AcctPay
  18915. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  18916. //}
  18917. //var user_name string
  18918. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18919. //if role.ID == 0 {
  18920. // user_name = "xxx"
  18921. //} else {
  18922. // user_name = role.UserName
  18923. //}
  18924. var res ResultSix
  18925. if config.IsOpen == 1 {
  18926. var bps []*models.BusinessParamsTwo
  18927. var bp models.BusinessParamsTwo
  18928. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  18929. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  18930. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  18931. bp.MedfeeSumamt = medfee_sumamt_str
  18932. bp.AcctPay = acct_pay_str
  18933. bp.FundPaySumamt = fund_pay_sumamt_str
  18934. bp.Insutype = "390"
  18935. bp.StmtBegndate = start_time
  18936. bp.ClrType = clr_type
  18937. bp.SetlOptins = clr_org
  18938. bp.StmtEnddate = end_time
  18939. bps = append(bps, &bp)
  18940. data := make(map[string]interface{})
  18941. data["bps"] = bps
  18942. data["org_name"] = miConfig.OrgName
  18943. data["doctor"] = role.UserName
  18944. data["fixmedins_code"] = miConfig.Code
  18945. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  18946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18947. if miConfig.MdtrtareaAdmvs == "421300" {
  18948. client := &http.Client{}
  18949. bytesData, _ := json.Marshal(data)
  18950. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  18951. resp, _ := client.Do(req)
  18952. defer resp.Body.Close()
  18953. body, ioErr := ioutil.ReadAll(resp.Body)
  18954. if ioErr != nil {
  18955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18957. return
  18958. }
  18959. var respJSON map[string]interface{}
  18960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18963. return
  18964. }
  18965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18966. userJSONBytes, _ := json.Marshal(respJSON)
  18967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18968. utils.ErrorLog("解析失败:%v", err)
  18969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18970. return
  18971. }
  18972. }
  18973. if res.Infcode == 0 {
  18974. c.ServeSuccessJSON(map[string]interface{}{
  18975. "msg": "发起成功",
  18976. })
  18977. } else {
  18978. c.ServeSuccessJSON(map[string]interface{}{
  18979. "code": -10,
  18980. "msg": res.ErrMsg,
  18981. })
  18982. }
  18983. }
  18984. }
  18985. func (c *HisApiController) Post3501() {
  18986. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18987. data := make(map[string]interface{})
  18988. var struct3501s []models.Struct3501
  18989. var struct3501 models.Struct3501
  18990. struct3501.OrgName = miConfig.OrgName
  18991. struct3501.AccessKey = miConfig.AccessKey
  18992. struct3501.RequestUrl = miConfig.Url
  18993. struct3501.SecretKey = miConfig.SecretKey
  18994. struct3501.ManuDate = "2022-08-17"
  18995. struct3501.FixmedinsBchno = ""
  18996. struct3501.ManuLotnum = ""
  18997. struct3501.RxFlag = "0"
  18998. struct3501.ExpyEnd = "2022-08-17"
  18999. struct3501.Invdate = "2022-08-17"
  19000. struct3501.InvCnt = "20.25"
  19001. struct3501.Memo = ""
  19002. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19003. struct3501.FixmedinsHilistId = miConfig.Code
  19004. struct3501.FixmedinsHilistName = miConfig.OrgName
  19005. struct3501s = append(struct3501s, struct3501)
  19006. data["struct_3501s"] = struct3501s
  19007. client := &http.Client{}
  19008. bytesData, _ := json.Marshal(data)
  19009. var req *http.Request
  19010. if miConfig.MdtrtareaAdmvs == "320921" {
  19011. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19012. } else {
  19013. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19014. }
  19015. resp, _ := client.Do(req)
  19016. defer resp.Body.Close()
  19017. body, ioErr := ioutil.ReadAll(resp.Body)
  19018. if ioErr != nil {
  19019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19021. return
  19022. }
  19023. var respJSON map[string]interface{}
  19024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19027. return
  19028. }
  19029. var res ResultSix
  19030. var resSix10265 ResultSix10265 //1101结果
  19031. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19032. result, _ := json.Marshal(respJSON)
  19033. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19034. utils.ErrorLog("解析失败:%v", err)
  19035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19036. return
  19037. }
  19038. res.InfRefmsgid = resSix10265.InfRefmsgid
  19039. res.Output = resSix10265.Output
  19040. res.ErrMsg = resSix10265.ErrMsg
  19041. res.Cainfo = resSix10265.Cainfo
  19042. res.WarnMsg = resSix10265.WarnMsg
  19043. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19044. res.Infcode = infocode
  19045. if infocode == 0 {
  19046. c.ServeSuccessJSON(map[string]interface{}{
  19047. "msg": "上传成功",
  19048. })
  19049. return
  19050. } else {
  19051. c.ServeSuccessJSON(map[string]interface{}{
  19052. "failed_code": -10,
  19053. "msg": res.ErrMsg,
  19054. })
  19055. return
  19056. }
  19057. }
  19058. func (c *HisApiController) Post3502() {
  19059. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19060. data := make(map[string]interface{})
  19061. var struct3502s []models.Struct3502
  19062. var struct3502 models.Struct3502
  19063. struct3502.OrgName = miConfig.OrgName
  19064. struct3502.AccessKey = miConfig.AccessKey
  19065. struct3502.RequestUrl = miConfig.Url
  19066. struct3502.SecretKey = miConfig.SecretKey
  19067. struct3502.ManuDate = "2022-08-15"
  19068. struct3502.FixmedinsBchno = ""
  19069. struct3502.ManuLotnum = ""
  19070. struct3502.RxFlag = "0"
  19071. struct3502.ExpyEnd = "2022-08-15"
  19072. struct3502.Invdate = "2022-08-15"
  19073. struct3502.InvCnt = "20.25"
  19074. struct3502.Memo = ""
  19075. struct3502.MedListCodg = "XB01ABD056B002020200517"
  19076. struct3502.FixmedinsHilistId = miConfig.Code
  19077. struct3502.FixmedinsHilistName = miConfig.OrgName
  19078. struct3502s = append(struct3502s, struct3502)
  19079. data["struct_3502s"] = struct3502s
  19080. client := &http.Client{}
  19081. bytesData, _ := json.Marshal(data)
  19082. var req *http.Request
  19083. if miConfig.MdtrtareaAdmvs == "320921" {
  19084. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19085. } else {
  19086. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19087. }
  19088. resp, _ := client.Do(req)
  19089. defer resp.Body.Close()
  19090. body, ioErr := ioutil.ReadAll(resp.Body)
  19091. if ioErr != nil {
  19092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19094. return
  19095. }
  19096. var respJSON map[string]interface{}
  19097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19100. return
  19101. }
  19102. var res ResultSix
  19103. var resSix10265 ResultSix10265 //1101结果
  19104. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19105. result, _ := json.Marshal(respJSON)
  19106. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19107. utils.ErrorLog("解析失败:%v", err)
  19108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19109. return
  19110. }
  19111. res.InfRefmsgid = resSix10265.InfRefmsgid
  19112. res.Output = resSix10265.Output
  19113. res.ErrMsg = resSix10265.ErrMsg
  19114. res.Cainfo = resSix10265.Cainfo
  19115. res.WarnMsg = resSix10265.WarnMsg
  19116. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19117. res.Infcode = infocode
  19118. if infocode == 0 {
  19119. c.ServeSuccessJSON(map[string]interface{}{
  19120. "msg": "上传成功",
  19121. })
  19122. return
  19123. } else {
  19124. c.ServeSuccessJSON(map[string]interface{}{
  19125. "failed_code": -10,
  19126. "msg": res.ErrMsg,
  19127. })
  19128. return
  19129. }
  19130. }
  19131. func (c *HisApiController) Post3503() {
  19132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19133. data := make(map[string]interface{})
  19134. var struct3501s []models.Struct3501
  19135. var struct3501 models.Struct3501
  19136. struct3501.OrgName = miConfig.OrgName
  19137. struct3501.AccessKey = miConfig.AccessKey
  19138. struct3501.RequestUrl = miConfig.Url
  19139. struct3501.SecretKey = miConfig.SecretKey
  19140. struct3501.ManuDate = "2022-08-15"
  19141. struct3501.FixmedinsBchno = ""
  19142. struct3501.ManuLotnum = ""
  19143. struct3501.RxFlag = "0"
  19144. struct3501.ExpyEnd = "2022-08-15"
  19145. struct3501.Invdate = "2022-08-15"
  19146. struct3501.InvCnt = "20.25"
  19147. struct3501.Memo = ""
  19148. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19149. struct3501.FixmedinsHilistId = miConfig.Code
  19150. struct3501.FixmedinsHilistName = miConfig.OrgName
  19151. struct3501s = append(struct3501s, struct3501)
  19152. data["struct_3501s"] = struct3501s
  19153. client := &http.Client{}
  19154. bytesData, _ := json.Marshal(data)
  19155. var req *http.Request
  19156. if miConfig.MdtrtareaAdmvs == "320921" {
  19157. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19158. } else {
  19159. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19160. }
  19161. resp, _ := client.Do(req)
  19162. defer resp.Body.Close()
  19163. body, ioErr := ioutil.ReadAll(resp.Body)
  19164. if ioErr != nil {
  19165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19167. return
  19168. }
  19169. var respJSON map[string]interface{}
  19170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19173. return
  19174. }
  19175. var res ResultSix
  19176. var resSix10265 ResultSix10265 //1101结果
  19177. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19178. result, _ := json.Marshal(respJSON)
  19179. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19180. utils.ErrorLog("解析失败:%v", err)
  19181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19182. return
  19183. }
  19184. res.InfRefmsgid = resSix10265.InfRefmsgid
  19185. res.Output = resSix10265.Output
  19186. res.ErrMsg = resSix10265.ErrMsg
  19187. res.Cainfo = resSix10265.Cainfo
  19188. res.WarnMsg = resSix10265.WarnMsg
  19189. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19190. res.Infcode = infocode
  19191. if infocode == 0 {
  19192. c.ServeSuccessJSON(map[string]interface{}{
  19193. "msg": "上传成功",
  19194. })
  19195. return
  19196. } else {
  19197. c.ServeSuccessJSON(map[string]interface{}{
  19198. "failed_code": -10,
  19199. "msg": res.ErrMsg,
  19200. })
  19201. return
  19202. }
  19203. }
  19204. func (c *HisApiController) Post3504() {
  19205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19206. data := make(map[string]interface{})
  19207. var struct3501s []models.Struct3501
  19208. var struct3501 models.Struct3501
  19209. struct3501.OrgName = miConfig.OrgName
  19210. struct3501.AccessKey = miConfig.AccessKey
  19211. struct3501.RequestUrl = miConfig.Url
  19212. struct3501.SecretKey = miConfig.SecretKey
  19213. struct3501.ManuDate = "2022-08-15"
  19214. struct3501.FixmedinsBchno = ""
  19215. struct3501.ManuLotnum = ""
  19216. struct3501.RxFlag = "0"
  19217. struct3501.ExpyEnd = "2022-08-15"
  19218. struct3501.Invdate = "2022-08-15"
  19219. struct3501.InvCnt = "20.25"
  19220. struct3501.Memo = ""
  19221. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19222. struct3501.FixmedinsHilistId = miConfig.Code
  19223. struct3501.FixmedinsHilistName = miConfig.OrgName
  19224. struct3501s = append(struct3501s, struct3501)
  19225. data["struct_3501s"] = struct3501s
  19226. client := &http.Client{}
  19227. bytesData, _ := json.Marshal(data)
  19228. var req *http.Request
  19229. if miConfig.MdtrtareaAdmvs == "320921" {
  19230. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19231. } else {
  19232. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19233. }
  19234. resp, _ := client.Do(req)
  19235. defer resp.Body.Close()
  19236. body, ioErr := ioutil.ReadAll(resp.Body)
  19237. if ioErr != nil {
  19238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19240. return
  19241. }
  19242. var respJSON map[string]interface{}
  19243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19246. return
  19247. }
  19248. var res ResultSix
  19249. var resSix10265 ResultSix10265 //1101结果
  19250. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19251. result, _ := json.Marshal(respJSON)
  19252. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19253. utils.ErrorLog("解析失败:%v", err)
  19254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19255. return
  19256. }
  19257. res.InfRefmsgid = resSix10265.InfRefmsgid
  19258. res.Output = resSix10265.Output
  19259. res.ErrMsg = resSix10265.ErrMsg
  19260. res.Cainfo = resSix10265.Cainfo
  19261. res.WarnMsg = resSix10265.WarnMsg
  19262. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19263. res.Infcode = infocode
  19264. if infocode == 0 {
  19265. c.ServeSuccessJSON(map[string]interface{}{
  19266. "msg": "上传成功",
  19267. })
  19268. return
  19269. } else {
  19270. c.ServeSuccessJSON(map[string]interface{}{
  19271. "failed_code": -10,
  19272. "msg": res.ErrMsg,
  19273. })
  19274. return
  19275. }
  19276. }
  19277. func (c *HisApiController) Post3505() {
  19278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19279. data := make(map[string]interface{})
  19280. var struct3501s []models.Struct3501
  19281. var struct3501 models.Struct3501
  19282. struct3501.OrgName = miConfig.OrgName
  19283. struct3501.AccessKey = miConfig.AccessKey
  19284. struct3501.RequestUrl = miConfig.Url
  19285. struct3501.SecretKey = miConfig.SecretKey
  19286. struct3501.ManuDate = "2022-08-15"
  19287. struct3501.FixmedinsBchno = ""
  19288. struct3501.ManuLotnum = ""
  19289. struct3501.RxFlag = "0"
  19290. struct3501.ExpyEnd = "2022-08-15"
  19291. struct3501.Invdate = "2022-08-15"
  19292. struct3501.InvCnt = "20.25"
  19293. struct3501.Memo = ""
  19294. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19295. struct3501.FixmedinsHilistId = miConfig.Code
  19296. struct3501.FixmedinsHilistName = miConfig.OrgName
  19297. struct3501s = append(struct3501s, struct3501)
  19298. data["struct_3501s"] = struct3501s
  19299. client := &http.Client{}
  19300. bytesData, _ := json.Marshal(data)
  19301. var req *http.Request
  19302. if miConfig.MdtrtareaAdmvs == "320921" {
  19303. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19304. } else {
  19305. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19306. }
  19307. resp, _ := client.Do(req)
  19308. defer resp.Body.Close()
  19309. body, ioErr := ioutil.ReadAll(resp.Body)
  19310. if ioErr != nil {
  19311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19313. return
  19314. }
  19315. var respJSON map[string]interface{}
  19316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19319. return
  19320. }
  19321. var res ResultSix
  19322. var resSix10265 ResultSix10265 //1101结果
  19323. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19324. result, _ := json.Marshal(respJSON)
  19325. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19326. utils.ErrorLog("解析失败:%v", err)
  19327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19328. return
  19329. }
  19330. res.InfRefmsgid = resSix10265.InfRefmsgid
  19331. res.Output = resSix10265.Output
  19332. res.ErrMsg = resSix10265.ErrMsg
  19333. res.Cainfo = resSix10265.Cainfo
  19334. res.WarnMsg = resSix10265.WarnMsg
  19335. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19336. res.Infcode = infocode
  19337. if infocode == 0 {
  19338. c.ServeSuccessJSON(map[string]interface{}{
  19339. "msg": "上传成功",
  19340. })
  19341. return
  19342. } else {
  19343. c.ServeSuccessJSON(map[string]interface{}{
  19344. "failed_code": -10,
  19345. "msg": res.ErrMsg,
  19346. })
  19347. return
  19348. }
  19349. }
  19350. func (c *HisApiController) Post3506() {
  19351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19352. data := make(map[string]interface{})
  19353. var struct3501s []models.Struct3501
  19354. var struct3501 models.Struct3501
  19355. struct3501.OrgName = miConfig.OrgName
  19356. struct3501.AccessKey = miConfig.AccessKey
  19357. struct3501.RequestUrl = miConfig.Url
  19358. struct3501.SecretKey = miConfig.SecretKey
  19359. struct3501.ManuDate = "2022-08-15"
  19360. struct3501.FixmedinsBchno = ""
  19361. struct3501.ManuLotnum = ""
  19362. struct3501.RxFlag = "0"
  19363. struct3501.ExpyEnd = "2022-08-15"
  19364. struct3501.Invdate = "2022-08-15"
  19365. struct3501.InvCnt = "20.25"
  19366. struct3501.Memo = ""
  19367. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19368. struct3501.FixmedinsHilistId = miConfig.Code
  19369. struct3501.FixmedinsHilistName = miConfig.OrgName
  19370. struct3501s = append(struct3501s, struct3501)
  19371. data["struct_3501s"] = struct3501s
  19372. client := &http.Client{}
  19373. bytesData, _ := json.Marshal(data)
  19374. var req *http.Request
  19375. if miConfig.MdtrtareaAdmvs == "320921" {
  19376. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19377. } else {
  19378. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19379. }
  19380. resp, _ := client.Do(req)
  19381. defer resp.Body.Close()
  19382. body, ioErr := ioutil.ReadAll(resp.Body)
  19383. if ioErr != nil {
  19384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19386. return
  19387. }
  19388. var respJSON map[string]interface{}
  19389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19392. return
  19393. }
  19394. var res ResultSix
  19395. var resSix10265 ResultSix10265 //1101结果
  19396. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19397. result, _ := json.Marshal(respJSON)
  19398. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19399. utils.ErrorLog("解析失败:%v", err)
  19400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19401. return
  19402. }
  19403. res.InfRefmsgid = resSix10265.InfRefmsgid
  19404. res.Output = resSix10265.Output
  19405. res.ErrMsg = resSix10265.ErrMsg
  19406. res.Cainfo = resSix10265.Cainfo
  19407. res.WarnMsg = resSix10265.WarnMsg
  19408. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19409. res.Infcode = infocode
  19410. if infocode == 0 {
  19411. c.ServeSuccessJSON(map[string]interface{}{
  19412. "msg": "上传成功",
  19413. })
  19414. return
  19415. } else {
  19416. c.ServeSuccessJSON(map[string]interface{}{
  19417. "failed_code": -10,
  19418. "msg": res.ErrMsg,
  19419. })
  19420. return
  19421. }
  19422. }
  19423. func (c *HisApiController) Post3507() {
  19424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19425. data := make(map[string]interface{})
  19426. var struct3501s []models.Struct3501
  19427. var struct3501 models.Struct3501
  19428. struct3501.OrgName = miConfig.OrgName
  19429. struct3501.AccessKey = miConfig.AccessKey
  19430. struct3501.RequestUrl = miConfig.Url
  19431. struct3501.SecretKey = miConfig.SecretKey
  19432. struct3501.ManuDate = "2022-08-15"
  19433. struct3501.FixmedinsBchno = ""
  19434. struct3501.ManuLotnum = ""
  19435. struct3501.RxFlag = "0"
  19436. struct3501.ExpyEnd = "2022-08-15"
  19437. struct3501.Invdate = "2022-08-15"
  19438. struct3501.InvCnt = "20.25"
  19439. struct3501.Memo = ""
  19440. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19441. struct3501.FixmedinsHilistId = miConfig.Code
  19442. struct3501.FixmedinsHilistName = miConfig.OrgName
  19443. struct3501s = append(struct3501s, struct3501)
  19444. data["struct_3501s"] = struct3501s
  19445. client := &http.Client{}
  19446. bytesData, _ := json.Marshal(data)
  19447. var req *http.Request
  19448. if miConfig.MdtrtareaAdmvs == "320921" {
  19449. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19450. } else {
  19451. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19452. }
  19453. resp, _ := client.Do(req)
  19454. defer resp.Body.Close()
  19455. body, ioErr := ioutil.ReadAll(resp.Body)
  19456. if ioErr != nil {
  19457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19459. return
  19460. }
  19461. var respJSON map[string]interface{}
  19462. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19465. return
  19466. }
  19467. var res ResultSix
  19468. var resSix10265 ResultSix10265 //1101结果
  19469. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19470. result, _ := json.Marshal(respJSON)
  19471. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19472. utils.ErrorLog("解析失败:%v", err)
  19473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19474. return
  19475. }
  19476. res.InfRefmsgid = resSix10265.InfRefmsgid
  19477. res.Output = resSix10265.Output
  19478. res.ErrMsg = resSix10265.ErrMsg
  19479. res.Cainfo = resSix10265.Cainfo
  19480. res.WarnMsg = resSix10265.WarnMsg
  19481. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19482. res.Infcode = infocode
  19483. if infocode == 0 {
  19484. c.ServeSuccessJSON(map[string]interface{}{
  19485. "msg": "上传成功",
  19486. })
  19487. return
  19488. } else {
  19489. c.ServeSuccessJSON(map[string]interface{}{
  19490. "failed_code": -10,
  19491. "msg": res.ErrMsg,
  19492. })
  19493. return
  19494. }
  19495. }
  19496. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  19497. // WebSocket服务器地址
  19498. serverURL := "ws://127.0.0.1:8899"
  19499. // 解析WebSocket服务器地址
  19500. u, err := url.Parse(serverURL)
  19501. if err != nil {
  19502. }
  19503. // 建立WebSocket连接
  19504. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  19505. if err != nil {
  19506. }
  19507. defer conn.Close()
  19508. input2 := make(map[string]interface{})
  19509. input := make(map[string]interface{})
  19510. inputData := make(map[string]interface{})
  19511. inputData["orgId"] = code
  19512. inputData["businessType"] = "01101"
  19513. inputData["operatorId"] = operator_id
  19514. inputData["operatorName"] = operator_name
  19515. inputData["officeId"] = "001"
  19516. inputData["officeName"] = "血透室"
  19517. inputData["deviceType"] = ""
  19518. input["data"] = inputData
  19519. input["orgId"] = code
  19520. input["transType"] = "ec.query"
  19521. //if md == ""
  19522. if md[:4] == "4403" {
  19523. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19524. } else if md[:4] == "4401" {
  19525. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19526. } else {
  19527. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19528. }
  19529. input2["indata"] = input
  19530. bytesData, _ := json.Marshal(input2)
  19531. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  19532. if err != nil {
  19533. fmt.Println(err)
  19534. }
  19535. // 接收消息
  19536. _, receivedMessage, err := conn.ReadMessage()
  19537. if err != nil {
  19538. fmt.Println(err)
  19539. }
  19540. return "", string(receivedMessage)
  19541. }
  19542. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  19543. // WebSocket服务器地址
  19544. serverURL := "ws://127.0.0.1:8899"
  19545. // 解析WebSocket服务器地址
  19546. u, err := url.Parse(serverURL)
  19547. if err != nil {
  19548. }
  19549. // 建立WebSocket连接
  19550. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  19551. if err != nil {
  19552. }
  19553. defer conn.Close()
  19554. input2 := make(map[string]interface{})
  19555. input := make(map[string]interface{})
  19556. inputData := make(map[string]interface{})
  19557. inputData["orgId"] = code
  19558. inputData["businessType"] = "01301"
  19559. inputData["operatorId"] = operator_id
  19560. inputData["operatorName"] = operator_name
  19561. inputData["officeId"] = "001"
  19562. inputData["officeName"] = "血透室"
  19563. inputData["deviceType"] = ""
  19564. input["data"] = inputData
  19565. input["orgId"] = code
  19566. input["transType"] = "ec.query"
  19567. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19568. input2["indata"] = input
  19569. bytesData, _ := json.Marshal(input2)
  19570. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  19571. if err != nil {
  19572. fmt.Println(err)
  19573. }
  19574. // 接收消息
  19575. _, receivedMessage, err := conn.ReadMessage()
  19576. if err != nil {
  19577. fmt.Println(err)
  19578. }
  19579. return "", string(receivedMessage)
  19580. }