his_api_controller.go 573KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. }
  82. type Result3101 struct {
  83. Infcode string `json:"infcode"`
  84. InfRefmsgid string `json:"inf_refmsgid"`
  85. RefmsgTime string `json:"refmsg_time"`
  86. RespondTime string `json:"respond_time"`
  87. Enctype string `json:"enctype"`
  88. Signtype string `json:"signtype"`
  89. ErrMsg string `json:"err_msg"`
  90. Output struct {
  91. Result []struct {
  92. JudgeResultDetailDtos []struct {
  93. VolaItemType string `json:"vola_item_type"`
  94. MdtrtID string `json:"mdtrt_id"`
  95. JrdID string `json:"jrd_id"`
  96. PatnID string `json:"patn_id"`
  97. RxID string `json:"rx_id"`
  98. VolaAmt interface{} `json:"vola_amt"`
  99. } `json:"judge_result_detail_dtos"`
  100. RuleID string `json:"rule_id"`
  101. VolaEvid string `json:"vola_evid"`
  102. MdtrtID string `json:"mdtrt_id"`
  103. RuleName string `json:"rule_name"`
  104. VolaAmtStas string `json:"vola_amt_stas"`
  105. JrID string `json:"jr_id"`
  106. PatnID string `json:"patn_id"`
  107. SevDeg string `json:"sev_deg"`
  108. VolaAmt float64 `json:"vola_amt"`
  109. VolaBhvrType string `json:"vola_bhvr_type"`
  110. VolaCont string `json:"vola_cont"`
  111. } `json:"result"`
  112. } `json:"output"`
  113. }
  114. func (c *HisApiController) ReadEleToken() {
  115. admin_user_id, _ := c.GetInt64("admin_user_id")
  116. his_patient_id, _ := c.GetInt64("his_patient_id")
  117. adminUser := c.GetAdminUserInfo()
  118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  122. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  123. if len(tokens) > 0 {
  124. c.ServeSuccessJSON(map[string]interface{}{
  125. "msg": "读取成功",
  126. })
  127. } else {
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "failed_code": -10,
  130. "msg": "读取失败",
  131. })
  132. }
  133. } else if miConfig.MdtrtareaAdmvs == "440305" {
  134. if initFlag == 0 {
  135. c.TestGetBasBaseInit()
  136. }
  137. token := c.GetEleBaseInfo()
  138. token = Remove0000(token)
  139. if len(token) > 0 {
  140. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  142. var res ResultTwo
  143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. if res.Infcode == 0 {
  149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  150. if err == gorm.ErrRecordNotFound {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  152. return
  153. } else if err != nil {
  154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  155. return
  156. } else {
  157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  159. infoStr := string(Iinfos)
  160. idetinfoStr := string(Idetinfos)
  161. psn := &models.HisPsn{
  162. PsnNo: res.Output.Baseinfo.PsnNo,
  163. Age: res.Output.Baseinfo.Age,
  164. PatientId: patient.ID,
  165. Certno: res.Output.Baseinfo.Certno,
  166. Brdy: res.Output.Baseinfo.Brdy,
  167. Gend: res.Output.Baseinfo.Gend,
  168. Naty: res.Output.Baseinfo.Naty,
  169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  170. PsnName: res.Output.Baseinfo.PsnName,
  171. Idetinfo: idetinfoStr,
  172. Insuinfo: infoStr,
  173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  174. CardInfo: "",
  175. VerifyNumber: token,
  176. }
  177. service.CreateHisPsn(psn)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "msg": "读取成功",
  180. })
  181. }
  182. } else {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  184. return
  185. }
  186. } else {
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "failed_code": -10,
  189. "msg": "读取失败",
  190. })
  191. }
  192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  193. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  194. if len(errMsg) == 0 {
  195. type ELeData struct {
  196. Data struct {
  197. IdNo string `json:"idNo"`
  198. IdType string `json:"idType"`
  199. UserName string `json:"userName"`
  200. EcToken string `json:"ecToken"`
  201. InsuOrg string `json:"insuOrg"`
  202. Gender string `json:"gender"`
  203. Birthday string `json:"birthday"`
  204. Nationality string `json:"nationality"`
  205. Email string `json:"email"`
  206. Extra string `json:"extra"`
  207. } `json:"data"`
  208. Code int `json:"code"`
  209. Message string `json:"message"`
  210. }
  211. var ele ELeData
  212. err := json.Unmarshal([]byte(outPutInfo), &ele)
  213. if err != nil {
  214. utils.ErrorLog("解析失败:%v", err)
  215. }
  216. token := ele.Data.EcToken
  217. if len(token) > 0 {
  218. psn := &models.HisPsn{
  219. PsnNo: his.PsnNo,
  220. Age: 0,
  221. PatientId: his.PatientId,
  222. Certno: his.Certno,
  223. Brdy: his.Brdy,
  224. Gend: his.Gend,
  225. Naty: his.Naty,
  226. PsnCertType: his.PsnCertType,
  227. PsnName: his.PsnName,
  228. Idetinfo: his.Idetinfo,
  229. Insuinfo: his.Iinfo,
  230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  231. CardInfo: outPutInfo,
  232. VerifyNumber: token,
  233. }
  234. service.CreateHisPsn(psn)
  235. }
  236. if len(token) > 0 {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "读取成功",
  239. })
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": "读取失败",
  244. })
  245. }
  246. }
  247. } else if miConfig.MdtrtareaAdmvs == "360399" {
  248. if initFlag == 0 {
  249. c.TestGetJiangXiBasBaseInit()
  250. }
  251. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  252. type ELeData struct {
  253. Data struct {
  254. IdNo string `json:"idNo"`
  255. IdType string `json:"idType"`
  256. UserName string `json:"userName"`
  257. EcToken string `json:"ecToken"`
  258. InsuOrg string `json:"insuOrg"`
  259. Gender string `json:"gender"`
  260. Birthday string `json:"birthday"`
  261. Nationality string `json:"nationality"`
  262. Email string `json:"email"`
  263. Extra string `json:"extra"`
  264. } `json:"data"`
  265. Code int `json:"code"`
  266. Message string `json:"message"`
  267. }
  268. var ele ELeData
  269. err := json.Unmarshal([]byte(json_result), &ele)
  270. if err != nil {
  271. utils.ErrorLog("解析失败:%v", err)
  272. }
  273. token := ele.Data.EcToken
  274. token = Remove0000(token)
  275. fmt.Println(ele.Data.UserName)
  276. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  277. saveLog(result2, requestLog2, "1101", "获取人员信息")
  278. var res ResultTwo
  279. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  280. utils.ErrorLog("解析失败:%v", err)
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. if res.Infcode == 0 {
  285. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  286. if err == gorm.ErrRecordNotFound {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  288. return
  289. } else if err != nil {
  290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  291. return
  292. } else {
  293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  295. infoStr := string(Iinfos)
  296. idetinfoStr := string(Idetinfos)
  297. psn := &models.HisPsn{
  298. PsnNo: res.Output.Baseinfo.PsnNo,
  299. Age: res.Output.Baseinfo.Age,
  300. PatientId: patient.ID,
  301. Certno: res.Output.Baseinfo.Certno,
  302. Brdy: res.Output.Baseinfo.Brdy,
  303. Gend: res.Output.Baseinfo.Gend,
  304. Naty: res.Output.Baseinfo.Naty,
  305. PsnCertType: res.Output.Baseinfo.PsnCertType,
  306. PsnName: res.Output.Baseinfo.PsnName,
  307. Idetinfo: idetinfoStr,
  308. Insuinfo: infoStr,
  309. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  310. CardInfo: "",
  311. VerifyNumber: token,
  312. }
  313. service.CreateHisPsn(psn)
  314. c.ServeSuccessJSON(map[string]interface{}{
  315. "patient": patient,
  316. "number": token,
  317. })
  318. }
  319. } else {
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  321. return
  322. }
  323. } else if miConfig.MdtrtareaAdmvs == "430800" {
  324. if initFlag == 0 {
  325. c.TestGetJiangXiBasBaseInit()
  326. }
  327. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. type ELeData struct {
  329. Data struct {
  330. IdNo string `json:"idNo"`
  331. IdType string `json:"idType"`
  332. UserName string `json:"userName"`
  333. EcToken string `json:"ecToken"`
  334. InsuOrg string `json:"insuOrg"`
  335. Gender string `json:"gender"`
  336. Birthday string `json:"birthday"`
  337. Nationality string `json:"nationality"`
  338. Email string `json:"email"`
  339. Extra string `json:"extra"`
  340. } `json:"data"`
  341. Code int `json:"code"`
  342. Message string `json:"message"`
  343. }
  344. var ele ELeData
  345. err := json.Unmarshal([]byte(json_result), &ele)
  346. if err != nil {
  347. utils.ErrorLog("解析失败:%v", err)
  348. }
  349. token := ele.Data.EcToken
  350. token = Remove0000(token)
  351. fmt.Println(ele.Data.UserName)
  352. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  353. saveLog(result2, requestLog2, "1101", "获取人员信息")
  354. var res ResultTwo
  355. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  356. utils.ErrorLog("解析失败:%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. if res.Infcode == 0 {
  361. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  362. if err == gorm.ErrRecordNotFound {
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  364. return
  365. } else if err != nil {
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  367. return
  368. } else {
  369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  371. infoStr := string(Iinfos)
  372. idetinfoStr := string(Idetinfos)
  373. psn := &models.HisPsn{
  374. PsnNo: res.Output.Baseinfo.PsnNo,
  375. Age: res.Output.Baseinfo.Age,
  376. PatientId: patient.ID,
  377. Certno: res.Output.Baseinfo.Certno,
  378. Brdy: res.Output.Baseinfo.Brdy,
  379. Gend: res.Output.Baseinfo.Gend,
  380. Naty: res.Output.Baseinfo.Naty,
  381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  382. PsnName: res.Output.Baseinfo.PsnName,
  383. Idetinfo: idetinfoStr,
  384. Insuinfo: infoStr,
  385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  386. CardInfo: "",
  387. VerifyNumber: token,
  388. }
  389. service.CreateHisPsn(psn)
  390. c.ServeSuccessJSON(map[string]interface{}{
  391. "patient": patient,
  392. "number": token,
  393. })
  394. }
  395. } else {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  397. return
  398. }
  399. }
  400. }
  401. func (c *HisApiController) Get9001() {
  402. adminUser := c.GetAdminUserInfo()
  403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  405. if miConfig.MdtrtareaAdmvs == "350500" {
  406. service.GetFjAuthorizationInfo(miConfig.Code)
  407. } else {
  408. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  409. var dat map[string]interface{}
  410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  411. fmt.Println(dat)
  412. } else {
  413. fmt.Println(err)
  414. }
  415. userJSONBytes, _ := json.Marshal(dat)
  416. var res models.Result9001
  417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  418. utils.ErrorLog("解析失败:%v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. }
  423. }
  424. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  425. var res Result3101
  426. adminUser := c.GetAdminUserInfo()
  427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  428. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  430. //record_time := c.GetString("record_time")
  431. //trig_scen := c.GetString("trig_scen")
  432. timeLayout := "2006-01-02"
  433. loc, _ := time.LoadLocation("Local")
  434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  435. if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  437. return res
  438. }
  439. recordDateTime := theTime.Unix()
  440. var patientPrescription models.HisPrescriptionInfo
  441. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  442. //if patientPrescription.ID == 0 {
  443. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  444. //}
  445. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  446. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  447. //
  448. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  449. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  450. var pp models.PublicParams
  451. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  452. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  453. pp.FixmedinsName = miConfig.OrgName
  454. pp.FixmedinsCode = miConfig.Code
  455. pp.RequestUrl = miConfig.Url
  456. pp.Cainfo = miConfig.Cainfo
  457. pp.SecretKey = miConfig.SecretKey
  458. pp.AccessKey = miConfig.AccessKey
  459. pp.OpterName = roles.UserName
  460. var config []*models.HisXtDiagnoseConfig
  461. for _, item := range diagnosis_ids {
  462. id, _ := strconv.ParseInt(item, 10, 64)
  463. diagnosisConfig, _ := service.FindDiagnoseById(id)
  464. config = append(config, &diagnosisConfig)
  465. }
  466. var pd models.PatientDtos
  467. pd.PatnID = his.PsnNo
  468. pd.PatnName = his.Name
  469. pd.Gend = his.Gend
  470. pd.Brdy = his.Brdy
  471. pd.Poolarea = miConfig.MdtrtareaAdmvs
  472. pd.CurrMdtrtID = his.Number
  473. var fed models.FsiEncounterDtos
  474. fed.MdtrtID = his.Number
  475. fed.MedinsID = miConfig.Code
  476. fed.MedinsName = miConfig.OrgName
  477. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  478. fed.MedMdtrtType = "1"
  479. fed.MedinsType = "1"
  480. fed.MedinsLv = "11"
  481. tm := time.Unix(his.RecordDate, 0)
  482. s_tm := tm.Format("2006-01-02 15:04:05")
  483. fed.AdmDate = s_tm
  484. fed.DscgDate = s_tm
  485. fed.DscgMainDiseCodg = config[0].CountryCode
  486. fed.DscgMainDiseName = config[0].CountryContentName
  487. //诊断信息
  488. var fdds []*models.FsiDiagnoseDtos
  489. for index, item := range config {
  490. if index == 0 {
  491. var fdd models.FsiDiagnoseDtos
  492. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  493. fdd.InoutDiseType = "1"
  494. fdd.MaindiseFlag = "1"
  495. fdd.DiseDate = s_tm
  496. fdd.DiasSrtNo = "1"
  497. fdd.DiseName = item.CountryContentName
  498. fdd.DiseCodg = item.CountryCode
  499. fdds = append(fdds, &fdd)
  500. } else {
  501. var fdd models.FsiDiagnoseDtos
  502. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  503. fdd.InoutDiseType = "1"
  504. fdd.MaindiseFlag = "1"
  505. fdd.DiseDate = s_tm
  506. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  507. fdd.DiseName = item.CountryContentName
  508. fdd.DiseCodg = item.CountryCode
  509. fdds = append(fdds, &fdd)
  510. }
  511. }
  512. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  513. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  514. fed.AdmDeptName = department.Name
  515. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  516. fed.DscgDeptName = department.Name
  517. fed.MedMdtrtType = "1"
  518. fed.MedType = "11"
  519. //if his.Insutype == "390" {
  520. // fed.MedType = "1402"
  521. //} else {
  522. // fed.MedType = "9933"
  523. //}
  524. var orders []*models.FsiOrderDtos
  525. if trig_scen == "2" {
  526. //处方医嘱信息
  527. for _, item := range prescriptions {
  528. for _, subItem := range item.HisDoctorAdviceInfo {
  529. var order models.FsiOrderDtos
  530. order.RxID = strconv.FormatInt(item.ID, 10)
  531. order.Rxno = strconv.FormatInt(item.ID, 10)
  532. order.LongDrordFlag = "0"
  533. order.HilistType = "1"
  534. order.ChrgType = "1"
  535. order.DrordBhvr = "-"
  536. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  537. order.HosplistName = subItem.BaseDrugLib.DrugName
  538. order.HilistLv = "1"
  539. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  540. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  541. order.HosplistName = subItem.BaseDrugLib.DrugName
  542. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  543. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  544. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  545. order.OwnpayAmt = ""
  546. order.SelfpayAmt = ""
  547. order.Spec = ""
  548. order.SpecUnt = ""
  549. order.DrordBegnDate = s_tm
  550. order.DrordStopDate = ""
  551. order.DrordDrCodg = "1"
  552. order.DrordDeptName = department.Name
  553. order.DrordDrCodg = "1"
  554. order.DrordDrName = doctor_info.UserName
  555. order.DrordDrProfttl = ""
  556. order.CurrDrordFlag = "1"
  557. orders = append(orders, &order)
  558. }
  559. for _, subItem := range item.HisPrescriptionProject {
  560. if subItem.Type == 2 {
  561. var order models.FsiOrderDtos
  562. order.RxID = strconv.FormatInt(item.ID, 10)
  563. order.Rxno = strconv.FormatInt(item.ID, 10)
  564. order.LongDrordFlag = "0"
  565. order.HilistType = "1"
  566. order.ChrgType = "1"
  567. order.DrordBhvr = "-"
  568. order.HilistCode = subItem.HisProject.MedicalCode
  569. order.HosplistName = subItem.HisProject.ProjectName
  570. order.HilistLv = "1"
  571. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  572. order.HosplistCode = subItem.HisProject.MedicalCode
  573. order.HosplistName = subItem.HisProject.ProjectName
  574. order.Cnt = subItem.Count
  575. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  576. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  578. order.OwnpayAmt = ""
  579. order.SelfpayAmt = ""
  580. order.Spec = ""
  581. order.SpecUnt = ""
  582. order.DrordBegnDate = s_tm
  583. order.DrordStopDate = ""
  584. order.DrordDrCodg = "1"
  585. order.DrordDeptName = department.Name
  586. order.DrordDrCodg = "1"
  587. order.DrordDrName = doctor_info.UserName
  588. order.DrordDrProfttl = ""
  589. order.CurrDrordFlag = "1"
  590. orders = append(orders, &order)
  591. }
  592. if subItem.Type == 3 {
  593. var order models.FsiOrderDtos
  594. order.RxID = strconv.FormatInt(item.ID, 10)
  595. order.Rxno = strconv.FormatInt(item.ID, 10)
  596. order.LongDrordFlag = "0"
  597. order.HilistType = "1"
  598. order.ChrgType = "1"
  599. order.DrordBhvr = "-"
  600. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  601. order.HosplistName = subItem.GoodInfo.GoodName
  602. order.HilistLv = "1"
  603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  604. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  605. order.HosplistName = subItem.GoodInfo.GoodName
  606. order.Cnt = subItem.Count
  607. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  608. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  610. order.OwnpayAmt = ""
  611. order.SelfpayAmt = ""
  612. order.Spec = ""
  613. order.SpecUnt = ""
  614. order.DrordBegnDate = s_tm
  615. order.DrordStopDate = ""
  616. order.DrordDrCodg = "1"
  617. order.DrordDeptName = department.Name
  618. order.DrordDrCodg = "1"
  619. order.DrordDrName = doctor_info.UserName
  620. order.DrordDrProfttl = ""
  621. order.CurrDrordFlag = "1"
  622. orders = append(orders, &order)
  623. }
  624. }
  625. }
  626. //处方医嘱信息
  627. }
  628. fed.MatnStas = "0"
  629. fed.MedfeeSumamt = "0"
  630. fed.OwnpayAmt = "0"
  631. fed.SelfpayAmt = "0"
  632. fed.AcctPayamt = "0"
  633. fed.MaAmt = "0"
  634. fed.HifpPayamt = "0"
  635. fed.SetlTotlnum = "1"
  636. fed.Insutype = his.Insutype
  637. fed.ReimFlag = "0"
  638. fed.OutSetlFlag = "0"
  639. var fopd []*models.FsiOperationDtosData
  640. data := make(map[string]interface{})
  641. data["fed"] = fed
  642. data["fdd"] = fdds
  643. data["fod"] = orders
  644. data["pd"] = pd
  645. data["pp"] = pp
  646. data["fopd"] = fopd
  647. data["trig_scen"] = trig_scen
  648. fmt.Println(data)
  649. fmt.Println(fed)
  650. fmt.Println(fdds)
  651. fmt.Println(orders)
  652. fmt.Println(pd)
  653. fmt.Println(pp)
  654. fmt.Println(fopd)
  655. client := &http.Client{}
  656. bytesData, _ := json.Marshal(data)
  657. var req *http.Request
  658. if miConfig.MdtrtareaAdmvs == "320921" {
  659. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  660. } else {
  661. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  662. }
  663. resp, _ := client.Do(req)
  664. defer resp.Body.Close()
  665. body, ioErr := ioutil.ReadAll(resp.Body)
  666. if ioErr != nil {
  667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return res
  670. }
  671. var respJSON map[string]interface{}
  672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  675. return res
  676. }
  677. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  678. fmt.Println(respJSON)
  679. result, _ := json.Marshal(respJSON)
  680. fmt.Println(result)
  681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  682. utils.ErrorLog("解析失败:%v", err)
  683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. return res
  685. }
  686. return res
  687. }
  688. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  689. adminUser := c.GetAdminUserInfo()
  690. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  691. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  693. //record_time := c.GetString("record_time")
  694. //trig_scen := c.GetString("trig_scen")
  695. timeLayout := "2006-01-02"
  696. loc, _ := time.LoadLocation("Local")
  697. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  698. if err != nil {
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. return res
  701. }
  702. recordDateTime := theTime.Unix()
  703. var patientPrescription models.HisPrescriptionInfo
  704. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  705. if patientPrescription.ID == 0 {
  706. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  707. }
  708. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  709. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  710. //
  711. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  712. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  713. var pp models.PublicParams
  714. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  715. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  716. pp.FixmedinsName = miConfig.OrgName
  717. pp.FixmedinsCode = miConfig.Code
  718. pp.RequestUrl = miConfig.Url
  719. pp.Cainfo = miConfig.Cainfo
  720. pp.SecretKey = miConfig.SecretKey
  721. pp.AccessKey = miConfig.AccessKey
  722. pp.OpterName = roles.UserName
  723. var config []*models.HisXtDiagnoseConfig
  724. for _, item := range diagnosis_ids {
  725. id, _ := strconv.ParseInt(item, 10, 64)
  726. diagnosisConfig, _ := service.FindDiagnoseById(id)
  727. config = append(config, &diagnosisConfig)
  728. }
  729. var pd models.PatientDtos
  730. pd.PatnID = his.PsnNo
  731. pd.PatnName = his.Name
  732. pd.Gend = his.Gend
  733. pd.Brdy = his.Brdy
  734. pd.Poolarea = his.InsuplcAdmdvs
  735. pd.CurrMdtrtID = his.Number
  736. var fed models.FsiEncounterDtos
  737. fed.MdtrtID = his.Number
  738. fed.MedinsID = miConfig.Code
  739. fed.MedinsName = miConfig.OrgName
  740. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  741. fed.MedMdtrtType = "1"
  742. fed.MedinsType = "1"
  743. fed.MedinsLv = "11"
  744. tm := time.Unix(his.RecordDate, 0)
  745. s_tm := tm.Format("2006-01-02 15:04:05")
  746. fed.AdmDate = s_tm
  747. fed.DscgDate = s_tm
  748. fed.DscgMainDiseCodg = config[0].CountryCode
  749. fed.DscgMainDiseName = config[0].CountryContentName
  750. //诊断信息
  751. var fdds []*models.FsiDiagnoseDtos
  752. for index, item := range config {
  753. if index == 0 {
  754. var fdd models.FsiDiagnoseDtos
  755. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  756. fdd.InoutDiseType = "1"
  757. fdd.MaindiseFlag = "1"
  758. fdd.DiseDate = s_tm
  759. fdd.DiasSrtNo = "1"
  760. fdd.DiseName = item.CountryContentName
  761. fdd.DiseCodg = item.CountryCode
  762. fdds = append(fdds, &fdd)
  763. } else {
  764. var fdd models.FsiDiagnoseDtos
  765. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  766. fdd.InoutDiseType = "1"
  767. fdd.MaindiseFlag = "1"
  768. fdd.DiseDate = s_tm
  769. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  770. fdd.DiseName = item.CountryContentName
  771. fdd.DiseCodg = item.CountryCode
  772. fdds = append(fdds, &fdd)
  773. }
  774. }
  775. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  776. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  777. fed.AdmDeptName = department.Name
  778. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  779. fed.DscgDeptName = department.Name
  780. fed.MedMdtrtType = "1"
  781. fed.MedType = "11"
  782. //if his.Insutype == "390" {
  783. // fed.MedType = "1402"
  784. //} else {
  785. // fed.MedType = "9933"
  786. //}
  787. var orders []*models.FsiOrderDtos
  788. if trig_scen == "2" {
  789. //处方医嘱信息
  790. for _, item := range prescriptions {
  791. for _, subItem := range item.HisDoctorAdviceInfo {
  792. var order models.FsiOrderDtos
  793. order.RxID = strconv.FormatInt(item.ID, 10)
  794. order.Rxno = strconv.FormatInt(item.ID, 10)
  795. order.LongDrordFlag = "0"
  796. order.HilistType = "1"
  797. order.ChrgType = "1"
  798. order.DrordBhvr = "-"
  799. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  800. order.HosplistName = subItem.BaseDrugLib.DrugName
  801. order.HilistLv = "1"
  802. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  803. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  804. order.HosplistName = subItem.BaseDrugLib.DrugName
  805. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  807. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  808. order.OwnpayAmt = ""
  809. order.SelfpayAmt = ""
  810. order.Spec = ""
  811. order.SpecUnt = ""
  812. order.DrordBegnDate = s_tm
  813. order.DrordStopDate = ""
  814. order.DrordDrCodg = "1"
  815. order.DrordDeptName = department.Name
  816. order.DrordDrCodg = "1"
  817. order.DrordDrName = doctor_info.UserName
  818. order.DrordDrProfttl = ""
  819. order.CurrDrordFlag = "1"
  820. orders = append(orders, &order)
  821. }
  822. for _, subItem := range item.HisPrescriptionProject {
  823. if subItem.Type == 2 {
  824. var order models.FsiOrderDtos
  825. order.RxID = strconv.FormatInt(item.ID, 10)
  826. order.Rxno = strconv.FormatInt(item.ID, 10)
  827. order.LongDrordFlag = "0"
  828. order.HilistType = "1"
  829. order.ChrgType = "1"
  830. order.DrordBhvr = "-"
  831. order.HilistCode = subItem.HisProject.MedicalCode
  832. order.HosplistName = subItem.HisProject.ProjectName
  833. order.HilistLv = "1"
  834. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  835. order.HosplistCode = subItem.HisProject.MedicalCode
  836. order.HosplistName = subItem.HisProject.ProjectName
  837. order.Cnt = subItem.Count
  838. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  839. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  840. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  841. order.OwnpayAmt = ""
  842. order.SelfpayAmt = ""
  843. order.Spec = ""
  844. order.SpecUnt = ""
  845. order.DrordBegnDate = s_tm
  846. order.DrordStopDate = ""
  847. order.DrordDrCodg = "1"
  848. order.DrordDeptName = department.Name
  849. order.DrordDrCodg = "1"
  850. order.DrordDrName = doctor_info.UserName
  851. order.DrordDrProfttl = ""
  852. order.CurrDrordFlag = "1"
  853. orders = append(orders, &order)
  854. }
  855. if subItem.Type == 3 {
  856. var order models.FsiOrderDtos
  857. order.RxID = strconv.FormatInt(item.ID, 10)
  858. order.Rxno = strconv.FormatInt(item.ID, 10)
  859. order.LongDrordFlag = "0"
  860. order.HilistType = "1"
  861. order.ChrgType = "1"
  862. order.DrordBhvr = "-"
  863. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  864. order.HosplistName = subItem.GoodInfo.GoodName
  865. order.HilistLv = "1"
  866. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  867. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  868. order.HosplistName = subItem.GoodInfo.GoodName
  869. order.Cnt = subItem.Count
  870. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  871. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  872. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  873. order.OwnpayAmt = ""
  874. order.SelfpayAmt = ""
  875. order.Spec = ""
  876. order.SpecUnt = ""
  877. order.DrordBegnDate = s_tm
  878. order.DrordStopDate = ""
  879. order.DrordDrCodg = "1"
  880. order.DrordDeptName = department.Name
  881. order.DrordDrCodg = "1"
  882. order.DrordDrName = doctor_info.UserName
  883. order.DrordDrProfttl = ""
  884. order.CurrDrordFlag = "1"
  885. orders = append(orders, &order)
  886. }
  887. }
  888. }
  889. //处方医嘱信息
  890. }
  891. fed.MatnStas = "0"
  892. fed.MedfeeSumamt = "0"
  893. fed.OwnpayAmt = "0"
  894. fed.SelfpayAmt = "0"
  895. fed.AcctPayamt = "0"
  896. fed.MaAmt = "0"
  897. fed.HifpPayamt = "0"
  898. fed.SetlTotlnum = "1"
  899. fed.Insutype = his.Insutype
  900. fed.ReimFlag = "0"
  901. fed.OutSetlFlag = "0"
  902. var fopd []*models.FsiOperationDtosData
  903. data := make(map[string]interface{})
  904. data["fed"] = fed
  905. data["fdd"] = fdds
  906. data["fod"] = orders
  907. data["pd"] = pd
  908. data["pp"] = pp
  909. data["fopd"] = fopd
  910. data["trig_scen"] = trig_scen
  911. fmt.Println(data)
  912. fmt.Println(fed)
  913. fmt.Println(fdds)
  914. fmt.Println(orders)
  915. fmt.Println(pd)
  916. fmt.Println(pp)
  917. fmt.Println(fopd)
  918. client := &http.Client{}
  919. bytesData, _ := json.Marshal(data)
  920. var req *http.Request
  921. if miConfig.MdtrtareaAdmvs == "320921" {
  922. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  923. } else {
  924. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  925. }
  926. resp, _ := client.Do(req)
  927. defer resp.Body.Close()
  928. body, ioErr := ioutil.ReadAll(resp.Body)
  929. if ioErr != nil {
  930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return res
  933. }
  934. var respJSON map[string]interface{}
  935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return res
  939. }
  940. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  941. result, _ := json.Marshal(respJSON)
  942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  943. utils.ErrorLog("解析失败:%v", err)
  944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  945. return res
  946. }
  947. return res
  948. }
  949. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  950. ////patient_id, _ := c.GetInt64("patient_id")
  951. //order_id, _ := c.GetInt64("order_id")
  952. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  953. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  954. //trig_scen := c.GetString("trig_scen")
  955. adminUser := c.GetAdminUserInfo()
  956. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  957. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  959. record_time := c.GetString("record_time")
  960. order, _ := service.GetHisOrderByID(order_id)
  961. timeLayout := "2006-01-02"
  962. loc, _ := time.LoadLocation("Local")
  963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  964. if err != nil {
  965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  966. return
  967. }
  968. recordDateTime := theTime.Unix()
  969. var patientPrescription models.HisPrescriptionInfo
  970. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  971. if patientPrescription.ID == 0 {
  972. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  973. }
  974. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  975. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  976. //
  977. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  978. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  979. var pp models.PublicParams
  980. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  981. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  982. pp.FixmedinsName = miConfig.OrgName
  983. pp.FixmedinsCode = miConfig.Code
  984. pp.RequestUrl = miConfig.Url
  985. pp.Cainfo = miConfig.Cainfo
  986. pp.SecretKey = miConfig.SecretKey
  987. pp.AccessKey = miConfig.AccessKey
  988. pp.OpterName = roles.UserName
  989. var config []*models.HisXtDiagnoseConfig
  990. for _, item := range diagnosis_ids {
  991. id, _ := strconv.ParseInt(item, 10, 64)
  992. diagnosisConfig, _ := service.FindDiagnoseById(id)
  993. config = append(config, &diagnosisConfig)
  994. }
  995. var pd models.PatientDtos
  996. pd.PatnID = his.PsnNo
  997. pd.PatnName = his.Name
  998. pd.Gend = his.Gend
  999. pd.Brdy = his.Brdy
  1000. pd.Poolarea = his.InsuplcAdmdvs
  1001. pd.CurrMdtrtID = his.Number
  1002. var fed models.FsiEncounterDtos
  1003. fed.MdtrtID = his.Number
  1004. fed.MedinsID = miConfig.Code
  1005. fed.MedinsName = miConfig.OrgName
  1006. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1007. fed.MedMdtrtType = "1"
  1008. fed.MedinsType = "1"
  1009. fed.MedinsLv = "11"
  1010. tm := time.Unix(his.RecordDate, 0)
  1011. s_tm := tm.Format("2006-01-02 15:04:05")
  1012. fed.AdmDate = s_tm
  1013. fed.DscgDate = s_tm
  1014. fed.DscgMainDiseCodg = config[0].CountryCode
  1015. fed.DscgMainDiseName = config[0].CountryContentName
  1016. //诊断信息
  1017. var fdds []*models.FsiDiagnoseDtos
  1018. for index, item := range config {
  1019. if index == 0 {
  1020. var fdd models.FsiDiagnoseDtos
  1021. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1022. fdd.InoutDiseType = "1"
  1023. fdd.MaindiseFlag = "1"
  1024. fdd.DiseDate = s_tm
  1025. fdd.DiasSrtNo = "1"
  1026. fdd.DiseName = item.CountryContentName
  1027. fdd.DiseCodg = item.CountryCode
  1028. fdds = append(fdds, &fdd)
  1029. } else {
  1030. var fdd models.FsiDiagnoseDtos
  1031. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1032. fdd.InoutDiseType = "1"
  1033. fdd.MaindiseFlag = "1"
  1034. fdd.DiseDate = s_tm
  1035. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1036. fdd.DiseName = item.CountryContentName
  1037. fdd.DiseCodg = item.CountryCode
  1038. fdds = append(fdds, &fdd)
  1039. }
  1040. }
  1041. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1042. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1043. fed.AdmDeptName = department.Name
  1044. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1045. fed.DscgDeptName = department.Name
  1046. fed.MedType = order.MedType
  1047. //处方医嘱信息
  1048. var orders []*models.FsiOrderDtos
  1049. //for _, item := range prescriptions {
  1050. // for _, subItem := range item.HisDoctorAdviceInfo {
  1051. // var order models.FsiOrderDtos
  1052. // order.RxID = strconv.FormatInt(item.ID, 10)
  1053. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1054. // order.LongDrordFlag = "0"
  1055. // order.HilistType = "1"
  1056. // order.ChrgType = "1"
  1057. // order.DrordBhvr = "-"
  1058. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1059. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1060. // order.HilistLv = "1"
  1061. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1062. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1063. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1064. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1065. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1066. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1067. // order.OwnpayAmt = ""
  1068. // order.SelfpayAmt = ""
  1069. // order.Spec = ""
  1070. // order.SpecUnt = ""
  1071. // order.DrordBegnDate = s_tm
  1072. // order.DrordStopDate = ""
  1073. // order.DrordDrCodg = "1"
  1074. // order.DrordDeptName = department.Name
  1075. // order.DrordDrCodg = "1"
  1076. // order.DrordDrName = doctor_info.UserName
  1077. // order.DrordDrProfttl = ""
  1078. // order.CurrDrordFlag = "1"
  1079. // orders = append(orders, &order)
  1080. // }
  1081. // for _, subItem := range item.HisPrescriptionProject {
  1082. // if subItem.Type == 2 {
  1083. // var order models.FsiOrderDtos
  1084. // order.RxID = strconv.FormatInt(item.ID, 10)
  1085. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1086. // order.LongDrordFlag = "0"
  1087. // order.HilistType = "1"
  1088. // order.ChrgType = "1"
  1089. // order.DrordBhvr = "-"
  1090. // order.HilistCode = subItem.HisProject.MedicalCode
  1091. // order.HosplistName = subItem.HisProject.ProjectName
  1092. // order.HilistLv = "1"
  1093. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1094. // order.HosplistCode = subItem.HisProject.MedicalCode
  1095. // order.HosplistName = subItem.HisProject.ProjectName
  1096. // order.Cnt = subItem.Count
  1097. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1098. //
  1099. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1100. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1101. // order.OwnpayAmt = ""
  1102. // order.SelfpayAmt = ""
  1103. // order.Spec = ""
  1104. // order.SpecUnt = ""
  1105. // order.DrordBegnDate = s_tm
  1106. // order.DrordStopDate = ""
  1107. // order.DrordDrCodg = "1"
  1108. // order.DrordDeptName = department.Name
  1109. // order.DrordDrCodg = "1"
  1110. // order.DrordDrName = doctor_info.UserName
  1111. // order.DrordDrProfttl = ""
  1112. // order.CurrDrordFlag = "1"
  1113. // orders = append(orders, &order)
  1114. //
  1115. // }
  1116. // if subItem.Type == 3 {
  1117. //
  1118. // var order models.FsiOrderDtos
  1119. // order.RxID = strconv.FormatInt(item.ID, 10)
  1120. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1121. // order.LongDrordFlag = "0"
  1122. // order.HilistType = "1"
  1123. // order.ChrgType = "1"
  1124. // order.DrordBhvr = "-"
  1125. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1126. // order.HosplistName = subItem.GoodInfo.GoodName
  1127. // order.HilistLv = "1"
  1128. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1129. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1130. // order.HosplistName = subItem.GoodInfo.GoodName
  1131. // order.Cnt = subItem.Count
  1132. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1133. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1134. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1135. // order.OwnpayAmt = ""
  1136. // order.SelfpayAmt = ""
  1137. // order.Spec = ""
  1138. // order.SpecUnt = ""
  1139. // order.DrordBegnDate = s_tm
  1140. // order.DrordStopDate = ""
  1141. // order.DrordDrCodg = "1"
  1142. // order.DrordDeptName = department.Name
  1143. // order.DrordDrCodg = "1"
  1144. // order.DrordDrName = doctor_info.UserName
  1145. // order.DrordDrProfttl = ""
  1146. // order.CurrDrordFlag = "1"
  1147. // orders = append(orders, &order)
  1148. //
  1149. // }
  1150. // }
  1151. //}
  1152. for _, item := range prescriptions {
  1153. for _, subItem := range item.HisDoctorAdviceInfo {
  1154. var order models.FsiOrderDtos
  1155. order.RxID = strconv.FormatInt(item.ID, 10)
  1156. order.Rxno = strconv.FormatInt(item.ID, 10)
  1157. order.LongDrordFlag = "0"
  1158. order.HilistType = "1"
  1159. order.ChrgType = "1"
  1160. order.DrordBhvr = "-"
  1161. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1162. order.HosplistName = subItem.BaseDrugLib.DrugName
  1163. order.HilistLv = "1"
  1164. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1165. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1166. order.HosplistName = subItem.BaseDrugLib.DrugName
  1167. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1169. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1170. order.OwnpayAmt = ""
  1171. order.SelfpayAmt = ""
  1172. order.Spec = ""
  1173. order.SpecUnt = ""
  1174. order.DrordBegnDate = s_tm
  1175. order.DrordStopDate = ""
  1176. order.DrordDrCodg = "1"
  1177. order.DrordDeptName = department.Name
  1178. order.DrordDrCodg = "1"
  1179. order.DrordDrName = doctor_info.UserName
  1180. order.DrordDrProfttl = ""
  1181. order.CurrDrordFlag = "1"
  1182. orders = append(orders, &order)
  1183. }
  1184. for _, subItem := range item.HisPrescriptionProject {
  1185. if subItem.Type == 2 {
  1186. var order models.FsiOrderDtos
  1187. order.RxID = strconv.FormatInt(item.ID, 10)
  1188. order.Rxno = strconv.FormatInt(item.ID, 10)
  1189. order.LongDrordFlag = "0"
  1190. order.HilistType = "1"
  1191. order.ChrgType = "1"
  1192. order.DrordBhvr = "-"
  1193. order.HilistCode = subItem.HisProject.MedicalCode
  1194. order.HosplistName = subItem.HisProject.ProjectName
  1195. order.HilistLv = "1"
  1196. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1197. order.HosplistCode = subItem.HisProject.MedicalCode
  1198. order.HosplistName = subItem.HisProject.ProjectName
  1199. order.Cnt = subItem.Count
  1200. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1201. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1202. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1203. order.OwnpayAmt = ""
  1204. order.SelfpayAmt = ""
  1205. order.Spec = ""
  1206. order.SpecUnt = ""
  1207. order.DrordBegnDate = s_tm
  1208. order.DrordStopDate = ""
  1209. order.DrordDrCodg = "1"
  1210. order.DrordDeptName = department.Name
  1211. order.DrordDrCodg = "1"
  1212. order.DrordDrName = doctor_info.UserName
  1213. order.DrordDrProfttl = ""
  1214. order.CurrDrordFlag = "1"
  1215. orders = append(orders, &order)
  1216. }
  1217. if subItem.Type == 3 {
  1218. var order models.FsiOrderDtos
  1219. order.RxID = strconv.FormatInt(item.ID, 10)
  1220. order.Rxno = strconv.FormatInt(item.ID, 10)
  1221. order.LongDrordFlag = "0"
  1222. order.HilistType = "1"
  1223. order.ChrgType = "1"
  1224. order.DrordBhvr = "-"
  1225. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1226. order.HosplistName = subItem.GoodInfo.GoodName
  1227. order.HilistLv = "1"
  1228. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1229. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1230. order.HosplistName = subItem.GoodInfo.GoodName
  1231. order.Cnt = subItem.Count
  1232. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1233. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1234. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1235. order.OwnpayAmt = ""
  1236. order.SelfpayAmt = ""
  1237. order.Spec = ""
  1238. order.SpecUnt = ""
  1239. order.DrordBegnDate = s_tm
  1240. order.DrordStopDate = ""
  1241. order.DrordDrCodg = "1"
  1242. order.DrordDeptName = department.Name
  1243. order.DrordDrCodg = "1"
  1244. order.DrordDrName = doctor_info.UserName
  1245. order.DrordDrProfttl = ""
  1246. order.CurrDrordFlag = "1"
  1247. orders = append(orders, &order)
  1248. }
  1249. }
  1250. }
  1251. //处方医嘱信息
  1252. fed.MatnStas = "0"
  1253. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1254. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1255. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1256. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1257. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1258. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1259. fed.SetlTotlnum = "1"
  1260. fed.Insutype = his.Insutype
  1261. fed.ReimFlag = "0"
  1262. fed.OutSetlFlag = "0"
  1263. var fopd []*models.FsiOperationDtosData
  1264. data := make(map[string]interface{})
  1265. data["fed"] = fed
  1266. data["fdd"] = fdds
  1267. data["fod"] = orders
  1268. data["pd"] = pd
  1269. data["pp"] = pp
  1270. data["fopd"] = fopd
  1271. data["trig_scen"] = trig_scen
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return res
  1287. }
  1288. var respJSON map[string]interface{}
  1289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return res
  1293. }
  1294. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1295. result, _ := json.Marshal(respJSON)
  1296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return res
  1300. }
  1301. return res
  1302. //手术操作集合
  1303. //手术操作集合
  1304. }
  1305. func (c *HisApiController) Check() {
  1306. psn_no := c.GetString("psn_no")
  1307. in := c.GetString("in")
  1308. mt := c.GetString("mt")
  1309. baseParams := models.BaseParams{
  1310. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1311. FixmedinsCode: "H15049901371",
  1312. InsuplcAdmdvs: "150499",
  1313. MdtrtareaAdmvs: "150499",
  1314. OrgName: "赤峰费森血液透析中心",
  1315. Doctor: "1111",
  1316. }
  1317. service.Gdyb2001(baseParams, psn_no, in, mt)
  1318. }
  1319. func (c *HisApiController) GetPsnNcdsInfo() {
  1320. admin_user_id, _ := c.GetInt64("admin_user_id")
  1321. patient_id, _ := c.GetInt64("patient_id")
  1322. id, _ := c.GetInt64("id")
  1323. adminUser := c.GetAdminUserInfo()
  1324. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1325. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1326. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1327. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1328. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1329. //
  1330. //if psn_record.ID == 0 {
  1331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1332. // return
  1333. //}
  1334. var res Result5301
  1335. var res10265 Result5301For10265
  1336. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1337. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1338. var api string
  1339. if miConfig.MdtrtareaAdmvs == "320921" {
  1340. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1342. } else {
  1343. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1345. }
  1346. resp, requestErr := http.Get(api)
  1347. if requestErr != nil {
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. body, ioErr := ioutil.ReadAll(resp.Body)
  1352. if ioErr != nil {
  1353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. var respJSON map[string]interface{}
  1358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1364. result, _ := json.Marshal(respJSON)
  1365. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1366. utils.ErrorLog("解析失败:%v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. res.ErrMsg = res10265.ErrMsg
  1371. res.Output = res10265.Output
  1372. res.InfRefmsgid = res10265.InfRefmsgid
  1373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1374. res.Infcode = infocode
  1375. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1376. p, _ := service.GetHisPatientById(patient_id)
  1377. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1378. var dat map[string]interface{}
  1379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1380. fmt.Println(dat)
  1381. } else {
  1382. fmt.Println(err)
  1383. }
  1384. userJSONBytes, _ := json.Marshal(dat)
  1385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1386. utils.ErrorLog("解析失败:%v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1391. p, _ := service.GetHisPatientById(patient_id)
  1392. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1393. var dat map[string]interface{}
  1394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1395. fmt.Println(dat)
  1396. } else {
  1397. fmt.Println(err)
  1398. }
  1399. userJSONBytes, _ := json.Marshal(dat)
  1400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1401. utils.ErrorLog("解析失败:%v", err)
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1403. return
  1404. }
  1405. } else {
  1406. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1407. var dat map[string]interface{}
  1408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1409. fmt.Println(dat)
  1410. } else {
  1411. fmt.Println(err)
  1412. }
  1413. userJSONBytes, _ := json.Marshal(dat)
  1414. if miConfig.Code == "H15049901371" {
  1415. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. res.InfRefmsgid = res10265.InfRefmsgid
  1421. res.Output = res10265.Output
  1422. res.ErrMsg = res10265.ErrMsg
  1423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1424. res.Infcode = infocode
  1425. } else {
  1426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1427. utils.ErrorLog("解析失败:%v", err)
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1429. return
  1430. }
  1431. }
  1432. }
  1433. if res.Infcode == 0 {
  1434. c.ServeSuccessJSON(map[string]interface{}{
  1435. "result": res.Output.Result,
  1436. })
  1437. }
  1438. }
  1439. func (c *HisApiController) CheckInsutype() {
  1440. his_patient_id, _ := c.GetInt64("his_patient_id")
  1441. admin_user_id, _ := c.GetInt64("admin_user_id")
  1442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1445. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res Result90100
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. if res.Infcode != 0 {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "failed_code": -10,
  1462. "msg": res.ErrMsg,
  1463. })
  1464. return
  1465. } else {
  1466. fmt.Println(res)
  1467. }
  1468. }
  1469. func (c *HisApiController) CheckCardPWD() {
  1470. card_pwd := c.GetString("card_pwd")
  1471. his_patient_id, _ := c.GetInt64("his_patient_id")
  1472. admin_user_id, _ := c.GetInt64("admin_user_id")
  1473. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1475. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1476. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1477. bas := strings.Split(psn.CardInfo, "|")
  1478. basNumber := bas[2]
  1479. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1480. var dat map[string]interface{}
  1481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1482. fmt.Println(dat)
  1483. } else {
  1484. fmt.Println(err)
  1485. }
  1486. userJSONBytes, _ := json.Marshal(dat)
  1487. var res Result90991
  1488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1489. utils.ErrorLog("解析失败:%v", err)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. if res.Infcode != 0 {
  1494. c.ServeSuccessJSON(map[string]interface{}{
  1495. "failed_code": -10,
  1496. "msg": res.ErrMsg,
  1497. })
  1498. return
  1499. } else {
  1500. if res.Output.Result.SscnoCheckStat == "0" {
  1501. var msg string
  1502. switch res.Output.Result.CardStat {
  1503. case "00":
  1504. msg = "未激活"
  1505. break
  1506. case "10":
  1507. msg = "激活"
  1508. break
  1509. case "20":
  1510. msg = "窗口挂失"
  1511. break
  1512. case "21":
  1513. msg = "电话挂失"
  1514. break
  1515. case "22":
  1516. msg = "单位网上申报挂失"
  1517. break
  1518. case "23":
  1519. msg = "保健办挂失"
  1520. break
  1521. case "24":
  1522. msg = "个人网上挂失"
  1523. break
  1524. case "25":
  1525. msg = "网上服务大厅挂失"
  1526. break
  1527. case "30":
  1528. msg = "注销"
  1529. break
  1530. case "40":
  1531. msg = "回收"
  1532. break
  1533. case "99":
  1534. msg = "制卡中(无效卡)"
  1535. break
  1536. }
  1537. c.ServeSuccessJSON(map[string]interface{}{
  1538. "failed_code": -10,
  1539. "msg": msg,
  1540. })
  1541. return
  1542. } else {
  1543. c.ServeSuccessJSON(map[string]interface{}{
  1544. "msg": "校验成功",
  1545. })
  1546. return
  1547. }
  1548. }
  1549. }
  1550. func (c *HisApiController) CheckCardPWDTwo() {
  1551. //card_pwd := c.GetString("card_pwd")
  1552. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1553. admin_user_id, _ := c.GetInt64("admin_user_id")
  1554. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1556. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1557. var dat map[string]interface{}
  1558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1559. fmt.Println(dat)
  1560. } else {
  1561. fmt.Println(err)
  1562. }
  1563. userJSONBytes, _ := json.Marshal(dat)
  1564. var res Result90991
  1565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1566. utils.ErrorLog("解析失败:%v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. if res.Infcode != 0 {
  1571. c.ServeSuccessJSON(map[string]interface{}{
  1572. "failed_code": -10,
  1573. "msg": res.ErrMsg,
  1574. })
  1575. return
  1576. } else {
  1577. if res.Output.Result.SscnoCheckStat == "0" {
  1578. var msg string
  1579. switch res.Output.Result.CardStat {
  1580. case "00":
  1581. msg = "未激活"
  1582. break
  1583. case "10":
  1584. msg = "激活"
  1585. break
  1586. case "20":
  1587. msg = "窗口挂失"
  1588. break
  1589. case "21":
  1590. msg = "电话挂失"
  1591. break
  1592. case "22":
  1593. msg = "单位网上申报挂失"
  1594. break
  1595. case "23":
  1596. msg = "保健办挂失"
  1597. break
  1598. case "24":
  1599. msg = "个人网上挂失"
  1600. break
  1601. case "25":
  1602. msg = "网上服务大厅挂失"
  1603. break
  1604. case "30":
  1605. msg = "注销"
  1606. break
  1607. case "40":
  1608. msg = "回收"
  1609. break
  1610. case "99":
  1611. msg = "制卡中(无效卡)"
  1612. break
  1613. }
  1614. c.ServeSuccessJSON(map[string]interface{}{
  1615. "failed_code": -10,
  1616. "msg": msg,
  1617. })
  1618. return
  1619. } else {
  1620. c.ServeSuccessJSON(map[string]interface{}{
  1621. "msg": "校验成功",
  1622. })
  1623. return
  1624. }
  1625. }
  1626. }
  1627. type ELeCertData struct {
  1628. Data struct {
  1629. Extra string `json:"extra"`
  1630. IDNo string `json:"idNo"`
  1631. IDType string `json:"idType"`
  1632. EcToken string `json:"ecToken"`
  1633. InsuOrg string `json:"insuOrg"`
  1634. UserName string `json:"userName"`
  1635. EcIndexNo string `json:"ecIndexNo"`
  1636. Gender string `json:"gender"`
  1637. Birthday string `json:"birthday"`
  1638. Nationality string `json:"nationality"`
  1639. Email string `json:"email"`
  1640. } `json:"OutData"`
  1641. }
  1642. func (c *HisApiController) ReadCard() {
  1643. id_card_type, _ := c.GetInt64("id_card_type")
  1644. admin_user_id, _ := c.GetInt64("admin_user_id")
  1645. certificates, _ := c.GetInt64("certificates")
  1646. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1648. switch id_card_type {
  1649. case 1:
  1650. if miConfig.MdtrtareaAdmvs == "421300" {
  1651. var res ResultTwo
  1652. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1653. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1655. resp, requestErr := http.Get(api)
  1656. if requestErr != nil {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. var respJSON map[string]interface{}
  1667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. fmt.Println("log")
  1675. fmt.Println(string(result))
  1676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1677. utils.ErrorLog("解析失败:%v", err)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. if res.Infcode == 0 {
  1682. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1683. if err == gorm.ErrRecordNotFound {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1685. return
  1686. } else if err != nil {
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1688. return
  1689. } else {
  1690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1692. infoStr := string(Iinfos)
  1693. idetinfoStr := string(Idetinfos)
  1694. psn := &models.HisPsn{
  1695. PsnNo: res.Output.Baseinfo.PsnNo,
  1696. Age: res.Output.Baseinfo.Age,
  1697. PatientId: patient.ID,
  1698. Certno: res.Output.Baseinfo.Certno,
  1699. Brdy: res.Output.Baseinfo.Brdy,
  1700. Gend: res.Output.Baseinfo.Gend,
  1701. Naty: res.Output.Baseinfo.Naty,
  1702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1703. PsnName: res.Output.Baseinfo.PsnName,
  1704. Idetinfo: idetinfoStr,
  1705. Insuinfo: infoStr,
  1706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1707. }
  1708. service.CreateHisPsn(psn)
  1709. c.ServeSuccessJSON(map[string]interface{}{
  1710. "patient": patient,
  1711. "number": res.Output.Baseinfo.Certno,
  1712. })
  1713. }
  1714. } else {
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1716. return
  1717. }
  1718. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1719. var api string
  1720. if miConfig.MdtrtareaAdmvs == "320921" {
  1721. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1722. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1723. fmt.Println(api)
  1724. } else {
  1725. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1726. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1727. }
  1728. resp, requestErr := http.Get(api)
  1729. if requestErr != nil {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. body, ioErr := ioutil.ReadAll(resp.Body)
  1734. if ioErr != nil {
  1735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1737. return
  1738. }
  1739. var respJSON map[string]interface{}
  1740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1743. return
  1744. }
  1745. var status string
  1746. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1747. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1748. //console.log()
  1749. fmt.Println("type===")
  1750. fmt.Println(card_type)
  1751. var token string
  1752. var res ResultTwo //1101结果
  1753. var res10265 ResultTwo10265 //1101结果
  1754. var card_info string //卡信息
  1755. var busi_card_info string
  1756. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1757. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1758. if status == "0" { //读卡成功
  1759. if card_type == "1" {
  1760. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1761. result, _ := json.Marshal(respJSON)
  1762. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1763. utils.ErrorLog("解析失败:%v", err)
  1764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1765. return
  1766. }
  1767. res.ErrMsg = res10265.ErrMsg
  1768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1769. res.Infcode = infocode
  1770. res.Output = res10265.Output
  1771. res.InfRefmsgid = res10265.InfRefmsgid
  1772. } else {
  1773. //var card_info string //卡信息
  1774. //var busi_card_info string
  1775. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1776. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1777. //fmt.Println(card_info)
  1778. //fmt.Println(busi_card_info)
  1779. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1780. result, _ := json.Marshal(respJSON)
  1781. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1782. utils.ErrorLog("解析失败:%v", err)
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1784. return
  1785. }
  1786. res.ErrMsg = res10265.ErrMsg
  1787. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1788. res.Infcode = infocode
  1789. res.Output = res10265.Output
  1790. res.InfRefmsgid = res10265.InfRefmsgid
  1791. }
  1792. if res.Infcode == 0 {
  1793. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1794. if err == gorm.ErrRecordNotFound {
  1795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1796. return
  1797. } else if err != nil {
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1799. return
  1800. } else {
  1801. if card_type == "1" {
  1802. bas := strings.Split(card_info, "|")
  1803. basNumber := bas[2]
  1804. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1805. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1806. infoStr := string(Iinfos)
  1807. idetinfoStr := string(Idetinfos)
  1808. psn := &models.HisPsn{
  1809. PsnNo: res.Output.Baseinfo.PsnNo,
  1810. Age: res.Output.Baseinfo.Age,
  1811. PatientId: patient.ID,
  1812. Certno: res.Output.Baseinfo.Certno,
  1813. Brdy: res.Output.Baseinfo.Brdy,
  1814. Gend: res.Output.Baseinfo.Gend,
  1815. Naty: res.Output.Baseinfo.Naty,
  1816. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1817. PsnName: res.Output.Baseinfo.PsnName,
  1818. Idetinfo: idetinfoStr,
  1819. Insuinfo: infoStr,
  1820. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1821. CardInfo: card_info,
  1822. VerifyNumber: busi_card_info,
  1823. }
  1824. service.CreateHisPsn(psn)
  1825. var rf []*ResultFive
  1826. json.Unmarshal([]byte(infoStr), &rf)
  1827. var insutypes []*ResultFive
  1828. var insutype string
  1829. var is390 int = 0
  1830. var is310 int = 0
  1831. for _, item := range rf {
  1832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1833. insutypes = append(insutypes, item)
  1834. }
  1835. }
  1836. if len(insutypes) == 1 {
  1837. insutype = insutypes[0].Insutype
  1838. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1839. } else {
  1840. for _, i := range insutypes {
  1841. if i.Insutype == "390" {
  1842. is390 = 1
  1843. }
  1844. if i.Insutype == "310" {
  1845. is310 = 1
  1846. }
  1847. }
  1848. }
  1849. if is390 == 1 {
  1850. insutype = "390"
  1851. }
  1852. if is310 == 1 {
  1853. insutype = "310"
  1854. }
  1855. if len(insutypes) == 0 {
  1856. insutype = "310"
  1857. }
  1858. c.ServeSuccessJSON(map[string]interface{}{
  1859. "patient": patient,
  1860. "number": basNumber,
  1861. "insutype": insutype,
  1862. })
  1863. } else {
  1864. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1865. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1866. infoStr := string(Iinfos)
  1867. idetinfoStr := string(Idetinfos)
  1868. psn := &models.HisPsn{
  1869. PsnNo: res.Output.Baseinfo.PsnNo,
  1870. Age: res.Output.Baseinfo.Age,
  1871. PatientId: patient.ID,
  1872. Certno: res.Output.Baseinfo.Certno,
  1873. Brdy: res.Output.Baseinfo.Brdy,
  1874. Gend: res.Output.Baseinfo.Gend,
  1875. Naty: res.Output.Baseinfo.Naty,
  1876. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1877. PsnName: res.Output.Baseinfo.PsnName,
  1878. Idetinfo: idetinfoStr,
  1879. Insuinfo: infoStr,
  1880. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1881. CardInfo: card_info,
  1882. VerifyNumber: token,
  1883. }
  1884. service.CreateHisPsn(psn)
  1885. c.ServeSuccessJSON(map[string]interface{}{
  1886. "patient": patient,
  1887. "number": token,
  1888. })
  1889. }
  1890. }
  1891. } else {
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1893. return
  1894. }
  1895. } else { //读卡失败
  1896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1897. return
  1898. }
  1899. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1900. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1901. cardnum = DeleteExtraSpaceTwo(cardnum)
  1902. cardCode = DeleteExtraSpaceTwo(cardCode)
  1903. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1904. name = DeleteExtraSpaceTwo(name)
  1905. errmsg = DeleteExtraSpaceTwo(errmsg)
  1906. cardnum = Remove0000(cardnum)
  1907. cardCode = Remove0000(cardCode)
  1908. id_card_no = Remove0000(id_card_no)
  1909. name = Remove0000(name)
  1910. errmsg = Remove0000(errmsg)
  1911. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1912. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1913. saveLog(result, requestLog, "1101", "获取人员信息")
  1914. fmt.Println(errMsgLog)
  1915. if len(errMsgLog) > 0 {
  1916. } else {
  1917. var dat map[string]interface{}
  1918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1919. fmt.Println(dat)
  1920. } else {
  1921. fmt.Println(err)
  1922. }
  1923. userJSONBytes, _ := json.Marshal(dat)
  1924. var res ResultTwo
  1925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1926. utils.ErrorLog("解析失败:%v", err)
  1927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. return
  1929. }
  1930. res.ErrMsg = errMsgLog
  1931. if res.Infcode == 0 {
  1932. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1933. if err == gorm.ErrRecordNotFound {
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1935. return
  1936. } else if err != nil {
  1937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1938. return
  1939. } else {
  1940. fmt.Println(res)
  1941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1943. infoStr := string(Iinfos)
  1944. idetinfoStr := string(Idetinfos)
  1945. psn := &models.HisPsn{
  1946. PsnNo: res.Output.Baseinfo.PsnNo,
  1947. Age: res.Output.Baseinfo.Age,
  1948. PatientId: patient.ID,
  1949. Certno: res.Output.Baseinfo.Certno,
  1950. Brdy: res.Output.Baseinfo.Brdy,
  1951. Gend: res.Output.Baseinfo.Gend,
  1952. Naty: res.Output.Baseinfo.Naty,
  1953. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1954. PsnName: res.Output.Baseinfo.PsnName,
  1955. Idetinfo: idetinfoStr,
  1956. Insuinfo: infoStr,
  1957. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1958. CardInfo: basStr,
  1959. VerifyNumber: "",
  1960. }
  1961. service.CreateHisPsn(psn)
  1962. var rf []*ResultFive
  1963. json.Unmarshal([]byte(infoStr), &rf)
  1964. var insutypes []*ResultFive
  1965. var insutype string
  1966. var is390 int = 0
  1967. var is310 int = 0
  1968. for _, item := range rf {
  1969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1970. insutypes = append(insutypes, item)
  1971. }
  1972. }
  1973. if len(insutypes) == 1 {
  1974. insutype = insutypes[0].Insutype
  1975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1976. } else {
  1977. for _, i := range insutypes {
  1978. if i.Insutype == "390" {
  1979. is390 = 1
  1980. }
  1981. if i.Insutype == "310" {
  1982. is310 = 1
  1983. }
  1984. }
  1985. }
  1986. if is390 == 1 {
  1987. insutype = "390"
  1988. }
  1989. if is310 == 1 {
  1990. insutype = "310"
  1991. }
  1992. if len(insutypes) == 0 {
  1993. insutype = "310"
  1994. }
  1995. c.ServeSuccessJSON(map[string]interface{}{
  1996. "patient": patient,
  1997. "number": cardnum,
  1998. "insutype": insutype,
  1999. })
  2000. }
  2001. } else {
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2003. return
  2004. }
  2005. }
  2006. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2007. fmt.Println(initFlag)
  2008. fmt.Println("initFlag")
  2009. if initFlag == 0 {
  2010. c.TestGetJiangXiBasBaseInit()
  2011. }
  2012. basStr := c.GetBasBaseInfo()
  2013. if len(basStr) == 0 {
  2014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2015. return
  2016. }
  2017. fmt.Println(basStr)
  2018. bas := strings.Split(basStr, "|")
  2019. basNumber := bas[1]
  2020. fmt.Println(basNumber)
  2021. card_sn := bas[3]
  2022. fmt.Println(card_sn)
  2023. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2024. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2025. var dat map[string]interface{}
  2026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2027. fmt.Println(dat)
  2028. } else {
  2029. fmt.Println(err)
  2030. }
  2031. userJSONBytes, _ := json.Marshal(dat)
  2032. var res ResultTwo
  2033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2034. utils.ErrorLog("解析失败:%v", err)
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. return
  2037. }
  2038. if res.Infcode == 0 {
  2039. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2040. if err == gorm.ErrRecordNotFound {
  2041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2042. return
  2043. } else if err != nil {
  2044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2045. return
  2046. } else {
  2047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2048. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2049. infoStr := string(Iinfos)
  2050. idetinfoStr := string(Idetinfos)
  2051. psn := &models.HisPsn{
  2052. PsnNo: res.Output.Baseinfo.PsnNo,
  2053. Age: res.Output.Baseinfo.Age,
  2054. PatientId: patient.ID,
  2055. Certno: res.Output.Baseinfo.Certno,
  2056. Brdy: res.Output.Baseinfo.Brdy,
  2057. Gend: res.Output.Baseinfo.Gend,
  2058. Naty: res.Output.Baseinfo.Naty,
  2059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2060. PsnName: res.Output.Baseinfo.PsnName,
  2061. Idetinfo: idetinfoStr,
  2062. Insuinfo: infoStr,
  2063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2064. CardInfo: basStr,
  2065. VerifyNumber: "",
  2066. }
  2067. service.CreateHisPsn(psn)
  2068. var rf []*ResultFive
  2069. json.Unmarshal([]byte(infoStr), &rf)
  2070. var insutypes []*ResultFive
  2071. var insutype string
  2072. var is390 int = 0
  2073. var is310 int = 0
  2074. for _, item := range rf {
  2075. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2076. insutypes = append(insutypes, item)
  2077. }
  2078. }
  2079. if len(insutypes) == 1 {
  2080. insutype = insutypes[0].Insutype
  2081. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2082. } else {
  2083. for _, i := range insutypes {
  2084. if i.Insutype == "390" {
  2085. is390 = 1
  2086. }
  2087. if i.Insutype == "310" {
  2088. is310 = 1
  2089. }
  2090. }
  2091. }
  2092. if is390 == 1 {
  2093. insutype = "390"
  2094. }
  2095. if is310 == 1 {
  2096. insutype = "310"
  2097. }
  2098. if len(insutypes) == 0 {
  2099. insutype = "310"
  2100. }
  2101. c.ServeSuccessJSON(map[string]interface{}{
  2102. "patient": patient,
  2103. "number": basNumber,
  2104. "insutype": insutype,
  2105. })
  2106. }
  2107. } else {
  2108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2109. return
  2110. }
  2111. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2112. fmt.Println(initFlag)
  2113. fmt.Println("initFlag")
  2114. if initFlag == 0 {
  2115. c.TestGetHnBasBaseInit()
  2116. }
  2117. basStr := c.GetBasBaseInfo()
  2118. if len(basStr) == 0 {
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2120. return
  2121. }
  2122. fmt.Println(basStr)
  2123. bas := strings.Split(basStr, "|")
  2124. basNumber := bas[1]
  2125. fmt.Println(basNumber)
  2126. card_sn := bas[3]
  2127. fmt.Println(card_sn)
  2128. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2129. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2130. var dat map[string]interface{}
  2131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2132. fmt.Println(dat)
  2133. } else {
  2134. fmt.Println(err)
  2135. }
  2136. userJSONBytes, _ := json.Marshal(dat)
  2137. var res ResultTwo
  2138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2139. utils.ErrorLog("解析失败:%v", err)
  2140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. return
  2142. }
  2143. if res.Infcode == 0 {
  2144. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2145. if err == gorm.ErrRecordNotFound {
  2146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2147. return
  2148. } else if err != nil {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2150. return
  2151. } else {
  2152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2154. infoStr := string(Iinfos)
  2155. idetinfoStr := string(Idetinfos)
  2156. psn := &models.HisPsn{
  2157. PsnNo: res.Output.Baseinfo.PsnNo,
  2158. Age: res.Output.Baseinfo.Age,
  2159. PatientId: patient.ID,
  2160. Certno: res.Output.Baseinfo.Certno,
  2161. Brdy: res.Output.Baseinfo.Brdy,
  2162. Gend: res.Output.Baseinfo.Gend,
  2163. Naty: res.Output.Baseinfo.Naty,
  2164. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2165. PsnName: res.Output.Baseinfo.PsnName,
  2166. Idetinfo: idetinfoStr,
  2167. Insuinfo: infoStr,
  2168. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2169. CardInfo: basStr,
  2170. VerifyNumber: "",
  2171. }
  2172. service.CreateHisPsn(psn)
  2173. var rf []*ResultFive
  2174. json.Unmarshal([]byte(infoStr), &rf)
  2175. var insutypes []*ResultFive
  2176. var insutype string
  2177. var is390 int = 0
  2178. var is310 int = 0
  2179. for _, item := range rf {
  2180. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2181. insutypes = append(insutypes, item)
  2182. }
  2183. }
  2184. if len(insutypes) == 1 {
  2185. insutype = insutypes[0].Insutype
  2186. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2187. } else {
  2188. for _, i := range insutypes {
  2189. if i.Insutype == "390" {
  2190. is390 = 1
  2191. }
  2192. if i.Insutype == "310" {
  2193. is310 = 1
  2194. }
  2195. }
  2196. }
  2197. if is390 == 1 {
  2198. insutype = "390"
  2199. }
  2200. if is310 == 1 {
  2201. insutype = "310"
  2202. }
  2203. if len(insutypes) == 0 {
  2204. insutype = "310"
  2205. }
  2206. c.ServeSuccessJSON(map[string]interface{}{
  2207. "patient": patient,
  2208. "number": basNumber,
  2209. "insutype": insutype,
  2210. })
  2211. }
  2212. } else {
  2213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2214. return
  2215. }
  2216. } else {
  2217. if initFlag == 0 {
  2218. c.TestGetBasBaseInit()
  2219. }
  2220. basStr := c.GetBasBaseInfo()
  2221. if len(basStr) == 0 {
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2223. return
  2224. }
  2225. fmt.Println(basStr)
  2226. bas := strings.Split(basStr, "|")
  2227. basNumber := bas[1]
  2228. fmt.Println(basNumber)
  2229. card_sn := bas[3]
  2230. fmt.Println(card_sn)
  2231. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2232. var dat map[string]interface{}
  2233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2234. fmt.Println(dat)
  2235. } else {
  2236. fmt.Println(err)
  2237. }
  2238. userJSONBytes, _ := json.Marshal(dat)
  2239. var res ResultTwo
  2240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. if res.Infcode == 0 {
  2246. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2247. if err == gorm.ErrRecordNotFound {
  2248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2249. return
  2250. } else if err != nil {
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2252. return
  2253. } else {
  2254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2256. infoStr := string(Iinfos)
  2257. idetinfoStr := string(Idetinfos)
  2258. psn := &models.HisPsn{
  2259. PsnNo: res.Output.Baseinfo.PsnNo,
  2260. Age: res.Output.Baseinfo.Age,
  2261. PatientId: patient.ID,
  2262. Certno: res.Output.Baseinfo.Certno,
  2263. Brdy: res.Output.Baseinfo.Brdy,
  2264. Gend: res.Output.Baseinfo.Gend,
  2265. Naty: res.Output.Baseinfo.Naty,
  2266. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2267. PsnName: res.Output.Baseinfo.PsnName,
  2268. Idetinfo: idetinfoStr,
  2269. Insuinfo: infoStr,
  2270. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2271. CardInfo: basStr,
  2272. VerifyNumber: "",
  2273. }
  2274. service.CreateHisPsn(psn)
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "patient": patient,
  2277. "number": basNumber,
  2278. })
  2279. }
  2280. } else {
  2281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2282. return
  2283. }
  2284. break
  2285. }
  2286. case 2:
  2287. SFZStr := c.GetSFZBaseInfo()
  2288. id_card_str := strings.Split(SFZStr, "^")
  2289. id_card_number := id_card_str[0]
  2290. card_sn := ""
  2291. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2292. var dat map[string]interface{}
  2293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2294. fmt.Println(dat)
  2295. } else {
  2296. fmt.Println(err)
  2297. }
  2298. userJSONBytes, _ := json.Marshal(dat)
  2299. var res ResultTwo
  2300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2301. utils.ErrorLog("解析失败:%v", err)
  2302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2303. return
  2304. }
  2305. if res.Infcode == 0 {
  2306. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2307. if err == gorm.ErrRecordNotFound {
  2308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2309. return
  2310. } else if err != nil {
  2311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2312. return
  2313. } else {
  2314. c.ServeSuccessJSON(map[string]interface{}{
  2315. "patient": patient,
  2316. "number": id_card_number,
  2317. })
  2318. }
  2319. } else {
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2321. return
  2322. }
  2323. break
  2324. case 3:
  2325. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2326. var api string
  2327. if miConfig.MdtrtareaAdmvs == "320921" {
  2328. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2329. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2330. fmt.Println(api)
  2331. } else {
  2332. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2333. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2334. }
  2335. resp, requestErr := http.Get(api)
  2336. if requestErr != nil {
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. return
  2339. }
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. var respJSON map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. var status string
  2353. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2354. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2355. var token string
  2356. var res ResultTwo //1101结果
  2357. var res10265 ResultTwo10265 //1101结果
  2358. var card_info string //卡信息
  2359. var busi_card_info string
  2360. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2361. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2362. if status == "0" { //读卡成功
  2363. if card_type == "1" {
  2364. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2365. result, _ := json.Marshal(respJSON)
  2366. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2367. utils.ErrorLog("解析失败:%v", err)
  2368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2369. return
  2370. }
  2371. res.ErrMsg = res10265.ErrMsg
  2372. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2373. res.Infcode = infocode
  2374. res.Output = res10265.Output
  2375. res.InfRefmsgid = res10265.InfRefmsgid
  2376. } else {
  2377. //var card_info string //卡信息
  2378. //var busi_card_info string
  2379. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2380. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2381. //fmt.Println(card_info)
  2382. //fmt.Println(busi_card_info)
  2383. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2384. result, _ := json.Marshal(respJSON)
  2385. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2386. utils.ErrorLog("解析失败:%v", err)
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. return
  2389. }
  2390. res.ErrMsg = res10265.ErrMsg
  2391. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2392. res.Infcode = infocode
  2393. res.Output = res10265.Output
  2394. res.InfRefmsgid = res10265.InfRefmsgid
  2395. }
  2396. if res.Infcode == 0 {
  2397. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2398. if err == gorm.ErrRecordNotFound {
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2400. return
  2401. } else if err != nil {
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2403. return
  2404. } else {
  2405. if card_type == "1" {
  2406. bas := strings.Split(card_info, "|")
  2407. basNumber := bas[2]
  2408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2410. infoStr := string(Iinfos)
  2411. idetinfoStr := string(Idetinfos)
  2412. psn := &models.HisPsn{
  2413. PsnNo: res.Output.Baseinfo.PsnNo,
  2414. Age: res.Output.Baseinfo.Age,
  2415. PatientId: patient.ID,
  2416. Certno: res.Output.Baseinfo.Certno,
  2417. Brdy: res.Output.Baseinfo.Brdy,
  2418. Gend: res.Output.Baseinfo.Gend,
  2419. Naty: res.Output.Baseinfo.Naty,
  2420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2421. PsnName: res.Output.Baseinfo.PsnName,
  2422. Idetinfo: idetinfoStr,
  2423. Insuinfo: infoStr,
  2424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2425. CardInfo: card_info,
  2426. VerifyNumber: busi_card_info,
  2427. }
  2428. service.CreateHisPsn(psn)
  2429. c.ServeSuccessJSON(map[string]interface{}{
  2430. "patient": patient,
  2431. "number": basNumber,
  2432. })
  2433. } else {
  2434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2436. infoStr := string(Iinfos)
  2437. idetinfoStr := string(Idetinfos)
  2438. psn := &models.HisPsn{
  2439. PsnNo: res.Output.Baseinfo.PsnNo,
  2440. Age: res.Output.Baseinfo.Age,
  2441. PatientId: patient.ID,
  2442. Certno: res.Output.Baseinfo.Certno,
  2443. Brdy: res.Output.Baseinfo.Brdy,
  2444. Gend: res.Output.Baseinfo.Gend,
  2445. Naty: res.Output.Baseinfo.Naty,
  2446. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2447. PsnName: res.Output.Baseinfo.PsnName,
  2448. Idetinfo: idetinfoStr,
  2449. Insuinfo: infoStr,
  2450. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2451. CardInfo: card_info,
  2452. VerifyNumber: token,
  2453. }
  2454. service.CreateHisPsn(psn)
  2455. var rf []*ResultFive
  2456. json.Unmarshal([]byte(infoStr), &rf)
  2457. var insutypes []*ResultFive
  2458. var insutype string
  2459. var is390 int = 0
  2460. var is310 int = 0
  2461. for _, item := range rf {
  2462. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2463. insutypes = append(insutypes, item)
  2464. }
  2465. }
  2466. if len(insutypes) == 1 {
  2467. insutype = insutypes[0].Insutype
  2468. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2469. } else {
  2470. for _, i := range insutypes {
  2471. if i.Insutype == "390" {
  2472. is390 = 1
  2473. }
  2474. if i.Insutype == "310" {
  2475. is310 = 1
  2476. }
  2477. }
  2478. }
  2479. if is390 == 1 {
  2480. insutype = "390"
  2481. }
  2482. if is310 == 1 {
  2483. insutype = "310"
  2484. }
  2485. if len(insutypes) == 0 {
  2486. insutype = "310"
  2487. }
  2488. c.ServeSuccessJSON(map[string]interface{}{
  2489. "patient": patient,
  2490. "number": token,
  2491. "insutype": insutype,
  2492. })
  2493. }
  2494. }
  2495. } else {
  2496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2497. return
  2498. }
  2499. } else { //读卡失败
  2500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2501. return
  2502. }
  2503. }
  2504. break
  2505. case 4:
  2506. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2507. var api string
  2508. if miConfig.MdtrtareaAdmvs == "320921" {
  2509. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2510. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2511. fmt.Println(api)
  2512. } else {
  2513. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2514. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2515. }
  2516. resp, requestErr := http.Get(api)
  2517. if requestErr != nil {
  2518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2519. return
  2520. }
  2521. body, ioErr := ioutil.ReadAll(resp.Body)
  2522. if ioErr != nil {
  2523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. return
  2526. }
  2527. var respJSON map[string]interface{}
  2528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2531. return
  2532. }
  2533. var status string
  2534. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2535. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2536. var token string
  2537. var res ResultTwo //1101结果
  2538. var res10265 ResultTwo10265 //1101结果
  2539. if status == "0" { //读卡成功
  2540. var card_info string //卡信息
  2541. var busi_card_info string
  2542. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2543. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2544. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2545. fmt.Println(card_info)
  2546. fmt.Println(busi_card_info)
  2547. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2548. result, _ := json.Marshal(respJSON)
  2549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2550. utils.ErrorLog("解析失败:%v", err)
  2551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2552. return
  2553. }
  2554. res.ErrMsg = res10265.ErrMsg
  2555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2556. res.Infcode = infocode
  2557. res.Output = res10265.Output
  2558. res.InfRefmsgid = res10265.InfRefmsgid
  2559. if res.Infcode == 0 {
  2560. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2561. if err == gorm.ErrRecordNotFound {
  2562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2563. return
  2564. } else if err != nil {
  2565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2566. return
  2567. } else {
  2568. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2569. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2570. infoStr := string(Iinfos)
  2571. idetinfoStr := string(Idetinfos)
  2572. psn := &models.HisPsn{
  2573. PsnNo: res.Output.Baseinfo.PsnNo,
  2574. Age: res.Output.Baseinfo.Age,
  2575. PatientId: patient.ID,
  2576. Certno: res.Output.Baseinfo.Certno,
  2577. Brdy: res.Output.Baseinfo.Brdy,
  2578. Gend: res.Output.Baseinfo.Gend,
  2579. Naty: res.Output.Baseinfo.Naty,
  2580. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2581. PsnName: res.Output.Baseinfo.PsnName,
  2582. Idetinfo: idetinfoStr,
  2583. Insuinfo: infoStr,
  2584. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2585. CardInfo: card_info,
  2586. VerifyNumber: token,
  2587. }
  2588. var rf []*ResultFive
  2589. json.Unmarshal([]byte(infoStr), &rf)
  2590. var insutypes []*ResultFive
  2591. var insutype string
  2592. var is390 int = 0
  2593. var is310 int = 0
  2594. for _, item := range rf {
  2595. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2596. insutypes = append(insutypes, item)
  2597. }
  2598. }
  2599. if len(insutypes) == 1 {
  2600. insutype = insutypes[0].Insutype
  2601. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2602. } else {
  2603. for _, i := range insutypes {
  2604. if i.Insutype == "390" {
  2605. is390 = 1
  2606. }
  2607. if i.Insutype == "310" {
  2608. is310 = 1
  2609. }
  2610. }
  2611. }
  2612. if is390 == 1 {
  2613. insutype = "390"
  2614. }
  2615. if is310 == 1 {
  2616. insutype = "310"
  2617. }
  2618. if len(insutypes) == 0 {
  2619. insutype = "310"
  2620. }
  2621. service.CreateHisPsn(psn)
  2622. c.ServeSuccessJSON(map[string]interface{}{
  2623. "patient": patient,
  2624. "number": token,
  2625. "insutype": insutype,
  2626. })
  2627. }
  2628. } else {
  2629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2630. return
  2631. }
  2632. } else { //读卡失败
  2633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2634. return
  2635. }
  2636. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2637. if initFlag == 0 {
  2638. c.TestGetBasBaseInit()
  2639. }
  2640. token := c.GetEleBaseInfo()
  2641. token = Remove0000(token)
  2642. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2643. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2644. //
  2645. var res ResultTwo
  2646. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. if res.Infcode == 0 {
  2652. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2653. if err == gorm.ErrRecordNotFound {
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2655. return
  2656. } else if err != nil {
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2658. return
  2659. } else {
  2660. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2661. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2662. infoStr := string(Iinfos)
  2663. idetinfoStr := string(Idetinfos)
  2664. psn := &models.HisPsn{
  2665. PsnNo: res.Output.Baseinfo.PsnNo,
  2666. Age: res.Output.Baseinfo.Age,
  2667. PatientId: patient.ID,
  2668. Certno: res.Output.Baseinfo.Certno,
  2669. Brdy: res.Output.Baseinfo.Brdy,
  2670. Gend: res.Output.Baseinfo.Gend,
  2671. Naty: res.Output.Baseinfo.Naty,
  2672. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2673. PsnName: res.Output.Baseinfo.PsnName,
  2674. Idetinfo: idetinfoStr,
  2675. Insuinfo: infoStr,
  2676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2677. CardInfo: "",
  2678. VerifyNumber: token,
  2679. }
  2680. service.CreateHisPsn(psn)
  2681. c.ServeSuccessJSON(map[string]interface{}{
  2682. "patient": patient,
  2683. "number": token,
  2684. })
  2685. }
  2686. } else {
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2688. return
  2689. }
  2690. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2691. //if initFlag == 0 {
  2692. c.TestGetJiangXiBasBaseInit()
  2693. //}
  2694. //if initEleFlag == 0 {
  2695. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2696. //}
  2697. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2698. type ELeData struct {
  2699. Data struct {
  2700. IdNo string `json:"idNo"`
  2701. IdType string `json:"idType"`
  2702. UserName string `json:"userName"`
  2703. EcToken string `json:"ecToken"`
  2704. InsuOrg string `json:"insuOrg"`
  2705. Gender string `json:"gender"`
  2706. Birthday string `json:"birthday"`
  2707. Nationality string `json:"nationality"`
  2708. Email string `json:"email"`
  2709. Extra string `json:"extra"`
  2710. } `json:"data"`
  2711. Code int `json:"code"`
  2712. Message string `json:"message"`
  2713. }
  2714. var ele ELeData
  2715. err := json.Unmarshal([]byte(json_result), &ele)
  2716. if err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. }
  2719. token := ele.Data.EcToken
  2720. token = Remove0000(token)
  2721. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  2722. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2723. var res ResultTwo
  2724. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2725. utils.ErrorLog("解析失败:%v", err)
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2727. return
  2728. }
  2729. if res.Infcode == 0 {
  2730. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2731. if err == gorm.ErrRecordNotFound {
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2733. return
  2734. } else if err != nil {
  2735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2736. return
  2737. } else {
  2738. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2739. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2740. infoStr := string(Iinfos)
  2741. idetinfoStr := string(Idetinfos)
  2742. psn := &models.HisPsn{
  2743. PsnNo: res.Output.Baseinfo.PsnNo,
  2744. Age: res.Output.Baseinfo.Age,
  2745. PatientId: patient.ID,
  2746. Certno: res.Output.Baseinfo.Certno,
  2747. Brdy: res.Output.Baseinfo.Brdy,
  2748. Gend: res.Output.Baseinfo.Gend,
  2749. Naty: res.Output.Baseinfo.Naty,
  2750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2751. PsnName: res.Output.Baseinfo.PsnName,
  2752. Idetinfo: idetinfoStr,
  2753. Insuinfo: infoStr,
  2754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2755. CardInfo: "",
  2756. VerifyNumber: token,
  2757. }
  2758. service.CreateHisPsn(psn)
  2759. var rf []*ResultFive
  2760. json.Unmarshal([]byte(infoStr), &rf)
  2761. var insutypes []*ResultFive
  2762. var insutype string
  2763. var is390 int = 0
  2764. var is310 int = 0
  2765. for _, item := range rf {
  2766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2767. insutypes = append(insutypes, item)
  2768. }
  2769. }
  2770. if len(insutypes) == 1 {
  2771. insutype = insutypes[0].Insutype
  2772. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2773. } else {
  2774. for _, i := range insutypes {
  2775. if i.Insutype == "390" {
  2776. is390 = 1
  2777. }
  2778. if i.Insutype == "310" {
  2779. is310 = 1
  2780. }
  2781. }
  2782. }
  2783. if is390 == 1 {
  2784. insutype = "390"
  2785. }
  2786. if is310 == 1 {
  2787. insutype = "310"
  2788. }
  2789. if len(insutypes) == 0 {
  2790. insutype = "310"
  2791. }
  2792. c.ServeSuccessJSON(map[string]interface{}{
  2793. "patient": patient,
  2794. "number": token,
  2795. "insutype": insutype,
  2796. })
  2797. }
  2798. } else {
  2799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2800. return
  2801. }
  2802. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2803. //if initFlag == 0 {
  2804. c.TestGetJiangXiBasBaseInit()
  2805. //}
  2806. //if initEleFlag == 0 {
  2807. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2808. //}
  2809. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2810. type ELeData struct {
  2811. Data struct {
  2812. IdNo string `json:"idNo"`
  2813. IdType string `json:"idType"`
  2814. UserName string `json:"userName"`
  2815. EcToken string `json:"ecToken"`
  2816. InsuOrg string `json:"insuOrg"`
  2817. Gender string `json:"gender"`
  2818. Birthday string `json:"birthday"`
  2819. Nationality string `json:"nationality"`
  2820. Email string `json:"email"`
  2821. Extra string `json:"extra"`
  2822. } `json:"data"`
  2823. Code int `json:"code"`
  2824. Message string `json:"message"`
  2825. }
  2826. var ele ELeData
  2827. err := json.Unmarshal([]byte(json_result), &ele)
  2828. if err != nil {
  2829. utils.ErrorLog("解析失败:%v", err)
  2830. }
  2831. token := ele.Data.EcToken
  2832. token = Remove0000(token)
  2833. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  2834. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2835. var res ResultTwo
  2836. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2837. utils.ErrorLog("解析失败:%v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. return
  2840. }
  2841. if res.Infcode == 0 {
  2842. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2843. if err == gorm.ErrRecordNotFound {
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2845. return
  2846. } else if err != nil {
  2847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2848. return
  2849. } else {
  2850. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2851. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2852. infoStr := string(Iinfos)
  2853. idetinfoStr := string(Idetinfos)
  2854. psn := &models.HisPsn{
  2855. PsnNo: res.Output.Baseinfo.PsnNo,
  2856. Age: res.Output.Baseinfo.Age,
  2857. PatientId: patient.ID,
  2858. Certno: res.Output.Baseinfo.Certno,
  2859. Brdy: res.Output.Baseinfo.Brdy,
  2860. Gend: res.Output.Baseinfo.Gend,
  2861. Naty: res.Output.Baseinfo.Naty,
  2862. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2863. PsnName: res.Output.Baseinfo.PsnName,
  2864. Idetinfo: idetinfoStr,
  2865. Insuinfo: infoStr,
  2866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2867. CardInfo: "",
  2868. VerifyNumber: token,
  2869. }
  2870. service.CreateHisPsn(psn)
  2871. var rf []*ResultFive
  2872. json.Unmarshal([]byte(infoStr), &rf)
  2873. var insutypes []*ResultFive
  2874. var insutype string
  2875. var is390 int = 0
  2876. var is310 int = 0
  2877. for _, item := range rf {
  2878. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2879. insutypes = append(insutypes, item)
  2880. }
  2881. }
  2882. if len(insutypes) == 1 {
  2883. insutype = insutypes[0].Insutype
  2884. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2885. } else {
  2886. for _, i := range insutypes {
  2887. if i.Insutype == "390" {
  2888. is390 = 1
  2889. }
  2890. if i.Insutype == "310" {
  2891. is310 = 1
  2892. }
  2893. }
  2894. }
  2895. if is390 == 1 {
  2896. insutype = "390"
  2897. }
  2898. if is310 == 1 {
  2899. insutype = "310"
  2900. }
  2901. if len(insutypes) == 0 {
  2902. insutype = "310"
  2903. }
  2904. c.ServeSuccessJSON(map[string]interface{}{
  2905. "patient": patient,
  2906. "number": token,
  2907. "insutype": insutype,
  2908. })
  2909. }
  2910. } else {
  2911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2912. return
  2913. }
  2914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2915. type ELeData struct {
  2916. Code string `json:"code"`
  2917. Data struct {
  2918. Aac002 string `json:"aac002"`
  2919. Aaz500 string `json:"aaz500"`
  2920. ActCardNo string `json:"actCardNo"`
  2921. Bab520 string `json:"bab520"`
  2922. Bkz543 string `json:"bkz543"`
  2923. BusinessType string `json:"businessType"`
  2924. CertfCodg string `json:"certfCodg"`
  2925. EcIndexNo string `json:"ecIndexNo"`
  2926. EcToken string `json:"ecToken"`
  2927. ID0000 string `json:"id0000"`
  2928. IDNo string `json:"idNo"`
  2929. IDType string `json:"idType"`
  2930. Idcode string `json:"idcode"`
  2931. IdentityToken string `json:"identity_token"`
  2932. InsuOrg string `json:"insuOrg"`
  2933. OfficeID string `json:"officeId"`
  2934. OfficeName string `json:"officeName"`
  2935. OperatorID string `json:"operatorId"`
  2936. OperatorName string `json:"operatorName"`
  2937. OrgID string `json:"orgId"`
  2938. UserName string `json:"userName"`
  2939. } `json:"data"`
  2940. Infno interface{} `json:"infno"`
  2941. Message string `json:"message"`
  2942. OrgID string `json:"orgId"`
  2943. TransType string `json:"transType"`
  2944. }
  2945. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  2946. outPutInfo = Remove0000(outPutInfo)
  2947. if len(outPutInfo) > 0 {
  2948. var ele ELeData
  2949. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2950. if err != nil {
  2951. utils.ErrorLog("解析失败:%v", err)
  2952. }
  2953. token := ele.Data.EcToken
  2954. fmt.Println(inputInfo)
  2955. fmt.Println(outPutInfo)
  2956. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  2957. saveLog(result, requestLog, "1101", "获取人员信息")
  2958. var dat map[string]interface{}
  2959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2960. fmt.Println(dat)
  2961. } else {
  2962. fmt.Println(err)
  2963. }
  2964. userJSONBytes, _ := json.Marshal(dat)
  2965. var res ResultTwo
  2966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2967. utils.ErrorLog("解析失败:%v", err)
  2968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2969. return
  2970. }
  2971. res.ErrMsg = errMsgLog
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. fmt.Println(res)
  2982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2984. infoStr := string(Iinfos)
  2985. idetinfoStr := string(Idetinfos)
  2986. psn := &models.HisPsn{
  2987. PsnNo: res.Output.Baseinfo.PsnNo,
  2988. Age: res.Output.Baseinfo.Age,
  2989. PatientId: patient.ID,
  2990. Certno: res.Output.Baseinfo.Certno,
  2991. Brdy: res.Output.Baseinfo.Brdy,
  2992. Gend: res.Output.Baseinfo.Gend,
  2993. Naty: res.Output.Baseinfo.Naty,
  2994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2995. PsnName: res.Output.Baseinfo.PsnName,
  2996. Idetinfo: idetinfoStr,
  2997. Insuinfo: infoStr,
  2998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2999. CardInfo: outPutInfo,
  3000. VerifyNumber: token,
  3001. }
  3002. service.CreateHisPsn(psn)
  3003. var rf []*ResultFive
  3004. json.Unmarshal([]byte(infoStr), &rf)
  3005. var insutypes []*ResultFive
  3006. var insutype string
  3007. var is390 int = 0
  3008. var is310 int = 0
  3009. for _, item := range rf {
  3010. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3011. insutypes = append(insutypes, item)
  3012. }
  3013. }
  3014. if len(insutypes) == 1 {
  3015. insutype = insutypes[0].Insutype
  3016. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3017. } else {
  3018. for _, i := range insutypes {
  3019. if i.Insutype == "390" {
  3020. is390 = 1
  3021. }
  3022. if i.Insutype == "310" {
  3023. is310 = 1
  3024. }
  3025. }
  3026. }
  3027. if is390 == 1 {
  3028. insutype = "390"
  3029. }
  3030. if is310 == 1 {
  3031. insutype = "310"
  3032. }
  3033. if len(insutypes) == 0 {
  3034. insutype = "310"
  3035. }
  3036. c.ServeSuccessJSON(map[string]interface{}{
  3037. "patient": patient,
  3038. "number": token,
  3039. "insutype": insutype,
  3040. })
  3041. }
  3042. } else {
  3043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3044. return
  3045. }
  3046. }
  3047. }
  3048. break
  3049. }
  3050. }
  3051. var initFlag int64 = 0
  3052. var initEleFlag int64 = 0
  3053. func (c *HisApiController) TestGetBasBaseInit() {
  3054. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3055. Iinit := DllDef.MustFindProc("Init")
  3056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3057. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3058. if ret != 0 {
  3059. fmt.Println("SSCard的报错原因:", err)
  3060. fmt.Println("SSCard的运算结果为:", ret)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3062. return
  3063. }
  3064. result := int(ret)
  3065. fmt.Println("SSCard的运算结果为1:", result)
  3066. initFlag = 1
  3067. return
  3068. }
  3069. func (c *HisApiController) HandleJiangXiReadCard() {
  3070. fmt.Println("~~~~~~")
  3071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3072. admin_user_id, _ := c.GetInt64("admin_user_id")
  3073. id_card_type, _ := c.GetInt64("id_card_type")
  3074. //certificates, _ := c.GetInt64("certificates")
  3075. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3076. if initFlag == 0 {
  3077. c.TestGetJiangXiBasBaseInit()
  3078. }
  3079. basStr := c.GetBasBaseInfo()
  3080. if len(basStr) == 0 {
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3082. return
  3083. }
  3084. fmt.Println(basStr)
  3085. bas := strings.Split(basStr, "|")
  3086. basNumber := bas[1]
  3087. fmt.Println(basNumber)
  3088. card_sn := bas[3]
  3089. fmt.Println(card_sn)
  3090. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  3091. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3092. var dat map[string]interface{}
  3093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3094. fmt.Println(dat)
  3095. } else {
  3096. fmt.Println(err)
  3097. }
  3098. userJSONBytes, _ := json.Marshal(dat)
  3099. var res ResultTwo
  3100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3101. utils.ErrorLog("解析失败:%v", err)
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3103. return
  3104. }
  3105. if res.Infcode == 0 {
  3106. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3107. if err == gorm.ErrRecordNotFound {
  3108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3109. return
  3110. } else if err != nil {
  3111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3112. return
  3113. } else {
  3114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3116. infoStr := string(Iinfos)
  3117. idetinfoStr := string(Idetinfos)
  3118. psn := &models.HisPsn{
  3119. PsnNo: res.Output.Baseinfo.PsnNo,
  3120. Age: res.Output.Baseinfo.Age,
  3121. PatientId: patient.ID,
  3122. Certno: res.Output.Baseinfo.Certno,
  3123. Brdy: res.Output.Baseinfo.Brdy,
  3124. Gend: res.Output.Baseinfo.Gend,
  3125. Naty: res.Output.Baseinfo.Naty,
  3126. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3127. PsnName: res.Output.Baseinfo.PsnName,
  3128. Idetinfo: idetinfoStr,
  3129. Insuinfo: infoStr,
  3130. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3131. CardInfo: basStr,
  3132. VerifyNumber: "",
  3133. }
  3134. service.CreateHisPsn(psn)
  3135. c.ServeSuccessJSON(map[string]interface{}{
  3136. "patient": patient,
  3137. "number": basNumber,
  3138. })
  3139. }
  3140. } else {
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3142. return
  3143. }
  3144. }
  3145. func (c *HisApiController) TestGetHnBasBaseInit() {
  3146. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3147. Iinit := DllDef.MustFindProc("Init")
  3148. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3149. //http://10.77.211.236/CSB/hsa-fsi-1303
  3150. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430802"))
  3151. if ret != 0 {
  3152. fmt.Println("SSCard的报错原因:", err)
  3153. fmt.Println("SSCard的运算结果为:", ret)
  3154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3155. return
  3156. }
  3157. result := int(ret)
  3158. fmt.Println("SSCard的运算结果为1:", result)
  3159. initFlag = 1
  3160. return
  3161. }
  3162. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3163. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3164. Iinit := DllDef.MustFindProc("Init")
  3165. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3166. //http://10.77.211.236/CSB/hsa-fsi-1303
  3167. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3168. if ret != 0 {
  3169. fmt.Println("SSCard的报错原因:", err)
  3170. fmt.Println("SSCard的运算结果为:", ret)
  3171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3172. return
  3173. }
  3174. result := int(ret)
  3175. fmt.Println("SSCard的运算结果为1:", result)
  3176. initFlag = 1
  3177. return
  3178. }
  3179. func (c *HisApiController) GetSFZBaseInfo() string {
  3180. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3181. readCard := DllDef.MustFindProc("ReadSFZ")
  3182. if readCard == nil {
  3183. fmt.Println("readcard is nil")
  3184. readCard = DllDef.MustFindProc("ReadSFZ")
  3185. }
  3186. str := make([]byte, 256)
  3187. str1 := make([]byte, 256)
  3188. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3189. fmt.Println(r)
  3190. return string(str)
  3191. }
  3192. func (c *HisApiController) GetEleBaseInfo() string {
  3193. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3194. readCard := DllDef.MustFindProc("GetQRBase")
  3195. fmt.Println(readCard)
  3196. if readCard == nil {
  3197. fmt.Println("readcard is nil")
  3198. readCard = DllDef.MustFindProc("GetQRBase")
  3199. }
  3200. str := make([]byte, 1024)
  3201. str1 := make([]byte, 1024)
  3202. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3203. fmt.Println(ret2)
  3204. fmt.Println(string(str1))
  3205. fmt.Println(string(str))
  3206. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3207. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3208. if ret2 != 0 {
  3209. return ""
  3210. }
  3211. return string(str)
  3212. }
  3213. func GetJxEleBaseInfo(org_id int64) string {
  3214. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3215. readCard := DllDef.MustFindProc("NationEcTrans")
  3216. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3217. if readCard == nil {
  3218. fmt.Println("readcard is nil")
  3219. readCard = DllDef.MustFindProc("NationEcTrans")
  3220. }
  3221. str1 := make([]byte, 1024)
  3222. data := make(map[string]interface{})
  3223. inputData := make(map[string]interface{})
  3224. inputData["orgId"] = miConfig.Code
  3225. inputData["businessType"] = "01101"
  3226. inputData["operatorId"] = "test001"
  3227. inputData["operatorName"] = "cn"
  3228. inputData["officeId"] = "32760"
  3229. inputData["officeName"] = "waike"
  3230. inputData["deviceType"] = ""
  3231. data["data"] = inputData
  3232. data["transType"] = "ec.query"
  3233. data["extra "] = ""
  3234. data["orgId"] = miConfig.Code
  3235. bytesData, _ := json.Marshal(data)
  3236. //bytesData, _ := json.Marshal(data)
  3237. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3238. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3239. fmt.Println(ret2)
  3240. fmt.Println(string(str1))
  3241. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3242. if ret2 != 0 {
  3243. return ""
  3244. }
  3245. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3246. }
  3247. func GetJxEleBaseInitInfo(org_id int64) string {
  3248. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3249. readCard := DllDef.MustFindProc("NationEcTrans")
  3250. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3251. if readCard == nil {
  3252. fmt.Println("readcard is nil")
  3253. readCard = DllDef.MustFindProc("NationEcTrans")
  3254. }
  3255. str1 := make([]byte, 2048)
  3256. data := make(map[string]interface{})
  3257. inputData := make(map[string]interface{})
  3258. inputData["orgId"] = miConfig.Code
  3259. inputData["businessType"] = "01101"
  3260. inputData["operatorId"] = "1"
  3261. inputData["operatorName"] = "huangchuang"
  3262. inputData["officeId"] = "101"
  3263. inputData["officeName"] = "xuetou"
  3264. inputData["deviceType"] = ""
  3265. data["data"] = inputData
  3266. data["transType"] = "ec.query"
  3267. data["orgId"] = miConfig.Code
  3268. bytesData, _ := json.Marshal(data)
  3269. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3270. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3271. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3272. fmt.Println(ret2)
  3273. fmt.Println(string(str1))
  3274. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3275. if ret2 != 0 {
  3276. return ""
  3277. }
  3278. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3279. initEleFlag = 1
  3280. }
  3281. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3282. }
  3283. func (c *HisApiController) GetBasBaseInfo() string {
  3284. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3285. readCard := DllDef.MustFindProc("ReadCardBas")
  3286. if readCard == nil {
  3287. fmt.Println("readcard is nil")
  3288. readCard = DllDef.MustFindProc("ReadCardBas")
  3289. }
  3290. str := make([]byte, 1024)
  3291. str1 := make([]byte, 1024)
  3292. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3293. fmt.Println(string(str1))
  3294. fmt.Println(string(str))
  3295. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3296. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3297. if ret2 != 0 {
  3298. return ""
  3299. }
  3300. return string(str)
  3301. }
  3302. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3303. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3304. readCard := DllDef.MustFindProc("read_cardinfo")
  3305. if readCard == nil {
  3306. fmt.Println("readcard is nil")
  3307. readCard = DllDef.MustFindProc("read_cardinfo")
  3308. }
  3309. str := make([]byte, 1024) //卡号
  3310. str1 := make([]byte, 1024) //卡识别码
  3311. str2 := make([]byte, 1024) //身份证号
  3312. str3 := make([]byte, 1024) //姓名
  3313. str4 := make([]byte, 1024) //错误信息
  3314. 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])))
  3315. fmt.Println(string(str1))
  3316. fmt.Println(string(str))
  3317. fmt.Println(string(str2))
  3318. fmt.Println(string(str3))
  3319. fmt.Println(string(str4))
  3320. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3321. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3322. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3323. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3324. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3325. if ret2 != 0 {
  3326. return "", "", "", "", ""
  3327. }
  3328. return string(str), string(str1), string(str2), string(str3), string(str4)
  3329. }
  3330. type CustomFundPay struct {
  3331. FundPayType string `json:"fund_pay_type"`
  3332. FundPayamt float64 `json:"fund_payamt"`
  3333. }
  3334. func (c *HisApiController) GetSettleList() {
  3335. order_id, _ := c.GetInt64("order_id")
  3336. admin_user_id, _ := c.GetInt64("admin_user_id")
  3337. order, _ := service.GetHisOrderByIDTwo(order_id)
  3338. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3339. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3340. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3341. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3342. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3343. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3344. if order.ID == 0 {
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3346. return
  3347. }
  3348. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3349. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3350. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3351. fmt.Println(count)
  3352. var zero string
  3353. number := count + 1
  3354. if number >= 1000 {
  3355. zero = "0000" + strconv.FormatInt(number, 10)
  3356. } else if number >= 10000 {
  3357. zero = "000" + strconv.FormatInt(number, 10)
  3358. } else if number >= 100000 {
  3359. zero = "00" + strconv.FormatInt(number, 10)
  3360. } else if number >= 1000000 {
  3361. zero = "0" + strconv.FormatInt(number, 10)
  3362. } else {
  3363. zero = strconv.FormatInt(number, 10)
  3364. }
  3365. fmt.Println(zero)
  3366. struct4101 := service.Struct4101{
  3367. PsnNo: order.PsnNo,
  3368. MdtrtId: order.MdtrtId,
  3369. SetlId: order.SetlId,
  3370. PsnName: order.PsnName,
  3371. Gend: order.Gend,
  3372. Brdy: his.Brdy,
  3373. Age: his.Age,
  3374. Naty: order.Naty,
  3375. PatnCertType: "01",
  3376. Certno: order.Certno,
  3377. Prfs: "90",
  3378. ConerName: roles[0].UserName,
  3379. PatnRlts: "99",
  3380. ConerAddr: miConfig.OrgName,
  3381. ConerTel: admin.Mobile,
  3382. HiType: order.Insutype,
  3383. Insuplc: miConfig.InsuplcAdmdvs,
  3384. MaindiagFlag: "1",
  3385. BillCode: order.SetlId,
  3386. BillNo: order.SetlId,
  3387. BizSn: order.Number,
  3388. PsnSelfPay: order.PsnPartAmt,
  3389. PsnOwnPay: order.PsnPartAmt,
  3390. AcctPay: order.AcctPay,
  3391. PsnCashpay: order.PsnCashPay,
  3392. HiPaymtd: "1",
  3393. Hsorg: miConfig.InsuplcAdmdvs,
  3394. HsorgOpter: miConfig.InsuplcAdmdvs,
  3395. MedinsFillPsn: curRoles.UserName,
  3396. MedinsFillDept: depart.Name,
  3397. IptMedType: "2",
  3398. }
  3399. struct4101.SetlBegnDate = order.SetlTime
  3400. struct4101.SetlEndDate = order.SetlTime
  3401. time_arr := strings.Split(order.SetlTime, " ")
  3402. struct4101.AdmTime = time_arr[0]
  3403. struct4101.AdmEndTime = time_arr[0]
  3404. var rf []CustomFundPay
  3405. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3406. var tempFunPays []service.CustomStruct
  3407. for _, item := range rf {
  3408. var tempFunPay service.CustomStruct
  3409. tempFunPay.FundPayamt = item.FundPayamt
  3410. tempFunPay.FundPayType = item.FundPayType
  3411. tempFunPays = append(tempFunPays, tempFunPay)
  3412. }
  3413. struct4101.CustomStruct = tempFunPays
  3414. var tempDiaginfos []service.DiaginfoStructTwo
  3415. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3416. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3417. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3418. var config []*models.HisXtDiagnoseConfig
  3419. for _, item := range diagnosis_ids {
  3420. id, _ := strconv.ParseInt(item, 10, 64)
  3421. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3422. config = append(config, &diagnosisConfig)
  3423. }
  3424. for index, item := range config {
  3425. if index == 0 {
  3426. var tempDiaginfo service.DiaginfoStructTwo
  3427. tempDiaginfo.DiagCode = item.CountryCode
  3428. tempDiaginfo.DiagName = item.CountryContentName
  3429. tempDiaginfo.DiagType = "1"
  3430. tempDiaginfo.MaindiagFlag = "1"
  3431. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3432. } else {
  3433. var tempDiaginfo service.DiaginfoStructTwo
  3434. tempDiaginfo.DiagCode = item.CountryCode
  3435. tempDiaginfo.DiagName = item.CountryContentName
  3436. tempDiaginfo.DiagType = "2"
  3437. tempDiaginfo.MaindiagFlag = "0"
  3438. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3439. }
  3440. }
  3441. struct4101.Diseinfo = tempDiaginfos
  3442. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3443. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3444. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3445. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3446. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3447. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3448. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3449. var iteminfo service.IteminfoStruct
  3450. var bedCostTotal float64 = 0 //床位总费
  3451. var bedCostSelfTotal float64 = 0 //床位自费
  3452. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3453. var operationCostTotal float64 = 0 //手术费
  3454. var operationCostSelfTotal float64 = 0 //手术费
  3455. var operationCostPartSelfTotal float64 = 0 //手术费
  3456. var otherCostTotal float64 = 0 //其他费用
  3457. var otherCostSelfTotal float64 = 0 //其他费用
  3458. var otherCostPartSelfTotal float64 = 0 //其他费用
  3459. var materialCostTotal float64 = 0 //材料费
  3460. var materialCostSelfTotal float64 = 0 //材料费
  3461. var materialCostPartSelfTotal float64 = 0 //材料费
  3462. var westernMedicineCostTotal float64 = 0 //西药费
  3463. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3464. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3465. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3466. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3467. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3468. var checkCostTotal float64 = 0 //检查费
  3469. var checkCostSelfTotal float64 = 0 //检查费
  3470. var checkCostPartSelfTotal float64 = 0 //检查费
  3471. var laboratoryCostTotal float64 = 0 //化验费
  3472. var laboratoryCostSelfTotal float64 = 0 //化验费
  3473. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3474. var treatCostTotal float64 = 0 //治疗费用
  3475. var treatCostSelfTotal float64 = 0 //治疗费用
  3476. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3477. decimal.DivisionPrecision = 2
  3478. var bed_fulamt_ownpay_amt float64 = 0
  3479. var operation_fulamt_ownpay_amt float64 = 0
  3480. var other_fulamt_ownpay_amt float64 = 0
  3481. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3482. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3483. var check_fulamt_ownpay_amt float64 = 0
  3484. var material_fulamt_ownpay_amt float64 = 0
  3485. var laboratory_fulamt_ownpay_amt float64 = 0
  3486. var treat_fulamt_ownpay_amt float64 = 0
  3487. var bed_claa_sunmfee float64 = 0
  3488. var bed_clab_amt float64 = 0
  3489. var bed_other_amt float64 = 0
  3490. var operation_claa_sunmfee float64 = 0
  3491. var operation_clab_amt float64 = 0
  3492. var operation_other_amt float64 = 0
  3493. var other_claa_sunmfee float64 = 0
  3494. var other_clab_amt float64 = 0
  3495. var other_other_amt float64 = 0
  3496. var westernMedicine_claa_sunmfee float64 = 0
  3497. var westernMedicine_clab_amt float64 = 0
  3498. var westernMedicine_other_amt float64 = 0
  3499. var chineseTraditional_claa_sunmfee float64 = 0
  3500. var chineseTraditional_clab_amt float64 = 0
  3501. var chineseTraditional_other_amt float64 = 0
  3502. var check_claa_sunmfee float64 = 0
  3503. var check_clab_amt float64 = 0
  3504. var check_other_amt float64 = 0
  3505. var material_claa_sunmfee float64 = 0
  3506. var material_clab_amt float64 = 0
  3507. var material_other_amt float64 = 0
  3508. var laboratory_claa_sunmfee float64 = 0
  3509. var laboratory_clab_amt float64 = 0
  3510. var laboratory_other_amt float64 = 0
  3511. var treat_claa_sunmfee float64 = 0
  3512. var treat_clab_amt float64 = 0
  3513. var treat_other_amt float64 = 0
  3514. for _, item := range order.HisOrderInfo {
  3515. if item.MedChrgitmType == "01" { //床位费
  3516. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3517. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3518. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3519. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3520. if item.ChrgitmLv == "1" {
  3521. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3522. }
  3523. if item.ChrgitmLv == "2" {
  3524. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3525. }
  3526. if item.ChrgitmLv == "3" {
  3527. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3528. }
  3529. }
  3530. if item.MedChrgitmType == "03" { //检查费
  3531. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3532. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3533. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3534. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3535. if item.ChrgitmLv == "1" {
  3536. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3537. }
  3538. if item.ChrgitmLv == "2" {
  3539. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3540. }
  3541. if item.ChrgitmLv == "3" {
  3542. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3543. }
  3544. }
  3545. if item.MedChrgitmType == "04" { //化验费
  3546. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3547. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3548. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3549. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3550. if item.ChrgitmLv == "1" {
  3551. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3552. }
  3553. if item.ChrgitmLv == "2" {
  3554. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3555. }
  3556. if item.ChrgitmLv == "3" {
  3557. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3558. }
  3559. }
  3560. if item.MedChrgitmType == "05" { //治疗费
  3561. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3562. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3563. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3564. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3565. if item.ChrgitmLv == "1" {
  3566. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3567. }
  3568. if item.ChrgitmLv == "2" {
  3569. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3570. }
  3571. if item.ChrgitmLv == "3" {
  3572. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3573. }
  3574. }
  3575. if item.MedChrgitmType == "06" { //手术费
  3576. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3577. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3578. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3579. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3580. if item.ChrgitmLv == "1" {
  3581. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3582. }
  3583. if item.ChrgitmLv == "2" {
  3584. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3585. }
  3586. if item.ChrgitmLv == "3" {
  3587. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3588. }
  3589. }
  3590. if item.MedChrgitmType == "08" { //材料费
  3591. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3592. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3593. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3594. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3595. if item.ChrgitmLv == "1" {
  3596. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3597. }
  3598. if item.ChrgitmLv == "2" {
  3599. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3600. }
  3601. if item.ChrgitmLv == "3" {
  3602. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3603. }
  3604. }
  3605. if item.MedChrgitmType == "09" { //西药费
  3606. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3607. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3608. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3609. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3610. if item.ChrgitmLv == "1" {
  3611. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3612. }
  3613. if item.ChrgitmLv == "2" {
  3614. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3615. }
  3616. if item.ChrgitmLv == "3" {
  3617. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3618. }
  3619. }
  3620. if item.MedChrgitmType == "11" { //中成费
  3621. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3622. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3623. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3624. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3625. if item.ChrgitmLv == "1" {
  3626. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3627. }
  3628. if item.ChrgitmLv == "2" {
  3629. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3630. }
  3631. if item.ChrgitmLv == "3" {
  3632. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3633. }
  3634. }
  3635. if item.MedChrgitmType == "14" { //其他费
  3636. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3637. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3638. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3639. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3640. if item.ChrgitmLv == "1" {
  3641. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3642. }
  3643. if item.ChrgitmLv == "2" {
  3644. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3645. }
  3646. if item.ChrgitmLv == "3" {
  3647. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3648. }
  3649. }
  3650. }
  3651. var iteminfoStructs []service.IteminfoStruct
  3652. if bedCostTotal != 0 {
  3653. iteminfo.MedChrgitm = "01"
  3654. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3655. iteminfo.Amt = bedCostTotal
  3656. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3657. iteminfo.ClabAmt = bed_clab_amt
  3658. iteminfo.OthAmt = bed_other_amt
  3659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3660. }
  3661. if checkCostTotal != 0 {
  3662. iteminfo.MedChrgitm = "03"
  3663. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3664. iteminfo.Amt = checkCostTotal
  3665. iteminfo.ClaaSumfee = check_claa_sunmfee
  3666. iteminfo.ClabAmt = check_clab_amt
  3667. iteminfo.OthAmt = check_other_amt
  3668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3669. }
  3670. if laboratoryCostTotal != 0 {
  3671. iteminfo.MedChrgitm = "04"
  3672. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3673. iteminfo.Amt = laboratoryCostTotal
  3674. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3675. iteminfo.ClabAmt = laboratory_clab_amt
  3676. iteminfo.OthAmt = laboratory_other_amt
  3677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3679. }
  3680. if treatCostTotal != 0 {
  3681. iteminfo.MedChrgitm = "05"
  3682. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3683. iteminfo.Amt = treatCostTotal
  3684. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3685. iteminfo.ClabAmt = treat_clab_amt
  3686. iteminfo.OthAmt = treat_other_amt
  3687. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3688. //(struct4101.IteminfoStruct, iteminfo)
  3689. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3690. }
  3691. if operationCostTotal != 0 {
  3692. iteminfo.MedChrgitm = "06"
  3693. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3694. iteminfo.Amt = operationCostTotal
  3695. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3696. iteminfo.ClabAmt = operation_clab_amt
  3697. iteminfo.OthAmt = operation_other_amt
  3698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3700. }
  3701. if materialCostTotal != 0 {
  3702. iteminfo.MedChrgitm = "08"
  3703. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3704. iteminfo.Amt = materialCostTotal
  3705. iteminfo.ClaaSumfee = material_claa_sunmfee
  3706. iteminfo.ClabAmt = material_clab_amt
  3707. iteminfo.OthAmt = material_other_amt
  3708. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3709. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3710. }
  3711. if westernMedicineCostTotal != 0 {
  3712. iteminfo.MedChrgitm = "09"
  3713. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3714. iteminfo.Amt = westernMedicineCostTotal
  3715. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3716. iteminfo.ClabAmt = westernMedicine_clab_amt
  3717. iteminfo.OthAmt = westernMedicine_other_amt
  3718. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3719. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3720. }
  3721. if chineseTraditionalMedicineCostTotal != 0 {
  3722. iteminfo.MedChrgitm = "11"
  3723. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3724. iteminfo.Amt = westernMedicineCostTotal
  3725. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3726. iteminfo.ClabAmt = westernMedicine_clab_amt
  3727. iteminfo.OthAmt = westernMedicine_other_amt
  3728. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3729. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3730. }
  3731. if otherCostTotal != 0 {
  3732. iteminfo.MedChrgitm = "14"
  3733. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3734. iteminfo.Amt = otherCostTotal
  3735. iteminfo.ClaaSumfee = other_claa_sunmfee
  3736. iteminfo.ClabAmt = other_clab_amt
  3737. iteminfo.OthAmt = other_other_amt
  3738. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3739. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3740. }
  3741. struct4101.IteminfoStruct = iteminfoStructs
  3742. struct4101.Ntly = "中国"
  3743. struct4101.AdmCaty = "A03.06"
  3744. var res ResultSeventeen
  3745. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3746. struct4101.BillCode = order.Number
  3747. struct4101.BillNo = order.SetlId
  3748. var resOther ResultSeventeenOther
  3749. var pp models.PublicParams
  3750. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3751. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3752. pp.FixmedinsName = miConfig.OrgName
  3753. pp.FixmedinsCode = miConfig.Code
  3754. pp.RequestUrl = miConfig.Url
  3755. pp.Cainfo = miConfig.Cainfo
  3756. pp.SecretKey = miConfig.SecretKey
  3757. pp.AccessKey = miConfig.AccessKey
  3758. pp.OpterName = curRoles.UserName
  3759. client := &http.Client{}
  3760. var req *http.Request
  3761. data := make(map[string]interface{})
  3762. data["struct4101"] = struct4101
  3763. data["pp"] = pp
  3764. bytesData, _ := json.Marshal(data)
  3765. if miConfig.MdtrtareaAdmvs == "320921" {
  3766. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3767. } else {
  3768. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3769. }
  3770. resp, _ := client.Do(req)
  3771. defer resp.Body.Close()
  3772. body, ioErr := ioutil.ReadAll(resp.Body)
  3773. if ioErr != nil {
  3774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3776. return
  3777. }
  3778. var respJSON map[string]interface{}
  3779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3782. return
  3783. }
  3784. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3785. userJSONBytes, _ := json.Marshal(respJSON)
  3786. fmt.Println("log")
  3787. fmt.Println(string(userJSONBytes))
  3788. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3789. utils.ErrorLog("解析失败:%v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. res.InfRefmsgid = resOther.InfRefmsgid
  3794. res.Output = resOther.Output
  3795. res.ErrMsg = resOther.ErrMsg
  3796. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3797. res.Infcode = infocode
  3798. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3799. var pp models.PublicParams
  3800. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3801. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3802. pp.FixmedinsName = miConfig.OrgName
  3803. pp.FixmedinsCode = miConfig.Code
  3804. pp.RequestUrl = miConfig.Url
  3805. pp.Cainfo = miConfig.Cainfo
  3806. pp.SecretKey = miConfig.SecretKey
  3807. pp.AccessKey = miConfig.AccessKey
  3808. pp.OpterName = curRoles.UserName
  3809. result, _ := service.Jxyb4101(struct4101, pp)
  3810. var dat map[string]interface{}
  3811. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3812. fmt.Println(dat)
  3813. } else {
  3814. fmt.Println(err)
  3815. }
  3816. userJSONBytes, _ := json.Marshal(dat)
  3817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3818. utils.ErrorLog("解析失败:%v", err)
  3819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3820. return
  3821. }
  3822. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3823. var pp models.PublicParams
  3824. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3825. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3826. pp.FixmedinsName = miConfig.OrgName
  3827. pp.FixmedinsCode = miConfig.Code
  3828. pp.RequestUrl = miConfig.Url
  3829. pp.Cainfo = miConfig.Cainfo
  3830. pp.SecretKey = miConfig.SecretKey
  3831. pp.AccessKey = miConfig.AccessKey
  3832. pp.OpterName = curRoles.UserName
  3833. result, _ := service.Hnyb4101(struct4101, pp)
  3834. var dat map[string]interface{}
  3835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3836. fmt.Println(dat)
  3837. } else {
  3838. fmt.Println(err)
  3839. }
  3840. userJSONBytes, _ := json.Marshal(dat)
  3841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3842. utils.ErrorLog("解析失败:%v", err)
  3843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. return
  3845. }
  3846. } else {
  3847. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3848. var dat map[string]interface{}
  3849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3850. fmt.Println(dat)
  3851. } else {
  3852. fmt.Println(err)
  3853. }
  3854. userJSONBytes, _ := json.Marshal(dat)
  3855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3856. utils.ErrorLog("解析失败:%v", err)
  3857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. return
  3859. }
  3860. }
  3861. if res.Infcode != 0 {
  3862. c.ServeSuccessJSON(map[string]interface{}{
  3863. "failed_code": -10,
  3864. "msg": res.ErrMsg,
  3865. })
  3866. return
  3867. } else {
  3868. order.FaPiaoNumber = zero
  3869. order.FaPiaoCode = last_order.FaPiaoCode
  3870. service.UpdateOrder(order)
  3871. hisFundSettleListResult := &models.HisFundSettleListResult{
  3872. Number: res.Output.SetlListId,
  3873. Status: 1,
  3874. Ctime: time.Now().Unix(),
  3875. Mtime: time.Now().Unix(),
  3876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3877. IsUpload: 1,
  3878. OrderId: order_id,
  3879. }
  3880. service.CreateUploadRecord(hisFundSettleListResult)
  3881. c.ServeSuccessJSON(map[string]interface{}{
  3882. "msg": "上传成功",
  3883. "result": hisFundSettleListResult,
  3884. })
  3885. return
  3886. }
  3887. }
  3888. func (c *HisApiController) GetSettleListHospital() {
  3889. order_id, _ := c.GetInt64("order_id")
  3890. admin_user_id, _ := c.GetInt64("admin_user_id")
  3891. order, _ := service.GetHisOrderByIDTwo(order_id)
  3892. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3893. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3894. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3895. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3896. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3897. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3898. if order.ID == 0 {
  3899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3900. return
  3901. }
  3902. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3903. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3904. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3905. fmt.Println(count)
  3906. var zero string
  3907. number := count + 1
  3908. if number >= 1000 {
  3909. zero = "0000" + strconv.FormatInt(number, 10)
  3910. } else if number >= 10000 {
  3911. zero = "000" + strconv.FormatInt(number, 10)
  3912. } else if number >= 100000 {
  3913. zero = "00" + strconv.FormatInt(number, 10)
  3914. } else if number >= 1000000 {
  3915. zero = "0" + strconv.FormatInt(number, 10)
  3916. } else {
  3917. zero = strconv.FormatInt(number, 10)
  3918. }
  3919. fmt.Println(zero)
  3920. struct4101 := service.Struct4101{
  3921. PsnNo: order.PsnNo,
  3922. MdtrtId: order.MdtrtId,
  3923. SetlId: order.SetlId,
  3924. PsnName: order.PsnName,
  3925. Gend: order.Gend,
  3926. Brdy: his.Brdy,
  3927. Age: int64(order.Age),
  3928. Naty: order.Naty,
  3929. PatnCertType: "01",
  3930. Certno: order.Certno,
  3931. Prfs: "90",
  3932. ConerName: roles[0].UserName,
  3933. PatnRlts: "99",
  3934. ConerAddr: miConfig.OrgName,
  3935. ConerTel: admin.Mobile,
  3936. HiType: order.Insutype,
  3937. Insuplc: miConfig.InsuplcAdmdvs,
  3938. MaindiagFlag: "1",
  3939. BillCode: order.SetlId,
  3940. BillNo: order.SetlId,
  3941. BizSn: order.Number,
  3942. PsnSelfPay: order.PsnPartAmt,
  3943. PsnOwnPay: order.PsnPartAmt,
  3944. AcctPay: order.AcctPay,
  3945. PsnCashpay: order.PsnCashPay,
  3946. HiPaymtd: "1",
  3947. Hsorg: miConfig.InsuplcAdmdvs,
  3948. HsorgOpter: miConfig.InsuplcAdmdvs,
  3949. MedinsFillPsn: curRoles.UserName,
  3950. MedinsFillDept: depart.Name,
  3951. IptMedType: "2",
  3952. AdmTime: his.InHosptialTime,
  3953. AdmEndTime: his.OutHosptialTime,
  3954. }
  3955. struct4101.SetlBegnDate = order.SetlTime
  3956. struct4101.SetlEndDate = order.SetlTime
  3957. var rf []CustomFundPay
  3958. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3959. var tempFunPays []service.CustomStruct
  3960. for _, item := range rf {
  3961. var tempFunPay service.CustomStruct
  3962. tempFunPay.FundPayamt = item.FundPayamt
  3963. tempFunPay.FundPayType = item.FundPayType
  3964. tempFunPays = append(tempFunPays, tempFunPay)
  3965. }
  3966. struct4101.CustomStruct = tempFunPays
  3967. var tempDiaginfos []service.DiaginfoStructTwo
  3968. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3969. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3970. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3971. var config []*models.HisXtDiagnoseConfig
  3972. for _, item := range diagnosis_ids {
  3973. id, _ := strconv.ParseInt(item, 10, 64)
  3974. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3975. config = append(config, &diagnosisConfig)
  3976. }
  3977. for index, item := range config {
  3978. if index == 0 {
  3979. var tempDiaginfo service.DiaginfoStructTwo
  3980. tempDiaginfo.DiagCode = item.CountryCode
  3981. tempDiaginfo.DiagName = item.CountryContentName
  3982. tempDiaginfo.DiagType = "1"
  3983. tempDiaginfo.MaindiagFlag = "1"
  3984. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3985. } else {
  3986. var tempDiaginfo service.DiaginfoStructTwo
  3987. tempDiaginfo.DiagCode = item.CountryCode
  3988. tempDiaginfo.DiagName = item.CountryContentName
  3989. tempDiaginfo.DiagType = "2"
  3990. tempDiaginfo.MaindiagFlag = "0"
  3991. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3992. }
  3993. }
  3994. struct4101.Diseinfo = tempDiaginfos
  3995. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3996. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3997. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3998. tempOpspdiseinfo2.OprnOprtCode = ""
  3999. tempOpspdiseinfo2.OprnOprtName = ""
  4000. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4001. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4002. var iteminfo service.IteminfoStruct
  4003. var bedCostTotal float64 = 0 //床位总费
  4004. var bedCostSelfTotal float64 = 0 //床位自费
  4005. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4006. var operationCostTotal float64 = 0 //手术费
  4007. var operationCostSelfTotal float64 = 0 //手术费
  4008. var operationCostPartSelfTotal float64 = 0 //手术费
  4009. var otherCostTotal float64 = 0 //其他费用
  4010. var otherCostSelfTotal float64 = 0 //其他费用
  4011. var otherCostPartSelfTotal float64 = 0 //其他费用
  4012. var materialCostTotal float64 = 0 //材料费
  4013. var materialCostSelfTotal float64 = 0 //材料费
  4014. var materialCostPartSelfTotal float64 = 0 //材料费
  4015. var westernMedicineCostTotal float64 = 0 //西药费
  4016. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4017. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4018. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4019. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4020. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4021. var checkCostTotal float64 = 0 //检查费
  4022. var checkCostSelfTotal float64 = 0 //检查费
  4023. var checkCostPartSelfTotal float64 = 0 //检查费
  4024. var laboratoryCostTotal float64 = 0 //化验费
  4025. var laboratoryCostSelfTotal float64 = 0 //化验费
  4026. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4027. var treatCostTotal float64 = 0 //治疗费用
  4028. var treatCostSelfTotal float64 = 0 //治疗费用
  4029. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4030. decimal.DivisionPrecision = 2
  4031. var bed_fulamt_ownpay_amt float64 = 0
  4032. var operation_fulamt_ownpay_amt float64 = 0
  4033. var other_fulamt_ownpay_amt float64 = 0
  4034. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4035. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4036. var check_fulamt_ownpay_amt float64 = 0
  4037. var material_fulamt_ownpay_amt float64 = 0
  4038. var laboratory_fulamt_ownpay_amt float64 = 0
  4039. var treat_fulamt_ownpay_amt float64 = 0
  4040. var bed_claa_sunmfee float64 = 0
  4041. var bed_clab_amt float64 = 0
  4042. var bed_other_amt float64 = 0
  4043. var operation_claa_sunmfee float64 = 0
  4044. var operation_clab_amt float64 = 0
  4045. var operation_other_amt float64 = 0
  4046. var other_claa_sunmfee float64 = 0
  4047. var other_clab_amt float64 = 0
  4048. var other_other_amt float64 = 0
  4049. var westernMedicine_claa_sunmfee float64 = 0
  4050. var westernMedicine_clab_amt float64 = 0
  4051. var westernMedicine_other_amt float64 = 0
  4052. var chineseTraditional_claa_sunmfee float64 = 0
  4053. var chineseTraditional_clab_amt float64 = 0
  4054. var chineseTraditional_other_amt float64 = 0
  4055. var check_claa_sunmfee float64 = 0
  4056. var check_clab_amt float64 = 0
  4057. var check_other_amt float64 = 0
  4058. var material_claa_sunmfee float64 = 0
  4059. var material_clab_amt float64 = 0
  4060. var material_other_amt float64 = 0
  4061. var laboratory_claa_sunmfee float64 = 0
  4062. var laboratory_clab_amt float64 = 0
  4063. var laboratory_other_amt float64 = 0
  4064. var treat_claa_sunmfee float64 = 0
  4065. var treat_clab_amt float64 = 0
  4066. var treat_other_amt float64 = 0
  4067. for _, item := range order.HisOrderInfo {
  4068. if item.MedChrgitmType == "01" { //床位费
  4069. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4070. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4071. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4072. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4073. if item.ChrgitmLv == "1" {
  4074. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4075. }
  4076. if item.ChrgitmLv == "2" {
  4077. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4078. }
  4079. if item.ChrgitmLv == "3" {
  4080. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4081. }
  4082. }
  4083. if item.MedChrgitmType == "03" { //检查费
  4084. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4085. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4086. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4087. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4088. if item.ChrgitmLv == "1" {
  4089. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4090. }
  4091. if item.ChrgitmLv == "2" {
  4092. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4093. }
  4094. if item.ChrgitmLv == "3" {
  4095. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4096. }
  4097. }
  4098. if item.MedChrgitmType == "04" { //化验费
  4099. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4100. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4101. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4102. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4103. if item.ChrgitmLv == "1" {
  4104. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4105. }
  4106. if item.ChrgitmLv == "2" {
  4107. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4108. }
  4109. if item.ChrgitmLv == "3" {
  4110. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4111. }
  4112. }
  4113. if item.MedChrgitmType == "05" { //治疗费
  4114. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4115. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4116. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4117. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4118. if item.ChrgitmLv == "1" {
  4119. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4120. }
  4121. if item.ChrgitmLv == "2" {
  4122. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4123. }
  4124. if item.ChrgitmLv == "3" {
  4125. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4126. }
  4127. }
  4128. if item.MedChrgitmType == "06" { //手术费
  4129. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4130. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4131. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4132. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4133. if item.ChrgitmLv == "1" {
  4134. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4135. }
  4136. if item.ChrgitmLv == "2" {
  4137. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4138. }
  4139. if item.ChrgitmLv == "3" {
  4140. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4141. }
  4142. }
  4143. if item.MedChrgitmType == "08" { //材料费
  4144. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4145. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4146. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4147. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4148. if item.ChrgitmLv == "1" {
  4149. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4150. }
  4151. if item.ChrgitmLv == "2" {
  4152. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4153. }
  4154. if item.ChrgitmLv == "3" {
  4155. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4156. }
  4157. }
  4158. if item.MedChrgitmType == "09" { //西药费
  4159. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4160. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4161. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4162. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4163. if item.ChrgitmLv == "1" {
  4164. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4165. }
  4166. if item.ChrgitmLv == "2" {
  4167. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4168. }
  4169. if item.ChrgitmLv == "3" {
  4170. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4171. }
  4172. }
  4173. if item.MedChrgitmType == "11" { //中成费
  4174. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4175. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4176. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4177. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4178. if item.ChrgitmLv == "1" {
  4179. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4180. }
  4181. if item.ChrgitmLv == "2" {
  4182. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4183. }
  4184. if item.ChrgitmLv == "3" {
  4185. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4186. }
  4187. }
  4188. if item.MedChrgitmType == "14" { //其他费
  4189. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4190. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4191. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4192. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4193. if item.ChrgitmLv == "1" {
  4194. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4195. }
  4196. if item.ChrgitmLv == "2" {
  4197. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4198. }
  4199. if item.ChrgitmLv == "3" {
  4200. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4201. }
  4202. }
  4203. }
  4204. var iteminfoStructs []service.IteminfoStruct
  4205. if bedCostTotal != 0 {
  4206. iteminfo.MedChrgitm = "01"
  4207. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4208. iteminfo.Amt = bedCostTotal
  4209. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4210. iteminfo.ClabAmt = bed_clab_amt
  4211. iteminfo.OthAmt = bed_other_amt
  4212. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4213. }
  4214. if checkCostTotal != 0 {
  4215. iteminfo.MedChrgitm = "03"
  4216. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4217. iteminfo.Amt = checkCostTotal
  4218. iteminfo.ClaaSumfee = check_claa_sunmfee
  4219. iteminfo.ClabAmt = check_clab_amt
  4220. iteminfo.OthAmt = check_other_amt
  4221. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4222. }
  4223. if laboratoryCostTotal != 0 {
  4224. iteminfo.MedChrgitm = "04"
  4225. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4226. iteminfo.Amt = laboratoryCostTotal
  4227. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4228. iteminfo.ClabAmt = laboratory_clab_amt
  4229. iteminfo.OthAmt = laboratory_other_amt
  4230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4231. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4232. }
  4233. if treatCostTotal != 0 {
  4234. iteminfo.MedChrgitm = "05"
  4235. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4236. iteminfo.Amt = treatCostTotal
  4237. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4238. iteminfo.ClabAmt = treat_clab_amt
  4239. iteminfo.OthAmt = treat_other_amt
  4240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4241. //(struct4101.IteminfoStruct, iteminfo)
  4242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4243. }
  4244. if operationCostTotal != 0 {
  4245. iteminfo.MedChrgitm = "06"
  4246. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4247. iteminfo.Amt = operationCostTotal
  4248. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4249. iteminfo.ClabAmt = operation_clab_amt
  4250. iteminfo.OthAmt = operation_other_amt
  4251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4253. }
  4254. if materialCostTotal != 0 {
  4255. iteminfo.MedChrgitm = "08"
  4256. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4257. iteminfo.Amt = materialCostTotal
  4258. iteminfo.ClaaSumfee = material_claa_sunmfee
  4259. iteminfo.ClabAmt = material_clab_amt
  4260. iteminfo.OthAmt = material_other_amt
  4261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4263. }
  4264. if westernMedicineCostTotal != 0 {
  4265. iteminfo.MedChrgitm = "09"
  4266. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4267. iteminfo.Amt = westernMedicineCostTotal
  4268. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4269. iteminfo.ClabAmt = westernMedicine_clab_amt
  4270. iteminfo.OthAmt = westernMedicine_other_amt
  4271. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4272. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4273. }
  4274. if chineseTraditionalMedicineCostTotal != 0 {
  4275. iteminfo.MedChrgitm = "11"
  4276. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4277. iteminfo.Amt = westernMedicineCostTotal
  4278. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4279. iteminfo.ClabAmt = westernMedicine_clab_amt
  4280. iteminfo.OthAmt = westernMedicine_other_amt
  4281. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4283. }
  4284. if otherCostTotal != 0 {
  4285. iteminfo.MedChrgitm = "14"
  4286. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4287. iteminfo.Amt = otherCostTotal
  4288. iteminfo.ClaaSumfee = other_claa_sunmfee
  4289. iteminfo.ClabAmt = other_clab_amt
  4290. iteminfo.OthAmt = other_other_amt
  4291. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4293. }
  4294. struct4101.IteminfoStruct = iteminfoStructs
  4295. struct4101.Ntly = "中国"
  4296. struct4101.AdmCaty = "A03.06"
  4297. var resOther ResultSeventeenOther
  4298. var res ResultSeventeen
  4299. if miConfig.MdtrtareaAdmvs == "150499" {
  4300. var pp models.PublicParams
  4301. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4302. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4303. pp.FixmedinsName = miConfig.OrgName
  4304. pp.FixmedinsCode = miConfig.Code
  4305. pp.RequestUrl = miConfig.Url
  4306. pp.Cainfo = miConfig.Cainfo
  4307. pp.SecretKey = miConfig.SecretKey
  4308. pp.AccessKey = miConfig.AccessKey
  4309. pp.OpterName = curRoles.UserName
  4310. client := &http.Client{}
  4311. var req *http.Request
  4312. data := make(map[string]interface{})
  4313. data["struct4101"] = struct4101
  4314. data["pp"] = pp
  4315. bytesData, _ := json.Marshal(data)
  4316. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4317. resp, _ := client.Do(req)
  4318. defer resp.Body.Close()
  4319. body, ioErr := ioutil.ReadAll(resp.Body)
  4320. if ioErr != nil {
  4321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4323. return
  4324. }
  4325. var respJSON map[string]interface{}
  4326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4329. return
  4330. }
  4331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4332. userJSONBytes, _ := json.Marshal(respJSON)
  4333. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4334. utils.ErrorLog("解析失败:%v", err)
  4335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4336. return
  4337. }
  4338. res.InfRefmsgid = resOther.InfRefmsgid
  4339. res.Output = resOther.Output
  4340. res.ErrMsg = resOther.ErrMsg
  4341. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4342. res.Infcode = infocode
  4343. } else {
  4344. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4345. var dat map[string]interface{}
  4346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4347. fmt.Println(dat)
  4348. } else {
  4349. fmt.Println(err)
  4350. }
  4351. userJSONBytes, _ := json.Marshal(dat)
  4352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4353. utils.ErrorLog("解析失败:%v", err)
  4354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4355. return
  4356. }
  4357. }
  4358. if res.Infcode != 0 {
  4359. c.ServeSuccessJSON(map[string]interface{}{
  4360. "failed_code": -10,
  4361. "msg": res.ErrMsg,
  4362. })
  4363. return
  4364. } else {
  4365. if miConfig.MdtrtareaAdmvs != "150499" {
  4366. order.FaPiaoNumber = zero
  4367. order.FaPiaoCode = last_order.FaPiaoCode
  4368. service.UpdateOrder(order)
  4369. }
  4370. hisFundSettleListResult := &models.HisFundSettleListResult{
  4371. Number: res.Output.SetlListId,
  4372. Status: 1,
  4373. Ctime: time.Now().Unix(),
  4374. Mtime: time.Now().Unix(),
  4375. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4376. IsUpload: 1,
  4377. OrderId: order_id,
  4378. }
  4379. service.CreateUploadRecord(hisFundSettleListResult)
  4380. c.ServeSuccessJSON(map[string]interface{}{
  4381. "msg": "上传成功",
  4382. "result": hisFundSettleListResult,
  4383. })
  4384. return
  4385. }
  4386. }
  4387. func (c *HisApiController) GetBatchSettleList() {
  4388. orders, _ := service.GetAllHisOrder(10138)
  4389. for _, item := range orders {
  4390. order_id := item.ID
  4391. order, _ := service.GetHisOrderByIDTwo(order_id)
  4392. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4393. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4394. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4395. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  4396. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4398. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4399. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4400. if order.ID == 0 {
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4402. return
  4403. }
  4404. if his.BalanceAccountsType == 2 {
  4405. continue
  4406. }
  4407. struct4101 := service.Struct4101{
  4408. PsnNo: order.PsnNo,
  4409. MdtrtId: order.MdtrtId,
  4410. SetlId: order.SetlId,
  4411. PsnName: order.PsnName,
  4412. Gend: order.Gend,
  4413. Brdy: his.Brdy,
  4414. Age: his.Age,
  4415. Naty: order.Naty,
  4416. PatnCertType: "01",
  4417. Certno: order.Certno,
  4418. Prfs: "90",
  4419. ConerName: roles[0].UserName,
  4420. PatnRlts: "99",
  4421. ConerAddr: miConfig.OrgName,
  4422. ConerTel: admin.Mobile,
  4423. HiType: order.Insutype,
  4424. Insuplc: his.InsuplcAdmdvs,
  4425. MaindiagFlag: "1",
  4426. BillCode: order.SetlId,
  4427. BillNo: order.SetlId,
  4428. BizSn: order.Number,
  4429. PsnSelfPay: order.PsnPartAmt,
  4430. PsnOwnPay: order.PsnPartAmt,
  4431. AcctPay: order.AcctPay,
  4432. PsnCashpay: order.PsnCashPay,
  4433. HiPaymtd: "1",
  4434. Hsorg: his.InsuplcAdmdvs,
  4435. HsorgOpter: his.InsuplcAdmdvs,
  4436. MedinsFillPsn: curRoles.UserName,
  4437. MedinsFillDept: depart.Name,
  4438. IptMedType: "2",
  4439. }
  4440. struct4101.SetlBegnDate = order.SetlTime
  4441. struct4101.SetlEndDate = order.SetlTime
  4442. //if order.SettleType == 1 {
  4443. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4444. // dateStr := t.Format("2006-01-02")
  4445. // struct4101.SetlBegnDate = dateStr
  4446. // struct4101.SetlEndDate = dateStr
  4447. //} else {
  4448. // t := time.Unix(int64(order.SettleStartTime), 0)
  4449. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4450. // dateStartStr := t.Format("2006-01-02")
  4451. // dateEndStr := t2.Format("2006-01-02")
  4452. // struct4101.SetlBegnDate = dateStartStr
  4453. // struct4101.SetlEndDate = dateEndStr
  4454. //}
  4455. var rf []CustomFundPay
  4456. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4457. var tempFunPays []service.CustomStruct
  4458. var tempFunPay610100 service.CustomStruct
  4459. for _, item := range rf {
  4460. if item.FundPayType == "610100" {
  4461. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4462. tempFunPay610100.FundPayType = item.FundPayType
  4463. } else {
  4464. var tempFunPay service.CustomStruct
  4465. tempFunPay.FundPayamt = item.FundPayamt
  4466. tempFunPay.FundPayType = item.FundPayType
  4467. tempFunPays = append(tempFunPays, tempFunPay)
  4468. }
  4469. }
  4470. tempFunPays = append(tempFunPays, tempFunPay610100)
  4471. struct4101.CustomStruct = tempFunPays
  4472. var tempDiaginfos []service.DiaginfoStructTwo
  4473. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4474. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4475. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4476. var config []*models.HisXtDiagnoseConfig
  4477. for _, item := range diagnosis_ids {
  4478. id, _ := strconv.ParseInt(item, 10, 64)
  4479. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4480. config = append(config, &diagnosisConfig)
  4481. }
  4482. for index, item := range config {
  4483. if index == 0 {
  4484. var tempDiaginfo service.DiaginfoStructTwo
  4485. tempDiaginfo.DiagCode = item.CountryCode
  4486. tempDiaginfo.DiagName = item.CountryContentName
  4487. tempDiaginfo.DiagType = "1"
  4488. tempDiaginfo.MaindiagFlag = "1"
  4489. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4490. } else {
  4491. var tempDiaginfo service.DiaginfoStructTwo
  4492. tempDiaginfo.DiagCode = item.CountryCode
  4493. tempDiaginfo.DiagName = item.CountryContentName
  4494. tempDiaginfo.DiagType = "2"
  4495. tempDiaginfo.MaindiagFlag = "0"
  4496. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4497. }
  4498. }
  4499. struct4101.Diseinfo = tempDiaginfos
  4500. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4501. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4502. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4503. tempOpspdiseinfo2.OprnOprtCode = ""
  4504. tempOpspdiseinfo2.OprnOprtName = ""
  4505. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4506. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4507. var iteminfo service.IteminfoStruct
  4508. var bedCostTotal float64 = 0 //床位总费
  4509. var bedCostSelfTotal float64 = 0 //床位自费
  4510. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4511. var examineCostTotal float64 = 0 //诊查总费
  4512. var examineCostSelfTotal float64 = 0 //诊查自费
  4513. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4514. var nursingCostTotal float64 = 0 //护理总费
  4515. var nursingCostSelfTotal float64 = 0 //护理自费
  4516. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4517. var chineseMedicineCostTotal float64 = 0 //中成药
  4518. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4519. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4520. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4521. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4522. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4523. var registerCostTotal float64 = 0 //一般诊疗费
  4524. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4525. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4526. var operationCostTotal float64 = 0 //手术费
  4527. var operationCostSelfTotal float64 = 0 //手术费
  4528. var operationCostPartSelfTotal float64 = 0 //手术费
  4529. var otherCostTotal float64 = 0 //其他费用
  4530. var otherCostSelfTotal float64 = 0 //其他费用
  4531. var otherCostPartSelfTotal float64 = 0 //其他费用
  4532. var materialCostTotal float64 = 0 //材料费
  4533. var materialCostSelfTotal float64 = 0 //材料费
  4534. var materialCostPartSelfTotal float64 = 0 //材料费
  4535. var westernMedicineCostTotal float64 = 0 //西药费
  4536. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4537. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4538. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4539. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4540. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4541. var checkCostTotal float64 = 0 //检查费
  4542. var checkCostSelfTotal float64 = 0 //检查费
  4543. var checkCostPartSelfTotal float64 = 0 //检查费
  4544. var laboratoryCostTotal float64 = 0 //化验费
  4545. var laboratoryCostSelfTotal float64 = 0 //化验费
  4546. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4547. var treatCostTotal float64 = 0 //治疗费用
  4548. var treatCostSelfTotal float64 = 0 //治疗费用
  4549. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4550. decimal.DivisionPrecision = 2
  4551. var bed_fulamt_ownpay_amt float64 = 0
  4552. var examine_fulamt_ownpay_amt float64 = 0
  4553. var nursing_fulamt_ownpay_amt float64 = 0
  4554. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4555. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4556. var register_fulamt_ownpay_amt float64 = 0
  4557. var operation_fulamt_ownpay_amt float64 = 0
  4558. var other_fulamt_ownpay_amt float64 = 0
  4559. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4560. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4561. var check_fulamt_ownpay_amt float64 = 0
  4562. var material_fulamt_ownpay_amt float64 = 0
  4563. var laboratory_fulamt_ownpay_amt float64 = 0
  4564. var treat_fulamt_ownpay_amt float64 = 0
  4565. var bed_claa_sunmfee float64 = 0
  4566. var bed_clab_amt float64 = 0
  4567. var bed_other_amt float64 = 0
  4568. var examine_claa_sunmfee float64 = 0
  4569. var examine_clab_amt float64 = 0
  4570. var examine_other_amt float64 = 0
  4571. var nursing_claa_sunmfee float64 = 0
  4572. var nursing_clab_amt float64 = 0
  4573. var nursing_other_amt float64 = 0
  4574. var chinese_medicine_claa_sunmfee float64 = 0
  4575. var chinese_medicine_clab_amt float64 = 0
  4576. var chinese_medicine_other_amt float64 = 0
  4577. var commonly_treatment_claa_sunmfee float64 = 0
  4578. var commonly_treatment_clab_amt float64 = 0
  4579. var commonly_treatment_other_amt float64 = 0
  4580. var operation_claa_sunmfee float64 = 0
  4581. var operation_clab_amt float64 = 0
  4582. var operation_other_amt float64 = 0
  4583. var other_claa_sunmfee float64 = 0
  4584. var other_clab_amt float64 = 0
  4585. var other_other_amt float64 = 0
  4586. var westernMedicine_claa_sunmfee float64 = 0
  4587. var westernMedicine_clab_amt float64 = 0
  4588. var westernMedicine_other_amt float64 = 0
  4589. var chineseTraditional_claa_sunmfee float64 = 0
  4590. var chineseTraditional_clab_amt float64 = 0
  4591. var chineseTraditional_other_amt float64 = 0
  4592. var check_claa_sunmfee float64 = 0
  4593. var check_clab_amt float64 = 0
  4594. var check_other_amt float64 = 0
  4595. var material_claa_sunmfee float64 = 0
  4596. var material_clab_amt float64 = 0
  4597. var material_other_amt float64 = 0
  4598. var laboratory_claa_sunmfee float64 = 0
  4599. var laboratory_clab_amt float64 = 0
  4600. var laboratory_other_amt float64 = 0
  4601. var treat_claa_sunmfee float64 = 0
  4602. var treat_clab_amt float64 = 0
  4603. var treat_other_amt float64 = 0
  4604. var register_claa_sunmfee float64 = 0
  4605. var register_clab_amt float64 = 0
  4606. var register_other_amt float64 = 0
  4607. for _, item := range order.HisOrderInfo {
  4608. if item.MedChrgitmType == "01" { //床位费
  4609. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4610. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4611. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4612. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4613. if item.ChrgitmLv == "1" {
  4614. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4615. }
  4616. if item.ChrgitmLv == "2" {
  4617. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4618. }
  4619. if item.ChrgitmLv == "3" {
  4620. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4621. }
  4622. }
  4623. if item.MedChrgitmType == "02" { //诊查
  4624. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4625. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4626. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4627. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4628. if item.ChrgitmLv == "1" {
  4629. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4630. }
  4631. if item.ChrgitmLv == "2" {
  4632. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4633. }
  4634. if item.ChrgitmLv == "3" {
  4635. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4636. }
  4637. }
  4638. if item.MedChrgitmType == "03" { //检查费
  4639. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4640. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4641. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4642. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4643. if item.ChrgitmLv == "1" {
  4644. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4645. }
  4646. if item.ChrgitmLv == "2" {
  4647. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4648. }
  4649. if item.ChrgitmLv == "3" {
  4650. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4651. }
  4652. }
  4653. if item.MedChrgitmType == "04" { //化验费
  4654. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4655. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4656. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4657. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4658. if item.ChrgitmLv == "1" {
  4659. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4660. }
  4661. if item.ChrgitmLv == "2" {
  4662. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4663. }
  4664. if item.ChrgitmLv == "3" {
  4665. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4666. }
  4667. }
  4668. if item.MedChrgitmType == "05" { //治疗费
  4669. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4670. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4671. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4672. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4673. if item.ChrgitmLv == "1" {
  4674. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4675. }
  4676. if item.ChrgitmLv == "2" {
  4677. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4678. }
  4679. if item.ChrgitmLv == "3" {
  4680. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4681. }
  4682. }
  4683. if item.MedChrgitmType == "06" { //手术费
  4684. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4685. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4686. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4687. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4688. if item.ChrgitmLv == "1" {
  4689. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4690. }
  4691. if item.ChrgitmLv == "2" {
  4692. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4693. }
  4694. if item.ChrgitmLv == "3" {
  4695. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4696. }
  4697. }
  4698. if item.MedChrgitmType == "07" { //手术费
  4699. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4700. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4701. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4702. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4703. if item.ChrgitmLv == "1" {
  4704. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4705. }
  4706. if item.ChrgitmLv == "2" {
  4707. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4708. }
  4709. if item.ChrgitmLv == "3" {
  4710. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4711. }
  4712. }
  4713. if item.MedChrgitmType == "08" { //材料费
  4714. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4715. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4716. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4717. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4718. if item.ChrgitmLv == "1" {
  4719. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4720. }
  4721. if item.ChrgitmLv == "2" {
  4722. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4723. }
  4724. if item.ChrgitmLv == "3" {
  4725. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4726. }
  4727. }
  4728. if item.MedChrgitmType == "09" { //西药费
  4729. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4730. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4731. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4732. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4733. if item.ChrgitmLv == "1" {
  4734. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4735. }
  4736. if item.ChrgitmLv == "2" {
  4737. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4738. }
  4739. if item.ChrgitmLv == "3" {
  4740. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4741. }
  4742. }
  4743. if item.MedChrgitmType == "10" { //中药饮片
  4744. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4745. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4746. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4747. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4748. if item.ChrgitmLv == "1" {
  4749. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4750. }
  4751. if item.ChrgitmLv == "2" {
  4752. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4753. }
  4754. if item.ChrgitmLv == "3" {
  4755. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4756. }
  4757. }
  4758. if item.MedChrgitmType == "11" { //中成费
  4759. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4760. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4761. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4762. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4763. if item.ChrgitmLv == "1" {
  4764. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4765. }
  4766. if item.ChrgitmLv == "2" {
  4767. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4768. }
  4769. if item.ChrgitmLv == "3" {
  4770. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4771. }
  4772. }
  4773. if item.MedChrgitmType == "12" { //中成费
  4774. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4775. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4776. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4777. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4778. if item.ChrgitmLv == "1" {
  4779. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4780. }
  4781. if item.ChrgitmLv == "2" {
  4782. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4783. }
  4784. if item.ChrgitmLv == "3" {
  4785. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4786. }
  4787. }
  4788. if item.MedChrgitmType == "13" { //中成费
  4789. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4790. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4791. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4792. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4793. if item.ChrgitmLv == "1" {
  4794. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4795. }
  4796. if item.ChrgitmLv == "2" {
  4797. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4798. }
  4799. if item.ChrgitmLv == "3" {
  4800. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4801. }
  4802. }
  4803. if item.MedChrgitmType == "14" { //其他费
  4804. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4805. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4806. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4807. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4808. if item.ChrgitmLv == "1" {
  4809. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4810. }
  4811. if item.ChrgitmLv == "2" {
  4812. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4813. }
  4814. if item.ChrgitmLv == "3" {
  4815. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4816. }
  4817. }
  4818. }
  4819. var iteminfoStructs []service.IteminfoStruct
  4820. if bedCostTotal != 0 {
  4821. iteminfo.MedChrgitm = "01"
  4822. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4823. iteminfo.Amt = bedCostTotal
  4824. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4825. iteminfo.ClabAmt = bed_clab_amt
  4826. iteminfo.OthAmt = bed_other_amt
  4827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4828. }
  4829. if examineCostTotal != 0 {
  4830. iteminfo.MedChrgitm = "02"
  4831. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  4832. iteminfo.Amt = examineCostTotal
  4833. iteminfo.ClaaSumfee = examine_claa_sunmfee
  4834. iteminfo.ClabAmt = examine_clab_amt
  4835. iteminfo.OthAmt = examine_other_amt
  4836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4837. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4838. }
  4839. if checkCostTotal != 0 {
  4840. iteminfo.MedChrgitm = "03"
  4841. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4842. iteminfo.Amt = checkCostTotal
  4843. iteminfo.ClaaSumfee = check_claa_sunmfee
  4844. iteminfo.ClabAmt = check_clab_amt
  4845. iteminfo.OthAmt = check_other_amt
  4846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4847. }
  4848. if laboratoryCostTotal != 0 {
  4849. iteminfo.MedChrgitm = "04"
  4850. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4851. iteminfo.Amt = laboratoryCostTotal
  4852. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4853. iteminfo.ClabAmt = laboratory_clab_amt
  4854. iteminfo.OthAmt = laboratory_other_amt
  4855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4857. }
  4858. if treatCostTotal != 0 {
  4859. iteminfo.MedChrgitm = "05"
  4860. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4861. iteminfo.Amt = treatCostTotal
  4862. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4863. iteminfo.ClabAmt = treat_clab_amt
  4864. iteminfo.OthAmt = treat_other_amt
  4865. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4866. //(struct4101.IteminfoStruct, iteminfo)
  4867. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4868. }
  4869. if operationCostTotal != 0 {
  4870. iteminfo.MedChrgitm = "06"
  4871. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4872. iteminfo.Amt = operationCostTotal
  4873. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4874. iteminfo.ClabAmt = operation_clab_amt
  4875. iteminfo.OthAmt = operation_other_amt
  4876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4877. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4878. }
  4879. if nursingCostTotal != 0 {
  4880. iteminfo.MedChrgitm = "07"
  4881. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  4882. iteminfo.Amt = nursingCostTotal
  4883. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  4884. iteminfo.ClabAmt = nursing_clab_amt
  4885. iteminfo.OthAmt = nursing_other_amt
  4886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4887. }
  4888. if materialCostTotal != 0 {
  4889. iteminfo.MedChrgitm = "08"
  4890. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4891. iteminfo.Amt = materialCostTotal
  4892. iteminfo.ClaaSumfee = material_claa_sunmfee
  4893. iteminfo.ClabAmt = material_clab_amt
  4894. iteminfo.OthAmt = material_other_amt
  4895. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4896. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4897. }
  4898. if westernMedicineCostTotal != 0 {
  4899. iteminfo.MedChrgitm = "09"
  4900. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4901. iteminfo.Amt = westernMedicineCostTotal
  4902. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4903. iteminfo.ClabAmt = westernMedicine_clab_amt
  4904. iteminfo.OthAmt = westernMedicine_other_amt
  4905. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4906. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4907. }
  4908. if chineseMedicineCostTotal != 0 {
  4909. iteminfo.MedChrgitm = "10"
  4910. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  4911. iteminfo.Amt = chineseMedicineCostTotal
  4912. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  4913. iteminfo.ClabAmt = chinese_medicine_clab_amt
  4914. iteminfo.OthAmt = chinese_medicine_other_amt
  4915. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4917. }
  4918. if chineseTraditionalMedicineCostTotal != 0 {
  4919. iteminfo.MedChrgitm = "11"
  4920. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4921. iteminfo.Amt = westernMedicineCostTotal
  4922. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4923. iteminfo.ClabAmt = westernMedicine_clab_amt
  4924. iteminfo.OthAmt = westernMedicine_other_amt
  4925. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4927. }
  4928. if commonlyTreatmentCostTotal != 0 {
  4929. iteminfo.MedChrgitm = "12"
  4930. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  4931. iteminfo.Amt = commonlyTreatmentCostTotal
  4932. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  4933. iteminfo.ClabAmt = commonly_treatment_clab_amt
  4934. iteminfo.OthAmt = commonly_treatment_other_amt
  4935. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4936. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4937. }
  4938. if registerCostTotal != 0 {
  4939. iteminfo.MedChrgitm = "13"
  4940. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  4941. iteminfo.Amt = registerCostTotal
  4942. iteminfo.ClaaSumfee = register_claa_sunmfee
  4943. iteminfo.ClabAmt = register_clab_amt
  4944. iteminfo.OthAmt = register_other_amt
  4945. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4947. }
  4948. if otherCostTotal != 0 {
  4949. iteminfo.MedChrgitm = "14"
  4950. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4951. iteminfo.Amt = otherCostTotal
  4952. iteminfo.ClaaSumfee = other_claa_sunmfee
  4953. iteminfo.ClabAmt = other_clab_amt
  4954. iteminfo.OthAmt = other_other_amt
  4955. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4956. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4957. }
  4958. struct4101.IteminfoStruct = iteminfoStructs
  4959. time_arr := strings.Split(order.SetlTime, " ")
  4960. struct4101.AdmTime = time_arr[0]
  4961. struct4101.AdmEndTime = time_arr[0]
  4962. struct4101.DoctorName = doctor.UserName
  4963. struct4101.DoctorCode = doctor.DoctorNumber
  4964. struct4101.Ntly = "中国"
  4965. struct4101.AdmCaty = "A03.06"
  4966. var res ResultSeventeen
  4967. if miConfig.MdtrtareaAdmvs == "421300" {
  4968. data := make(map[string]interface{})
  4969. data["struct4101"] = struct4101
  4970. data["secret_key"] = miConfig.SecretKey
  4971. data["org_name"] = miConfig.OrgName
  4972. data["opera"] = curRoles.UserName
  4973. data["code"] = miConfig.Code
  4974. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4975. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4976. client := &http.Client{}
  4977. bytesData, _ := json.Marshal(data)
  4978. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. var respJSON map[string]interface{}
  4988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4991. return
  4992. }
  4993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4994. userJSONBytes, _ := json.Marshal(respJSON)
  4995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4996. utils.ErrorLog("解析失败:%v", err)
  4997. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4998. adminUser := c.GetAdminUserInfo()
  4999. errlog := &models.HisOrderError{
  5000. UserOrgId: adminUser.CurrentOrgId,
  5001. Ctime: time.Now().Unix(),
  5002. Mtime: time.Now().Unix(),
  5003. ErrMsg: res.ErrMsg + "解析失败",
  5004. Status: 1,
  5005. PatientId: order_id,
  5006. Stage: 10088,
  5007. }
  5008. service.CreateErrMsgLog(errlog)
  5009. continue
  5010. }
  5011. } else {
  5012. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5013. fmt.Println(result)
  5014. var dat map[string]interface{}
  5015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5016. fmt.Println(dat)
  5017. } else {
  5018. fmt.Println(err)
  5019. }
  5020. userJSONBytes, _ := json.Marshal(dat)
  5021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5022. utils.ErrorLog("解析失败:%v", err)
  5023. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5024. adminUser := c.GetAdminUserInfo()
  5025. errlog := &models.HisOrderError{
  5026. UserOrgId: adminUser.CurrentOrgId,
  5027. Ctime: time.Now().Unix(),
  5028. Mtime: time.Now().Unix(),
  5029. ErrMsg: res.ErrMsg + "解析失败",
  5030. Status: 1,
  5031. PatientId: order_id,
  5032. Stage: 10106,
  5033. }
  5034. service.CreateErrMsgLog(errlog)
  5035. continue
  5036. }
  5037. }
  5038. if res.Infcode != 0 {
  5039. adminUser := c.GetAdminUserInfo()
  5040. errlog := &models.HisOrderError{
  5041. UserOrgId: adminUser.CurrentOrgId,
  5042. Ctime: time.Now().Unix(),
  5043. Mtime: time.Now().Unix(),
  5044. ErrMsg: res.ErrMsg,
  5045. Status: 1,
  5046. PatientId: order_id,
  5047. Stage: 10106,
  5048. }
  5049. service.CreateErrMsgLog(errlog)
  5050. continue
  5051. } else {
  5052. hisFundSettleListResult := &models.HisFundSettleListResult{
  5053. Number: res.Output.SetlListId,
  5054. Status: 1,
  5055. Ctime: time.Now().Unix(),
  5056. Mtime: time.Now().Unix(),
  5057. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5058. IsUpload: 1,
  5059. OrderId: order_id,
  5060. }
  5061. service.CreateUploadRecord(hisFundSettleListResult)
  5062. continue
  5063. }
  5064. }
  5065. }
  5066. func (c *HisApiController) GetOrgInfo() {
  5067. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5068. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5069. }
  5070. func (c *HisApiController) GetHisPatientInfo() {
  5071. medical_insurance_card := c.GetString("medical_insurance_card")
  5072. id_card_type, _ := c.GetInt64("id_card_type")
  5073. id_card := c.GetString("id_card")
  5074. adminInfo := c.GetAdminUserInfo()
  5075. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5076. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5077. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5078. IdCardNo := ""
  5079. if id_card_type == 1 {
  5080. IdCardNo = medical_insurance_card
  5081. } else if id_card_type == 2 {
  5082. IdCardNo = id_card
  5083. }
  5084. if config.IsOpen == 1 {
  5085. 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
  5086. resp, requestErr := http.Get(api)
  5087. if requestErr != nil {
  5088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5089. return
  5090. }
  5091. defer resp.Body.Close()
  5092. body, ioErr := ioutil.ReadAll(resp.Body)
  5093. if ioErr != nil {
  5094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5096. return
  5097. }
  5098. var respJSON map[string]interface{}
  5099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. return
  5103. }
  5104. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5105. userJSONBytes, _ := json.Marshal(userJSON)
  5106. var res ResultTwo
  5107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5108. utils.ErrorLog("解析失败:%v", err)
  5109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5110. return
  5111. }
  5112. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5113. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5114. infoStr := string(Iinfos)
  5115. idetinfoStr := string(Idetinfos)
  5116. if res.Infcode == 0 {
  5117. his := models.VMHisPatient{
  5118. Status: 1,
  5119. Ctime: time.Now().Unix(),
  5120. Mtime: time.Now().Unix(),
  5121. PsnNo: res.Output.Baseinfo.PsnNo,
  5122. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5123. Certno: res.Output.Baseinfo.Certno,
  5124. PsnName: res.Output.Baseinfo.PsnName,
  5125. Gend: res.Output.Baseinfo.Gend,
  5126. Naty: res.Output.Baseinfo.Naty,
  5127. Brdy: res.Output.Baseinfo.Brdy,
  5128. Age: res.Output.Baseinfo.Age,
  5129. Iinfo: infoStr,
  5130. Idetinfo: idetinfoStr,
  5131. UserOrgId: adminInfo.CurrentOrgId,
  5132. IsReturn: 1,
  5133. IdCardType: id_card_type,
  5134. }
  5135. c.ServeSuccessJSON(map[string]interface{}{
  5136. "info": his,
  5137. })
  5138. } else {
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5140. return
  5141. }
  5142. }
  5143. }
  5144. //func GetBasBaseInfo() (jsonStr string, err error) {
  5145. //
  5146. // handle := syscall.NewLazyDLL("SSCard.dll")
  5147. // add := handle.NewProc("ReadCardBas")
  5148. // str := make([]byte, 1024)
  5149. // str1 := make([]byte, 1024)
  5150. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5151. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5152. //
  5153. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5154. //
  5155. // fmt.Println("> Add(4,5)的结果为:", ret)
  5156. // handle.Release()
  5157. //
  5158. // return "", nil
  5159. //
  5160. //}
  5161. //func GetQRBaseInfo() (jsonStr string, err error) {
  5162. // handle := syscall.LoadDLL("SSCard.dll")
  5163. // ReadCardBas := handle.FindProc("GetQRBase")
  5164. //
  5165. // str := make([]byte, 256)
  5166. // str1 := make([]byte, 256)
  5167. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5168. //
  5169. // fmt.Println(string(str))
  5170. // fmt.Println(r)
  5171. // return string(str), nil
  5172. //}
  5173. //func CardInit() int {
  5174. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5175. // add := DllTestDef.MustFindProc("Init")
  5176. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5177. // if err != nil {
  5178. // fmt.Println("SSCard的运算结果为:", ret)
  5179. // }
  5180. // result := int(ret)
  5181. // return result
  5182. //}
  5183. //func CardInit() int {
  5184. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5185. // if err != nil {
  5186. // fmt.Println("SSCard的运算结果为:", ret)
  5187. // }
  5188. // fmt.Println(err)
  5189. // result := int(ret)
  5190. // return result
  5191. //}
  5192. func IntPtr(n int) uintptr {
  5193. return uintptr(n)
  5194. }
  5195. func StrPtr(s string) uintptr {
  5196. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5197. }
  5198. type Result2001 struct {
  5199. Cainfo interface{} `json:"cainfo"`
  5200. ErrMsg string `json:"err_msg"`
  5201. InfRefmsgid string `json:"inf_refmsgid"`
  5202. Infcode int64 `json:"infcode"`
  5203. Output struct {
  5204. Trtinfo struct {
  5205. PsnNo string `json:"psn_no"`
  5206. TrtChkType string `json:"trt_chk_type"`
  5207. FundPayType string `json:"fund_pay_type"`
  5208. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5209. Begndate string `json:"begndate"`
  5210. Enddate string `json:"enddate"`
  5211. TrtChkRslt string `json:"trt_chk_rslt"`
  5212. } `json:"trtinfo"`
  5213. } `json:"output"`
  5214. RefmsgTime string `json:"refmsg_time"`
  5215. RespondTime string `json:"respond_time"`
  5216. Signtype interface{} `json:"signtype"`
  5217. WarnMsg interface{} `json:"warn_msg"`
  5218. }
  5219. type Result2001Org10265 struct {
  5220. Cainfo interface{} `json:"cainfo"`
  5221. ErrMsg string `json:"err_msg"`
  5222. InfRefmsgid string `json:"inf_refmsgid"`
  5223. Infcode string `json:"infcode"`
  5224. Output struct {
  5225. Trtinfo struct {
  5226. PsnNo string `json:"psn_no"`
  5227. TrtChkType string `json:"trt_chk_type"`
  5228. FundPayType string `json:"fund_pay_type"`
  5229. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5230. Begndate string `json:"begndate"`
  5231. Enddate string `json:"enddate"`
  5232. TrtChkRslt string `json:"trt_chk_rslt"`
  5233. } `json:"trtinfo"`
  5234. } `json:"output"`
  5235. RefmsgTime string `json:"refmsg_time"`
  5236. RespondTime string `json:"respond_time"`
  5237. Signtype interface{} `json:"signtype"`
  5238. WarnMsg interface{} `json:"warn_msg"`
  5239. }
  5240. type ResultTwo struct {
  5241. ErrMsg string `json:"err_msg"`
  5242. InfRefmsgid string `json:"inf_refmsgid"`
  5243. Infcode int64 `json:"infcode"`
  5244. Output struct {
  5245. Baseinfo struct {
  5246. Age float64 `json:"age"`
  5247. Brdy string `json:"brdy"`
  5248. Certno string `json:"certno"`
  5249. Gend string `json:"gend"`
  5250. Naty string `json:"naty"`
  5251. PsnCertType string `json:"psn_cert_type"`
  5252. PsnName string `json:"psn_name"`
  5253. PsnNo string `json:"psn_no"`
  5254. } `json:"baseinfo"`
  5255. Idetinfo []interface{} `json:"idetinfo"`
  5256. Iinfo []struct {
  5257. Balc float64 `json:"balc"`
  5258. CvlservFlag string `json:"cvlserv_flag"`
  5259. EmpName string `json:"emp_name"`
  5260. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5261. Insutype string `json:"insutype"`
  5262. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5263. PausInsuDate string `json:"paus_insu_date"`
  5264. PsnInsuDate string `json:"psn_insu_date"`
  5265. PsnInsuStas string `json:"psn_insu_stas"`
  5266. PsnType string `json:"psn_type"`
  5267. } `json:"insuinfo"`
  5268. } `json:"output"`
  5269. RefmsgTime string `json:"refmsg_time"`
  5270. RespondTime string `json:"respond_time"`
  5271. Signtype interface{} `json:"signtype"`
  5272. WarnInfo interface{} `json:"warn_info"`
  5273. }
  5274. type ResultTwo10265 struct {
  5275. ErrMsg string `json:"err_msg"`
  5276. InfRefmsgid string `json:"inf_refmsgid"`
  5277. Infcode string `json:"infcode"`
  5278. Output struct {
  5279. Baseinfo struct {
  5280. Age float64 `json:"age"`
  5281. Brdy string `json:"brdy"`
  5282. Certno string `json:"certno"`
  5283. Gend string `json:"gend"`
  5284. Naty string `json:"naty"`
  5285. PsnCertType string `json:"psn_cert_type"`
  5286. PsnName string `json:"psn_name"`
  5287. PsnNo string `json:"psn_no"`
  5288. } `json:"baseinfo"`
  5289. Idetinfo []interface{} `json:"idetinfo"`
  5290. Iinfo []struct {
  5291. Balc float64 `json:"balc"`
  5292. CvlservFlag string `json:"cvlserv_flag"`
  5293. EmpName string `json:"emp_name"`
  5294. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5295. Insutype string `json:"insutype"`
  5296. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5297. PausInsuDate string `json:"paus_insu_date"`
  5298. PsnInsuDate string `json:"psn_insu_date"`
  5299. PsnInsuStas string `json:"psn_insu_stas"`
  5300. PsnType string `json:"psn_type"`
  5301. } `json:"insuinfo"`
  5302. } `json:"output"`
  5303. RefmsgTime string `json:"refmsg_time"`
  5304. RespondTime string `json:"respond_time"`
  5305. Signtype interface{} `json:"signtype"`
  5306. WarnInfo interface{} `json:"warn_info"`
  5307. }
  5308. type ResultThree struct {
  5309. Cainfo interface{} `json:"cainfo"`
  5310. ErrMsg string `json:"err_msg"`
  5311. InfRefmsgid string `json:"inf_refmsgid"`
  5312. Infcode int64 `json:"infcode"`
  5313. Output struct {
  5314. Data struct {
  5315. IptOtpNo string `json:"ipt_otp_no"`
  5316. MdtrtID string `json:"mdtrt_id"`
  5317. PsnNo string `json:"psn_no"`
  5318. } `json:"data"`
  5319. } `json:"output"`
  5320. RefmsgTime string `json:"refmsg_time"`
  5321. RespondTime string `json:"respond_time"`
  5322. Signtype interface{} `json:"signtype"`
  5323. WarnMsg interface{} `json:"warn_msg"`
  5324. }
  5325. type ResultThree10265 struct {
  5326. Cainfo interface{} `json:"cainfo"`
  5327. ErrMsg string `json:"err_msg"`
  5328. InfRefmsgid string `json:"inf_refmsgid"`
  5329. Infcode string `json:"infcode"`
  5330. Output struct {
  5331. Data struct {
  5332. IptOtpNo string `json:"ipt_otp_no"`
  5333. MdtrtID string `json:"mdtrt_id"`
  5334. PsnNo string `json:"psn_no"`
  5335. } `json:"data"`
  5336. } `json:"output"`
  5337. RefmsgTime string `json:"refmsg_time"`
  5338. RespondTime string `json:"respond_time"`
  5339. Signtype interface{} `json:"signtype"`
  5340. WarnMsg interface{} `json:"warn_msg"`
  5341. }
  5342. type ResultFour struct {
  5343. Cainfo string `json:"cainfo"`
  5344. ErrMsg string `json:"err_msg"`
  5345. InfRefmsgid string `json:"inf_refmsgid"`
  5346. Infcode int64 `json:"infcode"`
  5347. Output struct {
  5348. Result []struct {
  5349. BasMednFlag string `json:"bas_medn_flag"`
  5350. ChldMedcFlag string `json:"chld_medc_flag"`
  5351. ChrgitmLv string `json:"chrgitm_lv"`
  5352. Cnt float64 `json:"cnt"`
  5353. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5354. DrtReimFlag string `json:"drt_reim_flag"`
  5355. FeedetlSn string `json:"feedetl_sn"`
  5356. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5357. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5358. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5359. ListSpItemFlag string `json:"list_sp_item_flag"`
  5360. LmtUsedFlag string `json:"lmt_used_flag"`
  5361. MedChrgitmType string `json:"med_chrgitm_type"`
  5362. Memo string `json:"memo"`
  5363. OverlmtAmt float64 `json:"overlmt_amt"`
  5364. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5365. Pric float64 `json:"pric"`
  5366. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5367. SelfpayProp float64 `json:"selfpay_prop"`
  5368. } `json:"result"`
  5369. } `json:"output"`
  5370. RefmsgTime string `json:"refmsg_time"`
  5371. RespondTime string `json:"respond_time"`
  5372. Signtype string `json:"signtype"`
  5373. WarnMsg string `json:"warn_msg"`
  5374. }
  5375. type ResultFour10265 struct {
  5376. Cainfo string `json:"cainfo"`
  5377. ErrMsg string `json:"err_msg"`
  5378. InfRefmsgid string `json:"inf_refmsgid"`
  5379. Infcode string `json:"infcode"`
  5380. Output struct {
  5381. Result []struct {
  5382. BasMednFlag string `json:"bas_medn_flag"`
  5383. ChldMedcFlag string `json:"chld_medc_flag"`
  5384. ChrgitmLv string `json:"chrgitm_lv"`
  5385. Cnt float64 `json:"cnt"`
  5386. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5387. DrtReimFlag string `json:"drt_reim_flag"`
  5388. FeedetlSn string `json:"feedetl_sn"`
  5389. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5390. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5391. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5392. ListSpItemFlag string `json:"list_sp_item_flag"`
  5393. LmtUsedFlag string `json:"lmt_used_flag"`
  5394. MedChrgitmType string `json:"med_chrgitm_type"`
  5395. Memo string `json:"memo"`
  5396. OverlmtAmt float64 `json:"overlmt_amt"`
  5397. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5398. Pric float64 `json:"pric"`
  5399. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5400. SelfpayProp float64 `json:"selfpay_prop"`
  5401. } `json:"result"`
  5402. } `json:"output"`
  5403. RefmsgTime string `json:"refmsg_time"`
  5404. RespondTime string `json:"respond_time"`
  5405. Signtype string `json:"signtype"`
  5406. WarnMsg string `json:"warn_msg"`
  5407. }
  5408. type ResultFive struct {
  5409. Balc float64 `json:"balc"`
  5410. CvlservFlag string `json:"cvlserv_flag"`
  5411. EmpName string `json:"emp_name"`
  5412. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5413. Insutype string `json:"insutype"`
  5414. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5415. PausInsuDate string `json:"paus_insu_date"`
  5416. PsnInsuDate string `json:"psn_insu_date"`
  5417. PsnInsuStas string `json:"psn_insu_stas"`
  5418. PsnType string `json:"psn_type"`
  5419. }
  5420. type ResultSix struct {
  5421. Cainfo interface{} `json:"cainfo"`
  5422. ErrMsg string `json:"err_msg"`
  5423. InfRefmsgid string `json:"inf_refmsgid"`
  5424. Infcode int64 `json:"infcode"`
  5425. Output struct {
  5426. } `json:"output"`
  5427. RefmsgTime string `json:"refmsg_time"`
  5428. RespondTime string `json:"respond_time"`
  5429. Signtype interface{} `json:"signtype"`
  5430. WarnMsg interface{} `json:"warn_msg"`
  5431. }
  5432. type ResultSix10265 struct {
  5433. Cainfo interface{} `json:"cainfo"`
  5434. ErrMsg string `json:"err_msg"`
  5435. InfRefmsgid string `json:"inf_refmsgid"`
  5436. Infcode string `json:"infcode"`
  5437. Output struct {
  5438. } `json:"output"`
  5439. RefmsgTime string `json:"refmsg_time"`
  5440. RespondTime string `json:"respond_time"`
  5441. Signtype interface{} `json:"signtype"`
  5442. WarnMsg interface{} `json:"warn_msg"`
  5443. }
  5444. type ResultSeven struct {
  5445. Cainfo string `json:"cainfo"`
  5446. ErrMsg string `json:"err_msg"`
  5447. InfRefmsgid string `json:"inf_refmsgid"`
  5448. Infcode int64 `json:"infcode"`
  5449. Output struct {
  5450. Setldetail []interface{} `json:"setldetail"`
  5451. Setlinfo struct {
  5452. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5453. AcctPay float64 `json:"acct_pay"`
  5454. ActPayDedc float64 `json:"act_pay_dedc"`
  5455. Age float64 `json:"age"`
  5456. Balc float64 `json:"balc"`
  5457. Brdy string `json:"brdy"`
  5458. Certno string `json:"certno"`
  5459. ClrOptins string `json:"clr_optins"`
  5460. ClrType string `json:"clr_type"`
  5461. ClrWay string `json:"clr_way"`
  5462. CvlservFlag string `json:"cvlserv_flag"`
  5463. CvlservPay float64 `json:"cvlserv_pay"`
  5464. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5465. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5466. Gend string `json:"gend"`
  5467. HifesPay float64 `json:"hifes_pay"`
  5468. HifmiPay float64 `json:"hifmi_pay"`
  5469. HifpPay float64 `json:"hifp_pay"`
  5470. HospPartAmt float64 `json:"hosp_part_amt"`
  5471. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5472. Insutype string `json:"insutype"`
  5473. MafPay float64 `json:"maf_pay"`
  5474. MdtrtCertType string `json:"mdtrt_cert_type"`
  5475. HifobPay float64 `json:"hifob_pay"`
  5476. MdtrtID string `json:"mdtrt_id"`
  5477. MedType string `json:"med_type"`
  5478. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5479. MedinsSetlID string `json:"medins_setl_id"`
  5480. Naty string `json:"naty"`
  5481. OthPay float64 `json:"oth_pay"`
  5482. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5483. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5484. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5485. PsnCashPay float64 `json:"psn_cash_pay"`
  5486. PsnCertType string `json:"psn_cert_type"`
  5487. PsnName string `json:"psn_name"`
  5488. PsnNo string `json:"psn_no"`
  5489. PsnPartAmt float64 `json:"psn_part_amt"`
  5490. PsnType string `json:"psn_type"`
  5491. SetlID string `json:"setl_id"`
  5492. SetlTime string `json:"setl_time"`
  5493. } `json:"setlinfo"`
  5494. } `json:"output"`
  5495. RefmsgTime string `json:"refmsg_time"`
  5496. RespondTime string `json:"respond_time"`
  5497. Signtype interface{} `json:"signtype"`
  5498. WarnMsg interface{} `json:"warn_msg"`
  5499. }
  5500. type ResultSeven10265 struct {
  5501. Cainfo string `json:"cainfo"`
  5502. ErrMsg string `json:"err_msg"`
  5503. InfRefmsgid string `json:"inf_refmsgid"`
  5504. Infcode string `json:"infcode"`
  5505. Output struct {
  5506. Setldetail []interface{} `json:"setldetail"`
  5507. Setlinfo struct {
  5508. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5509. AcctPay float64 `json:"acct_pay"`
  5510. ActPayDedc float64 `json:"act_pay_dedc"`
  5511. Age float64 `json:"age"`
  5512. Balc float64 `json:"balc"`
  5513. Brdy string `json:"brdy"`
  5514. Certno string `json:"certno"`
  5515. ClrOptins string `json:"clr_optins"`
  5516. ClrType string `json:"clr_type"`
  5517. ClrWay string `json:"clr_way"`
  5518. CvlservFlag string `json:"cvlserv_flag"`
  5519. CvlservPay float64 `json:"cvlserv_pay"`
  5520. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5521. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5522. Gend string `json:"gend"`
  5523. HifesPay float64 `json:"hifes_pay"`
  5524. HifmiPay float64 `json:"hifmi_pay"`
  5525. HifpPay float64 `json:"hifp_pay"`
  5526. HospPartAmt float64 `json:"hosp_part_amt"`
  5527. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5528. Insutype string `json:"insutype"`
  5529. MafPay float64 `json:"maf_pay"`
  5530. MdtrtCertType string `json:"mdtrt_cert_type"`
  5531. HifobPay float64 `json:"hifob_pay"`
  5532. MdtrtID string `json:"mdtrt_id"`
  5533. MedType string `json:"med_type"`
  5534. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5535. MedinsSetlID string `json:"medins_setl_id"`
  5536. Naty string `json:"naty"`
  5537. OthPay float64 `json:"oth_pay"`
  5538. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5539. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5540. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5541. PsnCashPay float64 `json:"psn_cash_pay"`
  5542. PsnCertType string `json:"psn_cert_type"`
  5543. PsnName string `json:"psn_name"`
  5544. PsnNo string `json:"psn_no"`
  5545. PsnPartAmt float64 `json:"psn_part_amt"`
  5546. PsnType string `json:"psn_type"`
  5547. SetlID string `json:"setl_id"`
  5548. SetlTime string `json:"setl_time"`
  5549. } `json:"setlinfo"`
  5550. } `json:"output"`
  5551. RefmsgTime string `json:"refmsg_time"`
  5552. RespondTime string `json:"respond_time"`
  5553. Signtype interface{} `json:"signtype"`
  5554. WarnMsg interface{} `json:"warn_msg"`
  5555. }
  5556. type ResultEight struct {
  5557. Cainfo string `json:"cainfo"`
  5558. ErrMsg string `json:"err_msg"`
  5559. InfRefmsgid string `json:"inf_refmsgid"`
  5560. Infcode int64 `json:"infcode"`
  5561. Output struct {
  5562. Stmtinfo struct {
  5563. SetlOptins string `json:"setl_optins"`
  5564. StmtRslt string `json:"stmt_rslt"`
  5565. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5566. } `json:"stmtinfo"`
  5567. } `json:"output"`
  5568. RefmsgTime string `json:"refmsg_time"`
  5569. RespondTime string `json:"respond_time"`
  5570. Signtype interface{} `json:"signtype"`
  5571. WarnMsg interface{} `json:"warn_msg"`
  5572. }
  5573. type ResultEightFor10188 struct {
  5574. Cainfo string `json:"cainfo"`
  5575. ErrMsg string `json:"err_msg"`
  5576. InfRefmsgid string `json:"inf_refmsgid"`
  5577. Infcode string `json:"infcode"`
  5578. Output struct {
  5579. Stmtinfo struct {
  5580. SetlOptins string `json:"setl_optins"`
  5581. StmtRslt string `json:"stmt_rslt"`
  5582. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5583. } `json:"stmtinfo"`
  5584. } `json:"output"`
  5585. RefmsgTime string `json:"refmsg_time"`
  5586. RespondTime string `json:"respond_time"`
  5587. Signtype interface{} `json:"signtype"`
  5588. WarnMsg interface{} `json:"warn_msg"`
  5589. }
  5590. type ResultNine struct {
  5591. Cainfo string `json:"cainfo"`
  5592. ErrMsg string `json:"err_msg"`
  5593. InfRefmsgid string `json:"inf_refmsgid"`
  5594. Infcode int64 `json:"infcode"`
  5595. Output struct {
  5596. FileQuryNo string `json:"file_qury_no"`
  5597. } `json:"output"`
  5598. RefmsgTime string `json:"refmsg_time"`
  5599. RespondTime string `json:"respond_time"`
  5600. Signtype interface{} `json:"signtype"`
  5601. WarnMsg interface{} `json:"warn_msg"`
  5602. }
  5603. type ResultTen struct {
  5604. Cainfo string `json:"cainfo"`
  5605. ErrMsg string `json:"err_msg"`
  5606. InfRefmsgid string `json:"inf_refmsgid"`
  5607. Infcode int64 `json:"infcode"`
  5608. Output struct {
  5609. DldEndtime string `json:"dld_endtime"`
  5610. FileQuryNo string `json:"file_qury_no"`
  5611. Filename string `json:"filename"`
  5612. } `json:"output"`
  5613. RefmsgTime string `json:"refmsg_time"`
  5614. RespondTime string `json:"respond_time"`
  5615. Signtype interface{} `json:"signtype"`
  5616. WarnMsg interface{} `json:"warn_msg"`
  5617. }
  5618. //type Autogenerated struct {
  5619. // Output struct {
  5620. // Setlinfo struct {
  5621. // SetlTime string `json:"setl_time"`
  5622. // CvlservPay float64 `json:"cvlserv_pay"`
  5623. // Year string `json:"year"`
  5624. // MedType string `json:"med_type"`
  5625. // PsnPay float64 `json:"psn_pay"`
  5626. // OpterID string `json:"opter_id"`
  5627. // Begndate string `json:"begndate"`
  5628. // FlxempeFlag string `json:"flxempe_flag"`
  5629. // HifmiPay float64 `json:"hifmi_pay"`
  5630. // PsnNo string `json:"psn_no"`
  5631. // ActPayDedc float64 `json:"act_pay_dedc"`
  5632. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5633. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5634. // ClrWay string `json:"clr_way"`
  5635. // OthPay float64 `json:"oth_pay"`
  5636. // Gend string `json:"gend"`
  5637. // MdtrtID string `json:"mdtrt_id"`
  5638. // AcctPay float64 `json:"acct_pay"`
  5639. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5640. // Insutype string `json:"insutype"`
  5641. // Invono interface{} `json:"invono"`
  5642. // Enddate string `json:"enddate"`
  5643. // CashPayamt float64 `json:"cash_payamt"`
  5644. // PsnType string `json:"psn_type"`
  5645. // FixmedinsName string `json:"fixmedins_name"`
  5646. // HifpPay float64 `json:"hifp_pay"`
  5647. // NewFlag interface{} `json:"new_flag"`
  5648. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5649. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5650. // PayLoc string `json:"pay_loc"`
  5651. // ClrType string `json:"clr_type"`
  5652. // RefdSetlFlag string `json:"refd_setl_flag"`
  5653. // CvlservFlag string `json:"cvlserv_flag"`
  5654. // EmpName string `json:"emp_name"`
  5655. // Brdy string `json:"brdy"`
  5656. // Naty string `json:"naty"`
  5657. // Certno string `json:"certno"`
  5658. // DiseCode string `json:"dise_code"`
  5659. // FixmedinsCode string `json:"fixmedins_code"`
  5660. // DedcHospLv string `json:"dedc_hosp_lv"`
  5661. // OpterName string `json:"opter_name"`
  5662. // Balc float64 `json:"balc"`
  5663. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5664. // PsnCertType string `json:"psn_cert_type"`
  5665. // HifobPay float64 `json:"hifob_pay"`
  5666. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5667. // HifesPay float64 `json:"hifes_pay"`
  5668. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5669. // OptTime string `json:"opt_time"`
  5670. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5671. // SetlID string `json:"setl_id"`
  5672. // MafPay float64 `json:"maf_pay"`
  5673. // PsnName string `json:"psn_name"`
  5674. // InsuOptins interface{} `json:"insu_optins"`
  5675. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5676. // ClrOptins string `json:"clr_optins"`
  5677. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5678. // DiseName string `json:"dise_name"`
  5679. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5680. // Age float64 `json:"age"`
  5681. // DtrtCertType string `json:"dtrt_cert_type"`
  5682. // HospLv string `json:"hosp_lv"`
  5683. // } `json:"setlinfo"`
  5684. // Setldetail []struct {
  5685. // FundPayType string `json:"fund_pay_type"`
  5686. // FundPayamt float64 `json:"fund_payamt"`
  5687. // SetlProcInfo interface{} `json:"setl_proc_info"`
  5688. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  5689. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  5690. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  5691. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5692. // } `json:"setldetail"`
  5693. // } `json:"output"`
  5694. // Infcode int `json:"infcode"`
  5695. // WarnMsg interface{} `json:"warn_msg"`
  5696. // Cainfo interface{} `json:"cainfo"`
  5697. // ErrMsg interface{} `json:"err_msg"`
  5698. // RefmsgTime string `json:"refmsg_time"`
  5699. // Signtype interface{} `json:"signtype"`
  5700. // RespondTime string `json:"respond_time"`
  5701. // InfRefmsgid string `json:"inf_refmsgid"`
  5702. //}
  5703. type ResultEleven struct {
  5704. Cainfo string `json:"cainfo"`
  5705. ErrMsg string `json:"err_msg"`
  5706. InfRefmsgid string `json:"inf_refmsgid"`
  5707. Infcode int64 `json:"infcode"`
  5708. Output struct {
  5709. Setlinfo struct {
  5710. SetlTime string `json:"setl_time"`
  5711. CvlservPay float64 `json:"cvlserv_pay"`
  5712. Year string `json:"year"`
  5713. MedType string `json:"med_type"`
  5714. PsnPay float64 `json:"psn_pay"`
  5715. OpterID string `json:"opter_id"`
  5716. Begndate string `json:"begndate"`
  5717. FlxempeFlag string `json:"flxempe_flag"`
  5718. HifmiPay float64 `json:"hifmi_pay"`
  5719. PsnNo string `json:"psn_no"`
  5720. ActPayDedc float64 `json:"act_pay_dedc"`
  5721. MedinsSetlID interface{} `json:"medins_setl_id"`
  5722. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5723. ClrWay string `json:"clr_way"`
  5724. OthPay float64 `json:"oth_pay"`
  5725. Gend string `json:"gend"`
  5726. MdtrtID string `json:"mdtrt_id"`
  5727. AcctPay float64 `json:"acct_pay"`
  5728. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5729. Insutype string `json:"insutype"`
  5730. Invono interface{} `json:"invono"`
  5731. Enddate string `json:"enddate"`
  5732. CashPayamt float64 `json:"cash_payamt"`
  5733. PsnType string `json:"psn_type"`
  5734. FixmedinsName string `json:"fixmedins_name"`
  5735. HifpPay float64 `json:"hifp_pay"`
  5736. NewFlag interface{} `json:"new_flag"`
  5737. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5738. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5739. PayLoc string `json:"pay_loc"`
  5740. ClrType string `json:"clr_type"`
  5741. RefdSetlFlag string `json:"refd_setl_flag"`
  5742. CvlservFlag string `json:"cvlserv_flag"`
  5743. EmpName string `json:"emp_name"`
  5744. Brdy string `json:"brdy"`
  5745. Naty string `json:"naty"`
  5746. Certno string `json:"certno"`
  5747. DiseCode string `json:"dise_code"`
  5748. FixmedinsCode string `json:"fixmedins_code"`
  5749. DedcHospLv string `json:"dedc_hosp_lv"`
  5750. OpterName string `json:"opter_name"`
  5751. Balc float64 `json:"balc"`
  5752. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5753. PsnCertType string `json:"psn_cert_type"`
  5754. HifobPay float64 `json:"hifob_pay"`
  5755. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5756. HifesPay float64 `json:"hifes_pay"`
  5757. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5758. OptTime string `json:"opt_time"`
  5759. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5760. SetlID string `json:"setl_id"`
  5761. MafPay float64 `json:"maf_pay"`
  5762. PsnName string `json:"psn_name"`
  5763. InsuOptins interface{} `json:"insu_optins"`
  5764. PrefFundPay interface{} `json:"pref_fund_pay"`
  5765. ClrOptins string `json:"clr_optins"`
  5766. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5767. DiseName string `json:"dise_name"`
  5768. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5769. Age float64 `json:"age"`
  5770. DtrtCertType string `json:"dtrt_cert_type"`
  5771. HospLv string `json:"hosp_lv"`
  5772. PsnCashPay float64
  5773. } `json:"setlinfo"`
  5774. } `json:"output"`
  5775. RefmsgTime string `json:"refmsg_time"`
  5776. RespondTime string `json:"respond_time"`
  5777. Signtype interface{} `json:"signtype"`
  5778. WarnMsg interface{} `json:"warn_msg"`
  5779. }
  5780. type ResultEleven10265 struct {
  5781. Cainfo string `json:"cainfo"`
  5782. ErrMsg string `json:"err_msg"`
  5783. InfRefmsgid string `json:"inf_refmsgid"`
  5784. Infcode string `json:"infcode"`
  5785. Output struct {
  5786. Setlinfo struct {
  5787. SetlTime string `json:"setl_time"`
  5788. CvlservPay float64 `json:"cvlserv_pay"`
  5789. Year string `json:"year"`
  5790. MedType string `json:"med_type"`
  5791. PsnPay float64 `json:"psn_pay"`
  5792. OpterID string `json:"opter_id"`
  5793. Begndate string `json:"begndate"`
  5794. FlxempeFlag string `json:"flxempe_flag"`
  5795. HifmiPay float64 `json:"hifmi_pay"`
  5796. PsnNo string `json:"psn_no"`
  5797. ActPayDedc float64 `json:"act_pay_dedc"`
  5798. MedinsSetlID interface{} `json:"medins_setl_id"`
  5799. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5800. ClrWay string `json:"clr_way"`
  5801. OthPay float64 `json:"oth_pay"`
  5802. Gend string `json:"gend"`
  5803. MdtrtID string `json:"mdtrt_id"`
  5804. AcctPay float64 `json:"acct_pay"`
  5805. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5806. Insutype string `json:"insutype"`
  5807. Invono interface{} `json:"invono"`
  5808. Enddate string `json:"enddate"`
  5809. CashPayamt float64 `json:"cash_payamt"`
  5810. PsnType string `json:"psn_type"`
  5811. FixmedinsName string `json:"fixmedins_name"`
  5812. HifpPay float64 `json:"hifp_pay"`
  5813. NewFlag interface{} `json:"new_flag"`
  5814. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5815. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5816. PayLoc string `json:"pay_loc"`
  5817. ClrType string `json:"clr_type"`
  5818. RefdSetlFlag string `json:"refd_setl_flag"`
  5819. CvlservFlag string `json:"cvlserv_flag"`
  5820. EmpName string `json:"emp_name"`
  5821. Brdy string `json:"brdy"`
  5822. Naty string `json:"naty"`
  5823. Certno string `json:"certno"`
  5824. DiseCode string `json:"dise_code"`
  5825. FixmedinsCode string `json:"fixmedins_code"`
  5826. DedcHospLv string `json:"dedc_hosp_lv"`
  5827. OpterName string `json:"opter_name"`
  5828. Balc float64 `json:"balc"`
  5829. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5830. PsnCertType string `json:"psn_cert_type"`
  5831. HifobPay float64 `json:"hifob_pay"`
  5832. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5833. HifesPay float64 `json:"hifes_pay"`
  5834. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5835. OptTime string `json:"opt_time"`
  5836. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5837. SetlID string `json:"setl_id"`
  5838. MafPay float64 `json:"maf_pay"`
  5839. PsnName string `json:"psn_name"`
  5840. InsuOptins interface{} `json:"insu_optins"`
  5841. PrefFundPay interface{} `json:"pref_fund_pay"`
  5842. ClrOptins string `json:"clr_optins"`
  5843. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5844. DiseName string `json:"dise_name"`
  5845. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5846. Age float64 `json:"age"`
  5847. DtrtCertType string `json:"dtrt_cert_type"`
  5848. HospLv string `json:"hosp_lv"`
  5849. PsnCashPay float64
  5850. } `json:"setlinfo"`
  5851. } `json:"output"`
  5852. RefmsgTime string `json:"refmsg_time"`
  5853. RespondTime string `json:"respond_time"`
  5854. Signtype interface{} `json:"signtype"`
  5855. WarnMsg interface{} `json:"warn_msg"`
  5856. }
  5857. type ResultTwelve struct {
  5858. Cainfo string `json:"cainfo"`
  5859. ErrMsg string `json:"err_msg"`
  5860. InfRefmsgid string `json:"inf_refmsgid"`
  5861. Infcode int64 `json:"infcode"`
  5862. Output struct {
  5863. MdtrtId string `json:"mdtrt_id"`
  5864. ChrgBchno string `json:"chrg_bchno"`
  5865. PsnNo string `json:"psn_no"`
  5866. } `json:"output"`
  5867. RefmsgTime string `json:"refmsg_time"`
  5868. RespondTime string `json:"respond_time"`
  5869. Signtype interface{} `json:"signtype"`
  5870. WarnMsg interface{} `json:"warn_msg"`
  5871. }
  5872. type ResultThirteen struct {
  5873. ErrMsg string `json:"err_msg"`
  5874. InfRefmsgid string `json:"inf_refmsgid"`
  5875. Infcode int64 `json:"infcode"`
  5876. Output struct {
  5877. Result struct {
  5878. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  5879. } `json:"result"`
  5880. } `json:"output"`
  5881. RefmsgTime string `json:"refmsg_time"`
  5882. RespondTime string `json:"respond_time"`
  5883. Signtype interface{} `json:"signtype"`
  5884. WarnInfo interface{} `json:"warn_info"`
  5885. }
  5886. type ResultThirteen10265 struct {
  5887. ErrMsg string `json:"err_msg"`
  5888. InfRefmsgid string `json:"inf_refmsgid"`
  5889. Infcode string `json:"infcode"`
  5890. Output struct {
  5891. Result struct {
  5892. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  5893. } `json:"result"`
  5894. } `json:"output"`
  5895. RefmsgTime string `json:"refmsg_time"`
  5896. RespondTime string `json:"respond_time"`
  5897. Signtype interface{} `json:"signtype"`
  5898. WarnInfo interface{} `json:"warn_info"`
  5899. }
  5900. type ResultFourteen struct {
  5901. ErrMsg string `json:"err_msg"`
  5902. InfRefmsgid string `json:"inf_refmsgid"`
  5903. Infcode int64 `json:"infcode"`
  5904. Output struct {
  5905. } `json:"output"`
  5906. RefmsgTime string `json:"refmsg_time"`
  5907. RespondTime string `json:"respond_time"`
  5908. Signtype interface{} `json:"signtype"`
  5909. WarnInfo interface{} `json:"warn_info"`
  5910. }
  5911. type ResultFourteen10265 struct {
  5912. ErrMsg string `json:"err_msg"`
  5913. InfRefmsgid string `json:"inf_refmsgid"`
  5914. Infcode string `json:"infcode"`
  5915. Output struct {
  5916. } `json:"output"`
  5917. RefmsgTime string `json:"refmsg_time"`
  5918. RespondTime string `json:"respond_time"`
  5919. Signtype interface{} `json:"signtype"`
  5920. WarnInfo interface{} `json:"warn_info"`
  5921. }
  5922. type ResultSixteen struct {
  5923. Cainfo string `json:"cainfo"`
  5924. ErrMsg string `json:"err_msg"`
  5925. InfRefmsgid string `json:"inf_refmsgid"`
  5926. Infcode int64 `json:"infcode"`
  5927. Output struct {
  5928. Setldetail []interface{} `json:"setldetail"`
  5929. Setlinfo struct {
  5930. MdtrtID string `json:"mdtrt_id"`
  5931. SetlID string `json:"setl_id"`
  5932. ClrOptins string `json:"clr_optins"`
  5933. SetlTime string `json:"setl_time"`
  5934. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5935. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5936. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5937. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5938. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5939. ActPayDedc float64 `json:"act_pay_dedc"`
  5940. HifpPay float64 `json:"hifp_pay"`
  5941. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5942. Lfpay float64 `json:"selfpay"`
  5943. CvlservPay float64 `json:"cvlserv_pay"`
  5944. HifesPay float64 `json:"hifes_pay"`
  5945. HifmiPay float64 `json:"hifmi_pay"`
  5946. HifobPay float64 `json:"hifob_pay"`
  5947. MafPay float64 `json:"maf_pay"`
  5948. OthPay float64 `json:"oth_pay"`
  5949. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5950. PsnPartAmt float64 `json:"psn_part_amt"`
  5951. AcctPay float64 `json:"acct_pay"`
  5952. Balc float64 `json:"balc"`
  5953. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5954. HospPartAmt float64 `json:"hosp_part_amt"`
  5955. MedinsSetlID string `json:"medins_setl_id"`
  5956. PdnCashPay string `json:"pdn_cash_pay"`
  5957. } `json:"setlinfo"`
  5958. } `json:"output"`
  5959. RefmsgTime string `json:"refmsg_time"`
  5960. RespondTime string `json:"respond_time"`
  5961. Signtype interface{} `json:"signtype"`
  5962. WarnMsg interface{} `json:"warn_msg"`
  5963. }
  5964. type ResultSixteen10265 struct {
  5965. Cainfo string `json:"cainfo"`
  5966. ErrMsg string `json:"err_msg"`
  5967. InfRefmsgid string `json:"inf_refmsgid"`
  5968. Infcode string `json:"infcode"`
  5969. Output struct {
  5970. Setldetail []interface{} `json:"setldetail"`
  5971. Setlinfo struct {
  5972. MdtrtID string `json:"mdtrt_id"`
  5973. SetlID string `json:"setl_id"`
  5974. ClrOptins string `json:"clr_optins"`
  5975. SetlTime string `json:"setl_time"`
  5976. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5977. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5978. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5979. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5980. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5981. ActPayDedc float64 `json:"act_pay_dedc"`
  5982. HifpPay float64 `json:"hifp_pay"`
  5983. PoolPropSe float64 `json:"pool_prop_selfpay"`
  5984. Lfpay float64 `json:"selfpay"`
  5985. CvlservPay float64 `json:"cvlserv_pay"`
  5986. HifesPay float64 `json:"hifes_pay"`
  5987. HifmiPay float64 `json:"hifmi_pay"`
  5988. HifobPay float64 `json:"hifob_pay"`
  5989. MafPay float64 `json:"maf_pay"`
  5990. OthPay float64 `json:"oth_pay"`
  5991. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5992. PsnPartAmt float64 `json:"psn_part_amt"`
  5993. AcctPay float64 `json:"acct_pay"`
  5994. Balc float64 `json:"balc"`
  5995. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5996. HospPartAmt float64 `json:"hosp_part_amt"`
  5997. MedinsSetlID string `json:"medins_setl_id"`
  5998. PdnCashPay string `json:"pdn_cash_pay"`
  5999. } `json:"setlinfo"`
  6000. } `json:"output"`
  6001. RefmsgTime string `json:"refmsg_time"`
  6002. RespondTime string `json:"respond_time"`
  6003. Signtype interface{} `json:"signtype"`
  6004. WarnMsg interface{} `json:"warn_msg"`
  6005. }
  6006. type ResultSeventeen struct {
  6007. ErrMsg string `json:"err_msg"`
  6008. InfRefmsgid string `json:"inf_refmsgid"`
  6009. Infcode int64 `json:"infcode"`
  6010. Output struct {
  6011. SetlListId string `json:"setl_list_id"`
  6012. } `json:"output"`
  6013. RefmsgTime string `json:"refmsg_time"`
  6014. RespondTime string `json:"respond_time"`
  6015. Signtype string `json:"signtype"`
  6016. WarnInfo string `json:"warn_info"`
  6017. }
  6018. type ResultSeventeenOther struct {
  6019. ErrMsg string `json:"err_msg"`
  6020. InfRefmsgid string `json:"inf_refmsgid"`
  6021. Infcode string `json:"infcode"`
  6022. Output struct {
  6023. SetlListId string `json:"setl_list_id"`
  6024. } `json:"output"`
  6025. RefmsgTime string `json:"refmsg_time"`
  6026. RespondTime string `json:"respond_time"`
  6027. Signtype string `json:"signtype"`
  6028. WarnInfo string `json:"warn_info"`
  6029. }
  6030. type Result90991 struct {
  6031. ErrMsg string `json:"err_msg"`
  6032. InfRefmsgid string `json:"inf_refmsgid"`
  6033. Infcode int64 `json:"infcode"`
  6034. Output struct {
  6035. Result struct {
  6036. PsnNo string `json:"psn_no"`
  6037. CardStat string `json:"card_stat"`
  6038. Certno string `json:"certno"`
  6039. PsnName string `json:"psn_name"`
  6040. CheckStat string `json:"check_stat"`
  6041. SscnoCheckStat string `json:"sscno_check_stat"`
  6042. } `json:"result"`
  6043. } `json:"output"`
  6044. RefmsgTime string `json:"refmsg_time"`
  6045. RespondTime string `json:"respond_time"`
  6046. Signtype interface{} `json:"signtype"`
  6047. WarnInfo interface{} `json:"warn_info"`
  6048. }
  6049. type Result90100 struct {
  6050. ErrMsg string `json:"err_msg"`
  6051. InfRefmsgid string `json:"inf_refmsgid"`
  6052. Infcode int64 `json:"infcode"`
  6053. Output struct {
  6054. PoolareaNo string `json:"poolarea_no"`
  6055. PoolareaNoName string `json:"poolarea_no_name"`
  6056. Insutype string `json:"insutype"`
  6057. InsutypeName string `json:"insutype_name"`
  6058. ClctType string `json:"clct_type"`
  6059. ClctTypeName string `json:"clct_type_name"`
  6060. ClctFlag string `json:"clct_flag"`
  6061. ClctFlagName string `json:"clct_flag_name"`
  6062. AccrymBegn string `json:"accrym_begn"`
  6063. AccrymEnd string `json:"accrym_end"`
  6064. ClctTime string `json:"clct_time"`
  6065. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6066. } `json:"output"`
  6067. RefmsgTime string `json:"refmsg_time"`
  6068. RespondTime string `json:"respond_time"`
  6069. Signtype interface{} `json:"signtype"`
  6070. WarnInfo interface{} `json:"warn_info"`
  6071. }
  6072. type Custom struct {
  6073. DetItemFeeSumamt string
  6074. Cut string
  6075. FeedetlSn string
  6076. Price string
  6077. MedListCodg string
  6078. Type int64
  6079. AdviceId int64
  6080. ProjectId int64
  6081. ItemId int64
  6082. }
  6083. type Result5301 struct {
  6084. ErrMsg string `json:"err_msg"`
  6085. InfRefmsgid string `json:"inf_refmsgid"`
  6086. Infcode int64 `json:"infcode"`
  6087. Output struct {
  6088. Result []struct {
  6089. OpspDiseCode string `json:"opsp_dise_code"`
  6090. OpspDiseName string `json:"opsp_dise_name"`
  6091. Begndate string `json:"begndate"`
  6092. Enddate string `json:"enddate"`
  6093. } `json:"feedetail"`
  6094. } `json:"output"`
  6095. RefmsgTime string `json:"refmsg_time"`
  6096. RespondTime string `json:"respond_time"`
  6097. Signtype interface{} `json:"signtype"`
  6098. WarnInfo interface{} `json:"warn_info"`
  6099. }
  6100. type Result5301For10265 struct {
  6101. ErrMsg string `json:"err_msg"`
  6102. InfRefmsgid string `json:"inf_refmsgid"`
  6103. Infcode string `json:"infcode"`
  6104. Output struct {
  6105. Result []struct {
  6106. OpspDiseCode string `json:"opsp_dise_code"`
  6107. OpspDiseName string `json:"opsp_dise_name"`
  6108. Begndate string `json:"begndate"`
  6109. Enddate string `json:"enddate"`
  6110. } `json:"feedetail"`
  6111. } `json:"output"`
  6112. RefmsgTime string `json:"refmsg_time"`
  6113. RespondTime string `json:"respond_time"`
  6114. Signtype interface{} `json:"signtype"`
  6115. WarnInfo interface{} `json:"warn_info"`
  6116. }
  6117. //获取个人信息----挂号-----上传就诊信息
  6118. func (c *HisApiController) GetRegisterInfo() {
  6119. id, _ := c.GetInt64("id")
  6120. record_time := c.GetString("record_time")
  6121. settlementValue, _ := c.GetInt64("settlement_value")
  6122. medical_insurance_card := c.GetString("medical_insurance_card")
  6123. name := c.GetString("name")
  6124. id_card_type, _ := c.GetInt64("id_card_type")
  6125. certificates, _ := c.GetInt64("certificates")
  6126. medical_care, _ := c.GetInt64("medical_care")
  6127. birthday := c.GetString("birthday")
  6128. id_card := c.GetString("id_card")
  6129. register_type, _ := c.GetInt64("register")
  6130. doctor, _ := c.GetInt64("doctor")
  6131. department, _ := c.GetInt64("department")
  6132. gender, _ := c.GetInt64("sex")
  6133. registration_fee, _ := c.GetFloat("registration_fee")
  6134. medical_expenses, _ := c.GetFloat("medical_expenses")
  6135. social_type, _ := c.GetInt64("social_type")
  6136. med_type := c.GetString("social_type")
  6137. admin_user_id, _ := c.GetInt64("admin_user_id")
  6138. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6139. timeLayout := "2006-01-02"
  6140. loc, _ := time.LoadLocation("Local")
  6141. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6142. birthUnix := birthdays.Unix()
  6143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6144. if err != nil {
  6145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6146. return
  6147. }
  6148. recordDateTime := theTime.Unix()
  6149. adminInfo := c.GetAdminUserInfo()
  6150. var patient service.Patients
  6151. if id == 0 {
  6152. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6153. } else {
  6154. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6155. }
  6156. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6157. if patientPrescription.ID == 0 {
  6158. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6159. }
  6160. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6161. if patient.ID == 0 {
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6163. return
  6164. }
  6165. if len(patient.IdCardNo) == 0 {
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6167. return
  6168. }
  6169. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6170. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6171. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6172. //就诊结算未完成,不能进行二次挂号
  6173. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6174. if len(his) >= 1 {
  6175. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6176. if len(his) >= 1 && order.ID == 0 {
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6178. return
  6179. }
  6180. }
  6181. //var register_log string
  6182. if config.IsOpen == 1 {
  6183. var res ResultTwo
  6184. var res10265 ResultTwo10265
  6185. var PsnNo string
  6186. var PsnCertType string
  6187. var Certno string
  6188. var PsnName string
  6189. var Gend string
  6190. var Naty string
  6191. var Brdy string
  6192. var Age float64
  6193. var infoStr string
  6194. var idetinfoStr string
  6195. var infocode int64
  6196. var verify_number string
  6197. fmt.Println(verify_number)
  6198. if miConfig.MdtrtareaAdmvs == "421300" {
  6199. psn_info, _ := service.GetPsnByPatientId(id)
  6200. PsnNo = psn_info.PsnNo
  6201. PsnCertType = psn_info.PsnCertType
  6202. Certno = psn_info.Certno
  6203. PsnName = psn_info.PsnName
  6204. Gend = psn_info.Gend
  6205. Naty = psn_info.Naty
  6206. Brdy = psn_info.Brdy
  6207. Age = psn_info.Age
  6208. infoStr = psn_info.Insuinfo
  6209. idetinfoStr = psn_info.Idetinfo
  6210. infocode = 0
  6211. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6212. psn_info, _ := service.GetPsnByPatientId(id)
  6213. PsnNo = psn_info.PsnNo
  6214. PsnCertType = psn_info.PsnCertType
  6215. Certno = psn_info.Certno
  6216. PsnName = psn_info.PsnName
  6217. Gend = psn_info.Gend
  6218. Naty = psn_info.Naty
  6219. Brdy = psn_info.Brdy
  6220. Age = psn_info.Age
  6221. infoStr = psn_info.Insuinfo
  6222. idetinfoStr = psn_info.Idetinfo
  6223. infocode = 0
  6224. verify_number = psn_info.VerifyNumber
  6225. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6226. if id_card_type == 1 {
  6227. psn_info, _ := service.GetPsnByPatientId(id)
  6228. PsnNo = psn_info.PsnNo
  6229. PsnCertType = psn_info.PsnCertType
  6230. Certno = psn_info.Certno
  6231. PsnName = psn_info.PsnName
  6232. Gend = psn_info.Gend
  6233. Naty = psn_info.Naty
  6234. Brdy = psn_info.Brdy
  6235. Age = psn_info.Age
  6236. infoStr = psn_info.Insuinfo
  6237. idetinfoStr = psn_info.Idetinfo
  6238. infocode = 0
  6239. verify_number = psn_info.VerifyNumber
  6240. } else if id_card_type == 2 {
  6241. 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)
  6242. fmt.Println(errMsgLog)
  6243. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6245. utils.ErrorLog("解析失败:%v", err)
  6246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6247. return
  6248. }
  6249. PsnNo = res.Output.Baseinfo.PsnNo
  6250. PsnCertType = res.Output.Baseinfo.PsnCertType
  6251. Certno = res.Output.Baseinfo.Certno
  6252. PsnName = res.Output.Baseinfo.PsnName
  6253. Gend = res.Output.Baseinfo.Gend
  6254. Naty = res.Output.Baseinfo.Naty
  6255. Brdy = res.Output.Baseinfo.Brdy
  6256. Age = res.Output.Baseinfo.Age
  6257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6259. infoStr = string(Iinfos)
  6260. idetinfoStr = string(Idetinfos)
  6261. infocode = res.Infcode
  6262. }
  6263. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6264. if id_card_type == 1 {
  6265. psn_info, _ := service.GetPsnByPatientId(id)
  6266. PsnNo = psn_info.PsnNo
  6267. PsnCertType = psn_info.PsnCertType
  6268. Certno = psn_info.Certno
  6269. PsnName = psn_info.PsnName
  6270. Gend = psn_info.Gend
  6271. Naty = psn_info.Naty
  6272. Brdy = psn_info.Brdy
  6273. Age = psn_info.Age
  6274. infoStr = psn_info.Insuinfo
  6275. idetinfoStr = psn_info.Idetinfo
  6276. infocode = 0
  6277. verify_number = psn_info.VerifyNumber
  6278. } else if id_card_type == 2 {
  6279. 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, "")
  6280. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6281. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6282. utils.ErrorLog("解析失败:%v", err)
  6283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. return
  6285. }
  6286. PsnNo = res.Output.Baseinfo.PsnNo
  6287. PsnCertType = res.Output.Baseinfo.PsnCertType
  6288. Certno = res.Output.Baseinfo.Certno
  6289. PsnName = res.Output.Baseinfo.PsnName
  6290. Gend = res.Output.Baseinfo.Gend
  6291. Naty = res.Output.Baseinfo.Naty
  6292. Brdy = res.Output.Baseinfo.Brdy
  6293. Age = res.Output.Baseinfo.Age
  6294. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6295. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6296. infoStr = string(Iinfos)
  6297. idetinfoStr = string(Idetinfos)
  6298. infocode = res.Infcode
  6299. }
  6300. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6301. if id_card_type == 1 {
  6302. psn_info, _ := service.GetPsnByPatientId(id)
  6303. PsnNo = psn_info.PsnNo
  6304. PsnCertType = psn_info.PsnCertType
  6305. Certno = psn_info.Certno
  6306. PsnName = psn_info.PsnName
  6307. Gend = psn_info.Gend
  6308. Naty = psn_info.Naty
  6309. Brdy = psn_info.Brdy
  6310. Age = psn_info.Age
  6311. infoStr = psn_info.Insuinfo
  6312. idetinfoStr = psn_info.Idetinfo
  6313. infocode = 0
  6314. verify_number = psn_info.VerifyNumber
  6315. } else if id_card_type == 2 {
  6316. 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, "")
  6317. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. PsnNo = res.Output.Baseinfo.PsnNo
  6324. PsnCertType = res.Output.Baseinfo.PsnCertType
  6325. Certno = res.Output.Baseinfo.Certno
  6326. PsnName = res.Output.Baseinfo.PsnName
  6327. Gend = res.Output.Baseinfo.Gend
  6328. Naty = res.Output.Baseinfo.Naty
  6329. Brdy = res.Output.Baseinfo.Brdy
  6330. Age = res.Output.Baseinfo.Age
  6331. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6332. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6333. infoStr = string(Iinfos)
  6334. idetinfoStr = string(Idetinfos)
  6335. infocode = res.Infcode
  6336. }
  6337. } else {
  6338. var result string
  6339. var requestLog string
  6340. if miConfig.UserOrgId == 10138 {
  6341. if id_card_type != 4 {
  6342. //psn_info, _ := service.GetPsnByPatientId(id)
  6343. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6344. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6345. }
  6346. } else {
  6347. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6348. }
  6349. if id_card_type == 4 {
  6350. psn_info, _ := service.GetPsnByPatientId(id)
  6351. PsnNo = psn_info.PsnNo
  6352. PsnCertType = psn_info.PsnCertType
  6353. Certno = psn_info.Certno
  6354. PsnName = psn_info.PsnName
  6355. Gend = psn_info.Gend
  6356. Naty = psn_info.Naty
  6357. Brdy = psn_info.Brdy
  6358. Age = psn_info.Age
  6359. infoStr = psn_info.Insuinfo
  6360. idetinfoStr = psn_info.Idetinfo
  6361. infocode = 0
  6362. verify_number = psn_info.VerifyNumber
  6363. } else {
  6364. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6365. if miConfig.Code == "H15049901371" {
  6366. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6367. utils.ErrorLog("解析失败:%v", err)
  6368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6369. return
  6370. }
  6371. res.ErrMsg = res10265.ErrMsg
  6372. res.Output = res10265.Output
  6373. res.InfRefmsgid = res10265.InfRefmsgid
  6374. } else {
  6375. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6376. utils.ErrorLog("解析失败:%v", err)
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. return
  6379. }
  6380. }
  6381. PsnNo = res.Output.Baseinfo.PsnNo
  6382. PsnCertType = res.Output.Baseinfo.PsnCertType
  6383. Certno = res.Output.Baseinfo.Certno
  6384. PsnName = res.Output.Baseinfo.PsnName
  6385. Gend = res.Output.Baseinfo.Gend
  6386. Naty = res.Output.Baseinfo.Naty
  6387. Brdy = res.Output.Baseinfo.Brdy
  6388. Age = res.Output.Baseinfo.Age
  6389. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6390. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6391. infoStr = string(Iinfos)
  6392. idetinfoStr = string(Idetinfos)
  6393. if miConfig.Code == "H15049901371" {
  6394. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6395. } else {
  6396. infocode = res.Infcode
  6397. }
  6398. }
  6399. }
  6400. if infocode == 0 {
  6401. his := models.VMHisPatient{
  6402. Name: name,
  6403. Gender: gender,
  6404. Birthday: birthUnix,
  6405. MedicalTreatmentType: medical_care,
  6406. IdType: certificates,
  6407. IdCardNo: id_card,
  6408. BalanceAccountsType: settlementValue,
  6409. SocialType: social_type,
  6410. MedicalInsuranceNumber: medical_insurance_card,
  6411. RegisterType: register_type,
  6412. RegisterCost: registration_fee,
  6413. TreatmentCost: medical_expenses,
  6414. Status: 1,
  6415. Ctime: time.Now().Unix(),
  6416. Mtime: time.Now().Unix(),
  6417. PsnNo: PsnNo,
  6418. PsnCertType: PsnCertType,
  6419. Certno: Certno,
  6420. PsnName: PsnName,
  6421. Gend: Gend,
  6422. Naty: Naty,
  6423. Brdy: Brdy,
  6424. Age: Age,
  6425. Iinfo: infoStr,
  6426. Idetinfo: idetinfoStr,
  6427. PatientId: patient.ID,
  6428. RecordDate: theTime.Unix(),
  6429. UserOrgId: adminInfo.CurrentOrgId,
  6430. AdminUserId: admin_user_id,
  6431. IsReturn: 1,
  6432. IdCardType: id_card_type,
  6433. Doctor: doctor,
  6434. Departments: department,
  6435. }
  6436. timestamp := time.Now().Unix()
  6437. tempTime := time.Unix(timestamp, 0)
  6438. timeFormat := tempTime.Format("20060102150405")
  6439. chrgBchno := rand.Intn(100000) + 10000
  6440. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6441. his.Number = ipt_otp_no
  6442. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6443. department, _ := service.GetDepartMentDetail(department)
  6444. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6445. IdCardNo := ""
  6446. if id_card_type == 1 {
  6447. // IdCardNo = medical_insurance_card
  6448. IdCardNo = patient.IdCardNo
  6449. } else {
  6450. IdCardNo = patient.IdCardNo
  6451. }
  6452. var rf []*ResultFive
  6453. json.Unmarshal([]byte(his.Iinfo), &rf)
  6454. var insutypes []*ResultFive
  6455. var insutype string
  6456. var insuplc_admdvs_temp string
  6457. var is390 int = 0
  6458. var is310 int = 0
  6459. for _, item := range rf {
  6460. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6461. insutypes = append(insutypes, item)
  6462. }
  6463. }
  6464. if len(insutypes) == 1 {
  6465. insutype = insutypes[0].Insutype
  6466. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6467. } else {
  6468. for _, i := range insutypes {
  6469. if i.Insutype == "390" {
  6470. is390 = 1
  6471. }
  6472. if i.Insutype == "310" {
  6473. is310 = 1
  6474. }
  6475. }
  6476. }
  6477. if is390 == 1 {
  6478. insutype = "390"
  6479. }
  6480. if is310 == 1 {
  6481. insutype = "310"
  6482. }
  6483. if len(insutypes) == 0 {
  6484. insutype = "310"
  6485. }
  6486. if len(insutypes) == 2 {
  6487. insutype = med_type
  6488. }
  6489. if len(med_type) > 0 {
  6490. insutype = med_type
  6491. }
  6492. var infocode int64
  6493. var resThree ResultThree
  6494. var resThree10265 ResultThree10265
  6495. if len(insuplc_admdvs) == 0 {
  6496. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6497. } else {
  6498. insuplc_admdvs_temp = insuplc_admdvs
  6499. }
  6500. if miConfig.MdtrtareaAdmvs == "421300" {
  6501. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6502. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6503. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6504. "&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
  6505. resp, requestErr := http.Get(api)
  6506. if requestErr != nil {
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. return
  6509. }
  6510. body, ioErr := ioutil.ReadAll(resp.Body)
  6511. if ioErr != nil {
  6512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. return
  6515. }
  6516. var respJSON map[string]interface{}
  6517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6523. result, _ := json.Marshal(respJSON)
  6524. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6525. utils.ErrorLog("解析失败:%v", err)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. return
  6528. }
  6529. infocode = resThree.Infcode
  6530. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6531. psn_info, _ := service.GetPsnByPatientId(id)
  6532. his.PsnNo = psn_info.PsnNo
  6533. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6534. var cert_no string
  6535. if id_card_type == 3 {
  6536. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6537. cert_no = IdCardNo
  6538. } else if id_card_type == 4 {
  6539. cert_no = IdCardNo
  6540. psn_info.VerifyNumber = psn_info.VerifyNumber
  6541. } else {
  6542. bas := strings.Split(psn_info.CardInfo, "|")
  6543. cert_no = bas[2]
  6544. }
  6545. var hisPrescription []*models.HisPrescription
  6546. for _, item := range rf {
  6547. if item.Insutype == insutype {
  6548. //insuplc_admdvs = item.InsuplcAdmdvs
  6549. his.InsuplcAdmdvs = insuplc_admdvs
  6550. }
  6551. }
  6552. his.Insutype = insutype
  6553. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6554. fmt.Println(res3101)
  6555. fmt.Println(res3101.Infcode)
  6556. if res3101.Infcode == "0" {
  6557. fmt.Println("33333333")
  6558. if len(res3101.Output.Result) > 0 {
  6559. fmt.Println("222222")
  6560. for _, item := range res3101.Output.Result {
  6561. if len(res3101.ErrMsg) == 0 {
  6562. res3101.ErrMsg = item.VolaCont
  6563. } else {
  6564. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6565. }
  6566. }
  6567. c.ServeSuccessJSON(map[string]interface{}{
  6568. "failed_code": -10,
  6569. "msg": res3101.ErrMsg,
  6570. })
  6571. return
  6572. } else {
  6573. fmt.Println("11111")
  6574. var api string
  6575. if miConfig.MdtrtareaAdmvs == "320921" {
  6576. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6577. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6578. "&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
  6579. } else {
  6580. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6581. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6582. "&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
  6583. }
  6584. resp, requestErr := http.Get(api)
  6585. if requestErr != nil {
  6586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6587. return
  6588. }
  6589. body, ioErr := ioutil.ReadAll(resp.Body)
  6590. if ioErr != nil {
  6591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6593. return
  6594. }
  6595. var respJSON map[string]interface{}
  6596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6599. return
  6600. }
  6601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6602. result, _ := json.Marshal(respJSON)
  6603. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6604. utils.ErrorLog("解析失败:%v", err)
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. return
  6607. }
  6608. resThree.ErrMsg = resThree10265.ErrMsg
  6609. resThree.Output = resThree10265.Output
  6610. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6611. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6612. }
  6613. } else if res3101.Infcode != "0" {
  6614. c.ServeSuccessJSON(map[string]interface{}{
  6615. "failed_code": -10,
  6616. "msg": res3101.ErrMsg,
  6617. })
  6618. return
  6619. }
  6620. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6621. psn_info, _ := service.GetPsnByPatientId(id)
  6622. var cert_no string
  6623. if id_card_type == 1 {
  6624. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6625. } else if id_card_type == 4 {
  6626. cert_no = psn_info.VerifyNumber
  6627. } else {
  6628. cert_no = psn_info.VerifyNumber
  6629. }
  6630. 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)
  6631. saveLog(result, requestLog, "2201", "挂号")
  6632. if miConfig.Code == "H15049901371" {
  6633. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6634. utils.ErrorLog("解析失败:%v", err)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. return
  6637. }
  6638. resThree.ErrMsg = resThree10265.ErrMsg
  6639. resThree.Output = resThree10265.Output
  6640. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6641. } else {
  6642. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6643. utils.ErrorLog("解析失败:%v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. }
  6648. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6649. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  6650. psn_info, _ := service.GetPsnByPatientId(id)
  6651. var result string
  6652. var requestLog string
  6653. if id_card_type == 1 {
  6654. bas := strings.Split(psn_info.CardInfo, "|")
  6655. basNumber := bas[2]
  6656. card_sn := bas[3]
  6657. 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)
  6658. saveLog(result, requestLog, "2201A", "挂号")
  6659. } else if id_card_type == 2 {
  6660. 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, "", "")
  6661. saveLog(result, requestLog, "2201A", "挂号")
  6662. } else {
  6663. 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, "", "")
  6664. saveLog(result, requestLog, "2201A", "挂号")
  6665. }
  6666. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6667. utils.ErrorLog("解析失败:%v", err)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return
  6670. }
  6671. infocode = resThree.Infcode
  6672. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  6673. psn_info, _ := service.GetPsnByPatientId(id)
  6674. var result string
  6675. var requestLog string
  6676. if id_card_type == 1 {
  6677. bas := strings.Split(psn_info.CardInfo, "|")
  6678. basNumber := bas[2]
  6679. card_sn := bas[3]
  6680. 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)
  6681. saveLog(result, requestLog, "2201A", "挂号")
  6682. } else if id_card_type == 2 {
  6683. 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, "", "")
  6684. saveLog(result, requestLog, "2201A", "挂号")
  6685. } else {
  6686. 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, "", "")
  6687. saveLog(result, requestLog, "2201A", "挂号")
  6688. }
  6689. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6690. utils.ErrorLog("解析失败:%v", err)
  6691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6692. return
  6693. }
  6694. infocode = resThree.Infcode
  6695. } else {
  6696. psn_info, _ := service.GetPsnByPatientId(id)
  6697. 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)
  6698. saveLog(result, requestLog, "2201A", "挂号")
  6699. if miConfig.Code == "H15049901371" {
  6700. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6701. utils.ErrorLog("解析失败:%v", err)
  6702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6703. return
  6704. }
  6705. resThree.ErrMsg = resThree10265.ErrMsg
  6706. resThree.Output = resThree10265.Output
  6707. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6708. } else {
  6709. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6710. utils.ErrorLog("解析失败:%v", err)
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. return
  6713. }
  6714. }
  6715. if miConfig.Code == "H15049901371" {
  6716. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6717. } else {
  6718. infocode = resThree.Infcode
  6719. }
  6720. }
  6721. if infocode != 0 {
  6722. adminUser := c.GetAdminUserInfo()
  6723. errlog := &models.HisOrderError{
  6724. UserOrgId: adminUser.CurrentOrgId,
  6725. Ctime: time.Now().Unix(),
  6726. Mtime: time.Now().Unix(),
  6727. ErrMsg: resThree.ErrMsg,
  6728. Status: 1,
  6729. PatientId: id,
  6730. RecordTime: recordDateTime,
  6731. Stage: 2,
  6732. }
  6733. service.CreateErrMsgLog(errlog)
  6734. c.ServeSuccessJSON(map[string]interface{}{
  6735. "failed_code": -10,
  6736. "msg": resThree.ErrMsg,
  6737. })
  6738. return
  6739. }
  6740. his.Number = resThree.Output.Data.MdtrtID
  6741. his.PsnNo = resThree.Output.Data.PsnNo
  6742. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  6743. his.IdCardNo = patient.IdCardNo
  6744. his.PhoneNumber = patient.Phone
  6745. his.UserOrgId = adminInfo.CurrentOrgId
  6746. his.Insutype = insutype
  6747. his.Ctime = time.Now().Unix()
  6748. his.Mtime = time.Now().Unix()
  6749. his.InsuplcAdmdvs = insuplc_admdvs_temp
  6750. his.Status = 1
  6751. service.UpdateHisPatientStatus(&his)
  6752. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  6753. c.ServeSuccessJSON(map[string]interface{}{
  6754. "his_info": his,
  6755. })
  6756. } else {
  6757. adminUser := c.GetAdminUserInfo()
  6758. errlog := &models.HisOrderError{
  6759. UserOrgId: adminUser.CurrentOrgId,
  6760. Ctime: time.Now().Unix(),
  6761. Mtime: time.Now().Unix(),
  6762. ErrMsg: res.ErrMsg,
  6763. Status: 1,
  6764. PatientId: id,
  6765. RecordTime: recordDateTime,
  6766. Stage: 1,
  6767. }
  6768. service.CreateErrMsgLog(errlog)
  6769. c.ServeSuccessJSON(map[string]interface{}{
  6770. "failed_code": -10,
  6771. "msg": res.ErrMsg,
  6772. })
  6773. return
  6774. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6775. }
  6776. }
  6777. }
  6778. //上传明细----预结算----确认订单
  6779. func (c *HisApiController) GetUploadInfo() {
  6780. id, _ := c.GetInt64("id")
  6781. record_time := c.GetString("record_time")
  6782. his_patient_id, _ := c.GetInt64("his_patient_id")
  6783. order_id, _ := c.GetInt64("order_id")
  6784. pay_way, _ := c.GetInt64("pay_way")
  6785. pay_price, _ := c.GetFloat("pay_price")
  6786. pay_card_no := c.GetString("pay_card_no")
  6787. discount_price, _ := c.GetFloat("discount_price")
  6788. preferential_price, _ := c.GetFloat("preferential_price")
  6789. reality_price, _ := c.GetFloat("reality_price")
  6790. found_price, _ := c.GetFloat("found_price")
  6791. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6792. private_price, _ := c.GetFloat("private_price")
  6793. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6794. admin_user_id, _ := c.GetInt64("admin_user_id")
  6795. fapiao_code := c.GetString("fapiao_code")
  6796. fapiao_number := c.GetString("fapiao_number")
  6797. diagnosis_id := c.GetString("diagnosis")
  6798. sick_type, _ := c.GetInt64("sick_type")
  6799. reg_type, _ := c.GetInt64("p_type")
  6800. begin_time := c.GetString("begin_time")
  6801. id_str := c.GetString("ids")
  6802. ids_arr := strings.Split(id_str, ",")
  6803. timeLayout := "2006-01-02"
  6804. loc, _ := time.LoadLocation("Local")
  6805. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6806. if err != nil {
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6808. return
  6809. }
  6810. recordDateTime := theTime.Unix()
  6811. adminUser := c.GetAdminUserInfo()
  6812. var tempOrder models.HisOrder
  6813. tempOrder, _ = service.GetHisOrderByID(order_id)
  6814. var prescriptions []*models.HisPrescription
  6815. var start_time int64
  6816. var end_time int64
  6817. //押金模块
  6818. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  6819. tmp_decimal := c.GetString("tmp_decimal")
  6820. var decimal float64 //本次使用的押金
  6821. var errmsg error
  6822. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  6823. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  6824. return
  6825. }
  6826. if len(tmp_decimal) > 0 {
  6827. if tmp_decimal[0] == 45 {
  6828. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  6829. return
  6830. }
  6831. }
  6832. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  6833. fmt.Println(errs)
  6834. decimal = tt
  6835. //if adminUser.CurrentOrgId == 10106{
  6836. // if len(fapiao_code) == 0{
  6837. // fapiao_code = "144072080589"
  6838. // }
  6839. // if len(fapiao_number) == 0{
  6840. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  6841. // if order.ID == 0{
  6842. // fapiao_number = "00001520"
  6843. // }else{
  6844. // //fapiao_code = "00001520"
  6845. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  6846. // var zero string
  6847. // if fpNumber >= 1000{
  6848. // zero = "0000" + strconv.Itoa(fpNumber)
  6849. // }else if fpNumber >= 10000{
  6850. // zero = "000" + strconv.Itoa(fpNumber)
  6851. // } else if fpNumber >= 100000{
  6852. // zero = "00" + strconv.Itoa(fpNumber)
  6853. // } else if fpNumber >= 1000000{
  6854. // zero = "0" + strconv.Itoa(fpNumber)
  6855. // }else {
  6856. // zero = strconv.Itoa(fpNumber)
  6857. // }
  6858. // fapiao_number = zero
  6859. // }
  6860. // }
  6861. //}
  6862. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6863. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6864. var patientPrescription models.HisPrescriptionInfo
  6865. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6866. if patientPrescription.ID == 0 {
  6867. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6868. }
  6869. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6870. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6871. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6872. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6873. var config []*models.HisXtDiagnoseConfig
  6874. for _, item := range diagnosis_ids {
  6875. id, _ := strconv.ParseInt(item, 10, 64)
  6876. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6877. config = append(config, &diagnosisConfig)
  6878. }
  6879. sickConfig, _ := service.FindSickById(sick_type)
  6880. //if tempOrder.ID == 0 {
  6881. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  6882. //}
  6883. if tempOrder.ID == 0 {
  6884. var result string
  6885. var requestLog string
  6886. var res2 ResultSix
  6887. var ressix10265 ResultSix10265
  6888. if miConfig.MdtrtareaAdmvs == "421300" {
  6889. data := make(map[string]interface{})
  6890. client := &http.Client{}
  6891. data["psn_no"] = his.PsnNo
  6892. data["mdtrt_id"] = his.Number
  6893. data["opter"] = roles.UserName
  6894. data["org_name"] = miConfig.OrgName
  6895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6896. data["doctor_id"] = doctor_info.DoctorNumber
  6897. data["doctor_name"] = doctor_info.UserName
  6898. data["department"] = department.Name
  6899. data["fixmedins_code"] = miConfig.Code
  6900. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6901. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6902. data["secret_key"] = miConfig.SecretKey
  6903. data["sick_code"] = sickConfig.CountryCode
  6904. data["sick_name"] = sickConfig.ClassName
  6905. data["dept"] = strconv.FormatInt(department.ID, 10)
  6906. data["config"] = config
  6907. data["begin_time"] = begin_time
  6908. bytesData, _ := json.Marshal(data)
  6909. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6910. resp, _ := client.Do(req)
  6911. defer resp.Body.Close()
  6912. body, ioErr := ioutil.ReadAll(resp.Body)
  6913. if ioErr != nil {
  6914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. var respJSON map[string]interface{}
  6919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6925. userJSONBytes, _ := json.Marshal(respJSON)
  6926. fmt.Println("log")
  6927. fmt.Println(string(userJSONBytes))
  6928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6929. utils.ErrorLog("解析失败:%v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return
  6932. }
  6933. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6934. data := make(map[string]interface{})
  6935. client := &http.Client{}
  6936. data["psn_no"] = his.PsnNo
  6937. data["mdtrt_id"] = his.Number
  6938. data["doctor"] = roles.UserName
  6939. data["department"] = department.Name
  6940. data["org_name"] = miConfig.OrgName
  6941. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6942. data["doctor_id"] = doctor_info.DoctorNumber
  6943. data["new_doctor_name"] = doctor_info.UserName
  6944. data["fixmedins_code"] = miConfig.Code
  6945. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6947. data["secret_key"] = miConfig.SecretKey
  6948. data["sick_code"] = sickConfig.CountryCode
  6949. data["sick_name"] = sickConfig.ClassName
  6950. data["url"] = miConfig.Url
  6951. data["ak"] = miConfig.AccessKey
  6952. data["begin_time"] = begin_time
  6953. data["cainfo"] = miConfig.Cainfo
  6954. data["dept"] = strconv.FormatInt(department.ID, 10)
  6955. data["config"] = config
  6956. bytesData, _ := json.Marshal(data)
  6957. var req *http.Request
  6958. if miConfig.MdtrtareaAdmvs == "320921" {
  6959. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6960. //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 +
  6961. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6962. } else {
  6963. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6964. }
  6965. resp, _ := client.Do(req)
  6966. defer resp.Body.Close()
  6967. body, ioErr := ioutil.ReadAll(resp.Body)
  6968. if ioErr != nil {
  6969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. return
  6972. }
  6973. var respJSON map[string]interface{}
  6974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6980. userJSONBytes, _ := json.Marshal(respJSON)
  6981. fmt.Println("log")
  6982. fmt.Println(string(userJSONBytes))
  6983. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6984. utils.ErrorLog("解析失败:%v", err)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. res2.InfRefmsgid = ressix10265.InfRefmsgid
  6989. res2.Output = ressix10265.Output
  6990. res2.ErrMsg = ressix10265.ErrMsg
  6991. res2.Cainfo = ressix10265.Cainfo
  6992. res2.WarnMsg = ressix10265.WarnMsg
  6993. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6994. res2.Infcode = infocode
  6995. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6996. 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)
  6997. saveLog(result, requestLog, "2203", "上传就诊信息")
  6998. var respJSON2 map[string]interface{}
  6999. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. userJSONBytes2, _ := json.Marshal(respJSON2)
  7005. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7006. utils.ErrorLog("解析失败:%v", err)
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return
  7009. }
  7010. } else {
  7011. if miConfig.MdtrtareaAdmvs == "440781" { //
  7012. 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)
  7013. } else {
  7014. if miConfig.Code == "H15049901371" {
  7015. //赤峰地区国家医保医疗类别
  7016. //职工透析:医疗类别选特殊情况门诊990502
  7017. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7018. var med_type string
  7019. if his.Insutype == "390" {
  7020. if reg_type == 14 {
  7021. med_type = "9933"
  7022. } else if reg_type == 11 {
  7023. med_type = "11"
  7024. }
  7025. } else if his.Insutype == "310" {
  7026. if reg_type == 14 {
  7027. med_type = "990502"
  7028. } else if reg_type == 11 {
  7029. med_type = "11"
  7030. }
  7031. }
  7032. 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)
  7033. } else {
  7034. 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)
  7035. }
  7036. }
  7037. saveLog(result, requestLog, "2203", "上传就诊信息")
  7038. var respJSON2 map[string]interface{}
  7039. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. userJSONBytes2, _ := json.Marshal(respJSON2)
  7045. if miConfig.Code == "H15049901371" {
  7046. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7047. utils.ErrorLog("解析失败:%v", err)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. return
  7050. }
  7051. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7052. res2.Output = ressix10265.Output
  7053. res2.ErrMsg = ressix10265.ErrMsg
  7054. res2.Cainfo = ressix10265.Cainfo
  7055. res2.WarnMsg = ressix10265.WarnMsg
  7056. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7057. res2.Infcode = infocode
  7058. } else {
  7059. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. }
  7065. }
  7066. if res2.Infcode != 0 {
  7067. adminUser := c.GetAdminUserInfo()
  7068. errlog := &models.HisOrderError{
  7069. UserOrgId: adminUser.CurrentOrgId,
  7070. Ctime: time.Now().Unix(),
  7071. Mtime: time.Now().Unix(),
  7072. ErrMsg: res2.ErrMsg,
  7073. Status: 1,
  7074. PatientId: id,
  7075. RecordTime: recordDateTime,
  7076. Stage: 3,
  7077. }
  7078. service.CreateErrMsgLog(errlog)
  7079. c.ServeSuccessJSON(map[string]interface{}{
  7080. "failed_code": -10,
  7081. "msg": res2.ErrMsg,
  7082. })
  7083. return
  7084. } else {
  7085. his.Diagnosis = diagnosis_id
  7086. his.SickType = sickConfig.ID
  7087. //var p_type int64
  7088. //if reg_type == 1111 || reg_type == 1112 {
  7089. // p_type = 11
  7090. //
  7091. //}
  7092. his.PType = fmt.Sprintf("%d", reg_type)
  7093. service.UpdateHisPatientThree(&his)
  7094. data := make(map[string]interface{})
  7095. if settle_accounts_type == 1 { //日结
  7096. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7097. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7098. } else {
  7099. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7100. }
  7101. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7102. data["pre"] = prescriptions
  7103. } else { //月结
  7104. start_time_str := c.GetString("start_time")
  7105. end_time_str := c.GetString("end_time")
  7106. timeLayout := "2006-01-02"
  7107. loc, _ := time.LoadLocation("Local")
  7108. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7109. if err != nil {
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7111. return
  7112. }
  7113. recordStartTime := theStartTime.Unix()
  7114. start_time = recordStartTime
  7115. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7116. if err != nil {
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7118. return
  7119. }
  7120. recordEndTime := theEndTime.Unix()
  7121. end_time = recordEndTime
  7122. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7123. data["pre"] = prescriptions
  7124. }
  7125. timestamp := time.Now().Unix()
  7126. tempTime := time.Unix(timestamp, 0)
  7127. timeFormat := tempTime.Format("20060102150405")
  7128. chrgBchno := rand.Intn(100000) + 10000
  7129. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7130. strconv.FormatInt(his.PatientId, 10)
  7131. client := &http.Client{}
  7132. data["psn_no"] = his.PsnNo
  7133. data["mdtrt_id"] = his.Number
  7134. data["chrg_bchno"] = chrg_bchno
  7135. data["org_name"] = miConfig.OrgName
  7136. data["doctor"] = doctor_info.UserName
  7137. data["doctor_id"] = doctor_info.DoctorNumber
  7138. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7139. data["fixmedins_code"] = miConfig.Code
  7140. data["opter"] = roles.UserName
  7141. data["dept_code"] = department.Number
  7142. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7143. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7144. data["secret_key"] = miConfig.SecretKey
  7145. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7146. data["url"] = miConfig.Url
  7147. data["ak"] = miConfig.AccessKey
  7148. data["new_doctor_name"] = patientPrescription.Doctor
  7149. data["diag_code"] = sickConfig.CountryCode
  7150. data["cainfo"] = miConfig.Cainfo
  7151. data["opter"] = roles.UserName
  7152. var ids []int64
  7153. for _, item := range prescriptions {
  7154. ids = append(ids, item.ID)
  7155. }
  7156. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7157. if config.IsOpen == 1 { //对接了医保,走医保流程
  7158. var res ResultFour
  7159. var resFour10265 ResultFour10265
  7160. if miConfig.MdtrtareaAdmvs == "421300" {
  7161. bytesData, _ := json.Marshal(data)
  7162. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7163. resp, _ := client.Do(req)
  7164. defer resp.Body.Close()
  7165. body, ioErr := ioutil.ReadAll(resp.Body)
  7166. if ioErr != nil {
  7167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7169. return
  7170. }
  7171. var respJSON map[string]interface{}
  7172. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7175. return
  7176. }
  7177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7178. userJSONBytes, _ := json.Marshal(respJSON)
  7179. fmt.Println("log")
  7180. fmt.Println(string(userJSONBytes))
  7181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7182. utils.ErrorLog("解析失败:%v", err)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7187. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7188. if result3101.Infcode == "0" {
  7189. if len(result3101.Output.Result) > 0 {
  7190. var errMsgs []string
  7191. for _, item := range result3101.Output.Result {
  7192. errMsgs = append(errMsgs, item.VolaCont)
  7193. }
  7194. c.ServeSuccessJSON(map[string]interface{}{
  7195. "failed_code": -10,
  7196. "msg": errMsgs,
  7197. })
  7198. return
  7199. }
  7200. }
  7201. bytesData, _ := json.Marshal(data)
  7202. var req *http.Request
  7203. if miConfig.MdtrtareaAdmvs == "320921" {
  7204. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7205. } else {
  7206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7207. }
  7208. resp, _ := client.Do(req)
  7209. defer resp.Body.Close()
  7210. body, ioErr := ioutil.ReadAll(resp.Body)
  7211. if ioErr != nil {
  7212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. return
  7215. }
  7216. var respJSON map[string]interface{}
  7217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7220. return
  7221. }
  7222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7223. userJSONBytes, _ := json.Marshal(respJSON)
  7224. fmt.Println("log")
  7225. fmt.Println(string(userJSONBytes))
  7226. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7227. utils.ErrorLog("解析失败:%v", err)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. res.InfRefmsgid = resFour10265.InfRefmsgid
  7232. res.Output = resFour10265.Output
  7233. res.ErrMsg = resFour10265.ErrMsg
  7234. res.Cainfo = resFour10265.Cainfo
  7235. res.WarnMsg = resFour10265.WarnMsg
  7236. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7237. res.Infcode = infocode
  7238. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7239. 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)
  7240. var dat map[string]interface{}
  7241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7242. fmt.Println(dat)
  7243. } else {
  7244. fmt.Println(err)
  7245. }
  7246. saveLog(result, request_log, "2204", "上传费用明细")
  7247. userJSONBytes, _ := json.Marshal(dat)
  7248. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7249. utils.ErrorLog("解析失败:%v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return
  7252. }
  7253. res.InfRefmsgid = resFour10265.InfRefmsgid
  7254. res.Output = resFour10265.Output
  7255. res.ErrMsg = resFour10265.ErrMsg
  7256. res.Cainfo = resFour10265.Cainfo
  7257. res.WarnMsg = resFour10265.WarnMsg
  7258. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7259. res.Infcode = infocode
  7260. } else {
  7261. if miConfig.Code == "H15049901371" {
  7262. 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)
  7263. var dat map[string]interface{}
  7264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7265. fmt.Println(dat)
  7266. } else {
  7267. fmt.Println(err)
  7268. }
  7269. saveLog(result, request_log, "2204", "上传费用明细")
  7270. userJSONBytes, _ := json.Marshal(dat)
  7271. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7272. utils.ErrorLog("解析失败:%v", err)
  7273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7274. return
  7275. }
  7276. res.InfRefmsgid = resFour10265.InfRefmsgid
  7277. res.Output = resFour10265.Output
  7278. res.ErrMsg = resFour10265.ErrMsg
  7279. res.Cainfo = resFour10265.Cainfo
  7280. res.WarnMsg = resFour10265.WarnMsg
  7281. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7282. res.Infcode = infocode
  7283. } else {
  7284. 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)
  7285. var dat map[string]interface{}
  7286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7287. fmt.Println(dat)
  7288. } else {
  7289. fmt.Println(err)
  7290. }
  7291. saveLog(result, request_log, "2204", "上传费用明细")
  7292. userJSONBytes, _ := json.Marshal(dat)
  7293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7294. utils.ErrorLog("解析失败:%v", err)
  7295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7296. return
  7297. }
  7298. }
  7299. }
  7300. if res.Infcode == 0 {
  7301. order := &models.HisOrder{
  7302. UserOrgId: adminUser.CurrentOrgId,
  7303. HisPatientId: his.ID,
  7304. PatientId: his.PatientId,
  7305. SettleAccountsDate: recordDateTime,
  7306. MdtrtId: his.Number,
  7307. PsnNo: his.PsnNo,
  7308. MedType: strconv.FormatInt(reg_type, 10),
  7309. Ctime: time.Now().Unix(),
  7310. Mtime: time.Now().Unix(),
  7311. Status: 1,
  7312. Number: chrg_bchno,
  7313. Infcode: res.Infcode,
  7314. WarnMsg: res.WarnMsg,
  7315. Cainfo: res.Cainfo,
  7316. ErrMsg: res.ErrMsg,
  7317. RespondTime: res.RefmsgTime,
  7318. InfRefmsgid: res.InfRefmsgid,
  7319. OrderStatus: 1,
  7320. PayWay: pay_way,
  7321. PayPrice: pay_price,
  7322. PayCardNo: pay_card_no,
  7323. DiscountPrice: discount_price,
  7324. PreferentialPrice: preferential_price,
  7325. RealityPrice: reality_price,
  7326. FoundPrice: found_price,
  7327. MedicalInsurancePrice: medical_insurance_price,
  7328. PrivatePrice: private_price,
  7329. IsMedicineInsurance: 1,
  7330. SettleType: settle_accounts_type,
  7331. SettleStartTime: start_time,
  7332. SettleEndTime: end_time,
  7333. Creator: roles.AdminUserId,
  7334. Modify: roles.AdminUserId,
  7335. FaPiaoNumber: fapiao_number,
  7336. FaPiaoCode: fapiao_code,
  7337. PType: 2,
  7338. Diagnosis: diagnosis_id,
  7339. }
  7340. err = service.CreateOrder(order)
  7341. if err != nil {
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7343. return
  7344. }
  7345. for _, item := range res.Output.Result {
  7346. temp := strings.Split(item.FeedetlSn, "-")
  7347. var advice_id int64 = 0
  7348. var project_id int64 = 0
  7349. var types int64 = 0
  7350. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7351. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7352. if temp[1] == "1" {
  7353. advice_id = id
  7354. project_id = 0
  7355. } else if temp[1] == "2" {
  7356. advice_id = 0
  7357. project_id = id
  7358. }
  7359. info := &models.HisOrderInfo{
  7360. OrderNumber: order.Number,
  7361. FeedetlSn: item.FeedetlSn,
  7362. UploadDate: time.Now().Unix(),
  7363. AdviceId: advice_id,
  7364. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7365. Cnt: item.Cnt,
  7366. Pric: float64(item.Pric),
  7367. PatientId: his.PatientId,
  7368. PricUplmtAmt: item.PricUplmtAmt,
  7369. SelfpayProp: item.SelfpayProp,
  7370. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7371. OverlmtAmt: item.OverlmtAmt,
  7372. PreselfpayAmt: item.PreselfpayAmt,
  7373. BasMednFlag: item.BasMednFlag,
  7374. MedChrgitmType: item.MedChrgitmType,
  7375. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7376. Status: 1,
  7377. Memo: item.Memo,
  7378. Mtime: time.Now().Unix(),
  7379. InscpScpAmt: item.InscpScpAmt,
  7380. DrtReimFlag: item.DrtReimFlag,
  7381. Ctime: time.Now().Unix(),
  7382. ListSpItemFlag: item.ListSpItemFlag,
  7383. ChldMedcFlag: item.ChldMedcFlag,
  7384. LmtUsedFlag: item.LmtUsedFlag,
  7385. ChrgitmLv: item.ChrgitmLv,
  7386. UserOrgId: adminUser.CurrentOrgId,
  7387. HisPatientId: his.ID,
  7388. OrderId: order.ID,
  7389. ProjectId: project_id,
  7390. Type: types,
  7391. }
  7392. service.CreateOrderInfo(info)
  7393. }
  7394. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7395. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7396. var total float64
  7397. for _, item := range prescriptions {
  7398. if item.Type == 1 { //药品
  7399. for _, subItem := range item.HisDoctorAdviceInfo {
  7400. total = total + (subItem.Price * subItem.PrescribingNumber)
  7401. }
  7402. }
  7403. if item.Type == 2 { //项目
  7404. for _, subItem := range item.HisPrescriptionProject {
  7405. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7406. total = total + (subItem.Price * cnt)
  7407. }
  7408. }
  7409. }
  7410. for _, item := range prescriptions {
  7411. for _, subItem := range item.HisAdditionalCharge {
  7412. total = total + (subItem.Price * float64(subItem.Count))
  7413. }
  7414. }
  7415. var allTotal string
  7416. if adminUser.CurrentOrgId == 9919 {
  7417. allTotal = fmt.Sprintf("%.4f", total)
  7418. } else {
  7419. allTotal = fmt.Sprintf("%.4f", total)
  7420. }
  7421. if res.Infcode == 0 {
  7422. var rf []*ResultFive
  7423. json.Unmarshal([]byte(his.Iinfo), &rf)
  7424. chrg_bchno := chrg_bchno
  7425. cert_no := his.Certno
  7426. var insutypes []string
  7427. var insutype string
  7428. var is390 int = 0
  7429. var is310 int = 0
  7430. for _, item := range rf {
  7431. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7432. insutypes = append(insutypes, item.Insutype)
  7433. }
  7434. }
  7435. if len(insutypes) == 1 {
  7436. insutype = insutypes[0]
  7437. } else {
  7438. for _, i := range insutypes {
  7439. if i == "390" {
  7440. is390 = 1
  7441. }
  7442. if i == "310" {
  7443. is310 = 1
  7444. }
  7445. }
  7446. }
  7447. if is390 == 1 {
  7448. insutype = "390"
  7449. }
  7450. if is310 == 1 {
  7451. insutype = "310"
  7452. }
  7453. if len(insutypes) == 0 {
  7454. insutype = "310"
  7455. }
  7456. if len(insutypes) == 2 {
  7457. insutype = strconv.FormatInt(his.SocialType, 10)
  7458. }
  7459. insutype = strconv.FormatInt(his.SocialType, 10)
  7460. //insutype = "390"
  7461. if his.IdCardType == 1 {
  7462. // cert_no = his.MedicalInsuranceNumber
  7463. cert_no = his.Certno
  7464. } else {
  7465. cert_no = his.Certno
  7466. }
  7467. var res ResultSeven
  7468. var resSeven10265 ResultSeven10265
  7469. var src_resquest string
  7470. var result2 string
  7471. var acct_used_flag string
  7472. fmt.Println("pay_way")
  7473. fmt.Println(pay_way)
  7474. fmt.Println("pay_way")
  7475. if pay_way == 4 {
  7476. acct_used_flag = "1"
  7477. } else {
  7478. acct_used_flag = "0"
  7479. }
  7480. if miConfig.MdtrtareaAdmvs == "421300" {
  7481. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7482. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7483. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7485. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7486. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7487. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7488. resp, requestErr := http.Get(api)
  7489. if requestErr != nil {
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7491. return
  7492. }
  7493. body, ioErr := ioutil.ReadAll(resp.Body)
  7494. if ioErr != nil {
  7495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. var respJSON map[string]interface{}
  7500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7503. return
  7504. }
  7505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7506. result, _ := json.Marshal(respJSON)
  7507. if miConfig.Code == "H15049901371" {
  7508. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7509. utils.ErrorLog("解析失败:%v", err)
  7510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7511. return
  7512. }
  7513. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7514. res.Output = resSeven10265.Output
  7515. res.ErrMsg = resSeven10265.ErrMsg
  7516. res.Cainfo = resSeven10265.Cainfo
  7517. res.WarnMsg = resSeven10265.WarnMsg
  7518. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7519. res.Infcode = infocode
  7520. } else {
  7521. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7522. utils.ErrorLog("解析失败:%v", err)
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. }
  7527. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7528. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7529. if result3101.Infcode == "0" {
  7530. if len(result3101.Output.Result) > 0 {
  7531. var errMsgs []string
  7532. for _, item := range result3101.Output.Result {
  7533. errMsgs = append(errMsgs, item.VolaCont)
  7534. }
  7535. c.ServeSuccessJSON(map[string]interface{}{
  7536. "failed_code": -10,
  7537. "msg": errMsgs,
  7538. })
  7539. return
  7540. } else {
  7541. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7542. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7543. bas := strings.Split(psn_info.CardInfo, "|")
  7544. if his.IdCardType == 1 {
  7545. cert_no = bas[2]
  7546. } else if his.IdCardType == 3 {
  7547. cert_no = his.Certno
  7548. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7549. } else if his.IdCardType == 4 {
  7550. cert_no = his.Certno
  7551. psn_info.VerifyNumber = psn_info.VerifyNumber
  7552. }
  7553. var api string
  7554. if miConfig.MdtrtareaAdmvs == "320921" {
  7555. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7556. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7557. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7559. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7560. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7561. "&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
  7562. } else {
  7563. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7564. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7565. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7566. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7567. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7568. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7569. "&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
  7570. }
  7571. resp, requestErr := http.Get(api)
  7572. if requestErr != nil {
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. body, ioErr := ioutil.ReadAll(resp.Body)
  7577. if ioErr != nil {
  7578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. var respJSON map[string]interface{}
  7583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7586. return
  7587. }
  7588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7589. result, _ := json.Marshal(respJSON)
  7590. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7591. utils.ErrorLog("解析失败:%v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7596. res.Output = resSeven10265.Output
  7597. res.ErrMsg = resSeven10265.ErrMsg
  7598. res.Cainfo = resSeven10265.Cainfo
  7599. res.WarnMsg = resSeven10265.WarnMsg
  7600. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7601. res.Infcode = infocode
  7602. }
  7603. }
  7604. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7605. var cert_no string
  7606. if his.IdCardType == 4 {
  7607. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7608. cert_no = psn_info.VerifyNumber
  7609. 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)
  7610. } else if his.IdCardType == 1 {
  7611. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7612. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7613. 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)
  7614. }
  7615. //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)
  7616. var dat map[string]interface{}
  7617. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7618. fmt.Println(dat)
  7619. } else {
  7620. fmt.Println(err)
  7621. }
  7622. saveLog(result2, src_resquest, "2207", "结算")
  7623. userJSONBytes, _ := json.Marshal(dat)
  7624. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7625. utils.ErrorLog("解析失败:%v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7630. res.Output = resSeven10265.Output
  7631. res.ErrMsg = resSeven10265.ErrMsg
  7632. res.Cainfo = resSeven10265.Cainfo
  7633. res.WarnMsg = resSeven10265.WarnMsg
  7634. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7635. res.Infcode = infocode
  7636. } else {
  7637. if miConfig.Code == "H15049901371" {
  7638. //赤峰地区国家医保医疗类别
  7639. //职工透析:医疗类别选特殊情况门诊990502
  7640. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7641. var med_type string
  7642. if his.Insutype == "390" {
  7643. if reg_type == 14 {
  7644. med_type = "9933"
  7645. } else if reg_type == 11 {
  7646. med_type = "11"
  7647. }
  7648. } else if his.Insutype == "310" {
  7649. if reg_type == 14 {
  7650. med_type = "990502"
  7651. } else if reg_type == 11 {
  7652. med_type = "11"
  7653. }
  7654. }
  7655. 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, "")
  7656. } else {
  7657. if his.IdCardType == 4 {
  7658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7659. var token string
  7660. token = psn_info.VerifyNumber
  7661. 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)
  7662. } else {
  7663. 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, "")
  7664. }
  7665. }
  7666. //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)
  7667. var dat map[string]interface{}
  7668. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7669. fmt.Println(dat)
  7670. } else {
  7671. fmt.Println(err)
  7672. }
  7673. saveLog(result2, src_resquest, "2207", "结算")
  7674. userJSONBytes, _ := json.Marshal(dat)
  7675. if miConfig.Code == "H15049901371" {
  7676. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7677. utils.ErrorLog("解析失败:%v", err)
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7679. return
  7680. }
  7681. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7682. res.Output = resSeven10265.Output
  7683. res.ErrMsg = resSeven10265.ErrMsg
  7684. res.Cainfo = resSeven10265.Cainfo
  7685. res.WarnMsg = resSeven10265.WarnMsg
  7686. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7687. res.Infcode = infocode
  7688. } else {
  7689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7690. utils.ErrorLog("解析失败:%v", err)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. }
  7695. }
  7696. if res.Infcode != 0 {
  7697. errlog := &models.HisOrderError{
  7698. UserOrgId: adminUser.CurrentOrgId,
  7699. Ctime: time.Now().Unix(),
  7700. Mtime: time.Now().Unix(),
  7701. Number: chrg_bchno,
  7702. ErrMsg: res.ErrMsg,
  7703. Status: 1,
  7704. PatientId: id,
  7705. RecordTime: recordDateTime,
  7706. Stage: 6,
  7707. }
  7708. service.CreateErrMsgLog(errlog)
  7709. c.ServeSuccessJSON(map[string]interface{}{
  7710. "failed_code": -10,
  7711. "msg": res.ErrMsg,
  7712. })
  7713. return
  7714. } else {
  7715. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7716. order.OrderStatus = 2
  7717. order.Status = 1
  7718. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7719. order.SetlId = res.Output.Setlinfo.SetlID
  7720. order.PsnNo = res.Output.Setlinfo.PsnNo
  7721. order.PsnName = res.Output.Setlinfo.PsnName
  7722. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7723. order.Certno = res.Output.Setlinfo.Certno
  7724. order.Gend = res.Output.Setlinfo.Gend
  7725. order.Naty = res.Output.Setlinfo.Naty
  7726. order.Age = res.Output.Setlinfo.Age
  7727. order.Insutype = res.Output.Setlinfo.Insutype
  7728. order.PsnType = res.Output.Setlinfo.PsnType
  7729. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7730. order.SetlTime = res.Output.Setlinfo.SetlTime
  7731. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7732. if res.Output.Setlinfo.MedType == "140101" {
  7733. order.MedType = "14"
  7734. } else {
  7735. order.MedType = res.Output.Setlinfo.MedType
  7736. }
  7737. if reg_type == 1112 {
  7738. order.MedType = "1112"
  7739. }
  7740. if reg_type == 1111 {
  7741. order.MedType = "1111"
  7742. }
  7743. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7744. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7745. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7746. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7747. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7748. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7749. order.HifpPay = res.Output.Setlinfo.HifpPay
  7750. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7751. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7752. order.HifesPay = res.Output.Setlinfo.HifesPay
  7753. order.HifobPay = res.Output.Setlinfo.HifobPay
  7754. order.MafPay = res.Output.Setlinfo.MafPay
  7755. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7756. order.OthPay = res.Output.Setlinfo.OthPay
  7757. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7758. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7759. order.AcctPay = res.Output.Setlinfo.AcctPay
  7760. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7761. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7762. order.Balc = res.Output.Setlinfo.Balc
  7763. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7764. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7765. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7766. order.ClrType = res.Output.Setlinfo.ClrType
  7767. order.ClrWay = res.Output.Setlinfo.ClrWay
  7768. order.Creator = order.Creator
  7769. order.Modify = roles.AdminUserId
  7770. order.RequestLog = src_resquest
  7771. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7772. detailStr := string(setlDetail)
  7773. order.SetlDetail = detailStr
  7774. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7775. err = service.UpDateOrder(order)
  7776. if err == nil {
  7777. //判断是否使用了押金
  7778. if dec_way == "true" {
  7779. tmpstring := strconv.FormatInt(order.ID, 10)
  7780. order.Decimal = decimal
  7781. service.UpDateOrder(order)
  7782. //扣押金
  7783. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  7784. if errmsg != nil {
  7785. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  7786. return
  7787. }
  7788. }
  7789. c.ServeSuccessJSON(map[string]interface{}{
  7790. "msg": "结算成功",
  7791. })
  7792. } else {
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7794. return
  7795. }
  7796. }
  7797. } else {
  7798. adminUser := c.GetAdminUserInfo()
  7799. errlog := &models.HisOrderError{
  7800. UserOrgId: adminUser.CurrentOrgId,
  7801. Ctime: time.Now().Unix(),
  7802. Mtime: time.Now().Unix(),
  7803. ErrMsg: res.ErrMsg,
  7804. Status: 1,
  7805. PatientId: id,
  7806. RecordTime: recordDateTime,
  7807. Stage: 4,
  7808. }
  7809. service.CreateErrMsgLog(errlog)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7811. return
  7812. }
  7813. } else {
  7814. adminUser := c.GetAdminUserInfo()
  7815. errlog := &models.HisOrderError{
  7816. UserOrgId: adminUser.CurrentOrgId,
  7817. Ctime: time.Now().Unix(),
  7818. Mtime: time.Now().Unix(),
  7819. ErrMsg: res.ErrMsg,
  7820. Status: 1,
  7821. PatientId: id,
  7822. RecordTime: recordDateTime,
  7823. Stage: 4,
  7824. }
  7825. service.CreateErrMsgLog(errlog)
  7826. c.ServeSuccessJSON(map[string]interface{}{
  7827. "failed_code": -10,
  7828. "msg": res.ErrMsg,
  7829. })
  7830. return
  7831. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7832. //return
  7833. }
  7834. }
  7835. }
  7836. } else if tempOrder.ID > 0 {
  7837. if tempOrder.IsPre == 1 {
  7838. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  7839. var rf []*ResultFive
  7840. json.Unmarshal([]byte(his.Iinfo), &rf)
  7841. chrg_bchno := tempOrder.Number
  7842. cert_no := his.Certno
  7843. var insutypes []string
  7844. var insutype string
  7845. var is390 int = 0
  7846. var is310 int = 0
  7847. for _, item := range rf {
  7848. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7849. insutypes = append(insutypes, item.Insutype)
  7850. }
  7851. }
  7852. if len(insutypes) == 1 {
  7853. insutype = insutypes[0]
  7854. } else {
  7855. for _, i := range insutypes {
  7856. if i == "390" {
  7857. is390 = 1
  7858. }
  7859. if i == "310" {
  7860. is310 = 1
  7861. }
  7862. }
  7863. }
  7864. if is390 == 1 {
  7865. insutype = "390"
  7866. }
  7867. if is310 == 1 {
  7868. insutype = "310"
  7869. }
  7870. if len(insutypes) == 0 {
  7871. insutype = "310"
  7872. }
  7873. if len(insutypes) == 2 {
  7874. insutype = strconv.FormatInt(his.SocialType, 64)
  7875. }
  7876. //insutype = "390"
  7877. if his.IdCardType == 1 {
  7878. // cert_no = his.MedicalInsuranceNumber
  7879. cert_no = his.Certno
  7880. } else {
  7881. cert_no = his.Certno
  7882. }
  7883. var res ResultSeven
  7884. var resSeven10265 ResultSeven10265
  7885. var src_resquest string
  7886. var result2 string
  7887. var acct_used_flag string
  7888. fmt.Println("pay_way")
  7889. fmt.Println(pay_way)
  7890. fmt.Println("pay_way")
  7891. if pay_way == 4 {
  7892. acct_used_flag = "1"
  7893. } else {
  7894. acct_used_flag = "0"
  7895. }
  7896. if miConfig.MdtrtareaAdmvs == "421300" {
  7897. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7898. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7899. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7901. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7902. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7903. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7904. resp, requestErr := http.Get(api)
  7905. if requestErr != nil {
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. body, ioErr := ioutil.ReadAll(resp.Body)
  7910. if ioErr != nil {
  7911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. var respJSON map[string]interface{}
  7916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. return
  7920. }
  7921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7922. result, _ := json.Marshal(respJSON)
  7923. fmt.Println("log")
  7924. fmt.Println(string(result))
  7925. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7926. utils.ErrorLog("解析失败:%v", err)
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. return
  7929. }
  7930. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7931. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  7932. if result3101.Infcode == "0" {
  7933. if len(result3101.Output.Result) > 0 {
  7934. var errMsgs []string
  7935. for _, item := range result3101.Output.Result {
  7936. errMsgs = append(errMsgs, item.VolaCont)
  7937. }
  7938. c.ServeSuccessJSON(map[string]interface{}{
  7939. "failed_code": -10,
  7940. "msg": errMsgs,
  7941. })
  7942. return
  7943. } else {
  7944. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7945. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7946. bas := strings.Split(psn_info.CardInfo, "|")
  7947. if his.IdCardType == 1 {
  7948. cert_no = bas[2]
  7949. } else if his.IdCardType == 3 {
  7950. cert_no = his.Certno
  7951. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7952. } else if his.IdCardType == 4 {
  7953. cert_no = his.Certno
  7954. psn_info.VerifyNumber = psn_info.VerifyNumber
  7955. }
  7956. //江苏地区国家医保医疗类别
  7957. //职工透析:医疗类别选特殊情况门诊9933
  7958. //居民血透门慢: 医疗类别选门诊慢病1402
  7959. //var med_type string
  7960. //if his.Insutype == "310" {
  7961. // if reg_type == 14 {
  7962. // med_type = "9933"
  7963. // } else if reg_type == 11 {
  7964. // med_type = "11"
  7965. //
  7966. // }
  7967. //} else if his.Insutype == "390" {
  7968. // if reg_type == 14 {
  7969. // med_type = "1402"
  7970. // } else if reg_type == 11 {
  7971. // med_type = "11"
  7972. // }
  7973. //}
  7974. var api string
  7975. if miConfig.MdtrtareaAdmvs == "320921" {
  7976. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7977. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7978. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7980. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7981. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7982. "&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
  7983. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7984. } else {
  7985. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7986. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7987. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7988. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7989. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7990. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7991. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7992. "&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
  7993. }
  7994. resp, requestErr := http.Get(api)
  7995. if requestErr != nil {
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. body, ioErr := ioutil.ReadAll(resp.Body)
  8000. if ioErr != nil {
  8001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. var respJSON map[string]interface{}
  8006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8009. return
  8010. }
  8011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8012. result, _ := json.Marshal(respJSON)
  8013. fmt.Println("log")
  8014. fmt.Println(string(result))
  8015. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8016. utils.ErrorLog("解析失败:%v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8021. res.Output = resSeven10265.Output
  8022. res.ErrMsg = resSeven10265.ErrMsg
  8023. res.Cainfo = resSeven10265.Cainfo
  8024. res.WarnMsg = resSeven10265.WarnMsg
  8025. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8026. res.Infcode = infocode
  8027. }
  8028. }
  8029. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8031. var cert_no string
  8032. if his.IdCardType == 1 {
  8033. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8034. } else {
  8035. cert_no = psn_info.VerifyNumber
  8036. }
  8037. 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)
  8038. var dat map[string]interface{}
  8039. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8040. fmt.Println(dat)
  8041. } else {
  8042. fmt.Println(err)
  8043. }
  8044. saveLog(result2, src_resquest, "2207", "结算")
  8045. userJSONBytes, _ := json.Marshal(dat)
  8046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8047. utils.ErrorLog("解析失败:%v", err)
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8049. return
  8050. }
  8051. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8052. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8053. var cert_no string
  8054. if his.IdCardType == 1 {
  8055. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8056. } else if his.IdCardType == 2 {
  8057. cert_no = his.IdCardNo
  8058. } else {
  8059. cert_no = psn_info.VerifyNumber
  8060. }
  8061. 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, "")
  8062. var dat map[string]interface{}
  8063. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8064. fmt.Println(dat)
  8065. } else {
  8066. fmt.Println(err)
  8067. }
  8068. saveLog(result2, src_resquest, "2207", "结算")
  8069. userJSONBytes, _ := json.Marshal(dat)
  8070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8071. utils.ErrorLog("解析失败:%v", err)
  8072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8073. return
  8074. }
  8075. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8076. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8077. var cert_no string
  8078. if his.IdCardType == 1 {
  8079. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8080. } else if his.IdCardType == 2 {
  8081. cert_no = his.IdCardNo
  8082. } else {
  8083. cert_no = psn_info.VerifyNumber
  8084. }
  8085. 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, "")
  8086. var dat map[string]interface{}
  8087. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8088. fmt.Println(dat)
  8089. } else {
  8090. fmt.Println(err)
  8091. }
  8092. saveLog(result2, src_resquest, "2207", "结算")
  8093. userJSONBytes, _ := json.Marshal(dat)
  8094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8095. utils.ErrorLog("解析失败:%v", err)
  8096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8097. return
  8098. }
  8099. } else {
  8100. var src_resquest string
  8101. if miConfig.Code == "H15049901371" {
  8102. //赤峰地区国家医保医疗类别
  8103. //职工透析:医疗类别选特殊情况门诊990502
  8104. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8105. var med_type string
  8106. if his.Insutype == "390" {
  8107. if reg_type == 14 {
  8108. med_type = "9933"
  8109. } else if reg_type == 11 {
  8110. med_type = "11"
  8111. }
  8112. } else if his.Insutype == "310" {
  8113. if reg_type == 14 {
  8114. med_type = "990502"
  8115. } else if reg_type == 11 {
  8116. med_type = "11"
  8117. }
  8118. }
  8119. 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, "")
  8120. } else {
  8121. if his.IdCardType == 4 {
  8122. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8123. token := psn_info.VerifyNumber
  8124. 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)
  8125. } else {
  8126. 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, "")
  8127. }
  8128. }
  8129. var dat map[string]interface{}
  8130. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8131. fmt.Println(dat)
  8132. } else {
  8133. fmt.Println(err)
  8134. }
  8135. saveLog(result2, src_resquest, "2207", "结算")
  8136. userJSONBytes, _ := json.Marshal(dat)
  8137. if miConfig.Code == "H15049901371" {
  8138. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8139. utils.ErrorLog("解析失败:%v", err)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8144. res.Output = resSeven10265.Output
  8145. res.ErrMsg = resSeven10265.ErrMsg
  8146. res.Cainfo = resSeven10265.Cainfo
  8147. res.WarnMsg = resSeven10265.WarnMsg
  8148. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8149. res.Infcode = infocode
  8150. } else {
  8151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. }
  8157. }
  8158. if res.Infcode != 0 {
  8159. errlog := &models.HisOrderError{
  8160. UserOrgId: adminUser.CurrentOrgId,
  8161. Ctime: time.Now().Unix(),
  8162. Mtime: time.Now().Unix(),
  8163. Number: chrg_bchno,
  8164. ErrMsg: res.ErrMsg,
  8165. Status: 1,
  8166. PatientId: id,
  8167. RecordTime: recordDateTime,
  8168. Stage: 6,
  8169. }
  8170. service.CreateErrMsgLog(errlog)
  8171. c.ServeSuccessJSON(map[string]interface{}{
  8172. "failed_code": -10,
  8173. "msg": res.ErrMsg,
  8174. })
  8175. return
  8176. } else {
  8177. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8178. order.OrderStatus = 2
  8179. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8180. order.SetlId = res.Output.Setlinfo.SetlID
  8181. order.PsnNo = res.Output.Setlinfo.PsnNo
  8182. order.PsnName = res.Output.Setlinfo.PsnName
  8183. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8184. order.Certno = res.Output.Setlinfo.Certno
  8185. order.Gend = res.Output.Setlinfo.Gend
  8186. order.Naty = res.Output.Setlinfo.Naty
  8187. order.Age = res.Output.Setlinfo.Age
  8188. order.Insutype = res.Output.Setlinfo.Insutype
  8189. order.PsnType = res.Output.Setlinfo.PsnType
  8190. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8191. order.SetlTime = res.Output.Setlinfo.SetlTime
  8192. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8193. //order.MedType = res.Output.Setlinfo.MedType
  8194. if reg_type == 1112 {
  8195. order.MedType = "1112"
  8196. }
  8197. if reg_type == 1111 {
  8198. order.MedType = "1111"
  8199. }
  8200. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8201. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8202. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8203. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8204. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8205. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8206. order.HifpPay = res.Output.Setlinfo.HifpPay
  8207. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8208. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8209. order.HifesPay = res.Output.Setlinfo.HifesPay
  8210. order.HifobPay = res.Output.Setlinfo.HifobPay
  8211. order.MafPay = res.Output.Setlinfo.MafPay
  8212. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8213. order.OthPay = res.Output.Setlinfo.OthPay
  8214. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8215. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8216. order.AcctPay = res.Output.Setlinfo.AcctPay
  8217. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8218. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8219. order.Balc = res.Output.Setlinfo.Balc
  8220. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8221. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8222. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8223. order.ClrWay = res.Output.Setlinfo.ClrWay
  8224. order.Creator = order.Creator
  8225. order.Modify = roles.AdminUserId
  8226. order.RequestLog = src_resquest
  8227. order.Diagnosis = diagnosis_id
  8228. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8229. detailStr := string(setlDetail)
  8230. order.SetlDetail = detailStr
  8231. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8232. err = service.UpDateOrder(order)
  8233. if err == nil {
  8234. //判断是否使用了押金
  8235. if dec_way == "true" {
  8236. tmpstring := strconv.FormatInt(order.ID, 10)
  8237. //扣押金
  8238. order.Decimal = decimal
  8239. service.UpDateOrder(order)
  8240. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8241. if errmsg != nil {
  8242. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8243. return
  8244. }
  8245. }
  8246. c.ServeSuccessJSON(map[string]interface{}{
  8247. "msg": "结算成功",
  8248. })
  8249. } else {
  8250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8251. return
  8252. }
  8253. }
  8254. }
  8255. }
  8256. }
  8257. //func (c *HisApiController) GetPreUploadInfo() {
  8258. // id, _ := c.GetInt64("id")
  8259. // record_time := c.GetString("record_time")
  8260. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8261. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8262. //
  8263. // timeLayout := "2006-01-02"
  8264. // loc, _ := time.LoadLocation("Local")
  8265. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8266. // if err != nil {
  8267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8268. // return
  8269. // }
  8270. // recordDateTime := theTime.Unix()
  8271. // adminUser := c.GetAdminUserInfo()
  8272. //
  8273. // var prescriptions []*models.HisPrescription
  8274. //
  8275. // var start_time int64
  8276. // var end_time int64
  8277. //
  8278. // data := make(map[string]interface{})
  8279. // if settle_accounts_type == 1 { //日结
  8280. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8281. // data["pre"] = prescriptions
  8282. //
  8283. // } else { //月结
  8284. // start_time_str := c.GetString("start_time")
  8285. // end_time_str := c.GetString("end_time")
  8286. // timeLayout := "2006-01-02"
  8287. // loc, _ := time.LoadLocation("Local")
  8288. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8289. // if err != nil {
  8290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8291. // return
  8292. // }
  8293. // recordStartTime := theStartTime.Unix()
  8294. // start_time = recordStartTime
  8295. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8296. // if err != nil {
  8297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8298. // return
  8299. // }
  8300. // recordEndTime := theEndTime.Unix()
  8301. // end_time = recordEndTime
  8302. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8303. // data["pre"] = prescriptions
  8304. //
  8305. // }
  8306. //
  8307. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8308. //
  8309. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8310. // timestamp := time.Now().Unix()
  8311. // tempTime := time.Unix(timestamp, 0)
  8312. // timeFormat := tempTime.Format("20060102150405")
  8313. // chrgBchno := rand.Intn(100000) + 10000
  8314. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8315. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8316. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8317. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8318. // strconv.FormatInt(his.PatientId, 10)
  8319. // client := &http.Client{}
  8320. // data["psn_no"] = his.PsnNo
  8321. // data["mdtrt_id"] = his.Number
  8322. // data["chrg_bchno"] = chrg_bchno
  8323. // data["org_name"] = miConfig.OrgName
  8324. // data["doctor"] = roles.UserName
  8325. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8326. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8327. // data["fixmedins_code"] = miConfig.Code
  8328. // data["dept_code"] = department.Number
  8329. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8330. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8331. // data["secret_key"] = miConfig.SecretKey
  8332. // var ids []int64
  8333. //
  8334. // for _, item := range prescriptions {
  8335. // ids = append(ids, item.ID)
  8336. // }
  8337. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8338. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8339. // bytesData, _ := json.Marshal(data)
  8340. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8341. // resp, _ := client.Do(req)
  8342. // defer resp.Body.Close()
  8343. // body, ioErr := ioutil.ReadAll(resp.Body)
  8344. // if ioErr != nil {
  8345. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. // return
  8348. // }
  8349. // var respJSON map[string]interface{}
  8350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. // return
  8354. // }
  8355. //
  8356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8357. // userJSONBytes, _ := json.Marshal(respJSON)
  8358. // var res ResultFour
  8359. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8360. // utils.ErrorLog("解析失败:%v", err)
  8361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8362. // return
  8363. // }
  8364. //
  8365. // if res.Infcode == 0 {
  8366. // order := &models.HisOrder{
  8367. // UserOrgId: adminUser.CurrentOrgId,
  8368. // HisPatientId: his.ID,
  8369. // PatientId: his.PatientId,
  8370. // SettleAccountsDate: recordDateTime,
  8371. // Ctime: time.Now().Unix(),
  8372. // Mtime: time.Now().Unix(),
  8373. // Status: 1,
  8374. // Number: chrg_bchno,
  8375. // Infcode: res.Infcode,
  8376. // WarnMsg: res.WarnMsg,
  8377. // Cainfo: res.Cainfo,
  8378. // ErrMsg: res.ErrMsg,
  8379. // RespondTime: res.RefmsgTime,
  8380. // InfRefmsgid: res.InfRefmsgid,
  8381. // OrderStatus: 1,
  8382. // IsMedicineInsurance: 1,
  8383. // SettleType: settle_accounts_type,
  8384. // SettleStartTime: start_time,
  8385. // SettleEndTime: end_time,
  8386. // Creator: roles.ID,
  8387. // Modify: roles.ID,
  8388. // PType: 2,
  8389. // }
  8390. // err = service.CreateOrder(order)
  8391. // if err != nil {
  8392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8393. // return
  8394. // }
  8395. //
  8396. // for _, item := range res.Output.Result {
  8397. // temp := strings.Split(item.FeedetlSn, "-")
  8398. // var advice_id int64 = 0
  8399. // var project_id int64 = 0
  8400. // var types int64 = 0
  8401. //
  8402. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8403. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8404. //
  8405. // if temp[1] == "1" {
  8406. // advice_id = id
  8407. // project_id = 0
  8408. // } else if temp[1] == "2" {
  8409. // advice_id = 0
  8410. // project_id = id
  8411. // }
  8412. //
  8413. // info := &models.HisOrderInfo{
  8414. // OrderNumber: order.Number,
  8415. // FeedetlSn: item.FeedetlSn,
  8416. // UploadDate: time.Now().Unix(),
  8417. // AdviceId: advice_id,
  8418. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8419. // Cnt: item.Cnt,
  8420. // Pric: float64(item.Pric),
  8421. // PatientId: his.PatientId,
  8422. // PricUplmtAmt: item.PricUplmtAmt,
  8423. // SelfpayProp: item.SelfpayProp,
  8424. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8425. // OverlmtAmt: item.OverlmtAmt,
  8426. // PreselfpayAmt: item.PreselfpayAmt,
  8427. // BasMednFlag: item.BasMednFlag,
  8428. // MedChrgitmType: item.MedChrgitmType,
  8429. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8430. // Status: 1,
  8431. // Memo: item.Memo,
  8432. // Mtime: time.Now().Unix(),
  8433. // InscpScpAmt: item.InscpScpAmt,
  8434. // DrtReimFlag: item.DrtReimFlag,
  8435. // Ctime: time.Now().Unix(),
  8436. // ListSpItemFlag: item.ListSpItemFlag,
  8437. // ChldMedcFlag: item.ChldMedcFlag,
  8438. // LmtUsedFlag: item.LmtUsedFlag,
  8439. // ChrgitmLv: item.ChrgitmLv,
  8440. // UserOrgId: adminUser.CurrentOrgId,
  8441. // HisPatientId: his.ID,
  8442. // OrderId: order.ID,
  8443. // ProjectId: project_id,
  8444. // Type: types,
  8445. // }
  8446. // service.CreateOrderInfo(info)
  8447. //
  8448. // }
  8449. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8450. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8451. //
  8452. // var total float64
  8453. // for _, item := range prescriptions {
  8454. // if item.Type == 1 { //药品
  8455. // for _, subItem := range item.HisDoctorAdviceInfo {
  8456. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8457. // }
  8458. // }
  8459. // if item.Type == 2 { //项目
  8460. // for _, subItem := range item.HisPrescriptionProject {
  8461. // total = total + (subItem.Price * float64(subItem.Count))
  8462. // }
  8463. // }
  8464. // }
  8465. //
  8466. // for _, item := range prescriptions {
  8467. // for _, subItem := range item.HisAdditionalCharge {
  8468. // total = total + (subItem.Price * float64(subItem.Count))
  8469. // }
  8470. // }
  8471. //
  8472. // allTotal := fmt.Sprintf("%.2f", total)
  8473. // if res.Infcode == 0 {
  8474. // var rf []*ResultFive
  8475. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8476. // psn_no := his.PsnNo
  8477. // mdtrt_id := his.Number
  8478. // chrg_bchno := chrg_bchno
  8479. // cert_no := his.Certno
  8480. // insutype := rf[0].Insutype
  8481. //
  8482. // if his.IdCardType == 1 {
  8483. // cert_no = his.MedicalInsuranceNumber
  8484. //
  8485. // } else {
  8486. //
  8487. // cert_no = his.Certno
  8488. //
  8489. // }
  8490. //
  8491. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8492. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8493. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8494. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8495. // resp, requestErr := http.Get(api)
  8496. // if requestErr != nil {
  8497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. // return
  8499. // }
  8500. // defer resp.Body.Close()
  8501. // body, ioErr := ioutil.ReadAll(resp.Body)
  8502. // if ioErr != nil {
  8503. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. // return
  8506. // }
  8507. // var respJSON map[string]interface{}
  8508. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8509. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8511. // return
  8512. // }
  8513. // fmt.Println(respJSON)
  8514. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8515. // userJSONBytes, _ := json.Marshal(respJSON)
  8516. // var res ResultSeven
  8517. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8518. // utils.ErrorLog("解析失败:%v", err)
  8519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. // return
  8521. // }
  8522. // if res.Infcode != 0 {
  8523. // errlog := &models.HisOrderError{
  8524. // UserOrgId: adminUser.CurrentOrgId,
  8525. // Ctime: time.Now().Unix(),
  8526. // Mtime: time.Now().Unix(),
  8527. // Number: chrg_bchno,
  8528. // ErrMsg: res.ErrMsg,
  8529. // Status: 1,
  8530. // PatientId: id,
  8531. // RecordTime: recordDateTime,
  8532. // Stage: 7,
  8533. // }
  8534. // service.CreateErrMsgLog(errlog)
  8535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8536. // return
  8537. // } else {
  8538. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8539. // order.OrderStatus = 1
  8540. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8541. // order.SetlId = res.Output.Setlinfo.SetlID
  8542. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8543. // order.PsnName = res.Output.Setlinfo.PsnName
  8544. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8545. // order.Certno = res.Output.Setlinfo.Certno
  8546. // order.Gend = res.Output.Setlinfo.Gend
  8547. // order.Naty = res.Output.Setlinfo.Naty
  8548. // order.Age = res.Output.Setlinfo.Age
  8549. // order.Insutype = res.Output.Setlinfo.Insutype
  8550. // order.PsnType = res.Output.Setlinfo.PsnType
  8551. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8552. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8553. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8554. // order.MedType = res.Output.Setlinfo.MedType
  8555. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8556. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8557. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8558. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8559. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8560. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8561. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8562. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8563. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8564. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8565. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8566. // order.MafPay = res.Output.Setlinfo.MafPay
  8567. // order.OthPay = res.Output.Setlinfo.OthPay
  8568. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8569. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8570. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8571. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8572. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8573. // order.Balc = res.Output.Setlinfo.Balc
  8574. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8575. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8576. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8577. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8578. // order.Creator = order.Creator
  8579. // order.Modify = roles.ID
  8580. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8581. // detailStr := string(setlDetail)
  8582. // order.SetlDetail = detailStr
  8583. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8584. // err = service.UpDateOrder(order)
  8585. // if err == nil {
  8586. // c.ServeSuccessJSON(map[string]interface{}{
  8587. // "msg": "预结算成功",
  8588. // })
  8589. // } else {
  8590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8591. // return
  8592. // }
  8593. // }
  8594. // } else {
  8595. // adminUser := c.GetAdminUserInfo()
  8596. // errlog := &models.HisOrderError{
  8597. // UserOrgId: adminUser.CurrentOrgId,
  8598. // Ctime: time.Now().Unix(),
  8599. // Mtime: time.Now().Unix(),
  8600. // ErrMsg: res.ErrMsg,
  8601. // Status: 1,
  8602. // PatientId: id,
  8603. // RecordTime: recordDateTime,
  8604. // Stage: 4,
  8605. // }
  8606. // service.CreateErrMsgLog(errlog)
  8607. //
  8608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8609. // return
  8610. // }
  8611. // } else {
  8612. // adminUser := c.GetAdminUserInfo()
  8613. // errlog := &models.HisOrderError{
  8614. // UserOrgId: adminUser.CurrentOrgId,
  8615. // Ctime: time.Now().Unix(),
  8616. // Mtime: time.Now().Unix(),
  8617. // ErrMsg: res.ErrMsg,
  8618. // Status: 1,
  8619. // PatientId: id,
  8620. // RecordTime: recordDateTime,
  8621. // Stage: 4,
  8622. // }
  8623. // service.CreateErrMsgLog(errlog)
  8624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8625. // return
  8626. // }
  8627. //
  8628. // } else {
  8629. // var total float64
  8630. // for _, item := range prescriptions {
  8631. // if item.Type == 1 { //药品
  8632. // for _, subItem := range item.HisDoctorAdviceInfo {
  8633. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8634. // }
  8635. // }
  8636. // if item.Type == 2 { //项目
  8637. // for _, subItem := range item.HisPrescriptionProject {
  8638. // total = total + (subItem.Price * float64(subItem.Count))
  8639. // }
  8640. // }
  8641. //
  8642. // for _, subItem := range item.HisAdditionalCharge {
  8643. // total = total + (subItem.Price * float64(subItem.Count))
  8644. // }
  8645. // }
  8646. //
  8647. // allTotal := fmt.Sprintf("%.2f", total)
  8648. // totals, _ := strconv.ParseFloat(allTotal, 64)
  8649. // order := &models.HisOrder{
  8650. // UserOrgId: adminUser.CurrentOrgId,
  8651. // HisPatientId: his.ID,
  8652. // PatientId: id,
  8653. // SettleAccountsDate: recordDateTime,
  8654. // Ctime: time.Now().Unix(),
  8655. // Mtime: time.Now().Unix(),
  8656. // Status: 1,
  8657. // OrderStatus: 2,
  8658. // Number: chrg_bchno,
  8659. // MedfeeSumamt: totals,
  8660. // }
  8661. // err = service.CreateOrder(order)
  8662. // if err != nil {
  8663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8664. // return
  8665. // }
  8666. //
  8667. // var customs []*Custom
  8668. // for _, item := range prescriptions {
  8669. //
  8670. // if item.Type == 1 { //药品
  8671. // for _, subItem := range item.HisDoctorAdviceInfo {
  8672. // cus := &Custom{
  8673. // AdviceId: subItem.ID,
  8674. // ProjectId: 0,
  8675. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  8676. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  8677. // FeedetlSn: subItem.FeedetlSn,
  8678. // Price: fmt.Sprintf("%.2f", subItem.Price),
  8679. // MedListCodg: subItem.MedListCodg,
  8680. // Type: 1,
  8681. // }
  8682. // customs = append(customs, cus)
  8683. // }
  8684. // }
  8685. //
  8686. // if item.Type == 2 { //项目
  8687. // for _, subItem := range item.HisPrescriptionProject {
  8688. //
  8689. // cus := &Custom{
  8690. // AdviceId: 0,
  8691. // ProjectId: subItem.ID,
  8692. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  8693. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  8694. // FeedetlSn: subItem.FeedetlSn,
  8695. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  8696. // MedListCodg: subItem.MedListCodg,
  8697. // Type: 2,
  8698. // }
  8699. //
  8700. // customs = append(customs, cus)
  8701. // }
  8702. // }
  8703. //
  8704. // for _, item := range item.HisAdditionalCharge {
  8705. // cus := &Custom{
  8706. // ItemId: item.ID,
  8707. // AdviceId: 0,
  8708. // ProjectId: 0,
  8709. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  8710. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  8711. // FeedetlSn: item.FeedetlSn,
  8712. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  8713. // MedListCodg: item.XtHisAddtionConfig.Code,
  8714. // Type: 3,
  8715. // }
  8716. //
  8717. // customs = append(customs, cus)
  8718. // }
  8719. //
  8720. // }
  8721. //
  8722. // for _, item := range customs {
  8723. // var advice_id int64 = 0
  8724. // var project_id int64 = 0
  8725. // var item_id int64 = 0
  8726. //
  8727. // var types int64 = 0
  8728. //
  8729. // if item.Type == 1 {
  8730. // advice_id = item.AdviceId
  8731. // project_id = 0
  8732. // item_id = 0
  8733. // } else if item.Type == 2 {
  8734. // advice_id = 0
  8735. // item_id = 0
  8736. //
  8737. // project_id = item.ProjectId
  8738. // } else if item.Type == 3 {
  8739. // advice_id = 0
  8740. // item_id = item.ItemId
  8741. // project_id = 0
  8742. // }
  8743. //
  8744. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  8745. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  8746. // pric, _ := strconv.ParseFloat(item.Price, 32)
  8747. //
  8748. // info := &models.HisOrderInfo{
  8749. // OrderNumber: order.Number,
  8750. // UploadDate: time.Now().Unix(),
  8751. // AdviceId: advice_id,
  8752. // DetItemFeeSumamt: detItemFeeSumamt,
  8753. // Cnt: cut,
  8754. // Pric: pric,
  8755. // PatientId: id,
  8756. // Status: 1,
  8757. // Mtime: time.Now().Unix(),
  8758. // Ctime: time.Now().Unix(),
  8759. // UserOrgId: adminUser.CurrentOrgId,
  8760. // HisPatientId: his.ID,
  8761. // OrderId: order.ID,
  8762. // ProjectId: project_id,
  8763. // Type: types,
  8764. // ItemId: item_id,
  8765. // }
  8766. // service.CreateOrderInfo(info)
  8767. // }
  8768. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8769. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8770. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  8771. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8772. // if err == nil {
  8773. // c.ServeSuccessJSON(map[string]interface{}{
  8774. // "msg": "结算成功",
  8775. // })
  8776. // } else {
  8777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8778. // return
  8779. // }
  8780. // }
  8781. //}
  8782. //上传明细-预结算-
  8783. func (c *HisApiController) GetPreUploadInfo() {
  8784. id, _ := c.GetInt64("id")
  8785. record_time := c.GetString("record_time")
  8786. his_patient_id, _ := c.GetInt64("his_patient_id")
  8787. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8788. admin_user_id, _ := c.GetInt64("admin_user_id")
  8789. diagnosis_id := c.GetString("diagnosis")
  8790. sick_type, _ := c.GetInt64("sick_type")
  8791. reg_type, _ := c.GetInt64("p_type")
  8792. begin_time := c.GetString("begin_time")
  8793. id_str := c.GetString("ids")
  8794. ids_arr := strings.Split(id_str, ",")
  8795. timeLayout := "2006-01-02"
  8796. loc, _ := time.LoadLocation("Local")
  8797. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8798. if err != nil {
  8799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8800. return
  8801. }
  8802. recordDateTime := theTime.Unix()
  8803. adminUser := c.GetAdminUserInfo()
  8804. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8805. var config []*models.HisXtDiagnoseConfig
  8806. for _, item := range diagnosis_ids {
  8807. id, _ := strconv.ParseInt(item, 10, 64)
  8808. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8809. config = append(config, &diagnosisConfig)
  8810. }
  8811. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8812. sickConfig, _ := service.FindSickById(sick_type)
  8813. var prescriptions []*models.HisPrescription
  8814. var start_time int64
  8815. var end_time int64
  8816. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8817. fmt.Println(his_patient_id)
  8818. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8819. timestamp := time.Now().Unix()
  8820. tempTime := time.Unix(timestamp, 0)
  8821. timeFormat := tempTime.Format("20060102150405")
  8822. chrgBchno := rand.Intn(100000) + 10000
  8823. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8824. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8825. var patientPrescription models.HisPrescriptionInfo
  8826. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8827. if patientPrescription.ID == 0 {
  8828. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8829. }
  8830. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8831. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8832. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8833. strconv.FormatInt(his.PatientId, 10)
  8834. var res2 ResultSix
  8835. var resSix10265 ResultSix10265
  8836. //var time_stamp string
  8837. if miConfig.MdtrtareaAdmvs == "421300" {
  8838. data := make(map[string]interface{})
  8839. client := &http.Client{}
  8840. data["psn_no"] = his.PsnNo
  8841. data["mdtrt_id"] = his.Number
  8842. data["department"] = department.Name
  8843. data["org_name"] = miConfig.OrgName
  8844. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8845. data["doctor_id"] = doctor_info.DoctorNumber
  8846. data["doctor_name"] = roles.UserName
  8847. data["fixmedins_code"] = miConfig.Code
  8848. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8849. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8850. data["secret_key"] = miConfig.SecretKey
  8851. data["sick_code"] = sickConfig.CountryCode
  8852. data["sick_name"] = sickConfig.ClassName
  8853. data["begin_time"] = begin_time
  8854. data["dept"] = strconv.FormatInt(department.ID, 10)
  8855. data["config"] = config
  8856. data["opter"] = roles.UserName
  8857. fmt.Println(data)
  8858. bytesData, _ := json.Marshal(data)
  8859. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8860. resp, _ := client.Do(req)
  8861. defer resp.Body.Close()
  8862. body, ioErr := ioutil.ReadAll(resp.Body)
  8863. if ioErr != nil {
  8864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. var respJSON map[string]interface{}
  8869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8875. userJSONBytes, _ := json.Marshal(respJSON)
  8876. fmt.Println("log")
  8877. fmt.Println(string(userJSONBytes))
  8878. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8879. utils.ErrorLog("解析失败:%v", err)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8884. data := make(map[string]interface{})
  8885. client := &http.Client{}
  8886. data["psn_no"] = his.PsnNo
  8887. data["mdtrt_id"] = his.Number
  8888. data["doctor"] = roles.UserName
  8889. data["department"] = department.Name
  8890. data["org_name"] = miConfig.OrgName
  8891. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8892. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  8893. data["fixmedins_code"] = miConfig.Code
  8894. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8895. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8896. data["secret_key"] = miConfig.SecretKey
  8897. data["sick_code"] = sickConfig.CountryCode
  8898. data["sick_name"] = sickConfig.ClassName
  8899. data["begin_time"] = begin_time
  8900. data["dept"] = strconv.FormatInt(department.ID, 10)
  8901. data["config"] = config
  8902. data["url"] = miConfig.Url
  8903. data["ak"] = miConfig.AccessKey
  8904. data["cainfo"] = miConfig.Cainfo
  8905. bytesData, _ := json.Marshal(data)
  8906. var req *http.Request
  8907. if miConfig.MdtrtareaAdmvs == "320921" {
  8908. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8909. } else {
  8910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8911. }
  8912. resp, _ := client.Do(req)
  8913. defer resp.Body.Close()
  8914. body, ioErr := ioutil.ReadAll(resp.Body)
  8915. if ioErr != nil {
  8916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8918. return
  8919. }
  8920. var respJSON map[string]interface{}
  8921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. return
  8925. }
  8926. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  8927. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  8928. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  8929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8930. userJSONBytes, _ := json.Marshal(respJSON)
  8931. fmt.Println("log")
  8932. fmt.Println(string(userJSONBytes))
  8933. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8934. utils.ErrorLog("解析失败:%v", err)
  8935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8936. return
  8937. }
  8938. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8939. res2.Output = resSix10265.Output
  8940. res2.ErrMsg = resSix10265.ErrMsg
  8941. res2.Cainfo = resSix10265.Cainfo
  8942. res2.WarnMsg = resSix10265.WarnMsg
  8943. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8944. res2.Infcode = infocode
  8945. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8946. 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)
  8947. saveLog(result, requestLog, "2203", "上传就诊信息")
  8948. var respJSON2 map[string]interface{}
  8949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. userJSONBytes2, _ := json.Marshal(respJSON2)
  8955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8956. utils.ErrorLog("解析失败:%v", err)
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8958. return
  8959. }
  8960. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8961. var result string
  8962. var requestLog string
  8963. 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, "")
  8964. saveLog(result, requestLog, "2203", "上传就诊信息")
  8965. var respJSON2 map[string]interface{}
  8966. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8969. return
  8970. }
  8971. userJSONBytes2, _ := json.Marshal(respJSON2)
  8972. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8973. utils.ErrorLog("解析失败:%v", err)
  8974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8975. return
  8976. }
  8977. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8978. var result string
  8979. var requestLog string
  8980. 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, "")
  8981. saveLog(result, requestLog, "2203", "上传就诊信息")
  8982. var respJSON2 map[string]interface{}
  8983. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8986. return
  8987. }
  8988. userJSONBytes2, _ := json.Marshal(respJSON2)
  8989. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8990. utils.ErrorLog("解析失败:%v", err)
  8991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8992. return
  8993. }
  8994. } else {
  8995. var result string
  8996. var requestLog string
  8997. if miConfig.MdtrtareaAdmvs == "440781" { //
  8998. 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)
  8999. } else {
  9000. if miConfig.Code == "H15049901371" {
  9001. //赤峰地区国家医保医疗类别
  9002. //职工透析:医疗类别选特殊情况门诊990502
  9003. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9004. var med_type string
  9005. if his.Insutype == "390" {
  9006. if reg_type == 14 {
  9007. med_type = "9933"
  9008. } else if reg_type == 11 {
  9009. med_type = "11"
  9010. }
  9011. } else if his.Insutype == "310" {
  9012. if reg_type == 14 {
  9013. med_type = "990502"
  9014. } else if reg_type == 11 {
  9015. med_type = "11"
  9016. }
  9017. }
  9018. 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)
  9019. } else {
  9020. 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)
  9021. }
  9022. saveLog(result, requestLog, "2203", "上传就诊信息")
  9023. var respJSON2 map[string]interface{}
  9024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9027. return
  9028. }
  9029. userJSONBytes2, _ := json.Marshal(respJSON2)
  9030. if miConfig.Code == "H15049901371" {
  9031. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9032. utils.ErrorLog("解析失败:%v", err)
  9033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9034. return
  9035. }
  9036. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9037. res2.Output = resSix10265.Output
  9038. res2.ErrMsg = resSix10265.ErrMsg
  9039. res2.Cainfo = resSix10265.Cainfo
  9040. res2.WarnMsg = resSix10265.WarnMsg
  9041. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9042. res2.Infcode = infocode
  9043. } else {
  9044. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9045. utils.ErrorLog("解析失败:%v", err)
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. return
  9048. }
  9049. }
  9050. }
  9051. }
  9052. if res2.Infcode != 0 {
  9053. adminUser := c.GetAdminUserInfo()
  9054. errlog := &models.HisOrderError{
  9055. UserOrgId: adminUser.CurrentOrgId,
  9056. Ctime: time.Now().Unix(),
  9057. Mtime: time.Now().Unix(),
  9058. ErrMsg: res2.ErrMsg,
  9059. Status: 1,
  9060. PatientId: id,
  9061. RecordTime: recordDateTime,
  9062. Stage: 3,
  9063. }
  9064. service.CreateErrMsgLog(errlog)
  9065. c.ServeSuccessJSON(map[string]interface{}{
  9066. "failed_code": -10,
  9067. "msg": res2.ErrMsg,
  9068. })
  9069. return
  9070. } else {
  9071. his.Diagnosis = diagnosis_id
  9072. his.SickType = sickConfig.ID
  9073. his.PType = fmt.Sprintf("%d", reg_type)
  9074. service.UpdateHisPatientThree(&his)
  9075. data := make(map[string]interface{})
  9076. if settle_accounts_type == 1 { //日结
  9077. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9078. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9079. } else {
  9080. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9081. }
  9082. data["pre"] = prescriptions
  9083. } else { //月结
  9084. start_time_str := c.GetString("start_time")
  9085. end_time_str := c.GetString("end_time")
  9086. timeLayout := "2006-01-02"
  9087. loc, _ := time.LoadLocation("Local")
  9088. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9089. if err != nil {
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9091. return
  9092. }
  9093. recordStartTime := theStartTime.Unix()
  9094. start_time = recordStartTime
  9095. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9096. if err != nil {
  9097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9098. return
  9099. }
  9100. recordEndTime := theEndTime.Unix()
  9101. end_time = recordEndTime
  9102. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9103. data["pre"] = prescriptions
  9104. }
  9105. client := &http.Client{}
  9106. data["psn_no"] = his.PsnNo
  9107. data["mdtrt_id"] = his.Number
  9108. data["chrg_bchno"] = chrg_bchno
  9109. data["org_name"] = miConfig.OrgName
  9110. data["doctor"] = doctor_info.UserName
  9111. data["doctor_id"] = doctor_info.DoctorNumber
  9112. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9113. data["fixmedins_code"] = miConfig.Code
  9114. data["opter"] = roles.UserName
  9115. data["dept_code"] = department.Number
  9116. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9117. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9118. data["secret_key"] = miConfig.SecretKey
  9119. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9120. data["url"] = miConfig.Url
  9121. data["ak"] = miConfig.AccessKey
  9122. data["new_doctor_name"] = patientPrescription.Doctor
  9123. data["diag_code"] = sickConfig.CountryCode
  9124. data["cainfo"] = miConfig.Cainfo
  9125. data["opter"] = roles.UserName
  9126. var ids []int64
  9127. for _, item := range prescriptions {
  9128. ids = append(ids, item.ID)
  9129. }
  9130. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9131. if config.IsOpen == 1 { //对接了医保,走医保流程
  9132. var res ResultFour
  9133. var resFour10265 ResultFour10265
  9134. if miConfig.MdtrtareaAdmvs == "421300" {
  9135. bytesData, _ := json.Marshal(data)
  9136. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9137. resp, _ := client.Do(req)
  9138. defer resp.Body.Close()
  9139. body, ioErr := ioutil.ReadAll(resp.Body)
  9140. if ioErr != nil {
  9141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9143. return
  9144. }
  9145. var respJSON map[string]interface{}
  9146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9149. return
  9150. }
  9151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9152. userJSONBytes, _ := json.Marshal(respJSON)
  9153. fmt.Println("log")
  9154. fmt.Println(string(userJSONBytes))
  9155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9156. utils.ErrorLog("解析失败:%v", err)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9161. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9162. if result3101.Infcode == "0" {
  9163. if len(result3101.Output.Result) > 0 {
  9164. var errMsgs []string
  9165. for _, item := range result3101.Output.Result {
  9166. errMsgs = append(errMsgs, item.VolaCont)
  9167. }
  9168. c.ServeSuccessJSON(map[string]interface{}{
  9169. "failed_code": -10,
  9170. "msg": errMsgs,
  9171. })
  9172. return
  9173. } else {
  9174. bytesData, _ := json.Marshal(data)
  9175. var req *http.Request
  9176. if miConfig.MdtrtareaAdmvs == "320921" {
  9177. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9178. } else {
  9179. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9180. }
  9181. resp, _ := client.Do(req)
  9182. defer resp.Body.Close()
  9183. body, ioErr := ioutil.ReadAll(resp.Body)
  9184. if ioErr != nil {
  9185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9187. return
  9188. }
  9189. var respJSON map[string]interface{}
  9190. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9193. return
  9194. }
  9195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9196. userJSONBytes, _ := json.Marshal(respJSON)
  9197. fmt.Println("log")
  9198. fmt.Println(string(userJSONBytes))
  9199. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9200. utils.ErrorLog("解析失败:%v", err)
  9201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9202. return
  9203. }
  9204. res.InfRefmsgid = resFour10265.InfRefmsgid
  9205. res.Output = resFour10265.Output
  9206. res.ErrMsg = resFour10265.ErrMsg
  9207. res.Cainfo = resFour10265.Cainfo
  9208. res.WarnMsg = resFour10265.WarnMsg
  9209. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9210. res.Infcode = infocode
  9211. }
  9212. }
  9213. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9214. 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)
  9215. var dat map[string]interface{}
  9216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9217. fmt.Println(dat)
  9218. } else {
  9219. fmt.Println(err)
  9220. }
  9221. saveLog(result, request_log, "2204", "上传费用明细")
  9222. userJSONBytes, _ := json.Marshal(dat)
  9223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9224. utils.ErrorLog("解析失败:%v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9229. 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, "", "")
  9230. var dat map[string]interface{}
  9231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9232. fmt.Println(dat)
  9233. } else {
  9234. fmt.Println(err)
  9235. }
  9236. saveLog(result, request_log, "2204", "上传费用明细")
  9237. userJSONBytes, _ := json.Marshal(dat)
  9238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9239. utils.ErrorLog("解析失败:%v", err)
  9240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9241. return
  9242. }
  9243. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9244. 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, "", "")
  9245. var dat map[string]interface{}
  9246. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9247. fmt.Println(dat)
  9248. } else {
  9249. fmt.Println(err)
  9250. }
  9251. saveLog(result, request_log, "2204", "上传费用明细")
  9252. userJSONBytes, _ := json.Marshal(dat)
  9253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9254. utils.ErrorLog("解析失败:%v", err)
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9256. return
  9257. }
  9258. } else {
  9259. if miConfig.Code == "H15049901371" {
  9260. 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)
  9261. var dat map[string]interface{}
  9262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9263. fmt.Println(dat)
  9264. } else {
  9265. fmt.Println(err)
  9266. }
  9267. saveLog(result, request_log, "2204", "上传费用明细")
  9268. userJSONBytes, _ := json.Marshal(dat)
  9269. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9270. utils.ErrorLog("解析失败:%v", err)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. res.InfRefmsgid = resFour10265.InfRefmsgid
  9275. res.Output = resFour10265.Output
  9276. res.ErrMsg = resFour10265.ErrMsg
  9277. res.Cainfo = resFour10265.Cainfo
  9278. res.WarnMsg = resFour10265.WarnMsg
  9279. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9280. res.Infcode = infocode
  9281. } else {
  9282. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  9283. var dat map[string]interface{}
  9284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9285. fmt.Println(dat)
  9286. } else {
  9287. fmt.Println(err)
  9288. }
  9289. saveLog(result, request_log, "2204", "上传费用明细")
  9290. userJSONBytes, _ := json.Marshal(dat)
  9291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9292. utils.ErrorLog("解析失败:%v", err)
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9294. return
  9295. }
  9296. }
  9297. }
  9298. if res.Infcode == 0 {
  9299. order := &models.HisOrder{
  9300. UserOrgId: adminUser.CurrentOrgId,
  9301. HisPatientId: his.ID,
  9302. PatientId: his.PatientId,
  9303. SettleAccountsDate: recordDateTime,
  9304. Ctime: time.Now().Unix(),
  9305. Mtime: time.Now().Unix(),
  9306. MdtrtId: his.Number,
  9307. PsnNo: his.PsnNo,
  9308. MedType: strconv.FormatInt(reg_type, 10),
  9309. Status: 1,
  9310. Number: chrg_bchno,
  9311. Infcode: res.Infcode,
  9312. WarnMsg: res.WarnMsg,
  9313. Cainfo: res.Cainfo,
  9314. ErrMsg: res.ErrMsg,
  9315. RespondTime: res.RefmsgTime,
  9316. InfRefmsgid: res.InfRefmsgid,
  9317. OrderStatus: 1,
  9318. IsMedicineInsurance: 1,
  9319. SettleType: settle_accounts_type,
  9320. SettleStartTime: start_time,
  9321. SettleEndTime: end_time,
  9322. Creator: roles.AdminUserId,
  9323. Modify: roles.AdminUserId,
  9324. PType: 2,
  9325. Diagnosis: diagnosis_id,
  9326. }
  9327. err = service.CreateOrder(order)
  9328. if err != nil {
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9330. return
  9331. }
  9332. for _, item := range res.Output.Result {
  9333. temp := strings.Split(item.FeedetlSn, "-")
  9334. var advice_id int64 = 0
  9335. var project_id int64 = 0
  9336. var types int64 = 0
  9337. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9338. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9339. if temp[1] == "1" {
  9340. advice_id = id
  9341. project_id = 0
  9342. } else if temp[1] == "2" {
  9343. advice_id = 0
  9344. project_id = id
  9345. }
  9346. info := &models.HisOrderInfo{
  9347. OrderNumber: order.Number,
  9348. FeedetlSn: item.FeedetlSn,
  9349. UploadDate: time.Now().Unix(),
  9350. AdviceId: advice_id,
  9351. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9352. Cnt: item.Cnt,
  9353. Pric: float64(item.Pric),
  9354. PatientId: his.PatientId,
  9355. PricUplmtAmt: item.PricUplmtAmt,
  9356. SelfpayProp: item.SelfpayProp,
  9357. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9358. OverlmtAmt: item.OverlmtAmt,
  9359. PreselfpayAmt: item.PreselfpayAmt,
  9360. BasMednFlag: item.BasMednFlag,
  9361. MedChrgitmType: item.MedChrgitmType,
  9362. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9363. Status: 1,
  9364. Memo: item.Memo,
  9365. Mtime: time.Now().Unix(),
  9366. InscpScpAmt: item.InscpScpAmt,
  9367. DrtReimFlag: item.DrtReimFlag,
  9368. Ctime: time.Now().Unix(),
  9369. ListSpItemFlag: item.ListSpItemFlag,
  9370. ChldMedcFlag: item.ChldMedcFlag,
  9371. LmtUsedFlag: item.LmtUsedFlag,
  9372. ChrgitmLv: item.ChrgitmLv,
  9373. UserOrgId: adminUser.CurrentOrgId,
  9374. HisPatientId: his.ID,
  9375. OrderId: order.ID,
  9376. ProjectId: project_id,
  9377. Type: types,
  9378. }
  9379. service.CreateOrderInfo(info)
  9380. }
  9381. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9382. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9383. var total float64
  9384. for _, item := range prescriptions {
  9385. if item.Type == 1 { //药品
  9386. for _, subItem := range item.HisDoctorAdviceInfo {
  9387. total = total + (subItem.Price * subItem.PrescribingNumber)
  9388. }
  9389. }
  9390. if item.Type == 2 { //项目
  9391. for _, subItem := range item.HisPrescriptionProject {
  9392. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9393. total = total + (subItem.Price * cnt)
  9394. }
  9395. }
  9396. }
  9397. for _, item := range prescriptions {
  9398. for _, subItem := range item.HisAdditionalCharge {
  9399. total = total + (subItem.Price * float64(subItem.Count))
  9400. }
  9401. }
  9402. allTotal := fmt.Sprintf("%.4f", total)
  9403. if res.Infcode == 0 {
  9404. var rf []*ResultFive
  9405. json.Unmarshal([]byte(his.Iinfo), &rf)
  9406. chrg_bchno := chrg_bchno
  9407. cert_no := his.Certno
  9408. var insutypes []string
  9409. var insutype string
  9410. var is390 int = 0
  9411. var is310 int = 0
  9412. for _, item := range rf {
  9413. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9414. insutypes = append(insutypes, item.Insutype)
  9415. }
  9416. }
  9417. if len(insutypes) == 1 {
  9418. insutype = insutypes[0]
  9419. } else {
  9420. for _, i := range insutypes {
  9421. if i == "390" {
  9422. is390 = 1
  9423. }
  9424. if i == "310" {
  9425. is310 = 1
  9426. }
  9427. }
  9428. }
  9429. if is390 == 1 {
  9430. insutype = "390"
  9431. }
  9432. if is310 == 1 {
  9433. insutype = "310"
  9434. }
  9435. if len(insutypes) == 0 {
  9436. insutype = "310"
  9437. }
  9438. if len(insutypes) == 2 {
  9439. insutype = strconv.FormatInt(his.SocialType, 64)
  9440. }
  9441. //insutype = "390"
  9442. if his.IdCardType == 1 {
  9443. cert_no = his.MedicalInsuranceNumber
  9444. } else {
  9445. cert_no = his.Certno
  9446. }
  9447. var res ResultSeven
  9448. var resSeven10265 ResultSeven10265
  9449. if miConfig.MdtrtareaAdmvs == "421300" {
  9450. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9451. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9452. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9453. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9454. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9455. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9456. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9457. resp, requestErr := http.Get(api)
  9458. if requestErr != nil {
  9459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9460. return
  9461. }
  9462. body, ioErr := ioutil.ReadAll(resp.Body)
  9463. if ioErr != nil {
  9464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9466. return
  9467. }
  9468. var respJSON map[string]interface{}
  9469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9475. result, _ := json.Marshal(respJSON)
  9476. fmt.Println("log")
  9477. fmt.Println(string(result))
  9478. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9479. utils.ErrorLog("解析失败:%v", err)
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9484. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9485. if result3101.Infcode == "0" {
  9486. if len(result3101.Output.Result) > 0 {
  9487. var errMsgs []string
  9488. for _, item := range result3101.Output.Result {
  9489. errMsgs = append(errMsgs, item.VolaCont)
  9490. }
  9491. c.ServeSuccessJSON(map[string]interface{}{
  9492. "failed_code": -10,
  9493. "msg": errMsgs,
  9494. })
  9495. return
  9496. } else {
  9497. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9498. if his.IdCardType != 4 {
  9499. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9500. bas := strings.Split(psn_info.CardInfo, "|")
  9501. if his.IdCardType == 1 {
  9502. cert_no = bas[2]
  9503. } else {
  9504. cert_no = bas[1]
  9505. }
  9506. } else {
  9507. cert_no = his.Certno
  9508. }
  9509. //江苏地区国家医保医疗类别
  9510. //职工透析:医疗类别选特殊情况门诊9933
  9511. //居民血透门慢: 医疗类别选门诊慢病1402
  9512. //var med_type string
  9513. //if his.Insutype == "310" {
  9514. // if reg_type == 14 {
  9515. // med_type = "9933"
  9516. // } else if reg_type == 11 {
  9517. // med_type = "11"
  9518. //
  9519. // }
  9520. //} else if his.Insutype == "390" {
  9521. // if reg_type == 14 {
  9522. // med_type = "1402"
  9523. // } else if reg_type == 11 {
  9524. // med_type = "11"
  9525. // }
  9526. //}
  9527. var api string
  9528. if miConfig.MdtrtareaAdmvs == "320921" {
  9529. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9530. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9531. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9532. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9533. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9534. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9535. "&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
  9536. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9537. } else {
  9538. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9539. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9540. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9541. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9542. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9543. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9544. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9545. "&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
  9546. }
  9547. resp, requestErr := http.Get(api)
  9548. if requestErr != nil {
  9549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. return
  9551. }
  9552. body, ioErr := ioutil.ReadAll(resp.Body)
  9553. if ioErr != nil {
  9554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9556. return
  9557. }
  9558. var respJSON map[string]interface{}
  9559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9562. return
  9563. }
  9564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9565. result, _ := json.Marshal(respJSON)
  9566. fmt.Println("log")
  9567. fmt.Println(string(result))
  9568. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9569. utils.ErrorLog("解析失败:%v", err)
  9570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. return
  9572. }
  9573. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9574. res.Output = resSeven10265.Output
  9575. res.ErrMsg = resSeven10265.ErrMsg
  9576. res.Cainfo = resSeven10265.Cainfo
  9577. res.WarnMsg = resSeven10265.WarnMsg
  9578. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9579. res.Infcode = infocode
  9580. }
  9581. }
  9582. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9583. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9584. var result string
  9585. var request_log string
  9586. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  9587. 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)
  9588. } else {
  9589. 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)
  9590. }
  9591. var dat map[string]interface{}
  9592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9593. fmt.Println(dat)
  9594. } else {
  9595. fmt.Println(err)
  9596. }
  9597. saveLog(result, request_log, "2206", "预结算")
  9598. userJSONBytes, _ := json.Marshal(dat)
  9599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9600. utils.ErrorLog("解析失败:%v", err)
  9601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9602. return
  9603. }
  9604. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9605. var result string
  9606. var request_log string
  9607. if his.IdCardType == 2 {
  9608. 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, "")
  9609. } else if his.IdCardType == 1 {
  9610. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9611. bas := strings.Split(psn_info.CardInfo, "|")
  9612. basNumber := bas[2]
  9613. card_sn := bas[3]
  9614. 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)
  9615. } else {
  9616. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9617. 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, "")
  9618. }
  9619. var dat map[string]interface{}
  9620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9621. fmt.Println(dat)
  9622. } else {
  9623. fmt.Println(err)
  9624. }
  9625. saveLog(result, request_log, "2206", "预结算")
  9626. userJSONBytes, _ := json.Marshal(dat)
  9627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9628. utils.ErrorLog("解析失败:%v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9633. var result string
  9634. var request_log string
  9635. if his.IdCardType == 2 {
  9636. 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, "")
  9637. } else if his.IdCardType == 1 {
  9638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9639. bas := strings.Split(psn_info.CardInfo, "|")
  9640. basNumber := bas[2]
  9641. card_sn := bas[3]
  9642. 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)
  9643. } else {
  9644. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9645. 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, "")
  9646. }
  9647. var dat map[string]interface{}
  9648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9649. fmt.Println(dat)
  9650. } else {
  9651. fmt.Println(err)
  9652. }
  9653. saveLog(result, request_log, "2206", "预结算")
  9654. userJSONBytes, _ := json.Marshal(dat)
  9655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9656. utils.ErrorLog("解析失败:%v", err)
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9658. return
  9659. }
  9660. } else {
  9661. var result string
  9662. var request_log string
  9663. if miConfig.Code == "H15049901371" {
  9664. //赤峰地区国家医保医疗类别
  9665. //职工透析:医疗类别选特殊情况门诊990502
  9666. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9667. var med_type string
  9668. if his.Insutype == "390" {
  9669. if reg_type == 14 {
  9670. med_type = "9933"
  9671. } else if reg_type == 11 {
  9672. med_type = "11"
  9673. }
  9674. } else if his.Insutype == "310" {
  9675. if reg_type == 14 {
  9676. med_type = "990502"
  9677. } else if reg_type == 11 {
  9678. med_type = "11"
  9679. }
  9680. }
  9681. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  9682. } else {
  9683. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9684. if his.IdCardType == 4 {
  9685. 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)
  9686. } else {
  9687. 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)
  9688. }
  9689. }
  9690. var dat map[string]interface{}
  9691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9692. fmt.Println(dat)
  9693. } else {
  9694. fmt.Println(err)
  9695. }
  9696. saveLog(result, request_log, "2206", "预结算")
  9697. //userJSONBytes, _ := json.Marshal(dat)
  9698. //
  9699. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9700. // utils.ErrorLog("解析失败:%v", err)
  9701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9702. // return
  9703. //}
  9704. userJSONBytes, _ := json.Marshal(dat)
  9705. if miConfig.Code == "H15049901371" {
  9706. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9707. utils.ErrorLog("解析失败:%v", err)
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9709. return
  9710. }
  9711. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9712. res.Output = resSeven10265.Output
  9713. res.ErrMsg = resSeven10265.ErrMsg
  9714. res.Cainfo = resSeven10265.Cainfo
  9715. res.WarnMsg = resSeven10265.WarnMsg
  9716. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9717. res.Infcode = infocode
  9718. } else {
  9719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9720. utils.ErrorLog("解析失败:%v", err)
  9721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9722. return
  9723. }
  9724. }
  9725. }
  9726. if res.Infcode != 0 {
  9727. errlog := &models.HisOrderError{
  9728. UserOrgId: adminUser.CurrentOrgId,
  9729. Ctime: time.Now().Unix(),
  9730. Mtime: time.Now().Unix(),
  9731. Number: chrg_bchno,
  9732. ErrMsg: res.ErrMsg,
  9733. Status: 1,
  9734. PatientId: id,
  9735. RecordTime: recordDateTime,
  9736. Stage: 20,
  9737. }
  9738. service.CreateErrMsgLog(errlog)
  9739. c.ServeSuccessJSON(map[string]interface{}{
  9740. "failed_code": -10,
  9741. "msg": res.ErrMsg,
  9742. })
  9743. return
  9744. } else {
  9745. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9746. order.OrderStatus = 1
  9747. order.IsPre = 1
  9748. order.Status = 1
  9749. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9750. order.SetlId = res.Output.Setlinfo.SetlID
  9751. order.PsnNo = res.Output.Setlinfo.PsnNo
  9752. order.PsnName = res.Output.Setlinfo.PsnName
  9753. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9754. order.Certno = res.Output.Setlinfo.Certno
  9755. order.Gend = res.Output.Setlinfo.Gend
  9756. order.Naty = res.Output.Setlinfo.Naty
  9757. order.Age = res.Output.Setlinfo.Age
  9758. order.Insutype = res.Output.Setlinfo.Insutype
  9759. order.PsnType = res.Output.Setlinfo.PsnType
  9760. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9761. order.SetlTime = res.Output.Setlinfo.SetlTime
  9762. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9763. if res.Output.Setlinfo.MedType == "140101" {
  9764. order.MedType = "14"
  9765. } else {
  9766. order.MedType = res.Output.Setlinfo.MedType
  9767. }
  9768. if reg_type == 1112 {
  9769. order.MedType = "1112"
  9770. }
  9771. if reg_type == 1111 {
  9772. order.MedType = "1111"
  9773. }
  9774. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9775. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9776. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9777. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9778. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9779. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9780. order.HifpPay = res.Output.Setlinfo.HifpPay
  9781. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9782. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9783. order.HifesPay = res.Output.Setlinfo.HifesPay
  9784. order.HifobPay = res.Output.Setlinfo.HifobPay
  9785. order.MafPay = res.Output.Setlinfo.MafPay
  9786. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9787. order.OthPay = res.Output.Setlinfo.OthPay
  9788. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9789. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9790. order.AcctPay = res.Output.Setlinfo.AcctPay
  9791. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9792. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9793. order.Balc = res.Output.Setlinfo.Balc
  9794. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9795. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9796. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9797. order.ClrWay = res.Output.Setlinfo.ClrWay
  9798. order.Creator = order.Creator
  9799. order.Modify = roles.AdminUserId
  9800. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9801. detailStr := string(setlDetail)
  9802. order.SetlDetail = detailStr
  9803. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9804. err = service.UpDateOrder(order)
  9805. if err == nil {
  9806. c.ServeSuccessJSON(map[string]interface{}{
  9807. "msg": "预结算成功",
  9808. })
  9809. } else {
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9811. return
  9812. }
  9813. }
  9814. } else {
  9815. adminUser := c.GetAdminUserInfo()
  9816. errlog := &models.HisOrderError{
  9817. UserOrgId: adminUser.CurrentOrgId,
  9818. Ctime: time.Now().Unix(),
  9819. Mtime: time.Now().Unix(),
  9820. ErrMsg: res.ErrMsg,
  9821. Status: 1,
  9822. PatientId: id,
  9823. RecordTime: recordDateTime,
  9824. Stage: 4,
  9825. }
  9826. service.CreateErrMsgLog(errlog)
  9827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9828. return
  9829. }
  9830. } else {
  9831. adminUser := c.GetAdminUserInfo()
  9832. errlog := &models.HisOrderError{
  9833. UserOrgId: adminUser.CurrentOrgId,
  9834. Ctime: time.Now().Unix(),
  9835. Mtime: time.Now().Unix(),
  9836. ErrMsg: res.ErrMsg,
  9837. Status: 1,
  9838. PatientId: id,
  9839. RecordTime: recordDateTime,
  9840. Stage: 4,
  9841. }
  9842. service.CreateErrMsgLog(errlog)
  9843. c.ServeSuccessJSON(map[string]interface{}{
  9844. "failed_code": -10,
  9845. "msg": res.ErrMsg,
  9846. })
  9847. return
  9848. }
  9849. }
  9850. }
  9851. }
  9852. //退款
  9853. func (c *HisApiController) Refund() {
  9854. order_id, _ := c.GetInt64("order_id")
  9855. admin_user_id, _ := c.GetInt64("admin_user_id")
  9856. adminUser := c.GetAdminUserInfo()
  9857. var order models.HisOrder
  9858. order, _ = service.GetHisOrderByID(order_id)
  9859. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9860. if order.ID == 0 {
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9862. return
  9863. }
  9864. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9867. if config.IsOpen == 1 { //对接了医保,走医保流程
  9868. var res ResultSixteen
  9869. var resSixteen10265 ResultSixteen10265
  9870. var src_resquest string
  9871. var result string
  9872. if miConfig.MdtrtareaAdmvs == "421300" {
  9873. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  9874. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9875. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9876. resp3, requestErr3 := http.Get(api3)
  9877. if requestErr3 != nil {
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9879. return
  9880. }
  9881. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9882. if ioErr3 != nil {
  9883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9885. return
  9886. }
  9887. var respJSON3 map[string]interface{}
  9888. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9891. return
  9892. }
  9893. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9894. userJSONBytes3, _ := json.Marshal(respJSON3)
  9895. fmt.Println("log")
  9896. fmt.Println(string(userJSONBytes3))
  9897. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  9898. utils.ErrorLog("解析失败:%v", err)
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9900. return
  9901. }
  9902. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9903. var api3 string
  9904. if miConfig.MdtrtareaAdmvs == "320921" {
  9905. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  9906. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9908. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9909. } else {
  9910. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9911. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  9912. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9913. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9914. }
  9915. resp3, requestErr3 := http.Get(api3)
  9916. if requestErr3 != nil {
  9917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9918. return
  9919. }
  9920. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9921. if ioErr3 != nil {
  9922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9924. return
  9925. }
  9926. var respJSON3 map[string]interface{}
  9927. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9930. return
  9931. }
  9932. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9933. userJSONBytes3, _ := json.Marshal(respJSON3)
  9934. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  9935. utils.ErrorLog("解析失败:%v", err)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  9940. res.Output = resSixteen10265.Output
  9941. res.ErrMsg = resSixteen10265.ErrMsg
  9942. res.Cainfo = resSixteen10265.Cainfo
  9943. res.WarnMsg = resSixteen10265.WarnMsg
  9944. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  9945. res.Infcode = infocode
  9946. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9947. 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)
  9948. var dat map[string]interface{}
  9949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9950. fmt.Println(dat)
  9951. } else {
  9952. fmt.Println(err)
  9953. }
  9954. saveLog(result, src_resquest, "2208", "退费")
  9955. userJSONBytes, _ := json.Marshal(dat)
  9956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9957. utils.ErrorLog("解析失败:%v", err)
  9958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9959. return
  9960. }
  9961. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9962. 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, "")
  9963. var dat map[string]interface{}
  9964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9965. fmt.Println(dat)
  9966. } else {
  9967. fmt.Println(err)
  9968. }
  9969. saveLog(result, src_resquest, "2208", "退费")
  9970. userJSONBytes, _ := json.Marshal(dat)
  9971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9972. utils.ErrorLog("解析失败:%v", err)
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9974. return
  9975. }
  9976. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9977. 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, "")
  9978. var dat map[string]interface{}
  9979. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9980. fmt.Println(dat)
  9981. } else {
  9982. fmt.Println(err)
  9983. }
  9984. saveLog(result, src_resquest, "2208", "退费")
  9985. userJSONBytes, _ := json.Marshal(dat)
  9986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9987. utils.ErrorLog("解析失败:%v", err)
  9988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9989. return
  9990. }
  9991. } else {
  9992. if miConfig.Code == "H15049901371" {
  9993. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  9994. var dat map[string]interface{}
  9995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9996. fmt.Println(dat)
  9997. } else {
  9998. fmt.Println(err)
  9999. }
  10000. saveLog(result, src_resquest, "2208", "退费")
  10001. userJSONBytes, _ := json.Marshal(dat)
  10002. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10003. utils.ErrorLog("解析失败:%v", err)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10008. res.Output = resSixteen10265.Output
  10009. res.ErrMsg = resSixteen10265.ErrMsg
  10010. res.Cainfo = resSixteen10265.Cainfo
  10011. res.WarnMsg = resSixteen10265.WarnMsg
  10012. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10013. res.Infcode = infocode
  10014. } else {
  10015. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10016. var dat map[string]interface{}
  10017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10018. fmt.Println(dat)
  10019. } else {
  10020. fmt.Println(err)
  10021. }
  10022. saveLog(result, src_resquest, "2208", "退费")
  10023. userJSONBytes, _ := json.Marshal(dat)
  10024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10025. utils.ErrorLog("解析失败:%v", err)
  10026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10027. return
  10028. }
  10029. }
  10030. }
  10031. if res.Infcode == 0 {
  10032. var res2 ResultSix
  10033. var resSix10265 ResultSix10265
  10034. if miConfig.MdtrtareaAdmvs == "421300" {
  10035. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10036. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10038. resp3, requestErr3 := http.Get(api3)
  10039. if requestErr3 != nil {
  10040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10041. return
  10042. }
  10043. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10044. if ioErr3 != nil {
  10045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. return
  10048. }
  10049. var respJSON3 map[string]interface{}
  10050. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return
  10054. }
  10055. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10056. userJSONBytes3, _ := json.Marshal(respJSON3)
  10057. fmt.Println("log")
  10058. fmt.Println(string(userJSONBytes3))
  10059. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10060. utils.ErrorLog("解析失败:%v", err)
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10062. return
  10063. }
  10064. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10065. var api3 string
  10066. if miConfig.MdtrtareaAdmvs == "320921" {
  10067. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10068. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10069. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10070. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10071. } else {
  10072. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10073. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10074. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10076. }
  10077. resp3, requestErr3 := http.Get(api3)
  10078. if requestErr3 != nil {
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10083. if ioErr3 != nil {
  10084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10086. return
  10087. }
  10088. var respJSON3 map[string]interface{}
  10089. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10092. return
  10093. }
  10094. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10095. userJSONBytes3, _ := json.Marshal(respJSON3)
  10096. fmt.Println("log")
  10097. fmt.Println(string(userJSONBytes3))
  10098. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10099. utils.ErrorLog("解析失败:%v", err)
  10100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10101. return
  10102. }
  10103. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10104. res2.Output = resSix10265.Output
  10105. res2.ErrMsg = resSix10265.ErrMsg
  10106. res2.Cainfo = resSix10265.Cainfo
  10107. res2.WarnMsg = resSix10265.WarnMsg
  10108. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10109. res2.Infcode = infocode
  10110. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10111. 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)
  10112. var dat map[string]interface{}
  10113. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10114. fmt.Println(dat)
  10115. } else {
  10116. fmt.Println(err)
  10117. }
  10118. saveLog(result2, src_request, "2205", "撤销明细")
  10119. userJSONBytes, _ := json.Marshal(dat)
  10120. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10121. utils.ErrorLog("解析失败:%v", err)
  10122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10123. return
  10124. }
  10125. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10126. 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, "")
  10127. var dat map[string]interface{}
  10128. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10129. fmt.Println(dat)
  10130. } else {
  10131. fmt.Println(err)
  10132. }
  10133. saveLog(result2, src_request, "2205", "撤销明细")
  10134. userJSONBytes, _ := json.Marshal(dat)
  10135. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10136. utils.ErrorLog("解析失败:%v", err)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10141. 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, "")
  10142. var dat map[string]interface{}
  10143. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10144. fmt.Println(dat)
  10145. } else {
  10146. fmt.Println(err)
  10147. }
  10148. saveLog(result2, src_request, "2205", "撤销明细")
  10149. userJSONBytes, _ := json.Marshal(dat)
  10150. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10151. utils.ErrorLog("解析失败:%v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. } else {
  10156. if miConfig.Code == "H15049901371" {
  10157. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10158. var dat map[string]interface{}
  10159. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10160. fmt.Println(dat)
  10161. } else {
  10162. fmt.Println(err)
  10163. }
  10164. saveLog(result2, src_request, "2205", "撤销明细")
  10165. userJSONBytes, _ := json.Marshal(dat)
  10166. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10167. utils.ErrorLog("解析失败:%v", err)
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10169. return
  10170. }
  10171. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10172. res2.Output = resSix10265.Output
  10173. res2.ErrMsg = resSix10265.ErrMsg
  10174. res2.Cainfo = resSix10265.Cainfo
  10175. res2.WarnMsg = resSix10265.WarnMsg
  10176. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10177. res2.Infcode = infocode
  10178. } else {
  10179. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10180. var dat map[string]interface{}
  10181. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10182. fmt.Println(dat)
  10183. } else {
  10184. fmt.Println(err)
  10185. }
  10186. saveLog(result2, src_request, "2205", "撤销明细")
  10187. userJSONBytes, _ := json.Marshal(dat)
  10188. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10189. utils.ErrorLog("解析失败:%v", err)
  10190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10191. return
  10192. }
  10193. }
  10194. }
  10195. if res2.Infcode == 0 {
  10196. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10197. if err == nil {
  10198. //当押金不为零时产生退费记录
  10199. if order.Decimal != 0 {
  10200. tmp := strconv.FormatInt(order.ID, 10)
  10201. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10202. if err != nil {
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10204. return
  10205. }
  10206. }
  10207. c.ServeSuccessJSON(map[string]interface{}{
  10208. "msg": "退费成功",
  10209. })
  10210. } else {
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10212. return
  10213. }
  10214. } else {
  10215. c.ServeSuccessJSON(map[string]interface{}{
  10216. "code": -10,
  10217. "msg": res2.ErrMsg,
  10218. })
  10219. }
  10220. } else {
  10221. c.ServeSuccessJSON(map[string]interface{}{
  10222. "code": -10,
  10223. "msg": res.ErrMsg,
  10224. })
  10225. }
  10226. }
  10227. }
  10228. func (c *HisApiController) RefundNumber() {
  10229. record_time := c.GetString("record_time")
  10230. //patient_id, _ := c.GetInt64("patient_id")
  10231. admin_user_id, _ := c.GetInt64("admin_user_id")
  10232. his_patient_id, _ := c.GetInt64("id")
  10233. timeLayout := "2006-01-02"
  10234. loc, _ := time.LoadLocation("Local")
  10235. adminUser := c.GetAdminUserInfo()
  10236. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10237. fmt.Println(err)
  10238. if err != nil {
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10240. return
  10241. }
  10242. recordDateTime := theTime.Unix()
  10243. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10244. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10245. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10246. //order, _ := service.GetHisOrderByID(order_id)
  10247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10248. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10249. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10250. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10251. if count > 0 {
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10253. return
  10254. }
  10255. if config.IsOpen == 1 { //对接了医保,走医保流程
  10256. var res2 ResultSix
  10257. var resSix10265 ResultSix10265
  10258. if miConfig.MdtrtareaAdmvs == "421300" {
  10259. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10260. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10261. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10262. resp3, requestErr3 := http.Get(api3)
  10263. if requestErr3 != nil {
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10265. return
  10266. }
  10267. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10268. if ioErr3 != nil {
  10269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. var respJSON3 map[string]interface{}
  10274. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10277. return
  10278. }
  10279. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10280. userJSONBytes3, _ := json.Marshal(respJSON3)
  10281. fmt.Println("log")
  10282. fmt.Println(string(userJSONBytes3))
  10283. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10284. utils.ErrorLog("解析失败:%v", err)
  10285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10286. return
  10287. }
  10288. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10289. var api3 string
  10290. if miConfig.MdtrtareaAdmvs == "320921" {
  10291. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10292. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10294. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10295. } else {
  10296. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10297. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10298. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10299. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10300. }
  10301. resp3, requestErr3 := http.Get(api3)
  10302. if requestErr3 != nil {
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10304. return
  10305. }
  10306. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10307. if ioErr3 != nil {
  10308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10310. return
  10311. }
  10312. var respJSON3 map[string]interface{}
  10313. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10319. userJSONBytes3, _ := json.Marshal(respJSON3)
  10320. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10321. utils.ErrorLog("解析失败:%v", err)
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10323. return
  10324. }
  10325. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10326. res2.Output = resSix10265.Output
  10327. res2.ErrMsg = resSix10265.ErrMsg
  10328. res2.Cainfo = resSix10265.Cainfo
  10329. res2.WarnMsg = resSix10265.WarnMsg
  10330. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10331. res2.Infcode = infocode
  10332. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10333. 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)
  10334. var dat map[string]interface{}
  10335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10336. fmt.Println(dat)
  10337. } else {
  10338. fmt.Println(err)
  10339. }
  10340. saveLog(result, request, "2202", "退号")
  10341. userJSONBytes, _ := json.Marshal(dat)
  10342. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10343. utils.ErrorLog("解析失败:%v", err)
  10344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10345. return
  10346. }
  10347. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10348. 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, "")
  10349. var dat map[string]interface{}
  10350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10351. fmt.Println(dat)
  10352. } else {
  10353. fmt.Println(err)
  10354. }
  10355. saveLog(result, request, "2202", "退号")
  10356. userJSONBytes, _ := json.Marshal(dat)
  10357. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10358. utils.ErrorLog("解析失败:%v", err)
  10359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10360. return
  10361. }
  10362. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10363. 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, "")
  10364. var dat map[string]interface{}
  10365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10366. fmt.Println(dat)
  10367. } else {
  10368. fmt.Println(err)
  10369. }
  10370. saveLog(result, request, "2202", "退号")
  10371. userJSONBytes, _ := json.Marshal(dat)
  10372. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10373. utils.ErrorLog("解析失败:%v", err)
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10375. return
  10376. }
  10377. } else {
  10378. var api3 string
  10379. if miConfig.Code == "H15049901371" {
  10380. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10381. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10383. } else {
  10384. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10385. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10386. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10387. }
  10388. resp3, requestErr3 := http.Get(api3)
  10389. if requestErr3 != nil {
  10390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10391. return
  10392. }
  10393. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10394. if ioErr3 != nil {
  10395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10397. return
  10398. }
  10399. var respJSON3 map[string]interface{}
  10400. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10403. return
  10404. }
  10405. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10406. userJSONBytes3, _ := json.Marshal(respJSON3)
  10407. if miConfig.Code == "H15049901371" {
  10408. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10409. utils.ErrorLog("解析失败:%v", err)
  10410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10411. return
  10412. }
  10413. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10414. res2.Output = resSix10265.Output
  10415. res2.ErrMsg = resSix10265.ErrMsg
  10416. res2.Cainfo = resSix10265.Cainfo
  10417. res2.WarnMsg = resSix10265.WarnMsg
  10418. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10419. res2.Infcode = infocode
  10420. } else {
  10421. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10422. utils.ErrorLog("解析失败:%v", err)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. }
  10427. }
  10428. if res2.Infcode == 0 {
  10429. if err == nil {
  10430. c.ServeSuccessJSON(map[string]interface{}{
  10431. "msg": "退号成功",
  10432. })
  10433. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10434. } else {
  10435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10436. return
  10437. }
  10438. } else {
  10439. c.ServeSuccessJSON(map[string]interface{}{
  10440. "code": -10,
  10441. "msg": res2.ErrMsg,
  10442. })
  10443. }
  10444. } else {
  10445. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10446. //if err == nil {
  10447. // c.ServeSuccessJSON(map[string]interface{}{
  10448. // "msg": "退费成功",
  10449. // })
  10450. //} else {
  10451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10452. // return
  10453. //}
  10454. }
  10455. }
  10456. func (c *HisApiController) RefundDetail() {
  10457. order_id, _ := c.GetInt64("order_id")
  10458. admin_user_id, _ := c.GetInt64("admin_user_id")
  10459. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10460. number := c.GetString("number")
  10461. record_time := c.GetString("record_time")
  10462. patient_id, _ := c.GetInt64("patient_id")
  10463. //med_type, _ := c.GetInt64("med_type")
  10464. timeLayout := "2006-01-02"
  10465. loc, _ := time.LoadLocation("Local")
  10466. adminUser := c.GetAdminUserInfo()
  10467. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10468. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10469. fmt.Println(err)
  10470. if err != nil {
  10471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10472. return
  10473. }
  10474. recordDateTime := theTime.Unix()
  10475. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10476. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10478. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10479. var order models.HisOrder
  10480. order, _ = service.GetHisOrderByID(order_id)
  10481. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10482. if config.IsOpen == 1 { //对接了医保,走医保流程
  10483. var res2 ResultSix
  10484. if miConfig.MdtrtareaAdmvs == "421300" {
  10485. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10486. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10488. resp3, requestErr3 := http.Get(api3)
  10489. if requestErr3 != nil {
  10490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10491. return
  10492. }
  10493. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10494. if ioErr3 != nil {
  10495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10497. return
  10498. }
  10499. var respJSON3 map[string]interface{}
  10500. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10503. return
  10504. }
  10505. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10506. userJSONBytes3, _ := json.Marshal(respJSON3)
  10507. fmt.Println("log")
  10508. fmt.Println(string(userJSONBytes3))
  10509. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10510. utils.ErrorLog("解析失败:%v", err)
  10511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10512. return
  10513. }
  10514. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10515. if err == nil {
  10516. c.ServeSuccessJSON(map[string]interface{}{
  10517. "msg": "撤销明细成功",
  10518. })
  10519. return
  10520. } else {
  10521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10522. return
  10523. }
  10524. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10525. var resSix10265 ResultSix10265
  10526. var api3 string
  10527. if miConfig.MdtrtareaAdmvs == "320921" {
  10528. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10529. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10530. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10531. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10532. } else {
  10533. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10534. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10535. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10537. }
  10538. resp3, requestErr3 := http.Get(api3)
  10539. if requestErr3 != nil {
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return
  10542. }
  10543. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10544. if ioErr3 != nil {
  10545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return
  10548. }
  10549. var respJSON3 map[string]interface{}
  10550. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10553. return
  10554. }
  10555. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10556. userJSONBytes3, _ := json.Marshal(respJSON3)
  10557. fmt.Println("log")
  10558. fmt.Println(string(userJSONBytes3))
  10559. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10560. utils.ErrorLog("解析失败:%v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10565. res2.Output = resSix10265.Output
  10566. res2.ErrMsg = resSix10265.ErrMsg
  10567. res2.Cainfo = resSix10265.Cainfo
  10568. res2.WarnMsg = resSix10265.WarnMsg
  10569. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10570. res2.Infcode = infocode
  10571. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10572. if err == nil {
  10573. c.ServeSuccessJSON(map[string]interface{}{
  10574. "msg": "撤销明细成功",
  10575. })
  10576. return
  10577. } else {
  10578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10579. return
  10580. }
  10581. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10582. 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)
  10583. var dat map[string]interface{}
  10584. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10585. fmt.Println(dat)
  10586. } else {
  10587. fmt.Println(err)
  10588. }
  10589. saveLog(result2, src_request, "2205", "撤销明细")
  10590. userJSONBytes, _ := json.Marshal(dat)
  10591. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10592. utils.ErrorLog("解析失败:%v", err)
  10593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10594. return
  10595. }
  10596. if res2.Infcode == 0 {
  10597. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10598. if err == nil {
  10599. c.ServeSuccessJSON(map[string]interface{}{
  10600. "msg": "撤销明细成功",
  10601. })
  10602. return
  10603. } else {
  10604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10605. return
  10606. }
  10607. } else {
  10608. c.ServeSuccessJSON(map[string]interface{}{
  10609. "code": -10,
  10610. "msg": res2.ErrMsg,
  10611. })
  10612. }
  10613. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10614. 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, "")
  10615. var dat map[string]interface{}
  10616. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10617. fmt.Println(dat)
  10618. } else {
  10619. fmt.Println(err)
  10620. }
  10621. saveLog(result2, src_request, "2205", "撤销明细")
  10622. userJSONBytes, _ := json.Marshal(dat)
  10623. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10624. utils.ErrorLog("解析失败:%v", err)
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10626. return
  10627. }
  10628. if res2.Infcode == 0 {
  10629. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10630. if err == nil {
  10631. c.ServeSuccessJSON(map[string]interface{}{
  10632. "msg": "撤销明细成功",
  10633. })
  10634. return
  10635. } else {
  10636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10637. return
  10638. }
  10639. } else {
  10640. c.ServeSuccessJSON(map[string]interface{}{
  10641. "code": -10,
  10642. "msg": res2.ErrMsg,
  10643. })
  10644. }
  10645. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10646. 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, "")
  10647. var dat map[string]interface{}
  10648. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10649. fmt.Println(dat)
  10650. } else {
  10651. fmt.Println(err)
  10652. }
  10653. saveLog(result2, src_request, "2205", "撤销明细")
  10654. userJSONBytes, _ := json.Marshal(dat)
  10655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10656. utils.ErrorLog("解析失败:%v", err)
  10657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10658. return
  10659. }
  10660. if res2.Infcode == 0 {
  10661. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10662. if err == nil {
  10663. c.ServeSuccessJSON(map[string]interface{}{
  10664. "msg": "撤销明细成功",
  10665. })
  10666. return
  10667. } else {
  10668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10669. return
  10670. }
  10671. } else {
  10672. c.ServeSuccessJSON(map[string]interface{}{
  10673. "code": -10,
  10674. "msg": res2.ErrMsg,
  10675. })
  10676. }
  10677. } else {
  10678. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  10679. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10681. resp2, requestErr2 := http.Get(api2)
  10682. if requestErr2 != nil {
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10684. return
  10685. }
  10686. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10687. if ioErr2 != nil {
  10688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. return
  10691. }
  10692. var respJSON2 map[string]interface{}
  10693. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10699. if err == nil {
  10700. c.ServeSuccessJSON(map[string]interface{}{
  10701. "msg": "撤销明细成功",
  10702. })
  10703. return
  10704. } else {
  10705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10706. return
  10707. }
  10708. }
  10709. } else {
  10710. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10711. if err == nil {
  10712. c.ServeSuccessJSON(map[string]interface{}{
  10713. "msg": "退费成功",
  10714. })
  10715. } else {
  10716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10717. return
  10718. }
  10719. }
  10720. }
  10721. //对账
  10722. func (c *HisApiController) GetCheckAccount() {
  10723. start_time := c.GetString("start_time")
  10724. end_time := c.GetString("end_time")
  10725. insutype := c.GetString("insutype")
  10726. clr_type := c.GetString("clr_type")
  10727. clr_org := c.GetString("clr_optins")
  10728. admin_user_id, _ := c.GetInt64("admin_user_id")
  10729. adminUser := c.GetAdminUserInfo()
  10730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10732. if len(clr_org) == 0 {
  10733. clr_org = miConfig.MdtrtareaAdmvs
  10734. }
  10735. timeLayout := "2006-01-02"
  10736. loc, _ := time.LoadLocation("Local")
  10737. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  10738. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  10739. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10740. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  10741. fixmedins_setl_cnt := int64(len(orders))
  10742. var medfee_sumamt float64
  10743. var acct_pay float64
  10744. var fund_pay_sumamt float64
  10745. for _, item := range orders {
  10746. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  10747. acct_pay = acct_pay + item.AcctPay
  10748. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  10749. }
  10750. var user_name string
  10751. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10752. if role.ID == 0 {
  10753. user_name = "xxx"
  10754. } else {
  10755. user_name = role.UserName
  10756. }
  10757. var res ResultEight
  10758. var res10188 ResultEightFor10188
  10759. if config.IsOpen == 1 {
  10760. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10761. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  10762. "insutype=" + insutype +
  10763. "&clr_type=" + clr_type +
  10764. "&setl_optins=" + clr_org +
  10765. "&stmt_begndate=" + start_time +
  10766. "&stm_enddate=" + end_time +
  10767. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10768. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10769. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10770. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10771. "&fixmedins_code=" + miConfig.Code +
  10772. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10773. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10774. "&secret_key=" + miConfig.SecretKey +
  10775. "&org_name=" + miConfig.OrgName +
  10776. "&doctor=" + user_name +
  10777. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10778. fmt.Println(api)
  10779. resp, requestErr := http.Get(api)
  10780. if requestErr != nil {
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. body, ioErr := ioutil.ReadAll(resp.Body)
  10785. fmt.Println(body)
  10786. if ioErr != nil {
  10787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10789. return
  10790. }
  10791. var respJSON map[string]interface{}
  10792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10795. return
  10796. }
  10797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10798. userJSONBytes, _ := json.Marshal(respJSON)
  10799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10800. utils.ErrorLog("解析失败:%v", err)
  10801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10802. return
  10803. }
  10804. res.InfRefmsgid = res10188.InfRefmsgid
  10805. res.Output = res10188.Output
  10806. res.ErrMsg = res10188.ErrMsg
  10807. res.Cainfo = res10188.Cainfo
  10808. res.WarnMsg = res10188.WarnMsg
  10809. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  10810. res.Infcode = infocode
  10811. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10812. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  10813. "insutype=" + insutype +
  10814. "&clr_type=" + "21" +
  10815. "&setl_optins=" + clr_org +
  10816. "&stmt_begndate=" + start_time +
  10817. "&stm_enddate=" + end_time +
  10818. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10819. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10820. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10821. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  10822. "&fixmedins_code=" + miConfig.Code +
  10823. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10824. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10825. "&secret_key=" + miConfig.SecretKey +
  10826. "&org_name=" + miConfig.OrgName +
  10827. "&doctor=" + user_name
  10828. resp, requestErr := http.Get(api)
  10829. if requestErr != nil {
  10830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10831. return
  10832. }
  10833. body, ioErr := ioutil.ReadAll(resp.Body)
  10834. if ioErr != nil {
  10835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10837. return
  10838. }
  10839. var respJSON map[string]interface{}
  10840. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10846. result, _ := json.Marshal(respJSON)
  10847. fmt.Println("log")
  10848. fmt.Println(string(result))
  10849. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  10850. utils.ErrorLog("解析失败:%v", err)
  10851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10852. return
  10853. }
  10854. res.InfRefmsgid = res10188.InfRefmsgid
  10855. res.Output = res10188.Output
  10856. res.ErrMsg = res10188.ErrMsg
  10857. res.Cainfo = res10188.Cainfo
  10858. res.WarnMsg = res10188.WarnMsg
  10859. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  10860. res.Infcode = infocode
  10861. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10862. var baseParams models.BaseParams
  10863. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10864. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10865. baseParams.SecretKey = miConfig.SecretKey
  10866. baseParams.OrgName = miConfig.OrgName
  10867. baseParams.FixmedinsCode = miConfig.Code
  10868. baseParams.EncKey = miConfig.EncKey
  10869. baseParams.AppSecret = miConfig.AppSecret
  10870. baseParams.SignKey = miConfig.SignKey
  10871. baseParams.AppID = miConfig.Code
  10872. baseParams.Doctor = role.UserName
  10873. baseParams.RequestUrl = miConfig.Url
  10874. businessParams := models.BusinessParams{
  10875. Insutype: insutype,
  10876. ClrType: clr_type,
  10877. SetlOptins: clr_org,
  10878. StmtBegndate: start_time,
  10879. StmtEnddate: end_time,
  10880. MedfeeSumamt: medfee_sumamt,
  10881. FundPaySumamt: fund_pay_sumamt,
  10882. AcctPay: acct_pay,
  10883. FixmedinsSetlCnt: fixmedins_setl_cnt,
  10884. }
  10885. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  10886. fmt.Println(requestLog)
  10887. fmt.Println(result)
  10888. fmt.Println(err_msg)
  10889. var dat map[string]interface{}
  10890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10891. fmt.Println(dat)
  10892. } else {
  10893. fmt.Println(err)
  10894. }
  10895. userJSONBytes, _ := json.Marshal(dat)
  10896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10897. utils.ErrorLog("解析失败:%v", err)
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10899. return
  10900. }
  10901. } else if miConfig.MdtrtareaAdmvs == "" {
  10902. var baseParams models.BaseParams
  10903. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10904. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10905. baseParams.SecretKey = miConfig.SecretKey
  10906. baseParams.OrgName = miConfig.OrgName
  10907. baseParams.FixmedinsCode = miConfig.Code
  10908. baseParams.EncKey = miConfig.EncKey
  10909. baseParams.AppSecret = miConfig.AppSecret
  10910. baseParams.SignKey = miConfig.SignKey
  10911. baseParams.AppID = miConfig.Code
  10912. baseParams.Doctor = role.UserName
  10913. baseParams.RequestUrl = miConfig.Url
  10914. businessParams := models.BusinessParams{
  10915. Insutype: insutype,
  10916. ClrType: clr_type,
  10917. SetlOptins: clr_org,
  10918. StmtBegndate: start_time,
  10919. StmtEnddate: end_time,
  10920. MedfeeSumamt: medfee_sumamt,
  10921. FundPaySumamt: fund_pay_sumamt,
  10922. AcctPay: acct_pay,
  10923. FixmedinsSetlCnt: fixmedins_setl_cnt,
  10924. }
  10925. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  10926. fmt.Println(requestLog)
  10927. fmt.Println(result)
  10928. fmt.Println(err_msg)
  10929. var dat map[string]interface{}
  10930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10931. fmt.Println(dat)
  10932. } else {
  10933. fmt.Println(err)
  10934. }
  10935. userJSONBytes, _ := json.Marshal(dat)
  10936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10937. utils.ErrorLog("解析失败:%v", err)
  10938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10939. return
  10940. }
  10941. } else {
  10942. if len(clr_type) == 0 {
  10943. clr_type = "11"
  10944. }
  10945. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  10946. "insutype=" + insutype +
  10947. "&clr_type=" + clr_type +
  10948. "&setl_optins=" + clr_org +
  10949. "&stmt_begndate=" + start_time +
  10950. "&stm_enddate=" + end_time +
  10951. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  10952. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  10953. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  10954. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  10955. "&fixmedins_code=" + miConfig.Code +
  10956. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  10957. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10958. "&secret_key=" + miConfig.SecretKey +
  10959. "&org_name=" + miConfig.OrgName +
  10960. "&doctor=" + user_name
  10961. fmt.Println(api)
  10962. resp, requestErr := http.Get(api)
  10963. if requestErr != nil {
  10964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10965. return
  10966. }
  10967. body, ioErr := ioutil.ReadAll(resp.Body)
  10968. fmt.Println(body)
  10969. if ioErr != nil {
  10970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10972. return
  10973. }
  10974. var respJSON map[string]interface{}
  10975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. return
  10979. }
  10980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10981. userJSONBytes, _ := json.Marshal(respJSON)
  10982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10983. utils.ErrorLog("解析失败:%v", err)
  10984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10985. return
  10986. }
  10987. }
  10988. if res.Infcode == 0 {
  10989. if res.Output.Stmtinfo.StmtRslt == "0" {
  10990. micc := &models.MedicalInsuranceCostCompare{
  10991. StartTime: startime.Unix(),
  10992. EndTime: endtime.Unix(),
  10993. Insutype: insutype,
  10994. CheckType: 1,
  10995. Num: fixmedins_setl_cnt,
  10996. Mtime: time.Now().Unix(),
  10997. Status: 1,
  10998. UserOrgId: adminUser.CurrentOrgId,
  10999. CostTotal: medfee_sumamt,
  11000. FuncTotal: fund_pay_sumamt,
  11001. PsnPay: acct_pay,
  11002. Creator: admin_user_id,
  11003. Ctime: time.Now().Unix(),
  11004. ClrType: clr_type,
  11005. }
  11006. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11007. if err == nil {
  11008. c.ServeSuccessJSON(map[string]interface{}{
  11009. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11010. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11011. })
  11012. } else {
  11013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11014. }
  11015. } else {
  11016. c.ServeSuccessJSON(map[string]interface{}{
  11017. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11018. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11019. })
  11020. }
  11021. } else {
  11022. c.ServeSuccessJSON(map[string]interface{}{
  11023. "code": -10,
  11024. "msg": res.ErrMsg,
  11025. })
  11026. }
  11027. }
  11028. }
  11029. func (c *HisApiController) Check310() {
  11030. adminUser := c.GetAdminUserInfo()
  11031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11032. var user_name string
  11033. user_name = "高慧裕"
  11034. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11035. "insutype=" + "310" +
  11036. "&clr_type=" + "" +
  11037. "&setl_optins=" + "441202" +
  11038. "&stmt_begndate=" + "2022-03-01" +
  11039. "&stm_enddate=" + "2022-03-31" +
  11040. "&medfee_sumamt=" + "194930.12" +
  11041. "&fund_pay_sumamt=" + "188741.46" +
  11042. "&acct_pay=" + "0" +
  11043. "&fixmedins_setl_cnt=" + "452" +
  11044. "&fixmedins_code=" + miConfig.Code +
  11045. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11046. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11047. "&secret_key=" + miConfig.SecretKey +
  11048. "&org_name=" + miConfig.OrgName +
  11049. "&doctor=" + user_name
  11050. fmt.Println(api)
  11051. resp, requestErr := http.Get(api)
  11052. if requestErr != nil {
  11053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11054. return
  11055. }
  11056. body, ioErr := ioutil.ReadAll(resp.Body)
  11057. fmt.Println(body)
  11058. if ioErr != nil {
  11059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11061. return
  11062. }
  11063. var respJSON map[string]interface{}
  11064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11067. return
  11068. }
  11069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11070. userJSONBytes, _ := json.Marshal(respJSON)
  11071. var res ResultEight
  11072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11073. utils.ErrorLog("解析失败:%v", err)
  11074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11075. return
  11076. }
  11077. }
  11078. func (c *HisApiController) Check390() {
  11079. adminUser := c.GetAdminUserInfo()
  11080. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11081. var user_name string
  11082. user_name = "高慧裕"
  11083. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11084. "insutype=" + "390" +
  11085. "&clr_type=" + "" +
  11086. "&setl_optins=" + "441202" +
  11087. "&stmt_begndate=" + "2022-03-01" +
  11088. "&stm_enddate=" + "2022-03-31" +
  11089. "&medfee_sumamt=" + "1068448.89" +
  11090. "&fund_pay_sumamt=" + "1014677.62" +
  11091. "&acct_pay=" + "0" +
  11092. "&fixmedins_setl_cnt=" + "1950" +
  11093. "&fixmedins_code=" + miConfig.Code +
  11094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11095. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11096. "&secret_key=" + miConfig.SecretKey +
  11097. "&org_name=" + miConfig.OrgName +
  11098. "&doctor=" + user_name
  11099. fmt.Println(api)
  11100. resp, requestErr := http.Get(api)
  11101. if requestErr != nil {
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11103. return
  11104. }
  11105. body, ioErr := ioutil.ReadAll(resp.Body)
  11106. fmt.Println(body)
  11107. if ioErr != nil {
  11108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11110. return
  11111. }
  11112. var respJSON map[string]interface{}
  11113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. return
  11117. }
  11118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11119. userJSONBytes, _ := json.Marshal(respJSON)
  11120. var res ResultEight
  11121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11122. utils.ErrorLog("解析失败:%v", err)
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. }
  11127. //对账明细
  11128. func (c *HisApiController) GetCheckDetailAccount() {
  11129. start_time := c.GetString("start_time")
  11130. end_time := c.GetString("end_time")
  11131. admin_user_id, _ := c.GetInt64("admin_user_id")
  11132. adminUser := c.GetAdminUserInfo()
  11133. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11134. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11135. timeLayout := "2006-01-02"
  11136. loc, _ := time.LoadLocation("Local")
  11137. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11138. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11139. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11140. rand.Seed(time.Now().UnixNano())
  11141. num := rand.Intn(30000)
  11142. Mkdir(miConfig.OrgName)
  11143. file := strconv.FormatInt(int64(num), 10)
  11144. file_name := file + ".txt"
  11145. zip_name := file + ".zip"
  11146. zip_path := miConfig.OrgName + "/" + zip_name
  11147. file_path := miConfig.OrgName + "/" + file_name
  11148. decimal.DivisionPrecision = 2
  11149. var medfee_sumamt float64
  11150. var psn_cash_pay float64
  11151. var fund_pay_sumamt float64
  11152. fixmedins_setl_cnt := int64(len(orders))
  11153. for _, item := range orders {
  11154. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11155. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11156. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11157. }
  11158. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11159. defer f.Close()
  11160. if err != nil {
  11161. fmt.Println(err.Error())
  11162. } else {
  11163. for _, item := range orders {
  11164. var refd_setl_flag string
  11165. if item.OrderStatus == 2 {
  11166. refd_setl_flag = "0"
  11167. var str string
  11168. str = item.SetlId + " " +
  11169. item.MdtrtId + " " +
  11170. item.PsnNo + " " +
  11171. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11172. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11173. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11174. _, err = f.Write([]byte(str))
  11175. }
  11176. if item.OrderStatus == 3 {
  11177. var str string
  11178. str = item.SetlId + " " +
  11179. item.MdtrtId + " " +
  11180. item.PsnNo + " " +
  11181. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11182. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11183. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11184. _, err = f.Write([]byte(str))
  11185. var str2 string
  11186. str2 = item.SetlId + " " +
  11187. item.MdtrtId + " " +
  11188. item.PsnNo + " " +
  11189. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11190. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11191. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11192. _, err = f.Write([]byte(str2))
  11193. }
  11194. }
  11195. }
  11196. Zip(file_path, zip_path)
  11197. fmt.Println(ReadFile(zip_path))
  11198. fmt.Println(string(ReadFile(zip_path)))
  11199. if config.IsOpen == 1 {
  11200. var user_name string
  11201. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11202. if role.ID == 0 {
  11203. user_name = "管理员"
  11204. } else {
  11205. user_name = role.UserName
  11206. }
  11207. baseParams := models.BaseParams{
  11208. SecretKey: miConfig.SecretKey,
  11209. FixmedinsCode: miConfig.Code,
  11210. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11211. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11212. OrgName: miConfig.OrgName,
  11213. Doctor: user_name,
  11214. }
  11215. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11216. var dat map[string]interface{}
  11217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11218. fmt.Println(dat)
  11219. } else {
  11220. fmt.Println(err)
  11221. }
  11222. userJSONBytes, _ := json.Marshal(dat)
  11223. var res ResultNine
  11224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11225. utils.ErrorLog("解析失败:%v", err)
  11226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11227. return
  11228. }
  11229. if res.Infcode == 0 {
  11230. fileNo := res.Output.FileQuryNo
  11231. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11232. "file_qury_no=" + fileNo +
  11233. "&setl_optins=" + "定点医保中心" +
  11234. "&stmt_begndate=" + start_time +
  11235. "&stm_enddate=" + end_time +
  11236. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11237. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11238. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11239. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11240. "&fixmedins_code=" + miConfig.Code +
  11241. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11242. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11243. "&secret_key=" + miConfig.SecretKey +
  11244. "&org_name=" + miConfig.OrgName +
  11245. "&doctor=" + user_name
  11246. resp, requestErr := http.Get(api)
  11247. if requestErr != nil {
  11248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11249. return
  11250. }
  11251. body, ioErr := ioutil.ReadAll(resp.Body)
  11252. if ioErr != nil {
  11253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11255. return
  11256. }
  11257. var respJSON map[string]interface{}
  11258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11261. return
  11262. }
  11263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11264. userJSONBytes, _ := json.Marshal(respJSON)
  11265. var res ResultTen
  11266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11267. utils.ErrorLog("解析失败:%v", err)
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11269. return
  11270. }
  11271. if res.Infcode == 0 {
  11272. service.Gdyb9102(baseParams, zip_name, fileNo)
  11273. micc := &models.MedicalInsuranceCostCompare{
  11274. StartTime: startime.Unix(),
  11275. EndTime: endtime.Unix(),
  11276. Insutype: "0",
  11277. CheckType: 2,
  11278. Num: fixmedins_setl_cnt,
  11279. Mtime: time.Now().Unix(),
  11280. Status: 1,
  11281. UserOrgId: adminUser.CurrentOrgId,
  11282. CostTotal: medfee_sumamt,
  11283. FuncTotal: fund_pay_sumamt,
  11284. PsnPay: psn_cash_pay,
  11285. Creator: admin_user_id,
  11286. Ctime: time.Now().Unix(),
  11287. }
  11288. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11289. c.ServeSuccessJSON(map[string]interface{}{
  11290. "msg": "明细对账成功",
  11291. })
  11292. }
  11293. } else {
  11294. }
  11295. }
  11296. }
  11297. type CustomOrderInfo struct {
  11298. Name string
  11299. Spec string
  11300. Unit string
  11301. Count float64
  11302. Price float64
  11303. Total float64
  11304. }
  11305. func (c *HisApiController) GetSettleAccounts() {
  11306. //id, _ := c.GetInt64("id")
  11307. //record_time := c.GetString("record_time")
  11308. order_id, _ := c.GetInt64("order_id")
  11309. admin_user_id, _ := c.GetInt64("admin_user_id")
  11310. //timeLayout := "2006-01-02"
  11311. //loc, _ := time.LoadLocation("Local")
  11312. //
  11313. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11314. //if err != nil {
  11315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11316. // return
  11317. //}
  11318. //recordDateTime := theTime.Unix()
  11319. adminUser := c.GetAdminUserInfo()
  11320. order, _ := service.GetHisOrderByID(order_id)
  11321. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11322. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11323. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11324. orderInfos = append(orderInfos, orderInfos_two...)
  11325. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11326. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11327. var diagnosis_ids []string
  11328. if his.ID > 0 {
  11329. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11330. } else {
  11331. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11332. }
  11333. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11334. var dia_config []*models.HisXtDiagnoseConfig
  11335. var name string
  11336. for _, item := range diagnosis_ids {
  11337. id, _ := strconv.ParseInt(item, 10, 64)
  11338. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11339. dia_config = append(dia_config, &diagnosisConfig)
  11340. if len(name) == 0 {
  11341. name = diagnosisConfig.ClassName
  11342. } else {
  11343. name = name + "," + diagnosisConfig.ClassName
  11344. }
  11345. }
  11346. var bedCostTotal float64 = 0 //床位总费
  11347. var bedCostSelfTotal float64 = 0 //床位自费
  11348. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11349. var operationCostTotal float64 = 0 //手术费
  11350. var operationCostSelfTotal float64 = 0 //手术费
  11351. var operationCostPartSelfTotal float64 = 0 //手术费
  11352. var otherCostTotal float64 = 0 //其他费用
  11353. var otherCostSelfTotal float64 = 0 //其他费用
  11354. var otherCostPartSelfTotal float64 = 0 //其他费用
  11355. var materialCostTotal float64 = 0 //材料费
  11356. var materialCostSelfTotal float64 = 0 //材料费
  11357. var materialCostPartSelfTotal float64 = 0 //材料费
  11358. var westernMedicineCostTotal float64 = 0 //西药费
  11359. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11360. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11361. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11362. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11363. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11364. var checkCostTotal float64 = 0 //检查费
  11365. var checkCostSelfTotal float64 = 0 //检查费
  11366. var checkCostPartSelfTotal float64 = 0 //检查费
  11367. var laboratoryCostTotal float64 = 0 //化验费
  11368. var laboratoryCostSelfTotal float64 = 0 //化验费
  11369. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11370. var treatCostTotal float64 = 0 //治疗费用
  11371. var treatCostSelfTotal float64 = 0 //治疗费用
  11372. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11373. decimal.DivisionPrecision = 2
  11374. for _, item := range orderInfos {
  11375. if item.MedChrgitmType == "01" { //床位费
  11376. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11377. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11378. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11379. }
  11380. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11381. if item.MedChrgitmType == "03" { //检查费
  11382. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11383. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11384. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11385. }
  11386. } else {
  11387. if item.MedChrgitmType == "03" { //检查费
  11388. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11389. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11390. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11391. }
  11392. }
  11393. if item.MedChrgitmType == "04" { //化验费
  11394. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11395. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11396. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11397. }
  11398. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11399. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11400. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11401. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11402. }
  11403. if item.MedChrgitmType == "06" { //手术费
  11404. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11405. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11406. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11407. }
  11408. if item.MedChrgitmType == "08" { //材料费
  11409. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11410. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11411. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11412. }
  11413. if item.MedChrgitmType == "09" { //西药费
  11414. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11415. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11416. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11417. }
  11418. if item.MedChrgitmType == "11" { //中成费
  11419. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11420. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11421. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11422. }
  11423. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11424. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11425. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11426. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11427. }
  11428. }
  11429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11431. var user_name string
  11432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11433. if role.ID == 0 {
  11434. user_name = "管理员"
  11435. } else {
  11436. user_name = role.UserName
  11437. }
  11438. baseParams := models.BaseParams{
  11439. SecretKey: miConfig.SecretKey,
  11440. FixmedinsCode: miConfig.Code,
  11441. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11442. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11443. OrgName: miConfig.OrgName,
  11444. Doctor: user_name,
  11445. RequestUrl: miConfig.Url,
  11446. AccessKey: miConfig.AccessKey,
  11447. }
  11448. businessParams := models.BusinessParams{
  11449. PsnNo: order.PsnNo,
  11450. MdtrtId: order.MdtrtId,
  11451. SetlId: order.SetlId,
  11452. }
  11453. var res ResultEleven
  11454. var resEleven10265 ResultEleven10265
  11455. if config.IsOpen == 1 {
  11456. if miConfig.MdtrtareaAdmvs == "421300" {
  11457. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11458. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11459. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11460. resp, requestErr := http.Get(api)
  11461. if requestErr != nil {
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. body, ioErr := ioutil.ReadAll(resp.Body)
  11466. if ioErr != nil {
  11467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11469. return
  11470. }
  11471. var respJSON map[string]interface{}
  11472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11475. return
  11476. }
  11477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11478. result, _ := json.Marshal(respJSON)
  11479. fmt.Println("log")
  11480. fmt.Println(string(result))
  11481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11482. utils.ErrorLog("解析失败:%v", err)
  11483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11484. return
  11485. }
  11486. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11487. var api string
  11488. if miConfig.MdtrtareaAdmvs == "320921" {
  11489. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11490. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11492. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11493. } else {
  11494. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11495. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11496. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11497. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11498. }
  11499. resp, requestErr := http.Get(api)
  11500. if requestErr != nil {
  11501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11502. return
  11503. }
  11504. body, ioErr := ioutil.ReadAll(resp.Body)
  11505. if ioErr != nil {
  11506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11508. return
  11509. }
  11510. var respJSON map[string]interface{}
  11511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return
  11515. }
  11516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11517. result, _ := json.Marshal(respJSON)
  11518. fmt.Println("log")
  11519. fmt.Println(string(result))
  11520. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11521. utils.ErrorLog("解析失败:%v", err)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return
  11524. }
  11525. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11526. res.Output = resEleven10265.Output
  11527. res.ErrMsg = resEleven10265.ErrMsg
  11528. res.Cainfo = resEleven10265.Cainfo
  11529. res.WarnMsg = resEleven10265.WarnMsg
  11530. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11531. res.Infcode = infocode
  11532. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11533. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11534. saveLog(result, requestLog, "5203", "结算单")
  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. userJSONBytes, _ := json.Marshal(dat)
  11542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11543. utils.ErrorLog("解析失败:%v", err)
  11544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11545. return
  11546. }
  11547. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11548. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  11549. saveLog(result, requestLog, "5203", "结算单")
  11550. var dat map[string]interface{}
  11551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11552. fmt.Println(dat)
  11553. } else {
  11554. fmt.Println(err)
  11555. }
  11556. userJSONBytes, _ := json.Marshal(dat)
  11557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11558. utils.ErrorLog("解析失败:%v", err)
  11559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11560. return
  11561. }
  11562. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11563. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  11564. saveLog(result, requestLog, "5203", "结算单")
  11565. var dat map[string]interface{}
  11566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11567. fmt.Println(dat)
  11568. } else {
  11569. fmt.Println(err)
  11570. }
  11571. userJSONBytes, _ := json.Marshal(dat)
  11572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11573. utils.ErrorLog("解析失败:%v", err)
  11574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11575. return
  11576. }
  11577. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11578. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11579. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11581. resp, requestErr := http.Get(api)
  11582. if requestErr != nil {
  11583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11584. return
  11585. }
  11586. body, ioErr := ioutil.ReadAll(resp.Body)
  11587. if ioErr != nil {
  11588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11590. return
  11591. }
  11592. var respJSON map[string]interface{}
  11593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11596. return
  11597. }
  11598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11599. result, _ := json.Marshal(respJSON)
  11600. fmt.Println("log")
  11601. fmt.Println(string(result))
  11602. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11603. utils.ErrorLog("解析失败:%v", err)
  11604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11605. return
  11606. }
  11607. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11608. res.Output = resEleven10265.Output
  11609. res.ErrMsg = resEleven10265.ErrMsg
  11610. res.Cainfo = resEleven10265.Cainfo
  11611. res.WarnMsg = resEleven10265.WarnMsg
  11612. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11613. res.Infcode = infocode
  11614. } else {
  11615. result := service.Gdyb5203(baseParams, businessParams)
  11616. //service.Gdyb5204(baseParams, businessParams)
  11617. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  11618. var dat map[string]interface{}
  11619. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11620. fmt.Println(dat)
  11621. } else {
  11622. fmt.Println(err)
  11623. }
  11624. userJSONBytes, _ := json.Marshal(dat)
  11625. if miConfig.Code == "H15049901371" {
  11626. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  11627. utils.ErrorLog("解析失败:%v", err)
  11628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11629. return
  11630. }
  11631. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11632. res.Output = resEleven10265.Output
  11633. res.ErrMsg = resEleven10265.ErrMsg
  11634. res.Cainfo = resEleven10265.Cainfo
  11635. res.WarnMsg = resEleven10265.WarnMsg
  11636. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11637. res.Infcode = infocode
  11638. } else {
  11639. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11640. utils.ErrorLog("解析失败:%v", err)
  11641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11642. return
  11643. }
  11644. }
  11645. }
  11646. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11647. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  11648. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  11649. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11650. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  11651. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11652. var doctor_name string
  11653. if roles.ID == 0 {
  11654. doctor_name = "管理员"
  11655. } else {
  11656. doctor_name = roles.UserName
  11657. }
  11658. yiliao_leibie := ""
  11659. switch order.MedType {
  11660. case "11":
  11661. yiliao_leibie = "普通门诊"
  11662. break
  11663. case "12":
  11664. yiliao_leibie = "门诊挂号"
  11665. break
  11666. case "13":
  11667. yiliao_leibie = "急诊"
  11668. break
  11669. case "14":
  11670. yiliao_leibie = "门诊特殊病"
  11671. break
  11672. case "15":
  11673. yiliao_leibie = "门诊统筹"
  11674. break
  11675. case "16":
  11676. yiliao_leibie = "门诊慢性病"
  11677. break
  11678. case "21":
  11679. yiliao_leibie = "普通住院"
  11680. break
  11681. }
  11682. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11683. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  11684. if res.Infcode == 0 {
  11685. c.ServeSuccessJSON(map[string]interface{}{
  11686. "diagnosis": name,
  11687. "order_infos": orderInfos,
  11688. "number": order.MdtrtId,
  11689. "date": order.SettleAccountsDate,
  11690. "charge_admin": charge_admin,
  11691. "printor_admin": printor_admin,
  11692. "info": res.Output.Setlinfo,
  11693. "order": order,
  11694. "bedCostTotal": bedCostTotal,
  11695. "bedCostSelfTotal": bedCostSelfTotal,
  11696. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  11697. "operationCostTotal": operationCostTotal,
  11698. "operationCostSelfTotal": operationCostSelfTotal,
  11699. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  11700. "otherCostTotal": otherCostTotal,
  11701. "otherCostSelfTotal": otherCostSelfTotal,
  11702. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  11703. "materialCostTotal": materialCostTotal,
  11704. "materialCostSelfTotal": materialCostSelfTotal,
  11705. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  11706. "westernMedicineCostTotal": westernMedicineCostTotal,
  11707. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  11708. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  11709. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  11710. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  11711. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  11712. "checkCostTotal": checkCostTotal,
  11713. "checkCostSelfTotal": checkCostSelfTotal,
  11714. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  11715. "laboratoryCostTotal": laboratoryCostTotal,
  11716. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  11717. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  11718. "treatCostTotal": treatCostTotal,
  11719. "treatCostSelfTotal": treatCostSelfTotal,
  11720. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  11721. "doctor_info": doctor_info,
  11722. "doctor_code": adminRole_two.DoctorCode,
  11723. "doctor_name": doctor_name,
  11724. "health_card_no": order.PsnNo,
  11725. "department": departments.Name,
  11726. "yiliao_leibie": yiliao_leibie,
  11727. "after_money": order.AccountPrice,
  11728. "patient": patient,
  11729. "org_name": miConfig.OrgName,
  11730. "org_code": miConfig.Code,
  11731. "order_number": order.Number,
  11732. "his_hospital": his_hospital,
  11733. "his": his,
  11734. "dia_config": dia_config,
  11735. //"check_order_info": cus_slice,
  11736. })
  11737. }
  11738. }
  11739. }
  11740. func (c *HisApiController) CheckTreatment() {
  11741. patient_id, _ := c.GetInt64("patient_id")
  11742. id_card_no := c.GetString("id_card_no")
  11743. insutype := c.GetString("insutype")
  11744. med_type := c.GetString("med_type")
  11745. admin_user_id, _ := c.GetInt64("admin_user_id")
  11746. adminUser := c.GetAdminUserInfo()
  11747. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  11748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11749. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11750. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11751. if miConfig.MdtrtareaAdmvs == "421300" {
  11752. var res ResultTwo
  11753. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11754. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11755. "&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)
  11756. resp, requestErr := http.Get(api)
  11757. if requestErr != nil {
  11758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. return
  11760. }
  11761. body, ioErr := ioutil.ReadAll(resp.Body)
  11762. if ioErr != nil {
  11763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11765. return
  11766. }
  11767. var respJSON map[string]interface{}
  11768. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11771. return
  11772. }
  11773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11774. result, _ := json.Marshal(respJSON)
  11775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11776. utils.ErrorLog("解析失败:%v", err)
  11777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11778. return
  11779. }
  11780. if res.Infcode == 0 {
  11781. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  11782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11783. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  11784. resp, requestErr := http.Get(api)
  11785. if requestErr != nil {
  11786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11787. return
  11788. }
  11789. body, ioErr := ioutil.ReadAll(resp.Body)
  11790. if ioErr != nil {
  11791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11793. return
  11794. }
  11795. var respJSON map[string]interface{}
  11796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return
  11800. }
  11801. var res Result2001
  11802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11803. result2, _ := json.Marshal(respJSON)
  11804. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11805. utils.ErrorLog("解析失败:%v", err)
  11806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11807. return
  11808. }
  11809. if res.Infcode == 0 {
  11810. c.ServeSuccessJSON(map[string]interface{}{
  11811. "msg": res.Output.Trtinfo,
  11812. })
  11813. }
  11814. } else {
  11815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11816. return
  11817. }
  11818. } else {
  11819. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  11820. var dat map[string]interface{}
  11821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11822. fmt.Println(dat)
  11823. } else {
  11824. fmt.Println(err)
  11825. }
  11826. userJSONBytes, _ := json.Marshal(dat)
  11827. var res ResultTwo
  11828. var res10265 ResultTwo10265
  11829. if miConfig.Code == "H15049901371" {
  11830. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11831. utils.ErrorLog("解析失败:%v", err)
  11832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11833. return
  11834. }
  11835. res.ErrMsg = res10265.ErrMsg
  11836. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11837. res.Infcode = infocode
  11838. res.Output = res10265.Output
  11839. res.InfRefmsgid = res10265.InfRefmsgid
  11840. } else {
  11841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11842. utils.ErrorLog("解析失败:%v", err)
  11843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11844. return
  11845. }
  11846. }
  11847. var user_name string
  11848. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  11849. if role.ID == 0 {
  11850. user_name = "xxx"
  11851. } else {
  11852. user_name = role.UserName
  11853. }
  11854. baseParams := models.BaseParams{
  11855. SecretKey: miConfig.SecretKey,
  11856. FixmedinsCode: miConfig.Code,
  11857. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11858. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11859. OrgName: miConfig.OrgName,
  11860. Doctor: user_name,
  11861. }
  11862. if config.IsOpen == 1 {
  11863. if miConfig.Code == "H15049901371" {
  11864. if med_type == "14" {
  11865. if insutype == "390" {
  11866. med_type = "9933"
  11867. } else if insutype == "310" {
  11868. med_type = "990502"
  11869. }
  11870. } else if med_type == "11" {
  11871. med_type = "11"
  11872. }
  11873. }
  11874. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  11875. var dat map[string]interface{}
  11876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11877. fmt.Println(dat)
  11878. } else {
  11879. fmt.Println(err)
  11880. }
  11881. var res Result2001
  11882. var res10265 Result2001Org10265
  11883. if miConfig.Code == "H15049901371" {
  11884. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11885. utils.ErrorLog("解析失败:%v", err)
  11886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11887. return
  11888. }
  11889. res.ErrMsg = res10265.ErrMsg
  11890. res.Output = res10265.Output
  11891. res.InfRefmsgid = res10265.InfRefmsgid
  11892. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11893. res.Infcode = infocode
  11894. } else {
  11895. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11896. utils.ErrorLog("解析失败:%v", err)
  11897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11898. return
  11899. }
  11900. }
  11901. if res.Infcode == 0 {
  11902. c.ServeSuccessJSON(map[string]interface{}{
  11903. "msg": res.Output.Trtinfo,
  11904. })
  11905. }
  11906. }
  11907. }
  11908. }
  11909. //func (c *HisApiController) PutRecord() {
  11910. // id, _ := c.GetInt64("id")
  11911. // record_time := c.GetString("record_time")
  11912. // timeLayout := "2006-01-02"
  11913. // loc, _ := time.LoadLocation("Local")
  11914. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11915. // if err != nil {
  11916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11917. // return
  11918. // }
  11919. // recordDateTime := theTime.Unix()
  11920. //
  11921. // adminInfo := c.GetAdminUserInfo()
  11922. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  11923. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  11924. //
  11925. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  11926. //
  11927. // fmt.Println(miConfig.SecretKey)
  11928. //
  11929. // if patient == nil {
  11930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  11931. // return
  11932. // }
  11933. // if len(patient.IdCardNo) == 0 {
  11934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  11935. // return
  11936. // }
  11937. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  11938. // if config.IsOpen == 1 {
  11939. // 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
  11940. // resp, requestErr := http.Get(api)
  11941. // if requestErr != nil {
  11942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11943. // return
  11944. // }
  11945. // defer resp.Body.Close()
  11946. // body, ioErr := ioutil.ReadAll(resp.Body)
  11947. // if ioErr != nil {
  11948. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11950. // return
  11951. // }
  11952. // var respJSON map[string]interface{}
  11953. //
  11954. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11955. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11957. // return
  11958. // }
  11959. //
  11960. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11961. // userJSONBytes, _ := json.Marshal(userJSON)
  11962. // var res ResultTwo
  11963. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11964. // utils.ErrorLog("解析失败:%v", err)
  11965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11966. // return
  11967. // }
  11968. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11969. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11970. // infoStr := string(Iinfos)
  11971. // idetinfoStr := string(Idetinfos)
  11972. //
  11973. // if res.Infcode == 0 {
  11974. // his := models.VMHisPatient{
  11975. // Status: 1,
  11976. // Ctime: time.Now().Unix(),
  11977. // Mtime: time.Now().Unix(),
  11978. // PsnNo: res.Output.Baseinfo.PsnNo,
  11979. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11980. // Certno: res.Output.Baseinfo.Certno,
  11981. // PsnName: res.Output.Baseinfo.PsnName,
  11982. // Gend: res.Output.Baseinfo.Gend,
  11983. // Naty: res.Output.Baseinfo.Naty,
  11984. // Brdy: res.Output.Baseinfo.Brdy,
  11985. // Age: res.Output.Baseinfo.Age,
  11986. // Iinfo: infoStr,
  11987. // Idetinfo: idetinfoStr,
  11988. // PatientId: patient.ID,
  11989. // RecordDate: theTime.Unix(),
  11990. // UserOrgId: adminInfo.CurrentOrgId,
  11991. // AdminUserId: adminInfo.AdminUser.Id,
  11992. // IsReturn: 1,
  11993. // }
  11994. //
  11995. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  11996. // //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")
  11997. // //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")
  11998. //
  11999. // //var dat map[string]interface{}
  12000. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12001. // // fmt.Println(dat)
  12002. // //} else {
  12003. // // fmt.Println(err)
  12004. // //}
  12005. //
  12006. // var dat2 map[string]interface{}
  12007. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12008. // fmt.Println(dat2)
  12009. // } else {
  12010. // fmt.Println(err)
  12011. // }
  12012. //
  12013. // } else {
  12014. // adminUser := c.GetAdminUserInfo()
  12015. // errlog := &models.HisOrderError{
  12016. // UserOrgId: adminUser.CurrentOrgId,
  12017. // Ctime: time.Now().Unix(),
  12018. // Mtime: time.Now().Unix(),
  12019. // ErrMsg: res.ErrMsg,
  12020. // Status: 1,
  12021. // PatientId: id,
  12022. // RecordTime: recordDateTime,
  12023. // Stage: 1,
  12024. // }
  12025. // service.CreateErrMsgLog(errlog)
  12026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12027. // return
  12028. // }
  12029. // }
  12030. //
  12031. //}
  12032. //func (c *HisApiController) GetUploadDiag() {
  12033. // id, _ := c.GetInt64("id")
  12034. // record_time := c.GetString("record_time")
  12035. //
  12036. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12037. // sick_type, _ := c.GetInt64("sick_type")
  12038. // reg_type, _ := c.GetInt64("reg_type")
  12039. //
  12040. // timeLayout := "2006-01-02"
  12041. // loc, _ := time.LoadLocation("Local")
  12042. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12043. // if err != nil {
  12044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12045. // return
  12046. // }
  12047. //
  12048. // var patientPrescription models.HisPrescriptionInfo
  12049. // recordDateTime := theTime.Unix()
  12050. // adminInfo := c.GetAdminUserInfo()
  12051. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12052. //
  12053. // if patientPrescription.ID == 0 {
  12054. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12055. // }
  12056. //
  12057. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12058. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12059. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12060. // sickConfig, _ := service.FindSickById(sick_type)
  12061. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12062. //
  12063. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12064. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12065. // "&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 +
  12066. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12067. // resp2, requestErr2 := http.Get(api2)
  12068. // if requestErr2 != nil {
  12069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12070. // return
  12071. // }
  12072. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12073. // if ioErr2 != nil {
  12074. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. // return
  12077. // }
  12078. // var respJSON2 map[string]interface{}
  12079. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12080. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12082. // return
  12083. // }
  12084. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12085. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12086. //
  12087. // var res2 ResultSix
  12088. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12089. // utils.ErrorLog("解析失败:%v", err)
  12090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12091. // return
  12092. // }
  12093. // if res2.Infcode != 0 {
  12094. // adminUser := c.GetAdminUserInfo()
  12095. // errlog := &models.HisOrderError{
  12096. // UserOrgId: adminUser.CurrentOrgId,
  12097. // Ctime: time.Now().Unix(),
  12098. // Mtime: time.Now().Unix(),
  12099. // ErrMsg: res2.ErrMsg,
  12100. // Status: 1,
  12101. // PatientId: id,
  12102. // RecordTime: recordDateTime,
  12103. // Stage: 3,
  12104. // }
  12105. // service.CreateErrMsgLog(errlog)
  12106. //
  12107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12108. // return
  12109. // }
  12110. //
  12111. // c.ServeSuccessJSON(map[string]interface{}{
  12112. // "msg": "上传成功",
  12113. // })
  12114. //
  12115. //}
  12116. type QueryResult struct {
  12117. ID int64
  12118. Name string
  12119. Code string
  12120. List_type_code string
  12121. }
  12122. func (c *HisApiController) GetCheckCode() {
  12123. ids_str := c.GetString("ids")
  12124. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12125. ids_arr := strings.Split(ids_str, ",")
  12126. var queryResult []QueryResult
  12127. ids := make([]int64, 0)
  12128. for _, item := range ids_arr {
  12129. id, _ := strconv.ParseInt(item, 10, 64)
  12130. ids = append(ids, id)
  12131. }
  12132. if record_type == 1 {
  12133. drugs, _ := service.GetBatchDrugList(ids)
  12134. for _, item := range drugs {
  12135. result := QueryResult{
  12136. ID: item.ID,
  12137. Name: item.DrugName,
  12138. Code: item.MedicalInsuranceNumber,
  12139. List_type_code: "101",
  12140. }
  12141. queryResult = append(queryResult, result)
  12142. }
  12143. } else if record_type == 2 {
  12144. goods, _ := service.GetBatchGoodInformationList(ids)
  12145. for _, item := range goods {
  12146. result := QueryResult{
  12147. ID: item.ID,
  12148. Name: item.GoodName,
  12149. Code: item.MedicalInsuranceNumber,
  12150. List_type_code: "301",
  12151. }
  12152. queryResult = append(queryResult, result)
  12153. }
  12154. } else if record_type == 3 {
  12155. projects, _ := service.GetBathchMyPorjecgList(ids)
  12156. for _, item := range projects {
  12157. result := QueryResult{
  12158. ID: item.ID,
  12159. Name: item.ProjectName,
  12160. Code: item.MedicalCode,
  12161. List_type_code: "201",
  12162. }
  12163. queryResult = append(queryResult, result)
  12164. }
  12165. }
  12166. admin_user_id, _ := c.GetInt64("admin_user_id")
  12167. adminUser := c.GetAdminUserInfo()
  12168. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12169. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12170. var user_name string
  12171. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12172. if role.ID == 0 {
  12173. user_name = "xxx"
  12174. } else {
  12175. user_name = role.UserName
  12176. }
  12177. baseParams := &models.BaseParams{
  12178. SecretKey: miConfig.SecretKey,
  12179. FixmedinsCode: miConfig.Code,
  12180. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12181. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12182. OrgName: miConfig.OrgName,
  12183. Doctor: user_name,
  12184. }
  12185. if config.IsOpen == 1 {
  12186. for _, item := range queryResult {
  12187. var result string
  12188. if record_type == 1 {
  12189. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12190. } else if record_type == 2 {
  12191. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12192. } else if record_type == 3 {
  12193. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12194. }
  12195. var dat map[string]interface{}
  12196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12197. fmt.Println(dat)
  12198. } else {
  12199. fmt.Println(err)
  12200. }
  12201. userJSONBytes, _ := json.Marshal(dat)
  12202. var res ResultSix
  12203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12204. utils.ErrorLog("解析失败:%v", err)
  12205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12206. return
  12207. }
  12208. if res.Infcode == 0 {
  12209. if record_type == 1 {
  12210. service.UpdateBaseDrugById(item.ID)
  12211. } else if record_type == 2 {
  12212. service.UpdateGoodInformaitonByDetail(item.ID)
  12213. } else if record_type == 3 {
  12214. service.UpdateProjectById(item.ID)
  12215. }
  12216. c.ServeSuccessJSON(map[string]interface{}{
  12217. "failed_code": 0,
  12218. "msg": "目录对照成功",
  12219. })
  12220. } else {
  12221. c.ServeSuccessJSON(map[string]interface{}{
  12222. "failed_code": -10,
  12223. "msg": res.ErrMsg,
  12224. })
  12225. }
  12226. }
  12227. }
  12228. }
  12229. func (c *HisApiController) UnCheckCode() {
  12230. ids_str := c.GetString("ids")
  12231. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12232. admin_user_id, _ := c.GetInt64("admin_user_id")
  12233. ids_arr := strings.Split(ids_str, ",")
  12234. var queryResult []QueryResult
  12235. ids := make([]int64, 0)
  12236. for _, item := range ids_arr {
  12237. id, _ := strconv.ParseInt(item, 10, 64)
  12238. ids = append(ids, id)
  12239. }
  12240. if record_type == 1 {
  12241. drugs, _ := service.GetBatchDrugList(ids)
  12242. for _, item := range drugs {
  12243. result := QueryResult{
  12244. ID: item.ID,
  12245. Name: item.DrugName,
  12246. Code: item.MedicalInsuranceNumber,
  12247. List_type_code: "101",
  12248. }
  12249. queryResult = append(queryResult, result)
  12250. }
  12251. } else if record_type == 2 {
  12252. goods, _ := service.GetBatchGoodInformationList(ids)
  12253. for _, item := range goods {
  12254. result := QueryResult{
  12255. ID: item.ID,
  12256. Name: item.GoodName,
  12257. Code: item.MedicalInsuranceNumber,
  12258. List_type_code: "301",
  12259. }
  12260. queryResult = append(queryResult, result)
  12261. }
  12262. } else if record_type == 3 {
  12263. projects, _ := service.GetBathchMyPorjecgList(ids)
  12264. for _, item := range projects {
  12265. result := QueryResult{
  12266. ID: item.ID,
  12267. Name: item.ProjectName,
  12268. Code: item.MedicalCode,
  12269. List_type_code: "201",
  12270. }
  12271. queryResult = append(queryResult, result)
  12272. }
  12273. }
  12274. adminUser := c.GetAdminUserInfo()
  12275. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12276. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12277. var user_name string
  12278. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12279. if role.ID == 0 {
  12280. user_name = "xxx"
  12281. } else {
  12282. user_name = role.UserName
  12283. }
  12284. baseParams := &models.BaseParams{
  12285. SecretKey: miConfig.SecretKey,
  12286. FixmedinsCode: miConfig.Code,
  12287. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12288. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12289. OrgName: miConfig.OrgName,
  12290. Doctor: user_name,
  12291. }
  12292. if config.IsOpen == 1 {
  12293. for _, item := range queryResult {
  12294. var result string
  12295. if record_type == 1 {
  12296. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12297. } else if record_type == 2 {
  12298. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12299. } else if record_type == 3 {
  12300. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12301. }
  12302. var dat2 map[string]interface{}
  12303. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12304. fmt.Println(dat2)
  12305. } else {
  12306. fmt.Println(err)
  12307. }
  12308. userJSONBytes, _ := json.Marshal(dat2)
  12309. var res ResultSix
  12310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12311. utils.ErrorLog("解析失败:%v", err)
  12312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12313. return
  12314. }
  12315. if res.Infcode == 0 {
  12316. if record_type == 1 {
  12317. service.UpdateDrugByIdDetail(item.ID)
  12318. } else if record_type == 2 {
  12319. service.UpdateGoodInfoById(item.ID)
  12320. } else if record_type == 3 {
  12321. service.UpdateMyProjectById(item.ID)
  12322. }
  12323. c.ServeSuccessJSON(map[string]interface{}{
  12324. "failed_code": 0,
  12325. "msg": "撤销目录对照成功",
  12326. })
  12327. } else {
  12328. c.ServeSuccessJSON(map[string]interface{}{
  12329. "failed_code": -10,
  12330. "msg": res.ErrMsg,
  12331. })
  12332. }
  12333. }
  12334. }
  12335. }
  12336. func (c *HisApiController) GetPatientInfo() {
  12337. id_card_no := c.GetString("id_card_no")
  12338. admin_user_id, _ := c.GetInt64("admin_user_id")
  12339. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12340. if patient.ID == 0 {
  12341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12342. return
  12343. }
  12344. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12345. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12346. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12347. if config.IsOpen == 1 {
  12348. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12349. var dat map[string]interface{}
  12350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12351. fmt.Println(dat)
  12352. } else {
  12353. fmt.Println(err)
  12354. }
  12355. userJSONBytes, _ := json.Marshal(dat)
  12356. var res ResultTwo
  12357. var res10265 ResultTwo10265
  12358. if miConfig.Code == "H15049901371" {
  12359. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12360. utils.ErrorLog("解析失败:%v", err)
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return
  12363. }
  12364. res.ErrMsg = res10265.ErrMsg
  12365. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12366. res.Infcode = infocode
  12367. res.Output = res10265.Output
  12368. res.InfRefmsgid = res10265.InfRefmsgid
  12369. } else {
  12370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12371. utils.ErrorLog("解析失败:%v", err)
  12372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12373. return
  12374. }
  12375. }
  12376. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12377. // utils.ErrorLog("解析失败:%v", err)
  12378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12379. // return
  12380. //}
  12381. if res.Infcode != 0 {
  12382. c.ServeSuccessJSON(map[string]interface{}{
  12383. "failed_code": -10,
  12384. "msg": res.ErrMsg,
  12385. })
  12386. } else {
  12387. c.ServeSuccessJSON(map[string]interface{}{
  12388. "failed_code": 0,
  12389. "info": res,
  12390. })
  12391. }
  12392. }
  12393. }
  12394. func (c *HisApiController) PsnPutOnRecord() {
  12395. record_type, _ := c.GetInt64("type")
  12396. patient_id, _ := c.GetInt64("patient_id")
  12397. admin_user_id, _ := c.GetInt64("admin_user_id")
  12398. start_time := c.GetString("start_time")
  12399. end_time := c.GetString("end_time")
  12400. adminUser := c.GetAdminUserInfo()
  12401. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12402. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12403. var patients []*models.Patients
  12404. if record_type == 1 { //全部备案
  12405. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12406. patients = append(patients, patient...)
  12407. } else { //单个备案
  12408. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12409. patients = append(patients, patient)
  12410. }
  12411. var user_name string
  12412. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12413. if role.ID == 0 {
  12414. user_name = "xxx"
  12415. } else {
  12416. user_name = role.UserName
  12417. }
  12418. if config.IsOpen == 1 {
  12419. for _, item := range patients {
  12420. 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
  12421. resp, requestErr := http.Get(api)
  12422. if requestErr != nil {
  12423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12424. return
  12425. }
  12426. defer resp.Body.Close()
  12427. body, ioErr := ioutil.ReadAll(resp.Body)
  12428. if ioErr != nil {
  12429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12431. return
  12432. }
  12433. var respJSON map[string]interface{}
  12434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12437. return
  12438. }
  12439. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12440. userJSONBytes, _ := json.Marshal(userJSON)
  12441. var res ResultTwo
  12442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12443. utils.ErrorLog("解析失败:%v", err)
  12444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12445. return
  12446. }
  12447. if res.Infcode == 0 {
  12448. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12449. var dat map[string]interface{}
  12450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12451. fmt.Println(dat)
  12452. } else {
  12453. fmt.Println(err)
  12454. }
  12455. userJSONBytes, _ := json.Marshal(dat)
  12456. var res2 ResultThirteen
  12457. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12458. utils.ErrorLog("解析失败:%v", err)
  12459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12460. return
  12461. }
  12462. if res2.Infcode == 0 {
  12463. psnResult := &models.GdybPsnRecord{
  12464. UserOrgId: adminUser.CurrentOrgId,
  12465. PatientId: item.ID,
  12466. PsnNo: res.Output.Baseinfo.PsnNo,
  12467. Ctime: time.Now().Unix(),
  12468. Mtime: time.Now().Unix(),
  12469. Status: 1,
  12470. IsCancel: 1,
  12471. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12472. }
  12473. service.CreatePsnRecord(psnResult)
  12474. } else {
  12475. c.ServeSuccessJSON(map[string]interface{}{
  12476. "failed_code": -10,
  12477. "msg": res2.ErrMsg,
  12478. })
  12479. return
  12480. }
  12481. }
  12482. }
  12483. }
  12484. }
  12485. func (c *HisApiController) PsnUnPutOnRecord() {
  12486. id, _ := c.GetInt64("id")
  12487. //record_type, _ := c.GetInt64("type")
  12488. admin_user_id, _ := c.GetInt64("admin_user_id")
  12489. adminUser := c.GetAdminUserInfo()
  12490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12492. var user_name string
  12493. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12494. if role.ID == 0 {
  12495. user_name = "xxx"
  12496. } else {
  12497. user_name = role.UserName
  12498. }
  12499. psn_record, _ := service.GetPsnRecordById(id)
  12500. if psn_record.ID == 0 {
  12501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12502. return
  12503. }
  12504. if config.IsOpen == 1 {
  12505. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12506. var dat map[string]interface{}
  12507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12508. fmt.Println(dat)
  12509. } else {
  12510. fmt.Println(err)
  12511. }
  12512. userJSONBytes, _ := json.Marshal(dat)
  12513. var res ResultFourteen
  12514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12515. utils.ErrorLog("解析失败:%v", err)
  12516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12517. return
  12518. }
  12519. if res.Infcode == 0 {
  12520. psn_record.IsCancel = 2
  12521. service.CreatePsnRecord(&psn_record)
  12522. } else {
  12523. c.ServeSuccessJSON(map[string]interface{}{
  12524. "failed_code": -10,
  12525. "msg": res.ErrMsg,
  12526. })
  12527. return
  12528. }
  12529. }
  12530. }
  12531. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12532. patient_id, _ := c.GetInt64("patient_id")
  12533. insutype_two := c.GetString("insutype")
  12534. psn_no := c.GetString("psn_no")
  12535. doctor_id, _ := c.GetInt64("doctor_id")
  12536. sick_id, _ := c.GetInt64("sick_id")
  12537. department_id, _ := c.GetInt64("department_id")
  12538. start_time := c.GetString("start_time")
  12539. end_time := c.GetString("end_time")
  12540. check_time := c.GetString("check_time")
  12541. adminUser := c.GetAdminUserInfo()
  12542. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12543. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12544. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12545. sick, _ := service.FindSickById(sick_id)
  12546. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12547. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12548. var res ResultTwo
  12549. var res10265 ResultTwo10265
  12550. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12551. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  12552. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  12553. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12554. "&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
  12555. resp, requestErr := http.Get(api)
  12556. if requestErr != nil {
  12557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12558. return
  12559. }
  12560. body, ioErr := ioutil.ReadAll(resp.Body)
  12561. if ioErr != nil {
  12562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12564. return
  12565. }
  12566. var respJSON map[string]interface{}
  12567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12570. return
  12571. }
  12572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12573. result, _ := json.Marshal(respJSON)
  12574. fmt.Println("log")
  12575. fmt.Println(string(result))
  12576. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12577. utils.ErrorLog("解析失败:%v", err)
  12578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12579. return
  12580. }
  12581. res.ErrMsg = res10265.ErrMsg
  12582. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12583. res.Infcode = infocode
  12584. res.Output = res10265.Output
  12585. res.InfRefmsgid = res10265.InfRefmsgid
  12586. } else {
  12587. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12588. if miConfig.Code == "H15049901371" {
  12589. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12590. utils.ErrorLog("解析失败:%v", err)
  12591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12592. return
  12593. }
  12594. res.ErrMsg = res10265.ErrMsg
  12595. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12596. res.Infcode = infocode
  12597. res.Output = res10265.Output
  12598. res.InfRefmsgid = res10265.InfRefmsgid
  12599. } else {
  12600. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12601. utils.ErrorLog("解析失败:%v", err)
  12602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12603. return
  12604. }
  12605. }
  12606. }
  12607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12608. infoStr := string(Iinfos)
  12609. var rf []*ResultFive
  12610. json.Unmarshal([]byte(infoStr), &rf)
  12611. var insuplc_admdvs string
  12612. var insutype string
  12613. var is390 int = 0
  12614. var is310 int = 0
  12615. var insutypes []*ResultFive
  12616. for _, item := range rf {
  12617. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12618. insutypes = append(insutypes, item)
  12619. }
  12620. }
  12621. if len(insutypes) == 1 {
  12622. insutype = insutypes[0].Insutype
  12623. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12624. } else {
  12625. for _, i := range insutypes {
  12626. if i.Insutype == "390" {
  12627. is390 = 1
  12628. }
  12629. if i.Insutype == "310" {
  12630. is310 = 1
  12631. }
  12632. }
  12633. }
  12634. if is390 == 1 {
  12635. insutype = "390"
  12636. }
  12637. if is310 == 1 {
  12638. insutype = "310"
  12639. }
  12640. if len(insutypes) == 2 {
  12641. insutype = insutype_two
  12642. }
  12643. if len(insutypes) == 0 {
  12644. insutype = "310"
  12645. }
  12646. insutype = insutype_two
  12647. fmt.Println(insutype)
  12648. for _, item := range rf {
  12649. fmt.Println(item.Insutype)
  12650. fmt.Println(insutype)
  12651. if item.Insutype == insutype {
  12652. fmt.Println(item.Insutype)
  12653. fmt.Println(insutype)
  12654. insuplc_admdvs = item.InsuplcAdmdvs
  12655. }
  12656. }
  12657. fmt.Println(insuplc_admdvs)
  12658. var res2 ResultThirteen
  12659. var res10265_2 ResultThirteen10265
  12660. if config.IsOpen == 1 {
  12661. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12662. } else {
  12663. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  12664. var dat map[string]interface{}
  12665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12666. fmt.Println(dat)
  12667. } else {
  12668. fmt.Println(err)
  12669. }
  12670. userJSONBytes, _ := json.Marshal(dat)
  12671. if miConfig.Code == "H15049901371" {
  12672. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  12673. utils.ErrorLog("解析失败:%v", err)
  12674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12675. return
  12676. }
  12677. res2.ErrMsg = res10265_2.ErrMsg
  12678. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  12679. res2.Infcode = infocode
  12680. res2.Output = res10265_2.Output
  12681. res2.InfRefmsgid = res10265_2.InfRefmsgid
  12682. } else {
  12683. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12684. utils.ErrorLog("解析失败:%v", err)
  12685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12686. return
  12687. }
  12688. }
  12689. }
  12690. if res2.Infcode == 0 {
  12691. psnResult := &models.GdybPsnNcdsRecord{
  12692. UserOrgId: adminUser.CurrentOrgId,
  12693. PatientId: patient.ID,
  12694. PsnNo: psn_no,
  12695. DoctorId: doctor.AdminUserId,
  12696. DepartmentId: department_id,
  12697. SickType: sick_id,
  12698. Insutype: insutype,
  12699. Ctime: time.Now().Unix(),
  12700. Mtime: time.Now().Unix(),
  12701. Status: 1,
  12702. IsCancel: 1,
  12703. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12704. }
  12705. service.CreatePsnNCDSRecord(psnResult)
  12706. c.ServeSuccessJSON(map[string]interface{}{
  12707. "failed_code": 0,
  12708. "msg": "备案成功",
  12709. "result": psnResult,
  12710. })
  12711. } else {
  12712. c.ServeSuccessJSON(map[string]interface{}{
  12713. "failed_code": -10,
  12714. "msg": res2.ErrMsg,
  12715. })
  12716. return
  12717. }
  12718. }
  12719. }
  12720. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  12721. id, _ := c.GetInt64("id")
  12722. admin_user_id, _ := c.GetInt64("admin_user_id")
  12723. adminUser := c.GetAdminUserInfo()
  12724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12725. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12726. //config, _ := service.Ge(adminUser.CurrentOrgId)
  12727. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12728. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12729. //var user_name string
  12730. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12731. //if role.ID == 0 {
  12732. // user_name = "xxx"
  12733. //} else {
  12734. // user_name = role.UserName
  12735. //}
  12736. psn_record, _ := service.GetPsnNCDSRecordById(id)
  12737. if psn_record.ID == 0 {
  12738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12739. return
  12740. }
  12741. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12742. var res ResultTwo
  12743. var res10265 ResultTwo10265
  12744. if miConfig.Code == "H15049901371" {
  12745. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12746. utils.ErrorLog("解析失败:%v", err)
  12747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12748. return
  12749. }
  12750. res.ErrMsg = res10265.ErrMsg
  12751. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12752. res.Infcode = infocode
  12753. res.Output = res10265.Output
  12754. res.InfRefmsgid = res10265.InfRefmsgid
  12755. } else {
  12756. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12757. utils.ErrorLog("解析失败:%v", err)
  12758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12759. return
  12760. }
  12761. }
  12762. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12763. infoStr := string(Iinfos)
  12764. var rf []*ResultFive
  12765. json.Unmarshal([]byte(infoStr), &rf)
  12766. var insuplc_admdvs string
  12767. var insutype string
  12768. var is390 int = 0
  12769. var is310 int = 0
  12770. var insutypes []*ResultFive
  12771. for _, item := range rf {
  12772. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12773. insutypes = append(insutypes, item)
  12774. }
  12775. }
  12776. if len(insutypes) == 1 {
  12777. insutype = insutypes[0].Insutype
  12778. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12779. } else {
  12780. for _, i := range insutypes {
  12781. if i.Insutype == "390" {
  12782. is390 = 1
  12783. }
  12784. if i.Insutype == "310" {
  12785. is310 = 1
  12786. }
  12787. }
  12788. }
  12789. if is390 == 1 {
  12790. insutype = "390"
  12791. }
  12792. if is310 == 1 {
  12793. insutype = "310"
  12794. }
  12795. if len(insutypes) == 0 {
  12796. insutype = "310"
  12797. }
  12798. insutype = psn_record.Insutype
  12799. for _, item := range rf {
  12800. if item.Insutype == insutype {
  12801. insuplc_admdvs = item.InsuplcAdmdvs
  12802. }
  12803. }
  12804. if config.IsOpen == 1 {
  12805. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12806. var dat map[string]interface{}
  12807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12808. fmt.Println(dat)
  12809. } else {
  12810. fmt.Println(err)
  12811. }
  12812. userJSONBytes, _ := json.Marshal(dat)
  12813. var res ResultFourteen
  12814. var res10265 ResultFourteen10265
  12815. if miConfig.Code == "H15049901371" {
  12816. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12817. utils.ErrorLog("解析失败:%v", err)
  12818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12819. return
  12820. }
  12821. res.ErrMsg = res10265.ErrMsg
  12822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12823. res.Infcode = infocode
  12824. res.Output = res10265.Output
  12825. res.InfRefmsgid = res10265.InfRefmsgid
  12826. } else {
  12827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12828. utils.ErrorLog("解析失败:%v", err)
  12829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12830. return
  12831. }
  12832. }
  12833. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12834. // utils.ErrorLog("解析失败:%v", err)
  12835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12836. // return
  12837. //}
  12838. if res.Infcode == 0 {
  12839. psn_record.IsCancel = 2
  12840. service.CreatePsnNCDSRecord(&psn_record)
  12841. c.ServeSuccessJSON(map[string]interface{}{
  12842. "failed_code": 0,
  12843. "msg": "撤销备案成功",
  12844. })
  12845. } else {
  12846. c.ServeSuccessJSON(map[string]interface{}{
  12847. "failed_code": -10,
  12848. "msg": res.ErrMsg,
  12849. })
  12850. return
  12851. }
  12852. }
  12853. }
  12854. func (c *HisApiController) TestTest() {
  12855. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  12856. fmt.Println(patient.Iinfo)
  12857. }
  12858. type CustomData struct {
  12859. MsgId string
  12860. PsnNo string
  12861. Info string
  12862. }
  12863. func (c *HisApiController) ReversalData() {
  12864. var customData []*CustomData
  12865. custom := &CustomData{
  12866. MsgId: "H44022900158202103301714472004",
  12867. PsnNo: "44020000001101329945",
  12868. Info: "2207",
  12869. }
  12870. customData = append(customData, custom)
  12871. custom1 := &CustomData{
  12872. MsgId: "H4402290015820210330172057803",
  12873. PsnNo: "44020000001101161813",
  12874. Info: "2207",
  12875. }
  12876. customData = append(customData, custom1)
  12877. custom2 := &CustomData{
  12878. MsgId: "H44022900158202103301705198813",
  12879. PsnNo: "44190000133097375417",
  12880. Info: "2207",
  12881. }
  12882. customData = append(customData, custom2)
  12883. custom3 := &CustomData{
  12884. MsgId: "H44022900158202103301715524756",
  12885. PsnNo: "44020000001100187221",
  12886. Info: "2207",
  12887. }
  12888. customData = append(customData, custom3)
  12889. custom4 := &CustomData{
  12890. MsgId: "H44022900158202103301730376224",
  12891. PsnNo: "44020000001101959155",
  12892. Info: "2207",
  12893. }
  12894. customData = append(customData, custom4)
  12895. custom5 := &CustomData{
  12896. MsgId: "H44022900158202103301748008725",
  12897. PsnNo: "44020000001104246641",
  12898. Info: "2207",
  12899. }
  12900. customData = append(customData, custom5)
  12901. custom6 := &CustomData{
  12902. MsgId: "H44022900158202103301718096755",
  12903. PsnNo: "44020000001102211860",
  12904. Info: "2207",
  12905. }
  12906. customData = append(customData, custom6)
  12907. custom7 := &CustomData{
  12908. MsgId: "H44022900158202103301736551640",
  12909. PsnNo: "44020000001102687718",
  12910. Info: "2207",
  12911. }
  12912. customData = append(customData, custom7)
  12913. custom8 := &CustomData{
  12914. MsgId: "H44022900158202103301743097676",
  12915. PsnNo: "44020000001102127785",
  12916. Info: "2207",
  12917. }
  12918. customData = append(customData, custom8)
  12919. custom9 := &CustomData{
  12920. MsgId: "H44022900158202103301712304203",
  12921. PsnNo: "44020000001101518097",
  12922. Info: "2207",
  12923. }
  12924. customData = append(customData, custom9)
  12925. custom10 := &CustomData{
  12926. MsgId: "H44022900158202103301738448785",
  12927. PsnNo: "44020000001100500813",
  12928. Info: "2207",
  12929. }
  12930. customData = append(customData, custom10)
  12931. custom11 := &CustomData{
  12932. MsgId: "H44022900158202103301732455843",
  12933. PsnNo: "44020000001102690557",
  12934. Info: "2207",
  12935. }
  12936. customData = append(customData, custom11)
  12937. custom12 := &CustomData{
  12938. MsgId: "H44022900158202103301745421708",
  12939. PsnNo: "44020000001102211928",
  12940. Info: "2207",
  12941. }
  12942. customData = append(customData, custom12)
  12943. custom1212 := &CustomData{
  12944. MsgId: "H440229001582021033017351627",
  12945. PsnNo: "44020000001102481733",
  12946. Info: "2207",
  12947. }
  12948. customData = append(customData, custom1212)
  12949. custom13 := &CustomData{
  12950. MsgId: "H44022900158202103301740327951",
  12951. PsnNo: "44020000001103174866",
  12952. Info: "2207",
  12953. }
  12954. customData = append(customData, custom13)
  12955. custom14 := &CustomData{
  12956. MsgId: "H4402290015820210330174922668",
  12957. PsnNo: "44020000001102927272",
  12958. Info: "2207",
  12959. }
  12960. customData = append(customData, custom14)
  12961. custom15 := &CustomData{
  12962. MsgId: "H44022900158202103301752362273",
  12963. PsnNo: "44020000001102942890",
  12964. Info: "2207",
  12965. }
  12966. customData = append(customData, custom15)
  12967. custom16 := &CustomData{
  12968. MsgId: "H44022900158202103301751082917",
  12969. PsnNo: "44020000001101662162",
  12970. Info: "2207",
  12971. }
  12972. customData = append(customData, custom16)
  12973. custom17 := &CustomData{
  12974. MsgId: "H44022900158202103301754147728",
  12975. PsnNo: "44020000000229014511",
  12976. Info: "2207",
  12977. }
  12978. customData = append(customData, custom17)
  12979. adminUser := c.GetAdminUserInfo()
  12980. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12981. for _, item := range customData {
  12982. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12983. fmt.Println(result)
  12984. }
  12985. }
  12986. //func (c *HisApiController) GetAllopatry() {
  12987. // year := c.GetString("year")
  12988. // month := c.GetString("month")
  12989. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12990. // adminUser := c.GetAdminUserInfo()
  12991. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12992. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12993. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  12994. //
  12995. // var dat map[string]interface{}
  12996. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12997. // fmt.Println(dat)
  12998. // } else {
  12999. // fmt.Println(err)
  13000. // }
  13001. // userJSONBytes, _ := json.Marshal(dat)
  13002. // var res models.Result9001
  13003. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13004. // utils.ErrorLog("解析失败:%v", err)
  13005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13006. // return
  13007. // }
  13008. //
  13009. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13010. // var dat2 map[string]interface{}
  13011. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13012. // fmt.Println(dat)
  13013. // } else {
  13014. // fmt.Println(err)
  13015. // }
  13016. // userJSONBytes2, _ := json.Marshal(dat2)
  13017. // var res2 models.Result3260
  13018. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13019. // utils.ErrorLog("解析失败:%v", err)
  13020. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. // return
  13022. // }
  13023. // if res2.Infcode == 0 {
  13024. // c.ServeSuccessJSON(map[string]interface{}{
  13025. // "list": res2.Output.Data,
  13026. // })
  13027. // return
  13028. // } else {
  13029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13030. // return
  13031. // }
  13032. //
  13033. //}
  13034. //func (c *HisApiController) ComfirmAllopatry() {
  13035. // year := c.GetString("year")
  13036. // month := c.GetString("month")
  13037. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13038. // adminUser := c.GetAdminUserInfo()
  13039. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13040. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13041. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13042. // var dat map[string]interface{}
  13043. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13044. // fmt.Println(dat)
  13045. // } else {
  13046. // fmt.Println(err)
  13047. // }
  13048. // userJSONBytes, _ := json.Marshal(dat)
  13049. // var res models.Result9001
  13050. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13051. // utils.ErrorLog("解析失败:%v", err)
  13052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13053. // return
  13054. // }
  13055. //
  13056. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13057. // var dat2 map[string]interface{}
  13058. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13059. // fmt.Println(dat)
  13060. // } else {
  13061. // fmt.Println(err)
  13062. // }
  13063. // userJSONBytes2, _ := json.Marshal(dat2)
  13064. // var res2 models.Result3260
  13065. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13066. // utils.ErrorLog("解析失败:%v", err)
  13067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13068. // return
  13069. // }
  13070. //
  13071. // if res2.Infcode == 0 {
  13072. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13073. // var dat map[string]interface{}
  13074. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13075. // fmt.Println(dat)
  13076. // } else {
  13077. // fmt.Println(err)
  13078. // }
  13079. // userJSONBytes, _ := json.Marshal(dat)
  13080. // var res3 models.Result3261
  13081. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13082. // utils.ErrorLog("解析失败:%v", err)
  13083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13084. // return
  13085. // }
  13086. //
  13087. // if res3.Infcode == 0 {
  13088. // record := &models.HisYidiClearRecord{
  13089. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13090. // Ctime: time.Now().Unix(),
  13091. // Mtime: time.Now().Unix(),
  13092. // Status: 1,
  13093. // MsgId: msgId,
  13094. // }
  13095. // service.SaveClearRecord(record)
  13096. // c.ServeSuccessJSON(map[string]interface{}{
  13097. // "msg": "提取成功",
  13098. // })
  13099. // }
  13100. // }
  13101. //}
  13102. func (c *HisApiController) RefundAllopatry() {
  13103. year := c.GetString("year")
  13104. month := c.GetString("month")
  13105. id, _ := c.GetInt64("id")
  13106. admin_user_id, _ := c.GetInt64("admin_user_id")
  13107. adminUser := c.GetAdminUserInfo()
  13108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13109. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13110. record, _ := service.GetClearRecordById(id)
  13111. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13112. var dat map[string]interface{}
  13113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13114. fmt.Println(dat)
  13115. } else {
  13116. fmt.Println(err)
  13117. }
  13118. userJSONBytes, _ := json.Marshal(dat)
  13119. var empty ResultFourteen
  13120. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13121. utils.ErrorLog("解析失败:%v", err)
  13122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13123. return
  13124. }
  13125. if empty.Infcode == 0 {
  13126. c.ServeSuccessJSON(map[string]interface{}{
  13127. "msg": "撤销成功",
  13128. })
  13129. return
  13130. }
  13131. }
  13132. func (c *HisApiController) ReversalOtherData() {
  13133. var customData []*CustomData
  13134. custom := &CustomData{
  13135. MsgId: "H44022900158202103301714472004",
  13136. PsnNo: "44020000001101329945",
  13137. Info: "2208",
  13138. }
  13139. customData = append(customData, custom)
  13140. custom1 := &CustomData{
  13141. MsgId: "H4402290015820210330172057803",
  13142. PsnNo: "44020000001101161813",
  13143. Info: "2208",
  13144. }
  13145. customData = append(customData, custom1)
  13146. custom2 := &CustomData{
  13147. MsgId: "H44022900158202103301705198813",
  13148. PsnNo: "44190000133097375417",
  13149. Info: "2208",
  13150. }
  13151. customData = append(customData, custom2)
  13152. custom3 := &CustomData{
  13153. MsgId: "H44022900158202103301715524756",
  13154. PsnNo: "44020000001100187221",
  13155. Info: "2208",
  13156. }
  13157. customData = append(customData, custom3)
  13158. custom4 := &CustomData{
  13159. MsgId: "H44022900158202103301730376224",
  13160. PsnNo: "44020000001101959155",
  13161. Info: "2208",
  13162. }
  13163. customData = append(customData, custom4)
  13164. custom5 := &CustomData{
  13165. MsgId: "H44022900158202103301748008725",
  13166. PsnNo: "44020000001104246641",
  13167. Info: "2208",
  13168. }
  13169. customData = append(customData, custom5)
  13170. custom6 := &CustomData{
  13171. MsgId: "H44022900158202103301718096755",
  13172. PsnNo: "44020000001102211860",
  13173. Info: "2208",
  13174. }
  13175. customData = append(customData, custom6)
  13176. custom7 := &CustomData{
  13177. MsgId: "H44022900158202103301736551640",
  13178. PsnNo: "44020000001102687718",
  13179. Info: "2208",
  13180. }
  13181. customData = append(customData, custom7)
  13182. custom8 := &CustomData{
  13183. MsgId: "H44022900158202103301743097676",
  13184. PsnNo: "44020000001102127785",
  13185. Info: "2208",
  13186. }
  13187. customData = append(customData, custom8)
  13188. custom9 := &CustomData{
  13189. MsgId: "H44022900158202103301712304203",
  13190. PsnNo: "44020000001101518097",
  13191. Info: "2208",
  13192. }
  13193. customData = append(customData, custom9)
  13194. custom10 := &CustomData{
  13195. MsgId: "H44022900158202103301738448785",
  13196. PsnNo: "44020000001100500813",
  13197. Info: "2208",
  13198. }
  13199. customData = append(customData, custom10)
  13200. custom11 := &CustomData{
  13201. MsgId: "H44022900158202103301732455843",
  13202. PsnNo: "44020000001102690557",
  13203. Info: "2208",
  13204. }
  13205. customData = append(customData, custom11)
  13206. custom12 := &CustomData{
  13207. MsgId: "H44022900158202103301745421708",
  13208. PsnNo: "44020000001102211928",
  13209. Info: "2208",
  13210. }
  13211. customData = append(customData, custom12)
  13212. custom1212 := &CustomData{
  13213. MsgId: "H440229001582021033017351627",
  13214. PsnNo: "44020000001102481733",
  13215. Info: "2208",
  13216. }
  13217. customData = append(customData, custom1212)
  13218. custom13 := &CustomData{
  13219. MsgId: "H44022900158202103301740327951",
  13220. PsnNo: "44020000001103174866",
  13221. Info: "2208",
  13222. }
  13223. customData = append(customData, custom13)
  13224. custom14 := &CustomData{
  13225. MsgId: "H4402290015820210330174922668",
  13226. PsnNo: "44020000001102927272",
  13227. Info: "2208",
  13228. }
  13229. customData = append(customData, custom14)
  13230. custom15 := &CustomData{
  13231. MsgId: "H44022900158202103301752362273",
  13232. PsnNo: "44020000001102942890",
  13233. Info: "2208",
  13234. }
  13235. customData = append(customData, custom15)
  13236. custom16 := &CustomData{
  13237. MsgId: "H44022900158202103301751082917",
  13238. PsnNo: "44020000001101662162",
  13239. Info: "2208",
  13240. }
  13241. customData = append(customData, custom16)
  13242. custom17 := &CustomData{
  13243. MsgId: "H44022900158202103301754147728",
  13244. PsnNo: "44020000000229014511",
  13245. Info: "2208",
  13246. }
  13247. customData = append(customData, custom17)
  13248. adminUser := c.GetAdminUserInfo()
  13249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13250. for _, item := range customData {
  13251. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13252. fmt.Println(result)
  13253. }
  13254. }
  13255. func PathExists(path string) (bool, error) {
  13256. _, err := os.Stat(path)
  13257. if err == nil {
  13258. return true, nil
  13259. }
  13260. if os.IsNotExist(err) {
  13261. return false, nil
  13262. }
  13263. return false, err
  13264. }
  13265. //创建文件夹
  13266. func Mkdir(dir string) {
  13267. // 创建文件夹
  13268. exist, err := PathExists(dir)
  13269. if err != nil {
  13270. fmt.Println(err.Error())
  13271. } else {
  13272. if exist {
  13273. fmt.Println(dir + "文件夹已存在!")
  13274. } else {
  13275. // 文件夹名称,权限
  13276. err := os.Mkdir(dir, os.ModePerm)
  13277. if err != nil {
  13278. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13279. } else {
  13280. fmt.Println(dir + "文件夹创建成功!")
  13281. }
  13282. }
  13283. }
  13284. }
  13285. //压缩文件
  13286. func Zip(srcFile string, destZip string) error {
  13287. zipfile, err := os.Create(destZip)
  13288. if err != nil {
  13289. return err
  13290. }
  13291. defer zipfile.Close()
  13292. archive := zip.NewWriter(zipfile)
  13293. defer archive.Close()
  13294. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13295. if err != nil {
  13296. return err
  13297. }
  13298. header, err := zip.FileInfoHeader(info)
  13299. if err != nil {
  13300. return err
  13301. }
  13302. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13303. // header.Name = path
  13304. if info.IsDir() {
  13305. header.Name += "/"
  13306. } else {
  13307. header.Method = zip.Deflate
  13308. }
  13309. writer, err := archive.CreateHeader(header)
  13310. if err != nil {
  13311. return err
  13312. }
  13313. if !info.IsDir() {
  13314. file, err := os.Open(path)
  13315. if err != nil {
  13316. return err
  13317. }
  13318. defer file.Close()
  13319. _, err = io.Copy(writer, file)
  13320. }
  13321. return err
  13322. })
  13323. return err
  13324. }
  13325. func ReadFile(filePath string) []byte {
  13326. f, err := os.Open(filePath)
  13327. if err != nil {
  13328. fmt.Println("read file fail", err)
  13329. return nil
  13330. }
  13331. defer f.Close()
  13332. fd, err := ioutil.ReadAll(f)
  13333. if err != nil {
  13334. fmt.Println("read to fd fail", err)
  13335. return nil
  13336. }
  13337. return fd
  13338. }
  13339. func saveLog(result string, request string, infno string, desc string) {
  13340. org_id, _ := beego.AppConfig.Int64("org_id")
  13341. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13342. dir := miConfig.OrgName + "日志"
  13343. utils.Mkdir(dir)
  13344. month := time.Unix(1557042972, 0).Format("1")
  13345. year := time.Now().Format("2006")
  13346. month = time.Now().Format("01")
  13347. day := time.Now().Format("02")
  13348. hour := time.Now().Format("15")
  13349. min := time.Now().Format("04")
  13350. sec := time.Now().Format("05")
  13351. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13352. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13353. file_name := file + ".txt"
  13354. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13355. exist, _ := utils.PathExists(file_path)
  13356. if exist { //存在
  13357. fmt.Println("存在")
  13358. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13359. if err != nil {
  13360. fmt.Println("read fail")
  13361. }
  13362. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13363. n, _ := f.Seek(0, 2)
  13364. _, err = f.WriteAt([]byte(content), n)
  13365. } else { //不存在
  13366. fmt.Println("文件不存在,创建文件")
  13367. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13368. defer f.Close()
  13369. if err != nil {
  13370. } else {
  13371. _, err = f.Write([]byte("记录日志"))
  13372. }
  13373. }
  13374. }
  13375. type Charset string
  13376. const (
  13377. UTF8 = Charset("UTF-8")
  13378. GB18030 = Charset("GB18030")
  13379. )
  13380. func ConvertToString(src string, srcCode string, tagCode string) string {
  13381. srcCoder := mahonia.NewDecoder(srcCode)
  13382. srcResult := srcCoder.ConvertString(src)
  13383. tagCoder := mahonia.NewDecoder(tagCode)
  13384. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13385. result := string(cdata)
  13386. return result
  13387. }
  13388. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13389. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13390. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13391. var token string
  13392. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13393. var api string
  13394. if miConfig.MdtrtareaAdmvs == "320921" {
  13395. 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 +
  13396. "&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
  13397. fmt.Println(api)
  13398. } else {
  13399. 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 +
  13400. "&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
  13401. }
  13402. resp, requestErr := http.Get(api)
  13403. if requestErr != nil {
  13404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13405. return ""
  13406. }
  13407. body, ioErr := ioutil.ReadAll(resp.Body)
  13408. if ioErr != nil {
  13409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13411. return ""
  13412. }
  13413. var respJSON map[string]interface{}
  13414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13417. return ""
  13418. }
  13419. var status string
  13420. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13421. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13422. var res ResultTwo //1101结果
  13423. var res10265 ResultTwo10265 //1101结果
  13424. if status == "0" { //读卡成功
  13425. var card_info string //卡信息
  13426. var busi_card_info string
  13427. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13428. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13429. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13430. fmt.Println(card_info)
  13431. fmt.Println(busi_card_info)
  13432. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13433. result, _ := json.Marshal(respJSON)
  13434. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13435. utils.ErrorLog("解析失败:%v", err)
  13436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13437. return ""
  13438. }
  13439. res.ErrMsg = res10265.ErrMsg
  13440. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13441. res.Infcode = infocode
  13442. res.Output = res10265.Output
  13443. res.InfRefmsgid = res10265.InfRefmsgid
  13444. if res.Infcode == 0 {
  13445. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13446. if err == gorm.ErrRecordNotFound {
  13447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13448. return ""
  13449. } else if err != nil {
  13450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13451. return ""
  13452. } else {
  13453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13455. infoStr := string(Iinfos)
  13456. idetinfoStr := string(Idetinfos)
  13457. psn := &models.HisPsn{
  13458. PsnNo: res.Output.Baseinfo.PsnNo,
  13459. Age: res.Output.Baseinfo.Age,
  13460. PatientId: patient.ID,
  13461. Certno: res.Output.Baseinfo.Certno,
  13462. Brdy: res.Output.Baseinfo.Brdy,
  13463. Gend: res.Output.Baseinfo.Gend,
  13464. Naty: res.Output.Baseinfo.Naty,
  13465. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13466. PsnName: res.Output.Baseinfo.PsnName,
  13467. Idetinfo: idetinfoStr,
  13468. Insuinfo: infoStr,
  13469. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13470. CardInfo: card_info,
  13471. VerifyNumber: token,
  13472. }
  13473. service.CreateHisPsn(psn)
  13474. return token
  13475. }
  13476. }
  13477. } else {
  13478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13479. return ""
  13480. }
  13481. } else { //读卡失败
  13482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13483. return ""
  13484. }
  13485. return token
  13486. }
  13487. func DeleteExtraSpaceTwo(s string) string {
  13488. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13489. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13490. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13491. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13492. s2 := make([]byte, len(s1)) //定义字符数组切片
  13493. copy(s2, s1) //将字符串复制到切片
  13494. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13495. for len(spc_index) > 0 { //找到适配项
  13496. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13497. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13498. }
  13499. return string(s2)
  13500. }
  13501. func Remove0000(s string) string {
  13502. str := make([]rune, 0, len(s))
  13503. for _, v := range []rune(s) {
  13504. if v == 0 {
  13505. continue
  13506. }
  13507. str = append(str, v)
  13508. }
  13509. return string(str)
  13510. }
  13511. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13512. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13513. readCard := DllDef.MustFindProc("EcQuery")
  13514. pCardInfo := make([]byte, 8192)
  13515. pBusiCardInfo := make([]byte, 8192)
  13516. data := make(map[string]interface{})
  13517. //pData := make(map[string]interface{})
  13518. inputData := make(map[string]interface{})
  13519. inputData["orgId"] = code
  13520. inputData["businessType"] = "01101"
  13521. inputData["operatorId"] = operator_id
  13522. inputData["operatorName"] = operator_name
  13523. inputData["officeId"] = "001"
  13524. inputData["officeName"] = "血透室"
  13525. //
  13526. data["data"] = inputData
  13527. data["transType"] = "ec.query"
  13528. data["orgId"] = code
  13529. bytesData, _ := json.Marshal(data)
  13530. pCardInfo = bytesData
  13531. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13532. fmt.Println(ret2)
  13533. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13534. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13535. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13536. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13537. if ret2 != 0 {
  13538. return "", ""
  13539. }
  13540. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13541. }
  13542. func DeleteExtraSpace(s string) string {
  13543. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13544. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13545. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13546. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13547. s2 := make([]byte, len(s1)) //定义字符数组切片
  13548. copy(s2, s1) //将字符串复制到切片
  13549. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13550. for len(spc_index) > 0 { //找到适配项
  13551. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13552. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13553. }
  13554. return string(s2)
  13555. }
  13556. //对账
  13557. func (c *HisApiController) Post3202() {
  13558. start_time := c.GetString("start_time")
  13559. end_time := c.GetString("end_time")
  13560. //insutype := c.GetString("insutype")
  13561. clr_type := c.GetString("clr_type")
  13562. clr_org := c.GetString("clr_optins")
  13563. admin_user_id, _ := c.GetInt64("admin_user_id")
  13564. adminUser := c.GetAdminUserInfo()
  13565. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13566. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13567. if len(clr_org) == 0 {
  13568. clr_org = miConfig.MdtrtareaAdmvs
  13569. }
  13570. timeLayout := "2006-01-02"
  13571. loc, _ := time.LoadLocation("Local")
  13572. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13573. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13574. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13575. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  13576. //fixmedins_setl_cnt := int64(len(orders))
  13577. var medfee_sumamt float64
  13578. var acct_pay float64
  13579. var fund_pay_sumamt float64
  13580. for _, item := range orders {
  13581. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13582. acct_pay = acct_pay + item.AcctPay
  13583. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13584. }
  13585. //var medfee_sumamt_two float64
  13586. //var acct_pay_two float64
  13587. //var fund_pay_sumamt_two float64
  13588. //for _, item := range orders_two {
  13589. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  13590. // acct_pay_two = acct_pay_two + item.AcctPay
  13591. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  13592. //}
  13593. //var user_name string
  13594. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13595. //if role.ID == 0 {
  13596. // user_name = "xxx"
  13597. //} else {
  13598. // user_name = role.UserName
  13599. //}
  13600. var res ResultSix
  13601. if config.IsOpen == 1 {
  13602. var bps []*models.BusinessParamsTwo
  13603. var bp models.BusinessParamsTwo
  13604. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  13605. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  13606. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  13607. bp.MedfeeSumamt = medfee_sumamt_str
  13608. bp.AcctPay = acct_pay_str
  13609. bp.FundPaySumamt = fund_pay_sumamt_str
  13610. bp.Insutype = "390"
  13611. bp.StmtBegndate = start_time
  13612. bp.ClrType = clr_type
  13613. bp.SetlOptins = clr_org
  13614. bp.StmtEnddate = end_time
  13615. bps = append(bps, &bp)
  13616. data := make(map[string]interface{})
  13617. data["bps"] = bps
  13618. data["org_name"] = miConfig.OrgName
  13619. data["doctor"] = role.UserName
  13620. data["fixmedins_code"] = miConfig.Code
  13621. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13622. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13623. if miConfig.MdtrtareaAdmvs == "421300" {
  13624. client := &http.Client{}
  13625. bytesData, _ := json.Marshal(data)
  13626. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  13627. resp, _ := client.Do(req)
  13628. defer resp.Body.Close()
  13629. body, ioErr := ioutil.ReadAll(resp.Body)
  13630. if ioErr != nil {
  13631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13633. return
  13634. }
  13635. var respJSON map[string]interface{}
  13636. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13639. return
  13640. }
  13641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13642. userJSONBytes, _ := json.Marshal(respJSON)
  13643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13644. utils.ErrorLog("解析失败:%v", err)
  13645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13646. return
  13647. }
  13648. }
  13649. if res.Infcode == 0 {
  13650. c.ServeSuccessJSON(map[string]interface{}{
  13651. "msg": "发起成功",
  13652. })
  13653. } else {
  13654. c.ServeSuccessJSON(map[string]interface{}{
  13655. "code": -10,
  13656. "msg": res.ErrMsg,
  13657. })
  13658. }
  13659. }
  13660. }
  13661. func (c *HisApiController) Post3501() {
  13662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13663. data := make(map[string]interface{})
  13664. var struct3501s []models.Struct3501
  13665. var struct3501 models.Struct3501
  13666. struct3501.OrgName = miConfig.OrgName
  13667. struct3501.AccessKey = miConfig.AccessKey
  13668. struct3501.RequestUrl = miConfig.Url
  13669. struct3501.SecretKey = miConfig.SecretKey
  13670. struct3501.ManuDate = "2022-08-17"
  13671. struct3501.FixmedinsBchno = ""
  13672. struct3501.ManuLotnum = ""
  13673. struct3501.RxFlag = "0"
  13674. struct3501.ExpyEnd = "2022-08-17"
  13675. struct3501.Invdate = "2022-08-17"
  13676. struct3501.InvCnt = "20.25"
  13677. struct3501.Memo = ""
  13678. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13679. struct3501.FixmedinsHilistId = miConfig.Code
  13680. struct3501.FixmedinsHilistName = miConfig.OrgName
  13681. struct3501s = append(struct3501s, struct3501)
  13682. data["struct_3501s"] = struct3501s
  13683. client := &http.Client{}
  13684. bytesData, _ := json.Marshal(data)
  13685. var req *http.Request
  13686. if miConfig.MdtrtareaAdmvs == "320921" {
  13687. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13688. } else {
  13689. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13690. }
  13691. resp, _ := client.Do(req)
  13692. defer resp.Body.Close()
  13693. body, ioErr := ioutil.ReadAll(resp.Body)
  13694. if ioErr != nil {
  13695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13697. return
  13698. }
  13699. var respJSON map[string]interface{}
  13700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13703. return
  13704. }
  13705. var res ResultSix
  13706. var resSix10265 ResultSix10265 //1101结果
  13707. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13708. result, _ := json.Marshal(respJSON)
  13709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13710. utils.ErrorLog("解析失败:%v", err)
  13711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13712. return
  13713. }
  13714. res.InfRefmsgid = resSix10265.InfRefmsgid
  13715. res.Output = resSix10265.Output
  13716. res.ErrMsg = resSix10265.ErrMsg
  13717. res.Cainfo = resSix10265.Cainfo
  13718. res.WarnMsg = resSix10265.WarnMsg
  13719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13720. res.Infcode = infocode
  13721. if infocode == 0 {
  13722. c.ServeSuccessJSON(map[string]interface{}{
  13723. "msg": "上传成功",
  13724. })
  13725. return
  13726. } else {
  13727. c.ServeSuccessJSON(map[string]interface{}{
  13728. "failed_code": -10,
  13729. "msg": res.ErrMsg,
  13730. })
  13731. return
  13732. }
  13733. }
  13734. func (c *HisApiController) Post3502() {
  13735. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13736. data := make(map[string]interface{})
  13737. var struct3502s []models.Struct3502
  13738. var struct3502 models.Struct3502
  13739. struct3502.OrgName = miConfig.OrgName
  13740. struct3502.AccessKey = miConfig.AccessKey
  13741. struct3502.RequestUrl = miConfig.Url
  13742. struct3502.SecretKey = miConfig.SecretKey
  13743. struct3502.ManuDate = "2022-08-15"
  13744. struct3502.FixmedinsBchno = ""
  13745. struct3502.ManuLotnum = ""
  13746. struct3502.RxFlag = "0"
  13747. struct3502.ExpyEnd = "2022-08-15"
  13748. struct3502.Invdate = "2022-08-15"
  13749. struct3502.InvCnt = "20.25"
  13750. struct3502.Memo = ""
  13751. struct3502.MedListCodg = "XB01ABD056B002020200517"
  13752. struct3502.FixmedinsHilistId = miConfig.Code
  13753. struct3502.FixmedinsHilistName = miConfig.OrgName
  13754. struct3502s = append(struct3502s, struct3502)
  13755. data["struct_3502s"] = struct3502s
  13756. client := &http.Client{}
  13757. bytesData, _ := json.Marshal(data)
  13758. var req *http.Request
  13759. if miConfig.MdtrtareaAdmvs == "320921" {
  13760. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13761. } else {
  13762. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13763. }
  13764. resp, _ := client.Do(req)
  13765. defer resp.Body.Close()
  13766. body, ioErr := ioutil.ReadAll(resp.Body)
  13767. if ioErr != nil {
  13768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13770. return
  13771. }
  13772. var respJSON map[string]interface{}
  13773. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13776. return
  13777. }
  13778. var res ResultSix
  13779. var resSix10265 ResultSix10265 //1101结果
  13780. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13781. result, _ := json.Marshal(respJSON)
  13782. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13783. utils.ErrorLog("解析失败:%v", err)
  13784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13785. return
  13786. }
  13787. res.InfRefmsgid = resSix10265.InfRefmsgid
  13788. res.Output = resSix10265.Output
  13789. res.ErrMsg = resSix10265.ErrMsg
  13790. res.Cainfo = resSix10265.Cainfo
  13791. res.WarnMsg = resSix10265.WarnMsg
  13792. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13793. res.Infcode = infocode
  13794. if infocode == 0 {
  13795. c.ServeSuccessJSON(map[string]interface{}{
  13796. "msg": "上传成功",
  13797. })
  13798. return
  13799. } else {
  13800. c.ServeSuccessJSON(map[string]interface{}{
  13801. "failed_code": -10,
  13802. "msg": res.ErrMsg,
  13803. })
  13804. return
  13805. }
  13806. }
  13807. func (c *HisApiController) Post3503() {
  13808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13809. data := make(map[string]interface{})
  13810. var struct3501s []models.Struct3501
  13811. var struct3501 models.Struct3501
  13812. struct3501.OrgName = miConfig.OrgName
  13813. struct3501.AccessKey = miConfig.AccessKey
  13814. struct3501.RequestUrl = miConfig.Url
  13815. struct3501.SecretKey = miConfig.SecretKey
  13816. struct3501.ManuDate = "2022-08-15"
  13817. struct3501.FixmedinsBchno = ""
  13818. struct3501.ManuLotnum = ""
  13819. struct3501.RxFlag = "0"
  13820. struct3501.ExpyEnd = "2022-08-15"
  13821. struct3501.Invdate = "2022-08-15"
  13822. struct3501.InvCnt = "20.25"
  13823. struct3501.Memo = ""
  13824. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13825. struct3501.FixmedinsHilistId = miConfig.Code
  13826. struct3501.FixmedinsHilistName = miConfig.OrgName
  13827. struct3501s = append(struct3501s, struct3501)
  13828. data["struct_3501s"] = struct3501s
  13829. client := &http.Client{}
  13830. bytesData, _ := json.Marshal(data)
  13831. var req *http.Request
  13832. if miConfig.MdtrtareaAdmvs == "320921" {
  13833. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13834. } else {
  13835. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13836. }
  13837. resp, _ := client.Do(req)
  13838. defer resp.Body.Close()
  13839. body, ioErr := ioutil.ReadAll(resp.Body)
  13840. if ioErr != nil {
  13841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13843. return
  13844. }
  13845. var respJSON map[string]interface{}
  13846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13849. return
  13850. }
  13851. var res ResultSix
  13852. var resSix10265 ResultSix10265 //1101结果
  13853. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13854. result, _ := json.Marshal(respJSON)
  13855. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13856. utils.ErrorLog("解析失败:%v", err)
  13857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13858. return
  13859. }
  13860. res.InfRefmsgid = resSix10265.InfRefmsgid
  13861. res.Output = resSix10265.Output
  13862. res.ErrMsg = resSix10265.ErrMsg
  13863. res.Cainfo = resSix10265.Cainfo
  13864. res.WarnMsg = resSix10265.WarnMsg
  13865. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13866. res.Infcode = infocode
  13867. if infocode == 0 {
  13868. c.ServeSuccessJSON(map[string]interface{}{
  13869. "msg": "上传成功",
  13870. })
  13871. return
  13872. } else {
  13873. c.ServeSuccessJSON(map[string]interface{}{
  13874. "failed_code": -10,
  13875. "msg": res.ErrMsg,
  13876. })
  13877. return
  13878. }
  13879. }
  13880. func (c *HisApiController) Post3504() {
  13881. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13882. data := make(map[string]interface{})
  13883. var struct3501s []models.Struct3501
  13884. var struct3501 models.Struct3501
  13885. struct3501.OrgName = miConfig.OrgName
  13886. struct3501.AccessKey = miConfig.AccessKey
  13887. struct3501.RequestUrl = miConfig.Url
  13888. struct3501.SecretKey = miConfig.SecretKey
  13889. struct3501.ManuDate = "2022-08-15"
  13890. struct3501.FixmedinsBchno = ""
  13891. struct3501.ManuLotnum = ""
  13892. struct3501.RxFlag = "0"
  13893. struct3501.ExpyEnd = "2022-08-15"
  13894. struct3501.Invdate = "2022-08-15"
  13895. struct3501.InvCnt = "20.25"
  13896. struct3501.Memo = ""
  13897. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13898. struct3501.FixmedinsHilistId = miConfig.Code
  13899. struct3501.FixmedinsHilistName = miConfig.OrgName
  13900. struct3501s = append(struct3501s, struct3501)
  13901. data["struct_3501s"] = struct3501s
  13902. client := &http.Client{}
  13903. bytesData, _ := json.Marshal(data)
  13904. var req *http.Request
  13905. if miConfig.MdtrtareaAdmvs == "320921" {
  13906. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13907. } else {
  13908. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13909. }
  13910. resp, _ := client.Do(req)
  13911. defer resp.Body.Close()
  13912. body, ioErr := ioutil.ReadAll(resp.Body)
  13913. if ioErr != nil {
  13914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13916. return
  13917. }
  13918. var respJSON map[string]interface{}
  13919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13922. return
  13923. }
  13924. var res ResultSix
  13925. var resSix10265 ResultSix10265 //1101结果
  13926. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13927. result, _ := json.Marshal(respJSON)
  13928. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  13929. utils.ErrorLog("解析失败:%v", err)
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13931. return
  13932. }
  13933. res.InfRefmsgid = resSix10265.InfRefmsgid
  13934. res.Output = resSix10265.Output
  13935. res.ErrMsg = resSix10265.ErrMsg
  13936. res.Cainfo = resSix10265.Cainfo
  13937. res.WarnMsg = resSix10265.WarnMsg
  13938. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13939. res.Infcode = infocode
  13940. if infocode == 0 {
  13941. c.ServeSuccessJSON(map[string]interface{}{
  13942. "msg": "上传成功",
  13943. })
  13944. return
  13945. } else {
  13946. c.ServeSuccessJSON(map[string]interface{}{
  13947. "failed_code": -10,
  13948. "msg": res.ErrMsg,
  13949. })
  13950. return
  13951. }
  13952. }
  13953. func (c *HisApiController) Post3505() {
  13954. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13955. data := make(map[string]interface{})
  13956. var struct3501s []models.Struct3501
  13957. var struct3501 models.Struct3501
  13958. struct3501.OrgName = miConfig.OrgName
  13959. struct3501.AccessKey = miConfig.AccessKey
  13960. struct3501.RequestUrl = miConfig.Url
  13961. struct3501.SecretKey = miConfig.SecretKey
  13962. struct3501.ManuDate = "2022-08-15"
  13963. struct3501.FixmedinsBchno = ""
  13964. struct3501.ManuLotnum = ""
  13965. struct3501.RxFlag = "0"
  13966. struct3501.ExpyEnd = "2022-08-15"
  13967. struct3501.Invdate = "2022-08-15"
  13968. struct3501.InvCnt = "20.25"
  13969. struct3501.Memo = ""
  13970. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13971. struct3501.FixmedinsHilistId = miConfig.Code
  13972. struct3501.FixmedinsHilistName = miConfig.OrgName
  13973. struct3501s = append(struct3501s, struct3501)
  13974. data["struct_3501s"] = struct3501s
  13975. client := &http.Client{}
  13976. bytesData, _ := json.Marshal(data)
  13977. var req *http.Request
  13978. if miConfig.MdtrtareaAdmvs == "320921" {
  13979. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13980. } else {
  13981. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13982. }
  13983. resp, _ := client.Do(req)
  13984. defer resp.Body.Close()
  13985. body, ioErr := ioutil.ReadAll(resp.Body)
  13986. if ioErr != nil {
  13987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13989. return
  13990. }
  13991. var respJSON map[string]interface{}
  13992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13995. return
  13996. }
  13997. var res ResultSix
  13998. var resSix10265 ResultSix10265 //1101结果
  13999. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14000. result, _ := json.Marshal(respJSON)
  14001. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14002. utils.ErrorLog("解析失败:%v", err)
  14003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14004. return
  14005. }
  14006. res.InfRefmsgid = resSix10265.InfRefmsgid
  14007. res.Output = resSix10265.Output
  14008. res.ErrMsg = resSix10265.ErrMsg
  14009. res.Cainfo = resSix10265.Cainfo
  14010. res.WarnMsg = resSix10265.WarnMsg
  14011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14012. res.Infcode = infocode
  14013. if infocode == 0 {
  14014. c.ServeSuccessJSON(map[string]interface{}{
  14015. "msg": "上传成功",
  14016. })
  14017. return
  14018. } else {
  14019. c.ServeSuccessJSON(map[string]interface{}{
  14020. "failed_code": -10,
  14021. "msg": res.ErrMsg,
  14022. })
  14023. return
  14024. }
  14025. }
  14026. func (c *HisApiController) Post3506() {
  14027. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14028. data := make(map[string]interface{})
  14029. var struct3501s []models.Struct3501
  14030. var struct3501 models.Struct3501
  14031. struct3501.OrgName = miConfig.OrgName
  14032. struct3501.AccessKey = miConfig.AccessKey
  14033. struct3501.RequestUrl = miConfig.Url
  14034. struct3501.SecretKey = miConfig.SecretKey
  14035. struct3501.ManuDate = "2022-08-15"
  14036. struct3501.FixmedinsBchno = ""
  14037. struct3501.ManuLotnum = ""
  14038. struct3501.RxFlag = "0"
  14039. struct3501.ExpyEnd = "2022-08-15"
  14040. struct3501.Invdate = "2022-08-15"
  14041. struct3501.InvCnt = "20.25"
  14042. struct3501.Memo = ""
  14043. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14044. struct3501.FixmedinsHilistId = miConfig.Code
  14045. struct3501.FixmedinsHilistName = miConfig.OrgName
  14046. struct3501s = append(struct3501s, struct3501)
  14047. data["struct_3501s"] = struct3501s
  14048. client := &http.Client{}
  14049. bytesData, _ := json.Marshal(data)
  14050. var req *http.Request
  14051. if miConfig.MdtrtareaAdmvs == "320921" {
  14052. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14053. } else {
  14054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14055. }
  14056. resp, _ := client.Do(req)
  14057. defer resp.Body.Close()
  14058. body, ioErr := ioutil.ReadAll(resp.Body)
  14059. if ioErr != nil {
  14060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14062. return
  14063. }
  14064. var respJSON map[string]interface{}
  14065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14068. return
  14069. }
  14070. var res ResultSix
  14071. var resSix10265 ResultSix10265 //1101结果
  14072. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14073. result, _ := json.Marshal(respJSON)
  14074. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14075. utils.ErrorLog("解析失败:%v", err)
  14076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14077. return
  14078. }
  14079. res.InfRefmsgid = resSix10265.InfRefmsgid
  14080. res.Output = resSix10265.Output
  14081. res.ErrMsg = resSix10265.ErrMsg
  14082. res.Cainfo = resSix10265.Cainfo
  14083. res.WarnMsg = resSix10265.WarnMsg
  14084. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14085. res.Infcode = infocode
  14086. if infocode == 0 {
  14087. c.ServeSuccessJSON(map[string]interface{}{
  14088. "msg": "上传成功",
  14089. })
  14090. return
  14091. } else {
  14092. c.ServeSuccessJSON(map[string]interface{}{
  14093. "failed_code": -10,
  14094. "msg": res.ErrMsg,
  14095. })
  14096. return
  14097. }
  14098. }
  14099. func (c *HisApiController) Post3507() {
  14100. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14101. data := make(map[string]interface{})
  14102. var struct3501s []models.Struct3501
  14103. var struct3501 models.Struct3501
  14104. struct3501.OrgName = miConfig.OrgName
  14105. struct3501.AccessKey = miConfig.AccessKey
  14106. struct3501.RequestUrl = miConfig.Url
  14107. struct3501.SecretKey = miConfig.SecretKey
  14108. struct3501.ManuDate = "2022-08-15"
  14109. struct3501.FixmedinsBchno = ""
  14110. struct3501.ManuLotnum = ""
  14111. struct3501.RxFlag = "0"
  14112. struct3501.ExpyEnd = "2022-08-15"
  14113. struct3501.Invdate = "2022-08-15"
  14114. struct3501.InvCnt = "20.25"
  14115. struct3501.Memo = ""
  14116. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14117. struct3501.FixmedinsHilistId = miConfig.Code
  14118. struct3501.FixmedinsHilistName = miConfig.OrgName
  14119. struct3501s = append(struct3501s, struct3501)
  14120. data["struct_3501s"] = struct3501s
  14121. client := &http.Client{}
  14122. bytesData, _ := json.Marshal(data)
  14123. var req *http.Request
  14124. if miConfig.MdtrtareaAdmvs == "320921" {
  14125. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14126. } else {
  14127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14128. }
  14129. resp, _ := client.Do(req)
  14130. defer resp.Body.Close()
  14131. body, ioErr := ioutil.ReadAll(resp.Body)
  14132. if ioErr != nil {
  14133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14135. return
  14136. }
  14137. var respJSON map[string]interface{}
  14138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14141. return
  14142. }
  14143. var res ResultSix
  14144. var resSix10265 ResultSix10265 //1101结果
  14145. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14146. result, _ := json.Marshal(respJSON)
  14147. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14148. utils.ErrorLog("解析失败:%v", err)
  14149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14150. return
  14151. }
  14152. res.InfRefmsgid = resSix10265.InfRefmsgid
  14153. res.Output = resSix10265.Output
  14154. res.ErrMsg = resSix10265.ErrMsg
  14155. res.Cainfo = resSix10265.Cainfo
  14156. res.WarnMsg = resSix10265.WarnMsg
  14157. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14158. res.Infcode = infocode
  14159. if infocode == 0 {
  14160. c.ServeSuccessJSON(map[string]interface{}{
  14161. "msg": "上传成功",
  14162. })
  14163. return
  14164. } else {
  14165. c.ServeSuccessJSON(map[string]interface{}{
  14166. "failed_code": -10,
  14167. "msg": res.ErrMsg,
  14168. })
  14169. return
  14170. }
  14171. }