his_api_controller.go 583KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. }
  82. type Result3101 struct {
  83. Infcode string `json:"infcode"`
  84. InfRefmsgid string `json:"inf_refmsgid"`
  85. RefmsgTime string `json:"refmsg_time"`
  86. RespondTime string `json:"respond_time"`
  87. Enctype string `json:"enctype"`
  88. Signtype string `json:"signtype"`
  89. ErrMsg string `json:"err_msg"`
  90. Output struct {
  91. Result []struct {
  92. JudgeResultDetailDtos []struct {
  93. VolaItemType string `json:"vola_item_type"`
  94. MdtrtID string `json:"mdtrt_id"`
  95. JrdID string `json:"jrd_id"`
  96. PatnID string `json:"patn_id"`
  97. RxID string `json:"rx_id"`
  98. VolaAmt interface{} `json:"vola_amt"`
  99. } `json:"judge_result_detail_dtos"`
  100. RuleID string `json:"rule_id"`
  101. VolaEvid string `json:"vola_evid"`
  102. MdtrtID string `json:"mdtrt_id"`
  103. RuleName string `json:"rule_name"`
  104. VolaAmtStas string `json:"vola_amt_stas"`
  105. JrID string `json:"jr_id"`
  106. PatnID string `json:"patn_id"`
  107. SevDeg string `json:"sev_deg"`
  108. VolaAmt float64 `json:"vola_amt"`
  109. VolaBhvrType string `json:"vola_bhvr_type"`
  110. VolaCont string `json:"vola_cont"`
  111. } `json:"result"`
  112. } `json:"output"`
  113. }
  114. func (c *HisApiController) ReadEleToken() {
  115. admin_user_id, _ := c.GetInt64("admin_user_id")
  116. his_patient_id, _ := c.GetInt64("his_patient_id")
  117. adminUser := c.GetAdminUserInfo()
  118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  122. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  123. if len(tokens) > 0 {
  124. c.ServeSuccessJSON(map[string]interface{}{
  125. "msg": "读取成功",
  126. })
  127. } else {
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "failed_code": -10,
  130. "msg": "读取失败",
  131. })
  132. }
  133. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  134. if initFlag == 0 {
  135. c.TestGetBasBaseInit()
  136. }
  137. token := c.GetEleBaseInfo()
  138. token = Remove0000(token)
  139. if len(token) > 0 {
  140. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  142. var res ResultTwo
  143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  144. utils.ErrorLog("解析失败:%v", err)
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. if res.Infcode == 0 {
  149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  150. if err == gorm.ErrRecordNotFound {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  152. return
  153. } else if err != nil {
  154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  155. return
  156. } else {
  157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  159. infoStr := string(Iinfos)
  160. idetinfoStr := string(Idetinfos)
  161. psn := &models.HisPsn{
  162. PsnNo: res.Output.Baseinfo.PsnNo,
  163. Age: res.Output.Baseinfo.Age,
  164. PatientId: patient.ID,
  165. Certno: res.Output.Baseinfo.Certno,
  166. Brdy: res.Output.Baseinfo.Brdy,
  167. Gend: res.Output.Baseinfo.Gend,
  168. Naty: res.Output.Baseinfo.Naty,
  169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  170. PsnName: res.Output.Baseinfo.PsnName,
  171. Idetinfo: idetinfoStr,
  172. Insuinfo: infoStr,
  173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  174. CardInfo: "",
  175. VerifyNumber: token,
  176. }
  177. service.CreateHisPsn(psn)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "msg": "读取成功",
  180. })
  181. }
  182. } else {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  184. return
  185. }
  186. } else {
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "failed_code": -10,
  189. "msg": "读取失败",
  190. })
  191. }
  192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  193. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  194. if len(errMsg) == 0 {
  195. type ELeData struct {
  196. Data struct {
  197. IdNo string `json:"idNo"`
  198. IdType string `json:"idType"`
  199. UserName string `json:"userName"`
  200. EcToken string `json:"ecToken"`
  201. InsuOrg string `json:"insuOrg"`
  202. Gender string `json:"gender"`
  203. Birthday string `json:"birthday"`
  204. Nationality string `json:"nationality"`
  205. Email string `json:"email"`
  206. Extra string `json:"extra"`
  207. } `json:"data"`
  208. Code int `json:"code"`
  209. Message string `json:"message"`
  210. }
  211. var ele ELeData
  212. err := json.Unmarshal([]byte(outPutInfo), &ele)
  213. if err != nil {
  214. utils.ErrorLog("解析失败:%v", err)
  215. }
  216. token := ele.Data.EcToken
  217. if len(token) > 0 {
  218. psn := &models.HisPsn{
  219. PsnNo: his.PsnNo,
  220. Age: 0,
  221. PatientId: his.PatientId,
  222. Certno: his.Certno,
  223. Brdy: his.Brdy,
  224. Gend: his.Gend,
  225. Naty: his.Naty,
  226. PsnCertType: his.PsnCertType,
  227. PsnName: his.PsnName,
  228. Idetinfo: his.Idetinfo,
  229. Insuinfo: his.Iinfo,
  230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  231. CardInfo: outPutInfo,
  232. VerifyNumber: token,
  233. }
  234. service.CreateHisPsn(psn)
  235. }
  236. if len(token) > 0 {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "读取成功",
  239. })
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": "读取失败",
  244. })
  245. }
  246. }
  247. } else if miConfig.MdtrtareaAdmvs == "360399" {
  248. if initFlag == 0 {
  249. c.TestGetJiangXiBasBaseInit()
  250. }
  251. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  252. type ELeData struct {
  253. Data struct {
  254. IdNo string `json:"idNo"`
  255. IdType string `json:"idType"`
  256. UserName string `json:"userName"`
  257. EcToken string `json:"ecToken"`
  258. InsuOrg string `json:"insuOrg"`
  259. Gender string `json:"gender"`
  260. Birthday string `json:"birthday"`
  261. Nationality string `json:"nationality"`
  262. Email string `json:"email"`
  263. Extra string `json:"extra"`
  264. } `json:"data"`
  265. Code int `json:"code"`
  266. Message string `json:"message"`
  267. }
  268. var ele ELeData
  269. err := json.Unmarshal([]byte(json_result), &ele)
  270. if err != nil {
  271. utils.ErrorLog("解析失败:%v", err)
  272. }
  273. token := ele.Data.EcToken
  274. token = Remove0000(token)
  275. fmt.Println(ele.Data.UserName)
  276. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  277. saveLog(result2, requestLog2, "1101", "获取人员信息")
  278. var res ResultTwo
  279. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  280. utils.ErrorLog("解析失败:%v", err)
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. if res.Infcode == 0 {
  285. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  286. if err == gorm.ErrRecordNotFound {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  288. return
  289. } else if err != nil {
  290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  291. return
  292. } else {
  293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  295. infoStr := string(Iinfos)
  296. idetinfoStr := string(Idetinfos)
  297. psn := &models.HisPsn{
  298. PsnNo: res.Output.Baseinfo.PsnNo,
  299. Age: res.Output.Baseinfo.Age,
  300. PatientId: patient.ID,
  301. Certno: res.Output.Baseinfo.Certno,
  302. Brdy: res.Output.Baseinfo.Brdy,
  303. Gend: res.Output.Baseinfo.Gend,
  304. Naty: res.Output.Baseinfo.Naty,
  305. PsnCertType: res.Output.Baseinfo.PsnCertType,
  306. PsnName: res.Output.Baseinfo.PsnName,
  307. Idetinfo: idetinfoStr,
  308. Insuinfo: infoStr,
  309. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  310. CardInfo: "",
  311. VerifyNumber: token,
  312. }
  313. service.CreateHisPsn(psn)
  314. c.ServeSuccessJSON(map[string]interface{}{
  315. "patient": patient,
  316. "number": token,
  317. })
  318. }
  319. } else {
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  321. return
  322. }
  323. } else if miConfig.MdtrtareaAdmvs == "430800" {
  324. if initFlag == 0 {
  325. c.TestGetJiangXiBasBaseInit()
  326. }
  327. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. type ELeData struct {
  329. Data struct {
  330. IdNo string `json:"idNo"`
  331. IdType string `json:"idType"`
  332. UserName string `json:"userName"`
  333. EcToken string `json:"ecToken"`
  334. InsuOrg string `json:"insuOrg"`
  335. Gender string `json:"gender"`
  336. Birthday string `json:"birthday"`
  337. Nationality string `json:"nationality"`
  338. Email string `json:"email"`
  339. Extra string `json:"extra"`
  340. } `json:"data"`
  341. Code int `json:"code"`
  342. Message string `json:"message"`
  343. }
  344. var ele ELeData
  345. err := json.Unmarshal([]byte(json_result), &ele)
  346. if err != nil {
  347. utils.ErrorLog("解析失败:%v", err)
  348. }
  349. token := ele.Data.EcToken
  350. token = Remove0000(token)
  351. fmt.Println(ele.Data.UserName)
  352. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  353. saveLog(result2, requestLog2, "1101", "获取人员信息")
  354. var res ResultTwo
  355. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  356. utils.ErrorLog("解析失败:%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. if res.Infcode == 0 {
  361. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  362. if err == gorm.ErrRecordNotFound {
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  364. return
  365. } else if err != nil {
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  367. return
  368. } else {
  369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  371. infoStr := string(Iinfos)
  372. idetinfoStr := string(Idetinfos)
  373. psn := &models.HisPsn{
  374. PsnNo: res.Output.Baseinfo.PsnNo,
  375. Age: res.Output.Baseinfo.Age,
  376. PatientId: patient.ID,
  377. Certno: res.Output.Baseinfo.Certno,
  378. Brdy: res.Output.Baseinfo.Brdy,
  379. Gend: res.Output.Baseinfo.Gend,
  380. Naty: res.Output.Baseinfo.Naty,
  381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  382. PsnName: res.Output.Baseinfo.PsnName,
  383. Idetinfo: idetinfoStr,
  384. Insuinfo: infoStr,
  385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  386. CardInfo: "",
  387. VerifyNumber: token,
  388. }
  389. service.CreateHisPsn(psn)
  390. c.ServeSuccessJSON(map[string]interface{}{
  391. "patient": patient,
  392. "number": token,
  393. })
  394. }
  395. } else {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  397. return
  398. }
  399. }
  400. }
  401. func (c *HisApiController) Get9001() {
  402. adminUser := c.GetAdminUserInfo()
  403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  405. if miConfig.MdtrtareaAdmvs == "350500" {
  406. service.GetFjAuthorizationInfo(miConfig.Code)
  407. } else if miConfig.MdtrtareaAdmvs == "131023" {
  408. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  409. var dat map[string]interface{}
  410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  411. fmt.Println(dat)
  412. } else {
  413. fmt.Println(err)
  414. }
  415. userJSONBytes, _ := json.Marshal(dat)
  416. var res models.Result9001
  417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  418. utils.ErrorLog("解析失败:%v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. } else {
  423. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  424. var dat map[string]interface{}
  425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  426. fmt.Println(dat)
  427. } else {
  428. fmt.Println(err)
  429. }
  430. userJSONBytes, _ := json.Marshal(dat)
  431. var res models.Result9001
  432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  433. utils.ErrorLog("解析失败:%v", err)
  434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  435. return
  436. }
  437. }
  438. }
  439. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  440. var res Result3101
  441. adminUser := c.GetAdminUserInfo()
  442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  443. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  445. //record_time := c.GetString("record_time")
  446. //trig_scen := c.GetString("trig_scen")
  447. timeLayout := "2006-01-02"
  448. loc, _ := time.LoadLocation("Local")
  449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  450. if err != nil {
  451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  452. return res
  453. }
  454. recordDateTime := theTime.Unix()
  455. var patientPrescription models.HisPrescriptionInfo
  456. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  457. //if patientPrescription.ID == 0 {
  458. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  459. //}
  460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  462. //
  463. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  464. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  465. var pp models.PublicParams
  466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  468. pp.FixmedinsName = miConfig.OrgName
  469. pp.FixmedinsCode = miConfig.Code
  470. pp.RequestUrl = miConfig.Url
  471. pp.Cainfo = miConfig.Cainfo
  472. pp.SecretKey = miConfig.SecretKey
  473. pp.AccessKey = miConfig.AccessKey
  474. pp.OpterName = roles.UserName
  475. var config []*models.HisXtDiagnoseConfig
  476. for _, item := range diagnosis_ids {
  477. id, _ := strconv.ParseInt(item, 10, 64)
  478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  479. config = append(config, &diagnosisConfig)
  480. }
  481. var pd models.PatientDtos
  482. pd.PatnID = his.PsnNo
  483. pd.PatnName = his.Name
  484. pd.Gend = his.Gend
  485. pd.Brdy = his.Brdy
  486. pd.Poolarea = miConfig.MdtrtareaAdmvs
  487. pd.CurrMdtrtID = his.Number
  488. var fed models.FsiEncounterDtos
  489. fed.MdtrtID = his.Number
  490. fed.MedinsID = miConfig.Code
  491. fed.MedinsName = miConfig.OrgName
  492. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  493. fed.MedMdtrtType = "1"
  494. fed.MedinsType = "1"
  495. fed.MedinsLv = "11"
  496. tm := time.Unix(his.RecordDate, 0)
  497. s_tm := tm.Format("2006-01-02 15:04:05")
  498. fed.AdmDate = s_tm
  499. fed.DscgDate = s_tm
  500. fed.DscgMainDiseCodg = config[0].CountryCode
  501. fed.DscgMainDiseName = config[0].CountryContentName
  502. //诊断信息
  503. var fdds []*models.FsiDiagnoseDtos
  504. for index, item := range config {
  505. if index == 0 {
  506. var fdd models.FsiDiagnoseDtos
  507. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  508. fdd.InoutDiseType = "1"
  509. fdd.MaindiseFlag = "1"
  510. fdd.DiseDate = s_tm
  511. fdd.DiasSrtNo = "1"
  512. fdd.DiseName = item.CountryContentName
  513. fdd.DiseCodg = item.CountryCode
  514. fdds = append(fdds, &fdd)
  515. } else {
  516. var fdd models.FsiDiagnoseDtos
  517. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  518. fdd.InoutDiseType = "1"
  519. fdd.MaindiseFlag = "1"
  520. fdd.DiseDate = s_tm
  521. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  522. fdd.DiseName = item.CountryContentName
  523. fdd.DiseCodg = item.CountryCode
  524. fdds = append(fdds, &fdd)
  525. }
  526. }
  527. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  528. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  529. fed.AdmDeptName = department.Name
  530. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  531. fed.DscgDeptName = department.Name
  532. fed.MedMdtrtType = "1"
  533. fed.MedType = "11"
  534. //if his.Insutype == "390" {
  535. // fed.MedType = "1402"
  536. //} else {
  537. // fed.MedType = "9933"
  538. //}
  539. var orders []*models.FsiOrderDtos
  540. if trig_scen == "2" {
  541. //处方医嘱信息
  542. for _, item := range prescriptions {
  543. for _, subItem := range item.HisDoctorAdviceInfo {
  544. var order models.FsiOrderDtos
  545. order.RxID = strconv.FormatInt(item.ID, 10)
  546. order.Rxno = strconv.FormatInt(item.ID, 10)
  547. order.LongDrordFlag = "0"
  548. order.HilistType = "1"
  549. order.ChrgType = "1"
  550. order.DrordBhvr = "-"
  551. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  552. order.HosplistName = subItem.BaseDrugLib.DrugName
  553. order.HilistLv = "1"
  554. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  555. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  556. order.HosplistName = subItem.BaseDrugLib.DrugName
  557. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  558. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  559. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  560. order.OwnpayAmt = ""
  561. order.SelfpayAmt = ""
  562. order.Spec = ""
  563. order.SpecUnt = ""
  564. order.DrordBegnDate = s_tm
  565. order.DrordStopDate = ""
  566. order.DrordDrCodg = "1"
  567. order.DrordDeptName = department.Name
  568. order.DrordDrCodg = "1"
  569. order.DrordDrName = doctor_info.UserName
  570. order.DrordDrProfttl = ""
  571. order.CurrDrordFlag = "1"
  572. orders = append(orders, &order)
  573. }
  574. for _, subItem := range item.HisPrescriptionProject {
  575. if subItem.Type == 2 {
  576. var order models.FsiOrderDtos
  577. order.RxID = strconv.FormatInt(item.ID, 10)
  578. order.Rxno = strconv.FormatInt(item.ID, 10)
  579. order.LongDrordFlag = "0"
  580. order.HilistType = "1"
  581. order.ChrgType = "1"
  582. order.DrordBhvr = "-"
  583. order.HilistCode = subItem.HisProject.MedicalCode
  584. order.HosplistName = subItem.HisProject.ProjectName
  585. order.HilistLv = "1"
  586. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  587. order.HosplistCode = subItem.HisProject.MedicalCode
  588. order.HosplistName = subItem.HisProject.ProjectName
  589. order.Cnt = subItem.Count
  590. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  591. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  592. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  593. order.OwnpayAmt = ""
  594. order.SelfpayAmt = ""
  595. order.Spec = ""
  596. order.SpecUnt = ""
  597. order.DrordBegnDate = s_tm
  598. order.DrordStopDate = ""
  599. order.DrordDrCodg = "1"
  600. order.DrordDeptName = department.Name
  601. order.DrordDrCodg = "1"
  602. order.DrordDrName = doctor_info.UserName
  603. order.DrordDrProfttl = ""
  604. order.CurrDrordFlag = "1"
  605. orders = append(orders, &order)
  606. }
  607. if subItem.Type == 3 {
  608. var order models.FsiOrderDtos
  609. order.RxID = strconv.FormatInt(item.ID, 10)
  610. order.Rxno = strconv.FormatInt(item.ID, 10)
  611. order.LongDrordFlag = "0"
  612. order.HilistType = "1"
  613. order.ChrgType = "1"
  614. order.DrordBhvr = "-"
  615. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  616. order.HosplistName = subItem.GoodInfo.GoodName
  617. order.HilistLv = "1"
  618. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  619. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  620. order.HosplistName = subItem.GoodInfo.GoodName
  621. order.Cnt = subItem.Count
  622. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  623. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  624. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  625. order.OwnpayAmt = ""
  626. order.SelfpayAmt = ""
  627. order.Spec = ""
  628. order.SpecUnt = ""
  629. order.DrordBegnDate = s_tm
  630. order.DrordStopDate = ""
  631. order.DrordDrCodg = "1"
  632. order.DrordDeptName = department.Name
  633. order.DrordDrCodg = "1"
  634. order.DrordDrName = doctor_info.UserName
  635. order.DrordDrProfttl = ""
  636. order.CurrDrordFlag = "1"
  637. orders = append(orders, &order)
  638. }
  639. }
  640. }
  641. //处方医嘱信息
  642. }
  643. fed.MatnStas = "0"
  644. fed.MedfeeSumamt = "0"
  645. fed.OwnpayAmt = "0"
  646. fed.SelfpayAmt = "0"
  647. fed.AcctPayamt = "0"
  648. fed.MaAmt = "0"
  649. fed.HifpPayamt = "0"
  650. fed.SetlTotlnum = "1"
  651. fed.Insutype = his.Insutype
  652. fed.ReimFlag = "0"
  653. fed.OutSetlFlag = "0"
  654. var fopd []*models.FsiOperationDtosData
  655. data := make(map[string]interface{})
  656. data["fed"] = fed
  657. data["fdd"] = fdds
  658. data["fod"] = orders
  659. data["pd"] = pd
  660. data["pp"] = pp
  661. data["fopd"] = fopd
  662. data["trig_scen"] = trig_scen
  663. fmt.Println(data)
  664. fmt.Println(fed)
  665. fmt.Println(fdds)
  666. fmt.Println(orders)
  667. fmt.Println(pd)
  668. fmt.Println(pp)
  669. fmt.Println(fopd)
  670. client := &http.Client{}
  671. bytesData, _ := json.Marshal(data)
  672. var req *http.Request
  673. if miConfig.MdtrtareaAdmvs == "320921" {
  674. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  675. } else {
  676. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  677. }
  678. resp, _ := client.Do(req)
  679. defer resp.Body.Close()
  680. body, ioErr := ioutil.ReadAll(resp.Body)
  681. if ioErr != nil {
  682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. return res
  685. }
  686. var respJSON map[string]interface{}
  687. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return res
  691. }
  692. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  693. fmt.Println(respJSON)
  694. result, _ := json.Marshal(respJSON)
  695. fmt.Println(result)
  696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return res
  700. }
  701. return res
  702. }
  703. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  704. adminUser := c.GetAdminUserInfo()
  705. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  706. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  707. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  708. //record_time := c.GetString("record_time")
  709. //trig_scen := c.GetString("trig_scen")
  710. timeLayout := "2006-01-02"
  711. loc, _ := time.LoadLocation("Local")
  712. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  713. if err != nil {
  714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  715. return res
  716. }
  717. recordDateTime := theTime.Unix()
  718. var patientPrescription models.HisPrescriptionInfo
  719. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  720. if patientPrescription.ID == 0 {
  721. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  722. }
  723. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  724. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  725. //
  726. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  727. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  728. var pp models.PublicParams
  729. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  731. pp.FixmedinsName = miConfig.OrgName
  732. pp.FixmedinsCode = miConfig.Code
  733. pp.RequestUrl = miConfig.Url
  734. pp.Cainfo = miConfig.Cainfo
  735. pp.SecretKey = miConfig.SecretKey
  736. pp.AccessKey = miConfig.AccessKey
  737. pp.OpterName = roles.UserName
  738. var config []*models.HisXtDiagnoseConfig
  739. for _, item := range diagnosis_ids {
  740. id, _ := strconv.ParseInt(item, 10, 64)
  741. diagnosisConfig, _ := service.FindDiagnoseById(id)
  742. config = append(config, &diagnosisConfig)
  743. }
  744. var pd models.PatientDtos
  745. pd.PatnID = his.PsnNo
  746. pd.PatnName = his.Name
  747. pd.Gend = his.Gend
  748. pd.Brdy = his.Brdy
  749. pd.Poolarea = his.InsuplcAdmdvs
  750. pd.CurrMdtrtID = his.Number
  751. var fed models.FsiEncounterDtos
  752. fed.MdtrtID = his.Number
  753. fed.MedinsID = miConfig.Code
  754. fed.MedinsName = miConfig.OrgName
  755. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  756. fed.MedMdtrtType = "1"
  757. fed.MedinsType = "1"
  758. fed.MedinsLv = "11"
  759. tm := time.Unix(his.RecordDate, 0)
  760. s_tm := tm.Format("2006-01-02 15:04:05")
  761. fed.AdmDate = s_tm
  762. fed.DscgDate = s_tm
  763. fed.DscgMainDiseCodg = config[0].CountryCode
  764. fed.DscgMainDiseName = config[0].CountryContentName
  765. //诊断信息
  766. var fdds []*models.FsiDiagnoseDtos
  767. for index, item := range config {
  768. if index == 0 {
  769. var fdd models.FsiDiagnoseDtos
  770. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  771. fdd.InoutDiseType = "1"
  772. fdd.MaindiseFlag = "1"
  773. fdd.DiseDate = s_tm
  774. fdd.DiasSrtNo = "1"
  775. fdd.DiseName = item.CountryContentName
  776. fdd.DiseCodg = item.CountryCode
  777. fdds = append(fdds, &fdd)
  778. } else {
  779. var fdd models.FsiDiagnoseDtos
  780. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  781. fdd.InoutDiseType = "1"
  782. fdd.MaindiseFlag = "1"
  783. fdd.DiseDate = s_tm
  784. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  785. fdd.DiseName = item.CountryContentName
  786. fdd.DiseCodg = item.CountryCode
  787. fdds = append(fdds, &fdd)
  788. }
  789. }
  790. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  791. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  792. fed.AdmDeptName = department.Name
  793. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  794. fed.DscgDeptName = department.Name
  795. fed.MedMdtrtType = "1"
  796. fed.MedType = "11"
  797. //if his.Insutype == "390" {
  798. // fed.MedType = "1402"
  799. //} else {
  800. // fed.MedType = "9933"
  801. //}
  802. var orders []*models.FsiOrderDtos
  803. if trig_scen == "2" {
  804. //处方医嘱信息
  805. for _, item := range prescriptions {
  806. for _, subItem := range item.HisDoctorAdviceInfo {
  807. var order models.FsiOrderDtos
  808. order.RxID = strconv.FormatInt(item.ID, 10)
  809. order.Rxno = strconv.FormatInt(item.ID, 10)
  810. order.LongDrordFlag = "0"
  811. order.HilistType = "1"
  812. order.ChrgType = "1"
  813. order.DrordBhvr = "-"
  814. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  815. order.HosplistName = subItem.BaseDrugLib.DrugName
  816. order.HilistLv = "1"
  817. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  818. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  819. order.HosplistName = subItem.BaseDrugLib.DrugName
  820. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  821. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  822. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  823. order.OwnpayAmt = ""
  824. order.SelfpayAmt = ""
  825. order.Spec = ""
  826. order.SpecUnt = ""
  827. order.DrordBegnDate = s_tm
  828. order.DrordStopDate = ""
  829. order.DrordDrCodg = "1"
  830. order.DrordDeptName = department.Name
  831. order.DrordDrCodg = "1"
  832. order.DrordDrName = doctor_info.UserName
  833. order.DrordDrProfttl = ""
  834. order.CurrDrordFlag = "1"
  835. orders = append(orders, &order)
  836. }
  837. for _, subItem := range item.HisPrescriptionProject {
  838. if subItem.Type == 2 {
  839. var order models.FsiOrderDtos
  840. order.RxID = strconv.FormatInt(item.ID, 10)
  841. order.Rxno = strconv.FormatInt(item.ID, 10)
  842. order.LongDrordFlag = "0"
  843. order.HilistType = "1"
  844. order.ChrgType = "1"
  845. order.DrordBhvr = "-"
  846. order.HilistCode = subItem.HisProject.MedicalCode
  847. order.HosplistName = subItem.HisProject.ProjectName
  848. order.HilistLv = "1"
  849. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  850. order.HosplistCode = subItem.HisProject.MedicalCode
  851. order.HosplistName = subItem.HisProject.ProjectName
  852. order.Cnt = subItem.Count
  853. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  854. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  855. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  856. order.OwnpayAmt = ""
  857. order.SelfpayAmt = ""
  858. order.Spec = ""
  859. order.SpecUnt = ""
  860. order.DrordBegnDate = s_tm
  861. order.DrordStopDate = ""
  862. order.DrordDrCodg = "1"
  863. order.DrordDeptName = department.Name
  864. order.DrordDrCodg = "1"
  865. order.DrordDrName = doctor_info.UserName
  866. order.DrordDrProfttl = ""
  867. order.CurrDrordFlag = "1"
  868. orders = append(orders, &order)
  869. }
  870. if subItem.Type == 3 {
  871. var order models.FsiOrderDtos
  872. order.RxID = strconv.FormatInt(item.ID, 10)
  873. order.Rxno = strconv.FormatInt(item.ID, 10)
  874. order.LongDrordFlag = "0"
  875. order.HilistType = "1"
  876. order.ChrgType = "1"
  877. order.DrordBhvr = "-"
  878. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  879. order.HosplistName = subItem.GoodInfo.GoodName
  880. order.HilistLv = "1"
  881. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  882. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  883. order.HosplistName = subItem.GoodInfo.GoodName
  884. order.Cnt = subItem.Count
  885. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  886. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  887. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  888. order.OwnpayAmt = ""
  889. order.SelfpayAmt = ""
  890. order.Spec = ""
  891. order.SpecUnt = ""
  892. order.DrordBegnDate = s_tm
  893. order.DrordStopDate = ""
  894. order.DrordDrCodg = "1"
  895. order.DrordDeptName = department.Name
  896. order.DrordDrCodg = "1"
  897. order.DrordDrName = doctor_info.UserName
  898. order.DrordDrProfttl = ""
  899. order.CurrDrordFlag = "1"
  900. orders = append(orders, &order)
  901. }
  902. }
  903. }
  904. //处方医嘱信息
  905. }
  906. fed.MatnStas = "0"
  907. fed.MedfeeSumamt = "0"
  908. fed.OwnpayAmt = "0"
  909. fed.SelfpayAmt = "0"
  910. fed.AcctPayamt = "0"
  911. fed.MaAmt = "0"
  912. fed.HifpPayamt = "0"
  913. fed.SetlTotlnum = "1"
  914. fed.Insutype = his.Insutype
  915. fed.ReimFlag = "0"
  916. fed.OutSetlFlag = "0"
  917. var fopd []*models.FsiOperationDtosData
  918. data := make(map[string]interface{})
  919. data["fed"] = fed
  920. data["fdd"] = fdds
  921. data["fod"] = orders
  922. data["pd"] = pd
  923. data["pp"] = pp
  924. data["fopd"] = fopd
  925. data["trig_scen"] = trig_scen
  926. fmt.Println(data)
  927. fmt.Println(fed)
  928. fmt.Println(fdds)
  929. fmt.Println(orders)
  930. fmt.Println(pd)
  931. fmt.Println(pp)
  932. fmt.Println(fopd)
  933. client := &http.Client{}
  934. bytesData, _ := json.Marshal(data)
  935. var req *http.Request
  936. if miConfig.MdtrtareaAdmvs == "320921" {
  937. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  938. } else {
  939. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  940. }
  941. resp, _ := client.Do(req)
  942. defer resp.Body.Close()
  943. body, ioErr := ioutil.ReadAll(resp.Body)
  944. if ioErr != nil {
  945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  947. return res
  948. }
  949. var respJSON map[string]interface{}
  950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  953. return res
  954. }
  955. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  956. result, _ := json.Marshal(respJSON)
  957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  958. utils.ErrorLog("解析失败:%v", err)
  959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  960. return res
  961. }
  962. return res
  963. }
  964. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  965. ////patient_id, _ := c.GetInt64("patient_id")
  966. //order_id, _ := c.GetInt64("order_id")
  967. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  968. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  969. //trig_scen := c.GetString("trig_scen")
  970. adminUser := c.GetAdminUserInfo()
  971. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  972. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  973. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  974. record_time := c.GetString("record_time")
  975. order, _ := service.GetHisOrderByID(order_id)
  976. timeLayout := "2006-01-02"
  977. loc, _ := time.LoadLocation("Local")
  978. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  979. if err != nil {
  980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  981. return
  982. }
  983. recordDateTime := theTime.Unix()
  984. var patientPrescription models.HisPrescriptionInfo
  985. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  986. if patientPrescription.ID == 0 {
  987. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  988. }
  989. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  990. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  991. //
  992. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  993. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  994. var pp models.PublicParams
  995. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  997. pp.FixmedinsName = miConfig.OrgName
  998. pp.FixmedinsCode = miConfig.Code
  999. pp.RequestUrl = miConfig.Url
  1000. pp.Cainfo = miConfig.Cainfo
  1001. pp.SecretKey = miConfig.SecretKey
  1002. pp.AccessKey = miConfig.AccessKey
  1003. pp.OpterName = roles.UserName
  1004. var config []*models.HisXtDiagnoseConfig
  1005. for _, item := range diagnosis_ids {
  1006. id, _ := strconv.ParseInt(item, 10, 64)
  1007. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1008. config = append(config, &diagnosisConfig)
  1009. }
  1010. var pd models.PatientDtos
  1011. pd.PatnID = his.PsnNo
  1012. pd.PatnName = his.Name
  1013. pd.Gend = his.Gend
  1014. pd.Brdy = his.Brdy
  1015. pd.Poolarea = his.InsuplcAdmdvs
  1016. pd.CurrMdtrtID = his.Number
  1017. var fed models.FsiEncounterDtos
  1018. fed.MdtrtID = his.Number
  1019. fed.MedinsID = miConfig.Code
  1020. fed.MedinsName = miConfig.OrgName
  1021. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1022. fed.MedMdtrtType = "1"
  1023. fed.MedinsType = "1"
  1024. fed.MedinsLv = "11"
  1025. tm := time.Unix(his.RecordDate, 0)
  1026. s_tm := tm.Format("2006-01-02 15:04:05")
  1027. fed.AdmDate = s_tm
  1028. fed.DscgDate = s_tm
  1029. fed.DscgMainDiseCodg = config[0].CountryCode
  1030. fed.DscgMainDiseName = config[0].CountryContentName
  1031. //诊断信息
  1032. var fdds []*models.FsiDiagnoseDtos
  1033. for index, item := range config {
  1034. if index == 0 {
  1035. var fdd models.FsiDiagnoseDtos
  1036. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1037. fdd.InoutDiseType = "1"
  1038. fdd.MaindiseFlag = "1"
  1039. fdd.DiseDate = s_tm
  1040. fdd.DiasSrtNo = "1"
  1041. fdd.DiseName = item.CountryContentName
  1042. fdd.DiseCodg = item.CountryCode
  1043. fdds = append(fdds, &fdd)
  1044. } else {
  1045. var fdd models.FsiDiagnoseDtos
  1046. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1047. fdd.InoutDiseType = "1"
  1048. fdd.MaindiseFlag = "1"
  1049. fdd.DiseDate = s_tm
  1050. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1051. fdd.DiseName = item.CountryContentName
  1052. fdd.DiseCodg = item.CountryCode
  1053. fdds = append(fdds, &fdd)
  1054. }
  1055. }
  1056. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1057. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1058. fed.AdmDeptName = department.Name
  1059. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1060. fed.DscgDeptName = department.Name
  1061. fed.MedType = order.MedType
  1062. //处方医嘱信息
  1063. var orders []*models.FsiOrderDtos
  1064. //for _, item := range prescriptions {
  1065. // for _, subItem := range item.HisDoctorAdviceInfo {
  1066. // var order models.FsiOrderDtos
  1067. // order.RxID = strconv.FormatInt(item.ID, 10)
  1068. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1069. // order.LongDrordFlag = "0"
  1070. // order.HilistType = "1"
  1071. // order.ChrgType = "1"
  1072. // order.DrordBhvr = "-"
  1073. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1074. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1075. // order.HilistLv = "1"
  1076. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1077. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1078. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1079. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1080. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1081. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1082. // order.OwnpayAmt = ""
  1083. // order.SelfpayAmt = ""
  1084. // order.Spec = ""
  1085. // order.SpecUnt = ""
  1086. // order.DrordBegnDate = s_tm
  1087. // order.DrordStopDate = ""
  1088. // order.DrordDrCodg = "1"
  1089. // order.DrordDeptName = department.Name
  1090. // order.DrordDrCodg = "1"
  1091. // order.DrordDrName = doctor_info.UserName
  1092. // order.DrordDrProfttl = ""
  1093. // order.CurrDrordFlag = "1"
  1094. // orders = append(orders, &order)
  1095. // }
  1096. // for _, subItem := range item.HisPrescriptionProject {
  1097. // if subItem.Type == 2 {
  1098. // var order models.FsiOrderDtos
  1099. // order.RxID = strconv.FormatInt(item.ID, 10)
  1100. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1101. // order.LongDrordFlag = "0"
  1102. // order.HilistType = "1"
  1103. // order.ChrgType = "1"
  1104. // order.DrordBhvr = "-"
  1105. // order.HilistCode = subItem.HisProject.MedicalCode
  1106. // order.HosplistName = subItem.HisProject.ProjectName
  1107. // order.HilistLv = "1"
  1108. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1109. // order.HosplistCode = subItem.HisProject.MedicalCode
  1110. // order.HosplistName = subItem.HisProject.ProjectName
  1111. // order.Cnt = subItem.Count
  1112. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1113. //
  1114. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1115. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1116. // order.OwnpayAmt = ""
  1117. // order.SelfpayAmt = ""
  1118. // order.Spec = ""
  1119. // order.SpecUnt = ""
  1120. // order.DrordBegnDate = s_tm
  1121. // order.DrordStopDate = ""
  1122. // order.DrordDrCodg = "1"
  1123. // order.DrordDeptName = department.Name
  1124. // order.DrordDrCodg = "1"
  1125. // order.DrordDrName = doctor_info.UserName
  1126. // order.DrordDrProfttl = ""
  1127. // order.CurrDrordFlag = "1"
  1128. // orders = append(orders, &order)
  1129. //
  1130. // }
  1131. // if subItem.Type == 3 {
  1132. //
  1133. // var order models.FsiOrderDtos
  1134. // order.RxID = strconv.FormatInt(item.ID, 10)
  1135. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1136. // order.LongDrordFlag = "0"
  1137. // order.HilistType = "1"
  1138. // order.ChrgType = "1"
  1139. // order.DrordBhvr = "-"
  1140. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1141. // order.HosplistName = subItem.GoodInfo.GoodName
  1142. // order.HilistLv = "1"
  1143. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1144. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1145. // order.HosplistName = subItem.GoodInfo.GoodName
  1146. // order.Cnt = subItem.Count
  1147. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1148. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1149. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1150. // order.OwnpayAmt = ""
  1151. // order.SelfpayAmt = ""
  1152. // order.Spec = ""
  1153. // order.SpecUnt = ""
  1154. // order.DrordBegnDate = s_tm
  1155. // order.DrordStopDate = ""
  1156. // order.DrordDrCodg = "1"
  1157. // order.DrordDeptName = department.Name
  1158. // order.DrordDrCodg = "1"
  1159. // order.DrordDrName = doctor_info.UserName
  1160. // order.DrordDrProfttl = ""
  1161. // order.CurrDrordFlag = "1"
  1162. // orders = append(orders, &order)
  1163. //
  1164. // }
  1165. // }
  1166. //}
  1167. for _, item := range prescriptions {
  1168. for _, subItem := range item.HisDoctorAdviceInfo {
  1169. var order models.FsiOrderDtos
  1170. order.RxID = strconv.FormatInt(item.ID, 10)
  1171. order.Rxno = strconv.FormatInt(item.ID, 10)
  1172. order.LongDrordFlag = "0"
  1173. order.HilistType = "1"
  1174. order.ChrgType = "1"
  1175. order.DrordBhvr = "-"
  1176. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1177. order.HosplistName = subItem.BaseDrugLib.DrugName
  1178. order.HilistLv = "1"
  1179. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1180. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1181. order.HosplistName = subItem.BaseDrugLib.DrugName
  1182. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1183. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1184. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1185. order.OwnpayAmt = ""
  1186. order.SelfpayAmt = ""
  1187. order.Spec = ""
  1188. order.SpecUnt = ""
  1189. order.DrordBegnDate = s_tm
  1190. order.DrordStopDate = ""
  1191. order.DrordDrCodg = "1"
  1192. order.DrordDeptName = department.Name
  1193. order.DrordDrCodg = "1"
  1194. order.DrordDrName = doctor_info.UserName
  1195. order.DrordDrProfttl = ""
  1196. order.CurrDrordFlag = "1"
  1197. orders = append(orders, &order)
  1198. }
  1199. for _, subItem := range item.HisPrescriptionProject {
  1200. if subItem.Type == 2 {
  1201. var order models.FsiOrderDtos
  1202. order.RxID = strconv.FormatInt(item.ID, 10)
  1203. order.Rxno = strconv.FormatInt(item.ID, 10)
  1204. order.LongDrordFlag = "0"
  1205. order.HilistType = "1"
  1206. order.ChrgType = "1"
  1207. order.DrordBhvr = "-"
  1208. order.HilistCode = subItem.HisProject.MedicalCode
  1209. order.HosplistName = subItem.HisProject.ProjectName
  1210. order.HilistLv = "1"
  1211. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1212. order.HosplistCode = subItem.HisProject.MedicalCode
  1213. order.HosplistName = subItem.HisProject.ProjectName
  1214. order.Cnt = subItem.Count
  1215. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1216. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1217. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1218. order.OwnpayAmt = ""
  1219. order.SelfpayAmt = ""
  1220. order.Spec = ""
  1221. order.SpecUnt = ""
  1222. order.DrordBegnDate = s_tm
  1223. order.DrordStopDate = ""
  1224. order.DrordDrCodg = "1"
  1225. order.DrordDeptName = department.Name
  1226. order.DrordDrCodg = "1"
  1227. order.DrordDrName = doctor_info.UserName
  1228. order.DrordDrProfttl = ""
  1229. order.CurrDrordFlag = "1"
  1230. orders = append(orders, &order)
  1231. }
  1232. if subItem.Type == 3 {
  1233. var order models.FsiOrderDtos
  1234. order.RxID = strconv.FormatInt(item.ID, 10)
  1235. order.Rxno = strconv.FormatInt(item.ID, 10)
  1236. order.LongDrordFlag = "0"
  1237. order.HilistType = "1"
  1238. order.ChrgType = "1"
  1239. order.DrordBhvr = "-"
  1240. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1241. order.HosplistName = subItem.GoodInfo.GoodName
  1242. order.HilistLv = "1"
  1243. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1244. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1245. order.HosplistName = subItem.GoodInfo.GoodName
  1246. order.Cnt = subItem.Count
  1247. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1248. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1249. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1250. order.OwnpayAmt = ""
  1251. order.SelfpayAmt = ""
  1252. order.Spec = ""
  1253. order.SpecUnt = ""
  1254. order.DrordBegnDate = s_tm
  1255. order.DrordStopDate = ""
  1256. order.DrordDrCodg = "1"
  1257. order.DrordDeptName = department.Name
  1258. order.DrordDrCodg = "1"
  1259. order.DrordDrName = doctor_info.UserName
  1260. order.DrordDrProfttl = ""
  1261. order.CurrDrordFlag = "1"
  1262. orders = append(orders, &order)
  1263. }
  1264. }
  1265. }
  1266. //处方医嘱信息
  1267. fed.MatnStas = "0"
  1268. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1269. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1270. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1271. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1272. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1273. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1274. fed.SetlTotlnum = "1"
  1275. fed.Insutype = his.Insutype
  1276. fed.ReimFlag = "0"
  1277. fed.OutSetlFlag = "0"
  1278. var fopd []*models.FsiOperationDtosData
  1279. data := make(map[string]interface{})
  1280. data["fed"] = fed
  1281. data["fdd"] = fdds
  1282. data["fod"] = orders
  1283. data["pd"] = pd
  1284. data["pp"] = pp
  1285. data["fopd"] = fopd
  1286. data["trig_scen"] = trig_scen
  1287. client := &http.Client{}
  1288. bytesData, _ := json.Marshal(data)
  1289. var req *http.Request
  1290. if miConfig.MdtrtareaAdmvs == "320921" {
  1291. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1292. } else {
  1293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1294. }
  1295. resp, _ := client.Do(req)
  1296. defer resp.Body.Close()
  1297. body, ioErr := ioutil.ReadAll(resp.Body)
  1298. if ioErr != nil {
  1299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1301. return res
  1302. }
  1303. var respJSON map[string]interface{}
  1304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. return res
  1308. }
  1309. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1310. result, _ := json.Marshal(respJSON)
  1311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1312. utils.ErrorLog("解析失败:%v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return res
  1315. }
  1316. return res
  1317. //手术操作集合
  1318. //手术操作集合
  1319. }
  1320. func (c *HisApiController) Check() {
  1321. psn_no := c.GetString("psn_no")
  1322. in := c.GetString("in")
  1323. mt := c.GetString("mt")
  1324. baseParams := models.BaseParams{
  1325. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1326. FixmedinsCode: "H15049901371",
  1327. InsuplcAdmdvs: "150499",
  1328. MdtrtareaAdmvs: "150499",
  1329. OrgName: "赤峰费森血液透析中心",
  1330. Doctor: "1111",
  1331. }
  1332. service.Gdyb2001(baseParams, psn_no, in, mt)
  1333. }
  1334. func (c *HisApiController) GetPsnNcdsInfo() {
  1335. admin_user_id, _ := c.GetInt64("admin_user_id")
  1336. patient_id, _ := c.GetInt64("patient_id")
  1337. id, _ := c.GetInt64("id")
  1338. adminUser := c.GetAdminUserInfo()
  1339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1340. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1341. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1342. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1343. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1344. //
  1345. //if psn_record.ID == 0 {
  1346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1347. // return
  1348. //}
  1349. var res Result5301
  1350. var res10265 Result5301For10265
  1351. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1352. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1353. var api string
  1354. if miConfig.MdtrtareaAdmvs == "320921" {
  1355. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1357. } else {
  1358. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1359. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1360. }
  1361. resp, requestErr := http.Get(api)
  1362. if requestErr != nil {
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1364. return
  1365. }
  1366. body, ioErr := ioutil.ReadAll(resp.Body)
  1367. if ioErr != nil {
  1368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1370. return
  1371. }
  1372. var respJSON map[string]interface{}
  1373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1376. return
  1377. }
  1378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1379. result, _ := json.Marshal(respJSON)
  1380. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. res.ErrMsg = res10265.ErrMsg
  1386. res.Output = res10265.Output
  1387. res.InfRefmsgid = res10265.InfRefmsgid
  1388. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1389. res.Infcode = infocode
  1390. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1391. p, _ := service.GetHisPatientById(patient_id)
  1392. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1393. var dat map[string]interface{}
  1394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1395. fmt.Println(dat)
  1396. } else {
  1397. fmt.Println(err)
  1398. }
  1399. userJSONBytes, _ := json.Marshal(dat)
  1400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1401. utils.ErrorLog("解析失败:%v", err)
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1403. return
  1404. }
  1405. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1406. p, _ := service.GetHisPatientById(patient_id)
  1407. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1408. var dat map[string]interface{}
  1409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1410. fmt.Println(dat)
  1411. } else {
  1412. fmt.Println(err)
  1413. }
  1414. userJSONBytes, _ := json.Marshal(dat)
  1415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. } else {
  1421. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1422. var dat map[string]interface{}
  1423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1424. fmt.Println(dat)
  1425. } else {
  1426. fmt.Println(err)
  1427. }
  1428. userJSONBytes, _ := json.Marshal(dat)
  1429. if miConfig.Code == "H15049901371" {
  1430. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1431. utils.ErrorLog("解析失败:%v", err)
  1432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1433. return
  1434. }
  1435. res.InfRefmsgid = res10265.InfRefmsgid
  1436. res.Output = res10265.Output
  1437. res.ErrMsg = res10265.ErrMsg
  1438. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1439. res.Infcode = infocode
  1440. } else {
  1441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1442. utils.ErrorLog("解析失败:%v", err)
  1443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1444. return
  1445. }
  1446. }
  1447. }
  1448. if res.Infcode == 0 {
  1449. c.ServeSuccessJSON(map[string]interface{}{
  1450. "result": res.Output.Result,
  1451. })
  1452. }
  1453. }
  1454. func (c *HisApiController) CheckInsutype() {
  1455. his_patient_id, _ := c.GetInt64("his_patient_id")
  1456. admin_user_id, _ := c.GetInt64("admin_user_id")
  1457. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1458. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1460. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1461. var dat map[string]interface{}
  1462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1463. fmt.Println(dat)
  1464. } else {
  1465. fmt.Println(err)
  1466. }
  1467. userJSONBytes, _ := json.Marshal(dat)
  1468. var res Result90100
  1469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1470. utils.ErrorLog("解析失败:%v", err)
  1471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1472. return
  1473. }
  1474. if res.Infcode != 0 {
  1475. c.ServeSuccessJSON(map[string]interface{}{
  1476. "failed_code": -10,
  1477. "msg": res.ErrMsg,
  1478. })
  1479. return
  1480. } else {
  1481. fmt.Println(res)
  1482. }
  1483. }
  1484. func (c *HisApiController) CheckCardPWD() {
  1485. card_pwd := c.GetString("card_pwd")
  1486. his_patient_id, _ := c.GetInt64("his_patient_id")
  1487. admin_user_id, _ := c.GetInt64("admin_user_id")
  1488. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1490. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1491. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1492. bas := strings.Split(psn.CardInfo, "|")
  1493. basNumber := bas[2]
  1494. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1495. var dat map[string]interface{}
  1496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1497. fmt.Println(dat)
  1498. } else {
  1499. fmt.Println(err)
  1500. }
  1501. userJSONBytes, _ := json.Marshal(dat)
  1502. var res Result90991
  1503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1504. utils.ErrorLog("解析失败:%v", err)
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1506. return
  1507. }
  1508. if res.Infcode != 0 {
  1509. c.ServeSuccessJSON(map[string]interface{}{
  1510. "failed_code": -10,
  1511. "msg": res.ErrMsg,
  1512. })
  1513. return
  1514. } else {
  1515. if res.Output.Result.SscnoCheckStat == "0" {
  1516. var msg string
  1517. switch res.Output.Result.CardStat {
  1518. case "00":
  1519. msg = "未激活"
  1520. break
  1521. case "10":
  1522. msg = "激活"
  1523. break
  1524. case "20":
  1525. msg = "窗口挂失"
  1526. break
  1527. case "21":
  1528. msg = "电话挂失"
  1529. break
  1530. case "22":
  1531. msg = "单位网上申报挂失"
  1532. break
  1533. case "23":
  1534. msg = "保健办挂失"
  1535. break
  1536. case "24":
  1537. msg = "个人网上挂失"
  1538. break
  1539. case "25":
  1540. msg = "网上服务大厅挂失"
  1541. break
  1542. case "30":
  1543. msg = "注销"
  1544. break
  1545. case "40":
  1546. msg = "回收"
  1547. break
  1548. case "99":
  1549. msg = "制卡中(无效卡)"
  1550. break
  1551. }
  1552. c.ServeSuccessJSON(map[string]interface{}{
  1553. "failed_code": -10,
  1554. "msg": msg,
  1555. })
  1556. return
  1557. } else {
  1558. c.ServeSuccessJSON(map[string]interface{}{
  1559. "msg": "校验成功",
  1560. })
  1561. return
  1562. }
  1563. }
  1564. }
  1565. func (c *HisApiController) CheckCardPWDTwo() {
  1566. //card_pwd := c.GetString("card_pwd")
  1567. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1568. admin_user_id, _ := c.GetInt64("admin_user_id")
  1569. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1570. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1571. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1572. var dat map[string]interface{}
  1573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1574. fmt.Println(dat)
  1575. } else {
  1576. fmt.Println(err)
  1577. }
  1578. userJSONBytes, _ := json.Marshal(dat)
  1579. var res Result90991
  1580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1581. utils.ErrorLog("解析失败:%v", err)
  1582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1583. return
  1584. }
  1585. if res.Infcode != 0 {
  1586. c.ServeSuccessJSON(map[string]interface{}{
  1587. "failed_code": -10,
  1588. "msg": res.ErrMsg,
  1589. })
  1590. return
  1591. } else {
  1592. if res.Output.Result.SscnoCheckStat == "0" {
  1593. var msg string
  1594. switch res.Output.Result.CardStat {
  1595. case "00":
  1596. msg = "未激活"
  1597. break
  1598. case "10":
  1599. msg = "激活"
  1600. break
  1601. case "20":
  1602. msg = "窗口挂失"
  1603. break
  1604. case "21":
  1605. msg = "电话挂失"
  1606. break
  1607. case "22":
  1608. msg = "单位网上申报挂失"
  1609. break
  1610. case "23":
  1611. msg = "保健办挂失"
  1612. break
  1613. case "24":
  1614. msg = "个人网上挂失"
  1615. break
  1616. case "25":
  1617. msg = "网上服务大厅挂失"
  1618. break
  1619. case "30":
  1620. msg = "注销"
  1621. break
  1622. case "40":
  1623. msg = "回收"
  1624. break
  1625. case "99":
  1626. msg = "制卡中(无效卡)"
  1627. break
  1628. }
  1629. c.ServeSuccessJSON(map[string]interface{}{
  1630. "failed_code": -10,
  1631. "msg": msg,
  1632. })
  1633. return
  1634. } else {
  1635. c.ServeSuccessJSON(map[string]interface{}{
  1636. "msg": "校验成功",
  1637. })
  1638. return
  1639. }
  1640. }
  1641. }
  1642. type ELeCertData struct {
  1643. Data struct {
  1644. Extra string `json:"extra"`
  1645. IDNo string `json:"idNo"`
  1646. IDType string `json:"idType"`
  1647. EcToken string `json:"ecToken"`
  1648. InsuOrg string `json:"insuOrg"`
  1649. UserName string `json:"userName"`
  1650. EcIndexNo string `json:"ecIndexNo"`
  1651. Gender string `json:"gender"`
  1652. Birthday string `json:"birthday"`
  1653. Nationality string `json:"nationality"`
  1654. Email string `json:"email"`
  1655. } `json:"OutData"`
  1656. }
  1657. func (c *HisApiController) ReadCard() {
  1658. id_card_type, _ := c.GetInt64("id_card_type")
  1659. admin_user_id, _ := c.GetInt64("admin_user_id")
  1660. certificates, _ := c.GetInt64("certificates")
  1661. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1663. switch id_card_type {
  1664. case 1:
  1665. if miConfig.MdtrtareaAdmvs == "421300" {
  1666. var res ResultTwo
  1667. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1668. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1670. resp, requestErr := http.Get(api)
  1671. if requestErr != nil {
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. return
  1674. }
  1675. body, ioErr := ioutil.ReadAll(resp.Body)
  1676. if ioErr != nil {
  1677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. var respJSON map[string]interface{}
  1682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1685. return
  1686. }
  1687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1688. result, _ := json.Marshal(respJSON)
  1689. fmt.Println("log")
  1690. fmt.Println(string(result))
  1691. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1692. utils.ErrorLog("解析失败:%v", err)
  1693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1694. return
  1695. }
  1696. if res.Infcode == 0 {
  1697. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1698. if err == gorm.ErrRecordNotFound {
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1700. return
  1701. } else if err != nil {
  1702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1703. return
  1704. } else {
  1705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1707. infoStr := string(Iinfos)
  1708. idetinfoStr := string(Idetinfos)
  1709. psn := &models.HisPsn{
  1710. PsnNo: res.Output.Baseinfo.PsnNo,
  1711. Age: res.Output.Baseinfo.Age,
  1712. PatientId: patient.ID,
  1713. Certno: res.Output.Baseinfo.Certno,
  1714. Brdy: res.Output.Baseinfo.Brdy,
  1715. Gend: res.Output.Baseinfo.Gend,
  1716. Naty: res.Output.Baseinfo.Naty,
  1717. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1718. PsnName: res.Output.Baseinfo.PsnName,
  1719. Idetinfo: idetinfoStr,
  1720. Insuinfo: infoStr,
  1721. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1722. }
  1723. service.CreateHisPsn(psn)
  1724. c.ServeSuccessJSON(map[string]interface{}{
  1725. "patient": patient,
  1726. "number": res.Output.Baseinfo.Certno,
  1727. })
  1728. }
  1729. } else {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1731. return
  1732. }
  1733. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1734. var api string
  1735. if miConfig.MdtrtareaAdmvs == "320921" {
  1736. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1737. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1738. fmt.Println(api)
  1739. } else {
  1740. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1741. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1742. }
  1743. resp, requestErr := http.Get(api)
  1744. if requestErr != nil {
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. body, ioErr := ioutil.ReadAll(resp.Body)
  1749. if ioErr != nil {
  1750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1752. return
  1753. }
  1754. var respJSON map[string]interface{}
  1755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. return
  1759. }
  1760. var status string
  1761. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1762. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1763. //console.log()
  1764. fmt.Println("type===")
  1765. fmt.Println(card_type)
  1766. var token string
  1767. var res ResultTwo //1101结果
  1768. var res10265 ResultTwo10265 //1101结果
  1769. var card_info string //卡信息
  1770. var busi_card_info string
  1771. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1772. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1773. if status == "0" { //读卡成功
  1774. if card_type == "1" {
  1775. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1776. result, _ := json.Marshal(respJSON)
  1777. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1778. utils.ErrorLog("解析失败:%v", err)
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. return
  1781. }
  1782. res.ErrMsg = res10265.ErrMsg
  1783. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1784. res.Infcode = infocode
  1785. res.Output = res10265.Output
  1786. res.InfRefmsgid = res10265.InfRefmsgid
  1787. } else {
  1788. //var card_info string //卡信息
  1789. //var busi_card_info string
  1790. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1791. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1792. //fmt.Println(card_info)
  1793. //fmt.Println(busi_card_info)
  1794. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1795. result, _ := json.Marshal(respJSON)
  1796. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1797. utils.ErrorLog("解析失败:%v", err)
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1799. return
  1800. }
  1801. res.ErrMsg = res10265.ErrMsg
  1802. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1803. res.Infcode = infocode
  1804. res.Output = res10265.Output
  1805. res.InfRefmsgid = res10265.InfRefmsgid
  1806. }
  1807. if res.Infcode == 0 {
  1808. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1809. if err == gorm.ErrRecordNotFound {
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1811. return
  1812. } else if err != nil {
  1813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1814. return
  1815. } else {
  1816. if card_type == "1" {
  1817. bas := strings.Split(card_info, "|")
  1818. basNumber := bas[2]
  1819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1821. infoStr := string(Iinfos)
  1822. idetinfoStr := string(Idetinfos)
  1823. psn := &models.HisPsn{
  1824. PsnNo: res.Output.Baseinfo.PsnNo,
  1825. Age: res.Output.Baseinfo.Age,
  1826. PatientId: patient.ID,
  1827. Certno: res.Output.Baseinfo.Certno,
  1828. Brdy: res.Output.Baseinfo.Brdy,
  1829. Gend: res.Output.Baseinfo.Gend,
  1830. Naty: res.Output.Baseinfo.Naty,
  1831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1832. PsnName: res.Output.Baseinfo.PsnName,
  1833. Idetinfo: idetinfoStr,
  1834. Insuinfo: infoStr,
  1835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1836. CardInfo: card_info,
  1837. VerifyNumber: busi_card_info,
  1838. }
  1839. service.CreateHisPsn(psn)
  1840. var rf []*ResultFive
  1841. json.Unmarshal([]byte(infoStr), &rf)
  1842. var insutypes []*ResultFive
  1843. var insutype string
  1844. var is390 int = 0
  1845. var is310 int = 0
  1846. for _, item := range rf {
  1847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1848. insutypes = append(insutypes, item)
  1849. }
  1850. }
  1851. if len(insutypes) == 1 {
  1852. insutype = insutypes[0].Insutype
  1853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1854. } else {
  1855. for _, i := range insutypes {
  1856. if i.Insutype == "390" {
  1857. is390 = 1
  1858. }
  1859. if i.Insutype == "310" {
  1860. is310 = 1
  1861. }
  1862. }
  1863. }
  1864. if is390 == 1 {
  1865. insutype = "390"
  1866. }
  1867. if is310 == 1 {
  1868. insutype = "310"
  1869. }
  1870. if len(insutypes) == 0 {
  1871. insutype = "310"
  1872. }
  1873. c.ServeSuccessJSON(map[string]interface{}{
  1874. "patient": patient,
  1875. "number": basNumber,
  1876. "insutype": insutype,
  1877. })
  1878. } else {
  1879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1881. infoStr := string(Iinfos)
  1882. idetinfoStr := string(Idetinfos)
  1883. psn := &models.HisPsn{
  1884. PsnNo: res.Output.Baseinfo.PsnNo,
  1885. Age: res.Output.Baseinfo.Age,
  1886. PatientId: patient.ID,
  1887. Certno: res.Output.Baseinfo.Certno,
  1888. Brdy: res.Output.Baseinfo.Brdy,
  1889. Gend: res.Output.Baseinfo.Gend,
  1890. Naty: res.Output.Baseinfo.Naty,
  1891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1892. PsnName: res.Output.Baseinfo.PsnName,
  1893. Idetinfo: idetinfoStr,
  1894. Insuinfo: infoStr,
  1895. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1896. CardInfo: card_info,
  1897. VerifyNumber: token,
  1898. }
  1899. service.CreateHisPsn(psn)
  1900. c.ServeSuccessJSON(map[string]interface{}{
  1901. "patient": patient,
  1902. "number": token,
  1903. })
  1904. }
  1905. }
  1906. } else {
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1908. return
  1909. }
  1910. } else { //读卡失败
  1911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1912. return
  1913. }
  1914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1915. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1916. cardnum = DeleteExtraSpaceTwo(cardnum)
  1917. cardCode = DeleteExtraSpaceTwo(cardCode)
  1918. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1919. name = DeleteExtraSpaceTwo(name)
  1920. errmsg = DeleteExtraSpaceTwo(errmsg)
  1921. cardnum = Remove0000(cardnum)
  1922. cardCode = Remove0000(cardCode)
  1923. id_card_no = Remove0000(id_card_no)
  1924. name = Remove0000(name)
  1925. errmsg = Remove0000(errmsg)
  1926. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1927. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1928. saveLog(result, requestLog, "1101", "获取人员信息")
  1929. fmt.Println(errMsgLog)
  1930. if len(errMsgLog) > 0 {
  1931. } else {
  1932. var dat map[string]interface{}
  1933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1934. fmt.Println(dat)
  1935. } else {
  1936. fmt.Println(err)
  1937. }
  1938. userJSONBytes, _ := json.Marshal(dat)
  1939. var res ResultTwo
  1940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1941. utils.ErrorLog("解析失败:%v", err)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. return
  1944. }
  1945. res.ErrMsg = errMsgLog
  1946. if res.Infcode == 0 {
  1947. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1948. if err == gorm.ErrRecordNotFound {
  1949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1950. return
  1951. } else if err != nil {
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1953. return
  1954. } else {
  1955. fmt.Println(res)
  1956. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1957. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1958. infoStr := string(Iinfos)
  1959. idetinfoStr := string(Idetinfos)
  1960. psn := &models.HisPsn{
  1961. PsnNo: res.Output.Baseinfo.PsnNo,
  1962. Age: res.Output.Baseinfo.Age,
  1963. PatientId: patient.ID,
  1964. Certno: res.Output.Baseinfo.Certno,
  1965. Brdy: res.Output.Baseinfo.Brdy,
  1966. Gend: res.Output.Baseinfo.Gend,
  1967. Naty: res.Output.Baseinfo.Naty,
  1968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1969. PsnName: res.Output.Baseinfo.PsnName,
  1970. Idetinfo: idetinfoStr,
  1971. Insuinfo: infoStr,
  1972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1973. CardInfo: basStr,
  1974. VerifyNumber: "",
  1975. }
  1976. service.CreateHisPsn(psn)
  1977. var rf []*ResultFive
  1978. json.Unmarshal([]byte(infoStr), &rf)
  1979. var insutypes []*ResultFive
  1980. var insutype string
  1981. var is390 int = 0
  1982. var is310 int = 0
  1983. for _, item := range rf {
  1984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1985. insutypes = append(insutypes, item)
  1986. }
  1987. }
  1988. if len(insutypes) == 1 {
  1989. insutype = insutypes[0].Insutype
  1990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1991. } else {
  1992. for _, i := range insutypes {
  1993. if i.Insutype == "390" {
  1994. is390 = 1
  1995. }
  1996. if i.Insutype == "310" {
  1997. is310 = 1
  1998. }
  1999. }
  2000. }
  2001. if is390 == 1 {
  2002. insutype = "390"
  2003. }
  2004. if is310 == 1 {
  2005. insutype = "310"
  2006. }
  2007. if len(insutypes) == 0 {
  2008. insutype = "310"
  2009. }
  2010. c.ServeSuccessJSON(map[string]interface{}{
  2011. "patient": patient,
  2012. "number": cardnum,
  2013. "insutype": insutype,
  2014. })
  2015. }
  2016. } else {
  2017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2018. return
  2019. }
  2020. }
  2021. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2022. fmt.Println(initFlag)
  2023. fmt.Println("initFlag")
  2024. if initFlag == 0 {
  2025. c.TestGetJiangXiBasBaseInit()
  2026. }
  2027. basStr := c.GetBasBaseInfo()
  2028. if len(basStr) == 0 {
  2029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2030. return
  2031. }
  2032. fmt.Println(basStr)
  2033. bas := strings.Split(basStr, "|")
  2034. basNumber := bas[1]
  2035. fmt.Println(basNumber)
  2036. card_sn := bas[3]
  2037. fmt.Println(card_sn)
  2038. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2039. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2040. var dat map[string]interface{}
  2041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2042. fmt.Println(dat)
  2043. } else {
  2044. fmt.Println(err)
  2045. }
  2046. userJSONBytes, _ := json.Marshal(dat)
  2047. var res ResultTwo
  2048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2049. utils.ErrorLog("解析失败:%v", err)
  2050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. return
  2052. }
  2053. if res.Infcode == 0 {
  2054. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2055. if err == gorm.ErrRecordNotFound {
  2056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2057. return
  2058. } else if err != nil {
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2060. return
  2061. } else {
  2062. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2063. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2064. infoStr := string(Iinfos)
  2065. idetinfoStr := string(Idetinfos)
  2066. psn := &models.HisPsn{
  2067. PsnNo: res.Output.Baseinfo.PsnNo,
  2068. Age: res.Output.Baseinfo.Age,
  2069. PatientId: patient.ID,
  2070. Certno: res.Output.Baseinfo.Certno,
  2071. Brdy: res.Output.Baseinfo.Brdy,
  2072. Gend: res.Output.Baseinfo.Gend,
  2073. Naty: res.Output.Baseinfo.Naty,
  2074. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2075. PsnName: res.Output.Baseinfo.PsnName,
  2076. Idetinfo: idetinfoStr,
  2077. Insuinfo: infoStr,
  2078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2079. CardInfo: basStr,
  2080. VerifyNumber: "",
  2081. }
  2082. service.CreateHisPsn(psn)
  2083. var rf []*ResultFive
  2084. json.Unmarshal([]byte(infoStr), &rf)
  2085. var insutypes []*ResultFive
  2086. var insutype string
  2087. var is390 int = 0
  2088. var is310 int = 0
  2089. for _, item := range rf {
  2090. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2091. insutypes = append(insutypes, item)
  2092. }
  2093. }
  2094. if len(insutypes) == 1 {
  2095. insutype = insutypes[0].Insutype
  2096. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2097. } else {
  2098. for _, i := range insutypes {
  2099. if i.Insutype == "390" {
  2100. is390 = 1
  2101. }
  2102. if i.Insutype == "310" {
  2103. is310 = 1
  2104. }
  2105. }
  2106. }
  2107. if is390 == 1 {
  2108. insutype = "390"
  2109. }
  2110. if is310 == 1 {
  2111. insutype = "310"
  2112. }
  2113. if len(insutypes) == 0 {
  2114. insutype = "310"
  2115. }
  2116. c.ServeSuccessJSON(map[string]interface{}{
  2117. "patient": patient,
  2118. "number": basNumber,
  2119. "insutype": insutype,
  2120. })
  2121. }
  2122. } else {
  2123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2124. return
  2125. }
  2126. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2127. fmt.Println(initFlag)
  2128. fmt.Println("initFlag")
  2129. if initFlag == 0 {
  2130. c.TestGetHnBasBaseInit()
  2131. }
  2132. basStr := c.GetBasBaseInfo()
  2133. if len(basStr) == 0 {
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2135. return
  2136. }
  2137. fmt.Println(basStr)
  2138. bas := strings.Split(basStr, "|")
  2139. basNumber := bas[1]
  2140. fmt.Println(basNumber)
  2141. card_sn := bas[3]
  2142. card_no := bas[2]
  2143. fmt.Println(card_sn)
  2144. name := bas[4]
  2145. name = ConvertToString(name, "gbk", "utf-8")
  2146. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  2147. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2148. var dat map[string]interface{}
  2149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2150. fmt.Println(dat)
  2151. } else {
  2152. fmt.Println(err)
  2153. }
  2154. userJSONBytes, _ := json.Marshal(dat)
  2155. var res ResultTwo
  2156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2157. utils.ErrorLog("解析失败:%v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. return
  2160. }
  2161. if res.Infcode == 0 {
  2162. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2163. if err == gorm.ErrRecordNotFound {
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2165. return
  2166. } else if err != nil {
  2167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2168. return
  2169. } else {
  2170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2172. infoStr := string(Iinfos)
  2173. idetinfoStr := string(Idetinfos)
  2174. psn := &models.HisPsn{
  2175. PsnNo: res.Output.Baseinfo.PsnNo,
  2176. Age: res.Output.Baseinfo.Age,
  2177. PatientId: patient.ID,
  2178. Certno: res.Output.Baseinfo.Certno,
  2179. Brdy: res.Output.Baseinfo.Brdy,
  2180. Gend: res.Output.Baseinfo.Gend,
  2181. Naty: res.Output.Baseinfo.Naty,
  2182. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2183. PsnName: res.Output.Baseinfo.PsnName,
  2184. Idetinfo: idetinfoStr,
  2185. Insuinfo: infoStr,
  2186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2187. CardInfo: basStr,
  2188. VerifyNumber: "",
  2189. }
  2190. service.CreateHisPsn(psn)
  2191. var rf []*ResultFive
  2192. json.Unmarshal([]byte(infoStr), &rf)
  2193. var insutypes []*ResultFive
  2194. var insutype string
  2195. var is390 int = 0
  2196. var is310 int = 0
  2197. for _, item := range rf {
  2198. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2199. insutypes = append(insutypes, item)
  2200. }
  2201. }
  2202. if len(insutypes) == 1 {
  2203. insutype = insutypes[0].Insutype
  2204. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2205. } else {
  2206. for _, i := range insutypes {
  2207. if i.Insutype == "390" {
  2208. is390 = 1
  2209. }
  2210. if i.Insutype == "310" {
  2211. is310 = 1
  2212. }
  2213. }
  2214. }
  2215. if is390 == 1 {
  2216. insutype = "390"
  2217. }
  2218. if is310 == 1 {
  2219. insutype = "310"
  2220. }
  2221. if len(insutypes) == 0 {
  2222. insutype = "310"
  2223. }
  2224. c.ServeSuccessJSON(map[string]interface{}{
  2225. "patient": patient,
  2226. "number": basNumber,
  2227. "insutype": insutype,
  2228. })
  2229. }
  2230. } else {
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2232. return
  2233. }
  2234. } else {
  2235. if initFlag == 0 {
  2236. c.TestGetBasBaseInit()
  2237. }
  2238. basStr := c.GetBasBaseInfo()
  2239. if len(basStr) == 0 {
  2240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2241. return
  2242. }
  2243. fmt.Println(basStr)
  2244. bas := strings.Split(basStr, "|")
  2245. basNumber := bas[1]
  2246. fmt.Println(basNumber)
  2247. card_sn := bas[3]
  2248. fmt.Println(card_sn)
  2249. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2250. var dat map[string]interface{}
  2251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2252. fmt.Println(dat)
  2253. } else {
  2254. fmt.Println(err)
  2255. }
  2256. userJSONBytes, _ := json.Marshal(dat)
  2257. var res ResultTwo
  2258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2259. utils.ErrorLog("解析失败:%v", err)
  2260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2261. return
  2262. }
  2263. if res.Infcode == 0 {
  2264. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2265. if err == gorm.ErrRecordNotFound {
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2267. return
  2268. } else if err != nil {
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2270. return
  2271. } else {
  2272. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2273. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2274. infoStr := string(Iinfos)
  2275. idetinfoStr := string(Idetinfos)
  2276. psn := &models.HisPsn{
  2277. PsnNo: res.Output.Baseinfo.PsnNo,
  2278. Age: res.Output.Baseinfo.Age,
  2279. PatientId: patient.ID,
  2280. Certno: res.Output.Baseinfo.Certno,
  2281. Brdy: res.Output.Baseinfo.Brdy,
  2282. Gend: res.Output.Baseinfo.Gend,
  2283. Naty: res.Output.Baseinfo.Naty,
  2284. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2285. PsnName: res.Output.Baseinfo.PsnName,
  2286. Idetinfo: idetinfoStr,
  2287. Insuinfo: infoStr,
  2288. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2289. CardInfo: basStr,
  2290. VerifyNumber: "",
  2291. }
  2292. service.CreateHisPsn(psn)
  2293. c.ServeSuccessJSON(map[string]interface{}{
  2294. "patient": patient,
  2295. "number": basNumber,
  2296. })
  2297. }
  2298. } else {
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2300. return
  2301. }
  2302. break
  2303. }
  2304. case 2:
  2305. if miConfig.MdtrtareaAdmvs == "430800" {
  2306. if initFlag == 0 {
  2307. c.TestGetHnBasBaseInit()
  2308. }
  2309. SFZStr := c.GetSFZBaseInfo()
  2310. if len(SFZStr) == 0 {
  2311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2312. return
  2313. }
  2314. fmt.Println(SFZStr)
  2315. id_card_str := strings.Split(SFZStr, "^")
  2316. card_no := id_card_str[0]
  2317. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2318. //name := id_card_str[1]
  2319. //name = ConvertToString(name, "gbk", "utf-8")
  2320. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  2321. var dat map[string]interface{}
  2322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2323. fmt.Println(dat)
  2324. } else {
  2325. fmt.Println(err)
  2326. }
  2327. userJSONBytes, _ := json.Marshal(dat)
  2328. var res ResultTwo
  2329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2330. utils.ErrorLog("解析失败:%v", err)
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. return
  2333. }
  2334. if res.Infcode == 0 {
  2335. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2336. if err == gorm.ErrRecordNotFound {
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2338. return
  2339. } else if err != nil {
  2340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2341. return
  2342. } else {
  2343. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2344. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2345. infoStr := string(Iinfos)
  2346. idetinfoStr := string(Idetinfos)
  2347. psn := &models.HisPsn{
  2348. PsnNo: res.Output.Baseinfo.PsnNo,
  2349. Age: res.Output.Baseinfo.Age,
  2350. PatientId: patient.ID,
  2351. Certno: res.Output.Baseinfo.Certno,
  2352. Brdy: res.Output.Baseinfo.Brdy,
  2353. Gend: res.Output.Baseinfo.Gend,
  2354. Naty: res.Output.Baseinfo.Naty,
  2355. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2356. PsnName: res.Output.Baseinfo.PsnName,
  2357. Idetinfo: idetinfoStr,
  2358. Insuinfo: infoStr,
  2359. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2360. CardInfo: SFZStr,
  2361. VerifyNumber: "",
  2362. }
  2363. service.CreateHisPsn(psn)
  2364. var rf []*ResultFive
  2365. json.Unmarshal([]byte(infoStr), &rf)
  2366. var insutypes []*ResultFive
  2367. var insutype string
  2368. var is390 int = 0
  2369. var is310 int = 0
  2370. for _, item := range rf {
  2371. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2372. insutypes = append(insutypes, item)
  2373. }
  2374. }
  2375. if len(insutypes) == 1 {
  2376. insutype = insutypes[0].Insutype
  2377. } else {
  2378. for _, i := range insutypes {
  2379. if i.Insutype == "390" {
  2380. is390 = 1
  2381. }
  2382. if i.Insutype == "310" {
  2383. is310 = 1
  2384. }
  2385. }
  2386. }
  2387. if is390 == 1 {
  2388. insutype = "390"
  2389. }
  2390. if is310 == 1 {
  2391. insutype = "310"
  2392. }
  2393. if len(insutypes) == 0 {
  2394. insutype = "310"
  2395. }
  2396. c.ServeSuccessJSON(map[string]interface{}{
  2397. "patient": patient,
  2398. "number": card_no,
  2399. "insutype": insutype,
  2400. })
  2401. }
  2402. } else {
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2404. return
  2405. }
  2406. } else {
  2407. SFZStr := c.GetSFZBaseInfo()
  2408. id_card_str := strings.Split(SFZStr, "^")
  2409. id_card_number := id_card_str[0]
  2410. card_sn := ""
  2411. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2412. var dat map[string]interface{}
  2413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2414. fmt.Println(dat)
  2415. } else {
  2416. fmt.Println(err)
  2417. }
  2418. userJSONBytes, _ := json.Marshal(dat)
  2419. var res ResultTwo
  2420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. if res.Infcode == 0 {
  2426. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2427. if err == gorm.ErrRecordNotFound {
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2429. return
  2430. } else if err != nil {
  2431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2432. return
  2433. } else {
  2434. c.ServeSuccessJSON(map[string]interface{}{
  2435. "patient": patient,
  2436. "number": id_card_number,
  2437. })
  2438. }
  2439. } else {
  2440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2441. return
  2442. }
  2443. }
  2444. break
  2445. case 3:
  2446. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2447. var api string
  2448. if miConfig.MdtrtareaAdmvs == "320921" {
  2449. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2450. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2451. fmt.Println(api)
  2452. } else {
  2453. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2454. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2455. }
  2456. resp, requestErr := http.Get(api)
  2457. if requestErr != nil {
  2458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. return
  2460. }
  2461. body, ioErr := ioutil.ReadAll(resp.Body)
  2462. if ioErr != nil {
  2463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. return
  2466. }
  2467. var respJSON map[string]interface{}
  2468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2471. return
  2472. }
  2473. var status string
  2474. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2475. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2476. var token string
  2477. var res ResultTwo //1101结果
  2478. var res10265 ResultTwo10265 //1101结果
  2479. var card_info string //卡信息
  2480. var busi_card_info string
  2481. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2482. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2483. if status == "0" { //读卡成功
  2484. if card_type == "1" {
  2485. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2486. result, _ := json.Marshal(respJSON)
  2487. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2488. utils.ErrorLog("解析失败:%v", err)
  2489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2490. return
  2491. }
  2492. res.ErrMsg = res10265.ErrMsg
  2493. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2494. res.Infcode = infocode
  2495. res.Output = res10265.Output
  2496. res.InfRefmsgid = res10265.InfRefmsgid
  2497. } else {
  2498. //var card_info string //卡信息
  2499. //var busi_card_info string
  2500. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2501. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2502. //fmt.Println(card_info)
  2503. //fmt.Println(busi_card_info)
  2504. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2505. result, _ := json.Marshal(respJSON)
  2506. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2507. utils.ErrorLog("解析失败:%v", err)
  2508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. return
  2510. }
  2511. res.ErrMsg = res10265.ErrMsg
  2512. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2513. res.Infcode = infocode
  2514. res.Output = res10265.Output
  2515. res.InfRefmsgid = res10265.InfRefmsgid
  2516. }
  2517. if res.Infcode == 0 {
  2518. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2519. if err == gorm.ErrRecordNotFound {
  2520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2521. return
  2522. } else if err != nil {
  2523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2524. return
  2525. } else {
  2526. if card_type == "1" {
  2527. bas := strings.Split(card_info, "|")
  2528. basNumber := bas[2]
  2529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2531. infoStr := string(Iinfos)
  2532. idetinfoStr := string(Idetinfos)
  2533. psn := &models.HisPsn{
  2534. PsnNo: res.Output.Baseinfo.PsnNo,
  2535. Age: res.Output.Baseinfo.Age,
  2536. PatientId: patient.ID,
  2537. Certno: res.Output.Baseinfo.Certno,
  2538. Brdy: res.Output.Baseinfo.Brdy,
  2539. Gend: res.Output.Baseinfo.Gend,
  2540. Naty: res.Output.Baseinfo.Naty,
  2541. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2542. PsnName: res.Output.Baseinfo.PsnName,
  2543. Idetinfo: idetinfoStr,
  2544. Insuinfo: infoStr,
  2545. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2546. CardInfo: card_info,
  2547. VerifyNumber: busi_card_info,
  2548. }
  2549. service.CreateHisPsn(psn)
  2550. c.ServeSuccessJSON(map[string]interface{}{
  2551. "patient": patient,
  2552. "number": basNumber,
  2553. })
  2554. } else {
  2555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2557. infoStr := string(Iinfos)
  2558. idetinfoStr := string(Idetinfos)
  2559. psn := &models.HisPsn{
  2560. PsnNo: res.Output.Baseinfo.PsnNo,
  2561. Age: res.Output.Baseinfo.Age,
  2562. PatientId: patient.ID,
  2563. Certno: res.Output.Baseinfo.Certno,
  2564. Brdy: res.Output.Baseinfo.Brdy,
  2565. Gend: res.Output.Baseinfo.Gend,
  2566. Naty: res.Output.Baseinfo.Naty,
  2567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2568. PsnName: res.Output.Baseinfo.PsnName,
  2569. Idetinfo: idetinfoStr,
  2570. Insuinfo: infoStr,
  2571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2572. CardInfo: card_info,
  2573. VerifyNumber: token,
  2574. }
  2575. service.CreateHisPsn(psn)
  2576. var rf []*ResultFive
  2577. json.Unmarshal([]byte(infoStr), &rf)
  2578. var insutypes []*ResultFive
  2579. var insutype string
  2580. var is390 int = 0
  2581. var is310 int = 0
  2582. for _, item := range rf {
  2583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2584. insutypes = append(insutypes, item)
  2585. }
  2586. }
  2587. if len(insutypes) == 1 {
  2588. insutype = insutypes[0].Insutype
  2589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2590. } else {
  2591. for _, i := range insutypes {
  2592. if i.Insutype == "390" {
  2593. is390 = 1
  2594. }
  2595. if i.Insutype == "310" {
  2596. is310 = 1
  2597. }
  2598. }
  2599. }
  2600. if is390 == 1 {
  2601. insutype = "390"
  2602. }
  2603. if is310 == 1 {
  2604. insutype = "310"
  2605. }
  2606. if len(insutypes) == 0 {
  2607. insutype = "310"
  2608. }
  2609. c.ServeSuccessJSON(map[string]interface{}{
  2610. "patient": patient,
  2611. "number": token,
  2612. "insutype": insutype,
  2613. })
  2614. }
  2615. }
  2616. } else {
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2618. return
  2619. }
  2620. } else { //读卡失败
  2621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2622. return
  2623. }
  2624. }
  2625. break
  2626. case 4:
  2627. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2628. var api string
  2629. if miConfig.MdtrtareaAdmvs == "320921" {
  2630. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2631. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2632. fmt.Println(api)
  2633. } else {
  2634. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2636. }
  2637. resp, requestErr := http.Get(api)
  2638. if requestErr != nil {
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. return
  2641. }
  2642. body, ioErr := ioutil.ReadAll(resp.Body)
  2643. if ioErr != nil {
  2644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2646. return
  2647. }
  2648. var respJSON map[string]interface{}
  2649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2652. return
  2653. }
  2654. var status string
  2655. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2656. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2657. var token string
  2658. var res ResultTwo //1101结果
  2659. var res10265 ResultTwo10265 //1101结果
  2660. if status == "0" { //读卡成功
  2661. var card_info string //卡信息
  2662. var busi_card_info string
  2663. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2664. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2665. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2666. fmt.Println(card_info)
  2667. fmt.Println(busi_card_info)
  2668. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2669. result, _ := json.Marshal(respJSON)
  2670. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2671. utils.ErrorLog("解析失败:%v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. res.ErrMsg = res10265.ErrMsg
  2676. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2677. res.Infcode = infocode
  2678. res.Output = res10265.Output
  2679. res.InfRefmsgid = res10265.InfRefmsgid
  2680. if res.Infcode == 0 {
  2681. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2682. if err == gorm.ErrRecordNotFound {
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2684. return
  2685. } else if err != nil {
  2686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2687. return
  2688. } else {
  2689. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2690. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2691. infoStr := string(Iinfos)
  2692. idetinfoStr := string(Idetinfos)
  2693. psn := &models.HisPsn{
  2694. PsnNo: res.Output.Baseinfo.PsnNo,
  2695. Age: res.Output.Baseinfo.Age,
  2696. PatientId: patient.ID,
  2697. Certno: res.Output.Baseinfo.Certno,
  2698. Brdy: res.Output.Baseinfo.Brdy,
  2699. Gend: res.Output.Baseinfo.Gend,
  2700. Naty: res.Output.Baseinfo.Naty,
  2701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2702. PsnName: res.Output.Baseinfo.PsnName,
  2703. Idetinfo: idetinfoStr,
  2704. Insuinfo: infoStr,
  2705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2706. CardInfo: card_info,
  2707. VerifyNumber: token,
  2708. }
  2709. var rf []*ResultFive
  2710. json.Unmarshal([]byte(infoStr), &rf)
  2711. var insutypes []*ResultFive
  2712. var insutype string
  2713. var is390 int = 0
  2714. var is310 int = 0
  2715. for _, item := range rf {
  2716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2717. insutypes = append(insutypes, item)
  2718. }
  2719. }
  2720. if len(insutypes) == 1 {
  2721. insutype = insutypes[0].Insutype
  2722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2723. } else {
  2724. for _, i := range insutypes {
  2725. if i.Insutype == "390" {
  2726. is390 = 1
  2727. }
  2728. if i.Insutype == "310" {
  2729. is310 = 1
  2730. }
  2731. }
  2732. }
  2733. if is390 == 1 {
  2734. insutype = "390"
  2735. }
  2736. if is310 == 1 {
  2737. insutype = "310"
  2738. }
  2739. if len(insutypes) == 0 {
  2740. insutype = "310"
  2741. }
  2742. service.CreateHisPsn(psn)
  2743. c.ServeSuccessJSON(map[string]interface{}{
  2744. "patient": patient,
  2745. "number": token,
  2746. "insutype": insutype,
  2747. })
  2748. }
  2749. } else {
  2750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2751. return
  2752. }
  2753. } else { //读卡失败
  2754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2755. return
  2756. }
  2757. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2758. if initFlag == 0 {
  2759. c.TestGetBasBaseInit()
  2760. }
  2761. token := c.GetEleBaseInfo()
  2762. token = Remove0000(token)
  2763. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
  2764. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2765. //
  2766. var res ResultTwo
  2767. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2768. utils.ErrorLog("解析失败:%v", err)
  2769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. return
  2771. }
  2772. if res.Infcode == 0 {
  2773. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2774. if err == gorm.ErrRecordNotFound {
  2775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2776. return
  2777. } else if err != nil {
  2778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2779. return
  2780. } else {
  2781. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2782. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2783. infoStr := string(Iinfos)
  2784. idetinfoStr := string(Idetinfos)
  2785. psn := &models.HisPsn{
  2786. PsnNo: res.Output.Baseinfo.PsnNo,
  2787. Age: res.Output.Baseinfo.Age,
  2788. PatientId: patient.ID,
  2789. Certno: res.Output.Baseinfo.Certno,
  2790. Brdy: res.Output.Baseinfo.Brdy,
  2791. Gend: res.Output.Baseinfo.Gend,
  2792. Naty: res.Output.Baseinfo.Naty,
  2793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2794. PsnName: res.Output.Baseinfo.PsnName,
  2795. Idetinfo: idetinfoStr,
  2796. Insuinfo: infoStr,
  2797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2798. CardInfo: "",
  2799. VerifyNumber: token,
  2800. }
  2801. service.CreateHisPsn(psn)
  2802. c.ServeSuccessJSON(map[string]interface{}{
  2803. "patient": patient,
  2804. "number": token,
  2805. })
  2806. }
  2807. } else {
  2808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2809. return
  2810. }
  2811. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2812. if initFlag == 0 {
  2813. c.TestGetBasBaseInit()
  2814. }
  2815. token := c.GetEleBaseInfo()
  2816. token = Remove0000(token)
  2817. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2818. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2819. //
  2820. var res ResultTwo
  2821. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2822. utils.ErrorLog("解析失败:%v", err)
  2823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2824. return
  2825. }
  2826. if res.Infcode == 0 {
  2827. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2828. if err == gorm.ErrRecordNotFound {
  2829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2830. return
  2831. } else if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2833. return
  2834. } else {
  2835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2837. infoStr := string(Iinfos)
  2838. idetinfoStr := string(Idetinfos)
  2839. psn := &models.HisPsn{
  2840. PsnNo: res.Output.Baseinfo.PsnNo,
  2841. Age: res.Output.Baseinfo.Age,
  2842. PatientId: patient.ID,
  2843. Certno: res.Output.Baseinfo.Certno,
  2844. Brdy: res.Output.Baseinfo.Brdy,
  2845. Gend: res.Output.Baseinfo.Gend,
  2846. Naty: res.Output.Baseinfo.Naty,
  2847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2848. PsnName: res.Output.Baseinfo.PsnName,
  2849. Idetinfo: idetinfoStr,
  2850. Insuinfo: infoStr,
  2851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2852. CardInfo: "",
  2853. VerifyNumber: token,
  2854. }
  2855. service.CreateHisPsn(psn)
  2856. c.ServeSuccessJSON(map[string]interface{}{
  2857. "patient": patient,
  2858. "number": token,
  2859. })
  2860. }
  2861. } else {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2863. return
  2864. }
  2865. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2866. //if initFlag == 0 {
  2867. c.TestGetJiangXiBasBaseInit()
  2868. //}
  2869. //if initEleFlag == 0 {
  2870. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2871. //}
  2872. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2873. type ELeData struct {
  2874. Data struct {
  2875. IdNo string `json:"idNo"`
  2876. IdType string `json:"idType"`
  2877. UserName string `json:"userName"`
  2878. EcToken string `json:"ecToken"`
  2879. InsuOrg string `json:"insuOrg"`
  2880. Gender string `json:"gender"`
  2881. Birthday string `json:"birthday"`
  2882. Nationality string `json:"nationality"`
  2883. Email string `json:"email"`
  2884. Extra string `json:"extra"`
  2885. } `json:"data"`
  2886. Code int `json:"code"`
  2887. Message string `json:"message"`
  2888. }
  2889. var ele ELeData
  2890. err := json.Unmarshal([]byte(json_result), &ele)
  2891. if err != nil {
  2892. utils.ErrorLog("解析失败:%v", err)
  2893. }
  2894. token := ele.Data.EcToken
  2895. token = Remove0000(token)
  2896. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  2897. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2898. var res ResultTwo
  2899. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2900. utils.ErrorLog("解析失败:%v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. if res.Infcode == 0 {
  2905. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2906. if err == gorm.ErrRecordNotFound {
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2908. return
  2909. } else if err != nil {
  2910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2911. return
  2912. } else {
  2913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2915. infoStr := string(Iinfos)
  2916. idetinfoStr := string(Idetinfos)
  2917. psn := &models.HisPsn{
  2918. PsnNo: res.Output.Baseinfo.PsnNo,
  2919. Age: res.Output.Baseinfo.Age,
  2920. PatientId: patient.ID,
  2921. Certno: res.Output.Baseinfo.Certno,
  2922. Brdy: res.Output.Baseinfo.Brdy,
  2923. Gend: res.Output.Baseinfo.Gend,
  2924. Naty: res.Output.Baseinfo.Naty,
  2925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2926. PsnName: res.Output.Baseinfo.PsnName,
  2927. Idetinfo: idetinfoStr,
  2928. Insuinfo: infoStr,
  2929. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2930. CardInfo: "",
  2931. VerifyNumber: token,
  2932. }
  2933. service.CreateHisPsn(psn)
  2934. var rf []*ResultFive
  2935. json.Unmarshal([]byte(infoStr), &rf)
  2936. var insutypes []*ResultFive
  2937. var insutype string
  2938. var is390 int = 0
  2939. var is310 int = 0
  2940. for _, item := range rf {
  2941. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2942. insutypes = append(insutypes, item)
  2943. }
  2944. }
  2945. if len(insutypes) == 1 {
  2946. insutype = insutypes[0].Insutype
  2947. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2948. } else {
  2949. for _, i := range insutypes {
  2950. if i.Insutype == "390" {
  2951. is390 = 1
  2952. }
  2953. if i.Insutype == "310" {
  2954. is310 = 1
  2955. }
  2956. }
  2957. }
  2958. if is390 == 1 {
  2959. insutype = "390"
  2960. }
  2961. if is310 == 1 {
  2962. insutype = "310"
  2963. }
  2964. if len(insutypes) == 0 {
  2965. insutype = "310"
  2966. }
  2967. c.ServeSuccessJSON(map[string]interface{}{
  2968. "patient": patient,
  2969. "number": token,
  2970. "insutype": insutype,
  2971. })
  2972. }
  2973. } else {
  2974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2975. return
  2976. }
  2977. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2978. //if initFlag == 0 {
  2979. c.TestGetJiangXiBasBaseInit()
  2980. //}
  2981. //if initEleFlag == 0 {
  2982. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  2983. //}
  2984. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  2985. type ELeData struct {
  2986. Data struct {
  2987. IdNo string `json:"idNo"`
  2988. IdType string `json:"idType"`
  2989. UserName string `json:"userName"`
  2990. EcToken string `json:"ecToken"`
  2991. InsuOrg string `json:"insuOrg"`
  2992. Gender string `json:"gender"`
  2993. Birthday string `json:"birthday"`
  2994. Nationality string `json:"nationality"`
  2995. Email string `json:"email"`
  2996. Extra string `json:"extra"`
  2997. } `json:"data"`
  2998. Code int `json:"code"`
  2999. Message string `json:"message"`
  3000. }
  3001. var ele ELeData
  3002. err := json.Unmarshal([]byte(json_result), &ele)
  3003. if err != nil {
  3004. utils.ErrorLog("解析失败:%v", err)
  3005. }
  3006. token := ele.Data.EcToken
  3007. token = Remove0000(token)
  3008. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3009. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3010. var res ResultTwo
  3011. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3012. utils.ErrorLog("解析失败:%v", err)
  3013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3014. return
  3015. }
  3016. if res.Infcode == 0 {
  3017. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3018. if err == gorm.ErrRecordNotFound {
  3019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3020. return
  3021. } else if err != nil {
  3022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3023. return
  3024. } else {
  3025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3027. infoStr := string(Iinfos)
  3028. idetinfoStr := string(Idetinfos)
  3029. psn := &models.HisPsn{
  3030. PsnNo: res.Output.Baseinfo.PsnNo,
  3031. Age: res.Output.Baseinfo.Age,
  3032. PatientId: patient.ID,
  3033. Certno: res.Output.Baseinfo.Certno,
  3034. Brdy: res.Output.Baseinfo.Brdy,
  3035. Gend: res.Output.Baseinfo.Gend,
  3036. Naty: res.Output.Baseinfo.Naty,
  3037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3038. PsnName: res.Output.Baseinfo.PsnName,
  3039. Idetinfo: idetinfoStr,
  3040. Insuinfo: infoStr,
  3041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3042. CardInfo: "",
  3043. VerifyNumber: token,
  3044. }
  3045. service.CreateHisPsn(psn)
  3046. var rf []*ResultFive
  3047. json.Unmarshal([]byte(infoStr), &rf)
  3048. var insutypes []*ResultFive
  3049. var insutype string
  3050. var is390 int = 0
  3051. var is310 int = 0
  3052. for _, item := range rf {
  3053. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3054. insutypes = append(insutypes, item)
  3055. }
  3056. }
  3057. if len(insutypes) == 1 {
  3058. insutype = insutypes[0].Insutype
  3059. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3060. } else {
  3061. for _, i := range insutypes {
  3062. if i.Insutype == "390" {
  3063. is390 = 1
  3064. }
  3065. if i.Insutype == "310" {
  3066. is310 = 1
  3067. }
  3068. }
  3069. }
  3070. if is390 == 1 {
  3071. insutype = "390"
  3072. }
  3073. if is310 == 1 {
  3074. insutype = "310"
  3075. }
  3076. if len(insutypes) == 0 {
  3077. insutype = "310"
  3078. }
  3079. c.ServeSuccessJSON(map[string]interface{}{
  3080. "patient": patient,
  3081. "number": token,
  3082. "insutype": insutype,
  3083. })
  3084. }
  3085. } else {
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3087. return
  3088. }
  3089. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3090. type ELeData struct {
  3091. Code string `json:"code"`
  3092. Data struct {
  3093. Aac002 string `json:"aac002"`
  3094. Aaz500 string `json:"aaz500"`
  3095. ActCardNo string `json:"actCardNo"`
  3096. Bab520 string `json:"bab520"`
  3097. Bkz543 string `json:"bkz543"`
  3098. BusinessType string `json:"businessType"`
  3099. CertfCodg string `json:"certfCodg"`
  3100. EcIndexNo string `json:"ecIndexNo"`
  3101. EcToken string `json:"ecToken"`
  3102. ID0000 string `json:"id0000"`
  3103. IDNo string `json:"idNo"`
  3104. IDType string `json:"idType"`
  3105. Idcode string `json:"idcode"`
  3106. IdentityToken string `json:"identity_token"`
  3107. InsuOrg string `json:"insuOrg"`
  3108. OfficeID string `json:"officeId"`
  3109. OfficeName string `json:"officeName"`
  3110. OperatorID string `json:"operatorId"`
  3111. OperatorName string `json:"operatorName"`
  3112. OrgID string `json:"orgId"`
  3113. UserName string `json:"userName"`
  3114. } `json:"data"`
  3115. Infno interface{} `json:"infno"`
  3116. Message string `json:"message"`
  3117. OrgID string `json:"orgId"`
  3118. TransType string `json:"transType"`
  3119. }
  3120. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3121. outPutInfo = Remove0000(outPutInfo)
  3122. if len(outPutInfo) > 0 {
  3123. var ele ELeData
  3124. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3125. if err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. }
  3128. token := ele.Data.EcToken
  3129. fmt.Println(inputInfo)
  3130. fmt.Println(outPutInfo)
  3131. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3132. saveLog(result, requestLog, "1101", "获取人员信息")
  3133. var dat map[string]interface{}
  3134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3135. fmt.Println(dat)
  3136. } else {
  3137. fmt.Println(err)
  3138. }
  3139. userJSONBytes, _ := json.Marshal(dat)
  3140. var res ResultTwo
  3141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3142. utils.ErrorLog("解析失败:%v", err)
  3143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. return
  3145. }
  3146. res.ErrMsg = errMsgLog
  3147. if res.Infcode == 0 {
  3148. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3149. if err == gorm.ErrRecordNotFound {
  3150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3151. return
  3152. } else if err != nil {
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3154. return
  3155. } else {
  3156. fmt.Println(res)
  3157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3159. infoStr := string(Iinfos)
  3160. idetinfoStr := string(Idetinfos)
  3161. psn := &models.HisPsn{
  3162. PsnNo: res.Output.Baseinfo.PsnNo,
  3163. Age: res.Output.Baseinfo.Age,
  3164. PatientId: patient.ID,
  3165. Certno: res.Output.Baseinfo.Certno,
  3166. Brdy: res.Output.Baseinfo.Brdy,
  3167. Gend: res.Output.Baseinfo.Gend,
  3168. Naty: res.Output.Baseinfo.Naty,
  3169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3170. PsnName: res.Output.Baseinfo.PsnName,
  3171. Idetinfo: idetinfoStr,
  3172. Insuinfo: infoStr,
  3173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3174. CardInfo: outPutInfo,
  3175. VerifyNumber: token,
  3176. }
  3177. service.CreateHisPsn(psn)
  3178. var rf []*ResultFive
  3179. json.Unmarshal([]byte(infoStr), &rf)
  3180. var insutypes []*ResultFive
  3181. var insutype string
  3182. var is390 int = 0
  3183. var is310 int = 0
  3184. for _, item := range rf {
  3185. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3186. insutypes = append(insutypes, item)
  3187. }
  3188. }
  3189. if len(insutypes) == 1 {
  3190. insutype = insutypes[0].Insutype
  3191. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3192. } else {
  3193. for _, i := range insutypes {
  3194. if i.Insutype == "390" {
  3195. is390 = 1
  3196. }
  3197. if i.Insutype == "310" {
  3198. is310 = 1
  3199. }
  3200. }
  3201. }
  3202. if is390 == 1 {
  3203. insutype = "390"
  3204. }
  3205. if is310 == 1 {
  3206. insutype = "310"
  3207. }
  3208. if len(insutypes) == 0 {
  3209. insutype = "310"
  3210. }
  3211. c.ServeSuccessJSON(map[string]interface{}{
  3212. "patient": patient,
  3213. "number": token,
  3214. "insutype": insutype,
  3215. })
  3216. }
  3217. } else {
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3219. return
  3220. }
  3221. }
  3222. }
  3223. break
  3224. }
  3225. }
  3226. var initFlag int64 = 0
  3227. var initEleFlag int64 = 0
  3228. func (c *HisApiController) TestGetBasBaseInit() {
  3229. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3230. Iinit := DllDef.MustFindProc("Init")
  3231. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3232. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3233. if ret != 0 {
  3234. fmt.Println("SSCard的报错原因:", err)
  3235. fmt.Println("SSCard的运算结果为:", ret)
  3236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3237. return
  3238. }
  3239. result := int(ret)
  3240. fmt.Println("SSCard的运算结果为1:", result)
  3241. initFlag = 1
  3242. return
  3243. }
  3244. func (c *HisApiController) HandleJiangXiReadCard() {
  3245. fmt.Println("~~~~~~")
  3246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3247. admin_user_id, _ := c.GetInt64("admin_user_id")
  3248. id_card_type, _ := c.GetInt64("id_card_type")
  3249. //certificates, _ := c.GetInt64("certificates")
  3250. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3251. if initFlag == 0 {
  3252. c.TestGetJiangXiBasBaseInit()
  3253. }
  3254. basStr := c.GetBasBaseInfo()
  3255. if len(basStr) == 0 {
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3257. return
  3258. }
  3259. fmt.Println(basStr)
  3260. bas := strings.Split(basStr, "|")
  3261. basNumber := bas[1]
  3262. fmt.Println(basNumber)
  3263. card_sn := bas[3]
  3264. fmt.Println(card_sn)
  3265. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  3266. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3267. var dat map[string]interface{}
  3268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3269. fmt.Println(dat)
  3270. } else {
  3271. fmt.Println(err)
  3272. }
  3273. userJSONBytes, _ := json.Marshal(dat)
  3274. var res ResultTwo
  3275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3276. utils.ErrorLog("解析失败:%v", err)
  3277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. return
  3279. }
  3280. if res.Infcode == 0 {
  3281. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3282. if err == gorm.ErrRecordNotFound {
  3283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3284. return
  3285. } else if err != nil {
  3286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3287. return
  3288. } else {
  3289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3291. infoStr := string(Iinfos)
  3292. idetinfoStr := string(Idetinfos)
  3293. psn := &models.HisPsn{
  3294. PsnNo: res.Output.Baseinfo.PsnNo,
  3295. Age: res.Output.Baseinfo.Age,
  3296. PatientId: patient.ID,
  3297. Certno: res.Output.Baseinfo.Certno,
  3298. Brdy: res.Output.Baseinfo.Brdy,
  3299. Gend: res.Output.Baseinfo.Gend,
  3300. Naty: res.Output.Baseinfo.Naty,
  3301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3302. PsnName: res.Output.Baseinfo.PsnName,
  3303. Idetinfo: idetinfoStr,
  3304. Insuinfo: infoStr,
  3305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3306. CardInfo: basStr,
  3307. VerifyNumber: "",
  3308. }
  3309. service.CreateHisPsn(psn)
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "patient": patient,
  3312. "number": basNumber,
  3313. })
  3314. }
  3315. } else {
  3316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3317. return
  3318. }
  3319. }
  3320. func (c *HisApiController) TestGetHnBasBaseInit() {
  3321. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3322. Iinit := DllDef.MustFindProc("Init")
  3323. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3324. //http://10.77.211.236/CSB/hsa-fsi-1303
  3325. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3326. if ret != 0 {
  3327. fmt.Println("SSCard的报错原因:", err)
  3328. fmt.Println("SSCard的运算结果为:", ret)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3330. return
  3331. }
  3332. result := int(ret)
  3333. fmt.Println("SSCard的运算结果为1:", result)
  3334. initFlag = 1
  3335. return
  3336. }
  3337. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3338. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3339. Iinit := DllDef.MustFindProc("Init")
  3340. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3341. //http://10.77.211.236/CSB/hsa-fsi-1303
  3342. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3343. if ret != 0 {
  3344. fmt.Println("SSCard的报错原因:", err)
  3345. fmt.Println("SSCard的运算结果为:", ret)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3347. return
  3348. }
  3349. result := int(ret)
  3350. fmt.Println("SSCard的运算结果为1:", result)
  3351. initFlag = 1
  3352. return
  3353. }
  3354. func (c *HisApiController) GetSFZBaseInfo() string {
  3355. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3356. readCard := DllDef.MustFindProc("ReadSFZ")
  3357. if readCard == nil {
  3358. fmt.Println("readcard is nil")
  3359. readCard = DllDef.MustFindProc("ReadSFZ")
  3360. }
  3361. str := make([]byte, 8096)
  3362. str1 := make([]byte, 8096)
  3363. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3364. fmt.Println(r)
  3365. return Remove0000(string(str))
  3366. }
  3367. func (c *HisApiController) GetEleBaseInfo() string {
  3368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3369. readCard := DllDef.MustFindProc("GetQRBase")
  3370. fmt.Println(readCard)
  3371. if readCard == nil {
  3372. fmt.Println("readcard is nil")
  3373. readCard = DllDef.MustFindProc("GetQRBase")
  3374. }
  3375. str := make([]byte, 1024)
  3376. str1 := make([]byte, 1024)
  3377. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3378. fmt.Println(ret2)
  3379. fmt.Println(string(str1))
  3380. fmt.Println(string(str))
  3381. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3382. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3383. if ret2 != 0 {
  3384. return ""
  3385. }
  3386. return string(str)
  3387. }
  3388. func GetJxEleBaseInfo(org_id int64) string {
  3389. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3390. readCard := DllDef.MustFindProc("NationEcTrans")
  3391. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3392. if readCard == nil {
  3393. fmt.Println("readcard is nil")
  3394. readCard = DllDef.MustFindProc("NationEcTrans")
  3395. }
  3396. str1 := make([]byte, 1024)
  3397. data := make(map[string]interface{})
  3398. inputData := make(map[string]interface{})
  3399. inputData["orgId"] = miConfig.Code
  3400. inputData["businessType"] = "01101"
  3401. inputData["operatorId"] = "test001"
  3402. inputData["operatorName"] = "cn"
  3403. inputData["officeId"] = "32760"
  3404. inputData["officeName"] = "waike"
  3405. inputData["deviceType"] = ""
  3406. data["data"] = inputData
  3407. data["transType"] = "ec.query"
  3408. data["extra "] = ""
  3409. data["orgId"] = miConfig.Code
  3410. bytesData, _ := json.Marshal(data)
  3411. //bytesData, _ := json.Marshal(data)
  3412. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3413. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3414. fmt.Println(ret2)
  3415. fmt.Println(string(str1))
  3416. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3417. if ret2 != 0 {
  3418. return ""
  3419. }
  3420. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3421. }
  3422. func GetJxEleBaseInitInfo(org_id int64) string {
  3423. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3424. readCard := DllDef.MustFindProc("NationEcTrans")
  3425. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3426. if readCard == nil {
  3427. fmt.Println("readcard is nil")
  3428. readCard = DllDef.MustFindProc("NationEcTrans")
  3429. }
  3430. str1 := make([]byte, 2048)
  3431. data := make(map[string]interface{})
  3432. inputData := make(map[string]interface{})
  3433. inputData["orgId"] = miConfig.Code
  3434. inputData["businessType"] = "01101"
  3435. inputData["operatorId"] = "1"
  3436. inputData["operatorName"] = "huangchuang"
  3437. inputData["officeId"] = "101"
  3438. inputData["officeName"] = "xuetou"
  3439. inputData["deviceType"] = ""
  3440. data["data"] = inputData
  3441. data["transType"] = "ec.query"
  3442. data["orgId"] = miConfig.Code
  3443. bytesData, _ := json.Marshal(data)
  3444. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3445. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3446. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3447. fmt.Println(ret2)
  3448. fmt.Println(string(str1))
  3449. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3450. if ret2 != 0 {
  3451. return ""
  3452. }
  3453. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3454. initEleFlag = 1
  3455. }
  3456. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3457. }
  3458. func (c *HisApiController) GetBasBaseInfo() string {
  3459. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3460. readCard := DllDef.MustFindProc("ReadCardBas")
  3461. if readCard == nil {
  3462. fmt.Println("readcard is nil")
  3463. readCard = DllDef.MustFindProc("ReadCardBas")
  3464. }
  3465. str := make([]byte, 1024)
  3466. str1 := make([]byte, 1024)
  3467. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3468. fmt.Println(string(str1))
  3469. fmt.Println(string(str))
  3470. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3471. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3472. if ret2 != 0 {
  3473. return ""
  3474. }
  3475. return string(str)
  3476. }
  3477. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3478. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3479. readCard := DllDef.MustFindProc("read_cardinfo")
  3480. if readCard == nil {
  3481. fmt.Println("readcard is nil")
  3482. readCard = DllDef.MustFindProc("read_cardinfo")
  3483. }
  3484. str := make([]byte, 1024) //卡号
  3485. str1 := make([]byte, 1024) //卡识别码
  3486. str2 := make([]byte, 1024) //身份证号
  3487. str3 := make([]byte, 1024) //姓名
  3488. str4 := make([]byte, 1024) //错误信息
  3489. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  3490. fmt.Println(string(str1))
  3491. fmt.Println(string(str))
  3492. fmt.Println(string(str2))
  3493. fmt.Println(string(str3))
  3494. fmt.Println(string(str4))
  3495. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3496. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3497. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3498. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3499. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3500. if ret2 != 0 {
  3501. return "", "", "", "", ""
  3502. }
  3503. return string(str), string(str1), string(str2), string(str3), string(str4)
  3504. }
  3505. type CustomFundPay struct {
  3506. FundPayType string `json:"fund_pay_type"`
  3507. FundPayamt float64 `json:"fund_payamt"`
  3508. }
  3509. func (c *HisApiController) GetSettleList() {
  3510. order_id, _ := c.GetInt64("order_id")
  3511. admin_user_id, _ := c.GetInt64("admin_user_id")
  3512. order, _ := service.GetHisOrderByIDTwo(order_id)
  3513. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3514. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3515. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3516. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3517. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3518. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3519. if order.ID == 0 {
  3520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3521. return
  3522. }
  3523. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3524. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3525. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3526. fmt.Println(count)
  3527. var zero string
  3528. number := count + 1
  3529. if number >= 1000 {
  3530. zero = "0000" + strconv.FormatInt(number, 10)
  3531. } else if number >= 10000 {
  3532. zero = "000" + strconv.FormatInt(number, 10)
  3533. } else if number >= 100000 {
  3534. zero = "00" + strconv.FormatInt(number, 10)
  3535. } else if number >= 1000000 {
  3536. zero = "0" + strconv.FormatInt(number, 10)
  3537. } else {
  3538. zero = strconv.FormatInt(number, 10)
  3539. }
  3540. fmt.Println(zero)
  3541. struct4101 := service.Struct4101{
  3542. PsnNo: order.PsnNo,
  3543. MdtrtId: order.MdtrtId,
  3544. SetlId: order.SetlId,
  3545. PsnName: order.PsnName,
  3546. Gend: order.Gend,
  3547. Brdy: his.Brdy,
  3548. Age: his.Age,
  3549. Naty: order.Naty,
  3550. PatnCertType: "01",
  3551. Certno: order.Certno,
  3552. Prfs: "90",
  3553. ConerName: roles[0].UserName,
  3554. PatnRlts: "99",
  3555. ConerAddr: miConfig.OrgName,
  3556. ConerTel: admin.Mobile,
  3557. HiType: order.Insutype,
  3558. Insuplc: miConfig.InsuplcAdmdvs,
  3559. MaindiagFlag: "1",
  3560. BillCode: order.SetlId,
  3561. BillNo: order.SetlId,
  3562. BizSn: order.Number,
  3563. PsnSelfPay: order.PsnPartAmt,
  3564. PsnOwnPay: order.PsnPartAmt,
  3565. AcctPay: order.AcctPay,
  3566. PsnCashpay: order.PsnCashPay,
  3567. HiPaymtd: "1",
  3568. Hsorg: miConfig.InsuplcAdmdvs,
  3569. HsorgOpter: miConfig.InsuplcAdmdvs,
  3570. MedinsFillPsn: curRoles.UserName,
  3571. MedinsFillDept: depart.Name,
  3572. IptMedType: "2",
  3573. }
  3574. struct4101.SetlBegnDate = order.SetlTime
  3575. struct4101.SetlEndDate = order.SetlTime
  3576. time_arr := strings.Split(order.SetlTime, " ")
  3577. struct4101.AdmTime = time_arr[0]
  3578. struct4101.AdmEndTime = time_arr[0]
  3579. var rf []CustomFundPay
  3580. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3581. var tempFunPays []service.CustomStruct
  3582. for _, item := range rf {
  3583. var tempFunPay service.CustomStruct
  3584. tempFunPay.FundPayamt = item.FundPayamt
  3585. tempFunPay.FundPayType = item.FundPayType
  3586. tempFunPays = append(tempFunPays, tempFunPay)
  3587. }
  3588. struct4101.CustomStruct = tempFunPays
  3589. var tempDiaginfos []service.DiaginfoStructTwo
  3590. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3591. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3592. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3593. var config []*models.HisXtDiagnoseConfig
  3594. for _, item := range diagnosis_ids {
  3595. id, _ := strconv.ParseInt(item, 10, 64)
  3596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3597. config = append(config, &diagnosisConfig)
  3598. }
  3599. for index, item := range config {
  3600. if index == 0 {
  3601. var tempDiaginfo service.DiaginfoStructTwo
  3602. tempDiaginfo.DiagCode = item.CountryCode
  3603. tempDiaginfo.DiagName = item.CountryContentName
  3604. tempDiaginfo.DiagType = "1"
  3605. tempDiaginfo.MaindiagFlag = "1"
  3606. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3607. } else {
  3608. var tempDiaginfo service.DiaginfoStructTwo
  3609. tempDiaginfo.DiagCode = item.CountryCode
  3610. tempDiaginfo.DiagName = item.CountryContentName
  3611. tempDiaginfo.DiagType = "2"
  3612. tempDiaginfo.MaindiagFlag = "0"
  3613. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3614. }
  3615. }
  3616. struct4101.Diseinfo = tempDiaginfos
  3617. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3618. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3619. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3620. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3621. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3622. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3623. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3624. var iteminfo service.IteminfoStruct
  3625. var bedCostTotal float64 = 0 //床位总费
  3626. var bedCostSelfTotal float64 = 0 //床位自费
  3627. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3628. var operationCostTotal float64 = 0 //手术费
  3629. var operationCostSelfTotal float64 = 0 //手术费
  3630. var operationCostPartSelfTotal float64 = 0 //手术费
  3631. var otherCostTotal float64 = 0 //其他费用
  3632. var otherCostSelfTotal float64 = 0 //其他费用
  3633. var otherCostPartSelfTotal float64 = 0 //其他费用
  3634. var materialCostTotal float64 = 0 //材料费
  3635. var materialCostSelfTotal float64 = 0 //材料费
  3636. var materialCostPartSelfTotal float64 = 0 //材料费
  3637. var westernMedicineCostTotal float64 = 0 //西药费
  3638. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3639. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3640. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3641. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3642. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3643. var checkCostTotal float64 = 0 //检查费
  3644. var checkCostSelfTotal float64 = 0 //检查费
  3645. var checkCostPartSelfTotal float64 = 0 //检查费
  3646. var laboratoryCostTotal float64 = 0 //化验费
  3647. var laboratoryCostSelfTotal float64 = 0 //化验费
  3648. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3649. var treatCostTotal float64 = 0 //治疗费用
  3650. var treatCostSelfTotal float64 = 0 //治疗费用
  3651. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3652. decimal.DivisionPrecision = 2
  3653. var bed_fulamt_ownpay_amt float64 = 0
  3654. var operation_fulamt_ownpay_amt float64 = 0
  3655. var other_fulamt_ownpay_amt float64 = 0
  3656. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3657. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3658. var check_fulamt_ownpay_amt float64 = 0
  3659. var material_fulamt_ownpay_amt float64 = 0
  3660. var laboratory_fulamt_ownpay_amt float64 = 0
  3661. var treat_fulamt_ownpay_amt float64 = 0
  3662. var bed_claa_sunmfee float64 = 0
  3663. var bed_clab_amt float64 = 0
  3664. var bed_other_amt float64 = 0
  3665. var operation_claa_sunmfee float64 = 0
  3666. var operation_clab_amt float64 = 0
  3667. var operation_other_amt float64 = 0
  3668. var other_claa_sunmfee float64 = 0
  3669. var other_clab_amt float64 = 0
  3670. var other_other_amt float64 = 0
  3671. var westernMedicine_claa_sunmfee float64 = 0
  3672. var westernMedicine_clab_amt float64 = 0
  3673. var westernMedicine_other_amt float64 = 0
  3674. var chineseTraditional_claa_sunmfee float64 = 0
  3675. var chineseTraditional_clab_amt float64 = 0
  3676. var chineseTraditional_other_amt float64 = 0
  3677. var check_claa_sunmfee float64 = 0
  3678. var check_clab_amt float64 = 0
  3679. var check_other_amt float64 = 0
  3680. var material_claa_sunmfee float64 = 0
  3681. var material_clab_amt float64 = 0
  3682. var material_other_amt float64 = 0
  3683. var laboratory_claa_sunmfee float64 = 0
  3684. var laboratory_clab_amt float64 = 0
  3685. var laboratory_other_amt float64 = 0
  3686. var treat_claa_sunmfee float64 = 0
  3687. var treat_clab_amt float64 = 0
  3688. var treat_other_amt float64 = 0
  3689. for _, item := range order.HisOrderInfo {
  3690. if item.MedChrgitmType == "01" { //床位费
  3691. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3692. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3693. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3694. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3695. if item.ChrgitmLv == "1" {
  3696. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3697. }
  3698. if item.ChrgitmLv == "2" {
  3699. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3700. }
  3701. if item.ChrgitmLv == "3" {
  3702. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3703. }
  3704. }
  3705. if item.MedChrgitmType == "03" { //检查费
  3706. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3707. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3708. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3709. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3710. if item.ChrgitmLv == "1" {
  3711. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3712. }
  3713. if item.ChrgitmLv == "2" {
  3714. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3715. }
  3716. if item.ChrgitmLv == "3" {
  3717. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3718. }
  3719. }
  3720. if item.MedChrgitmType == "04" { //化验费
  3721. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3722. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3723. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3724. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3725. if item.ChrgitmLv == "1" {
  3726. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3727. }
  3728. if item.ChrgitmLv == "2" {
  3729. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3730. }
  3731. if item.ChrgitmLv == "3" {
  3732. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3733. }
  3734. }
  3735. if item.MedChrgitmType == "05" { //治疗费
  3736. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3737. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3738. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3739. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3740. if item.ChrgitmLv == "1" {
  3741. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3742. }
  3743. if item.ChrgitmLv == "2" {
  3744. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3745. }
  3746. if item.ChrgitmLv == "3" {
  3747. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3748. }
  3749. }
  3750. if item.MedChrgitmType == "06" { //手术费
  3751. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3752. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3753. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3754. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3755. if item.ChrgitmLv == "1" {
  3756. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3757. }
  3758. if item.ChrgitmLv == "2" {
  3759. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3760. }
  3761. if item.ChrgitmLv == "3" {
  3762. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3763. }
  3764. }
  3765. if item.MedChrgitmType == "08" { //材料费
  3766. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3767. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3768. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3769. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3770. if item.ChrgitmLv == "1" {
  3771. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3772. }
  3773. if item.ChrgitmLv == "2" {
  3774. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3775. }
  3776. if item.ChrgitmLv == "3" {
  3777. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3778. }
  3779. }
  3780. if item.MedChrgitmType == "09" { //西药费
  3781. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3782. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3783. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3784. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3785. if item.ChrgitmLv == "1" {
  3786. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3787. }
  3788. if item.ChrgitmLv == "2" {
  3789. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3790. }
  3791. if item.ChrgitmLv == "3" {
  3792. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3793. }
  3794. }
  3795. if item.MedChrgitmType == "11" { //中成费
  3796. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3797. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3798. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3799. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3800. if item.ChrgitmLv == "1" {
  3801. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3802. }
  3803. if item.ChrgitmLv == "2" {
  3804. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3805. }
  3806. if item.ChrgitmLv == "3" {
  3807. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3808. }
  3809. }
  3810. if item.MedChrgitmType == "14" { //其他费
  3811. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3812. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3813. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3814. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3815. if item.ChrgitmLv == "1" {
  3816. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3817. }
  3818. if item.ChrgitmLv == "2" {
  3819. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3820. }
  3821. if item.ChrgitmLv == "3" {
  3822. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3823. }
  3824. }
  3825. }
  3826. var iteminfoStructs []service.IteminfoStruct
  3827. if bedCostTotal != 0 {
  3828. iteminfo.MedChrgitm = "01"
  3829. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3830. iteminfo.Amt = bedCostTotal
  3831. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3832. iteminfo.ClabAmt = bed_clab_amt
  3833. iteminfo.OthAmt = bed_other_amt
  3834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3835. }
  3836. if checkCostTotal != 0 {
  3837. iteminfo.MedChrgitm = "03"
  3838. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3839. iteminfo.Amt = checkCostTotal
  3840. iteminfo.ClaaSumfee = check_claa_sunmfee
  3841. iteminfo.ClabAmt = check_clab_amt
  3842. iteminfo.OthAmt = check_other_amt
  3843. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3844. }
  3845. if laboratoryCostTotal != 0 {
  3846. iteminfo.MedChrgitm = "04"
  3847. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3848. iteminfo.Amt = laboratoryCostTotal
  3849. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3850. iteminfo.ClabAmt = laboratory_clab_amt
  3851. iteminfo.OthAmt = laboratory_other_amt
  3852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3853. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3854. }
  3855. if treatCostTotal != 0 {
  3856. iteminfo.MedChrgitm = "05"
  3857. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3858. iteminfo.Amt = treatCostTotal
  3859. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3860. iteminfo.ClabAmt = treat_clab_amt
  3861. iteminfo.OthAmt = treat_other_amt
  3862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3863. //(struct4101.IteminfoStruct, iteminfo)
  3864. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3865. }
  3866. if operationCostTotal != 0 {
  3867. iteminfo.MedChrgitm = "06"
  3868. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3869. iteminfo.Amt = operationCostTotal
  3870. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3871. iteminfo.ClabAmt = operation_clab_amt
  3872. iteminfo.OthAmt = operation_other_amt
  3873. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3875. }
  3876. if materialCostTotal != 0 {
  3877. iteminfo.MedChrgitm = "08"
  3878. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3879. iteminfo.Amt = materialCostTotal
  3880. iteminfo.ClaaSumfee = material_claa_sunmfee
  3881. iteminfo.ClabAmt = material_clab_amt
  3882. iteminfo.OthAmt = material_other_amt
  3883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3885. }
  3886. if westernMedicineCostTotal != 0 {
  3887. iteminfo.MedChrgitm = "09"
  3888. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3889. iteminfo.Amt = westernMedicineCostTotal
  3890. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3891. iteminfo.ClabAmt = westernMedicine_clab_amt
  3892. iteminfo.OthAmt = westernMedicine_other_amt
  3893. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3895. }
  3896. if chineseTraditionalMedicineCostTotal != 0 {
  3897. iteminfo.MedChrgitm = "11"
  3898. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3899. iteminfo.Amt = westernMedicineCostTotal
  3900. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3901. iteminfo.ClabAmt = westernMedicine_clab_amt
  3902. iteminfo.OthAmt = westernMedicine_other_amt
  3903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3905. }
  3906. if otherCostTotal != 0 {
  3907. iteminfo.MedChrgitm = "14"
  3908. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3909. iteminfo.Amt = otherCostTotal
  3910. iteminfo.ClaaSumfee = other_claa_sunmfee
  3911. iteminfo.ClabAmt = other_clab_amt
  3912. iteminfo.OthAmt = other_other_amt
  3913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3915. }
  3916. struct4101.IteminfoStruct = iteminfoStructs
  3917. struct4101.Ntly = "中国"
  3918. struct4101.AdmCaty = "A03.06"
  3919. var res ResultSeventeen
  3920. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3921. struct4101.BillCode = order.Number
  3922. struct4101.BillNo = order.SetlId
  3923. var resOther ResultSeventeenOther
  3924. var pp models.PublicParams
  3925. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3926. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3927. pp.FixmedinsName = miConfig.OrgName
  3928. pp.FixmedinsCode = miConfig.Code
  3929. pp.RequestUrl = miConfig.Url
  3930. pp.Cainfo = miConfig.Cainfo
  3931. pp.SecretKey = miConfig.SecretKey
  3932. pp.AccessKey = miConfig.AccessKey
  3933. pp.OpterName = curRoles.UserName
  3934. client := &http.Client{}
  3935. var req *http.Request
  3936. data := make(map[string]interface{})
  3937. data["struct4101"] = struct4101
  3938. data["pp"] = pp
  3939. bytesData, _ := json.Marshal(data)
  3940. if miConfig.MdtrtareaAdmvs == "320921" {
  3941. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3942. } else {
  3943. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  3944. }
  3945. resp, _ := client.Do(req)
  3946. defer resp.Body.Close()
  3947. body, ioErr := ioutil.ReadAll(resp.Body)
  3948. if ioErr != nil {
  3949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3951. return
  3952. }
  3953. var respJSON map[string]interface{}
  3954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3960. userJSONBytes, _ := json.Marshal(respJSON)
  3961. fmt.Println("log")
  3962. fmt.Println(string(userJSONBytes))
  3963. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3964. utils.ErrorLog("解析失败:%v", err)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. res.InfRefmsgid = resOther.InfRefmsgid
  3969. res.Output = resOther.Output
  3970. res.ErrMsg = resOther.ErrMsg
  3971. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3972. res.Infcode = infocode
  3973. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3974. var pp models.PublicParams
  3975. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3976. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3977. pp.FixmedinsName = miConfig.OrgName
  3978. pp.FixmedinsCode = miConfig.Code
  3979. pp.RequestUrl = miConfig.Url
  3980. pp.Cainfo = miConfig.Cainfo
  3981. pp.SecretKey = miConfig.SecretKey
  3982. pp.AccessKey = miConfig.AccessKey
  3983. pp.OpterName = curRoles.UserName
  3984. result, _ := service.Jxyb4101(struct4101, pp)
  3985. var dat map[string]interface{}
  3986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3987. fmt.Println(dat)
  3988. } else {
  3989. fmt.Println(err)
  3990. }
  3991. userJSONBytes, _ := json.Marshal(dat)
  3992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3993. utils.ErrorLog("解析失败:%v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3998. var pp models.PublicParams
  3999. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4000. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4001. pp.FixmedinsName = miConfig.OrgName
  4002. pp.FixmedinsCode = miConfig.Code
  4003. pp.RequestUrl = miConfig.Url
  4004. pp.Cainfo = miConfig.Cainfo
  4005. pp.SecretKey = miConfig.SecretKey
  4006. pp.AccessKey = miConfig.AccessKey
  4007. pp.OpterName = curRoles.UserName
  4008. result, _ := service.Hnyb4101(struct4101, pp)
  4009. var dat map[string]interface{}
  4010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4011. fmt.Println(dat)
  4012. } else {
  4013. fmt.Println(err)
  4014. }
  4015. userJSONBytes, _ := json.Marshal(dat)
  4016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4017. utils.ErrorLog("解析失败:%v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. } else {
  4022. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4023. var dat map[string]interface{}
  4024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4025. fmt.Println(dat)
  4026. } else {
  4027. fmt.Println(err)
  4028. }
  4029. userJSONBytes, _ := json.Marshal(dat)
  4030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4031. utils.ErrorLog("解析失败:%v", err)
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. }
  4036. if res.Infcode != 0 {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": res.ErrMsg,
  4040. })
  4041. return
  4042. } else {
  4043. order.FaPiaoNumber = zero
  4044. order.FaPiaoCode = last_order.FaPiaoCode
  4045. service.UpdateOrder(order)
  4046. hisFundSettleListResult := &models.HisFundSettleListResult{
  4047. Number: res.Output.SetlListId,
  4048. Status: 1,
  4049. Ctime: time.Now().Unix(),
  4050. Mtime: time.Now().Unix(),
  4051. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4052. IsUpload: 1,
  4053. OrderId: order_id,
  4054. }
  4055. service.CreateUploadRecord(hisFundSettleListResult)
  4056. c.ServeSuccessJSON(map[string]interface{}{
  4057. "msg": "上传成功",
  4058. "result": hisFundSettleListResult,
  4059. })
  4060. return
  4061. }
  4062. }
  4063. func (c *HisApiController) GetSettleListHospital() {
  4064. order_id, _ := c.GetInt64("order_id")
  4065. admin_user_id, _ := c.GetInt64("admin_user_id")
  4066. order, _ := service.GetHisOrderByIDTwo(order_id)
  4067. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4068. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4069. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4071. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4072. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4073. if order.ID == 0 {
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4075. return
  4076. }
  4077. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4078. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4079. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4080. fmt.Println(count)
  4081. var zero string
  4082. number := count + 1
  4083. if number >= 1000 {
  4084. zero = "0000" + strconv.FormatInt(number, 10)
  4085. } else if number >= 10000 {
  4086. zero = "000" + strconv.FormatInt(number, 10)
  4087. } else if number >= 100000 {
  4088. zero = "00" + strconv.FormatInt(number, 10)
  4089. } else if number >= 1000000 {
  4090. zero = "0" + strconv.FormatInt(number, 10)
  4091. } else {
  4092. zero = strconv.FormatInt(number, 10)
  4093. }
  4094. fmt.Println(zero)
  4095. struct4101 := service.Struct4101{
  4096. PsnNo: order.PsnNo,
  4097. MdtrtId: order.MdtrtId,
  4098. SetlId: order.SetlId,
  4099. PsnName: order.PsnName,
  4100. Gend: order.Gend,
  4101. Brdy: his.Brdy,
  4102. Age: int64(order.Age),
  4103. Naty: order.Naty,
  4104. PatnCertType: "01",
  4105. Certno: order.Certno,
  4106. Prfs: "90",
  4107. ConerName: roles[0].UserName,
  4108. PatnRlts: "99",
  4109. ConerAddr: miConfig.OrgName,
  4110. ConerTel: admin.Mobile,
  4111. HiType: order.Insutype,
  4112. Insuplc: miConfig.InsuplcAdmdvs,
  4113. MaindiagFlag: "1",
  4114. BillCode: order.SetlId,
  4115. BillNo: order.SetlId,
  4116. BizSn: order.Number,
  4117. PsnSelfPay: order.PsnPartAmt,
  4118. PsnOwnPay: order.PsnPartAmt,
  4119. AcctPay: order.AcctPay,
  4120. PsnCashpay: order.PsnCashPay,
  4121. HiPaymtd: "1",
  4122. Hsorg: miConfig.InsuplcAdmdvs,
  4123. HsorgOpter: miConfig.InsuplcAdmdvs,
  4124. MedinsFillPsn: curRoles.UserName,
  4125. MedinsFillDept: depart.Name,
  4126. IptMedType: "2",
  4127. AdmTime: his.InHosptialTime,
  4128. AdmEndTime: his.OutHosptialTime,
  4129. }
  4130. struct4101.SetlBegnDate = order.SetlTime
  4131. struct4101.SetlEndDate = order.SetlTime
  4132. var rf []CustomFundPay
  4133. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4134. var tempFunPays []service.CustomStruct
  4135. for _, item := range rf {
  4136. var tempFunPay service.CustomStruct
  4137. tempFunPay.FundPayamt = item.FundPayamt
  4138. tempFunPay.FundPayType = item.FundPayType
  4139. tempFunPays = append(tempFunPays, tempFunPay)
  4140. }
  4141. struct4101.CustomStruct = tempFunPays
  4142. var tempDiaginfos []service.DiaginfoStructTwo
  4143. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4144. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4145. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4146. var config []*models.HisXtDiagnoseConfig
  4147. for _, item := range diagnosis_ids {
  4148. id, _ := strconv.ParseInt(item, 10, 64)
  4149. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4150. config = append(config, &diagnosisConfig)
  4151. }
  4152. for index, item := range config {
  4153. if index == 0 {
  4154. var tempDiaginfo service.DiaginfoStructTwo
  4155. tempDiaginfo.DiagCode = item.CountryCode
  4156. tempDiaginfo.DiagName = item.CountryContentName
  4157. tempDiaginfo.DiagType = "1"
  4158. tempDiaginfo.MaindiagFlag = "1"
  4159. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4160. } else {
  4161. var tempDiaginfo service.DiaginfoStructTwo
  4162. tempDiaginfo.DiagCode = item.CountryCode
  4163. tempDiaginfo.DiagName = item.CountryContentName
  4164. tempDiaginfo.DiagType = "2"
  4165. tempDiaginfo.MaindiagFlag = "0"
  4166. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4167. }
  4168. }
  4169. struct4101.Diseinfo = tempDiaginfos
  4170. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4171. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4172. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4173. tempOpspdiseinfo2.OprnOprtCode = ""
  4174. tempOpspdiseinfo2.OprnOprtName = ""
  4175. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4176. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4177. var iteminfo service.IteminfoStruct
  4178. var bedCostTotal float64 = 0 //床位总费
  4179. var bedCostSelfTotal float64 = 0 //床位自费
  4180. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4181. var operationCostTotal float64 = 0 //手术费
  4182. var operationCostSelfTotal float64 = 0 //手术费
  4183. var operationCostPartSelfTotal float64 = 0 //手术费
  4184. var otherCostTotal float64 = 0 //其他费用
  4185. var otherCostSelfTotal float64 = 0 //其他费用
  4186. var otherCostPartSelfTotal float64 = 0 //其他费用
  4187. var materialCostTotal float64 = 0 //材料费
  4188. var materialCostSelfTotal float64 = 0 //材料费
  4189. var materialCostPartSelfTotal float64 = 0 //材料费
  4190. var westernMedicineCostTotal float64 = 0 //西药费
  4191. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4192. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4193. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4194. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4195. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4196. var checkCostTotal float64 = 0 //检查费
  4197. var checkCostSelfTotal float64 = 0 //检查费
  4198. var checkCostPartSelfTotal float64 = 0 //检查费
  4199. var laboratoryCostTotal float64 = 0 //化验费
  4200. var laboratoryCostSelfTotal float64 = 0 //化验费
  4201. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4202. var treatCostTotal float64 = 0 //治疗费用
  4203. var treatCostSelfTotal float64 = 0 //治疗费用
  4204. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4205. decimal.DivisionPrecision = 2
  4206. var bed_fulamt_ownpay_amt float64 = 0
  4207. var operation_fulamt_ownpay_amt float64 = 0
  4208. var other_fulamt_ownpay_amt float64 = 0
  4209. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4210. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4211. var check_fulamt_ownpay_amt float64 = 0
  4212. var material_fulamt_ownpay_amt float64 = 0
  4213. var laboratory_fulamt_ownpay_amt float64 = 0
  4214. var treat_fulamt_ownpay_amt float64 = 0
  4215. var bed_claa_sunmfee float64 = 0
  4216. var bed_clab_amt float64 = 0
  4217. var bed_other_amt float64 = 0
  4218. var operation_claa_sunmfee float64 = 0
  4219. var operation_clab_amt float64 = 0
  4220. var operation_other_amt float64 = 0
  4221. var other_claa_sunmfee float64 = 0
  4222. var other_clab_amt float64 = 0
  4223. var other_other_amt float64 = 0
  4224. var westernMedicine_claa_sunmfee float64 = 0
  4225. var westernMedicine_clab_amt float64 = 0
  4226. var westernMedicine_other_amt float64 = 0
  4227. var chineseTraditional_claa_sunmfee float64 = 0
  4228. var chineseTraditional_clab_amt float64 = 0
  4229. var chineseTraditional_other_amt float64 = 0
  4230. var check_claa_sunmfee float64 = 0
  4231. var check_clab_amt float64 = 0
  4232. var check_other_amt float64 = 0
  4233. var material_claa_sunmfee float64 = 0
  4234. var material_clab_amt float64 = 0
  4235. var material_other_amt float64 = 0
  4236. var laboratory_claa_sunmfee float64 = 0
  4237. var laboratory_clab_amt float64 = 0
  4238. var laboratory_other_amt float64 = 0
  4239. var treat_claa_sunmfee float64 = 0
  4240. var treat_clab_amt float64 = 0
  4241. var treat_other_amt float64 = 0
  4242. for _, item := range order.HisOrderInfo {
  4243. if item.MedChrgitmType == "01" { //床位费
  4244. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4245. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4246. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4247. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4248. if item.ChrgitmLv == "1" {
  4249. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4250. }
  4251. if item.ChrgitmLv == "2" {
  4252. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4253. }
  4254. if item.ChrgitmLv == "3" {
  4255. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4256. }
  4257. }
  4258. if item.MedChrgitmType == "03" { //检查费
  4259. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4260. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4261. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4262. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4263. if item.ChrgitmLv == "1" {
  4264. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4265. }
  4266. if item.ChrgitmLv == "2" {
  4267. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4268. }
  4269. if item.ChrgitmLv == "3" {
  4270. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4271. }
  4272. }
  4273. if item.MedChrgitmType == "04" { //化验费
  4274. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4275. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4276. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4277. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4278. if item.ChrgitmLv == "1" {
  4279. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4280. }
  4281. if item.ChrgitmLv == "2" {
  4282. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4283. }
  4284. if item.ChrgitmLv == "3" {
  4285. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4286. }
  4287. }
  4288. if item.MedChrgitmType == "05" { //治疗费
  4289. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4290. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4291. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4292. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4293. if item.ChrgitmLv == "1" {
  4294. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4295. }
  4296. if item.ChrgitmLv == "2" {
  4297. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4298. }
  4299. if item.ChrgitmLv == "3" {
  4300. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4301. }
  4302. }
  4303. if item.MedChrgitmType == "06" { //手术费
  4304. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4305. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4306. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4307. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4308. if item.ChrgitmLv == "1" {
  4309. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4310. }
  4311. if item.ChrgitmLv == "2" {
  4312. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4313. }
  4314. if item.ChrgitmLv == "3" {
  4315. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4316. }
  4317. }
  4318. if item.MedChrgitmType == "08" { //材料费
  4319. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4320. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4321. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4322. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4323. if item.ChrgitmLv == "1" {
  4324. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4325. }
  4326. if item.ChrgitmLv == "2" {
  4327. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4328. }
  4329. if item.ChrgitmLv == "3" {
  4330. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4331. }
  4332. }
  4333. if item.MedChrgitmType == "09" { //西药费
  4334. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4335. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4336. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4337. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4338. if item.ChrgitmLv == "1" {
  4339. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4340. }
  4341. if item.ChrgitmLv == "2" {
  4342. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4343. }
  4344. if item.ChrgitmLv == "3" {
  4345. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4346. }
  4347. }
  4348. if item.MedChrgitmType == "11" { //中成费
  4349. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4350. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4351. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4352. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4353. if item.ChrgitmLv == "1" {
  4354. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4355. }
  4356. if item.ChrgitmLv == "2" {
  4357. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4358. }
  4359. if item.ChrgitmLv == "3" {
  4360. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4361. }
  4362. }
  4363. if item.MedChrgitmType == "14" { //其他费
  4364. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4365. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4366. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4367. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4368. if item.ChrgitmLv == "1" {
  4369. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4370. }
  4371. if item.ChrgitmLv == "2" {
  4372. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4373. }
  4374. if item.ChrgitmLv == "3" {
  4375. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4376. }
  4377. }
  4378. }
  4379. var iteminfoStructs []service.IteminfoStruct
  4380. if bedCostTotal != 0 {
  4381. iteminfo.MedChrgitm = "01"
  4382. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4383. iteminfo.Amt = bedCostTotal
  4384. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4385. iteminfo.ClabAmt = bed_clab_amt
  4386. iteminfo.OthAmt = bed_other_amt
  4387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4388. }
  4389. if checkCostTotal != 0 {
  4390. iteminfo.MedChrgitm = "03"
  4391. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4392. iteminfo.Amt = checkCostTotal
  4393. iteminfo.ClaaSumfee = check_claa_sunmfee
  4394. iteminfo.ClabAmt = check_clab_amt
  4395. iteminfo.OthAmt = check_other_amt
  4396. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4397. }
  4398. if laboratoryCostTotal != 0 {
  4399. iteminfo.MedChrgitm = "04"
  4400. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4401. iteminfo.Amt = laboratoryCostTotal
  4402. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4403. iteminfo.ClabAmt = laboratory_clab_amt
  4404. iteminfo.OthAmt = laboratory_other_amt
  4405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4407. }
  4408. if treatCostTotal != 0 {
  4409. iteminfo.MedChrgitm = "05"
  4410. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4411. iteminfo.Amt = treatCostTotal
  4412. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4413. iteminfo.ClabAmt = treat_clab_amt
  4414. iteminfo.OthAmt = treat_other_amt
  4415. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4416. //(struct4101.IteminfoStruct, iteminfo)
  4417. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4418. }
  4419. if operationCostTotal != 0 {
  4420. iteminfo.MedChrgitm = "06"
  4421. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4422. iteminfo.Amt = operationCostTotal
  4423. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4424. iteminfo.ClabAmt = operation_clab_amt
  4425. iteminfo.OthAmt = operation_other_amt
  4426. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4428. }
  4429. if materialCostTotal != 0 {
  4430. iteminfo.MedChrgitm = "08"
  4431. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4432. iteminfo.Amt = materialCostTotal
  4433. iteminfo.ClaaSumfee = material_claa_sunmfee
  4434. iteminfo.ClabAmt = material_clab_amt
  4435. iteminfo.OthAmt = material_other_amt
  4436. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4437. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4438. }
  4439. if westernMedicineCostTotal != 0 {
  4440. iteminfo.MedChrgitm = "09"
  4441. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4442. iteminfo.Amt = westernMedicineCostTotal
  4443. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4444. iteminfo.ClabAmt = westernMedicine_clab_amt
  4445. iteminfo.OthAmt = westernMedicine_other_amt
  4446. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4447. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4448. }
  4449. if chineseTraditionalMedicineCostTotal != 0 {
  4450. iteminfo.MedChrgitm = "11"
  4451. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4452. iteminfo.Amt = westernMedicineCostTotal
  4453. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4454. iteminfo.ClabAmt = westernMedicine_clab_amt
  4455. iteminfo.OthAmt = westernMedicine_other_amt
  4456. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4458. }
  4459. if otherCostTotal != 0 {
  4460. iteminfo.MedChrgitm = "14"
  4461. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4462. iteminfo.Amt = otherCostTotal
  4463. iteminfo.ClaaSumfee = other_claa_sunmfee
  4464. iteminfo.ClabAmt = other_clab_amt
  4465. iteminfo.OthAmt = other_other_amt
  4466. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4467. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4468. }
  4469. struct4101.IteminfoStruct = iteminfoStructs
  4470. struct4101.Ntly = "中国"
  4471. struct4101.AdmCaty = "A03.06"
  4472. var resOther ResultSeventeenOther
  4473. var res ResultSeventeen
  4474. if miConfig.MdtrtareaAdmvs == "150499" {
  4475. var pp models.PublicParams
  4476. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4477. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4478. pp.FixmedinsName = miConfig.OrgName
  4479. pp.FixmedinsCode = miConfig.Code
  4480. pp.RequestUrl = miConfig.Url
  4481. pp.Cainfo = miConfig.Cainfo
  4482. pp.SecretKey = miConfig.SecretKey
  4483. pp.AccessKey = miConfig.AccessKey
  4484. pp.OpterName = curRoles.UserName
  4485. client := &http.Client{}
  4486. var req *http.Request
  4487. data := make(map[string]interface{})
  4488. data["struct4101"] = struct4101
  4489. data["pp"] = pp
  4490. bytesData, _ := json.Marshal(data)
  4491. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4492. resp, _ := client.Do(req)
  4493. defer resp.Body.Close()
  4494. body, ioErr := ioutil.ReadAll(resp.Body)
  4495. if ioErr != nil {
  4496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4498. return
  4499. }
  4500. var respJSON map[string]interface{}
  4501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. return
  4505. }
  4506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4507. userJSONBytes, _ := json.Marshal(respJSON)
  4508. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4509. utils.ErrorLog("解析失败:%v", err)
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4511. return
  4512. }
  4513. res.InfRefmsgid = resOther.InfRefmsgid
  4514. res.Output = resOther.Output
  4515. res.ErrMsg = resOther.ErrMsg
  4516. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4517. res.Infcode = infocode
  4518. } else {
  4519. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4520. var dat map[string]interface{}
  4521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4522. fmt.Println(dat)
  4523. } else {
  4524. fmt.Println(err)
  4525. }
  4526. userJSONBytes, _ := json.Marshal(dat)
  4527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4528. utils.ErrorLog("解析失败:%v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. }
  4533. if res.Infcode != 0 {
  4534. c.ServeSuccessJSON(map[string]interface{}{
  4535. "failed_code": -10,
  4536. "msg": res.ErrMsg,
  4537. })
  4538. return
  4539. } else {
  4540. if miConfig.MdtrtareaAdmvs != "150499" {
  4541. order.FaPiaoNumber = zero
  4542. order.FaPiaoCode = last_order.FaPiaoCode
  4543. service.UpdateOrder(order)
  4544. }
  4545. hisFundSettleListResult := &models.HisFundSettleListResult{
  4546. Number: res.Output.SetlListId,
  4547. Status: 1,
  4548. Ctime: time.Now().Unix(),
  4549. Mtime: time.Now().Unix(),
  4550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4551. IsUpload: 1,
  4552. OrderId: order_id,
  4553. }
  4554. service.CreateUploadRecord(hisFundSettleListResult)
  4555. c.ServeSuccessJSON(map[string]interface{}{
  4556. "msg": "上传成功",
  4557. "result": hisFundSettleListResult,
  4558. })
  4559. return
  4560. }
  4561. }
  4562. func (c *HisApiController) GetBatchSettleList() {
  4563. orders, _ := service.GetAllHisOrder(10106)
  4564. for _, item := range orders {
  4565. order_id := item.ID
  4566. order, _ := service.GetHisOrderByIDTwo(order_id)
  4567. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4568. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4569. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4571. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4573. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4574. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4575. if order.ID == 0 {
  4576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4577. return
  4578. }
  4579. if his.BalanceAccountsType == 2 {
  4580. continue
  4581. }
  4582. struct4101 := service.Struct4101{
  4583. PsnNo: order.PsnNo,
  4584. MdtrtId: order.MdtrtId,
  4585. SetlId: order.SetlId,
  4586. PsnName: order.PsnName,
  4587. Gend: order.Gend,
  4588. Brdy: his.Brdy,
  4589. Age: his.Age,
  4590. Naty: order.Naty,
  4591. PatnCertType: "01",
  4592. Certno: order.Certno,
  4593. Prfs: "90",
  4594. ConerName: roles[0].UserName,
  4595. PatnRlts: "99",
  4596. ConerAddr: miConfig.OrgName,
  4597. ConerTel: admin.Mobile,
  4598. HiType: order.Insutype,
  4599. Insuplc: his.InsuplcAdmdvs,
  4600. MaindiagFlag: "1",
  4601. BillCode: order.SetlId,
  4602. BillNo: order.SetlId,
  4603. BizSn: order.Number,
  4604. PsnSelfPay: order.PsnPartAmt,
  4605. PsnOwnPay: order.PsnPartAmt,
  4606. AcctPay: order.AcctPay,
  4607. PsnCashpay: order.PsnCashPay,
  4608. HiPaymtd: "1",
  4609. Hsorg: his.InsuplcAdmdvs,
  4610. HsorgOpter: his.InsuplcAdmdvs,
  4611. MedinsFillPsn: curRoles.UserName,
  4612. MedinsFillDept: depart.Name,
  4613. IptMedType: "2",
  4614. }
  4615. struct4101.SetlBegnDate = order.SetlTime
  4616. struct4101.SetlEndDate = order.SetlTime
  4617. //if order.SettleType == 1 {
  4618. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4619. // dateStr := t.Format("2006-01-02")
  4620. // struct4101.SetlBegnDate = dateStr
  4621. // struct4101.SetlEndDate = dateStr
  4622. //} else {
  4623. // t := time.Unix(int64(order.SettleStartTime), 0)
  4624. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4625. // dateStartStr := t.Format("2006-01-02")
  4626. // dateEndStr := t2.Format("2006-01-02")
  4627. // struct4101.SetlBegnDate = dateStartStr
  4628. // struct4101.SetlEndDate = dateEndStr
  4629. //}
  4630. var rf []CustomFundPay
  4631. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4632. var tempFunPays []service.CustomStruct
  4633. var tempFunPay610100 service.CustomStruct
  4634. for _, item := range rf {
  4635. if item.FundPayType == "610100" {
  4636. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4637. tempFunPay610100.FundPayType = item.FundPayType
  4638. } else {
  4639. var tempFunPay service.CustomStruct
  4640. tempFunPay.FundPayamt = item.FundPayamt
  4641. tempFunPay.FundPayType = item.FundPayType
  4642. tempFunPays = append(tempFunPays, tempFunPay)
  4643. }
  4644. }
  4645. tempFunPays = append(tempFunPays, tempFunPay610100)
  4646. struct4101.CustomStruct = tempFunPays
  4647. var tempDiaginfos []service.DiaginfoStructTwo
  4648. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4649. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4650. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4651. var config []*models.HisXtDiagnoseConfig
  4652. for _, item := range diagnosis_ids {
  4653. id, _ := strconv.ParseInt(item, 10, 64)
  4654. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4655. config = append(config, &diagnosisConfig)
  4656. }
  4657. for index, item := range config {
  4658. if index == 0 {
  4659. var tempDiaginfo service.DiaginfoStructTwo
  4660. tempDiaginfo.DiagCode = item.CountryCode
  4661. tempDiaginfo.DiagName = item.CountryContentName
  4662. tempDiaginfo.DiagType = "1"
  4663. tempDiaginfo.MaindiagFlag = "1"
  4664. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4665. } else {
  4666. var tempDiaginfo service.DiaginfoStructTwo
  4667. tempDiaginfo.DiagCode = item.CountryCode
  4668. tempDiaginfo.DiagName = item.CountryContentName
  4669. tempDiaginfo.DiagType = "2"
  4670. tempDiaginfo.MaindiagFlag = "0"
  4671. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4672. }
  4673. }
  4674. struct4101.Diseinfo = tempDiaginfos
  4675. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4676. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4677. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4678. tempOpspdiseinfo2.OprnOprtCode = ""
  4679. tempOpspdiseinfo2.OprnOprtName = ""
  4680. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4681. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4682. var iteminfo service.IteminfoStruct
  4683. var bedCostTotal float64 = 0 //床位总费
  4684. var bedCostSelfTotal float64 = 0 //床位自费
  4685. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4686. var examineCostTotal float64 = 0 //诊查总费
  4687. var examineCostSelfTotal float64 = 0 //诊查自费
  4688. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4689. var nursingCostTotal float64 = 0 //护理总费
  4690. var nursingCostSelfTotal float64 = 0 //护理自费
  4691. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4692. var chineseMedicineCostTotal float64 = 0 //中成药
  4693. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4694. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4695. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4696. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4697. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4698. var registerCostTotal float64 = 0 //一般诊疗费
  4699. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4700. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4701. var operationCostTotal float64 = 0 //手术费
  4702. var operationCostSelfTotal float64 = 0 //手术费
  4703. var operationCostPartSelfTotal float64 = 0 //手术费
  4704. var otherCostTotal float64 = 0 //其他费用
  4705. var otherCostSelfTotal float64 = 0 //其他费用
  4706. var otherCostPartSelfTotal float64 = 0 //其他费用
  4707. var materialCostTotal float64 = 0 //材料费
  4708. var materialCostSelfTotal float64 = 0 //材料费
  4709. var materialCostPartSelfTotal float64 = 0 //材料费
  4710. var westernMedicineCostTotal float64 = 0 //西药费
  4711. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4712. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4713. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4714. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4715. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4716. var checkCostTotal float64 = 0 //检查费
  4717. var checkCostSelfTotal float64 = 0 //检查费
  4718. var checkCostPartSelfTotal float64 = 0 //检查费
  4719. var laboratoryCostTotal float64 = 0 //化验费
  4720. var laboratoryCostSelfTotal float64 = 0 //化验费
  4721. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4722. var treatCostTotal float64 = 0 //治疗费用
  4723. var treatCostSelfTotal float64 = 0 //治疗费用
  4724. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4725. decimal.DivisionPrecision = 2
  4726. var bed_fulamt_ownpay_amt float64 = 0
  4727. var examine_fulamt_ownpay_amt float64 = 0
  4728. var nursing_fulamt_ownpay_amt float64 = 0
  4729. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4730. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4731. var register_fulamt_ownpay_amt float64 = 0
  4732. var operation_fulamt_ownpay_amt float64 = 0
  4733. var other_fulamt_ownpay_amt float64 = 0
  4734. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4735. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4736. var check_fulamt_ownpay_amt float64 = 0
  4737. var material_fulamt_ownpay_amt float64 = 0
  4738. var laboratory_fulamt_ownpay_amt float64 = 0
  4739. var treat_fulamt_ownpay_amt float64 = 0
  4740. var bed_claa_sunmfee float64 = 0
  4741. var bed_clab_amt float64 = 0
  4742. var bed_other_amt float64 = 0
  4743. var examine_claa_sunmfee float64 = 0
  4744. var examine_clab_amt float64 = 0
  4745. var examine_other_amt float64 = 0
  4746. var nursing_claa_sunmfee float64 = 0
  4747. var nursing_clab_amt float64 = 0
  4748. var nursing_other_amt float64 = 0
  4749. var chinese_medicine_claa_sunmfee float64 = 0
  4750. var chinese_medicine_clab_amt float64 = 0
  4751. var chinese_medicine_other_amt float64 = 0
  4752. var commonly_treatment_claa_sunmfee float64 = 0
  4753. var commonly_treatment_clab_amt float64 = 0
  4754. var commonly_treatment_other_amt float64 = 0
  4755. var operation_claa_sunmfee float64 = 0
  4756. var operation_clab_amt float64 = 0
  4757. var operation_other_amt float64 = 0
  4758. var other_claa_sunmfee float64 = 0
  4759. var other_clab_amt float64 = 0
  4760. var other_other_amt float64 = 0
  4761. var westernMedicine_claa_sunmfee float64 = 0
  4762. var westernMedicine_clab_amt float64 = 0
  4763. var westernMedicine_other_amt float64 = 0
  4764. var chineseTraditional_claa_sunmfee float64 = 0
  4765. var chineseTraditional_clab_amt float64 = 0
  4766. var chineseTraditional_other_amt float64 = 0
  4767. var check_claa_sunmfee float64 = 0
  4768. var check_clab_amt float64 = 0
  4769. var check_other_amt float64 = 0
  4770. var material_claa_sunmfee float64 = 0
  4771. var material_clab_amt float64 = 0
  4772. var material_other_amt float64 = 0
  4773. var laboratory_claa_sunmfee float64 = 0
  4774. var laboratory_clab_amt float64 = 0
  4775. var laboratory_other_amt float64 = 0
  4776. var treat_claa_sunmfee float64 = 0
  4777. var treat_clab_amt float64 = 0
  4778. var treat_other_amt float64 = 0
  4779. var register_claa_sunmfee float64 = 0
  4780. var register_clab_amt float64 = 0
  4781. var register_other_amt float64 = 0
  4782. for _, item := range order.HisOrderInfo {
  4783. if item.MedChrgitmType == "01" { //床位费
  4784. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4785. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4786. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4787. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4788. if item.ChrgitmLv == "1" {
  4789. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4790. }
  4791. if item.ChrgitmLv == "2" {
  4792. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4793. }
  4794. if item.ChrgitmLv == "3" {
  4795. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4796. }
  4797. }
  4798. if item.MedChrgitmType == "02" { //诊查
  4799. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4800. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4801. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4802. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4803. if item.ChrgitmLv == "1" {
  4804. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4805. }
  4806. if item.ChrgitmLv == "2" {
  4807. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4808. }
  4809. if item.ChrgitmLv == "3" {
  4810. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4811. }
  4812. }
  4813. if item.MedChrgitmType == "03" { //检查费
  4814. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4815. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4816. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4817. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4818. if item.ChrgitmLv == "1" {
  4819. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4820. }
  4821. if item.ChrgitmLv == "2" {
  4822. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4823. }
  4824. if item.ChrgitmLv == "3" {
  4825. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4826. }
  4827. }
  4828. if item.MedChrgitmType == "04" { //化验费
  4829. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4830. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4831. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4832. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4833. if item.ChrgitmLv == "1" {
  4834. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4835. }
  4836. if item.ChrgitmLv == "2" {
  4837. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4838. }
  4839. if item.ChrgitmLv == "3" {
  4840. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4841. }
  4842. }
  4843. if item.MedChrgitmType == "05" { //治疗费
  4844. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4845. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4846. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4847. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4848. if item.ChrgitmLv == "1" {
  4849. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4850. }
  4851. if item.ChrgitmLv == "2" {
  4852. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4853. }
  4854. if item.ChrgitmLv == "3" {
  4855. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4856. }
  4857. }
  4858. if item.MedChrgitmType == "06" { //手术费
  4859. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4860. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4861. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4862. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4863. if item.ChrgitmLv == "1" {
  4864. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4865. }
  4866. if item.ChrgitmLv == "2" {
  4867. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4868. }
  4869. if item.ChrgitmLv == "3" {
  4870. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4871. }
  4872. }
  4873. if item.MedChrgitmType == "07" { //手术费
  4874. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4875. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4876. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4877. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4878. if item.ChrgitmLv == "1" {
  4879. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4880. }
  4881. if item.ChrgitmLv == "2" {
  4882. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4883. }
  4884. if item.ChrgitmLv == "3" {
  4885. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4886. }
  4887. }
  4888. if item.MedChrgitmType == "08" { //材料费
  4889. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4890. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4891. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4892. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4893. if item.ChrgitmLv == "1" {
  4894. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4895. }
  4896. if item.ChrgitmLv == "2" {
  4897. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4898. }
  4899. if item.ChrgitmLv == "3" {
  4900. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4901. }
  4902. }
  4903. if item.MedChrgitmType == "09" { //西药费
  4904. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4905. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4906. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4907. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4908. if item.ChrgitmLv == "1" {
  4909. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4910. }
  4911. if item.ChrgitmLv == "2" {
  4912. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4913. }
  4914. if item.ChrgitmLv == "3" {
  4915. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4916. }
  4917. }
  4918. if item.MedChrgitmType == "10" { //中药饮片
  4919. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4920. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4921. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4922. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4923. if item.ChrgitmLv == "1" {
  4924. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4925. }
  4926. if item.ChrgitmLv == "2" {
  4927. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4928. }
  4929. if item.ChrgitmLv == "3" {
  4930. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4931. }
  4932. }
  4933. if item.MedChrgitmType == "11" { //中成费
  4934. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4935. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4936. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4937. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4938. if item.ChrgitmLv == "1" {
  4939. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4940. }
  4941. if item.ChrgitmLv == "2" {
  4942. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4943. }
  4944. if item.ChrgitmLv == "3" {
  4945. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4946. }
  4947. }
  4948. if item.MedChrgitmType == "12" { //中成费
  4949. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4950. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4951. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4952. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4953. if item.ChrgitmLv == "1" {
  4954. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4955. }
  4956. if item.ChrgitmLv == "2" {
  4957. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4958. }
  4959. if item.ChrgitmLv == "3" {
  4960. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4961. }
  4962. }
  4963. if item.MedChrgitmType == "13" { //中成费
  4964. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4965. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4966. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4967. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4968. if item.ChrgitmLv == "1" {
  4969. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4970. }
  4971. if item.ChrgitmLv == "2" {
  4972. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4973. }
  4974. if item.ChrgitmLv == "3" {
  4975. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4976. }
  4977. }
  4978. if item.MedChrgitmType == "14" { //其他费
  4979. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4980. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4981. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4982. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4983. if item.ChrgitmLv == "1" {
  4984. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4985. }
  4986. if item.ChrgitmLv == "2" {
  4987. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4988. }
  4989. if item.ChrgitmLv == "3" {
  4990. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4991. }
  4992. }
  4993. }
  4994. var iteminfoStructs []service.IteminfoStruct
  4995. if bedCostTotal != 0 {
  4996. iteminfo.MedChrgitm = "01"
  4997. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4998. iteminfo.Amt = bedCostTotal
  4999. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5000. iteminfo.ClabAmt = bed_clab_amt
  5001. iteminfo.OthAmt = bed_other_amt
  5002. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5003. }
  5004. if examineCostTotal != 0 {
  5005. iteminfo.MedChrgitm = "02"
  5006. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5007. iteminfo.Amt = examineCostTotal
  5008. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5009. iteminfo.ClabAmt = examine_clab_amt
  5010. iteminfo.OthAmt = examine_other_amt
  5011. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5012. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5013. }
  5014. if checkCostTotal != 0 {
  5015. iteminfo.MedChrgitm = "03"
  5016. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5017. iteminfo.Amt = checkCostTotal
  5018. iteminfo.ClaaSumfee = check_claa_sunmfee
  5019. iteminfo.ClabAmt = check_clab_amt
  5020. iteminfo.OthAmt = check_other_amt
  5021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5022. }
  5023. if laboratoryCostTotal != 0 {
  5024. iteminfo.MedChrgitm = "04"
  5025. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5026. iteminfo.Amt = laboratoryCostTotal
  5027. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5028. iteminfo.ClabAmt = laboratory_clab_amt
  5029. iteminfo.OthAmt = laboratory_other_amt
  5030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5031. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5032. }
  5033. if treatCostTotal != 0 {
  5034. iteminfo.MedChrgitm = "05"
  5035. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5036. iteminfo.Amt = treatCostTotal
  5037. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5038. iteminfo.ClabAmt = treat_clab_amt
  5039. iteminfo.OthAmt = treat_other_amt
  5040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5041. //(struct4101.IteminfoStruct, iteminfo)
  5042. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5043. }
  5044. if operationCostTotal != 0 {
  5045. iteminfo.MedChrgitm = "06"
  5046. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5047. iteminfo.Amt = operationCostTotal
  5048. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5049. iteminfo.ClabAmt = operation_clab_amt
  5050. iteminfo.OthAmt = operation_other_amt
  5051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5052. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5053. }
  5054. if nursingCostTotal != 0 {
  5055. iteminfo.MedChrgitm = "07"
  5056. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5057. iteminfo.Amt = nursingCostTotal
  5058. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5059. iteminfo.ClabAmt = nursing_clab_amt
  5060. iteminfo.OthAmt = nursing_other_amt
  5061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5062. }
  5063. if materialCostTotal != 0 {
  5064. iteminfo.MedChrgitm = "08"
  5065. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5066. iteminfo.Amt = materialCostTotal
  5067. iteminfo.ClaaSumfee = material_claa_sunmfee
  5068. iteminfo.ClabAmt = material_clab_amt
  5069. iteminfo.OthAmt = material_other_amt
  5070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5072. }
  5073. if westernMedicineCostTotal != 0 {
  5074. iteminfo.MedChrgitm = "09"
  5075. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5076. iteminfo.Amt = westernMedicineCostTotal
  5077. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5078. iteminfo.ClabAmt = westernMedicine_clab_amt
  5079. iteminfo.OthAmt = westernMedicine_other_amt
  5080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5082. }
  5083. if chineseMedicineCostTotal != 0 {
  5084. iteminfo.MedChrgitm = "10"
  5085. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5086. iteminfo.Amt = chineseMedicineCostTotal
  5087. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5088. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5089. iteminfo.OthAmt = chinese_medicine_other_amt
  5090. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5092. }
  5093. if chineseTraditionalMedicineCostTotal != 0 {
  5094. iteminfo.MedChrgitm = "11"
  5095. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5096. iteminfo.Amt = westernMedicineCostTotal
  5097. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5098. iteminfo.ClabAmt = westernMedicine_clab_amt
  5099. iteminfo.OthAmt = westernMedicine_other_amt
  5100. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5102. }
  5103. if commonlyTreatmentCostTotal != 0 {
  5104. iteminfo.MedChrgitm = "12"
  5105. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5106. iteminfo.Amt = commonlyTreatmentCostTotal
  5107. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5108. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5109. iteminfo.OthAmt = commonly_treatment_other_amt
  5110. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5111. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5112. }
  5113. if registerCostTotal != 0 {
  5114. iteminfo.MedChrgitm = "13"
  5115. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5116. iteminfo.Amt = registerCostTotal
  5117. iteminfo.ClaaSumfee = register_claa_sunmfee
  5118. iteminfo.ClabAmt = register_clab_amt
  5119. iteminfo.OthAmt = register_other_amt
  5120. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5121. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5122. }
  5123. if otherCostTotal != 0 {
  5124. iteminfo.MedChrgitm = "14"
  5125. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5126. iteminfo.Amt = otherCostTotal
  5127. iteminfo.ClaaSumfee = other_claa_sunmfee
  5128. iteminfo.ClabAmt = other_clab_amt
  5129. iteminfo.OthAmt = other_other_amt
  5130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5132. }
  5133. struct4101.IteminfoStruct = iteminfoStructs
  5134. time_arr := strings.Split(order.SetlTime, " ")
  5135. struct4101.AdmTime = time_arr[0]
  5136. struct4101.AdmEndTime = time_arr[0]
  5137. struct4101.DoctorName = doctor.UserName
  5138. struct4101.DoctorCode = doctor.DoctorNumber
  5139. struct4101.Ntly = "中国"
  5140. struct4101.AdmCaty = "A03.06"
  5141. var res ResultSeventeen
  5142. if miConfig.MdtrtareaAdmvs == "421300" {
  5143. data := make(map[string]interface{})
  5144. data["struct4101"] = struct4101
  5145. data["secret_key"] = miConfig.SecretKey
  5146. data["org_name"] = miConfig.OrgName
  5147. data["opera"] = curRoles.UserName
  5148. data["code"] = miConfig.Code
  5149. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5150. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5151. client := &http.Client{}
  5152. bytesData, _ := json.Marshal(data)
  5153. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5154. resp, _ := client.Do(req)
  5155. defer resp.Body.Close()
  5156. body, ioErr := ioutil.ReadAll(resp.Body)
  5157. if ioErr != nil {
  5158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5160. return
  5161. }
  5162. var respJSON map[string]interface{}
  5163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5169. userJSONBytes, _ := json.Marshal(respJSON)
  5170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5171. utils.ErrorLog("解析失败:%v", err)
  5172. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5173. adminUser := c.GetAdminUserInfo()
  5174. errlog := &models.HisOrderError{
  5175. UserOrgId: adminUser.CurrentOrgId,
  5176. Ctime: time.Now().Unix(),
  5177. Mtime: time.Now().Unix(),
  5178. ErrMsg: res.ErrMsg + "解析失败",
  5179. Status: 1,
  5180. PatientId: order_id,
  5181. Stage: 10088,
  5182. }
  5183. service.CreateErrMsgLog(errlog)
  5184. continue
  5185. }
  5186. } else {
  5187. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5188. fmt.Println(result)
  5189. var dat map[string]interface{}
  5190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5191. fmt.Println(dat)
  5192. } else {
  5193. fmt.Println(err)
  5194. }
  5195. userJSONBytes, _ := json.Marshal(dat)
  5196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5197. utils.ErrorLog("解析失败:%v", err)
  5198. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5199. adminUser := c.GetAdminUserInfo()
  5200. errlog := &models.HisOrderError{
  5201. UserOrgId: adminUser.CurrentOrgId,
  5202. Ctime: time.Now().Unix(),
  5203. Mtime: time.Now().Unix(),
  5204. ErrMsg: res.ErrMsg + "解析失败",
  5205. Status: 1,
  5206. PatientId: order_id,
  5207. Stage: 10106,
  5208. }
  5209. service.CreateErrMsgLog(errlog)
  5210. continue
  5211. }
  5212. }
  5213. if res.Infcode != 0 {
  5214. adminUser := c.GetAdminUserInfo()
  5215. errlog := &models.HisOrderError{
  5216. UserOrgId: adminUser.CurrentOrgId,
  5217. Ctime: time.Now().Unix(),
  5218. Mtime: time.Now().Unix(),
  5219. ErrMsg: res.ErrMsg,
  5220. Status: 1,
  5221. PatientId: order_id,
  5222. Stage: 10106,
  5223. }
  5224. service.CreateErrMsgLog(errlog)
  5225. continue
  5226. } else {
  5227. hisFundSettleListResult := &models.HisFundSettleListResult{
  5228. Number: res.Output.SetlListId,
  5229. Status: 1,
  5230. Ctime: time.Now().Unix(),
  5231. Mtime: time.Now().Unix(),
  5232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5233. IsUpload: 1,
  5234. OrderId: order_id,
  5235. }
  5236. service.CreateUploadRecord(hisFundSettleListResult)
  5237. continue
  5238. }
  5239. }
  5240. }
  5241. func (c *HisApiController) GetOrgInfo() {
  5242. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5243. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5244. }
  5245. func (c *HisApiController) GetHisPatientInfo() {
  5246. medical_insurance_card := c.GetString("medical_insurance_card")
  5247. id_card_type, _ := c.GetInt64("id_card_type")
  5248. id_card := c.GetString("id_card")
  5249. adminInfo := c.GetAdminUserInfo()
  5250. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5251. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5252. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5253. IdCardNo := ""
  5254. if id_card_type == 1 {
  5255. IdCardNo = medical_insurance_card
  5256. } else if id_card_type == 2 {
  5257. IdCardNo = id_card
  5258. }
  5259. if config.IsOpen == 1 {
  5260. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5261. resp, requestErr := http.Get(api)
  5262. if requestErr != nil {
  5263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5264. return
  5265. }
  5266. defer resp.Body.Close()
  5267. body, ioErr := ioutil.ReadAll(resp.Body)
  5268. if ioErr != nil {
  5269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5271. return
  5272. }
  5273. var respJSON map[string]interface{}
  5274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. return
  5278. }
  5279. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5280. userJSONBytes, _ := json.Marshal(userJSON)
  5281. var res ResultTwo
  5282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5283. utils.ErrorLog("解析失败:%v", err)
  5284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5285. return
  5286. }
  5287. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5288. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5289. infoStr := string(Iinfos)
  5290. idetinfoStr := string(Idetinfos)
  5291. if res.Infcode == 0 {
  5292. his := models.VMHisPatient{
  5293. Status: 1,
  5294. Ctime: time.Now().Unix(),
  5295. Mtime: time.Now().Unix(),
  5296. PsnNo: res.Output.Baseinfo.PsnNo,
  5297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5298. Certno: res.Output.Baseinfo.Certno,
  5299. PsnName: res.Output.Baseinfo.PsnName,
  5300. Gend: res.Output.Baseinfo.Gend,
  5301. Naty: res.Output.Baseinfo.Naty,
  5302. Brdy: res.Output.Baseinfo.Brdy,
  5303. Age: res.Output.Baseinfo.Age,
  5304. Iinfo: infoStr,
  5305. Idetinfo: idetinfoStr,
  5306. UserOrgId: adminInfo.CurrentOrgId,
  5307. IsReturn: 1,
  5308. IdCardType: id_card_type,
  5309. }
  5310. c.ServeSuccessJSON(map[string]interface{}{
  5311. "info": his,
  5312. })
  5313. } else {
  5314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5315. return
  5316. }
  5317. }
  5318. }
  5319. //func GetBasBaseInfo() (jsonStr string, err error) {
  5320. //
  5321. // handle := syscall.NewLazyDLL("SSCard.dll")
  5322. // add := handle.NewProc("ReadCardBas")
  5323. // str := make([]byte, 1024)
  5324. // str1 := make([]byte, 1024)
  5325. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5326. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5327. //
  5328. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5329. //
  5330. // fmt.Println("> Add(4,5)的结果为:", ret)
  5331. // handle.Release()
  5332. //
  5333. // return "", nil
  5334. //
  5335. //}
  5336. //func GetQRBaseInfo() (jsonStr string, err error) {
  5337. // handle := syscall.LoadDLL("SSCard.dll")
  5338. // ReadCardBas := handle.FindProc("GetQRBase")
  5339. //
  5340. // str := make([]byte, 256)
  5341. // str1 := make([]byte, 256)
  5342. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5343. //
  5344. // fmt.Println(string(str))
  5345. // fmt.Println(r)
  5346. // return string(str), nil
  5347. //}
  5348. //func CardInit() int {
  5349. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5350. // add := DllTestDef.MustFindProc("Init")
  5351. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5352. // if err != nil {
  5353. // fmt.Println("SSCard的运算结果为:", ret)
  5354. // }
  5355. // result := int(ret)
  5356. // return result
  5357. //}
  5358. //func CardInit() int {
  5359. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5360. // if err != nil {
  5361. // fmt.Println("SSCard的运算结果为:", ret)
  5362. // }
  5363. // fmt.Println(err)
  5364. // result := int(ret)
  5365. // return result
  5366. //}
  5367. func IntPtr(n int) uintptr {
  5368. return uintptr(n)
  5369. }
  5370. func StrPtr(s string) uintptr {
  5371. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5372. }
  5373. type Result2001 struct {
  5374. Cainfo interface{} `json:"cainfo"`
  5375. ErrMsg string `json:"err_msg"`
  5376. InfRefmsgid string `json:"inf_refmsgid"`
  5377. Infcode int64 `json:"infcode"`
  5378. Output struct {
  5379. Trtinfo struct {
  5380. PsnNo string `json:"psn_no"`
  5381. TrtChkType string `json:"trt_chk_type"`
  5382. FundPayType string `json:"fund_pay_type"`
  5383. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5384. Begndate string `json:"begndate"`
  5385. Enddate string `json:"enddate"`
  5386. TrtChkRslt string `json:"trt_chk_rslt"`
  5387. } `json:"trtinfo"`
  5388. } `json:"output"`
  5389. RefmsgTime string `json:"refmsg_time"`
  5390. RespondTime string `json:"respond_time"`
  5391. Signtype interface{} `json:"signtype"`
  5392. WarnMsg interface{} `json:"warn_msg"`
  5393. }
  5394. type Result2001Org10265 struct {
  5395. Cainfo interface{} `json:"cainfo"`
  5396. ErrMsg string `json:"err_msg"`
  5397. InfRefmsgid string `json:"inf_refmsgid"`
  5398. Infcode string `json:"infcode"`
  5399. Output struct {
  5400. Trtinfo struct {
  5401. PsnNo string `json:"psn_no"`
  5402. TrtChkType string `json:"trt_chk_type"`
  5403. FundPayType string `json:"fund_pay_type"`
  5404. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5405. Begndate string `json:"begndate"`
  5406. Enddate string `json:"enddate"`
  5407. TrtChkRslt string `json:"trt_chk_rslt"`
  5408. } `json:"trtinfo"`
  5409. } `json:"output"`
  5410. RefmsgTime string `json:"refmsg_time"`
  5411. RespondTime string `json:"respond_time"`
  5412. Signtype interface{} `json:"signtype"`
  5413. WarnMsg interface{} `json:"warn_msg"`
  5414. }
  5415. type ResultTwo struct {
  5416. ErrMsg string `json:"err_msg"`
  5417. InfRefmsgid string `json:"inf_refmsgid"`
  5418. Infcode int64 `json:"infcode"`
  5419. Output struct {
  5420. Baseinfo struct {
  5421. Age float64 `json:"age"`
  5422. Brdy string `json:"brdy"`
  5423. Certno string `json:"certno"`
  5424. Gend string `json:"gend"`
  5425. Naty string `json:"naty"`
  5426. PsnCertType string `json:"psn_cert_type"`
  5427. PsnName string `json:"psn_name"`
  5428. PsnNo string `json:"psn_no"`
  5429. } `json:"baseinfo"`
  5430. Idetinfo []interface{} `json:"idetinfo"`
  5431. Iinfo []struct {
  5432. Balc float64 `json:"balc"`
  5433. CvlservFlag string `json:"cvlserv_flag"`
  5434. EmpName string `json:"emp_name"`
  5435. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5436. Insutype string `json:"insutype"`
  5437. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5438. PausInsuDate string `json:"paus_insu_date"`
  5439. PsnInsuDate string `json:"psn_insu_date"`
  5440. PsnInsuStas string `json:"psn_insu_stas"`
  5441. PsnType string `json:"psn_type"`
  5442. } `json:"insuinfo"`
  5443. } `json:"output"`
  5444. RefmsgTime string `json:"refmsg_time"`
  5445. RespondTime string `json:"respond_time"`
  5446. Signtype interface{} `json:"signtype"`
  5447. WarnInfo interface{} `json:"warn_info"`
  5448. }
  5449. type ResultTwo10265 struct {
  5450. ErrMsg string `json:"err_msg"`
  5451. InfRefmsgid string `json:"inf_refmsgid"`
  5452. Infcode string `json:"infcode"`
  5453. Output struct {
  5454. Baseinfo struct {
  5455. Age float64 `json:"age"`
  5456. Brdy string `json:"brdy"`
  5457. Certno string `json:"certno"`
  5458. Gend string `json:"gend"`
  5459. Naty string `json:"naty"`
  5460. PsnCertType string `json:"psn_cert_type"`
  5461. PsnName string `json:"psn_name"`
  5462. PsnNo string `json:"psn_no"`
  5463. } `json:"baseinfo"`
  5464. Idetinfo []interface{} `json:"idetinfo"`
  5465. Iinfo []struct {
  5466. Balc float64 `json:"balc"`
  5467. CvlservFlag string `json:"cvlserv_flag"`
  5468. EmpName string `json:"emp_name"`
  5469. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5470. Insutype string `json:"insutype"`
  5471. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5472. PausInsuDate string `json:"paus_insu_date"`
  5473. PsnInsuDate string `json:"psn_insu_date"`
  5474. PsnInsuStas string `json:"psn_insu_stas"`
  5475. PsnType string `json:"psn_type"`
  5476. } `json:"insuinfo"`
  5477. } `json:"output"`
  5478. RefmsgTime string `json:"refmsg_time"`
  5479. RespondTime string `json:"respond_time"`
  5480. Signtype interface{} `json:"signtype"`
  5481. WarnInfo interface{} `json:"warn_info"`
  5482. }
  5483. type ResultThree struct {
  5484. Cainfo interface{} `json:"cainfo"`
  5485. ErrMsg string `json:"err_msg"`
  5486. InfRefmsgid string `json:"inf_refmsgid"`
  5487. Infcode int64 `json:"infcode"`
  5488. Output struct {
  5489. Data struct {
  5490. IptOtpNo string `json:"ipt_otp_no"`
  5491. MdtrtID string `json:"mdtrt_id"`
  5492. PsnNo string `json:"psn_no"`
  5493. } `json:"data"`
  5494. } `json:"output"`
  5495. RefmsgTime string `json:"refmsg_time"`
  5496. RespondTime string `json:"respond_time"`
  5497. Signtype interface{} `json:"signtype"`
  5498. WarnMsg interface{} `json:"warn_msg"`
  5499. }
  5500. type ResultThree10265 struct {
  5501. Cainfo interface{} `json:"cainfo"`
  5502. ErrMsg string `json:"err_msg"`
  5503. InfRefmsgid string `json:"inf_refmsgid"`
  5504. Infcode string `json:"infcode"`
  5505. Output struct {
  5506. Data struct {
  5507. IptOtpNo string `json:"ipt_otp_no"`
  5508. MdtrtID string `json:"mdtrt_id"`
  5509. PsnNo string `json:"psn_no"`
  5510. } `json:"data"`
  5511. } `json:"output"`
  5512. RefmsgTime string `json:"refmsg_time"`
  5513. RespondTime string `json:"respond_time"`
  5514. Signtype interface{} `json:"signtype"`
  5515. WarnMsg interface{} `json:"warn_msg"`
  5516. }
  5517. type ResultFour struct {
  5518. Cainfo string `json:"cainfo"`
  5519. ErrMsg string `json:"err_msg"`
  5520. InfRefmsgid string `json:"inf_refmsgid"`
  5521. Infcode int64 `json:"infcode"`
  5522. Output struct {
  5523. Result []struct {
  5524. BasMednFlag string `json:"bas_medn_flag"`
  5525. ChldMedcFlag string `json:"chld_medc_flag"`
  5526. ChrgitmLv string `json:"chrgitm_lv"`
  5527. Cnt float64 `json:"cnt"`
  5528. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5529. DrtReimFlag string `json:"drt_reim_flag"`
  5530. FeedetlSn string `json:"feedetl_sn"`
  5531. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5532. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5533. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5534. ListSpItemFlag string `json:"list_sp_item_flag"`
  5535. LmtUsedFlag string `json:"lmt_used_flag"`
  5536. MedChrgitmType string `json:"med_chrgitm_type"`
  5537. Memo string `json:"memo"`
  5538. OverlmtAmt float64 `json:"overlmt_amt"`
  5539. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5540. Pric float64 `json:"pric"`
  5541. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5542. SelfpayProp float64 `json:"selfpay_prop"`
  5543. } `json:"result"`
  5544. } `json:"output"`
  5545. RefmsgTime string `json:"refmsg_time"`
  5546. RespondTime string `json:"respond_time"`
  5547. Signtype string `json:"signtype"`
  5548. WarnMsg string `json:"warn_msg"`
  5549. }
  5550. type ResultFour10265 struct {
  5551. Cainfo string `json:"cainfo"`
  5552. ErrMsg string `json:"err_msg"`
  5553. InfRefmsgid string `json:"inf_refmsgid"`
  5554. Infcode string `json:"infcode"`
  5555. Output struct {
  5556. Result []struct {
  5557. BasMednFlag string `json:"bas_medn_flag"`
  5558. ChldMedcFlag string `json:"chld_medc_flag"`
  5559. ChrgitmLv string `json:"chrgitm_lv"`
  5560. Cnt float64 `json:"cnt"`
  5561. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5562. DrtReimFlag string `json:"drt_reim_flag"`
  5563. FeedetlSn string `json:"feedetl_sn"`
  5564. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5565. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5566. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5567. ListSpItemFlag string `json:"list_sp_item_flag"`
  5568. LmtUsedFlag string `json:"lmt_used_flag"`
  5569. MedChrgitmType string `json:"med_chrgitm_type"`
  5570. Memo string `json:"memo"`
  5571. OverlmtAmt float64 `json:"overlmt_amt"`
  5572. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5573. Pric float64 `json:"pric"`
  5574. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5575. SelfpayProp float64 `json:"selfpay_prop"`
  5576. } `json:"result"`
  5577. } `json:"output"`
  5578. RefmsgTime string `json:"refmsg_time"`
  5579. RespondTime string `json:"respond_time"`
  5580. Signtype string `json:"signtype"`
  5581. WarnMsg string `json:"warn_msg"`
  5582. }
  5583. type ResultMemo struct {
  5584. InsuAdmdvs string `json:"insuAdmdvs"`
  5585. }
  5586. //[{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  5587. type ResultIDInfo struct {
  5588. Begntime string `json:"begntime"`
  5589. Endtime string `json:"endtime"`
  5590. Memo string `json:"memo"`
  5591. }
  5592. type ResultFive struct {
  5593. Balc float64 `json:"balc"`
  5594. CvlservFlag string `json:"cvlserv_flag"`
  5595. EmpName string `json:"emp_name"`
  5596. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5597. Insutype string `json:"insutype"`
  5598. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5599. PausInsuDate string `json:"paus_insu_date"`
  5600. PsnInsuDate string `json:"psn_insu_date"`
  5601. PsnInsuStas string `json:"psn_insu_stas"`
  5602. PsnType string `json:"psn_type"`
  5603. }
  5604. type ResultSix struct {
  5605. Cainfo interface{} `json:"cainfo"`
  5606. ErrMsg string `json:"err_msg"`
  5607. InfRefmsgid string `json:"inf_refmsgid"`
  5608. Infcode int64 `json:"infcode"`
  5609. Output struct {
  5610. } `json:"output"`
  5611. RefmsgTime string `json:"refmsg_time"`
  5612. RespondTime string `json:"respond_time"`
  5613. Signtype interface{} `json:"signtype"`
  5614. WarnMsg interface{} `json:"warn_msg"`
  5615. }
  5616. type ResultSix10265 struct {
  5617. Cainfo interface{} `json:"cainfo"`
  5618. ErrMsg string `json:"err_msg"`
  5619. InfRefmsgid string `json:"inf_refmsgid"`
  5620. Infcode string `json:"infcode"`
  5621. Output struct {
  5622. } `json:"output"`
  5623. RefmsgTime string `json:"refmsg_time"`
  5624. RespondTime string `json:"respond_time"`
  5625. Signtype interface{} `json:"signtype"`
  5626. WarnMsg interface{} `json:"warn_msg"`
  5627. }
  5628. type ResultSeven struct {
  5629. Cainfo string `json:"cainfo"`
  5630. ErrMsg string `json:"err_msg"`
  5631. InfRefmsgid string `json:"inf_refmsgid"`
  5632. Infcode int64 `json:"infcode"`
  5633. Output struct {
  5634. Setldetail []interface{} `json:"setldetail"`
  5635. Setlinfo struct {
  5636. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5637. AcctPay float64 `json:"acct_pay"`
  5638. ActPayDedc float64 `json:"act_pay_dedc"`
  5639. Age float64 `json:"age"`
  5640. Balc float64 `json:"balc"`
  5641. Brdy string `json:"brdy"`
  5642. Certno string `json:"certno"`
  5643. ClrOptins string `json:"clr_optins"`
  5644. ClrType string `json:"clr_type"`
  5645. ClrWay string `json:"clr_way"`
  5646. CvlservFlag string `json:"cvlserv_flag"`
  5647. CvlservPay float64 `json:"cvlserv_pay"`
  5648. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5649. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5650. Gend string `json:"gend"`
  5651. HifesPay float64 `json:"hifes_pay"`
  5652. HifmiPay float64 `json:"hifmi_pay"`
  5653. HifpPay float64 `json:"hifp_pay"`
  5654. HospPartAmt float64 `json:"hosp_part_amt"`
  5655. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5656. Insutype string `json:"insutype"`
  5657. MafPay float64 `json:"maf_pay"`
  5658. MdtrtCertType string `json:"mdtrt_cert_type"`
  5659. HifobPay float64 `json:"hifob_pay"`
  5660. MdtrtID string `json:"mdtrt_id"`
  5661. MedType string `json:"med_type"`
  5662. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5663. MedinsSetlID string `json:"medins_setl_id"`
  5664. Naty string `json:"naty"`
  5665. OthPay float64 `json:"oth_pay"`
  5666. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5667. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5668. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5669. PsnCashPay float64 `json:"psn_cash_pay"`
  5670. PsnCertType string `json:"psn_cert_type"`
  5671. PsnName string `json:"psn_name"`
  5672. PsnNo string `json:"psn_no"`
  5673. PsnPartAmt float64 `json:"psn_part_amt"`
  5674. PsnType string `json:"psn_type"`
  5675. SetlID string `json:"setl_id"`
  5676. SetlTime string `json:"setl_time"`
  5677. } `json:"setlinfo"`
  5678. } `json:"output"`
  5679. RefmsgTime string `json:"refmsg_time"`
  5680. RespondTime string `json:"respond_time"`
  5681. Signtype interface{} `json:"signtype"`
  5682. WarnMsg interface{} `json:"warn_msg"`
  5683. }
  5684. type ResultSeven10265 struct {
  5685. Cainfo string `json:"cainfo"`
  5686. ErrMsg string `json:"err_msg"`
  5687. InfRefmsgid string `json:"inf_refmsgid"`
  5688. Infcode string `json:"infcode"`
  5689. Output struct {
  5690. Setldetail []interface{} `json:"setldetail"`
  5691. Setlinfo struct {
  5692. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5693. AcctPay float64 `json:"acct_pay"`
  5694. ActPayDedc float64 `json:"act_pay_dedc"`
  5695. Age float64 `json:"age"`
  5696. Balc float64 `json:"balc"`
  5697. Brdy string `json:"brdy"`
  5698. Certno string `json:"certno"`
  5699. ClrOptins string `json:"clr_optins"`
  5700. ClrType string `json:"clr_type"`
  5701. ClrWay string `json:"clr_way"`
  5702. CvlservFlag string `json:"cvlserv_flag"`
  5703. CvlservPay float64 `json:"cvlserv_pay"`
  5704. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5705. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5706. Gend string `json:"gend"`
  5707. HifesPay float64 `json:"hifes_pay"`
  5708. HifmiPay float64 `json:"hifmi_pay"`
  5709. HifpPay float64 `json:"hifp_pay"`
  5710. HospPartAmt float64 `json:"hosp_part_amt"`
  5711. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5712. Insutype string `json:"insutype"`
  5713. MafPay float64 `json:"maf_pay"`
  5714. MdtrtCertType string `json:"mdtrt_cert_type"`
  5715. HifobPay float64 `json:"hifob_pay"`
  5716. MdtrtID string `json:"mdtrt_id"`
  5717. MedType string `json:"med_type"`
  5718. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5719. MedinsSetlID string `json:"medins_setl_id"`
  5720. Naty string `json:"naty"`
  5721. OthPay float64 `json:"oth_pay"`
  5722. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5723. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5724. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5725. PsnCashPay float64 `json:"psn_cash_pay"`
  5726. PsnCertType string `json:"psn_cert_type"`
  5727. PsnName string `json:"psn_name"`
  5728. PsnNo string `json:"psn_no"`
  5729. PsnPartAmt float64 `json:"psn_part_amt"`
  5730. PsnType string `json:"psn_type"`
  5731. SetlID string `json:"setl_id"`
  5732. SetlTime string `json:"setl_time"`
  5733. } `json:"setlinfo"`
  5734. } `json:"output"`
  5735. RefmsgTime string `json:"refmsg_time"`
  5736. RespondTime string `json:"respond_time"`
  5737. Signtype interface{} `json:"signtype"`
  5738. WarnMsg interface{} `json:"warn_msg"`
  5739. }
  5740. type ResultEight struct {
  5741. Cainfo string `json:"cainfo"`
  5742. ErrMsg string `json:"err_msg"`
  5743. InfRefmsgid string `json:"inf_refmsgid"`
  5744. Infcode int64 `json:"infcode"`
  5745. Output struct {
  5746. Stmtinfo struct {
  5747. SetlOptins string `json:"setl_optins"`
  5748. StmtRslt string `json:"stmt_rslt"`
  5749. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5750. } `json:"stmtinfo"`
  5751. } `json:"output"`
  5752. RefmsgTime string `json:"refmsg_time"`
  5753. RespondTime string `json:"respond_time"`
  5754. Signtype interface{} `json:"signtype"`
  5755. WarnMsg interface{} `json:"warn_msg"`
  5756. }
  5757. type ResultEightFor10188 struct {
  5758. Cainfo string `json:"cainfo"`
  5759. ErrMsg string `json:"err_msg"`
  5760. InfRefmsgid string `json:"inf_refmsgid"`
  5761. Infcode string `json:"infcode"`
  5762. Output struct {
  5763. Stmtinfo struct {
  5764. SetlOptins string `json:"setl_optins"`
  5765. StmtRslt string `json:"stmt_rslt"`
  5766. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5767. } `json:"stmtinfo"`
  5768. } `json:"output"`
  5769. RefmsgTime string `json:"refmsg_time"`
  5770. RespondTime string `json:"respond_time"`
  5771. Signtype interface{} `json:"signtype"`
  5772. WarnMsg interface{} `json:"warn_msg"`
  5773. }
  5774. type ResultNine struct {
  5775. Cainfo string `json:"cainfo"`
  5776. ErrMsg string `json:"err_msg"`
  5777. InfRefmsgid string `json:"inf_refmsgid"`
  5778. Infcode int64 `json:"infcode"`
  5779. Output struct {
  5780. FileQuryNo string `json:"file_qury_no"`
  5781. } `json:"output"`
  5782. RefmsgTime string `json:"refmsg_time"`
  5783. RespondTime string `json:"respond_time"`
  5784. Signtype interface{} `json:"signtype"`
  5785. WarnMsg interface{} `json:"warn_msg"`
  5786. }
  5787. type ResultTen struct {
  5788. Cainfo string `json:"cainfo"`
  5789. ErrMsg string `json:"err_msg"`
  5790. InfRefmsgid string `json:"inf_refmsgid"`
  5791. Infcode int64 `json:"infcode"`
  5792. Output struct {
  5793. DldEndtime string `json:"dld_endtime"`
  5794. FileQuryNo string `json:"file_qury_no"`
  5795. Filename string `json:"filename"`
  5796. } `json:"output"`
  5797. RefmsgTime string `json:"refmsg_time"`
  5798. RespondTime string `json:"respond_time"`
  5799. Signtype interface{} `json:"signtype"`
  5800. WarnMsg interface{} `json:"warn_msg"`
  5801. }
  5802. //type Autogenerated struct {
  5803. // Output struct {
  5804. // Setlinfo struct {
  5805. // SetlTime string `json:"setl_time"`
  5806. // CvlservPay float64 `json:"cvlserv_pay"`
  5807. // Year string `json:"year"`
  5808. // MedType string `json:"med_type"`
  5809. // PsnPay float64 `json:"psn_pay"`
  5810. // OpterID string `json:"opter_id"`
  5811. // Begndate string `json:"begndate"`
  5812. // FlxempeFlag string `json:"flxempe_flag"`
  5813. // HifmiPay float64 `json:"hifmi_pay"`
  5814. // PsnNo string `json:"psn_no"`
  5815. // ActPayDedc float64 `json:"act_pay_dedc"`
  5816. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5817. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5818. // ClrWay string `json:"clr_way"`
  5819. // OthPay float64 `json:"oth_pay"`
  5820. // Gend string `json:"gend"`
  5821. // MdtrtID string `json:"mdtrt_id"`
  5822. // AcctPay float64 `json:"acct_pay"`
  5823. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5824. // Insutype string `json:"insutype"`
  5825. // Invono interface{} `json:"invono"`
  5826. // Enddate string `json:"enddate"`
  5827. // CashPayamt float64 `json:"cash_payamt"`
  5828. // PsnType string `json:"psn_type"`
  5829. // FixmedinsName string `json:"fixmedins_name"`
  5830. // HifpPay float64 `json:"hifp_pay"`
  5831. // NewFlag interface{} `json:"new_flag"`
  5832. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5833. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5834. // PayLoc string `json:"pay_loc"`
  5835. // ClrType string `json:"clr_type"`
  5836. // RefdSetlFlag string `json:"refd_setl_flag"`
  5837. // CvlservFlag string `json:"cvlserv_flag"`
  5838. // EmpName string `json:"emp_name"`
  5839. // Brdy string `json:"brdy"`
  5840. // Naty string `json:"naty"`
  5841. // Certno string `json:"certno"`
  5842. // DiseCode string `json:"dise_code"`
  5843. // FixmedinsCode string `json:"fixmedins_code"`
  5844. // DedcHospLv string `json:"dedc_hosp_lv"`
  5845. // OpterName string `json:"opter_name"`
  5846. // Balc float64 `json:"balc"`
  5847. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5848. // PsnCertType string `json:"psn_cert_type"`
  5849. // HifobPay float64 `json:"hifob_pay"`
  5850. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5851. // HifesPay float64 `json:"hifes_pay"`
  5852. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5853. // OptTime string `json:"opt_time"`
  5854. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5855. // SetlID string `json:"setl_id"`
  5856. // MafPay float64 `json:"maf_pay"`
  5857. // PsnName string `json:"psn_name"`
  5858. // InsuOptins interface{} `json:"insu_optins"`
  5859. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5860. // ClrOptins string `json:"clr_optins"`
  5861. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5862. // DiseName string `json:"dise_name"`
  5863. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5864. // Age float64 `json:"age"`
  5865. // DtrtCertType string `json:"dtrt_cert_type"`
  5866. // HospLv string `json:"hosp_lv"`
  5867. // } `json:"setlinfo"`
  5868. // Setldetail []struct {
  5869. // FundPayType string `json:"fund_pay_type"`
  5870. // FundPayamt float64 `json:"fund_payamt"`
  5871. // SetlProcInfo interface{} `json:"setl_proc_info"`
  5872. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  5873. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  5874. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  5875. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5876. // } `json:"setldetail"`
  5877. // } `json:"output"`
  5878. // Infcode int `json:"infcode"`
  5879. // WarnMsg interface{} `json:"warn_msg"`
  5880. // Cainfo interface{} `json:"cainfo"`
  5881. // ErrMsg interface{} `json:"err_msg"`
  5882. // RefmsgTime string `json:"refmsg_time"`
  5883. // Signtype interface{} `json:"signtype"`
  5884. // RespondTime string `json:"respond_time"`
  5885. // InfRefmsgid string `json:"inf_refmsgid"`
  5886. //}
  5887. type ResultEleven struct {
  5888. Cainfo string `json:"cainfo"`
  5889. ErrMsg string `json:"err_msg"`
  5890. InfRefmsgid string `json:"inf_refmsgid"`
  5891. Infcode int64 `json:"infcode"`
  5892. Output struct {
  5893. Setlinfo struct {
  5894. SetlTime string `json:"setl_time"`
  5895. CvlservPay float64 `json:"cvlserv_pay"`
  5896. Year string `json:"year"`
  5897. MedType string `json:"med_type"`
  5898. PsnPay float64 `json:"psn_pay"`
  5899. OpterID string `json:"opter_id"`
  5900. Begndate string `json:"begndate"`
  5901. FlxempeFlag string `json:"flxempe_flag"`
  5902. HifmiPay float64 `json:"hifmi_pay"`
  5903. PsnNo string `json:"psn_no"`
  5904. ActPayDedc float64 `json:"act_pay_dedc"`
  5905. MedinsSetlID interface{} `json:"medins_setl_id"`
  5906. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5907. ClrWay string `json:"clr_way"`
  5908. OthPay float64 `json:"oth_pay"`
  5909. Gend string `json:"gend"`
  5910. MdtrtID string `json:"mdtrt_id"`
  5911. AcctPay float64 `json:"acct_pay"`
  5912. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5913. Insutype string `json:"insutype"`
  5914. Invono interface{} `json:"invono"`
  5915. Enddate string `json:"enddate"`
  5916. CashPayamt float64 `json:"cash_payamt"`
  5917. PsnType string `json:"psn_type"`
  5918. FixmedinsName string `json:"fixmedins_name"`
  5919. HifpPay float64 `json:"hifp_pay"`
  5920. NewFlag interface{} `json:"new_flag"`
  5921. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5922. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5923. PayLoc string `json:"pay_loc"`
  5924. ClrType string `json:"clr_type"`
  5925. RefdSetlFlag string `json:"refd_setl_flag"`
  5926. CvlservFlag string `json:"cvlserv_flag"`
  5927. EmpName string `json:"emp_name"`
  5928. Brdy string `json:"brdy"`
  5929. Naty string `json:"naty"`
  5930. Certno string `json:"certno"`
  5931. DiseCode string `json:"dise_code"`
  5932. FixmedinsCode string `json:"fixmedins_code"`
  5933. DedcHospLv string `json:"dedc_hosp_lv"`
  5934. OpterName string `json:"opter_name"`
  5935. Balc float64 `json:"balc"`
  5936. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5937. PsnCertType string `json:"psn_cert_type"`
  5938. HifobPay float64 `json:"hifob_pay"`
  5939. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5940. HifesPay float64 `json:"hifes_pay"`
  5941. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5942. OptTime string `json:"opt_time"`
  5943. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5944. SetlID string `json:"setl_id"`
  5945. MafPay float64 `json:"maf_pay"`
  5946. PsnName string `json:"psn_name"`
  5947. InsuOptins interface{} `json:"insu_optins"`
  5948. PrefFundPay interface{} `json:"pref_fund_pay"`
  5949. ClrOptins string `json:"clr_optins"`
  5950. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5951. DiseName string `json:"dise_name"`
  5952. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  5953. Age float64 `json:"age"`
  5954. DtrtCertType string `json:"dtrt_cert_type"`
  5955. HospLv string `json:"hosp_lv"`
  5956. PsnCashPay float64
  5957. } `json:"setlinfo"`
  5958. } `json:"output"`
  5959. RefmsgTime string `json:"refmsg_time"`
  5960. RespondTime string `json:"respond_time"`
  5961. Signtype interface{} `json:"signtype"`
  5962. WarnMsg interface{} `json:"warn_msg"`
  5963. }
  5964. type ResultEleven10265 struct {
  5965. Cainfo string `json:"cainfo"`
  5966. ErrMsg string `json:"err_msg"`
  5967. InfRefmsgid string `json:"inf_refmsgid"`
  5968. Infcode string `json:"infcode"`
  5969. Output struct {
  5970. Setlinfo struct {
  5971. SetlTime string `json:"setl_time"`
  5972. CvlservPay float64 `json:"cvlserv_pay"`
  5973. Year string `json:"year"`
  5974. MedType string `json:"med_type"`
  5975. PsnPay float64 `json:"psn_pay"`
  5976. OpterID string `json:"opter_id"`
  5977. Begndate string `json:"begndate"`
  5978. FlxempeFlag string `json:"flxempe_flag"`
  5979. HifmiPay float64 `json:"hifmi_pay"`
  5980. PsnNo string `json:"psn_no"`
  5981. ActPayDedc float64 `json:"act_pay_dedc"`
  5982. MedinsSetlID interface{} `json:"medins_setl_id"`
  5983. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5984. ClrWay string `json:"clr_way"`
  5985. OthPay float64 `json:"oth_pay"`
  5986. Gend string `json:"gend"`
  5987. MdtrtID string `json:"mdtrt_id"`
  5988. AcctPay float64 `json:"acct_pay"`
  5989. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5990. Insutype string `json:"insutype"`
  5991. Invono interface{} `json:"invono"`
  5992. Enddate string `json:"enddate"`
  5993. CashPayamt float64 `json:"cash_payamt"`
  5994. PsnType string `json:"psn_type"`
  5995. FixmedinsName string `json:"fixmedins_name"`
  5996. HifpPay float64 `json:"hifp_pay"`
  5997. NewFlag interface{} `json:"new_flag"`
  5998. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5999. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6000. PayLoc string `json:"pay_loc"`
  6001. ClrType string `json:"clr_type"`
  6002. RefdSetlFlag string `json:"refd_setl_flag"`
  6003. CvlservFlag string `json:"cvlserv_flag"`
  6004. EmpName string `json:"emp_name"`
  6005. Brdy string `json:"brdy"`
  6006. Naty string `json:"naty"`
  6007. Certno string `json:"certno"`
  6008. DiseCode string `json:"dise_code"`
  6009. FixmedinsCode string `json:"fixmedins_code"`
  6010. DedcHospLv string `json:"dedc_hosp_lv"`
  6011. OpterName string `json:"opter_name"`
  6012. Balc float64 `json:"balc"`
  6013. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6014. PsnCertType string `json:"psn_cert_type"`
  6015. HifobPay float64 `json:"hifob_pay"`
  6016. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6017. HifesPay float64 `json:"hifes_pay"`
  6018. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6019. OptTime string `json:"opt_time"`
  6020. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6021. SetlID string `json:"setl_id"`
  6022. MafPay float64 `json:"maf_pay"`
  6023. PsnName string `json:"psn_name"`
  6024. InsuOptins interface{} `json:"insu_optins"`
  6025. PrefFundPay interface{} `json:"pref_fund_pay"`
  6026. ClrOptins string `json:"clr_optins"`
  6027. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6028. DiseName string `json:"dise_name"`
  6029. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6030. Age float64 `json:"age"`
  6031. DtrtCertType string `json:"dtrt_cert_type"`
  6032. HospLv string `json:"hosp_lv"`
  6033. PsnCashPay float64
  6034. } `json:"setlinfo"`
  6035. } `json:"output"`
  6036. RefmsgTime string `json:"refmsg_time"`
  6037. RespondTime string `json:"respond_time"`
  6038. Signtype interface{} `json:"signtype"`
  6039. WarnMsg interface{} `json:"warn_msg"`
  6040. }
  6041. type ResultTwelve struct {
  6042. Cainfo string `json:"cainfo"`
  6043. ErrMsg string `json:"err_msg"`
  6044. InfRefmsgid string `json:"inf_refmsgid"`
  6045. Infcode int64 `json:"infcode"`
  6046. Output struct {
  6047. MdtrtId string `json:"mdtrt_id"`
  6048. ChrgBchno string `json:"chrg_bchno"`
  6049. PsnNo string `json:"psn_no"`
  6050. } `json:"output"`
  6051. RefmsgTime string `json:"refmsg_time"`
  6052. RespondTime string `json:"respond_time"`
  6053. Signtype interface{} `json:"signtype"`
  6054. WarnMsg interface{} `json:"warn_msg"`
  6055. }
  6056. type ResultThirteen struct {
  6057. ErrMsg string `json:"err_msg"`
  6058. InfRefmsgid string `json:"inf_refmsgid"`
  6059. Infcode int64 `json:"infcode"`
  6060. Output struct {
  6061. Result struct {
  6062. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6063. } `json:"result"`
  6064. } `json:"output"`
  6065. RefmsgTime string `json:"refmsg_time"`
  6066. RespondTime string `json:"respond_time"`
  6067. Signtype interface{} `json:"signtype"`
  6068. WarnInfo interface{} `json:"warn_info"`
  6069. }
  6070. type ResultThirteen10265 struct {
  6071. ErrMsg string `json:"err_msg"`
  6072. InfRefmsgid string `json:"inf_refmsgid"`
  6073. Infcode string `json:"infcode"`
  6074. Output struct {
  6075. Result struct {
  6076. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6077. } `json:"result"`
  6078. } `json:"output"`
  6079. RefmsgTime string `json:"refmsg_time"`
  6080. RespondTime string `json:"respond_time"`
  6081. Signtype interface{} `json:"signtype"`
  6082. WarnInfo interface{} `json:"warn_info"`
  6083. }
  6084. type ResultFourteen struct {
  6085. ErrMsg string `json:"err_msg"`
  6086. InfRefmsgid string `json:"inf_refmsgid"`
  6087. Infcode int64 `json:"infcode"`
  6088. Output struct {
  6089. } `json:"output"`
  6090. RefmsgTime string `json:"refmsg_time"`
  6091. RespondTime string `json:"respond_time"`
  6092. Signtype interface{} `json:"signtype"`
  6093. WarnInfo interface{} `json:"warn_info"`
  6094. }
  6095. type ResultFourteen10265 struct {
  6096. ErrMsg string `json:"err_msg"`
  6097. InfRefmsgid string `json:"inf_refmsgid"`
  6098. Infcode string `json:"infcode"`
  6099. Output struct {
  6100. } `json:"output"`
  6101. RefmsgTime string `json:"refmsg_time"`
  6102. RespondTime string `json:"respond_time"`
  6103. Signtype interface{} `json:"signtype"`
  6104. WarnInfo interface{} `json:"warn_info"`
  6105. }
  6106. type ResultSixteen struct {
  6107. Cainfo string `json:"cainfo"`
  6108. ErrMsg string `json:"err_msg"`
  6109. InfRefmsgid string `json:"inf_refmsgid"`
  6110. Infcode int64 `json:"infcode"`
  6111. Output struct {
  6112. Setldetail []interface{} `json:"setldetail"`
  6113. Setlinfo struct {
  6114. MdtrtID string `json:"mdtrt_id"`
  6115. SetlID string `json:"setl_id"`
  6116. ClrOptins string `json:"clr_optins"`
  6117. SetlTime string `json:"setl_time"`
  6118. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6119. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6120. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6121. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6122. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6123. ActPayDedc float64 `json:"act_pay_dedc"`
  6124. HifpPay float64 `json:"hifp_pay"`
  6125. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6126. Lfpay float64 `json:"selfpay"`
  6127. CvlservPay float64 `json:"cvlserv_pay"`
  6128. HifesPay float64 `json:"hifes_pay"`
  6129. HifmiPay float64 `json:"hifmi_pay"`
  6130. HifobPay float64 `json:"hifob_pay"`
  6131. MafPay float64 `json:"maf_pay"`
  6132. OthPay float64 `json:"oth_pay"`
  6133. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6134. PsnPartAmt float64 `json:"psn_part_amt"`
  6135. AcctPay float64 `json:"acct_pay"`
  6136. Balc float64 `json:"balc"`
  6137. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6138. HospPartAmt float64 `json:"hosp_part_amt"`
  6139. MedinsSetlID string `json:"medins_setl_id"`
  6140. PdnCashPay string `json:"pdn_cash_pay"`
  6141. } `json:"setlinfo"`
  6142. } `json:"output"`
  6143. RefmsgTime string `json:"refmsg_time"`
  6144. RespondTime string `json:"respond_time"`
  6145. Signtype interface{} `json:"signtype"`
  6146. WarnMsg interface{} `json:"warn_msg"`
  6147. }
  6148. type ResultSixteen10265 struct {
  6149. Cainfo string `json:"cainfo"`
  6150. ErrMsg string `json:"err_msg"`
  6151. InfRefmsgid string `json:"inf_refmsgid"`
  6152. Infcode string `json:"infcode"`
  6153. Output struct {
  6154. Setldetail []interface{} `json:"setldetail"`
  6155. Setlinfo struct {
  6156. MdtrtID string `json:"mdtrt_id"`
  6157. SetlID string `json:"setl_id"`
  6158. ClrOptins string `json:"clr_optins"`
  6159. SetlTime string `json:"setl_time"`
  6160. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6161. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6162. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6163. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6164. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6165. ActPayDedc float64 `json:"act_pay_dedc"`
  6166. HifpPay float64 `json:"hifp_pay"`
  6167. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6168. Lfpay float64 `json:"selfpay"`
  6169. CvlservPay float64 `json:"cvlserv_pay"`
  6170. HifesPay float64 `json:"hifes_pay"`
  6171. HifmiPay float64 `json:"hifmi_pay"`
  6172. HifobPay float64 `json:"hifob_pay"`
  6173. MafPay float64 `json:"maf_pay"`
  6174. OthPay float64 `json:"oth_pay"`
  6175. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6176. PsnPartAmt float64 `json:"psn_part_amt"`
  6177. AcctPay float64 `json:"acct_pay"`
  6178. Balc float64 `json:"balc"`
  6179. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6180. HospPartAmt float64 `json:"hosp_part_amt"`
  6181. MedinsSetlID string `json:"medins_setl_id"`
  6182. PdnCashPay string `json:"pdn_cash_pay"`
  6183. } `json:"setlinfo"`
  6184. } `json:"output"`
  6185. RefmsgTime string `json:"refmsg_time"`
  6186. RespondTime string `json:"respond_time"`
  6187. Signtype interface{} `json:"signtype"`
  6188. WarnMsg interface{} `json:"warn_msg"`
  6189. }
  6190. type ResultSeventeen struct {
  6191. ErrMsg string `json:"err_msg"`
  6192. InfRefmsgid string `json:"inf_refmsgid"`
  6193. Infcode int64 `json:"infcode"`
  6194. Output struct {
  6195. SetlListId string `json:"setl_list_id"`
  6196. } `json:"output"`
  6197. RefmsgTime string `json:"refmsg_time"`
  6198. RespondTime string `json:"respond_time"`
  6199. Signtype string `json:"signtype"`
  6200. WarnInfo string `json:"warn_info"`
  6201. }
  6202. type ResultSeventeenOther struct {
  6203. ErrMsg string `json:"err_msg"`
  6204. InfRefmsgid string `json:"inf_refmsgid"`
  6205. Infcode string `json:"infcode"`
  6206. Output struct {
  6207. SetlListId string `json:"setl_list_id"`
  6208. } `json:"output"`
  6209. RefmsgTime string `json:"refmsg_time"`
  6210. RespondTime string `json:"respond_time"`
  6211. Signtype string `json:"signtype"`
  6212. WarnInfo string `json:"warn_info"`
  6213. }
  6214. type Result90991 struct {
  6215. ErrMsg string `json:"err_msg"`
  6216. InfRefmsgid string `json:"inf_refmsgid"`
  6217. Infcode int64 `json:"infcode"`
  6218. Output struct {
  6219. Result struct {
  6220. PsnNo string `json:"psn_no"`
  6221. CardStat string `json:"card_stat"`
  6222. Certno string `json:"certno"`
  6223. PsnName string `json:"psn_name"`
  6224. CheckStat string `json:"check_stat"`
  6225. SscnoCheckStat string `json:"sscno_check_stat"`
  6226. } `json:"result"`
  6227. } `json:"output"`
  6228. RefmsgTime string `json:"refmsg_time"`
  6229. RespondTime string `json:"respond_time"`
  6230. Signtype interface{} `json:"signtype"`
  6231. WarnInfo interface{} `json:"warn_info"`
  6232. }
  6233. type Result90100 struct {
  6234. ErrMsg string `json:"err_msg"`
  6235. InfRefmsgid string `json:"inf_refmsgid"`
  6236. Infcode int64 `json:"infcode"`
  6237. Output struct {
  6238. PoolareaNo string `json:"poolarea_no"`
  6239. PoolareaNoName string `json:"poolarea_no_name"`
  6240. Insutype string `json:"insutype"`
  6241. InsutypeName string `json:"insutype_name"`
  6242. ClctType string `json:"clct_type"`
  6243. ClctTypeName string `json:"clct_type_name"`
  6244. ClctFlag string `json:"clct_flag"`
  6245. ClctFlagName string `json:"clct_flag_name"`
  6246. AccrymBegn string `json:"accrym_begn"`
  6247. AccrymEnd string `json:"accrym_end"`
  6248. ClctTime string `json:"clct_time"`
  6249. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6250. } `json:"output"`
  6251. RefmsgTime string `json:"refmsg_time"`
  6252. RespondTime string `json:"respond_time"`
  6253. Signtype interface{} `json:"signtype"`
  6254. WarnInfo interface{} `json:"warn_info"`
  6255. }
  6256. type Custom struct {
  6257. DetItemFeeSumamt string
  6258. Cut string
  6259. FeedetlSn string
  6260. Price string
  6261. MedListCodg string
  6262. Type int64
  6263. AdviceId int64
  6264. ProjectId int64
  6265. ItemId int64
  6266. }
  6267. type Result5301 struct {
  6268. ErrMsg string `json:"err_msg"`
  6269. InfRefmsgid string `json:"inf_refmsgid"`
  6270. Infcode int64 `json:"infcode"`
  6271. Output struct {
  6272. Result []struct {
  6273. OpspDiseCode string `json:"opsp_dise_code"`
  6274. OpspDiseName string `json:"opsp_dise_name"`
  6275. Begndate string `json:"begndate"`
  6276. Enddate string `json:"enddate"`
  6277. } `json:"feedetail"`
  6278. } `json:"output"`
  6279. RefmsgTime string `json:"refmsg_time"`
  6280. RespondTime string `json:"respond_time"`
  6281. Signtype interface{} `json:"signtype"`
  6282. WarnInfo interface{} `json:"warn_info"`
  6283. }
  6284. type Result5301For10265 struct {
  6285. ErrMsg string `json:"err_msg"`
  6286. InfRefmsgid string `json:"inf_refmsgid"`
  6287. Infcode string `json:"infcode"`
  6288. Output struct {
  6289. Result []struct {
  6290. OpspDiseCode string `json:"opsp_dise_code"`
  6291. OpspDiseName string `json:"opsp_dise_name"`
  6292. Begndate string `json:"begndate"`
  6293. Enddate string `json:"enddate"`
  6294. } `json:"feedetail"`
  6295. } `json:"output"`
  6296. RefmsgTime string `json:"refmsg_time"`
  6297. RespondTime string `json:"respond_time"`
  6298. Signtype interface{} `json:"signtype"`
  6299. WarnInfo interface{} `json:"warn_info"`
  6300. }
  6301. //获取个人信息----挂号-----上传就诊信息
  6302. func (c *HisApiController) GetRegisterInfo() {
  6303. id, _ := c.GetInt64("id")
  6304. record_time := c.GetString("record_time")
  6305. settlementValue, _ := c.GetInt64("settlement_value")
  6306. medical_insurance_card := c.GetString("medical_insurance_card")
  6307. name := c.GetString("name")
  6308. id_card_type, _ := c.GetInt64("id_card_type")
  6309. certificates, _ := c.GetInt64("certificates")
  6310. medical_care, _ := c.GetInt64("medical_care")
  6311. birthday := c.GetString("birthday")
  6312. id_card := c.GetString("id_card")
  6313. register_type, _ := c.GetInt64("register")
  6314. doctor, _ := c.GetInt64("doctor")
  6315. department, _ := c.GetInt64("department")
  6316. gender, _ := c.GetInt64("sex")
  6317. registration_fee, _ := c.GetFloat("registration_fee")
  6318. medical_expenses, _ := c.GetFloat("medical_expenses")
  6319. social_type, _ := c.GetInt64("social_type")
  6320. med_type := c.GetString("social_type")
  6321. admin_user_id, _ := c.GetInt64("admin_user_id")
  6322. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6323. timeLayout := "2006-01-02"
  6324. loc, _ := time.LoadLocation("Local")
  6325. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6326. birthUnix := birthdays.Unix()
  6327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6328. if err != nil {
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6330. return
  6331. }
  6332. recordDateTime := theTime.Unix()
  6333. adminInfo := c.GetAdminUserInfo()
  6334. var patient service.Patients
  6335. if id == 0 {
  6336. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6337. } else {
  6338. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6339. }
  6340. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6341. if patientPrescription.ID == 0 {
  6342. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6343. }
  6344. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6345. if patient.ID == 0 {
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6347. return
  6348. }
  6349. if len(patient.IdCardNo) == 0 {
  6350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6351. return
  6352. }
  6353. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6354. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6355. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6356. //就诊结算未完成,不能进行二次挂号
  6357. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6358. if len(his) >= 1 {
  6359. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6360. if len(his) >= 1 && order.ID == 0 {
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6362. return
  6363. }
  6364. }
  6365. //var register_log string
  6366. if config.IsOpen == 1 {
  6367. var res ResultTwo
  6368. var res10265 ResultTwo10265
  6369. var PsnNo string
  6370. var PsnCertType string
  6371. var Certno string
  6372. var PsnName string
  6373. var Gend string
  6374. var Naty string
  6375. var Brdy string
  6376. var Age float64
  6377. var infoStr string
  6378. var idetinfoStr string
  6379. var infocode int64
  6380. var verify_number string
  6381. fmt.Println(verify_number)
  6382. if miConfig.MdtrtareaAdmvs == "421300" {
  6383. psn_info, _ := service.GetPsnByPatientId(id)
  6384. PsnNo = psn_info.PsnNo
  6385. PsnCertType = psn_info.PsnCertType
  6386. Certno = psn_info.Certno
  6387. PsnName = psn_info.PsnName
  6388. Gend = psn_info.Gend
  6389. Naty = psn_info.Naty
  6390. Brdy = psn_info.Brdy
  6391. Age = psn_info.Age
  6392. infoStr = psn_info.Insuinfo
  6393. idetinfoStr = psn_info.Idetinfo
  6394. infocode = 0
  6395. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6396. psn_info, _ := service.GetPsnByPatientId(id)
  6397. PsnNo = psn_info.PsnNo
  6398. PsnCertType = psn_info.PsnCertType
  6399. Certno = psn_info.Certno
  6400. PsnName = psn_info.PsnName
  6401. Gend = psn_info.Gend
  6402. Naty = psn_info.Naty
  6403. Brdy = psn_info.Brdy
  6404. Age = psn_info.Age
  6405. infoStr = psn_info.Insuinfo
  6406. idetinfoStr = psn_info.Idetinfo
  6407. infocode = 0
  6408. verify_number = psn_info.VerifyNumber
  6409. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6410. if id_card_type == 1 {
  6411. psn_info, _ := service.GetPsnByPatientId(id)
  6412. PsnNo = psn_info.PsnNo
  6413. PsnCertType = psn_info.PsnCertType
  6414. Certno = psn_info.Certno
  6415. PsnName = psn_info.PsnName
  6416. Gend = psn_info.Gend
  6417. Naty = psn_info.Naty
  6418. Brdy = psn_info.Brdy
  6419. Age = psn_info.Age
  6420. infoStr = psn_info.Insuinfo
  6421. idetinfoStr = psn_info.Idetinfo
  6422. infocode = 0
  6423. verify_number = psn_info.VerifyNumber
  6424. } else if id_card_type == 2 {
  6425. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6426. fmt.Println(errMsgLog)
  6427. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6429. utils.ErrorLog("解析失败:%v", err)
  6430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6431. return
  6432. }
  6433. PsnNo = res.Output.Baseinfo.PsnNo
  6434. PsnCertType = res.Output.Baseinfo.PsnCertType
  6435. Certno = res.Output.Baseinfo.Certno
  6436. PsnName = res.Output.Baseinfo.PsnName
  6437. Gend = res.Output.Baseinfo.Gend
  6438. Naty = res.Output.Baseinfo.Naty
  6439. Brdy = res.Output.Baseinfo.Brdy
  6440. Age = res.Output.Baseinfo.Age
  6441. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6442. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6443. infoStr = string(Iinfos)
  6444. idetinfoStr = string(Idetinfos)
  6445. infocode = res.Infcode
  6446. }
  6447. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6448. if id_card_type == 1 {
  6449. psn_info, _ := service.GetPsnByPatientId(id)
  6450. PsnNo = psn_info.PsnNo
  6451. PsnCertType = psn_info.PsnCertType
  6452. Certno = psn_info.Certno
  6453. PsnName = psn_info.PsnName
  6454. Gend = psn_info.Gend
  6455. Naty = psn_info.Naty
  6456. Brdy = psn_info.Brdy
  6457. Age = psn_info.Age
  6458. infoStr = psn_info.Insuinfo
  6459. idetinfoStr = psn_info.Idetinfo
  6460. infocode = 0
  6461. verify_number = psn_info.VerifyNumber
  6462. } else if id_card_type == 2 {
  6463. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  6464. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6466. utils.ErrorLog("解析失败:%v", err)
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return
  6469. }
  6470. PsnNo = res.Output.Baseinfo.PsnNo
  6471. PsnCertType = res.Output.Baseinfo.PsnCertType
  6472. Certno = res.Output.Baseinfo.Certno
  6473. PsnName = res.Output.Baseinfo.PsnName
  6474. Gend = res.Output.Baseinfo.Gend
  6475. Naty = res.Output.Baseinfo.Naty
  6476. Brdy = res.Output.Baseinfo.Brdy
  6477. Age = res.Output.Baseinfo.Age
  6478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6480. infoStr = string(Iinfos)
  6481. idetinfoStr = string(Idetinfos)
  6482. infocode = res.Infcode
  6483. }
  6484. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6485. if id_card_type == 1 {
  6486. psn_info, _ := service.GetPsnByPatientId(id)
  6487. PsnNo = psn_info.PsnNo
  6488. PsnCertType = psn_info.PsnCertType
  6489. Certno = psn_info.Certno
  6490. PsnName = psn_info.PsnName
  6491. Gend = psn_info.Gend
  6492. Naty = psn_info.Naty
  6493. Brdy = psn_info.Brdy
  6494. Age = psn_info.Age
  6495. infoStr = psn_info.Insuinfo
  6496. idetinfoStr = psn_info.Idetinfo
  6497. infocode = 0
  6498. verify_number = psn_info.VerifyNumber
  6499. } else if id_card_type == 2 {
  6500. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  6501. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6502. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6503. utils.ErrorLog("解析失败:%v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. PsnNo = res.Output.Baseinfo.PsnNo
  6508. PsnCertType = res.Output.Baseinfo.PsnCertType
  6509. Certno = res.Output.Baseinfo.Certno
  6510. PsnName = res.Output.Baseinfo.PsnName
  6511. Gend = res.Output.Baseinfo.Gend
  6512. Naty = res.Output.Baseinfo.Naty
  6513. Brdy = res.Output.Baseinfo.Brdy
  6514. Age = res.Output.Baseinfo.Age
  6515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6517. infoStr = string(Iinfos)
  6518. idetinfoStr = string(Idetinfos)
  6519. infocode = res.Infcode
  6520. }
  6521. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6522. var result string
  6523. var requestLog string
  6524. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  6525. if id_card_type == 4 {
  6526. psn_info, _ := service.GetPsnByPatientId(id)
  6527. PsnNo = psn_info.PsnNo
  6528. PsnCertType = psn_info.PsnCertType
  6529. Certno = psn_info.Certno
  6530. PsnName = psn_info.PsnName
  6531. Gend = psn_info.Gend
  6532. Naty = psn_info.Naty
  6533. Brdy = psn_info.Brdy
  6534. Age = psn_info.Age
  6535. infoStr = psn_info.Insuinfo
  6536. idetinfoStr = psn_info.Idetinfo
  6537. infocode = 0
  6538. verify_number = psn_info.VerifyNumber
  6539. } else {
  6540. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6541. if miConfig.Code == "H15049901371" {
  6542. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6543. utils.ErrorLog("解析失败:%v", err)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return
  6546. }
  6547. res.ErrMsg = res10265.ErrMsg
  6548. res.Output = res10265.Output
  6549. res.InfRefmsgid = res10265.InfRefmsgid
  6550. } else {
  6551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6552. utils.ErrorLog("解析失败:%v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. }
  6557. PsnNo = res.Output.Baseinfo.PsnNo
  6558. PsnCertType = res.Output.Baseinfo.PsnCertType
  6559. Certno = res.Output.Baseinfo.Certno
  6560. PsnName = res.Output.Baseinfo.PsnName
  6561. Gend = res.Output.Baseinfo.Gend
  6562. Naty = res.Output.Baseinfo.Naty
  6563. Brdy = res.Output.Baseinfo.Brdy
  6564. Age = res.Output.Baseinfo.Age
  6565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6567. infoStr = string(Iinfos)
  6568. idetinfoStr = string(Idetinfos)
  6569. if miConfig.Code == "H15049901371" {
  6570. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6571. } else {
  6572. infocode = res.Infcode
  6573. }
  6574. }
  6575. } else {
  6576. var result string
  6577. var requestLog string
  6578. if miConfig.UserOrgId == 10138 {
  6579. if id_card_type != 4 {
  6580. //psn_info, _ := service.GetPsnByPatientId(id)
  6581. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6582. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6583. }
  6584. } else {
  6585. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6586. }
  6587. if id_card_type == 4 {
  6588. psn_info, _ := service.GetPsnByPatientId(id)
  6589. PsnNo = psn_info.PsnNo
  6590. PsnCertType = psn_info.PsnCertType
  6591. Certno = psn_info.Certno
  6592. PsnName = psn_info.PsnName
  6593. Gend = psn_info.Gend
  6594. Naty = psn_info.Naty
  6595. Brdy = psn_info.Brdy
  6596. Age = psn_info.Age
  6597. infoStr = psn_info.Insuinfo
  6598. idetinfoStr = psn_info.Idetinfo
  6599. infocode = 0
  6600. verify_number = psn_info.VerifyNumber
  6601. } else {
  6602. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6603. if miConfig.Code == "H15049901371" {
  6604. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6605. utils.ErrorLog("解析失败:%v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. res.ErrMsg = res10265.ErrMsg
  6610. res.Output = res10265.Output
  6611. res.InfRefmsgid = res10265.InfRefmsgid
  6612. } else {
  6613. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. }
  6619. PsnNo = res.Output.Baseinfo.PsnNo
  6620. PsnCertType = res.Output.Baseinfo.PsnCertType
  6621. Certno = res.Output.Baseinfo.Certno
  6622. PsnName = res.Output.Baseinfo.PsnName
  6623. Gend = res.Output.Baseinfo.Gend
  6624. Naty = res.Output.Baseinfo.Naty
  6625. Brdy = res.Output.Baseinfo.Brdy
  6626. Age = res.Output.Baseinfo.Age
  6627. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6628. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6629. infoStr = string(Iinfos)
  6630. idetinfoStr = string(Idetinfos)
  6631. if miConfig.Code == "H15049901371" {
  6632. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6633. } else {
  6634. infocode = res.Infcode
  6635. }
  6636. }
  6637. }
  6638. if infocode == 0 {
  6639. his := models.VMHisPatient{
  6640. Name: name,
  6641. Gender: gender,
  6642. Birthday: birthUnix,
  6643. MedicalTreatmentType: medical_care,
  6644. IdType: certificates,
  6645. IdCardNo: id_card,
  6646. BalanceAccountsType: settlementValue,
  6647. SocialType: social_type,
  6648. MedicalInsuranceNumber: medical_insurance_card,
  6649. RegisterType: register_type,
  6650. RegisterCost: registration_fee,
  6651. TreatmentCost: medical_expenses,
  6652. Status: 1,
  6653. Ctime: time.Now().Unix(),
  6654. Mtime: time.Now().Unix(),
  6655. PsnNo: PsnNo,
  6656. PsnCertType: PsnCertType,
  6657. Certno: Certno,
  6658. PsnName: PsnName,
  6659. Gend: Gend,
  6660. Naty: Naty,
  6661. Brdy: Brdy,
  6662. Age: Age,
  6663. Iinfo: infoStr,
  6664. Idetinfo: idetinfoStr,
  6665. PatientId: patient.ID,
  6666. RecordDate: theTime.Unix(),
  6667. UserOrgId: adminInfo.CurrentOrgId,
  6668. AdminUserId: admin_user_id,
  6669. IsReturn: 1,
  6670. IdCardType: id_card_type,
  6671. Doctor: doctor,
  6672. Departments: department,
  6673. }
  6674. timestamp := time.Now().Unix()
  6675. tempTime := time.Unix(timestamp, 0)
  6676. timeFormat := tempTime.Format("20060102150405")
  6677. chrgBchno := rand.Intn(100000) + 10000
  6678. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6679. his.Number = ipt_otp_no
  6680. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6681. department, _ := service.GetDepartMentDetail(department)
  6682. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6683. IdCardNo := ""
  6684. if id_card_type == 1 {
  6685. // IdCardNo = medical_insurance_card
  6686. IdCardNo = patient.IdCardNo
  6687. } else {
  6688. IdCardNo = patient.IdCardNo
  6689. }
  6690. var rf []*ResultFive
  6691. json.Unmarshal([]byte(his.Iinfo), &rf)
  6692. var insutypes []*ResultFive
  6693. var insutype string
  6694. var insuplc_admdvs_temp string
  6695. var is390 int = 0
  6696. var is310 int = 0
  6697. for _, item := range rf {
  6698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6699. insutypes = append(insutypes, item)
  6700. }
  6701. }
  6702. if len(insutypes) == 1 {
  6703. insutype = insutypes[0].Insutype
  6704. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6705. } else {
  6706. for _, i := range insutypes {
  6707. if i.Insutype == "390" {
  6708. is390 = 1
  6709. }
  6710. if i.Insutype == "310" {
  6711. is310 = 1
  6712. }
  6713. }
  6714. }
  6715. if is390 == 1 {
  6716. insutype = "390"
  6717. }
  6718. if is310 == 1 {
  6719. insutype = "310"
  6720. }
  6721. if len(insutypes) == 0 {
  6722. insutype = "310"
  6723. }
  6724. if len(insutypes) == 2 {
  6725. insutype = med_type
  6726. }
  6727. if len(med_type) > 0 {
  6728. insutype = med_type
  6729. }
  6730. var infocode int64
  6731. var resThree ResultThree
  6732. var resThree10265 ResultThree10265
  6733. if len(insuplc_admdvs) == 0 {
  6734. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6735. } else {
  6736. insuplc_admdvs_temp = insuplc_admdvs
  6737. }
  6738. if miConfig.MdtrtareaAdmvs == "350500" {
  6739. var rf []*ResultIDInfo
  6740. json.Unmarshal([]byte(idetinfoStr), &rf)
  6741. if len(rf) > 0 {
  6742. if len(rf[0].Memo) > 0 {
  6743. content := rf[0].Memo[1:len(rf[0].Memo)]
  6744. content2 := content[:len(rf[0].Memo)-1]
  6745. fmt.Println(content2)
  6746. var rf2 ResultMemo
  6747. json.Unmarshal([]byte(content2), &rf2)
  6748. fmt.Println(rf2)
  6749. fmt.Println(rf2.InsuAdmdvs)
  6750. }
  6751. }
  6752. }
  6753. if miConfig.MdtrtareaAdmvs == "421300" {
  6754. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6755. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6756. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6757. "&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
  6758. resp, requestErr := http.Get(api)
  6759. if requestErr != nil {
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. return
  6762. }
  6763. body, ioErr := ioutil.ReadAll(resp.Body)
  6764. if ioErr != nil {
  6765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. return
  6768. }
  6769. var respJSON map[string]interface{}
  6770. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6773. return
  6774. }
  6775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6776. result, _ := json.Marshal(respJSON)
  6777. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6778. utils.ErrorLog("解析失败:%v", err)
  6779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6780. return
  6781. }
  6782. infocode = resThree.Infcode
  6783. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6784. psn_info, _ := service.GetPsnByPatientId(id)
  6785. his.PsnNo = psn_info.PsnNo
  6786. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6787. var cert_no string
  6788. if id_card_type == 3 {
  6789. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6790. cert_no = IdCardNo
  6791. } else if id_card_type == 4 {
  6792. cert_no = IdCardNo
  6793. psn_info.VerifyNumber = psn_info.VerifyNumber
  6794. } else {
  6795. bas := strings.Split(psn_info.CardInfo, "|")
  6796. cert_no = bas[2]
  6797. }
  6798. var hisPrescription []*models.HisPrescription
  6799. for _, item := range rf {
  6800. if item.Insutype == insutype {
  6801. //insuplc_admdvs = item.InsuplcAdmdvs
  6802. his.InsuplcAdmdvs = insuplc_admdvs
  6803. }
  6804. }
  6805. his.Insutype = insutype
  6806. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6807. fmt.Println(res3101)
  6808. fmt.Println(res3101.Infcode)
  6809. if res3101.Infcode == "0" {
  6810. fmt.Println("33333333")
  6811. if len(res3101.Output.Result) > 0 {
  6812. fmt.Println("222222")
  6813. for _, item := range res3101.Output.Result {
  6814. if len(res3101.ErrMsg) == 0 {
  6815. res3101.ErrMsg = item.VolaCont
  6816. } else {
  6817. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6818. }
  6819. }
  6820. c.ServeSuccessJSON(map[string]interface{}{
  6821. "failed_code": -10,
  6822. "msg": res3101.ErrMsg,
  6823. })
  6824. return
  6825. } else {
  6826. fmt.Println("11111")
  6827. var api string
  6828. if miConfig.MdtrtareaAdmvs == "320921" {
  6829. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6830. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6831. "&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
  6832. } else {
  6833. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6834. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6835. "&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
  6836. }
  6837. resp, requestErr := http.Get(api)
  6838. if requestErr != nil {
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. return
  6841. }
  6842. body, ioErr := ioutil.ReadAll(resp.Body)
  6843. if ioErr != nil {
  6844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. var respJSON map[string]interface{}
  6849. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6855. result, _ := json.Marshal(respJSON)
  6856. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6857. utils.ErrorLog("解析失败:%v", err)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. return
  6860. }
  6861. resThree.ErrMsg = resThree10265.ErrMsg
  6862. resThree.Output = resThree10265.Output
  6863. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6864. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6865. }
  6866. } else if res3101.Infcode != "0" {
  6867. c.ServeSuccessJSON(map[string]interface{}{
  6868. "failed_code": -10,
  6869. "msg": res3101.ErrMsg,
  6870. })
  6871. return
  6872. }
  6873. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6874. psn_info, _ := service.GetPsnByPatientId(id)
  6875. var cert_no string
  6876. if id_card_type == 1 {
  6877. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6878. } else if id_card_type == 4 {
  6879. cert_no = psn_info.VerifyNumber
  6880. } else {
  6881. cert_no = psn_info.VerifyNumber
  6882. }
  6883. 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)
  6884. saveLog(result, requestLog, "2201", "挂号")
  6885. if miConfig.Code == "H15049901371" {
  6886. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6887. utils.ErrorLog("解析失败:%v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. resThree.ErrMsg = resThree10265.ErrMsg
  6892. resThree.Output = resThree10265.Output
  6893. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6894. } else {
  6895. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6896. utils.ErrorLog("解析失败:%v", err)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. }
  6901. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6902. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  6903. psn_info, _ := service.GetPsnByPatientId(id)
  6904. var result string
  6905. var requestLog string
  6906. if id_card_type == 1 {
  6907. bas := strings.Split(psn_info.CardInfo, "|")
  6908. basNumber := bas[2]
  6909. card_sn := bas[3]
  6910. 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)
  6911. saveLog(result, requestLog, "2201A", "挂号")
  6912. } else if id_card_type == 2 {
  6913. 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, "", "")
  6914. saveLog(result, requestLog, "2201A", "挂号")
  6915. } else {
  6916. 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, "", "")
  6917. saveLog(result, requestLog, "2201A", "挂号")
  6918. }
  6919. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6920. utils.ErrorLog("解析失败:%v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. infocode = resThree.Infcode
  6925. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  6926. psn_info, _ := service.GetPsnByPatientId(id)
  6927. var result string
  6928. var requestLog string
  6929. if id_card_type == 1 {
  6930. bas := strings.Split(psn_info.CardInfo, "|")
  6931. basNumber := bas[2]
  6932. card_sn := bas[3]
  6933. 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)
  6934. saveLog(result, requestLog, "2201A", "挂号")
  6935. } else if id_card_type == 2 {
  6936. 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, "", "")
  6937. saveLog(result, requestLog, "2201A", "挂号")
  6938. } else {
  6939. 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, "", "")
  6940. saveLog(result, requestLog, "2201A", "挂号")
  6941. }
  6942. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6943. utils.ErrorLog("解析失败:%v", err)
  6944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6945. return
  6946. }
  6947. infocode = resThree.Infcode
  6948. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6949. psn_info, _ := service.GetPsnByPatientId(id)
  6950. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  6951. saveLog(result, requestLog, "2201A", "挂号")
  6952. if miConfig.Code == "H15049901371" {
  6953. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. resThree.ErrMsg = resThree10265.ErrMsg
  6959. resThree.Output = resThree10265.Output
  6960. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6961. } else {
  6962. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6963. utils.ErrorLog("解析失败:%v", err)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. return
  6966. }
  6967. }
  6968. if miConfig.Code == "H15049901371" {
  6969. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6970. } else {
  6971. infocode = resThree.Infcode
  6972. }
  6973. } else {
  6974. psn_info, _ := service.GetPsnByPatientId(id)
  6975. 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)
  6976. saveLog(result, requestLog, "2201A", "挂号")
  6977. if miConfig.Code == "H15049901371" {
  6978. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6979. utils.ErrorLog("解析失败:%v", err)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. resThree.ErrMsg = resThree10265.ErrMsg
  6984. resThree.Output = resThree10265.Output
  6985. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6986. } else {
  6987. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6988. utils.ErrorLog("解析失败:%v", err)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. return
  6991. }
  6992. }
  6993. if miConfig.Code == "H15049901371" {
  6994. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6995. } else {
  6996. infocode = resThree.Infcode
  6997. }
  6998. }
  6999. if infocode != 0 {
  7000. adminUser := c.GetAdminUserInfo()
  7001. errlog := &models.HisOrderError{
  7002. UserOrgId: adminUser.CurrentOrgId,
  7003. Ctime: time.Now().Unix(),
  7004. Mtime: time.Now().Unix(),
  7005. ErrMsg: resThree.ErrMsg,
  7006. Status: 1,
  7007. PatientId: id,
  7008. RecordTime: recordDateTime,
  7009. Stage: 2,
  7010. }
  7011. service.CreateErrMsgLog(errlog)
  7012. c.ServeSuccessJSON(map[string]interface{}{
  7013. "failed_code": -10,
  7014. "msg": resThree.ErrMsg,
  7015. })
  7016. return
  7017. }
  7018. his.Number = resThree.Output.Data.MdtrtID
  7019. his.PsnNo = resThree.Output.Data.PsnNo
  7020. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7021. his.IdCardNo = patient.IdCardNo
  7022. his.PhoneNumber = patient.Phone
  7023. his.UserOrgId = adminInfo.CurrentOrgId
  7024. his.Insutype = insutype
  7025. his.Ctime = time.Now().Unix()
  7026. his.Mtime = time.Now().Unix()
  7027. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7028. his.Status = 1
  7029. service.UpdateHisPatientStatus(&his)
  7030. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7031. c.ServeSuccessJSON(map[string]interface{}{
  7032. "his_info": his,
  7033. })
  7034. } else {
  7035. adminUser := c.GetAdminUserInfo()
  7036. errlog := &models.HisOrderError{
  7037. UserOrgId: adminUser.CurrentOrgId,
  7038. Ctime: time.Now().Unix(),
  7039. Mtime: time.Now().Unix(),
  7040. ErrMsg: res.ErrMsg,
  7041. Status: 1,
  7042. PatientId: id,
  7043. RecordTime: recordDateTime,
  7044. Stage: 1,
  7045. }
  7046. service.CreateErrMsgLog(errlog)
  7047. c.ServeSuccessJSON(map[string]interface{}{
  7048. "failed_code": -10,
  7049. "msg": res.ErrMsg,
  7050. })
  7051. return
  7052. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7053. }
  7054. }
  7055. }
  7056. //上传明细----预结算----确认订单
  7057. func (c *HisApiController) GetUploadInfo() {
  7058. id, _ := c.GetInt64("id")
  7059. record_time := c.GetString("record_time")
  7060. his_patient_id, _ := c.GetInt64("his_patient_id")
  7061. order_id, _ := c.GetInt64("order_id")
  7062. pay_way, _ := c.GetInt64("pay_way")
  7063. pay_price, _ := c.GetFloat("pay_price")
  7064. pay_card_no := c.GetString("pay_card_no")
  7065. discount_price, _ := c.GetFloat("discount_price")
  7066. preferential_price, _ := c.GetFloat("preferential_price")
  7067. reality_price, _ := c.GetFloat("reality_price")
  7068. found_price, _ := c.GetFloat("found_price")
  7069. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7070. private_price, _ := c.GetFloat("private_price")
  7071. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7072. admin_user_id, _ := c.GetInt64("admin_user_id")
  7073. fapiao_code := c.GetString("fapiao_code")
  7074. fapiao_number := c.GetString("fapiao_number")
  7075. diagnosis_id := c.GetString("diagnosis")
  7076. sick_type, _ := c.GetInt64("sick_type")
  7077. reg_type, _ := c.GetInt64("p_type")
  7078. begin_time := c.GetString("begin_time")
  7079. id_str := c.GetString("ids")
  7080. ids_arr := strings.Split(id_str, ",")
  7081. timeLayout := "2006-01-02"
  7082. loc, _ := time.LoadLocation("Local")
  7083. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7084. if err != nil {
  7085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7086. return
  7087. }
  7088. recordDateTime := theTime.Unix()
  7089. adminUser := c.GetAdminUserInfo()
  7090. var tempOrder models.HisOrder
  7091. tempOrder, _ = service.GetHisOrderByID(order_id)
  7092. var prescriptions []*models.HisPrescription
  7093. var start_time int64
  7094. var end_time int64
  7095. //押金模块
  7096. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7097. tmp_decimal := c.GetString("tmp_decimal")
  7098. var decimal float64 //本次使用的押金
  7099. var errmsg error
  7100. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7101. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7102. return
  7103. }
  7104. if len(tmp_decimal) > 0 {
  7105. if tmp_decimal[0] == 45 {
  7106. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7107. return
  7108. }
  7109. }
  7110. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7111. fmt.Println(errs)
  7112. decimal = tt
  7113. //if adminUser.CurrentOrgId == 10106{
  7114. // if len(fapiao_code) == 0{
  7115. // fapiao_code = "144072080589"
  7116. // }
  7117. // if len(fapiao_number) == 0{
  7118. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7119. // if order.ID == 0{
  7120. // fapiao_number = "00001520"
  7121. // }else{
  7122. // //fapiao_code = "00001520"
  7123. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7124. // var zero string
  7125. // if fpNumber >= 1000{
  7126. // zero = "0000" + strconv.Itoa(fpNumber)
  7127. // }else if fpNumber >= 10000{
  7128. // zero = "000" + strconv.Itoa(fpNumber)
  7129. // } else if fpNumber >= 100000{
  7130. // zero = "00" + strconv.Itoa(fpNumber)
  7131. // } else if fpNumber >= 1000000{
  7132. // zero = "0" + strconv.Itoa(fpNumber)
  7133. // }else {
  7134. // zero = strconv.Itoa(fpNumber)
  7135. // }
  7136. // fapiao_number = zero
  7137. // }
  7138. // }
  7139. //}
  7140. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7141. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7142. var patientPrescription models.HisPrescriptionInfo
  7143. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7144. if patientPrescription.ID == 0 {
  7145. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7146. }
  7147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7148. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7149. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7150. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7151. var config []*models.HisXtDiagnoseConfig
  7152. for _, item := range diagnosis_ids {
  7153. id, _ := strconv.ParseInt(item, 10, 64)
  7154. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7155. config = append(config, &diagnosisConfig)
  7156. }
  7157. sickConfig, _ := service.FindSickById(sick_type)
  7158. //if tempOrder.ID == 0 {
  7159. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7160. //}
  7161. if tempOrder.ID == 0 {
  7162. var result string
  7163. var requestLog string
  7164. var res2 ResultSix
  7165. var ressix10265 ResultSix10265
  7166. if miConfig.MdtrtareaAdmvs == "421300" {
  7167. data := make(map[string]interface{})
  7168. client := &http.Client{}
  7169. data["psn_no"] = his.PsnNo
  7170. data["mdtrt_id"] = his.Number
  7171. data["opter"] = roles.UserName
  7172. data["org_name"] = miConfig.OrgName
  7173. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7174. data["doctor_id"] = doctor_info.DoctorNumber
  7175. data["doctor_name"] = doctor_info.UserName
  7176. data["department"] = department.Name
  7177. data["fixmedins_code"] = miConfig.Code
  7178. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7180. data["secret_key"] = miConfig.SecretKey
  7181. data["sick_code"] = sickConfig.CountryCode
  7182. data["sick_name"] = sickConfig.ClassName
  7183. data["dept"] = strconv.FormatInt(department.ID, 10)
  7184. data["config"] = config
  7185. data["begin_time"] = begin_time
  7186. bytesData, _ := json.Marshal(data)
  7187. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7188. resp, _ := client.Do(req)
  7189. defer resp.Body.Close()
  7190. body, ioErr := ioutil.ReadAll(resp.Body)
  7191. if ioErr != nil {
  7192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7194. return
  7195. }
  7196. var respJSON map[string]interface{}
  7197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7203. userJSONBytes, _ := json.Marshal(respJSON)
  7204. fmt.Println("log")
  7205. fmt.Println(string(userJSONBytes))
  7206. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7207. utils.ErrorLog("解析失败:%v", err)
  7208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7209. return
  7210. }
  7211. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7212. data := make(map[string]interface{})
  7213. client := &http.Client{}
  7214. data["psn_no"] = his.PsnNo
  7215. data["mdtrt_id"] = his.Number
  7216. data["doctor"] = roles.UserName
  7217. data["department"] = department.Name
  7218. data["org_name"] = miConfig.OrgName
  7219. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7220. data["doctor_id"] = doctor_info.DoctorNumber
  7221. data["new_doctor_name"] = doctor_info.UserName
  7222. data["fixmedins_code"] = miConfig.Code
  7223. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7224. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7225. data["secret_key"] = miConfig.SecretKey
  7226. data["sick_code"] = sickConfig.CountryCode
  7227. data["sick_name"] = sickConfig.ClassName
  7228. data["url"] = miConfig.Url
  7229. data["ak"] = miConfig.AccessKey
  7230. data["begin_time"] = begin_time
  7231. data["cainfo"] = miConfig.Cainfo
  7232. data["dept"] = strconv.FormatInt(department.ID, 10)
  7233. data["config"] = config
  7234. bytesData, _ := json.Marshal(data)
  7235. var req *http.Request
  7236. if miConfig.MdtrtareaAdmvs == "320921" {
  7237. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7238. //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 +
  7239. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7240. } else {
  7241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7242. }
  7243. resp, _ := client.Do(req)
  7244. defer resp.Body.Close()
  7245. body, ioErr := ioutil.ReadAll(resp.Body)
  7246. if ioErr != nil {
  7247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. var respJSON map[string]interface{}
  7252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7258. userJSONBytes, _ := json.Marshal(respJSON)
  7259. fmt.Println("log")
  7260. fmt.Println(string(userJSONBytes))
  7261. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7262. utils.ErrorLog("解析失败:%v", err)
  7263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7264. return
  7265. }
  7266. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7267. res2.Output = ressix10265.Output
  7268. res2.ErrMsg = ressix10265.ErrMsg
  7269. res2.Cainfo = ressix10265.Cainfo
  7270. res2.WarnMsg = ressix10265.WarnMsg
  7271. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7272. res2.Infcode = infocode
  7273. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7274. 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)
  7275. saveLog(result, requestLog, "2203", "上传就诊信息")
  7276. var respJSON2 map[string]interface{}
  7277. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7280. return
  7281. }
  7282. userJSONBytes2, _ := json.Marshal(respJSON2)
  7283. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7284. utils.ErrorLog("解析失败:%v", err)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return
  7287. }
  7288. } else {
  7289. if miConfig.MdtrtareaAdmvs == "440781" { //
  7290. 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)
  7291. } else {
  7292. if miConfig.Code == "H15049901371" {
  7293. //赤峰地区国家医保医疗类别
  7294. //职工透析:医疗类别选特殊情况门诊990502
  7295. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7296. var med_type string
  7297. if his.Insutype == "390" {
  7298. if reg_type == 14 {
  7299. med_type = "9933"
  7300. } else if reg_type == 11 {
  7301. med_type = "11"
  7302. }
  7303. } else if his.Insutype == "310" {
  7304. if reg_type == 14 {
  7305. med_type = "990502"
  7306. } else if reg_type == 11 {
  7307. med_type = "11"
  7308. }
  7309. }
  7310. 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)
  7311. } else {
  7312. 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)
  7313. }
  7314. }
  7315. saveLog(result, requestLog, "2203", "上传就诊信息")
  7316. var respJSON2 map[string]interface{}
  7317. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. return
  7321. }
  7322. userJSONBytes2, _ := json.Marshal(respJSON2)
  7323. if miConfig.Code == "H15049901371" {
  7324. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7325. utils.ErrorLog("解析失败:%v", err)
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. return
  7328. }
  7329. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7330. res2.Output = ressix10265.Output
  7331. res2.ErrMsg = ressix10265.ErrMsg
  7332. res2.Cainfo = ressix10265.Cainfo
  7333. res2.WarnMsg = ressix10265.WarnMsg
  7334. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7335. res2.Infcode = infocode
  7336. } else {
  7337. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7338. utils.ErrorLog("解析失败:%v", err)
  7339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. return
  7341. }
  7342. }
  7343. }
  7344. if res2.Infcode != 0 {
  7345. adminUser := c.GetAdminUserInfo()
  7346. errlog := &models.HisOrderError{
  7347. UserOrgId: adminUser.CurrentOrgId,
  7348. Ctime: time.Now().Unix(),
  7349. Mtime: time.Now().Unix(),
  7350. ErrMsg: res2.ErrMsg,
  7351. Status: 1,
  7352. PatientId: id,
  7353. RecordTime: recordDateTime,
  7354. Stage: 3,
  7355. }
  7356. service.CreateErrMsgLog(errlog)
  7357. c.ServeSuccessJSON(map[string]interface{}{
  7358. "failed_code": -10,
  7359. "msg": res2.ErrMsg,
  7360. })
  7361. return
  7362. } else {
  7363. his.Diagnosis = diagnosis_id
  7364. his.SickType = sickConfig.ID
  7365. //var p_type int64
  7366. //if reg_type == 1111 || reg_type == 1112 {
  7367. // p_type = 11
  7368. //
  7369. //}
  7370. his.PType = fmt.Sprintf("%d", reg_type)
  7371. service.UpdateHisPatientThree(&his)
  7372. data := make(map[string]interface{})
  7373. if settle_accounts_type == 1 { //日结
  7374. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7375. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7376. } else {
  7377. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7378. }
  7379. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7380. data["pre"] = prescriptions
  7381. } else { //月结
  7382. start_time_str := c.GetString("start_time")
  7383. end_time_str := c.GetString("end_time")
  7384. timeLayout := "2006-01-02"
  7385. loc, _ := time.LoadLocation("Local")
  7386. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7387. if err != nil {
  7388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7389. return
  7390. }
  7391. recordStartTime := theStartTime.Unix()
  7392. start_time = recordStartTime
  7393. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7394. if err != nil {
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7396. return
  7397. }
  7398. recordEndTime := theEndTime.Unix()
  7399. end_time = recordEndTime
  7400. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7401. data["pre"] = prescriptions
  7402. }
  7403. timestamp := time.Now().Unix()
  7404. tempTime := time.Unix(timestamp, 0)
  7405. timeFormat := tempTime.Format("20060102150405")
  7406. chrgBchno := rand.Intn(100000) + 10000
  7407. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7408. strconv.FormatInt(his.PatientId, 10)
  7409. client := &http.Client{}
  7410. data["psn_no"] = his.PsnNo
  7411. data["mdtrt_id"] = his.Number
  7412. data["chrg_bchno"] = chrg_bchno
  7413. data["org_name"] = miConfig.OrgName
  7414. data["doctor"] = doctor_info.UserName
  7415. data["doctor_id"] = doctor_info.DoctorNumber
  7416. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7417. data["fixmedins_code"] = miConfig.Code
  7418. data["opter"] = roles.UserName
  7419. data["dept_code"] = department.Number
  7420. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7422. data["secret_key"] = miConfig.SecretKey
  7423. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7424. data["url"] = miConfig.Url
  7425. data["ak"] = miConfig.AccessKey
  7426. data["new_doctor_name"] = patientPrescription.Doctor
  7427. data["diag_code"] = sickConfig.CountryCode
  7428. data["cainfo"] = miConfig.Cainfo
  7429. data["opter"] = roles.UserName
  7430. var ids []int64
  7431. for _, item := range prescriptions {
  7432. ids = append(ids, item.ID)
  7433. }
  7434. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7435. if config.IsOpen == 1 { //对接了医保,走医保流程
  7436. var res ResultFour
  7437. var resFour10265 ResultFour10265
  7438. if miConfig.MdtrtareaAdmvs == "421300" {
  7439. bytesData, _ := json.Marshal(data)
  7440. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7441. resp, _ := client.Do(req)
  7442. defer resp.Body.Close()
  7443. body, ioErr := ioutil.ReadAll(resp.Body)
  7444. if ioErr != nil {
  7445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. var respJSON map[string]interface{}
  7450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7453. return
  7454. }
  7455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7456. userJSONBytes, _ := json.Marshal(respJSON)
  7457. fmt.Println("log")
  7458. fmt.Println(string(userJSONBytes))
  7459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7460. utils.ErrorLog("解析失败:%v", err)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7465. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7466. if result3101.Infcode == "0" {
  7467. if len(result3101.Output.Result) > 0 {
  7468. var errMsgs []string
  7469. for _, item := range result3101.Output.Result {
  7470. errMsgs = append(errMsgs, item.VolaCont)
  7471. }
  7472. c.ServeSuccessJSON(map[string]interface{}{
  7473. "failed_code": -10,
  7474. "msg": errMsgs,
  7475. })
  7476. return
  7477. }
  7478. }
  7479. if miConfig.MdtrtareaAdmvs == "320921" {
  7480. data["doctor_id"] = "D320923012139"
  7481. } else {
  7482. data["doctor_id"] = "D371621008686"
  7483. }
  7484. bytesData, _ := json.Marshal(data)
  7485. var req *http.Request
  7486. if miConfig.MdtrtareaAdmvs == "320921" {
  7487. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7488. } else {
  7489. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7490. }
  7491. resp, _ := client.Do(req)
  7492. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  7507. fmt.Println("log")
  7508. fmt.Println(string(userJSONBytes))
  7509. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7510. utils.ErrorLog("解析失败:%v", err)
  7511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7512. return
  7513. }
  7514. res.InfRefmsgid = resFour10265.InfRefmsgid
  7515. res.Output = resFour10265.Output
  7516. res.ErrMsg = resFour10265.ErrMsg
  7517. res.Cainfo = resFour10265.Cainfo
  7518. res.WarnMsg = resFour10265.WarnMsg
  7519. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7520. res.Infcode = infocode
  7521. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7522. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  7523. var dat map[string]interface{}
  7524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7525. fmt.Println(dat)
  7526. } else {
  7527. fmt.Println(err)
  7528. }
  7529. saveLog(result, request_log, "2204", "上传费用明细")
  7530. userJSONBytes, _ := json.Marshal(dat)
  7531. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7532. utils.ErrorLog("解析失败:%v", err)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. res.InfRefmsgid = resFour10265.InfRefmsgid
  7537. res.Output = resFour10265.Output
  7538. res.ErrMsg = resFour10265.ErrMsg
  7539. res.Cainfo = resFour10265.Cainfo
  7540. res.WarnMsg = resFour10265.WarnMsg
  7541. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7542. res.Infcode = infocode
  7543. } else {
  7544. if miConfig.Code == "H15049901371" {
  7545. 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)
  7546. var dat map[string]interface{}
  7547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7548. fmt.Println(dat)
  7549. } else {
  7550. fmt.Println(err)
  7551. }
  7552. saveLog(result, request_log, "2204", "上传费用明细")
  7553. userJSONBytes, _ := json.Marshal(dat)
  7554. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7555. utils.ErrorLog("解析失败:%v", err)
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. res.InfRefmsgid = resFour10265.InfRefmsgid
  7560. res.Output = resFour10265.Output
  7561. res.ErrMsg = resFour10265.ErrMsg
  7562. res.Cainfo = resFour10265.Cainfo
  7563. res.WarnMsg = resFour10265.WarnMsg
  7564. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7565. res.Infcode = infocode
  7566. } else {
  7567. 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)
  7568. var dat map[string]interface{}
  7569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7570. fmt.Println(dat)
  7571. } else {
  7572. fmt.Println(err)
  7573. }
  7574. saveLog(result, request_log, "2204", "上传费用明细")
  7575. userJSONBytes, _ := json.Marshal(dat)
  7576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7577. utils.ErrorLog("解析失败:%v", err)
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. }
  7582. }
  7583. if res.Infcode == 0 {
  7584. order := &models.HisOrder{
  7585. UserOrgId: adminUser.CurrentOrgId,
  7586. HisPatientId: his.ID,
  7587. PatientId: his.PatientId,
  7588. SettleAccountsDate: recordDateTime,
  7589. MdtrtId: his.Number,
  7590. PsnNo: his.PsnNo,
  7591. MedType: strconv.FormatInt(reg_type, 10),
  7592. Ctime: time.Now().Unix(),
  7593. Mtime: time.Now().Unix(),
  7594. Status: 1,
  7595. Number: chrg_bchno,
  7596. Infcode: res.Infcode,
  7597. WarnMsg: res.WarnMsg,
  7598. Cainfo: res.Cainfo,
  7599. ErrMsg: res.ErrMsg,
  7600. RespondTime: res.RefmsgTime,
  7601. InfRefmsgid: res.InfRefmsgid,
  7602. OrderStatus: 1,
  7603. PayWay: pay_way,
  7604. PayPrice: pay_price,
  7605. PayCardNo: pay_card_no,
  7606. DiscountPrice: discount_price,
  7607. PreferentialPrice: preferential_price,
  7608. RealityPrice: reality_price,
  7609. FoundPrice: found_price,
  7610. MedicalInsurancePrice: medical_insurance_price,
  7611. PrivatePrice: private_price,
  7612. IsMedicineInsurance: 1,
  7613. SettleType: settle_accounts_type,
  7614. SettleStartTime: start_time,
  7615. SettleEndTime: end_time,
  7616. Creator: roles.AdminUserId,
  7617. Modify: roles.AdminUserId,
  7618. FaPiaoNumber: fapiao_number,
  7619. FaPiaoCode: fapiao_code,
  7620. PType: 2,
  7621. Diagnosis: diagnosis_id,
  7622. }
  7623. err = service.CreateOrder(order)
  7624. if err != nil {
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7626. return
  7627. }
  7628. for _, item := range res.Output.Result {
  7629. temp := strings.Split(item.FeedetlSn, "-")
  7630. var advice_id int64 = 0
  7631. var project_id int64 = 0
  7632. var types int64 = 0
  7633. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7634. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7635. if temp[1] == "1" {
  7636. advice_id = id
  7637. project_id = 0
  7638. } else if temp[1] == "2" {
  7639. advice_id = 0
  7640. project_id = id
  7641. }
  7642. if item.MedChrgitmType == "9" {
  7643. item.MedChrgitmType = "09"
  7644. }
  7645. info := &models.HisOrderInfo{
  7646. OrderNumber: order.Number,
  7647. FeedetlSn: item.FeedetlSn,
  7648. UploadDate: time.Now().Unix(),
  7649. AdviceId: advice_id,
  7650. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7651. Cnt: item.Cnt,
  7652. Pric: float64(item.Pric),
  7653. PatientId: his.PatientId,
  7654. PricUplmtAmt: item.PricUplmtAmt,
  7655. SelfpayProp: item.SelfpayProp,
  7656. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7657. OverlmtAmt: item.OverlmtAmt,
  7658. PreselfpayAmt: item.PreselfpayAmt,
  7659. BasMednFlag: item.BasMednFlag,
  7660. MedChrgitmType: item.MedChrgitmType,
  7661. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7662. Status: 1,
  7663. Memo: item.Memo,
  7664. Mtime: time.Now().Unix(),
  7665. InscpScpAmt: item.InscpScpAmt,
  7666. DrtReimFlag: item.DrtReimFlag,
  7667. Ctime: time.Now().Unix(),
  7668. ListSpItemFlag: item.ListSpItemFlag,
  7669. ChldMedcFlag: item.ChldMedcFlag,
  7670. LmtUsedFlag: item.LmtUsedFlag,
  7671. ChrgitmLv: item.ChrgitmLv,
  7672. UserOrgId: adminUser.CurrentOrgId,
  7673. HisPatientId: his.ID,
  7674. OrderId: order.ID,
  7675. ProjectId: project_id,
  7676. Type: types,
  7677. }
  7678. service.CreateOrderInfo(info)
  7679. }
  7680. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7681. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7682. var total float64
  7683. for _, item := range prescriptions {
  7684. if item.Type == 1 { //药品
  7685. for _, subItem := range item.HisDoctorAdviceInfo {
  7686. total = total + (subItem.Price * subItem.PrescribingNumber)
  7687. }
  7688. }
  7689. if item.Type == 2 { //项目
  7690. for _, subItem := range item.HisPrescriptionProject {
  7691. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7692. total = total + (subItem.Price * cnt)
  7693. }
  7694. }
  7695. }
  7696. for _, item := range prescriptions {
  7697. for _, subItem := range item.HisAdditionalCharge {
  7698. total = total + (subItem.Price * float64(subItem.Count))
  7699. }
  7700. }
  7701. var allTotal string
  7702. if adminUser.CurrentOrgId == 9919 {
  7703. allTotal = fmt.Sprintf("%.4f", total)
  7704. } else {
  7705. allTotal = fmt.Sprintf("%.4f", total)
  7706. }
  7707. if res.Infcode == 0 {
  7708. var rf []*ResultFive
  7709. json.Unmarshal([]byte(his.Iinfo), &rf)
  7710. chrg_bchno := chrg_bchno
  7711. cert_no := his.Certno
  7712. var insutypes []string
  7713. var insutype string
  7714. var is390 int = 0
  7715. var is310 int = 0
  7716. for _, item := range rf {
  7717. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7718. insutypes = append(insutypes, item.Insutype)
  7719. }
  7720. }
  7721. if len(insutypes) == 1 {
  7722. insutype = insutypes[0]
  7723. } else {
  7724. for _, i := range insutypes {
  7725. if i == "390" {
  7726. is390 = 1
  7727. }
  7728. if i == "310" {
  7729. is310 = 1
  7730. }
  7731. }
  7732. }
  7733. if is390 == 1 {
  7734. insutype = "390"
  7735. }
  7736. if is310 == 1 {
  7737. insutype = "310"
  7738. }
  7739. if len(insutypes) == 0 {
  7740. insutype = "310"
  7741. }
  7742. if len(insutypes) == 2 {
  7743. insutype = strconv.FormatInt(his.SocialType, 10)
  7744. }
  7745. insutype = strconv.FormatInt(his.SocialType, 10)
  7746. //insutype = "390"
  7747. if his.IdCardType == 1 {
  7748. // cert_no = his.MedicalInsuranceNumber
  7749. cert_no = his.Certno
  7750. } else {
  7751. cert_no = his.Certno
  7752. }
  7753. var res ResultSeven
  7754. var resSeven10265 ResultSeven10265
  7755. var src_resquest string
  7756. var result2 string
  7757. var acct_used_flag string
  7758. fmt.Println("pay_way")
  7759. fmt.Println(pay_way)
  7760. fmt.Println("pay_way")
  7761. if pay_way == 4 {
  7762. acct_used_flag = "1"
  7763. } else {
  7764. acct_used_flag = "0"
  7765. }
  7766. if miConfig.MdtrtareaAdmvs == "421300" {
  7767. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7768. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7769. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7770. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7771. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7772. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7773. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7774. resp, requestErr := http.Get(api)
  7775. if requestErr != nil {
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. body, ioErr := ioutil.ReadAll(resp.Body)
  7780. if ioErr != nil {
  7781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. return
  7784. }
  7785. var respJSON map[string]interface{}
  7786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7792. result, _ := json.Marshal(respJSON)
  7793. if miConfig.Code == "H15049901371" {
  7794. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7795. utils.ErrorLog("解析失败:%v", err)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7800. res.Output = resSeven10265.Output
  7801. res.ErrMsg = resSeven10265.ErrMsg
  7802. res.Cainfo = resSeven10265.Cainfo
  7803. res.WarnMsg = resSeven10265.WarnMsg
  7804. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7805. res.Infcode = infocode
  7806. } else {
  7807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7808. utils.ErrorLog("解析失败:%v", err)
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. }
  7813. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7814. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7815. if result3101.Infcode == "0" {
  7816. if len(result3101.Output.Result) > 0 {
  7817. var errMsgs []string
  7818. for _, item := range result3101.Output.Result {
  7819. errMsgs = append(errMsgs, item.VolaCont)
  7820. }
  7821. c.ServeSuccessJSON(map[string]interface{}{
  7822. "failed_code": -10,
  7823. "msg": errMsgs,
  7824. })
  7825. return
  7826. } else {
  7827. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7828. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7829. bas := strings.Split(psn_info.CardInfo, "|")
  7830. if his.IdCardType == 1 {
  7831. cert_no = bas[2]
  7832. } else if his.IdCardType == 3 {
  7833. cert_no = his.Certno
  7834. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7835. } else if his.IdCardType == 4 {
  7836. cert_no = his.Certno
  7837. psn_info.VerifyNumber = psn_info.VerifyNumber
  7838. }
  7839. var api string
  7840. if miConfig.MdtrtareaAdmvs == "320921" {
  7841. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7842. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7843. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7845. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7846. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7847. "&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
  7848. } else {
  7849. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7850. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7851. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7853. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7854. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7855. "&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
  7856. }
  7857. resp, requestErr := http.Get(api)
  7858. if requestErr != nil {
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. body, ioErr := ioutil.ReadAll(resp.Body)
  7863. if ioErr != nil {
  7864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. var respJSON map[string]interface{}
  7869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7875. result, _ := json.Marshal(respJSON)
  7876. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7877. utils.ErrorLog("解析失败:%v", err)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7882. res.Output = resSeven10265.Output
  7883. res.ErrMsg = resSeven10265.ErrMsg
  7884. res.Cainfo = resSeven10265.Cainfo
  7885. res.WarnMsg = resSeven10265.WarnMsg
  7886. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7887. res.Infcode = infocode
  7888. }
  7889. }
  7890. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7891. var cert_no string
  7892. if his.IdCardType == 4 {
  7893. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7894. cert_no = psn_info.VerifyNumber
  7895. 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)
  7896. } else if his.IdCardType == 1 {
  7897. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7898. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7899. 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)
  7900. }
  7901. //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)
  7902. var dat map[string]interface{}
  7903. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7904. fmt.Println(dat)
  7905. } else {
  7906. fmt.Println(err)
  7907. }
  7908. saveLog(result2, src_resquest, "2207", "结算")
  7909. userJSONBytes, _ := json.Marshal(dat)
  7910. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7911. utils.ErrorLog("解析失败:%v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7916. res.Output = resSeven10265.Output
  7917. res.ErrMsg = resSeven10265.ErrMsg
  7918. res.Cainfo = resSeven10265.Cainfo
  7919. res.WarnMsg = resSeven10265.WarnMsg
  7920. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7921. res.Infcode = infocode
  7922. } else {
  7923. if miConfig.Code == "H15049901371" {
  7924. //赤峰地区国家医保医疗类别
  7925. //职工透析:医疗类别选特殊情况门诊990502
  7926. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7927. var med_type string
  7928. if his.Insutype == "390" {
  7929. if reg_type == 14 {
  7930. med_type = "9933"
  7931. } else if reg_type == 11 {
  7932. med_type = "11"
  7933. }
  7934. } else if his.Insutype == "310" {
  7935. if reg_type == 14 {
  7936. med_type = "990502"
  7937. } else if reg_type == 11 {
  7938. med_type = "11"
  7939. }
  7940. }
  7941. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "")
  7942. } else {
  7943. if his.IdCardType == 4 {
  7944. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7945. var token string
  7946. token = psn_info.VerifyNumber
  7947. 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)
  7948. } else {
  7949. 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, "")
  7950. }
  7951. }
  7952. //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)
  7953. var dat map[string]interface{}
  7954. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7955. fmt.Println(dat)
  7956. } else {
  7957. fmt.Println(err)
  7958. }
  7959. saveLog(result2, src_resquest, "2207", "结算")
  7960. userJSONBytes, _ := json.Marshal(dat)
  7961. if miConfig.Code == "H15049901371" {
  7962. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7963. utils.ErrorLog("解析失败:%v", err)
  7964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. return
  7966. }
  7967. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7968. res.Output = resSeven10265.Output
  7969. res.ErrMsg = resSeven10265.ErrMsg
  7970. res.Cainfo = resSeven10265.Cainfo
  7971. res.WarnMsg = resSeven10265.WarnMsg
  7972. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7973. res.Infcode = infocode
  7974. } else {
  7975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7976. utils.ErrorLog("解析失败:%v", err)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. }
  7981. }
  7982. if res.Infcode != 0 {
  7983. errlog := &models.HisOrderError{
  7984. UserOrgId: adminUser.CurrentOrgId,
  7985. Ctime: time.Now().Unix(),
  7986. Mtime: time.Now().Unix(),
  7987. Number: chrg_bchno,
  7988. ErrMsg: res.ErrMsg,
  7989. Status: 1,
  7990. PatientId: id,
  7991. RecordTime: recordDateTime,
  7992. Stage: 6,
  7993. }
  7994. service.CreateErrMsgLog(errlog)
  7995. c.ServeSuccessJSON(map[string]interface{}{
  7996. "failed_code": -10,
  7997. "msg": res.ErrMsg,
  7998. })
  7999. return
  8000. } else {
  8001. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8002. order.OrderStatus = 2
  8003. order.Status = 1
  8004. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8005. order.SetlId = res.Output.Setlinfo.SetlID
  8006. order.PsnNo = res.Output.Setlinfo.PsnNo
  8007. order.PsnName = res.Output.Setlinfo.PsnName
  8008. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8009. order.Certno = res.Output.Setlinfo.Certno
  8010. order.Gend = res.Output.Setlinfo.Gend
  8011. order.Naty = res.Output.Setlinfo.Naty
  8012. order.Age = res.Output.Setlinfo.Age
  8013. order.Insutype = res.Output.Setlinfo.Insutype
  8014. order.PsnType = res.Output.Setlinfo.PsnType
  8015. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8016. order.SetlTime = res.Output.Setlinfo.SetlTime
  8017. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8018. if res.Output.Setlinfo.MedType == "140101" {
  8019. order.MedType = "14"
  8020. } else {
  8021. order.MedType = res.Output.Setlinfo.MedType
  8022. }
  8023. if reg_type == 1112 {
  8024. order.MedType = "1112"
  8025. }
  8026. if reg_type == 1111 {
  8027. order.MedType = "1111"
  8028. }
  8029. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8030. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8031. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8032. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8033. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8034. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8035. order.HifpPay = res.Output.Setlinfo.HifpPay
  8036. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8037. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8038. order.HifesPay = res.Output.Setlinfo.HifesPay
  8039. order.HifobPay = res.Output.Setlinfo.HifobPay
  8040. order.MafPay = res.Output.Setlinfo.MafPay
  8041. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8042. order.OthPay = res.Output.Setlinfo.OthPay
  8043. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8044. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8045. order.AcctPay = res.Output.Setlinfo.AcctPay
  8046. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8047. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8048. order.Balc = res.Output.Setlinfo.Balc
  8049. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8050. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8051. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8052. order.ClrType = res.Output.Setlinfo.ClrType
  8053. order.ClrWay = res.Output.Setlinfo.ClrWay
  8054. order.Creator = order.Creator
  8055. order.Modify = roles.AdminUserId
  8056. order.RequestLog = src_resquest
  8057. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8058. detailStr := string(setlDetail)
  8059. order.SetlDetail = detailStr
  8060. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8061. err = service.UpDateOrder(order)
  8062. if err == nil {
  8063. //判断是否使用了押金
  8064. if dec_way == "true" {
  8065. tmpstring := strconv.FormatInt(order.ID, 10)
  8066. order.Decimal = decimal
  8067. service.UpDateOrder(order)
  8068. //扣押金
  8069. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8070. if errmsg != nil {
  8071. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8072. return
  8073. }
  8074. }
  8075. c.ServeSuccessJSON(map[string]interface{}{
  8076. "msg": "结算成功",
  8077. })
  8078. } else {
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8080. return
  8081. }
  8082. }
  8083. } else {
  8084. adminUser := c.GetAdminUserInfo()
  8085. errlog := &models.HisOrderError{
  8086. UserOrgId: adminUser.CurrentOrgId,
  8087. Ctime: time.Now().Unix(),
  8088. Mtime: time.Now().Unix(),
  8089. ErrMsg: res.ErrMsg,
  8090. Status: 1,
  8091. PatientId: id,
  8092. RecordTime: recordDateTime,
  8093. Stage: 4,
  8094. }
  8095. service.CreateErrMsgLog(errlog)
  8096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8097. return
  8098. }
  8099. } else {
  8100. adminUser := c.GetAdminUserInfo()
  8101. errlog := &models.HisOrderError{
  8102. UserOrgId: adminUser.CurrentOrgId,
  8103. Ctime: time.Now().Unix(),
  8104. Mtime: time.Now().Unix(),
  8105. ErrMsg: res.ErrMsg,
  8106. Status: 1,
  8107. PatientId: id,
  8108. RecordTime: recordDateTime,
  8109. Stage: 4,
  8110. }
  8111. service.CreateErrMsgLog(errlog)
  8112. c.ServeSuccessJSON(map[string]interface{}{
  8113. "failed_code": -10,
  8114. "msg": res.ErrMsg,
  8115. })
  8116. return
  8117. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8118. //return
  8119. }
  8120. }
  8121. }
  8122. } else if tempOrder.ID > 0 {
  8123. if tempOrder.IsPre == 1 {
  8124. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8125. var rf []*ResultFive
  8126. json.Unmarshal([]byte(his.Iinfo), &rf)
  8127. chrg_bchno := tempOrder.Number
  8128. cert_no := his.Certno
  8129. var insutypes []string
  8130. var insutype string
  8131. var is390 int = 0
  8132. var is310 int = 0
  8133. for _, item := range rf {
  8134. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8135. insutypes = append(insutypes, item.Insutype)
  8136. }
  8137. }
  8138. if len(insutypes) == 1 {
  8139. insutype = insutypes[0]
  8140. } else {
  8141. for _, i := range insutypes {
  8142. if i == "390" {
  8143. is390 = 1
  8144. }
  8145. if i == "310" {
  8146. is310 = 1
  8147. }
  8148. }
  8149. }
  8150. if is390 == 1 {
  8151. insutype = "390"
  8152. }
  8153. if is310 == 1 {
  8154. insutype = "310"
  8155. }
  8156. if len(insutypes) == 0 {
  8157. insutype = "310"
  8158. }
  8159. if len(insutypes) == 2 {
  8160. insutype = strconv.FormatInt(his.SocialType, 64)
  8161. }
  8162. //insutype = "390"
  8163. if his.IdCardType == 1 {
  8164. // cert_no = his.MedicalInsuranceNumber
  8165. cert_no = his.Certno
  8166. } else {
  8167. cert_no = his.Certno
  8168. }
  8169. var res ResultSeven
  8170. var resSeven10265 ResultSeven10265
  8171. var src_resquest string
  8172. var result2 string
  8173. var acct_used_flag string
  8174. fmt.Println("pay_way")
  8175. fmt.Println(pay_way)
  8176. fmt.Println("pay_way")
  8177. if pay_way == 4 {
  8178. acct_used_flag = "1"
  8179. } else {
  8180. acct_used_flag = "0"
  8181. }
  8182. if miConfig.MdtrtareaAdmvs == "421300" {
  8183. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8184. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8185. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8187. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8188. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8189. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8190. resp, requestErr := http.Get(api)
  8191. if requestErr != nil {
  8192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8193. return
  8194. }
  8195. body, ioErr := ioutil.ReadAll(resp.Body)
  8196. if ioErr != nil {
  8197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. var respJSON map[string]interface{}
  8202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8208. result, _ := json.Marshal(respJSON)
  8209. fmt.Println("log")
  8210. fmt.Println(string(result))
  8211. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8212. utils.ErrorLog("解析失败:%v", err)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8217. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8218. if result3101.Infcode == "0" {
  8219. if len(result3101.Output.Result) > 0 {
  8220. var errMsgs []string
  8221. for _, item := range result3101.Output.Result {
  8222. errMsgs = append(errMsgs, item.VolaCont)
  8223. }
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "failed_code": -10,
  8226. "msg": errMsgs,
  8227. })
  8228. return
  8229. } else {
  8230. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8231. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8232. bas := strings.Split(psn_info.CardInfo, "|")
  8233. if his.IdCardType == 1 {
  8234. cert_no = bas[2]
  8235. } else if his.IdCardType == 3 {
  8236. cert_no = his.Certno
  8237. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8238. } else if his.IdCardType == 4 {
  8239. cert_no = his.Certno
  8240. psn_info.VerifyNumber = psn_info.VerifyNumber
  8241. }
  8242. //江苏地区国家医保医疗类别
  8243. //职工透析:医疗类别选特殊情况门诊9933
  8244. //居民血透门慢: 医疗类别选门诊慢病1402
  8245. //var med_type string
  8246. //if his.Insutype == "310" {
  8247. // if reg_type == 14 {
  8248. // med_type = "9933"
  8249. // } else if reg_type == 11 {
  8250. // med_type = "11"
  8251. //
  8252. // }
  8253. //} else if his.Insutype == "390" {
  8254. // if reg_type == 14 {
  8255. // med_type = "1402"
  8256. // } else if reg_type == 11 {
  8257. // med_type = "11"
  8258. // }
  8259. //}
  8260. var api string
  8261. if miConfig.MdtrtareaAdmvs == "320921" {
  8262. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8263. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8264. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8265. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8266. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8267. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8268. "&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
  8269. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8270. } else {
  8271. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8272. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8273. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8274. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8275. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8276. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8277. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8278. "&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
  8279. }
  8280. resp, requestErr := http.Get(api)
  8281. if requestErr != nil {
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8283. return
  8284. }
  8285. body, ioErr := ioutil.ReadAll(resp.Body)
  8286. if ioErr != nil {
  8287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. var respJSON map[string]interface{}
  8292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8295. return
  8296. }
  8297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8298. result, _ := json.Marshal(respJSON)
  8299. fmt.Println("log")
  8300. fmt.Println(string(result))
  8301. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8302. utils.ErrorLog("解析失败:%v", err)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8307. res.Output = resSeven10265.Output
  8308. res.ErrMsg = resSeven10265.ErrMsg
  8309. res.Cainfo = resSeven10265.Cainfo
  8310. res.WarnMsg = resSeven10265.WarnMsg
  8311. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8312. res.Infcode = infocode
  8313. }
  8314. }
  8315. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8316. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8317. var cert_no string
  8318. if his.IdCardType == 1 {
  8319. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8320. } else {
  8321. cert_no = psn_info.VerifyNumber
  8322. }
  8323. 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)
  8324. var dat map[string]interface{}
  8325. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8326. fmt.Println(dat)
  8327. } else {
  8328. fmt.Println(err)
  8329. }
  8330. saveLog(result2, src_resquest, "2207", "结算")
  8331. userJSONBytes, _ := json.Marshal(dat)
  8332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8333. utils.ErrorLog("解析失败:%v", err)
  8334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8335. return
  8336. }
  8337. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8338. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8339. var cert_no string
  8340. if his.IdCardType == 1 {
  8341. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8342. } else if his.IdCardType == 2 {
  8343. cert_no = his.IdCardNo
  8344. } else {
  8345. cert_no = psn_info.VerifyNumber
  8346. }
  8347. 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, "")
  8348. var dat map[string]interface{}
  8349. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8350. fmt.Println(dat)
  8351. } else {
  8352. fmt.Println(err)
  8353. }
  8354. saveLog(result2, src_resquest, "2207", "结算")
  8355. userJSONBytes, _ := json.Marshal(dat)
  8356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8357. utils.ErrorLog("解析失败:%v", err)
  8358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8359. return
  8360. }
  8361. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8362. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8363. var cert_no string
  8364. if his.IdCardType == 1 {
  8365. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8366. } else if his.IdCardType == 2 {
  8367. cert_no = his.IdCardNo
  8368. } else {
  8369. cert_no = psn_info.VerifyNumber
  8370. }
  8371. 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, "")
  8372. var dat map[string]interface{}
  8373. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8374. fmt.Println(dat)
  8375. } else {
  8376. fmt.Println(err)
  8377. }
  8378. saveLog(result2, src_resquest, "2207", "结算")
  8379. userJSONBytes, _ := json.Marshal(dat)
  8380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8381. utils.ErrorLog("解析失败:%v", err)
  8382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8383. return
  8384. }
  8385. } else {
  8386. var src_resquest string
  8387. if miConfig.Code == "H15049901371" {
  8388. //赤峰地区国家医保医疗类别
  8389. //职工透析:医疗类别选特殊情况门诊990502
  8390. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8391. var med_type string
  8392. if his.Insutype == "390" {
  8393. if reg_type == 14 {
  8394. med_type = "9933"
  8395. } else if reg_type == 11 {
  8396. med_type = "11"
  8397. }
  8398. } else if his.Insutype == "310" {
  8399. if reg_type == 14 {
  8400. med_type = "990502"
  8401. } else if reg_type == 11 {
  8402. med_type = "11"
  8403. }
  8404. }
  8405. 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, "")
  8406. } else {
  8407. if his.IdCardType == 4 {
  8408. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8409. token := psn_info.VerifyNumber
  8410. 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)
  8411. } else {
  8412. 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, "")
  8413. }
  8414. }
  8415. var dat map[string]interface{}
  8416. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8417. fmt.Println(dat)
  8418. } else {
  8419. fmt.Println(err)
  8420. }
  8421. saveLog(result2, src_resquest, "2207", "结算")
  8422. userJSONBytes, _ := json.Marshal(dat)
  8423. if miConfig.Code == "H15049901371" {
  8424. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8425. utils.ErrorLog("解析失败:%v", err)
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. return
  8428. }
  8429. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8430. res.Output = resSeven10265.Output
  8431. res.ErrMsg = resSeven10265.ErrMsg
  8432. res.Cainfo = resSeven10265.Cainfo
  8433. res.WarnMsg = resSeven10265.WarnMsg
  8434. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8435. res.Infcode = infocode
  8436. } else {
  8437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8438. utils.ErrorLog("解析失败:%v", err)
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8440. return
  8441. }
  8442. }
  8443. }
  8444. if res.Infcode != 0 {
  8445. errlog := &models.HisOrderError{
  8446. UserOrgId: adminUser.CurrentOrgId,
  8447. Ctime: time.Now().Unix(),
  8448. Mtime: time.Now().Unix(),
  8449. Number: chrg_bchno,
  8450. ErrMsg: res.ErrMsg,
  8451. Status: 1,
  8452. PatientId: id,
  8453. RecordTime: recordDateTime,
  8454. Stage: 6,
  8455. }
  8456. service.CreateErrMsgLog(errlog)
  8457. c.ServeSuccessJSON(map[string]interface{}{
  8458. "failed_code": -10,
  8459. "msg": res.ErrMsg,
  8460. })
  8461. return
  8462. } else {
  8463. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8464. order.OrderStatus = 2
  8465. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8466. order.SetlId = res.Output.Setlinfo.SetlID
  8467. order.PsnNo = res.Output.Setlinfo.PsnNo
  8468. order.PsnName = res.Output.Setlinfo.PsnName
  8469. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8470. order.Certno = res.Output.Setlinfo.Certno
  8471. order.Gend = res.Output.Setlinfo.Gend
  8472. order.Naty = res.Output.Setlinfo.Naty
  8473. order.Age = res.Output.Setlinfo.Age
  8474. order.Insutype = res.Output.Setlinfo.Insutype
  8475. order.PsnType = res.Output.Setlinfo.PsnType
  8476. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8477. order.SetlTime = res.Output.Setlinfo.SetlTime
  8478. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8479. //order.MedType = res.Output.Setlinfo.MedType
  8480. if reg_type == 1112 {
  8481. order.MedType = "1112"
  8482. }
  8483. if reg_type == 1111 {
  8484. order.MedType = "1111"
  8485. }
  8486. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8487. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8488. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8489. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8490. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8491. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8492. order.HifpPay = res.Output.Setlinfo.HifpPay
  8493. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8494. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8495. order.HifesPay = res.Output.Setlinfo.HifesPay
  8496. order.HifobPay = res.Output.Setlinfo.HifobPay
  8497. order.MafPay = res.Output.Setlinfo.MafPay
  8498. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8499. order.OthPay = res.Output.Setlinfo.OthPay
  8500. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8501. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8502. order.AcctPay = res.Output.Setlinfo.AcctPay
  8503. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8504. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8505. order.Balc = res.Output.Setlinfo.Balc
  8506. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8507. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8508. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8509. order.ClrWay = res.Output.Setlinfo.ClrWay
  8510. order.Creator = order.Creator
  8511. order.Modify = roles.AdminUserId
  8512. order.RequestLog = src_resquest
  8513. order.Diagnosis = diagnosis_id
  8514. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8515. detailStr := string(setlDetail)
  8516. order.SetlDetail = detailStr
  8517. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8518. err = service.UpDateOrder(order)
  8519. if err == nil {
  8520. //判断是否使用了押金
  8521. if dec_way == "true" {
  8522. tmpstring := strconv.FormatInt(order.ID, 10)
  8523. //扣押金
  8524. order.Decimal = decimal
  8525. service.UpDateOrder(order)
  8526. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8527. if errmsg != nil {
  8528. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8529. return
  8530. }
  8531. }
  8532. c.ServeSuccessJSON(map[string]interface{}{
  8533. "msg": "结算成功",
  8534. })
  8535. } else {
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8537. return
  8538. }
  8539. }
  8540. }
  8541. }
  8542. }
  8543. //func (c *HisApiController) GetPreUploadInfo() {
  8544. // id, _ := c.GetInt64("id")
  8545. // record_time := c.GetString("record_time")
  8546. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8547. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8548. //
  8549. // timeLayout := "2006-01-02"
  8550. // loc, _ := time.LoadLocation("Local")
  8551. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8552. // if err != nil {
  8553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8554. // return
  8555. // }
  8556. // recordDateTime := theTime.Unix()
  8557. // adminUser := c.GetAdminUserInfo()
  8558. //
  8559. // var prescriptions []*models.HisPrescription
  8560. //
  8561. // var start_time int64
  8562. // var end_time int64
  8563. //
  8564. // data := make(map[string]interface{})
  8565. // if settle_accounts_type == 1 { //日结
  8566. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8567. // data["pre"] = prescriptions
  8568. //
  8569. // } else { //月结
  8570. // start_time_str := c.GetString("start_time")
  8571. // end_time_str := c.GetString("end_time")
  8572. // timeLayout := "2006-01-02"
  8573. // loc, _ := time.LoadLocation("Local")
  8574. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8575. // if err != nil {
  8576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8577. // return
  8578. // }
  8579. // recordStartTime := theStartTime.Unix()
  8580. // start_time = recordStartTime
  8581. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8582. // if err != nil {
  8583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8584. // return
  8585. // }
  8586. // recordEndTime := theEndTime.Unix()
  8587. // end_time = recordEndTime
  8588. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8589. // data["pre"] = prescriptions
  8590. //
  8591. // }
  8592. //
  8593. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8594. //
  8595. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8596. // timestamp := time.Now().Unix()
  8597. // tempTime := time.Unix(timestamp, 0)
  8598. // timeFormat := tempTime.Format("20060102150405")
  8599. // chrgBchno := rand.Intn(100000) + 10000
  8600. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8601. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8602. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8603. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8604. // strconv.FormatInt(his.PatientId, 10)
  8605. // client := &http.Client{}
  8606. // data["psn_no"] = his.PsnNo
  8607. // data["mdtrt_id"] = his.Number
  8608. // data["chrg_bchno"] = chrg_bchno
  8609. // data["org_name"] = miConfig.OrgName
  8610. // data["doctor"] = roles.UserName
  8611. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8612. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8613. // data["fixmedins_code"] = miConfig.Code
  8614. // data["dept_code"] = department.Number
  8615. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8616. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8617. // data["secret_key"] = miConfig.SecretKey
  8618. // var ids []int64
  8619. //
  8620. // for _, item := range prescriptions {
  8621. // ids = append(ids, item.ID)
  8622. // }
  8623. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8624. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8625. // bytesData, _ := json.Marshal(data)
  8626. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8627. // resp, _ := client.Do(req)
  8628. // defer resp.Body.Close()
  8629. // body, ioErr := ioutil.ReadAll(resp.Body)
  8630. // if ioErr != nil {
  8631. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. // return
  8634. // }
  8635. // var respJSON map[string]interface{}
  8636. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8637. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. // return
  8640. // }
  8641. //
  8642. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8643. // userJSONBytes, _ := json.Marshal(respJSON)
  8644. // var res ResultFour
  8645. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8646. // utils.ErrorLog("解析失败:%v", err)
  8647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8648. // return
  8649. // }
  8650. //
  8651. // if res.Infcode == 0 {
  8652. // order := &models.HisOrder{
  8653. // UserOrgId: adminUser.CurrentOrgId,
  8654. // HisPatientId: his.ID,
  8655. // PatientId: his.PatientId,
  8656. // SettleAccountsDate: recordDateTime,
  8657. // Ctime: time.Now().Unix(),
  8658. // Mtime: time.Now().Unix(),
  8659. // Status: 1,
  8660. // Number: chrg_bchno,
  8661. // Infcode: res.Infcode,
  8662. // WarnMsg: res.WarnMsg,
  8663. // Cainfo: res.Cainfo,
  8664. // ErrMsg: res.ErrMsg,
  8665. // RespondTime: res.RefmsgTime,
  8666. // InfRefmsgid: res.InfRefmsgid,
  8667. // OrderStatus: 1,
  8668. // IsMedicineInsurance: 1,
  8669. // SettleType: settle_accounts_type,
  8670. // SettleStartTime: start_time,
  8671. // SettleEndTime: end_time,
  8672. // Creator: roles.ID,
  8673. // Modify: roles.ID,
  8674. // PType: 2,
  8675. // }
  8676. // err = service.CreateOrder(order)
  8677. // if err != nil {
  8678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8679. // return
  8680. // }
  8681. //
  8682. // for _, item := range res.Output.Result {
  8683. // temp := strings.Split(item.FeedetlSn, "-")
  8684. // var advice_id int64 = 0
  8685. // var project_id int64 = 0
  8686. // var types int64 = 0
  8687. //
  8688. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8689. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8690. //
  8691. // if temp[1] == "1" {
  8692. // advice_id = id
  8693. // project_id = 0
  8694. // } else if temp[1] == "2" {
  8695. // advice_id = 0
  8696. // project_id = id
  8697. // }
  8698. //
  8699. // info := &models.HisOrderInfo{
  8700. // OrderNumber: order.Number,
  8701. // FeedetlSn: item.FeedetlSn,
  8702. // UploadDate: time.Now().Unix(),
  8703. // AdviceId: advice_id,
  8704. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8705. // Cnt: item.Cnt,
  8706. // Pric: float64(item.Pric),
  8707. // PatientId: his.PatientId,
  8708. // PricUplmtAmt: item.PricUplmtAmt,
  8709. // SelfpayProp: item.SelfpayProp,
  8710. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8711. // OverlmtAmt: item.OverlmtAmt,
  8712. // PreselfpayAmt: item.PreselfpayAmt,
  8713. // BasMednFlag: item.BasMednFlag,
  8714. // MedChrgitmType: item.MedChrgitmType,
  8715. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8716. // Status: 1,
  8717. // Memo: item.Memo,
  8718. // Mtime: time.Now().Unix(),
  8719. // InscpScpAmt: item.InscpScpAmt,
  8720. // DrtReimFlag: item.DrtReimFlag,
  8721. // Ctime: time.Now().Unix(),
  8722. // ListSpItemFlag: item.ListSpItemFlag,
  8723. // ChldMedcFlag: item.ChldMedcFlag,
  8724. // LmtUsedFlag: item.LmtUsedFlag,
  8725. // ChrgitmLv: item.ChrgitmLv,
  8726. // UserOrgId: adminUser.CurrentOrgId,
  8727. // HisPatientId: his.ID,
  8728. // OrderId: order.ID,
  8729. // ProjectId: project_id,
  8730. // Type: types,
  8731. // }
  8732. // service.CreateOrderInfo(info)
  8733. //
  8734. // }
  8735. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8736. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8737. //
  8738. // var total float64
  8739. // for _, item := range prescriptions {
  8740. // if item.Type == 1 { //药品
  8741. // for _, subItem := range item.HisDoctorAdviceInfo {
  8742. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8743. // }
  8744. // }
  8745. // if item.Type == 2 { //项目
  8746. // for _, subItem := range item.HisPrescriptionProject {
  8747. // total = total + (subItem.Price * float64(subItem.Count))
  8748. // }
  8749. // }
  8750. // }
  8751. //
  8752. // for _, item := range prescriptions {
  8753. // for _, subItem := range item.HisAdditionalCharge {
  8754. // total = total + (subItem.Price * float64(subItem.Count))
  8755. // }
  8756. // }
  8757. //
  8758. // allTotal := fmt.Sprintf("%.2f", total)
  8759. // if res.Infcode == 0 {
  8760. // var rf []*ResultFive
  8761. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8762. // psn_no := his.PsnNo
  8763. // mdtrt_id := his.Number
  8764. // chrg_bchno := chrg_bchno
  8765. // cert_no := his.Certno
  8766. // insutype := rf[0].Insutype
  8767. //
  8768. // if his.IdCardType == 1 {
  8769. // cert_no = his.MedicalInsuranceNumber
  8770. //
  8771. // } else {
  8772. //
  8773. // cert_no = his.Certno
  8774. //
  8775. // }
  8776. //
  8777. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8778. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8779. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8780. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8781. // resp, requestErr := http.Get(api)
  8782. // if requestErr != nil {
  8783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8784. // return
  8785. // }
  8786. // defer resp.Body.Close()
  8787. // body, ioErr := ioutil.ReadAll(resp.Body)
  8788. // if ioErr != nil {
  8789. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. // return
  8792. // }
  8793. // var respJSON map[string]interface{}
  8794. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8795. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8797. // return
  8798. // }
  8799. // fmt.Println(respJSON)
  8800. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8801. // userJSONBytes, _ := json.Marshal(respJSON)
  8802. // var res ResultSeven
  8803. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8804. // utils.ErrorLog("解析失败:%v", err)
  8805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8806. // return
  8807. // }
  8808. // if res.Infcode != 0 {
  8809. // errlog := &models.HisOrderError{
  8810. // UserOrgId: adminUser.CurrentOrgId,
  8811. // Ctime: time.Now().Unix(),
  8812. // Mtime: time.Now().Unix(),
  8813. // Number: chrg_bchno,
  8814. // ErrMsg: res.ErrMsg,
  8815. // Status: 1,
  8816. // PatientId: id,
  8817. // RecordTime: recordDateTime,
  8818. // Stage: 7,
  8819. // }
  8820. // service.CreateErrMsgLog(errlog)
  8821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8822. // return
  8823. // } else {
  8824. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8825. // order.OrderStatus = 1
  8826. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8827. // order.SetlId = res.Output.Setlinfo.SetlID
  8828. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8829. // order.PsnName = res.Output.Setlinfo.PsnName
  8830. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8831. // order.Certno = res.Output.Setlinfo.Certno
  8832. // order.Gend = res.Output.Setlinfo.Gend
  8833. // order.Naty = res.Output.Setlinfo.Naty
  8834. // order.Age = res.Output.Setlinfo.Age
  8835. // order.Insutype = res.Output.Setlinfo.Insutype
  8836. // order.PsnType = res.Output.Setlinfo.PsnType
  8837. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8838. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8839. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8840. // order.MedType = res.Output.Setlinfo.MedType
  8841. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8842. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8843. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8844. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8845. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8846. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8847. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8848. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8849. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8850. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8851. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8852. // order.MafPay = res.Output.Setlinfo.MafPay
  8853. // order.OthPay = res.Output.Setlinfo.OthPay
  8854. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8855. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8856. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8857. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8858. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8859. // order.Balc = res.Output.Setlinfo.Balc
  8860. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8861. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8862. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8863. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8864. // order.Creator = order.Creator
  8865. // order.Modify = roles.ID
  8866. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8867. // detailStr := string(setlDetail)
  8868. // order.SetlDetail = detailStr
  8869. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8870. // err = service.UpDateOrder(order)
  8871. // if err == nil {
  8872. // c.ServeSuccessJSON(map[string]interface{}{
  8873. // "msg": "预结算成功",
  8874. // })
  8875. // } else {
  8876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8877. // return
  8878. // }
  8879. // }
  8880. // } else {
  8881. // adminUser := c.GetAdminUserInfo()
  8882. // errlog := &models.HisOrderError{
  8883. // UserOrgId: adminUser.CurrentOrgId,
  8884. // Ctime: time.Now().Unix(),
  8885. // Mtime: time.Now().Unix(),
  8886. // ErrMsg: res.ErrMsg,
  8887. // Status: 1,
  8888. // PatientId: id,
  8889. // RecordTime: recordDateTime,
  8890. // Stage: 4,
  8891. // }
  8892. // service.CreateErrMsgLog(errlog)
  8893. //
  8894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8895. // return
  8896. // }
  8897. // } else {
  8898. // adminUser := c.GetAdminUserInfo()
  8899. // errlog := &models.HisOrderError{
  8900. // UserOrgId: adminUser.CurrentOrgId,
  8901. // Ctime: time.Now().Unix(),
  8902. // Mtime: time.Now().Unix(),
  8903. // ErrMsg: res.ErrMsg,
  8904. // Status: 1,
  8905. // PatientId: id,
  8906. // RecordTime: recordDateTime,
  8907. // Stage: 4,
  8908. // }
  8909. // service.CreateErrMsgLog(errlog)
  8910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8911. // return
  8912. // }
  8913. //
  8914. // } else {
  8915. // var total float64
  8916. // for _, item := range prescriptions {
  8917. // if item.Type == 1 { //药品
  8918. // for _, subItem := range item.HisDoctorAdviceInfo {
  8919. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8920. // }
  8921. // }
  8922. // if item.Type == 2 { //项目
  8923. // for _, subItem := range item.HisPrescriptionProject {
  8924. // total = total + (subItem.Price * float64(subItem.Count))
  8925. // }
  8926. // }
  8927. //
  8928. // for _, subItem := range item.HisAdditionalCharge {
  8929. // total = total + (subItem.Price * float64(subItem.Count))
  8930. // }
  8931. // }
  8932. //
  8933. // allTotal := fmt.Sprintf("%.2f", total)
  8934. // totals, _ := strconv.ParseFloat(allTotal, 64)
  8935. // order := &models.HisOrder{
  8936. // UserOrgId: adminUser.CurrentOrgId,
  8937. // HisPatientId: his.ID,
  8938. // PatientId: id,
  8939. // SettleAccountsDate: recordDateTime,
  8940. // Ctime: time.Now().Unix(),
  8941. // Mtime: time.Now().Unix(),
  8942. // Status: 1,
  8943. // OrderStatus: 2,
  8944. // Number: chrg_bchno,
  8945. // MedfeeSumamt: totals,
  8946. // }
  8947. // err = service.CreateOrder(order)
  8948. // if err != nil {
  8949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8950. // return
  8951. // }
  8952. //
  8953. // var customs []*Custom
  8954. // for _, item := range prescriptions {
  8955. //
  8956. // if item.Type == 1 { //药品
  8957. // for _, subItem := range item.HisDoctorAdviceInfo {
  8958. // cus := &Custom{
  8959. // AdviceId: subItem.ID,
  8960. // ProjectId: 0,
  8961. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  8962. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  8963. // FeedetlSn: subItem.FeedetlSn,
  8964. // Price: fmt.Sprintf("%.2f", subItem.Price),
  8965. // MedListCodg: subItem.MedListCodg,
  8966. // Type: 1,
  8967. // }
  8968. // customs = append(customs, cus)
  8969. // }
  8970. // }
  8971. //
  8972. // if item.Type == 2 { //项目
  8973. // for _, subItem := range item.HisPrescriptionProject {
  8974. //
  8975. // cus := &Custom{
  8976. // AdviceId: 0,
  8977. // ProjectId: subItem.ID,
  8978. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  8979. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  8980. // FeedetlSn: subItem.FeedetlSn,
  8981. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  8982. // MedListCodg: subItem.MedListCodg,
  8983. // Type: 2,
  8984. // }
  8985. //
  8986. // customs = append(customs, cus)
  8987. // }
  8988. // }
  8989. //
  8990. // for _, item := range item.HisAdditionalCharge {
  8991. // cus := &Custom{
  8992. // ItemId: item.ID,
  8993. // AdviceId: 0,
  8994. // ProjectId: 0,
  8995. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  8996. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  8997. // FeedetlSn: item.FeedetlSn,
  8998. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  8999. // MedListCodg: item.XtHisAddtionConfig.Code,
  9000. // Type: 3,
  9001. // }
  9002. //
  9003. // customs = append(customs, cus)
  9004. // }
  9005. //
  9006. // }
  9007. //
  9008. // for _, item := range customs {
  9009. // var advice_id int64 = 0
  9010. // var project_id int64 = 0
  9011. // var item_id int64 = 0
  9012. //
  9013. // var types int64 = 0
  9014. //
  9015. // if item.Type == 1 {
  9016. // advice_id = item.AdviceId
  9017. // project_id = 0
  9018. // item_id = 0
  9019. // } else if item.Type == 2 {
  9020. // advice_id = 0
  9021. // item_id = 0
  9022. //
  9023. // project_id = item.ProjectId
  9024. // } else if item.Type == 3 {
  9025. // advice_id = 0
  9026. // item_id = item.ItemId
  9027. // project_id = 0
  9028. // }
  9029. //
  9030. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9031. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9032. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9033. //
  9034. // info := &models.HisOrderInfo{
  9035. // OrderNumber: order.Number,
  9036. // UploadDate: time.Now().Unix(),
  9037. // AdviceId: advice_id,
  9038. // DetItemFeeSumamt: detItemFeeSumamt,
  9039. // Cnt: cut,
  9040. // Pric: pric,
  9041. // PatientId: id,
  9042. // Status: 1,
  9043. // Mtime: time.Now().Unix(),
  9044. // Ctime: time.Now().Unix(),
  9045. // UserOrgId: adminUser.CurrentOrgId,
  9046. // HisPatientId: his.ID,
  9047. // OrderId: order.ID,
  9048. // ProjectId: project_id,
  9049. // Type: types,
  9050. // ItemId: item_id,
  9051. // }
  9052. // service.CreateOrderInfo(info)
  9053. // }
  9054. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9055. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9056. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9057. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9058. // if err == nil {
  9059. // c.ServeSuccessJSON(map[string]interface{}{
  9060. // "msg": "结算成功",
  9061. // })
  9062. // } else {
  9063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9064. // return
  9065. // }
  9066. // }
  9067. //}
  9068. //上传明细-预结算-
  9069. func (c *HisApiController) GetPreUploadInfo() {
  9070. id, _ := c.GetInt64("id")
  9071. record_time := c.GetString("record_time")
  9072. his_patient_id, _ := c.GetInt64("his_patient_id")
  9073. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9074. admin_user_id, _ := c.GetInt64("admin_user_id")
  9075. diagnosis_id := c.GetString("diagnosis")
  9076. sick_type, _ := c.GetInt64("sick_type")
  9077. reg_type, _ := c.GetInt64("p_type")
  9078. begin_time := c.GetString("begin_time")
  9079. id_str := c.GetString("ids")
  9080. ids_arr := strings.Split(id_str, ",")
  9081. timeLayout := "2006-01-02"
  9082. loc, _ := time.LoadLocation("Local")
  9083. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9084. if err != nil {
  9085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9086. return
  9087. }
  9088. recordDateTime := theTime.Unix()
  9089. adminUser := c.GetAdminUserInfo()
  9090. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9091. var config []*models.HisXtDiagnoseConfig
  9092. for _, item := range diagnosis_ids {
  9093. id, _ := strconv.ParseInt(item, 10, 64)
  9094. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9095. config = append(config, &diagnosisConfig)
  9096. }
  9097. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9098. sickConfig, _ := service.FindSickById(sick_type)
  9099. var prescriptions []*models.HisPrescription
  9100. var start_time int64
  9101. var end_time int64
  9102. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9103. fmt.Println(his_patient_id)
  9104. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9105. timestamp := time.Now().Unix()
  9106. tempTime := time.Unix(timestamp, 0)
  9107. timeFormat := tempTime.Format("20060102150405")
  9108. chrgBchno := rand.Intn(100000) + 10000
  9109. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9111. var patientPrescription models.HisPrescriptionInfo
  9112. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9113. if patientPrescription.ID == 0 {
  9114. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9115. }
  9116. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9117. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9118. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9119. strconv.FormatInt(his.PatientId, 10)
  9120. var res2 ResultSix
  9121. var resSix10265 ResultSix10265
  9122. //var time_stamp string
  9123. if miConfig.MdtrtareaAdmvs == "421300" {
  9124. data := make(map[string]interface{})
  9125. client := &http.Client{}
  9126. data["psn_no"] = his.PsnNo
  9127. data["mdtrt_id"] = his.Number
  9128. data["department"] = department.Name
  9129. data["org_name"] = miConfig.OrgName
  9130. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9131. data["doctor_id"] = doctor_info.DoctorNumber
  9132. data["doctor_name"] = roles.UserName
  9133. data["fixmedins_code"] = miConfig.Code
  9134. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9135. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9136. data["secret_key"] = miConfig.SecretKey
  9137. data["sick_code"] = sickConfig.CountryCode
  9138. data["sick_name"] = sickConfig.ClassName
  9139. data["begin_time"] = begin_time
  9140. data["dept"] = strconv.FormatInt(department.ID, 10)
  9141. data["config"] = config
  9142. data["opter"] = roles.UserName
  9143. fmt.Println(data)
  9144. bytesData, _ := json.Marshal(data)
  9145. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9146. resp, _ := client.Do(req)
  9147. defer resp.Body.Close()
  9148. body, ioErr := ioutil.ReadAll(resp.Body)
  9149. if ioErr != nil {
  9150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. var respJSON map[string]interface{}
  9155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9161. userJSONBytes, _ := json.Marshal(respJSON)
  9162. fmt.Println("log")
  9163. fmt.Println(string(userJSONBytes))
  9164. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9165. utils.ErrorLog("解析失败:%v", err)
  9166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. return
  9168. }
  9169. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9170. data := make(map[string]interface{})
  9171. client := &http.Client{}
  9172. data["psn_no"] = his.PsnNo
  9173. data["mdtrt_id"] = his.Number
  9174. data["doctor"] = roles.UserName
  9175. data["department"] = department.Name
  9176. data["org_name"] = miConfig.OrgName
  9177. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9178. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9179. data["fixmedins_code"] = miConfig.Code
  9180. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9181. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9182. data["secret_key"] = miConfig.SecretKey
  9183. data["sick_code"] = sickConfig.CountryCode
  9184. data["sick_name"] = sickConfig.ClassName
  9185. data["begin_time"] = begin_time
  9186. data["dept"] = strconv.FormatInt(department.ID, 10)
  9187. data["config"] = config
  9188. data["url"] = miConfig.Url
  9189. data["ak"] = miConfig.AccessKey
  9190. data["cainfo"] = miConfig.Cainfo
  9191. bytesData, _ := json.Marshal(data)
  9192. var req *http.Request
  9193. if miConfig.MdtrtareaAdmvs == "320921" {
  9194. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9195. } else {
  9196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9197. }
  9198. resp, _ := client.Do(req)
  9199. defer resp.Body.Close()
  9200. body, ioErr := ioutil.ReadAll(resp.Body)
  9201. if ioErr != nil {
  9202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. var respJSON map[string]interface{}
  9207. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9210. return
  9211. }
  9212. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9213. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9214. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9216. userJSONBytes, _ := json.Marshal(respJSON)
  9217. fmt.Println("log")
  9218. fmt.Println(string(userJSONBytes))
  9219. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9220. utils.ErrorLog("解析失败:%v", err)
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9225. res2.Output = resSix10265.Output
  9226. res2.ErrMsg = resSix10265.ErrMsg
  9227. res2.Cainfo = resSix10265.Cainfo
  9228. res2.WarnMsg = resSix10265.WarnMsg
  9229. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9230. res2.Infcode = infocode
  9231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9232. 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)
  9233. saveLog(result, requestLog, "2203", "上传就诊信息")
  9234. var respJSON2 map[string]interface{}
  9235. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9238. return
  9239. }
  9240. userJSONBytes2, _ := json.Marshal(respJSON2)
  9241. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9242. utils.ErrorLog("解析失败:%v", err)
  9243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9244. return
  9245. }
  9246. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9247. var result string
  9248. var requestLog string
  9249. 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, "")
  9250. saveLog(result, requestLog, "2203", "上传就诊信息")
  9251. var respJSON2 map[string]interface{}
  9252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9255. return
  9256. }
  9257. userJSONBytes2, _ := json.Marshal(respJSON2)
  9258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9259. utils.ErrorLog("解析失败:%v", err)
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9264. var result string
  9265. var requestLog string
  9266. 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, "")
  9267. saveLog(result, requestLog, "2203", "上传就诊信息")
  9268. var respJSON2 map[string]interface{}
  9269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. userJSONBytes2, _ := json.Marshal(respJSON2)
  9275. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9276. utils.ErrorLog("解析失败:%v", err)
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9278. return
  9279. }
  9280. } else {
  9281. var result string
  9282. var requestLog string
  9283. if miConfig.MdtrtareaAdmvs == "440781" { //
  9284. 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)
  9285. } else {
  9286. if miConfig.Code == "H15049901371" {
  9287. //赤峰地区国家医保医疗类别
  9288. //职工透析:医疗类别选特殊情况门诊990502
  9289. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9290. var med_type string
  9291. if his.Insutype == "390" {
  9292. if reg_type == 14 {
  9293. med_type = "9933"
  9294. } else if reg_type == 11 {
  9295. med_type = "11"
  9296. }
  9297. } else if his.Insutype == "310" {
  9298. if reg_type == 14 {
  9299. med_type = "990502"
  9300. } else if reg_type == 11 {
  9301. med_type = "11"
  9302. }
  9303. }
  9304. 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)
  9305. } else {
  9306. 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)
  9307. }
  9308. saveLog(result, requestLog, "2203", "上传就诊信息")
  9309. var respJSON2 map[string]interface{}
  9310. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9313. return
  9314. }
  9315. userJSONBytes2, _ := json.Marshal(respJSON2)
  9316. if miConfig.Code == "H15049901371" {
  9317. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9318. utils.ErrorLog("解析失败:%v", err)
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9320. return
  9321. }
  9322. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9323. res2.Output = resSix10265.Output
  9324. res2.ErrMsg = resSix10265.ErrMsg
  9325. res2.Cainfo = resSix10265.Cainfo
  9326. res2.WarnMsg = resSix10265.WarnMsg
  9327. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9328. res2.Infcode = infocode
  9329. } else {
  9330. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9331. utils.ErrorLog("解析失败:%v", err)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. }
  9336. }
  9337. }
  9338. if res2.Infcode != 0 {
  9339. adminUser := c.GetAdminUserInfo()
  9340. errlog := &models.HisOrderError{
  9341. UserOrgId: adminUser.CurrentOrgId,
  9342. Ctime: time.Now().Unix(),
  9343. Mtime: time.Now().Unix(),
  9344. ErrMsg: res2.ErrMsg,
  9345. Status: 1,
  9346. PatientId: id,
  9347. RecordTime: recordDateTime,
  9348. Stage: 3,
  9349. }
  9350. service.CreateErrMsgLog(errlog)
  9351. c.ServeSuccessJSON(map[string]interface{}{
  9352. "failed_code": -10,
  9353. "msg": res2.ErrMsg,
  9354. })
  9355. return
  9356. } else {
  9357. his.Diagnosis = diagnosis_id
  9358. his.SickType = sickConfig.ID
  9359. his.PType = fmt.Sprintf("%d", reg_type)
  9360. service.UpdateHisPatientThree(&his)
  9361. data := make(map[string]interface{})
  9362. if settle_accounts_type == 1 { //日结
  9363. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9364. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9365. } else {
  9366. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9367. }
  9368. data["pre"] = prescriptions
  9369. } else { //月结
  9370. start_time_str := c.GetString("start_time")
  9371. end_time_str := c.GetString("end_time")
  9372. timeLayout := "2006-01-02"
  9373. loc, _ := time.LoadLocation("Local")
  9374. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9375. if err != nil {
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9377. return
  9378. }
  9379. recordStartTime := theStartTime.Unix()
  9380. start_time = recordStartTime
  9381. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9382. if err != nil {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9384. return
  9385. }
  9386. recordEndTime := theEndTime.Unix()
  9387. end_time = recordEndTime
  9388. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9389. data["pre"] = prescriptions
  9390. }
  9391. client := &http.Client{}
  9392. data["psn_no"] = his.PsnNo
  9393. data["mdtrt_id"] = his.Number
  9394. data["chrg_bchno"] = chrg_bchno
  9395. data["org_name"] = miConfig.OrgName
  9396. data["doctor"] = doctor_info.UserName
  9397. data["doctor_id"] = doctor_info.DoctorNumber
  9398. data["dept"] = department.Name
  9399. data["fixmedins_code"] = miConfig.Code
  9400. data["opter"] = roles.UserName
  9401. data["dept_code"] = department.Number
  9402. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9403. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9404. data["secret_key"] = miConfig.SecretKey
  9405. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9406. data["url"] = miConfig.Url
  9407. data["ak"] = miConfig.AccessKey
  9408. data["new_doctor_name"] = patientPrescription.Doctor
  9409. data["diag_code"] = sickConfig.CountryCode
  9410. data["cainfo"] = miConfig.Cainfo
  9411. data["opter"] = roles.UserName
  9412. var ids []int64
  9413. for _, item := range prescriptions {
  9414. ids = append(ids, item.ID)
  9415. }
  9416. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9417. if config.IsOpen == 1 { //对接了医保,走医保流程
  9418. var res ResultFour
  9419. var resFour10265 ResultFour10265
  9420. if miConfig.MdtrtareaAdmvs == "421300" {
  9421. bytesData, _ := json.Marshal(data)
  9422. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9423. resp, _ := client.Do(req)
  9424. defer resp.Body.Close()
  9425. body, ioErr := ioutil.ReadAll(resp.Body)
  9426. if ioErr != nil {
  9427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9429. return
  9430. }
  9431. var respJSON map[string]interface{}
  9432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9435. return
  9436. }
  9437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9438. userJSONBytes, _ := json.Marshal(respJSON)
  9439. fmt.Println("log")
  9440. fmt.Println(string(userJSONBytes))
  9441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9442. utils.ErrorLog("解析失败:%v", err)
  9443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9444. return
  9445. }
  9446. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9447. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9448. if result3101.Infcode == "0" {
  9449. if len(result3101.Output.Result) > 0 {
  9450. var errMsgs []string
  9451. for _, item := range result3101.Output.Result {
  9452. errMsgs = append(errMsgs, item.VolaCont)
  9453. }
  9454. c.ServeSuccessJSON(map[string]interface{}{
  9455. "failed_code": -10,
  9456. "msg": errMsgs,
  9457. })
  9458. return
  9459. } else {
  9460. if miConfig.MdtrtareaAdmvs == "320921" {
  9461. data["doctor_id"] = "D320923012139"
  9462. } else {
  9463. data["doctor_id"] = "D371621008686"
  9464. }
  9465. bytesData, _ := json.Marshal(data)
  9466. var req *http.Request
  9467. if miConfig.MdtrtareaAdmvs == "320921" {
  9468. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9469. } else {
  9470. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9471. }
  9472. resp, _ := client.Do(req)
  9473. defer resp.Body.Close()
  9474. body, ioErr := ioutil.ReadAll(resp.Body)
  9475. if ioErr != nil {
  9476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9487. userJSONBytes, _ := json.Marshal(respJSON)
  9488. fmt.Println("log")
  9489. fmt.Println(string(userJSONBytes))
  9490. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9491. utils.ErrorLog("解析失败:%v", err)
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. return
  9494. }
  9495. res.InfRefmsgid = resFour10265.InfRefmsgid
  9496. res.Output = resFour10265.Output
  9497. res.ErrMsg = resFour10265.ErrMsg
  9498. res.Cainfo = resFour10265.Cainfo
  9499. res.WarnMsg = resFour10265.WarnMsg
  9500. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9501. res.Infcode = infocode
  9502. }
  9503. }
  9504. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9505. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  9506. var dat map[string]interface{}
  9507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9508. fmt.Println(dat)
  9509. } else {
  9510. fmt.Println(err)
  9511. }
  9512. saveLog(result, request_log, "2204", "上传费用明细")
  9513. userJSONBytes, _ := json.Marshal(dat)
  9514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9515. utils.ErrorLog("解析失败:%v", err)
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9517. return
  9518. }
  9519. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9520. 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, "", "")
  9521. var dat map[string]interface{}
  9522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9523. fmt.Println(dat)
  9524. } else {
  9525. fmt.Println(err)
  9526. }
  9527. saveLog(result, request_log, "2204", "上传费用明细")
  9528. userJSONBytes, _ := json.Marshal(dat)
  9529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9530. utils.ErrorLog("解析失败:%v", err)
  9531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9532. return
  9533. }
  9534. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9535. 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, "", "")
  9536. var dat map[string]interface{}
  9537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9538. fmt.Println(dat)
  9539. } else {
  9540. fmt.Println(err)
  9541. }
  9542. saveLog(result, request_log, "2204", "上传费用明细")
  9543. userJSONBytes, _ := json.Marshal(dat)
  9544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9545. utils.ErrorLog("解析失败:%v", err)
  9546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9547. return
  9548. }
  9549. } else {
  9550. if miConfig.Code == "H15049901371" {
  9551. 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)
  9552. var dat map[string]interface{}
  9553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9554. fmt.Println(dat)
  9555. } else {
  9556. fmt.Println(err)
  9557. }
  9558. saveLog(result, request_log, "2204", "上传费用明细")
  9559. userJSONBytes, _ := json.Marshal(dat)
  9560. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9561. utils.ErrorLog("解析失败:%v", err)
  9562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9563. return
  9564. }
  9565. res.InfRefmsgid = resFour10265.InfRefmsgid
  9566. res.Output = resFour10265.Output
  9567. res.ErrMsg = resFour10265.ErrMsg
  9568. res.Cainfo = resFour10265.Cainfo
  9569. res.WarnMsg = resFour10265.WarnMsg
  9570. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9571. res.Infcode = infocode
  9572. } else {
  9573. 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)
  9574. var dat map[string]interface{}
  9575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9576. fmt.Println(dat)
  9577. } else {
  9578. fmt.Println(err)
  9579. }
  9580. saveLog(result, request_log, "2204", "上传费用明细")
  9581. userJSONBytes, _ := json.Marshal(dat)
  9582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9583. utils.ErrorLog("解析失败:%v", err)
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. }
  9588. }
  9589. if res.Infcode == 0 {
  9590. order := &models.HisOrder{
  9591. UserOrgId: adminUser.CurrentOrgId,
  9592. HisPatientId: his.ID,
  9593. PatientId: his.PatientId,
  9594. SettleAccountsDate: recordDateTime,
  9595. Ctime: time.Now().Unix(),
  9596. Mtime: time.Now().Unix(),
  9597. MdtrtId: his.Number,
  9598. PsnNo: his.PsnNo,
  9599. MedType: strconv.FormatInt(reg_type, 10),
  9600. Status: 1,
  9601. Number: chrg_bchno,
  9602. Infcode: res.Infcode,
  9603. WarnMsg: res.WarnMsg,
  9604. Cainfo: res.Cainfo,
  9605. ErrMsg: res.ErrMsg,
  9606. RespondTime: res.RefmsgTime,
  9607. InfRefmsgid: res.InfRefmsgid,
  9608. OrderStatus: 1,
  9609. IsMedicineInsurance: 1,
  9610. SettleType: settle_accounts_type,
  9611. SettleStartTime: start_time,
  9612. SettleEndTime: end_time,
  9613. Creator: roles.AdminUserId,
  9614. Modify: roles.AdminUserId,
  9615. PType: 2,
  9616. Diagnosis: diagnosis_id,
  9617. }
  9618. err = service.CreateOrder(order)
  9619. if err != nil {
  9620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9621. return
  9622. }
  9623. for _, item := range res.Output.Result {
  9624. temp := strings.Split(item.FeedetlSn, "-")
  9625. var advice_id int64 = 0
  9626. var project_id int64 = 0
  9627. var types int64 = 0
  9628. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9629. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9630. if temp[1] == "1" {
  9631. advice_id = id
  9632. project_id = 0
  9633. } else if temp[1] == "2" {
  9634. advice_id = 0
  9635. project_id = id
  9636. }
  9637. info := &models.HisOrderInfo{
  9638. OrderNumber: order.Number,
  9639. FeedetlSn: item.FeedetlSn,
  9640. UploadDate: time.Now().Unix(),
  9641. AdviceId: advice_id,
  9642. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9643. Cnt: item.Cnt,
  9644. Pric: float64(item.Pric),
  9645. PatientId: his.PatientId,
  9646. PricUplmtAmt: item.PricUplmtAmt,
  9647. SelfpayProp: item.SelfpayProp,
  9648. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9649. OverlmtAmt: item.OverlmtAmt,
  9650. PreselfpayAmt: item.PreselfpayAmt,
  9651. BasMednFlag: item.BasMednFlag,
  9652. MedChrgitmType: item.MedChrgitmType,
  9653. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9654. Status: 1,
  9655. Memo: item.Memo,
  9656. Mtime: time.Now().Unix(),
  9657. InscpScpAmt: item.InscpScpAmt,
  9658. DrtReimFlag: item.DrtReimFlag,
  9659. Ctime: time.Now().Unix(),
  9660. ListSpItemFlag: item.ListSpItemFlag,
  9661. ChldMedcFlag: item.ChldMedcFlag,
  9662. LmtUsedFlag: item.LmtUsedFlag,
  9663. ChrgitmLv: item.ChrgitmLv,
  9664. UserOrgId: adminUser.CurrentOrgId,
  9665. HisPatientId: his.ID,
  9666. OrderId: order.ID,
  9667. ProjectId: project_id,
  9668. Type: types,
  9669. }
  9670. service.CreateOrderInfo(info)
  9671. }
  9672. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9673. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9674. var total float64
  9675. for _, item := range prescriptions {
  9676. if item.Type == 1 { //药品
  9677. for _, subItem := range item.HisDoctorAdviceInfo {
  9678. total = total + (subItem.Price * subItem.PrescribingNumber)
  9679. }
  9680. }
  9681. if item.Type == 2 { //项目
  9682. for _, subItem := range item.HisPrescriptionProject {
  9683. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9684. total = total + (subItem.Price * cnt)
  9685. }
  9686. }
  9687. }
  9688. for _, item := range prescriptions {
  9689. for _, subItem := range item.HisAdditionalCharge {
  9690. total = total + (subItem.Price * float64(subItem.Count))
  9691. }
  9692. }
  9693. allTotal := fmt.Sprintf("%.4f", total)
  9694. if res.Infcode == 0 {
  9695. var rf []*ResultFive
  9696. json.Unmarshal([]byte(his.Iinfo), &rf)
  9697. chrg_bchno := chrg_bchno
  9698. cert_no := his.Certno
  9699. var insutypes []string
  9700. var insutype string
  9701. var is390 int = 0
  9702. var is310 int = 0
  9703. for _, item := range rf {
  9704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9705. insutypes = append(insutypes, item.Insutype)
  9706. }
  9707. }
  9708. if len(insutypes) == 1 {
  9709. insutype = insutypes[0]
  9710. } else {
  9711. for _, i := range insutypes {
  9712. if i == "390" {
  9713. is390 = 1
  9714. }
  9715. if i == "310" {
  9716. is310 = 1
  9717. }
  9718. }
  9719. }
  9720. if is390 == 1 {
  9721. insutype = "390"
  9722. }
  9723. if is310 == 1 {
  9724. insutype = "310"
  9725. }
  9726. if len(insutypes) == 0 {
  9727. insutype = "310"
  9728. }
  9729. if len(insutypes) == 2 {
  9730. insutype = strconv.FormatInt(his.SocialType, 64)
  9731. }
  9732. //insutype = "390"
  9733. if his.IdCardType == 1 {
  9734. cert_no = his.MedicalInsuranceNumber
  9735. } else {
  9736. cert_no = his.Certno
  9737. }
  9738. var res ResultSeven
  9739. var resSeven10265 ResultSeven10265
  9740. if miConfig.MdtrtareaAdmvs == "421300" {
  9741. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9742. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9743. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9745. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9746. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9747. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9748. resp, requestErr := http.Get(api)
  9749. if requestErr != nil {
  9750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9751. return
  9752. }
  9753. body, ioErr := ioutil.ReadAll(resp.Body)
  9754. if ioErr != nil {
  9755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9757. return
  9758. }
  9759. var respJSON map[string]interface{}
  9760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9763. return
  9764. }
  9765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9766. result, _ := json.Marshal(respJSON)
  9767. fmt.Println("log")
  9768. fmt.Println(string(result))
  9769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9770. utils.ErrorLog("解析失败:%v", err)
  9771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9772. return
  9773. }
  9774. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9775. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9776. if result3101.Infcode == "0" {
  9777. if len(result3101.Output.Result) > 0 {
  9778. var errMsgs []string
  9779. for _, item := range result3101.Output.Result {
  9780. errMsgs = append(errMsgs, item.VolaCont)
  9781. }
  9782. c.ServeSuccessJSON(map[string]interface{}{
  9783. "failed_code": -10,
  9784. "msg": errMsgs,
  9785. })
  9786. return
  9787. } else {
  9788. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9789. if his.IdCardType != 4 {
  9790. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9791. bas := strings.Split(psn_info.CardInfo, "|")
  9792. if his.IdCardType == 1 {
  9793. cert_no = bas[2]
  9794. } else {
  9795. cert_no = bas[1]
  9796. }
  9797. } else {
  9798. cert_no = his.Certno
  9799. }
  9800. //江苏地区国家医保医疗类别
  9801. //职工透析:医疗类别选特殊情况门诊9933
  9802. //居民血透门慢: 医疗类别选门诊慢病1402
  9803. //var med_type string
  9804. //if his.Insutype == "310" {
  9805. // if reg_type == 14 {
  9806. // med_type = "9933"
  9807. // } else if reg_type == 11 {
  9808. // med_type = "11"
  9809. //
  9810. // }
  9811. //} else if his.Insutype == "390" {
  9812. // if reg_type == 14 {
  9813. // med_type = "1402"
  9814. // } else if reg_type == 11 {
  9815. // med_type = "11"
  9816. // }
  9817. //}
  9818. var api string
  9819. if miConfig.MdtrtareaAdmvs == "320921" {
  9820. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9821. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9822. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9824. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9825. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9826. "&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
  9827. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9828. } else {
  9829. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9830. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9831. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9832. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9834. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9835. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9836. "&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
  9837. }
  9838. resp, requestErr := http.Get(api)
  9839. if requestErr != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9841. return
  9842. }
  9843. body, ioErr := ioutil.ReadAll(resp.Body)
  9844. if ioErr != nil {
  9845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9847. return
  9848. }
  9849. var respJSON map[string]interface{}
  9850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9853. return
  9854. }
  9855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9856. result, _ := json.Marshal(respJSON)
  9857. fmt.Println("log")
  9858. fmt.Println(string(result))
  9859. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9860. utils.ErrorLog("解析失败:%v", err)
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9862. return
  9863. }
  9864. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9865. res.Output = resSeven10265.Output
  9866. res.ErrMsg = resSeven10265.ErrMsg
  9867. res.Cainfo = resSeven10265.Cainfo
  9868. res.WarnMsg = resSeven10265.WarnMsg
  9869. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9870. res.Infcode = infocode
  9871. }
  9872. }
  9873. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9874. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9875. var result string
  9876. var request_log string
  9877. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  9878. 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)
  9879. } else {
  9880. 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)
  9881. }
  9882. var dat map[string]interface{}
  9883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9884. fmt.Println(dat)
  9885. } else {
  9886. fmt.Println(err)
  9887. }
  9888. saveLog(result, request_log, "2206", "预结算")
  9889. userJSONBytes, _ := json.Marshal(dat)
  9890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9891. utils.ErrorLog("解析失败:%v", err)
  9892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9893. return
  9894. }
  9895. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9896. var result string
  9897. var request_log string
  9898. if his.IdCardType == 2 {
  9899. 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, "")
  9900. } else if his.IdCardType == 1 {
  9901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9902. bas := strings.Split(psn_info.CardInfo, "|")
  9903. basNumber := bas[2]
  9904. card_sn := bas[3]
  9905. 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)
  9906. } else {
  9907. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9908. 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, "")
  9909. }
  9910. var dat map[string]interface{}
  9911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9912. fmt.Println(dat)
  9913. } else {
  9914. fmt.Println(err)
  9915. }
  9916. saveLog(result, request_log, "2206", "预结算")
  9917. userJSONBytes, _ := json.Marshal(dat)
  9918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9919. utils.ErrorLog("解析失败:%v", err)
  9920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9921. return
  9922. }
  9923. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9924. var result string
  9925. var request_log string
  9926. if his.IdCardType == 2 {
  9927. 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, "")
  9928. } else if his.IdCardType == 1 {
  9929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9930. bas := strings.Split(psn_info.CardInfo, "|")
  9931. basNumber := bas[2]
  9932. card_sn := bas[3]
  9933. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  9934. } else {
  9935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9936. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  9937. }
  9938. var dat map[string]interface{}
  9939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9940. fmt.Println(dat)
  9941. } else {
  9942. fmt.Println(err)
  9943. }
  9944. saveLog(result, request_log, "2206", "预结算")
  9945. userJSONBytes, _ := json.Marshal(dat)
  9946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9947. utils.ErrorLog("解析失败:%v", err)
  9948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. return
  9950. }
  9951. } else {
  9952. var result string
  9953. var request_log string
  9954. if miConfig.Code == "H15049901371" {
  9955. //赤峰地区国家医保医疗类别
  9956. //职工透析:医疗类别选特殊情况门诊990502
  9957. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9958. var med_type string
  9959. if his.Insutype == "390" {
  9960. if reg_type == 14 {
  9961. med_type = "9933"
  9962. } else if reg_type == 11 {
  9963. med_type = "11"
  9964. }
  9965. } else if his.Insutype == "310" {
  9966. if reg_type == 14 {
  9967. med_type = "990502"
  9968. } else if reg_type == 11 {
  9969. med_type = "11"
  9970. }
  9971. }
  9972. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  9973. } else {
  9974. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9975. if his.IdCardType == 4 {
  9976. 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)
  9977. } else {
  9978. 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)
  9979. }
  9980. }
  9981. var dat map[string]interface{}
  9982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9983. fmt.Println(dat)
  9984. } else {
  9985. fmt.Println(err)
  9986. }
  9987. saveLog(result, request_log, "2206", "预结算")
  9988. //userJSONBytes, _ := json.Marshal(dat)
  9989. //
  9990. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9991. // utils.ErrorLog("解析失败:%v", err)
  9992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. // return
  9994. //}
  9995. userJSONBytes, _ := json.Marshal(dat)
  9996. if miConfig.Code == "H15049901371" {
  9997. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9998. utils.ErrorLog("解析失败:%v", err)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10003. res.Output = resSeven10265.Output
  10004. res.ErrMsg = resSeven10265.ErrMsg
  10005. res.Cainfo = resSeven10265.Cainfo
  10006. res.WarnMsg = resSeven10265.WarnMsg
  10007. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10008. res.Infcode = infocode
  10009. } else {
  10010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10011. utils.ErrorLog("解析失败:%v", err)
  10012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10013. return
  10014. }
  10015. }
  10016. }
  10017. if res.Infcode != 0 {
  10018. errlog := &models.HisOrderError{
  10019. UserOrgId: adminUser.CurrentOrgId,
  10020. Ctime: time.Now().Unix(),
  10021. Mtime: time.Now().Unix(),
  10022. Number: chrg_bchno,
  10023. ErrMsg: res.ErrMsg,
  10024. Status: 1,
  10025. PatientId: id,
  10026. RecordTime: recordDateTime,
  10027. Stage: 20,
  10028. }
  10029. service.CreateErrMsgLog(errlog)
  10030. c.ServeSuccessJSON(map[string]interface{}{
  10031. "failed_code": -10,
  10032. "msg": res.ErrMsg,
  10033. })
  10034. return
  10035. } else {
  10036. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10037. order.OrderStatus = 1
  10038. order.IsPre = 1
  10039. order.Status = 1
  10040. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10041. order.SetlId = res.Output.Setlinfo.SetlID
  10042. order.PsnNo = res.Output.Setlinfo.PsnNo
  10043. order.PsnName = res.Output.Setlinfo.PsnName
  10044. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10045. order.Certno = res.Output.Setlinfo.Certno
  10046. order.Gend = res.Output.Setlinfo.Gend
  10047. order.Naty = res.Output.Setlinfo.Naty
  10048. order.Age = res.Output.Setlinfo.Age
  10049. order.Insutype = res.Output.Setlinfo.Insutype
  10050. order.PsnType = res.Output.Setlinfo.PsnType
  10051. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10052. order.SetlTime = res.Output.Setlinfo.SetlTime
  10053. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10054. if res.Output.Setlinfo.MedType == "140101" {
  10055. order.MedType = "14"
  10056. } else {
  10057. order.MedType = res.Output.Setlinfo.MedType
  10058. }
  10059. if reg_type == 1112 {
  10060. order.MedType = "1112"
  10061. }
  10062. if reg_type == 1111 {
  10063. order.MedType = "1111"
  10064. }
  10065. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10066. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10067. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10068. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10069. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10070. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10071. order.HifpPay = res.Output.Setlinfo.HifpPay
  10072. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10073. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10074. order.HifesPay = res.Output.Setlinfo.HifesPay
  10075. order.HifobPay = res.Output.Setlinfo.HifobPay
  10076. order.MafPay = res.Output.Setlinfo.MafPay
  10077. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10078. order.OthPay = res.Output.Setlinfo.OthPay
  10079. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10080. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10081. order.AcctPay = res.Output.Setlinfo.AcctPay
  10082. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10083. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10084. order.Balc = res.Output.Setlinfo.Balc
  10085. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10086. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10087. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10088. order.ClrWay = res.Output.Setlinfo.ClrWay
  10089. order.Creator = order.Creator
  10090. order.Modify = roles.AdminUserId
  10091. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10092. detailStr := string(setlDetail)
  10093. order.SetlDetail = detailStr
  10094. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10095. err = service.UpDateOrder(order)
  10096. if err == nil {
  10097. c.ServeSuccessJSON(map[string]interface{}{
  10098. "msg": "预结算成功",
  10099. })
  10100. } else {
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10102. return
  10103. }
  10104. }
  10105. } else {
  10106. adminUser := c.GetAdminUserInfo()
  10107. errlog := &models.HisOrderError{
  10108. UserOrgId: adminUser.CurrentOrgId,
  10109. Ctime: time.Now().Unix(),
  10110. Mtime: time.Now().Unix(),
  10111. ErrMsg: res.ErrMsg,
  10112. Status: 1,
  10113. PatientId: id,
  10114. RecordTime: recordDateTime,
  10115. Stage: 4,
  10116. }
  10117. service.CreateErrMsgLog(errlog)
  10118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10119. return
  10120. }
  10121. } else {
  10122. adminUser := c.GetAdminUserInfo()
  10123. errlog := &models.HisOrderError{
  10124. UserOrgId: adminUser.CurrentOrgId,
  10125. Ctime: time.Now().Unix(),
  10126. Mtime: time.Now().Unix(),
  10127. ErrMsg: res.ErrMsg,
  10128. Status: 1,
  10129. PatientId: id,
  10130. RecordTime: recordDateTime,
  10131. Stage: 4,
  10132. }
  10133. service.CreateErrMsgLog(errlog)
  10134. c.ServeSuccessJSON(map[string]interface{}{
  10135. "failed_code": -10,
  10136. "msg": res.ErrMsg,
  10137. })
  10138. return
  10139. }
  10140. }
  10141. }
  10142. }
  10143. //退款
  10144. func (c *HisApiController) Refund() {
  10145. order_id, _ := c.GetInt64("order_id")
  10146. admin_user_id, _ := c.GetInt64("admin_user_id")
  10147. adminUser := c.GetAdminUserInfo()
  10148. var order models.HisOrder
  10149. order, _ = service.GetHisOrderByID(order_id)
  10150. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10151. if order.ID == 0 {
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10153. return
  10154. }
  10155. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10156. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10157. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10158. if config.IsOpen == 1 { //对接了医保,走医保流程
  10159. var res ResultSixteen
  10160. var resSixteen10265 ResultSixteen10265
  10161. var src_resquest string
  10162. var result string
  10163. if miConfig.MdtrtareaAdmvs == "421300" {
  10164. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10165. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10167. resp3, requestErr3 := http.Get(api3)
  10168. if requestErr3 != nil {
  10169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10170. return
  10171. }
  10172. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10173. if ioErr3 != nil {
  10174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. var respJSON3 map[string]interface{}
  10179. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10185. userJSONBytes3, _ := json.Marshal(respJSON3)
  10186. fmt.Println("log")
  10187. fmt.Println(string(userJSONBytes3))
  10188. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10189. utils.ErrorLog("解析失败:%v", err)
  10190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10191. return
  10192. }
  10193. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10194. var api3 string
  10195. if miConfig.MdtrtareaAdmvs == "320921" {
  10196. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10197. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10199. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10200. } else {
  10201. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10202. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10203. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10204. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10205. }
  10206. resp3, requestErr3 := http.Get(api3)
  10207. if requestErr3 != nil {
  10208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. return
  10210. }
  10211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10212. if ioErr3 != nil {
  10213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10215. return
  10216. }
  10217. var respJSON3 map[string]interface{}
  10218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10221. return
  10222. }
  10223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10224. userJSONBytes3, _ := json.Marshal(respJSON3)
  10225. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10226. utils.ErrorLog("解析失败:%v", err)
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10228. return
  10229. }
  10230. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10231. res.Output = resSixteen10265.Output
  10232. res.ErrMsg = resSixteen10265.ErrMsg
  10233. res.Cainfo = resSixteen10265.Cainfo
  10234. res.WarnMsg = resSixteen10265.WarnMsg
  10235. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10236. res.Infcode = infocode
  10237. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10238. 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)
  10239. var dat map[string]interface{}
  10240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10241. fmt.Println(dat)
  10242. } else {
  10243. fmt.Println(err)
  10244. }
  10245. saveLog(result, src_resquest, "2208", "退费")
  10246. userJSONBytes, _ := json.Marshal(dat)
  10247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10248. utils.ErrorLog("解析失败:%v", err)
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10250. return
  10251. }
  10252. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10253. 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, "")
  10254. var dat map[string]interface{}
  10255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10256. fmt.Println(dat)
  10257. } else {
  10258. fmt.Println(err)
  10259. }
  10260. saveLog(result, src_resquest, "2208", "退费")
  10261. userJSONBytes, _ := json.Marshal(dat)
  10262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10263. utils.ErrorLog("解析失败:%v", err)
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10265. return
  10266. }
  10267. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10268. 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, "")
  10269. var dat map[string]interface{}
  10270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10271. fmt.Println(dat)
  10272. } else {
  10273. fmt.Println(err)
  10274. }
  10275. saveLog(result, src_resquest, "2208", "退费")
  10276. userJSONBytes, _ := json.Marshal(dat)
  10277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10278. utils.ErrorLog("解析失败:%v", err)
  10279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10280. return
  10281. }
  10282. } else {
  10283. if miConfig.Code == "H15049901371" {
  10284. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10285. var dat map[string]interface{}
  10286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10287. fmt.Println(dat)
  10288. } else {
  10289. fmt.Println(err)
  10290. }
  10291. saveLog(result, src_resquest, "2208", "退费")
  10292. userJSONBytes, _ := json.Marshal(dat)
  10293. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10294. utils.ErrorLog("解析失败:%v", err)
  10295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10296. return
  10297. }
  10298. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10299. res.Output = resSixteen10265.Output
  10300. res.ErrMsg = resSixteen10265.ErrMsg
  10301. res.Cainfo = resSixteen10265.Cainfo
  10302. res.WarnMsg = resSixteen10265.WarnMsg
  10303. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10304. res.Infcode = infocode
  10305. } else {
  10306. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10307. var dat map[string]interface{}
  10308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10309. fmt.Println(dat)
  10310. } else {
  10311. fmt.Println(err)
  10312. }
  10313. saveLog(result, src_resquest, "2208", "退费")
  10314. userJSONBytes, _ := json.Marshal(dat)
  10315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10316. utils.ErrorLog("解析失败:%v", err)
  10317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10318. return
  10319. }
  10320. }
  10321. }
  10322. if res.Infcode == 0 {
  10323. var res2 ResultSix
  10324. var resSix10265 ResultSix10265
  10325. if miConfig.MdtrtareaAdmvs == "421300" {
  10326. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10327. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10328. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10329. resp3, requestErr3 := http.Get(api3)
  10330. if requestErr3 != nil {
  10331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. return
  10333. }
  10334. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10335. if ioErr3 != nil {
  10336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10338. return
  10339. }
  10340. var respJSON3 map[string]interface{}
  10341. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10344. return
  10345. }
  10346. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10347. userJSONBytes3, _ := json.Marshal(respJSON3)
  10348. fmt.Println("log")
  10349. fmt.Println(string(userJSONBytes3))
  10350. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10351. utils.ErrorLog("解析失败:%v", err)
  10352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10353. return
  10354. }
  10355. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10356. var api3 string
  10357. if miConfig.MdtrtareaAdmvs == "320921" {
  10358. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10359. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10361. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10362. } else {
  10363. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10364. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10365. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10367. }
  10368. resp3, requestErr3 := http.Get(api3)
  10369. if requestErr3 != nil {
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10374. if ioErr3 != nil {
  10375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10377. return
  10378. }
  10379. var respJSON3 map[string]interface{}
  10380. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10383. return
  10384. }
  10385. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10386. userJSONBytes3, _ := json.Marshal(respJSON3)
  10387. fmt.Println("log")
  10388. fmt.Println(string(userJSONBytes3))
  10389. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10390. utils.ErrorLog("解析失败:%v", err)
  10391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10392. return
  10393. }
  10394. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10395. res2.Output = resSix10265.Output
  10396. res2.ErrMsg = resSix10265.ErrMsg
  10397. res2.Cainfo = resSix10265.Cainfo
  10398. res2.WarnMsg = resSix10265.WarnMsg
  10399. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10400. res2.Infcode = infocode
  10401. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10402. 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)
  10403. var dat map[string]interface{}
  10404. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10405. fmt.Println(dat)
  10406. } else {
  10407. fmt.Println(err)
  10408. }
  10409. saveLog(result2, src_request, "2205", "撤销明细")
  10410. userJSONBytes, _ := json.Marshal(dat)
  10411. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10412. utils.ErrorLog("解析失败:%v", err)
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10414. return
  10415. }
  10416. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10417. 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, "")
  10418. var dat map[string]interface{}
  10419. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10420. fmt.Println(dat)
  10421. } else {
  10422. fmt.Println(err)
  10423. }
  10424. saveLog(result2, src_request, "2205", "撤销明细")
  10425. userJSONBytes, _ := json.Marshal(dat)
  10426. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10427. utils.ErrorLog("解析失败:%v", err)
  10428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10429. return
  10430. }
  10431. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10432. 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, "")
  10433. var dat map[string]interface{}
  10434. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10435. fmt.Println(dat)
  10436. } else {
  10437. fmt.Println(err)
  10438. }
  10439. saveLog(result2, src_request, "2205", "撤销明细")
  10440. userJSONBytes, _ := json.Marshal(dat)
  10441. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10442. utils.ErrorLog("解析失败:%v", err)
  10443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10444. return
  10445. }
  10446. } else {
  10447. if miConfig.Code == "H15049901371" {
  10448. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10449. var dat map[string]interface{}
  10450. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10451. fmt.Println(dat)
  10452. } else {
  10453. fmt.Println(err)
  10454. }
  10455. saveLog(result2, src_request, "2205", "撤销明细")
  10456. userJSONBytes, _ := json.Marshal(dat)
  10457. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10458. utils.ErrorLog("解析失败:%v", err)
  10459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10460. return
  10461. }
  10462. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10463. res2.Output = resSix10265.Output
  10464. res2.ErrMsg = resSix10265.ErrMsg
  10465. res2.Cainfo = resSix10265.Cainfo
  10466. res2.WarnMsg = resSix10265.WarnMsg
  10467. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10468. res2.Infcode = infocode
  10469. } else {
  10470. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10471. var dat map[string]interface{}
  10472. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10473. fmt.Println(dat)
  10474. } else {
  10475. fmt.Println(err)
  10476. }
  10477. saveLog(result2, src_request, "2205", "撤销明细")
  10478. userJSONBytes, _ := json.Marshal(dat)
  10479. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10480. utils.ErrorLog("解析失败:%v", err)
  10481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10482. return
  10483. }
  10484. }
  10485. }
  10486. if res2.Infcode == 0 {
  10487. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10488. if err == nil {
  10489. //当押金不为零时产生退费记录
  10490. if order.Decimal != 0 {
  10491. tmp := strconv.FormatInt(order.ID, 10)
  10492. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10493. if err != nil {
  10494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10495. return
  10496. }
  10497. }
  10498. c.ServeSuccessJSON(map[string]interface{}{
  10499. "msg": "退费成功",
  10500. })
  10501. } else {
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10503. return
  10504. }
  10505. } else {
  10506. c.ServeSuccessJSON(map[string]interface{}{
  10507. "code": -10,
  10508. "msg": res2.ErrMsg,
  10509. })
  10510. }
  10511. } else {
  10512. c.ServeSuccessJSON(map[string]interface{}{
  10513. "code": -10,
  10514. "msg": res.ErrMsg,
  10515. })
  10516. }
  10517. }
  10518. }
  10519. func (c *HisApiController) RefundNumber() {
  10520. record_time := c.GetString("record_time")
  10521. //patient_id, _ := c.GetInt64("patient_id")
  10522. admin_user_id, _ := c.GetInt64("admin_user_id")
  10523. his_patient_id, _ := c.GetInt64("id")
  10524. timeLayout := "2006-01-02"
  10525. loc, _ := time.LoadLocation("Local")
  10526. adminUser := c.GetAdminUserInfo()
  10527. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10528. fmt.Println(err)
  10529. if err != nil {
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10531. return
  10532. }
  10533. recordDateTime := theTime.Unix()
  10534. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10535. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10536. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10537. //order, _ := service.GetHisOrderByID(order_id)
  10538. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10539. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10540. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10541. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10542. if count > 0 {
  10543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10544. return
  10545. }
  10546. if config.IsOpen == 1 { //对接了医保,走医保流程
  10547. var res2 ResultSix
  10548. var resSix10265 ResultSix10265
  10549. if miConfig.MdtrtareaAdmvs == "421300" {
  10550. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10551. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10553. resp3, requestErr3 := http.Get(api3)
  10554. if requestErr3 != nil {
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return
  10557. }
  10558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10559. if ioErr3 != nil {
  10560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. var respJSON3 map[string]interface{}
  10565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10568. return
  10569. }
  10570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10571. userJSONBytes3, _ := json.Marshal(respJSON3)
  10572. fmt.Println("log")
  10573. fmt.Println(string(userJSONBytes3))
  10574. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10575. utils.ErrorLog("解析失败:%v", err)
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10577. return
  10578. }
  10579. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10580. var api3 string
  10581. if miConfig.MdtrtareaAdmvs == "320921" {
  10582. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10583. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10585. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10586. } else {
  10587. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10588. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10589. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10590. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10591. }
  10592. resp3, requestErr3 := http.Get(api3)
  10593. if requestErr3 != nil {
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10598. if ioErr3 != nil {
  10599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10601. return
  10602. }
  10603. var respJSON3 map[string]interface{}
  10604. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10607. return
  10608. }
  10609. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10610. userJSONBytes3, _ := json.Marshal(respJSON3)
  10611. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10612. utils.ErrorLog("解析失败:%v", err)
  10613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10614. return
  10615. }
  10616. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10617. res2.Output = resSix10265.Output
  10618. res2.ErrMsg = resSix10265.ErrMsg
  10619. res2.Cainfo = resSix10265.Cainfo
  10620. res2.WarnMsg = resSix10265.WarnMsg
  10621. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10622. res2.Infcode = infocode
  10623. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10624. 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)
  10625. var dat map[string]interface{}
  10626. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10627. fmt.Println(dat)
  10628. } else {
  10629. fmt.Println(err)
  10630. }
  10631. saveLog(result, request, "2202", "退号")
  10632. userJSONBytes, _ := json.Marshal(dat)
  10633. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10634. utils.ErrorLog("解析失败:%v", err)
  10635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10636. return
  10637. }
  10638. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10639. 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, "")
  10640. var dat map[string]interface{}
  10641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10642. fmt.Println(dat)
  10643. } else {
  10644. fmt.Println(err)
  10645. }
  10646. saveLog(result, request, "2202", "退号")
  10647. userJSONBytes, _ := json.Marshal(dat)
  10648. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10649. utils.ErrorLog("解析失败:%v", err)
  10650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10651. return
  10652. }
  10653. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10654. 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, "")
  10655. var dat map[string]interface{}
  10656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10657. fmt.Println(dat)
  10658. } else {
  10659. fmt.Println(err)
  10660. }
  10661. saveLog(result, request, "2202", "退号")
  10662. userJSONBytes, _ := json.Marshal(dat)
  10663. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10664. utils.ErrorLog("解析失败:%v", err)
  10665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10666. return
  10667. }
  10668. } else {
  10669. var api3 string
  10670. if miConfig.Code == "H15049901371" {
  10671. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10672. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10674. } else {
  10675. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10676. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10678. }
  10679. resp3, requestErr3 := http.Get(api3)
  10680. if requestErr3 != nil {
  10681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10682. return
  10683. }
  10684. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10685. if ioErr3 != nil {
  10686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10688. return
  10689. }
  10690. var respJSON3 map[string]interface{}
  10691. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10694. return
  10695. }
  10696. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10697. userJSONBytes3, _ := json.Marshal(respJSON3)
  10698. if miConfig.Code == "H15049901371" {
  10699. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10700. utils.ErrorLog("解析失败:%v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10705. res2.Output = resSix10265.Output
  10706. res2.ErrMsg = resSix10265.ErrMsg
  10707. res2.Cainfo = resSix10265.Cainfo
  10708. res2.WarnMsg = resSix10265.WarnMsg
  10709. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10710. res2.Infcode = infocode
  10711. } else {
  10712. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10713. utils.ErrorLog("解析失败:%v", err)
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10715. return
  10716. }
  10717. }
  10718. }
  10719. if res2.Infcode == 0 {
  10720. if err == nil {
  10721. c.ServeSuccessJSON(map[string]interface{}{
  10722. "msg": "退号成功",
  10723. })
  10724. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10725. } else {
  10726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10727. return
  10728. }
  10729. } else {
  10730. c.ServeSuccessJSON(map[string]interface{}{
  10731. "code": -10,
  10732. "msg": res2.ErrMsg,
  10733. })
  10734. }
  10735. } else {
  10736. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10737. //if err == nil {
  10738. // c.ServeSuccessJSON(map[string]interface{}{
  10739. // "msg": "退费成功",
  10740. // })
  10741. //} else {
  10742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10743. // return
  10744. //}
  10745. }
  10746. }
  10747. func (c *HisApiController) RefundDetail() {
  10748. order_id, _ := c.GetInt64("order_id")
  10749. admin_user_id, _ := c.GetInt64("admin_user_id")
  10750. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10751. number := c.GetString("number")
  10752. record_time := c.GetString("record_time")
  10753. patient_id, _ := c.GetInt64("patient_id")
  10754. //med_type, _ := c.GetInt64("med_type")
  10755. timeLayout := "2006-01-02"
  10756. loc, _ := time.LoadLocation("Local")
  10757. adminUser := c.GetAdminUserInfo()
  10758. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10759. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10760. fmt.Println(err)
  10761. if err != nil {
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10763. return
  10764. }
  10765. recordDateTime := theTime.Unix()
  10766. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10767. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10768. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10769. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10770. var order models.HisOrder
  10771. order, _ = service.GetHisOrderByID(order_id)
  10772. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10773. if config.IsOpen == 1 { //对接了医保,走医保流程
  10774. var res2 ResultSix
  10775. if miConfig.MdtrtareaAdmvs == "421300" {
  10776. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10777. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10779. resp3, requestErr3 := http.Get(api3)
  10780. if requestErr3 != nil {
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10785. if ioErr3 != nil {
  10786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. var respJSON3 map[string]interface{}
  10791. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10794. return
  10795. }
  10796. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10797. userJSONBytes3, _ := json.Marshal(respJSON3)
  10798. fmt.Println("log")
  10799. fmt.Println(string(userJSONBytes3))
  10800. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10801. utils.ErrorLog("解析失败:%v", err)
  10802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10803. return
  10804. }
  10805. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10806. if err == nil {
  10807. c.ServeSuccessJSON(map[string]interface{}{
  10808. "msg": "撤销明细成功",
  10809. })
  10810. return
  10811. } else {
  10812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10813. return
  10814. }
  10815. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10816. var resSix10265 ResultSix10265
  10817. var api3 string
  10818. if miConfig.MdtrtareaAdmvs == "320921" {
  10819. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10820. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10822. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10823. } else {
  10824. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10825. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10826. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10828. }
  10829. resp3, requestErr3 := http.Get(api3)
  10830. if requestErr3 != nil {
  10831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10832. return
  10833. }
  10834. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10835. if ioErr3 != nil {
  10836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10838. return
  10839. }
  10840. var respJSON3 map[string]interface{}
  10841. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10844. return
  10845. }
  10846. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10847. userJSONBytes3, _ := json.Marshal(respJSON3)
  10848. fmt.Println("log")
  10849. fmt.Println(string(userJSONBytes3))
  10850. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10851. utils.ErrorLog("解析失败:%v", err)
  10852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10853. return
  10854. }
  10855. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10856. res2.Output = resSix10265.Output
  10857. res2.ErrMsg = resSix10265.ErrMsg
  10858. res2.Cainfo = resSix10265.Cainfo
  10859. res2.WarnMsg = resSix10265.WarnMsg
  10860. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10861. res2.Infcode = infocode
  10862. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10863. if err == nil {
  10864. c.ServeSuccessJSON(map[string]interface{}{
  10865. "msg": "撤销明细成功",
  10866. })
  10867. return
  10868. } else {
  10869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10870. return
  10871. }
  10872. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10873. 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)
  10874. var dat map[string]interface{}
  10875. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10876. fmt.Println(dat)
  10877. } else {
  10878. fmt.Println(err)
  10879. }
  10880. saveLog(result2, src_request, "2205", "撤销明细")
  10881. userJSONBytes, _ := json.Marshal(dat)
  10882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10883. utils.ErrorLog("解析失败:%v", err)
  10884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10885. return
  10886. }
  10887. if res2.Infcode == 0 {
  10888. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10889. if err == nil {
  10890. c.ServeSuccessJSON(map[string]interface{}{
  10891. "msg": "撤销明细成功",
  10892. })
  10893. return
  10894. } else {
  10895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10896. return
  10897. }
  10898. } else {
  10899. c.ServeSuccessJSON(map[string]interface{}{
  10900. "code": -10,
  10901. "msg": res2.ErrMsg,
  10902. })
  10903. }
  10904. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10905. 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, "")
  10906. var dat map[string]interface{}
  10907. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10908. fmt.Println(dat)
  10909. } else {
  10910. fmt.Println(err)
  10911. }
  10912. saveLog(result2, src_request, "2205", "撤销明细")
  10913. userJSONBytes, _ := json.Marshal(dat)
  10914. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10915. utils.ErrorLog("解析失败:%v", err)
  10916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10917. return
  10918. }
  10919. if res2.Infcode == 0 {
  10920. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10921. if err == nil {
  10922. c.ServeSuccessJSON(map[string]interface{}{
  10923. "msg": "撤销明细成功",
  10924. })
  10925. return
  10926. } else {
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. } else {
  10931. c.ServeSuccessJSON(map[string]interface{}{
  10932. "code": -10,
  10933. "msg": res2.ErrMsg,
  10934. })
  10935. }
  10936. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10937. 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, "")
  10938. var dat map[string]interface{}
  10939. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10940. fmt.Println(dat)
  10941. } else {
  10942. fmt.Println(err)
  10943. }
  10944. saveLog(result2, src_request, "2205", "撤销明细")
  10945. userJSONBytes, _ := json.Marshal(dat)
  10946. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10947. utils.ErrorLog("解析失败:%v", err)
  10948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10949. return
  10950. }
  10951. if res2.Infcode == 0 {
  10952. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10953. if err == nil {
  10954. c.ServeSuccessJSON(map[string]interface{}{
  10955. "msg": "撤销明细成功",
  10956. })
  10957. return
  10958. } else {
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. } else {
  10963. c.ServeSuccessJSON(map[string]interface{}{
  10964. "code": -10,
  10965. "msg": res2.ErrMsg,
  10966. })
  10967. }
  10968. } else {
  10969. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  10970. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10972. resp2, requestErr2 := http.Get(api2)
  10973. if requestErr2 != nil {
  10974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10975. return
  10976. }
  10977. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10978. if ioErr2 != nil {
  10979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10981. return
  10982. }
  10983. var respJSON2 map[string]interface{}
  10984. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10990. if err == nil {
  10991. c.ServeSuccessJSON(map[string]interface{}{
  10992. "msg": "撤销明细成功",
  10993. })
  10994. return
  10995. } else {
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. return
  10998. }
  10999. }
  11000. } else {
  11001. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11002. if err == nil {
  11003. c.ServeSuccessJSON(map[string]interface{}{
  11004. "msg": "退费成功",
  11005. })
  11006. } else {
  11007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11008. return
  11009. }
  11010. }
  11011. }
  11012. //对账
  11013. func (c *HisApiController) GetCheckAccount() {
  11014. start_time := c.GetString("start_time")
  11015. end_time := c.GetString("end_time")
  11016. insutype := c.GetString("insutype")
  11017. clr_type := c.GetString("clr_type")
  11018. clr_org := c.GetString("clr_optins")
  11019. admin_user_id, _ := c.GetInt64("admin_user_id")
  11020. adminUser := c.GetAdminUserInfo()
  11021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11022. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11023. if len(clr_org) == 0 {
  11024. clr_org = miConfig.MdtrtareaAdmvs
  11025. }
  11026. timeLayout := "2006-01-02"
  11027. loc, _ := time.LoadLocation("Local")
  11028. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11029. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11030. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11031. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11032. fixmedins_setl_cnt := int64(len(orders))
  11033. var medfee_sumamt float64
  11034. var acct_pay float64
  11035. var fund_pay_sumamt float64
  11036. for _, item := range orders {
  11037. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11038. acct_pay = acct_pay + item.AcctPay
  11039. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11040. }
  11041. var user_name string
  11042. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11043. if role.ID == 0 {
  11044. user_name = "xxx"
  11045. } else {
  11046. user_name = role.UserName
  11047. }
  11048. var res ResultEight
  11049. var res10188 ResultEightFor10188
  11050. if config.IsOpen == 1 {
  11051. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11052. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11053. "insutype=" + insutype +
  11054. "&clr_type=" + clr_type +
  11055. "&setl_optins=" + clr_org +
  11056. "&stmt_begndate=" + start_time +
  11057. "&stm_enddate=" + end_time +
  11058. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11059. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11060. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11061. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11062. "&fixmedins_code=" + miConfig.Code +
  11063. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11064. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11065. "&secret_key=" + miConfig.SecretKey +
  11066. "&org_name=" + miConfig.OrgName +
  11067. "&doctor=" + user_name +
  11068. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11069. fmt.Println(api)
  11070. resp, requestErr := http.Get(api)
  11071. if requestErr != nil {
  11072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11073. return
  11074. }
  11075. body, ioErr := ioutil.ReadAll(resp.Body)
  11076. fmt.Println(body)
  11077. if ioErr != nil {
  11078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return
  11081. }
  11082. var respJSON map[string]interface{}
  11083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11086. return
  11087. }
  11088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11089. userJSONBytes, _ := json.Marshal(respJSON)
  11090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11091. utils.ErrorLog("解析失败:%v", err)
  11092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11093. return
  11094. }
  11095. res.InfRefmsgid = res10188.InfRefmsgid
  11096. res.Output = res10188.Output
  11097. res.ErrMsg = res10188.ErrMsg
  11098. res.Cainfo = res10188.Cainfo
  11099. res.WarnMsg = res10188.WarnMsg
  11100. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11101. res.Infcode = infocode
  11102. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11103. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11104. "insutype=" + insutype +
  11105. "&clr_type=" + "21" +
  11106. "&setl_optins=" + clr_org +
  11107. "&stmt_begndate=" + start_time +
  11108. "&stm_enddate=" + end_time +
  11109. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11110. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11111. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11112. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11113. "&fixmedins_code=" + miConfig.Code +
  11114. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11115. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11116. "&secret_key=" + miConfig.SecretKey +
  11117. "&org_name=" + miConfig.OrgName +
  11118. "&doctor=" + user_name
  11119. resp, requestErr := http.Get(api)
  11120. if requestErr != nil {
  11121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11122. return
  11123. }
  11124. body, ioErr := ioutil.ReadAll(resp.Body)
  11125. if ioErr != nil {
  11126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11128. return
  11129. }
  11130. var respJSON map[string]interface{}
  11131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11134. return
  11135. }
  11136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11137. result, _ := json.Marshal(respJSON)
  11138. fmt.Println("log")
  11139. fmt.Println(string(result))
  11140. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11141. utils.ErrorLog("解析失败:%v", err)
  11142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11143. return
  11144. }
  11145. res.InfRefmsgid = res10188.InfRefmsgid
  11146. res.Output = res10188.Output
  11147. res.ErrMsg = res10188.ErrMsg
  11148. res.Cainfo = res10188.Cainfo
  11149. res.WarnMsg = res10188.WarnMsg
  11150. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11151. res.Infcode = infocode
  11152. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11153. var baseParams models.BaseParams
  11154. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11155. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11156. baseParams.SecretKey = miConfig.SecretKey
  11157. baseParams.OrgName = miConfig.OrgName
  11158. baseParams.FixmedinsCode = miConfig.Code
  11159. baseParams.EncKey = miConfig.EncKey
  11160. baseParams.AppSecret = miConfig.AppSecret
  11161. baseParams.SignKey = miConfig.SignKey
  11162. baseParams.AppID = miConfig.Code
  11163. baseParams.Doctor = role.UserName
  11164. baseParams.RequestUrl = miConfig.Url
  11165. businessParams := models.BusinessParams{
  11166. Insutype: insutype,
  11167. ClrType: clr_type,
  11168. SetlOptins: clr_org,
  11169. StmtBegndate: start_time,
  11170. StmtEnddate: end_time,
  11171. MedfeeSumamt: medfee_sumamt,
  11172. FundPaySumamt: fund_pay_sumamt,
  11173. AcctPay: acct_pay,
  11174. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11175. }
  11176. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11177. fmt.Println(requestLog)
  11178. fmt.Println(result)
  11179. fmt.Println(err_msg)
  11180. var dat map[string]interface{}
  11181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11182. fmt.Println(dat)
  11183. } else {
  11184. fmt.Println(err)
  11185. }
  11186. userJSONBytes, _ := json.Marshal(dat)
  11187. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11188. utils.ErrorLog("解析失败:%v", err)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return
  11191. }
  11192. } else if miConfig.MdtrtareaAdmvs == "" {
  11193. var baseParams models.BaseParams
  11194. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11195. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11196. baseParams.SecretKey = miConfig.SecretKey
  11197. baseParams.OrgName = miConfig.OrgName
  11198. baseParams.FixmedinsCode = miConfig.Code
  11199. baseParams.EncKey = miConfig.EncKey
  11200. baseParams.AppSecret = miConfig.AppSecret
  11201. baseParams.SignKey = miConfig.SignKey
  11202. baseParams.AppID = miConfig.Code
  11203. baseParams.Doctor = role.UserName
  11204. baseParams.RequestUrl = miConfig.Url
  11205. businessParams := models.BusinessParams{
  11206. Insutype: insutype,
  11207. ClrType: clr_type,
  11208. SetlOptins: clr_org,
  11209. StmtBegndate: start_time,
  11210. StmtEnddate: end_time,
  11211. MedfeeSumamt: medfee_sumamt,
  11212. FundPaySumamt: fund_pay_sumamt,
  11213. AcctPay: acct_pay,
  11214. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11215. }
  11216. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11217. fmt.Println(requestLog)
  11218. fmt.Println(result)
  11219. fmt.Println(err_msg)
  11220. var dat map[string]interface{}
  11221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11222. fmt.Println(dat)
  11223. } else {
  11224. fmt.Println(err)
  11225. }
  11226. userJSONBytes, _ := json.Marshal(dat)
  11227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11228. utils.ErrorLog("解析失败:%v", err)
  11229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11230. return
  11231. }
  11232. } else {
  11233. if len(clr_type) == 0 {
  11234. clr_type = "11"
  11235. }
  11236. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11237. "insutype=" + insutype +
  11238. "&clr_type=" + clr_type +
  11239. "&setl_optins=" + clr_org +
  11240. "&stmt_begndate=" + start_time +
  11241. "&stm_enddate=" + end_time +
  11242. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11243. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11244. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11245. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11246. "&fixmedins_code=" + miConfig.Code +
  11247. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11248. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11249. "&secret_key=" + miConfig.SecretKey +
  11250. "&org_name=" + miConfig.OrgName +
  11251. "&doctor=" + user_name
  11252. fmt.Println(api)
  11253. resp, requestErr := http.Get(api)
  11254. if requestErr != nil {
  11255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11256. return
  11257. }
  11258. body, ioErr := ioutil.ReadAll(resp.Body)
  11259. fmt.Println(body)
  11260. if ioErr != nil {
  11261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11263. return
  11264. }
  11265. var respJSON map[string]interface{}
  11266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11269. return
  11270. }
  11271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11272. userJSONBytes, _ := json.Marshal(respJSON)
  11273. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11274. utils.ErrorLog("解析失败:%v", err)
  11275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11276. return
  11277. }
  11278. }
  11279. if res.Infcode == 0 {
  11280. if res.Output.Stmtinfo.StmtRslt == "0" {
  11281. micc := &models.MedicalInsuranceCostCompare{
  11282. StartTime: startime.Unix(),
  11283. EndTime: endtime.Unix(),
  11284. Insutype: insutype,
  11285. CheckType: 1,
  11286. Num: fixmedins_setl_cnt,
  11287. Mtime: time.Now().Unix(),
  11288. Status: 1,
  11289. UserOrgId: adminUser.CurrentOrgId,
  11290. CostTotal: medfee_sumamt,
  11291. FuncTotal: fund_pay_sumamt,
  11292. PsnPay: acct_pay,
  11293. Creator: admin_user_id,
  11294. Ctime: time.Now().Unix(),
  11295. ClrType: clr_type,
  11296. }
  11297. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11298. if err == nil {
  11299. c.ServeSuccessJSON(map[string]interface{}{
  11300. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11301. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11302. })
  11303. } else {
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. }
  11306. } else {
  11307. c.ServeSuccessJSON(map[string]interface{}{
  11308. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11309. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11310. })
  11311. }
  11312. } else {
  11313. c.ServeSuccessJSON(map[string]interface{}{
  11314. "code": -10,
  11315. "msg": res.ErrMsg,
  11316. })
  11317. }
  11318. }
  11319. }
  11320. func (c *HisApiController) Check310() {
  11321. adminUser := c.GetAdminUserInfo()
  11322. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11323. var user_name string
  11324. user_name = "高慧裕"
  11325. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11326. "insutype=" + "310" +
  11327. "&clr_type=" + "" +
  11328. "&setl_optins=" + "441202" +
  11329. "&stmt_begndate=" + "2022-03-01" +
  11330. "&stm_enddate=" + "2022-03-31" +
  11331. "&medfee_sumamt=" + "194930.12" +
  11332. "&fund_pay_sumamt=" + "188741.46" +
  11333. "&acct_pay=" + "0" +
  11334. "&fixmedins_setl_cnt=" + "452" +
  11335. "&fixmedins_code=" + miConfig.Code +
  11336. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11337. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11338. "&secret_key=" + miConfig.SecretKey +
  11339. "&org_name=" + miConfig.OrgName +
  11340. "&doctor=" + user_name
  11341. fmt.Println(api)
  11342. resp, requestErr := http.Get(api)
  11343. if requestErr != nil {
  11344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11345. return
  11346. }
  11347. body, ioErr := ioutil.ReadAll(resp.Body)
  11348. fmt.Println(body)
  11349. if ioErr != nil {
  11350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11352. return
  11353. }
  11354. var respJSON map[string]interface{}
  11355. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11358. return
  11359. }
  11360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11361. userJSONBytes, _ := json.Marshal(respJSON)
  11362. var res ResultEight
  11363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11364. utils.ErrorLog("解析失败:%v", err)
  11365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11366. return
  11367. }
  11368. }
  11369. func (c *HisApiController) Check390() {
  11370. adminUser := c.GetAdminUserInfo()
  11371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11372. var user_name string
  11373. user_name = "高慧裕"
  11374. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11375. "insutype=" + "390" +
  11376. "&clr_type=" + "" +
  11377. "&setl_optins=" + "441202" +
  11378. "&stmt_begndate=" + "2022-03-01" +
  11379. "&stm_enddate=" + "2022-03-31" +
  11380. "&medfee_sumamt=" + "1068448.89" +
  11381. "&fund_pay_sumamt=" + "1014677.62" +
  11382. "&acct_pay=" + "0" +
  11383. "&fixmedins_setl_cnt=" + "1950" +
  11384. "&fixmedins_code=" + miConfig.Code +
  11385. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11386. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11387. "&secret_key=" + miConfig.SecretKey +
  11388. "&org_name=" + miConfig.OrgName +
  11389. "&doctor=" + user_name
  11390. fmt.Println(api)
  11391. resp, requestErr := http.Get(api)
  11392. if requestErr != nil {
  11393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11394. return
  11395. }
  11396. body, ioErr := ioutil.ReadAll(resp.Body)
  11397. fmt.Println(body)
  11398. if ioErr != nil {
  11399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11401. return
  11402. }
  11403. var respJSON map[string]interface{}
  11404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11407. return
  11408. }
  11409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11410. userJSONBytes, _ := json.Marshal(respJSON)
  11411. var res ResultEight
  11412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11413. utils.ErrorLog("解析失败:%v", err)
  11414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11415. return
  11416. }
  11417. }
  11418. //对账明细
  11419. func (c *HisApiController) GetCheckDetailAccount() {
  11420. start_time := c.GetString("start_time")
  11421. end_time := c.GetString("end_time")
  11422. admin_user_id, _ := c.GetInt64("admin_user_id")
  11423. adminUser := c.GetAdminUserInfo()
  11424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11426. timeLayout := "2006-01-02"
  11427. loc, _ := time.LoadLocation("Local")
  11428. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11429. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11430. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11431. rand.Seed(time.Now().UnixNano())
  11432. num := rand.Intn(30000)
  11433. Mkdir(miConfig.OrgName)
  11434. file := strconv.FormatInt(int64(num), 10)
  11435. file_name := file + ".txt"
  11436. zip_name := file + ".zip"
  11437. zip_path := miConfig.OrgName + "/" + zip_name
  11438. file_path := miConfig.OrgName + "/" + file_name
  11439. decimal.DivisionPrecision = 2
  11440. var medfee_sumamt float64
  11441. var psn_cash_pay float64
  11442. var fund_pay_sumamt float64
  11443. fixmedins_setl_cnt := int64(len(orders))
  11444. for _, item := range orders {
  11445. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11446. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11447. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11448. }
  11449. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11450. defer f.Close()
  11451. if err != nil {
  11452. fmt.Println(err.Error())
  11453. } else {
  11454. for _, item := range orders {
  11455. var refd_setl_flag string
  11456. if item.OrderStatus == 2 {
  11457. refd_setl_flag = "0"
  11458. var str string
  11459. str = item.SetlId + " " +
  11460. item.MdtrtId + " " +
  11461. item.PsnNo + " " +
  11462. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11463. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11464. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11465. _, err = f.Write([]byte(str))
  11466. }
  11467. if item.OrderStatus == 3 {
  11468. var str string
  11469. str = item.SetlId + " " +
  11470. item.MdtrtId + " " +
  11471. item.PsnNo + " " +
  11472. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11473. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11474. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11475. _, err = f.Write([]byte(str))
  11476. var str2 string
  11477. str2 = item.SetlId + " " +
  11478. item.MdtrtId + " " +
  11479. item.PsnNo + " " +
  11480. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11481. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11482. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11483. _, err = f.Write([]byte(str2))
  11484. }
  11485. }
  11486. }
  11487. Zip(file_path, zip_path)
  11488. fmt.Println(ReadFile(zip_path))
  11489. fmt.Println(string(ReadFile(zip_path)))
  11490. if config.IsOpen == 1 {
  11491. var user_name string
  11492. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11493. if role.ID == 0 {
  11494. user_name = "管理员"
  11495. } else {
  11496. user_name = role.UserName
  11497. }
  11498. baseParams := models.BaseParams{
  11499. SecretKey: miConfig.SecretKey,
  11500. FixmedinsCode: miConfig.Code,
  11501. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11502. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11503. OrgName: miConfig.OrgName,
  11504. Doctor: user_name,
  11505. }
  11506. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11507. var dat map[string]interface{}
  11508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11509. fmt.Println(dat)
  11510. } else {
  11511. fmt.Println(err)
  11512. }
  11513. userJSONBytes, _ := json.Marshal(dat)
  11514. var res ResultNine
  11515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11516. utils.ErrorLog("解析失败:%v", err)
  11517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11518. return
  11519. }
  11520. if res.Infcode == 0 {
  11521. fileNo := res.Output.FileQuryNo
  11522. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11523. "file_qury_no=" + fileNo +
  11524. "&setl_optins=" + "定点医保中心" +
  11525. "&stmt_begndate=" + start_time +
  11526. "&stm_enddate=" + end_time +
  11527. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11528. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11529. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11530. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11531. "&fixmedins_code=" + miConfig.Code +
  11532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11533. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11534. "&secret_key=" + miConfig.SecretKey +
  11535. "&org_name=" + miConfig.OrgName +
  11536. "&doctor=" + user_name
  11537. resp, requestErr := http.Get(api)
  11538. if requestErr != nil {
  11539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11540. return
  11541. }
  11542. body, ioErr := ioutil.ReadAll(resp.Body)
  11543. if ioErr != nil {
  11544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. var respJSON map[string]interface{}
  11549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11555. userJSONBytes, _ := json.Marshal(respJSON)
  11556. var res ResultTen
  11557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11558. utils.ErrorLog("解析失败:%v", err)
  11559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11560. return
  11561. }
  11562. if res.Infcode == 0 {
  11563. service.Gdyb9102(baseParams, zip_name, fileNo)
  11564. micc := &models.MedicalInsuranceCostCompare{
  11565. StartTime: startime.Unix(),
  11566. EndTime: endtime.Unix(),
  11567. Insutype: "0",
  11568. CheckType: 2,
  11569. Num: fixmedins_setl_cnt,
  11570. Mtime: time.Now().Unix(),
  11571. Status: 1,
  11572. UserOrgId: adminUser.CurrentOrgId,
  11573. CostTotal: medfee_sumamt,
  11574. FuncTotal: fund_pay_sumamt,
  11575. PsnPay: psn_cash_pay,
  11576. Creator: admin_user_id,
  11577. Ctime: time.Now().Unix(),
  11578. }
  11579. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11580. c.ServeSuccessJSON(map[string]interface{}{
  11581. "msg": "明细对账成功",
  11582. })
  11583. }
  11584. } else {
  11585. }
  11586. }
  11587. }
  11588. type CustomOrderInfo struct {
  11589. Name string
  11590. Spec string
  11591. Unit string
  11592. Count float64
  11593. Price float64
  11594. Total float64
  11595. }
  11596. func (c *HisApiController) GetSettleAccounts() {
  11597. //id, _ := c.GetInt64("id")
  11598. //record_time := c.GetString("record_time")
  11599. order_id, _ := c.GetInt64("order_id")
  11600. admin_user_id, _ := c.GetInt64("admin_user_id")
  11601. //timeLayout := "2006-01-02"
  11602. //loc, _ := time.LoadLocation("Local")
  11603. //
  11604. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11605. //if err != nil {
  11606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11607. // return
  11608. //}
  11609. //recordDateTime := theTime.Unix()
  11610. adminUser := c.GetAdminUserInfo()
  11611. order, _ := service.GetHisOrderByID(order_id)
  11612. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11613. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11614. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11615. orderInfos = append(orderInfos, orderInfos_two...)
  11616. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11617. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11618. var diagnosis_ids []string
  11619. if his.ID > 0 {
  11620. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11621. } else {
  11622. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11623. }
  11624. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11625. var dia_config []*models.HisXtDiagnoseConfig
  11626. var name string
  11627. for _, item := range diagnosis_ids {
  11628. id, _ := strconv.ParseInt(item, 10, 64)
  11629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11630. dia_config = append(dia_config, &diagnosisConfig)
  11631. if len(name) == 0 {
  11632. name = diagnosisConfig.ClassName
  11633. } else {
  11634. name = name + "," + diagnosisConfig.ClassName
  11635. }
  11636. }
  11637. var bedCostTotal float64 = 0 //床位总费
  11638. var bedCostSelfTotal float64 = 0 //床位自费
  11639. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11640. var operationCostTotal float64 = 0 //手术费
  11641. var operationCostSelfTotal float64 = 0 //手术费
  11642. var operationCostPartSelfTotal float64 = 0 //手术费
  11643. var otherCostTotal float64 = 0 //其他费用
  11644. var otherCostSelfTotal float64 = 0 //其他费用
  11645. var otherCostPartSelfTotal float64 = 0 //其他费用
  11646. var materialCostTotal float64 = 0 //材料费
  11647. var materialCostSelfTotal float64 = 0 //材料费
  11648. var materialCostPartSelfTotal float64 = 0 //材料费
  11649. var westernMedicineCostTotal float64 = 0 //西药费
  11650. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11651. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11652. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11653. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11654. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11655. var checkCostTotal float64 = 0 //检查费
  11656. var checkCostSelfTotal float64 = 0 //检查费
  11657. var checkCostPartSelfTotal float64 = 0 //检查费
  11658. var laboratoryCostTotal float64 = 0 //化验费
  11659. var laboratoryCostSelfTotal float64 = 0 //化验费
  11660. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11661. var treatCostTotal float64 = 0 //治疗费用
  11662. var treatCostSelfTotal float64 = 0 //治疗费用
  11663. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11664. decimal.DivisionPrecision = 2
  11665. for _, item := range orderInfos {
  11666. if item.MedChrgitmType == "01" { //床位费
  11667. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11668. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11669. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11670. }
  11671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11672. if item.MedChrgitmType == "03" { //检查费
  11673. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11674. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11675. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11676. }
  11677. } else {
  11678. if item.MedChrgitmType == "03" { //检查费
  11679. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11680. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11681. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11682. }
  11683. }
  11684. if item.MedChrgitmType == "04" { //化验费
  11685. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11686. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11687. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11688. }
  11689. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11690. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11691. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11692. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11693. }
  11694. if item.MedChrgitmType == "06" { //手术费
  11695. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11696. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11697. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11698. }
  11699. if item.MedChrgitmType == "08" { //材料费
  11700. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11701. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11702. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11703. }
  11704. if item.MedChrgitmType == "09" { //西药费
  11705. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11706. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11707. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11708. }
  11709. if item.MedChrgitmType == "11" { //中成费
  11710. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11711. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11712. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11713. }
  11714. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11715. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11716. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11717. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11718. }
  11719. }
  11720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11721. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11722. var user_name string
  11723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11724. if role.ID == 0 {
  11725. user_name = "管理员"
  11726. } else {
  11727. user_name = role.UserName
  11728. }
  11729. baseParams := models.BaseParams{
  11730. SecretKey: miConfig.SecretKey,
  11731. FixmedinsCode: miConfig.Code,
  11732. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11733. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11734. OrgName: miConfig.OrgName,
  11735. Doctor: user_name,
  11736. RequestUrl: miConfig.Url,
  11737. AccessKey: miConfig.AccessKey,
  11738. }
  11739. businessParams := models.BusinessParams{
  11740. PsnNo: order.PsnNo,
  11741. MdtrtId: order.MdtrtId,
  11742. SetlId: order.SetlId,
  11743. }
  11744. var res ResultEleven
  11745. var resEleven10265 ResultEleven10265
  11746. if config.IsOpen == 1 {
  11747. if miConfig.MdtrtareaAdmvs == "421300" {
  11748. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11749. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11750. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11751. resp, requestErr := http.Get(api)
  11752. if requestErr != nil {
  11753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11754. return
  11755. }
  11756. body, ioErr := ioutil.ReadAll(resp.Body)
  11757. if ioErr != nil {
  11758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11760. return
  11761. }
  11762. var respJSON map[string]interface{}
  11763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11766. return
  11767. }
  11768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11769. result, _ := json.Marshal(respJSON)
  11770. fmt.Println("log")
  11771. fmt.Println(string(result))
  11772. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11773. utils.ErrorLog("解析失败:%v", err)
  11774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11775. return
  11776. }
  11777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11778. var api string
  11779. if miConfig.MdtrtareaAdmvs == "320921" {
  11780. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11781. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11782. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11783. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11784. } else {
  11785. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11786. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11787. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11789. }
  11790. resp, requestErr := http.Get(api)
  11791. if requestErr != nil {
  11792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11793. return
  11794. }
  11795. body, ioErr := ioutil.ReadAll(resp.Body)
  11796. if ioErr != nil {
  11797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return
  11800. }
  11801. var respJSON map[string]interface{}
  11802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11805. return
  11806. }
  11807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11808. result, _ := json.Marshal(respJSON)
  11809. fmt.Println("log")
  11810. fmt.Println(string(result))
  11811. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11812. utils.ErrorLog("解析失败:%v", err)
  11813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11814. return
  11815. }
  11816. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11817. res.Output = resEleven10265.Output
  11818. res.ErrMsg = resEleven10265.ErrMsg
  11819. res.Cainfo = resEleven10265.Cainfo
  11820. res.WarnMsg = resEleven10265.WarnMsg
  11821. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11822. res.Infcode = infocode
  11823. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11824. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11825. saveLog(result, requestLog, "5203", "结算单")
  11826. var dat map[string]interface{}
  11827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11828. fmt.Println(dat)
  11829. } else {
  11830. fmt.Println(err)
  11831. }
  11832. userJSONBytes, _ := json.Marshal(dat)
  11833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11834. utils.ErrorLog("解析失败:%v", err)
  11835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11836. return
  11837. }
  11838. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11839. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  11840. saveLog(result, requestLog, "5203", "结算单")
  11841. var dat map[string]interface{}
  11842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11843. fmt.Println(dat)
  11844. } else {
  11845. fmt.Println(err)
  11846. }
  11847. userJSONBytes, _ := json.Marshal(dat)
  11848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11849. utils.ErrorLog("解析失败:%v", err)
  11850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11851. return
  11852. }
  11853. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11854. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  11855. saveLog(result, requestLog, "5203", "结算单")
  11856. var dat map[string]interface{}
  11857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11858. fmt.Println(dat)
  11859. } else {
  11860. fmt.Println(err)
  11861. }
  11862. userJSONBytes, _ := json.Marshal(dat)
  11863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11864. utils.ErrorLog("解析失败:%v", err)
  11865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11866. return
  11867. }
  11868. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11869. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11870. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11871. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11872. resp, requestErr := http.Get(api)
  11873. if requestErr != nil {
  11874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11875. return
  11876. }
  11877. body, ioErr := ioutil.ReadAll(resp.Body)
  11878. if ioErr != nil {
  11879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. return
  11882. }
  11883. var respJSON map[string]interface{}
  11884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11887. return
  11888. }
  11889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11890. result, _ := json.Marshal(respJSON)
  11891. fmt.Println("log")
  11892. fmt.Println(string(result))
  11893. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11894. utils.ErrorLog("解析失败:%v", err)
  11895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11896. return
  11897. }
  11898. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11899. res.Output = resEleven10265.Output
  11900. res.ErrMsg = resEleven10265.ErrMsg
  11901. res.Cainfo = resEleven10265.Cainfo
  11902. res.WarnMsg = resEleven10265.WarnMsg
  11903. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11904. res.Infcode = infocode
  11905. } else {
  11906. result := service.Gdyb5203(baseParams, businessParams)
  11907. //service.Gdyb5204(baseParams, businessParams)
  11908. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  11909. var dat map[string]interface{}
  11910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11911. fmt.Println(dat)
  11912. } else {
  11913. fmt.Println(err)
  11914. }
  11915. userJSONBytes, _ := json.Marshal(dat)
  11916. if miConfig.Code == "H15049901371" {
  11917. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  11918. utils.ErrorLog("解析失败:%v", err)
  11919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11920. return
  11921. }
  11922. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11923. res.Output = resEleven10265.Output
  11924. res.ErrMsg = resEleven10265.ErrMsg
  11925. res.Cainfo = resEleven10265.Cainfo
  11926. res.WarnMsg = resEleven10265.WarnMsg
  11927. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11928. res.Infcode = infocode
  11929. } else {
  11930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11931. utils.ErrorLog("解析失败:%v", err)
  11932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11933. return
  11934. }
  11935. }
  11936. }
  11937. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11938. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  11939. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  11940. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11941. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  11942. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11943. var doctor_name string
  11944. if roles.ID == 0 {
  11945. doctor_name = "管理员"
  11946. } else {
  11947. doctor_name = roles.UserName
  11948. }
  11949. yiliao_leibie := ""
  11950. switch order.MedType {
  11951. case "11":
  11952. yiliao_leibie = "普通门诊"
  11953. break
  11954. case "12":
  11955. yiliao_leibie = "门诊挂号"
  11956. break
  11957. case "13":
  11958. yiliao_leibie = "急诊"
  11959. break
  11960. case "14":
  11961. yiliao_leibie = "门诊特殊病"
  11962. break
  11963. case "15":
  11964. yiliao_leibie = "门诊统筹"
  11965. break
  11966. case "16":
  11967. yiliao_leibie = "门诊慢性病"
  11968. break
  11969. case "21":
  11970. yiliao_leibie = "普通住院"
  11971. break
  11972. }
  11973. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11974. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  11975. if res.Infcode == 0 {
  11976. c.ServeSuccessJSON(map[string]interface{}{
  11977. "diagnosis": name,
  11978. "order_infos": orderInfos,
  11979. "number": order.MdtrtId,
  11980. "date": order.SettleAccountsDate,
  11981. "charge_admin": charge_admin,
  11982. "printor_admin": printor_admin,
  11983. "info": res.Output.Setlinfo,
  11984. "order": order,
  11985. "bedCostTotal": bedCostTotal,
  11986. "bedCostSelfTotal": bedCostSelfTotal,
  11987. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  11988. "operationCostTotal": operationCostTotal,
  11989. "operationCostSelfTotal": operationCostSelfTotal,
  11990. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  11991. "otherCostTotal": otherCostTotal,
  11992. "otherCostSelfTotal": otherCostSelfTotal,
  11993. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  11994. "materialCostTotal": materialCostTotal,
  11995. "materialCostSelfTotal": materialCostSelfTotal,
  11996. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  11997. "westernMedicineCostTotal": westernMedicineCostTotal,
  11998. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  11999. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12000. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12001. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12002. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12003. "checkCostTotal": checkCostTotal,
  12004. "checkCostSelfTotal": checkCostSelfTotal,
  12005. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12006. "laboratoryCostTotal": laboratoryCostTotal,
  12007. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12008. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12009. "treatCostTotal": treatCostTotal,
  12010. "treatCostSelfTotal": treatCostSelfTotal,
  12011. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12012. "doctor_info": doctor_info,
  12013. "doctor_code": adminRole_two.DoctorCode,
  12014. "doctor_name": doctor_name,
  12015. "health_card_no": order.PsnNo,
  12016. "department": departments.Name,
  12017. "yiliao_leibie": yiliao_leibie,
  12018. "after_money": order.AccountPrice,
  12019. "patient": patient,
  12020. "org_name": miConfig.OrgName,
  12021. "org_code": miConfig.Code,
  12022. "order_number": order.Number,
  12023. "his_hospital": his_hospital,
  12024. "his": his,
  12025. "dia_config": dia_config,
  12026. //"check_order_info": cus_slice,
  12027. })
  12028. }
  12029. }
  12030. }
  12031. func (c *HisApiController) CheckTreatment() {
  12032. patient_id, _ := c.GetInt64("patient_id")
  12033. id_card_no := c.GetString("id_card_no")
  12034. insutype := c.GetString("insutype")
  12035. med_type := c.GetString("med_type")
  12036. admin_user_id, _ := c.GetInt64("admin_user_id")
  12037. adminUser := c.GetAdminUserInfo()
  12038. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12039. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12040. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12041. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12042. if miConfig.MdtrtareaAdmvs == "421300" {
  12043. var res ResultTwo
  12044. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12045. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12046. "&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)
  12047. resp, requestErr := http.Get(api)
  12048. if requestErr != nil {
  12049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12050. return
  12051. }
  12052. body, ioErr := ioutil.ReadAll(resp.Body)
  12053. if ioErr != nil {
  12054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. var respJSON map[string]interface{}
  12059. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12065. result, _ := json.Marshal(respJSON)
  12066. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12067. utils.ErrorLog("解析失败:%v", err)
  12068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12069. return
  12070. }
  12071. if res.Infcode == 0 {
  12072. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12073. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12074. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12075. resp, requestErr := http.Get(api)
  12076. if requestErr != nil {
  12077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12078. return
  12079. }
  12080. body, ioErr := ioutil.ReadAll(resp.Body)
  12081. if ioErr != nil {
  12082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12084. return
  12085. }
  12086. var respJSON map[string]interface{}
  12087. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12090. return
  12091. }
  12092. var res Result2001
  12093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12094. result2, _ := json.Marshal(respJSON)
  12095. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12096. utils.ErrorLog("解析失败:%v", err)
  12097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12098. return
  12099. }
  12100. if res.Infcode == 0 {
  12101. c.ServeSuccessJSON(map[string]interface{}{
  12102. "msg": res.Output.Trtinfo,
  12103. })
  12104. }
  12105. } else {
  12106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12107. return
  12108. }
  12109. } else {
  12110. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12111. var dat map[string]interface{}
  12112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12113. fmt.Println(dat)
  12114. } else {
  12115. fmt.Println(err)
  12116. }
  12117. userJSONBytes, _ := json.Marshal(dat)
  12118. var res ResultTwo
  12119. var res10265 ResultTwo10265
  12120. if miConfig.Code == "H15049901371" {
  12121. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12122. utils.ErrorLog("解析失败:%v", err)
  12123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12124. return
  12125. }
  12126. res.ErrMsg = res10265.ErrMsg
  12127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12128. res.Infcode = infocode
  12129. res.Output = res10265.Output
  12130. res.InfRefmsgid = res10265.InfRefmsgid
  12131. } else {
  12132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12133. utils.ErrorLog("解析失败:%v", err)
  12134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12135. return
  12136. }
  12137. }
  12138. var user_name string
  12139. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12140. if role.ID == 0 {
  12141. user_name = "xxx"
  12142. } else {
  12143. user_name = role.UserName
  12144. }
  12145. baseParams := models.BaseParams{
  12146. SecretKey: miConfig.SecretKey,
  12147. FixmedinsCode: miConfig.Code,
  12148. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12149. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12150. OrgName: miConfig.OrgName,
  12151. Doctor: user_name,
  12152. }
  12153. if config.IsOpen == 1 {
  12154. if miConfig.Code == "H15049901371" {
  12155. if med_type == "14" {
  12156. if insutype == "390" {
  12157. med_type = "9933"
  12158. } else if insutype == "310" {
  12159. med_type = "990502"
  12160. }
  12161. } else if med_type == "11" {
  12162. med_type = "11"
  12163. }
  12164. }
  12165. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12166. var dat map[string]interface{}
  12167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12168. fmt.Println(dat)
  12169. } else {
  12170. fmt.Println(err)
  12171. }
  12172. var res Result2001
  12173. var res10265 Result2001Org10265
  12174. if miConfig.Code == "H15049901371" {
  12175. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12176. utils.ErrorLog("解析失败:%v", err)
  12177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12178. return
  12179. }
  12180. res.ErrMsg = res10265.ErrMsg
  12181. res.Output = res10265.Output
  12182. res.InfRefmsgid = res10265.InfRefmsgid
  12183. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12184. res.Infcode = infocode
  12185. } else {
  12186. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12187. utils.ErrorLog("解析失败:%v", err)
  12188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12189. return
  12190. }
  12191. }
  12192. if res.Infcode == 0 {
  12193. c.ServeSuccessJSON(map[string]interface{}{
  12194. "msg": res.Output.Trtinfo,
  12195. })
  12196. }
  12197. }
  12198. }
  12199. }
  12200. //func (c *HisApiController) PutRecord() {
  12201. // id, _ := c.GetInt64("id")
  12202. // record_time := c.GetString("record_time")
  12203. // timeLayout := "2006-01-02"
  12204. // loc, _ := time.LoadLocation("Local")
  12205. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12206. // if err != nil {
  12207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12208. // return
  12209. // }
  12210. // recordDateTime := theTime.Unix()
  12211. //
  12212. // adminInfo := c.GetAdminUserInfo()
  12213. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12214. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12215. //
  12216. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12217. //
  12218. // fmt.Println(miConfig.SecretKey)
  12219. //
  12220. // if patient == nil {
  12221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12222. // return
  12223. // }
  12224. // if len(patient.IdCardNo) == 0 {
  12225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12226. // return
  12227. // }
  12228. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12229. // if config.IsOpen == 1 {
  12230. // 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
  12231. // resp, requestErr := http.Get(api)
  12232. // if requestErr != nil {
  12233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12234. // return
  12235. // }
  12236. // defer resp.Body.Close()
  12237. // body, ioErr := ioutil.ReadAll(resp.Body)
  12238. // if ioErr != nil {
  12239. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. // return
  12242. // }
  12243. // var respJSON map[string]interface{}
  12244. //
  12245. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12246. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. // return
  12249. // }
  12250. //
  12251. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12252. // userJSONBytes, _ := json.Marshal(userJSON)
  12253. // var res ResultTwo
  12254. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12255. // utils.ErrorLog("解析失败:%v", err)
  12256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12257. // return
  12258. // }
  12259. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12260. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12261. // infoStr := string(Iinfos)
  12262. // idetinfoStr := string(Idetinfos)
  12263. //
  12264. // if res.Infcode == 0 {
  12265. // his := models.VMHisPatient{
  12266. // Status: 1,
  12267. // Ctime: time.Now().Unix(),
  12268. // Mtime: time.Now().Unix(),
  12269. // PsnNo: res.Output.Baseinfo.PsnNo,
  12270. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12271. // Certno: res.Output.Baseinfo.Certno,
  12272. // PsnName: res.Output.Baseinfo.PsnName,
  12273. // Gend: res.Output.Baseinfo.Gend,
  12274. // Naty: res.Output.Baseinfo.Naty,
  12275. // Brdy: res.Output.Baseinfo.Brdy,
  12276. // Age: res.Output.Baseinfo.Age,
  12277. // Iinfo: infoStr,
  12278. // Idetinfo: idetinfoStr,
  12279. // PatientId: patient.ID,
  12280. // RecordDate: theTime.Unix(),
  12281. // UserOrgId: adminInfo.CurrentOrgId,
  12282. // AdminUserId: adminInfo.AdminUser.Id,
  12283. // IsReturn: 1,
  12284. // }
  12285. //
  12286. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12287. // //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")
  12288. // //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")
  12289. //
  12290. // //var dat map[string]interface{}
  12291. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12292. // // fmt.Println(dat)
  12293. // //} else {
  12294. // // fmt.Println(err)
  12295. // //}
  12296. //
  12297. // var dat2 map[string]interface{}
  12298. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12299. // fmt.Println(dat2)
  12300. // } else {
  12301. // fmt.Println(err)
  12302. // }
  12303. //
  12304. // } else {
  12305. // adminUser := c.GetAdminUserInfo()
  12306. // errlog := &models.HisOrderError{
  12307. // UserOrgId: adminUser.CurrentOrgId,
  12308. // Ctime: time.Now().Unix(),
  12309. // Mtime: time.Now().Unix(),
  12310. // ErrMsg: res.ErrMsg,
  12311. // Status: 1,
  12312. // PatientId: id,
  12313. // RecordTime: recordDateTime,
  12314. // Stage: 1,
  12315. // }
  12316. // service.CreateErrMsgLog(errlog)
  12317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12318. // return
  12319. // }
  12320. // }
  12321. //
  12322. //}
  12323. //func (c *HisApiController) GetUploadDiag() {
  12324. // id, _ := c.GetInt64("id")
  12325. // record_time := c.GetString("record_time")
  12326. //
  12327. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12328. // sick_type, _ := c.GetInt64("sick_type")
  12329. // reg_type, _ := c.GetInt64("reg_type")
  12330. //
  12331. // timeLayout := "2006-01-02"
  12332. // loc, _ := time.LoadLocation("Local")
  12333. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12334. // if err != nil {
  12335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12336. // return
  12337. // }
  12338. //
  12339. // var patientPrescription models.HisPrescriptionInfo
  12340. // recordDateTime := theTime.Unix()
  12341. // adminInfo := c.GetAdminUserInfo()
  12342. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12343. //
  12344. // if patientPrescription.ID == 0 {
  12345. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12346. // }
  12347. //
  12348. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12349. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12350. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12351. // sickConfig, _ := service.FindSickById(sick_type)
  12352. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12353. //
  12354. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12355. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12356. // "&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 +
  12357. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12358. // resp2, requestErr2 := http.Get(api2)
  12359. // if requestErr2 != nil {
  12360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. // return
  12362. // }
  12363. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12364. // if ioErr2 != nil {
  12365. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. // return
  12368. // }
  12369. // var respJSON2 map[string]interface{}
  12370. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12371. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12373. // return
  12374. // }
  12375. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12376. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12377. //
  12378. // var res2 ResultSix
  12379. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12380. // utils.ErrorLog("解析失败:%v", err)
  12381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12382. // return
  12383. // }
  12384. // if res2.Infcode != 0 {
  12385. // adminUser := c.GetAdminUserInfo()
  12386. // errlog := &models.HisOrderError{
  12387. // UserOrgId: adminUser.CurrentOrgId,
  12388. // Ctime: time.Now().Unix(),
  12389. // Mtime: time.Now().Unix(),
  12390. // ErrMsg: res2.ErrMsg,
  12391. // Status: 1,
  12392. // PatientId: id,
  12393. // RecordTime: recordDateTime,
  12394. // Stage: 3,
  12395. // }
  12396. // service.CreateErrMsgLog(errlog)
  12397. //
  12398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12399. // return
  12400. // }
  12401. //
  12402. // c.ServeSuccessJSON(map[string]interface{}{
  12403. // "msg": "上传成功",
  12404. // })
  12405. //
  12406. //}
  12407. type QueryResult struct {
  12408. ID int64
  12409. Name string
  12410. Code string
  12411. List_type_code string
  12412. }
  12413. func (c *HisApiController) GetCheckCode() {
  12414. ids_str := c.GetString("ids")
  12415. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12416. ids_arr := strings.Split(ids_str, ",")
  12417. var queryResult []QueryResult
  12418. ids := make([]int64, 0)
  12419. for _, item := range ids_arr {
  12420. id, _ := strconv.ParseInt(item, 10, 64)
  12421. ids = append(ids, id)
  12422. }
  12423. if record_type == 1 {
  12424. drugs, _ := service.GetBatchDrugList(ids)
  12425. for _, item := range drugs {
  12426. result := QueryResult{
  12427. ID: item.ID,
  12428. Name: item.DrugName,
  12429. Code: item.MedicalInsuranceNumber,
  12430. List_type_code: "101",
  12431. }
  12432. queryResult = append(queryResult, result)
  12433. }
  12434. } else if record_type == 2 {
  12435. goods, _ := service.GetBatchGoodInformationList(ids)
  12436. for _, item := range goods {
  12437. result := QueryResult{
  12438. ID: item.ID,
  12439. Name: item.GoodName,
  12440. Code: item.MedicalInsuranceNumber,
  12441. List_type_code: "301",
  12442. }
  12443. queryResult = append(queryResult, result)
  12444. }
  12445. } else if record_type == 3 {
  12446. projects, _ := service.GetBathchMyPorjecgList(ids)
  12447. for _, item := range projects {
  12448. result := QueryResult{
  12449. ID: item.ID,
  12450. Name: item.ProjectName,
  12451. Code: item.MedicalCode,
  12452. List_type_code: "201",
  12453. }
  12454. queryResult = append(queryResult, result)
  12455. }
  12456. }
  12457. admin_user_id, _ := c.GetInt64("admin_user_id")
  12458. adminUser := c.GetAdminUserInfo()
  12459. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12460. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12461. var user_name string
  12462. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12463. if role.ID == 0 {
  12464. user_name = "xxx"
  12465. } else {
  12466. user_name = role.UserName
  12467. }
  12468. baseParams := &models.BaseParams{
  12469. SecretKey: miConfig.SecretKey,
  12470. FixmedinsCode: miConfig.Code,
  12471. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12472. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12473. OrgName: miConfig.OrgName,
  12474. Doctor: user_name,
  12475. }
  12476. if config.IsOpen == 1 {
  12477. for _, item := range queryResult {
  12478. var result string
  12479. if record_type == 1 {
  12480. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12481. } else if record_type == 2 {
  12482. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12483. } else if record_type == 3 {
  12484. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12485. }
  12486. var dat map[string]interface{}
  12487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12488. fmt.Println(dat)
  12489. } else {
  12490. fmt.Println(err)
  12491. }
  12492. userJSONBytes, _ := json.Marshal(dat)
  12493. var res ResultSix
  12494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12495. utils.ErrorLog("解析失败:%v", err)
  12496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12497. return
  12498. }
  12499. if res.Infcode == 0 {
  12500. if record_type == 1 {
  12501. service.UpdateBaseDrugById(item.ID)
  12502. } else if record_type == 2 {
  12503. service.UpdateGoodInformaitonByDetail(item.ID)
  12504. } else if record_type == 3 {
  12505. service.UpdateProjectById(item.ID)
  12506. }
  12507. c.ServeSuccessJSON(map[string]interface{}{
  12508. "failed_code": 0,
  12509. "msg": "目录对照成功",
  12510. })
  12511. } else {
  12512. c.ServeSuccessJSON(map[string]interface{}{
  12513. "failed_code": -10,
  12514. "msg": res.ErrMsg,
  12515. })
  12516. }
  12517. }
  12518. }
  12519. }
  12520. func (c *HisApiController) UnCheckCode() {
  12521. ids_str := c.GetString("ids")
  12522. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12523. admin_user_id, _ := c.GetInt64("admin_user_id")
  12524. ids_arr := strings.Split(ids_str, ",")
  12525. var queryResult []QueryResult
  12526. ids := make([]int64, 0)
  12527. for _, item := range ids_arr {
  12528. id, _ := strconv.ParseInt(item, 10, 64)
  12529. ids = append(ids, id)
  12530. }
  12531. if record_type == 1 {
  12532. drugs, _ := service.GetBatchDrugList(ids)
  12533. for _, item := range drugs {
  12534. result := QueryResult{
  12535. ID: item.ID,
  12536. Name: item.DrugName,
  12537. Code: item.MedicalInsuranceNumber,
  12538. List_type_code: "101",
  12539. }
  12540. queryResult = append(queryResult, result)
  12541. }
  12542. } else if record_type == 2 {
  12543. goods, _ := service.GetBatchGoodInformationList(ids)
  12544. for _, item := range goods {
  12545. result := QueryResult{
  12546. ID: item.ID,
  12547. Name: item.GoodName,
  12548. Code: item.MedicalInsuranceNumber,
  12549. List_type_code: "301",
  12550. }
  12551. queryResult = append(queryResult, result)
  12552. }
  12553. } else if record_type == 3 {
  12554. projects, _ := service.GetBathchMyPorjecgList(ids)
  12555. for _, item := range projects {
  12556. result := QueryResult{
  12557. ID: item.ID,
  12558. Name: item.ProjectName,
  12559. Code: item.MedicalCode,
  12560. List_type_code: "201",
  12561. }
  12562. queryResult = append(queryResult, result)
  12563. }
  12564. }
  12565. adminUser := c.GetAdminUserInfo()
  12566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12567. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12568. var user_name string
  12569. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12570. if role.ID == 0 {
  12571. user_name = "xxx"
  12572. } else {
  12573. user_name = role.UserName
  12574. }
  12575. baseParams := &models.BaseParams{
  12576. SecretKey: miConfig.SecretKey,
  12577. FixmedinsCode: miConfig.Code,
  12578. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12579. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12580. OrgName: miConfig.OrgName,
  12581. Doctor: user_name,
  12582. }
  12583. if config.IsOpen == 1 {
  12584. for _, item := range queryResult {
  12585. var result string
  12586. if record_type == 1 {
  12587. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12588. } else if record_type == 2 {
  12589. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12590. } else if record_type == 3 {
  12591. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12592. }
  12593. var dat2 map[string]interface{}
  12594. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12595. fmt.Println(dat2)
  12596. } else {
  12597. fmt.Println(err)
  12598. }
  12599. userJSONBytes, _ := json.Marshal(dat2)
  12600. var res ResultSix
  12601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12602. utils.ErrorLog("解析失败:%v", err)
  12603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12604. return
  12605. }
  12606. if res.Infcode == 0 {
  12607. if record_type == 1 {
  12608. service.UpdateDrugByIdDetail(item.ID)
  12609. } else if record_type == 2 {
  12610. service.UpdateGoodInfoById(item.ID)
  12611. } else if record_type == 3 {
  12612. service.UpdateMyProjectById(item.ID)
  12613. }
  12614. c.ServeSuccessJSON(map[string]interface{}{
  12615. "failed_code": 0,
  12616. "msg": "撤销目录对照成功",
  12617. })
  12618. } else {
  12619. c.ServeSuccessJSON(map[string]interface{}{
  12620. "failed_code": -10,
  12621. "msg": res.ErrMsg,
  12622. })
  12623. }
  12624. }
  12625. }
  12626. }
  12627. func (c *HisApiController) GetPatientInfo() {
  12628. id_card_no := c.GetString("id_card_no")
  12629. admin_user_id, _ := c.GetInt64("admin_user_id")
  12630. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12631. if patient.ID == 0 {
  12632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12633. return
  12634. }
  12635. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12636. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12637. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12638. if config.IsOpen == 1 {
  12639. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12640. var dat map[string]interface{}
  12641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12642. fmt.Println(dat)
  12643. } else {
  12644. fmt.Println(err)
  12645. }
  12646. userJSONBytes, _ := json.Marshal(dat)
  12647. var res ResultTwo
  12648. var res10265 ResultTwo10265
  12649. if miConfig.Code == "H15049901371" {
  12650. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12651. utils.ErrorLog("解析失败:%v", err)
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12653. return
  12654. }
  12655. res.ErrMsg = res10265.ErrMsg
  12656. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12657. res.Infcode = infocode
  12658. res.Output = res10265.Output
  12659. res.InfRefmsgid = res10265.InfRefmsgid
  12660. } else {
  12661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12662. utils.ErrorLog("解析失败:%v", err)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. }
  12667. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12668. // utils.ErrorLog("解析失败:%v", err)
  12669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12670. // return
  12671. //}
  12672. if res.Infcode != 0 {
  12673. c.ServeSuccessJSON(map[string]interface{}{
  12674. "failed_code": -10,
  12675. "msg": res.ErrMsg,
  12676. })
  12677. } else {
  12678. c.ServeSuccessJSON(map[string]interface{}{
  12679. "failed_code": 0,
  12680. "info": res,
  12681. })
  12682. }
  12683. }
  12684. }
  12685. func (c *HisApiController) PsnPutOnRecord() {
  12686. record_type, _ := c.GetInt64("type")
  12687. patient_id, _ := c.GetInt64("patient_id")
  12688. admin_user_id, _ := c.GetInt64("admin_user_id")
  12689. start_time := c.GetString("start_time")
  12690. end_time := c.GetString("end_time")
  12691. adminUser := c.GetAdminUserInfo()
  12692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12693. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12694. var patients []*models.Patients
  12695. if record_type == 1 { //全部备案
  12696. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12697. patients = append(patients, patient...)
  12698. } else { //单个备案
  12699. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12700. patients = append(patients, patient)
  12701. }
  12702. var user_name string
  12703. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12704. if role.ID == 0 {
  12705. user_name = "xxx"
  12706. } else {
  12707. user_name = role.UserName
  12708. }
  12709. if config.IsOpen == 1 {
  12710. for _, item := range patients {
  12711. 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
  12712. resp, requestErr := http.Get(api)
  12713. if requestErr != nil {
  12714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12715. return
  12716. }
  12717. defer resp.Body.Close()
  12718. body, ioErr := ioutil.ReadAll(resp.Body)
  12719. if ioErr != nil {
  12720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12722. return
  12723. }
  12724. var respJSON map[string]interface{}
  12725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12728. return
  12729. }
  12730. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12731. userJSONBytes, _ := json.Marshal(userJSON)
  12732. var res ResultTwo
  12733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12734. utils.ErrorLog("解析失败:%v", err)
  12735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12736. return
  12737. }
  12738. if res.Infcode == 0 {
  12739. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12740. var dat map[string]interface{}
  12741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12742. fmt.Println(dat)
  12743. } else {
  12744. fmt.Println(err)
  12745. }
  12746. userJSONBytes, _ := json.Marshal(dat)
  12747. var res2 ResultThirteen
  12748. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12749. utils.ErrorLog("解析失败:%v", err)
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12751. return
  12752. }
  12753. if res2.Infcode == 0 {
  12754. psnResult := &models.GdybPsnRecord{
  12755. UserOrgId: adminUser.CurrentOrgId,
  12756. PatientId: item.ID,
  12757. PsnNo: res.Output.Baseinfo.PsnNo,
  12758. Ctime: time.Now().Unix(),
  12759. Mtime: time.Now().Unix(),
  12760. Status: 1,
  12761. IsCancel: 1,
  12762. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12763. }
  12764. service.CreatePsnRecord(psnResult)
  12765. } else {
  12766. c.ServeSuccessJSON(map[string]interface{}{
  12767. "failed_code": -10,
  12768. "msg": res2.ErrMsg,
  12769. })
  12770. return
  12771. }
  12772. }
  12773. }
  12774. }
  12775. }
  12776. func (c *HisApiController) PsnUnPutOnRecord() {
  12777. id, _ := c.GetInt64("id")
  12778. //record_type, _ := c.GetInt64("type")
  12779. admin_user_id, _ := c.GetInt64("admin_user_id")
  12780. adminUser := c.GetAdminUserInfo()
  12781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12782. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12783. var user_name string
  12784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12785. if role.ID == 0 {
  12786. user_name = "xxx"
  12787. } else {
  12788. user_name = role.UserName
  12789. }
  12790. psn_record, _ := service.GetPsnRecordById(id)
  12791. if psn_record.ID == 0 {
  12792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12793. return
  12794. }
  12795. if config.IsOpen == 1 {
  12796. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12797. var dat map[string]interface{}
  12798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12799. fmt.Println(dat)
  12800. } else {
  12801. fmt.Println(err)
  12802. }
  12803. userJSONBytes, _ := json.Marshal(dat)
  12804. var res ResultFourteen
  12805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12806. utils.ErrorLog("解析失败:%v", err)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. if res.Infcode == 0 {
  12811. psn_record.IsCancel = 2
  12812. service.CreatePsnRecord(&psn_record)
  12813. } else {
  12814. c.ServeSuccessJSON(map[string]interface{}{
  12815. "failed_code": -10,
  12816. "msg": res.ErrMsg,
  12817. })
  12818. return
  12819. }
  12820. }
  12821. }
  12822. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12823. patient_id, _ := c.GetInt64("patient_id")
  12824. insutype_two := c.GetString("insutype")
  12825. psn_no := c.GetString("psn_no")
  12826. doctor_id, _ := c.GetInt64("doctor_id")
  12827. sick_id, _ := c.GetInt64("sick_id")
  12828. department_id, _ := c.GetInt64("department_id")
  12829. start_time := c.GetString("start_time")
  12830. end_time := c.GetString("end_time")
  12831. check_time := c.GetString("check_time")
  12832. adminUser := c.GetAdminUserInfo()
  12833. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12835. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12836. sick, _ := service.FindSickById(sick_id)
  12837. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12838. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  12839. var res ResultTwo
  12840. var res10265 ResultTwo10265
  12841. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12842. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  12843. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  12844. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12845. "&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
  12846. resp, requestErr := http.Get(api)
  12847. if requestErr != nil {
  12848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12849. return
  12850. }
  12851. body, ioErr := ioutil.ReadAll(resp.Body)
  12852. if ioErr != nil {
  12853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return
  12856. }
  12857. var respJSON map[string]interface{}
  12858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12861. return
  12862. }
  12863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12864. result, _ := json.Marshal(respJSON)
  12865. fmt.Println("log")
  12866. fmt.Println(string(result))
  12867. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12868. utils.ErrorLog("解析失败:%v", err)
  12869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12870. return
  12871. }
  12872. res.ErrMsg = res10265.ErrMsg
  12873. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12874. res.Infcode = infocode
  12875. res.Output = res10265.Output
  12876. res.InfRefmsgid = res10265.InfRefmsgid
  12877. } else {
  12878. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  12879. if miConfig.Code == "H15049901371" {
  12880. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12881. utils.ErrorLog("解析失败:%v", err)
  12882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12883. return
  12884. }
  12885. res.ErrMsg = res10265.ErrMsg
  12886. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12887. res.Infcode = infocode
  12888. res.Output = res10265.Output
  12889. res.InfRefmsgid = res10265.InfRefmsgid
  12890. } else {
  12891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12892. utils.ErrorLog("解析失败:%v", err)
  12893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12894. return
  12895. }
  12896. }
  12897. }
  12898. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12899. infoStr := string(Iinfos)
  12900. var rf []*ResultFive
  12901. json.Unmarshal([]byte(infoStr), &rf)
  12902. var insuplc_admdvs string
  12903. var insutype string
  12904. var is390 int = 0
  12905. var is310 int = 0
  12906. var insutypes []*ResultFive
  12907. for _, item := range rf {
  12908. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12909. insutypes = append(insutypes, item)
  12910. }
  12911. }
  12912. if len(insutypes) == 1 {
  12913. insutype = insutypes[0].Insutype
  12914. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12915. } else {
  12916. for _, i := range insutypes {
  12917. if i.Insutype == "390" {
  12918. is390 = 1
  12919. }
  12920. if i.Insutype == "310" {
  12921. is310 = 1
  12922. }
  12923. }
  12924. }
  12925. if is390 == 1 {
  12926. insutype = "390"
  12927. }
  12928. if is310 == 1 {
  12929. insutype = "310"
  12930. }
  12931. if len(insutypes) == 2 {
  12932. insutype = insutype_two
  12933. }
  12934. if len(insutypes) == 0 {
  12935. insutype = "310"
  12936. }
  12937. insutype = insutype_two
  12938. fmt.Println(insutype)
  12939. for _, item := range rf {
  12940. fmt.Println(item.Insutype)
  12941. fmt.Println(insutype)
  12942. if item.Insutype == insutype {
  12943. fmt.Println(item.Insutype)
  12944. fmt.Println(insutype)
  12945. insuplc_admdvs = item.InsuplcAdmdvs
  12946. }
  12947. }
  12948. fmt.Println(insuplc_admdvs)
  12949. var res2 ResultThirteen
  12950. var res10265_2 ResultThirteen10265
  12951. if config.IsOpen == 1 {
  12952. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12953. } else {
  12954. 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)
  12955. var dat map[string]interface{}
  12956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12957. fmt.Println(dat)
  12958. } else {
  12959. fmt.Println(err)
  12960. }
  12961. userJSONBytes, _ := json.Marshal(dat)
  12962. if miConfig.Code == "H15049901371" {
  12963. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  12964. utils.ErrorLog("解析失败:%v", err)
  12965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12966. return
  12967. }
  12968. res2.ErrMsg = res10265_2.ErrMsg
  12969. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  12970. res2.Infcode = infocode
  12971. res2.Output = res10265_2.Output
  12972. res2.InfRefmsgid = res10265_2.InfRefmsgid
  12973. } else {
  12974. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12975. utils.ErrorLog("解析失败:%v", err)
  12976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12977. return
  12978. }
  12979. }
  12980. }
  12981. if res2.Infcode == 0 {
  12982. psnResult := &models.GdybPsnNcdsRecord{
  12983. UserOrgId: adminUser.CurrentOrgId,
  12984. PatientId: patient.ID,
  12985. PsnNo: psn_no,
  12986. DoctorId: doctor.AdminUserId,
  12987. DepartmentId: department_id,
  12988. SickType: sick_id,
  12989. Insutype: insutype,
  12990. Ctime: time.Now().Unix(),
  12991. Mtime: time.Now().Unix(),
  12992. Status: 1,
  12993. IsCancel: 1,
  12994. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12995. }
  12996. service.CreatePsnNCDSRecord(psnResult)
  12997. c.ServeSuccessJSON(map[string]interface{}{
  12998. "failed_code": 0,
  12999. "msg": "备案成功",
  13000. "result": psnResult,
  13001. })
  13002. } else {
  13003. c.ServeSuccessJSON(map[string]interface{}{
  13004. "failed_code": -10,
  13005. "msg": res2.ErrMsg,
  13006. })
  13007. return
  13008. }
  13009. }
  13010. }
  13011. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13012. id, _ := c.GetInt64("id")
  13013. admin_user_id, _ := c.GetInt64("admin_user_id")
  13014. adminUser := c.GetAdminUserInfo()
  13015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13017. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13018. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13019. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13020. //var user_name string
  13021. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13022. //if role.ID == 0 {
  13023. // user_name = "xxx"
  13024. //} else {
  13025. // user_name = role.UserName
  13026. //}
  13027. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13028. if psn_record.ID == 0 {
  13029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13030. return
  13031. }
  13032. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13033. var res ResultTwo
  13034. var res10265 ResultTwo10265
  13035. if miConfig.Code == "H15049901371" {
  13036. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13037. utils.ErrorLog("解析失败:%v", err)
  13038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13039. return
  13040. }
  13041. res.ErrMsg = res10265.ErrMsg
  13042. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13043. res.Infcode = infocode
  13044. res.Output = res10265.Output
  13045. res.InfRefmsgid = res10265.InfRefmsgid
  13046. } else {
  13047. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. }
  13053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13054. infoStr := string(Iinfos)
  13055. var rf []*ResultFive
  13056. json.Unmarshal([]byte(infoStr), &rf)
  13057. var insuplc_admdvs string
  13058. var insutype string
  13059. var is390 int = 0
  13060. var is310 int = 0
  13061. var insutypes []*ResultFive
  13062. for _, item := range rf {
  13063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13064. insutypes = append(insutypes, item)
  13065. }
  13066. }
  13067. if len(insutypes) == 1 {
  13068. insutype = insutypes[0].Insutype
  13069. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13070. } else {
  13071. for _, i := range insutypes {
  13072. if i.Insutype == "390" {
  13073. is390 = 1
  13074. }
  13075. if i.Insutype == "310" {
  13076. is310 = 1
  13077. }
  13078. }
  13079. }
  13080. if is390 == 1 {
  13081. insutype = "390"
  13082. }
  13083. if is310 == 1 {
  13084. insutype = "310"
  13085. }
  13086. if len(insutypes) == 0 {
  13087. insutype = "310"
  13088. }
  13089. insutype = psn_record.Insutype
  13090. for _, item := range rf {
  13091. if item.Insutype == insutype {
  13092. insuplc_admdvs = item.InsuplcAdmdvs
  13093. }
  13094. }
  13095. if config.IsOpen == 1 {
  13096. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13097. var dat map[string]interface{}
  13098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13099. fmt.Println(dat)
  13100. } else {
  13101. fmt.Println(err)
  13102. }
  13103. userJSONBytes, _ := json.Marshal(dat)
  13104. var res ResultFourteen
  13105. var res10265 ResultFourteen10265
  13106. if miConfig.Code == "H15049901371" {
  13107. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13108. utils.ErrorLog("解析失败:%v", err)
  13109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13110. return
  13111. }
  13112. res.ErrMsg = res10265.ErrMsg
  13113. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13114. res.Infcode = infocode
  13115. res.Output = res10265.Output
  13116. res.InfRefmsgid = res10265.InfRefmsgid
  13117. } else {
  13118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13119. utils.ErrorLog("解析失败:%v", err)
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. return
  13122. }
  13123. }
  13124. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13125. // utils.ErrorLog("解析失败:%v", err)
  13126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. // return
  13128. //}
  13129. if res.Infcode == 0 {
  13130. psn_record.IsCancel = 2
  13131. service.CreatePsnNCDSRecord(&psn_record)
  13132. c.ServeSuccessJSON(map[string]interface{}{
  13133. "failed_code": 0,
  13134. "msg": "撤销备案成功",
  13135. })
  13136. } else {
  13137. c.ServeSuccessJSON(map[string]interface{}{
  13138. "failed_code": -10,
  13139. "msg": res.ErrMsg,
  13140. })
  13141. return
  13142. }
  13143. }
  13144. }
  13145. func (c *HisApiController) TestTest() {
  13146. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13147. fmt.Println(patient.Iinfo)
  13148. }
  13149. type CustomData struct {
  13150. MsgId string
  13151. PsnNo string
  13152. Info string
  13153. }
  13154. func (c *HisApiController) ReversalData() {
  13155. var customData []*CustomData
  13156. custom := &CustomData{
  13157. MsgId: "H44022900158202103301714472004",
  13158. PsnNo: "44020000001101329945",
  13159. Info: "2207",
  13160. }
  13161. customData = append(customData, custom)
  13162. custom1 := &CustomData{
  13163. MsgId: "H4402290015820210330172057803",
  13164. PsnNo: "44020000001101161813",
  13165. Info: "2207",
  13166. }
  13167. customData = append(customData, custom1)
  13168. custom2 := &CustomData{
  13169. MsgId: "H44022900158202103301705198813",
  13170. PsnNo: "44190000133097375417",
  13171. Info: "2207",
  13172. }
  13173. customData = append(customData, custom2)
  13174. custom3 := &CustomData{
  13175. MsgId: "H44022900158202103301715524756",
  13176. PsnNo: "44020000001100187221",
  13177. Info: "2207",
  13178. }
  13179. customData = append(customData, custom3)
  13180. custom4 := &CustomData{
  13181. MsgId: "H44022900158202103301730376224",
  13182. PsnNo: "44020000001101959155",
  13183. Info: "2207",
  13184. }
  13185. customData = append(customData, custom4)
  13186. custom5 := &CustomData{
  13187. MsgId: "H44022900158202103301748008725",
  13188. PsnNo: "44020000001104246641",
  13189. Info: "2207",
  13190. }
  13191. customData = append(customData, custom5)
  13192. custom6 := &CustomData{
  13193. MsgId: "H44022900158202103301718096755",
  13194. PsnNo: "44020000001102211860",
  13195. Info: "2207",
  13196. }
  13197. customData = append(customData, custom6)
  13198. custom7 := &CustomData{
  13199. MsgId: "H44022900158202103301736551640",
  13200. PsnNo: "44020000001102687718",
  13201. Info: "2207",
  13202. }
  13203. customData = append(customData, custom7)
  13204. custom8 := &CustomData{
  13205. MsgId: "H44022900158202103301743097676",
  13206. PsnNo: "44020000001102127785",
  13207. Info: "2207",
  13208. }
  13209. customData = append(customData, custom8)
  13210. custom9 := &CustomData{
  13211. MsgId: "H44022900158202103301712304203",
  13212. PsnNo: "44020000001101518097",
  13213. Info: "2207",
  13214. }
  13215. customData = append(customData, custom9)
  13216. custom10 := &CustomData{
  13217. MsgId: "H44022900158202103301738448785",
  13218. PsnNo: "44020000001100500813",
  13219. Info: "2207",
  13220. }
  13221. customData = append(customData, custom10)
  13222. custom11 := &CustomData{
  13223. MsgId: "H44022900158202103301732455843",
  13224. PsnNo: "44020000001102690557",
  13225. Info: "2207",
  13226. }
  13227. customData = append(customData, custom11)
  13228. custom12 := &CustomData{
  13229. MsgId: "H44022900158202103301745421708",
  13230. PsnNo: "44020000001102211928",
  13231. Info: "2207",
  13232. }
  13233. customData = append(customData, custom12)
  13234. custom1212 := &CustomData{
  13235. MsgId: "H440229001582021033017351627",
  13236. PsnNo: "44020000001102481733",
  13237. Info: "2207",
  13238. }
  13239. customData = append(customData, custom1212)
  13240. custom13 := &CustomData{
  13241. MsgId: "H44022900158202103301740327951",
  13242. PsnNo: "44020000001103174866",
  13243. Info: "2207",
  13244. }
  13245. customData = append(customData, custom13)
  13246. custom14 := &CustomData{
  13247. MsgId: "H4402290015820210330174922668",
  13248. PsnNo: "44020000001102927272",
  13249. Info: "2207",
  13250. }
  13251. customData = append(customData, custom14)
  13252. custom15 := &CustomData{
  13253. MsgId: "H44022900158202103301752362273",
  13254. PsnNo: "44020000001102942890",
  13255. Info: "2207",
  13256. }
  13257. customData = append(customData, custom15)
  13258. custom16 := &CustomData{
  13259. MsgId: "H44022900158202103301751082917",
  13260. PsnNo: "44020000001101662162",
  13261. Info: "2207",
  13262. }
  13263. customData = append(customData, custom16)
  13264. custom17 := &CustomData{
  13265. MsgId: "H44022900158202103301754147728",
  13266. PsnNo: "44020000000229014511",
  13267. Info: "2207",
  13268. }
  13269. customData = append(customData, custom17)
  13270. adminUser := c.GetAdminUserInfo()
  13271. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13272. for _, item := range customData {
  13273. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13274. fmt.Println(result)
  13275. }
  13276. }
  13277. //func (c *HisApiController) GetAllopatry() {
  13278. // year := c.GetString("year")
  13279. // month := c.GetString("month")
  13280. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13281. // adminUser := c.GetAdminUserInfo()
  13282. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13283. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13284. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13285. //
  13286. // var dat map[string]interface{}
  13287. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13288. // fmt.Println(dat)
  13289. // } else {
  13290. // fmt.Println(err)
  13291. // }
  13292. // userJSONBytes, _ := json.Marshal(dat)
  13293. // var res models.Result9001
  13294. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13295. // utils.ErrorLog("解析失败:%v", err)
  13296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13297. // return
  13298. // }
  13299. //
  13300. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13301. // var dat2 map[string]interface{}
  13302. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13303. // fmt.Println(dat)
  13304. // } else {
  13305. // fmt.Println(err)
  13306. // }
  13307. // userJSONBytes2, _ := json.Marshal(dat2)
  13308. // var res2 models.Result3260
  13309. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13310. // utils.ErrorLog("解析失败:%v", err)
  13311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13312. // return
  13313. // }
  13314. // if res2.Infcode == 0 {
  13315. // c.ServeSuccessJSON(map[string]interface{}{
  13316. // "list": res2.Output.Data,
  13317. // })
  13318. // return
  13319. // } else {
  13320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13321. // return
  13322. // }
  13323. //
  13324. //}
  13325. //func (c *HisApiController) ComfirmAllopatry() {
  13326. // year := c.GetString("year")
  13327. // month := c.GetString("month")
  13328. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13329. // adminUser := c.GetAdminUserInfo()
  13330. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13331. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13332. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13333. // var dat map[string]interface{}
  13334. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13335. // fmt.Println(dat)
  13336. // } else {
  13337. // fmt.Println(err)
  13338. // }
  13339. // userJSONBytes, _ := json.Marshal(dat)
  13340. // var res models.Result9001
  13341. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13342. // utils.ErrorLog("解析失败:%v", err)
  13343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13344. // return
  13345. // }
  13346. //
  13347. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13348. // var dat2 map[string]interface{}
  13349. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13350. // fmt.Println(dat)
  13351. // } else {
  13352. // fmt.Println(err)
  13353. // }
  13354. // userJSONBytes2, _ := json.Marshal(dat2)
  13355. // var res2 models.Result3260
  13356. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13357. // utils.ErrorLog("解析失败:%v", err)
  13358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13359. // return
  13360. // }
  13361. //
  13362. // if res2.Infcode == 0 {
  13363. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13364. // var dat map[string]interface{}
  13365. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13366. // fmt.Println(dat)
  13367. // } else {
  13368. // fmt.Println(err)
  13369. // }
  13370. // userJSONBytes, _ := json.Marshal(dat)
  13371. // var res3 models.Result3261
  13372. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13373. // utils.ErrorLog("解析失败:%v", err)
  13374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13375. // return
  13376. // }
  13377. //
  13378. // if res3.Infcode == 0 {
  13379. // record := &models.HisYidiClearRecord{
  13380. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13381. // Ctime: time.Now().Unix(),
  13382. // Mtime: time.Now().Unix(),
  13383. // Status: 1,
  13384. // MsgId: msgId,
  13385. // }
  13386. // service.SaveClearRecord(record)
  13387. // c.ServeSuccessJSON(map[string]interface{}{
  13388. // "msg": "提取成功",
  13389. // })
  13390. // }
  13391. // }
  13392. //}
  13393. func (c *HisApiController) RefundAllopatry() {
  13394. year := c.GetString("year")
  13395. month := c.GetString("month")
  13396. id, _ := c.GetInt64("id")
  13397. admin_user_id, _ := c.GetInt64("admin_user_id")
  13398. adminUser := c.GetAdminUserInfo()
  13399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13400. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13401. record, _ := service.GetClearRecordById(id)
  13402. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13403. var dat map[string]interface{}
  13404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13405. fmt.Println(dat)
  13406. } else {
  13407. fmt.Println(err)
  13408. }
  13409. userJSONBytes, _ := json.Marshal(dat)
  13410. var empty ResultFourteen
  13411. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13412. utils.ErrorLog("解析失败:%v", err)
  13413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13414. return
  13415. }
  13416. if empty.Infcode == 0 {
  13417. c.ServeSuccessJSON(map[string]interface{}{
  13418. "msg": "撤销成功",
  13419. })
  13420. return
  13421. }
  13422. }
  13423. func (c *HisApiController) ReversalOtherData() {
  13424. var customData []*CustomData
  13425. custom := &CustomData{
  13426. MsgId: "H44022900158202103301714472004",
  13427. PsnNo: "44020000001101329945",
  13428. Info: "2208",
  13429. }
  13430. customData = append(customData, custom)
  13431. custom1 := &CustomData{
  13432. MsgId: "H4402290015820210330172057803",
  13433. PsnNo: "44020000001101161813",
  13434. Info: "2208",
  13435. }
  13436. customData = append(customData, custom1)
  13437. custom2 := &CustomData{
  13438. MsgId: "H44022900158202103301705198813",
  13439. PsnNo: "44190000133097375417",
  13440. Info: "2208",
  13441. }
  13442. customData = append(customData, custom2)
  13443. custom3 := &CustomData{
  13444. MsgId: "H44022900158202103301715524756",
  13445. PsnNo: "44020000001100187221",
  13446. Info: "2208",
  13447. }
  13448. customData = append(customData, custom3)
  13449. custom4 := &CustomData{
  13450. MsgId: "H44022900158202103301730376224",
  13451. PsnNo: "44020000001101959155",
  13452. Info: "2208",
  13453. }
  13454. customData = append(customData, custom4)
  13455. custom5 := &CustomData{
  13456. MsgId: "H44022900158202103301748008725",
  13457. PsnNo: "44020000001104246641",
  13458. Info: "2208",
  13459. }
  13460. customData = append(customData, custom5)
  13461. custom6 := &CustomData{
  13462. MsgId: "H44022900158202103301718096755",
  13463. PsnNo: "44020000001102211860",
  13464. Info: "2208",
  13465. }
  13466. customData = append(customData, custom6)
  13467. custom7 := &CustomData{
  13468. MsgId: "H44022900158202103301736551640",
  13469. PsnNo: "44020000001102687718",
  13470. Info: "2208",
  13471. }
  13472. customData = append(customData, custom7)
  13473. custom8 := &CustomData{
  13474. MsgId: "H44022900158202103301743097676",
  13475. PsnNo: "44020000001102127785",
  13476. Info: "2208",
  13477. }
  13478. customData = append(customData, custom8)
  13479. custom9 := &CustomData{
  13480. MsgId: "H44022900158202103301712304203",
  13481. PsnNo: "44020000001101518097",
  13482. Info: "2208",
  13483. }
  13484. customData = append(customData, custom9)
  13485. custom10 := &CustomData{
  13486. MsgId: "H44022900158202103301738448785",
  13487. PsnNo: "44020000001100500813",
  13488. Info: "2208",
  13489. }
  13490. customData = append(customData, custom10)
  13491. custom11 := &CustomData{
  13492. MsgId: "H44022900158202103301732455843",
  13493. PsnNo: "44020000001102690557",
  13494. Info: "2208",
  13495. }
  13496. customData = append(customData, custom11)
  13497. custom12 := &CustomData{
  13498. MsgId: "H44022900158202103301745421708",
  13499. PsnNo: "44020000001102211928",
  13500. Info: "2208",
  13501. }
  13502. customData = append(customData, custom12)
  13503. custom1212 := &CustomData{
  13504. MsgId: "H440229001582021033017351627",
  13505. PsnNo: "44020000001102481733",
  13506. Info: "2208",
  13507. }
  13508. customData = append(customData, custom1212)
  13509. custom13 := &CustomData{
  13510. MsgId: "H44022900158202103301740327951",
  13511. PsnNo: "44020000001103174866",
  13512. Info: "2208",
  13513. }
  13514. customData = append(customData, custom13)
  13515. custom14 := &CustomData{
  13516. MsgId: "H4402290015820210330174922668",
  13517. PsnNo: "44020000001102927272",
  13518. Info: "2208",
  13519. }
  13520. customData = append(customData, custom14)
  13521. custom15 := &CustomData{
  13522. MsgId: "H44022900158202103301752362273",
  13523. PsnNo: "44020000001102942890",
  13524. Info: "2208",
  13525. }
  13526. customData = append(customData, custom15)
  13527. custom16 := &CustomData{
  13528. MsgId: "H44022900158202103301751082917",
  13529. PsnNo: "44020000001101662162",
  13530. Info: "2208",
  13531. }
  13532. customData = append(customData, custom16)
  13533. custom17 := &CustomData{
  13534. MsgId: "H44022900158202103301754147728",
  13535. PsnNo: "44020000000229014511",
  13536. Info: "2208",
  13537. }
  13538. customData = append(customData, custom17)
  13539. adminUser := c.GetAdminUserInfo()
  13540. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13541. for _, item := range customData {
  13542. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13543. fmt.Println(result)
  13544. }
  13545. }
  13546. func PathExists(path string) (bool, error) {
  13547. _, err := os.Stat(path)
  13548. if err == nil {
  13549. return true, nil
  13550. }
  13551. if os.IsNotExist(err) {
  13552. return false, nil
  13553. }
  13554. return false, err
  13555. }
  13556. //创建文件夹
  13557. func Mkdir(dir string) {
  13558. // 创建文件夹
  13559. exist, err := PathExists(dir)
  13560. if err != nil {
  13561. fmt.Println(err.Error())
  13562. } else {
  13563. if exist {
  13564. fmt.Println(dir + "文件夹已存在!")
  13565. } else {
  13566. // 文件夹名称,权限
  13567. err := os.Mkdir(dir, os.ModePerm)
  13568. if err != nil {
  13569. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13570. } else {
  13571. fmt.Println(dir + "文件夹创建成功!")
  13572. }
  13573. }
  13574. }
  13575. }
  13576. //压缩文件
  13577. func Zip(srcFile string, destZip string) error {
  13578. zipfile, err := os.Create(destZip)
  13579. if err != nil {
  13580. return err
  13581. }
  13582. defer zipfile.Close()
  13583. archive := zip.NewWriter(zipfile)
  13584. defer archive.Close()
  13585. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13586. if err != nil {
  13587. return err
  13588. }
  13589. header, err := zip.FileInfoHeader(info)
  13590. if err != nil {
  13591. return err
  13592. }
  13593. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13594. // header.Name = path
  13595. if info.IsDir() {
  13596. header.Name += "/"
  13597. } else {
  13598. header.Method = zip.Deflate
  13599. }
  13600. writer, err := archive.CreateHeader(header)
  13601. if err != nil {
  13602. return err
  13603. }
  13604. if !info.IsDir() {
  13605. file, err := os.Open(path)
  13606. if err != nil {
  13607. return err
  13608. }
  13609. defer file.Close()
  13610. _, err = io.Copy(writer, file)
  13611. }
  13612. return err
  13613. })
  13614. return err
  13615. }
  13616. func ReadFile(filePath string) []byte {
  13617. f, err := os.Open(filePath)
  13618. if err != nil {
  13619. fmt.Println("read file fail", err)
  13620. return nil
  13621. }
  13622. defer f.Close()
  13623. fd, err := ioutil.ReadAll(f)
  13624. if err != nil {
  13625. fmt.Println("read to fd fail", err)
  13626. return nil
  13627. }
  13628. return fd
  13629. }
  13630. func saveLog(result string, request string, infno string, desc string) {
  13631. org_id, _ := beego.AppConfig.Int64("org_id")
  13632. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13633. dir := miConfig.OrgName + "日志"
  13634. utils.Mkdir(dir)
  13635. month := time.Unix(1557042972, 0).Format("1")
  13636. year := time.Now().Format("2006")
  13637. month = time.Now().Format("01")
  13638. day := time.Now().Format("02")
  13639. hour := time.Now().Format("15")
  13640. min := time.Now().Format("04")
  13641. sec := time.Now().Format("05")
  13642. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13643. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13644. file_name := file + ".txt"
  13645. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13646. exist, _ := utils.PathExists(file_path)
  13647. if exist { //存在
  13648. fmt.Println("存在")
  13649. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13650. if err != nil {
  13651. fmt.Println("read fail")
  13652. }
  13653. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13654. n, _ := f.Seek(0, 2)
  13655. _, err = f.WriteAt([]byte(content), n)
  13656. } else { //不存在
  13657. fmt.Println("文件不存在,创建文件")
  13658. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13659. defer f.Close()
  13660. if err != nil {
  13661. } else {
  13662. _, err = f.Write([]byte("记录日志"))
  13663. }
  13664. }
  13665. }
  13666. type Charset string
  13667. const (
  13668. UTF8 = Charset("UTF-8")
  13669. GB18030 = Charset("GB18030")
  13670. )
  13671. func ConvertToString(src string, srcCode string, tagCode string) string {
  13672. srcCoder := mahonia.NewDecoder(srcCode)
  13673. srcResult := srcCoder.ConvertString(src)
  13674. tagCoder := mahonia.NewDecoder(tagCode)
  13675. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13676. result := string(cdata)
  13677. return result
  13678. }
  13679. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13680. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13681. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13682. var token string
  13683. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13684. var api string
  13685. if miConfig.MdtrtareaAdmvs == "320921" {
  13686. 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 +
  13687. "&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
  13688. fmt.Println(api)
  13689. } else {
  13690. 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 +
  13691. "&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
  13692. }
  13693. resp, requestErr := http.Get(api)
  13694. if requestErr != nil {
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13696. return ""
  13697. }
  13698. body, ioErr := ioutil.ReadAll(resp.Body)
  13699. if ioErr != nil {
  13700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13702. return ""
  13703. }
  13704. var respJSON map[string]interface{}
  13705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13708. return ""
  13709. }
  13710. var status string
  13711. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13712. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13713. var res ResultTwo //1101结果
  13714. var res10265 ResultTwo10265 //1101结果
  13715. if status == "0" { //读卡成功
  13716. var card_info string //卡信息
  13717. var busi_card_info string
  13718. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13719. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13720. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13721. fmt.Println(card_info)
  13722. fmt.Println(busi_card_info)
  13723. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13724. result, _ := json.Marshal(respJSON)
  13725. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13726. utils.ErrorLog("解析失败:%v", err)
  13727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13728. return ""
  13729. }
  13730. res.ErrMsg = res10265.ErrMsg
  13731. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13732. res.Infcode = infocode
  13733. res.Output = res10265.Output
  13734. res.InfRefmsgid = res10265.InfRefmsgid
  13735. if res.Infcode == 0 {
  13736. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13737. if err == gorm.ErrRecordNotFound {
  13738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13739. return ""
  13740. } else if err != nil {
  13741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13742. return ""
  13743. } else {
  13744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13745. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13746. infoStr := string(Iinfos)
  13747. idetinfoStr := string(Idetinfos)
  13748. psn := &models.HisPsn{
  13749. PsnNo: res.Output.Baseinfo.PsnNo,
  13750. Age: res.Output.Baseinfo.Age,
  13751. PatientId: patient.ID,
  13752. Certno: res.Output.Baseinfo.Certno,
  13753. Brdy: res.Output.Baseinfo.Brdy,
  13754. Gend: res.Output.Baseinfo.Gend,
  13755. Naty: res.Output.Baseinfo.Naty,
  13756. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13757. PsnName: res.Output.Baseinfo.PsnName,
  13758. Idetinfo: idetinfoStr,
  13759. Insuinfo: infoStr,
  13760. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13761. CardInfo: card_info,
  13762. VerifyNumber: token,
  13763. }
  13764. service.CreateHisPsn(psn)
  13765. return token
  13766. }
  13767. }
  13768. } else {
  13769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13770. return ""
  13771. }
  13772. } else { //读卡失败
  13773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13774. return ""
  13775. }
  13776. return token
  13777. }
  13778. func DeleteExtraSpaceTwo(s string) string {
  13779. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13780. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13781. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13782. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13783. s2 := make([]byte, len(s1)) //定义字符数组切片
  13784. copy(s2, s1) //将字符串复制到切片
  13785. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13786. for len(spc_index) > 0 { //找到适配项
  13787. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13788. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13789. }
  13790. return string(s2)
  13791. }
  13792. func Remove0000(s string) string {
  13793. str := make([]rune, 0, len(s))
  13794. for _, v := range []rune(s) {
  13795. if v == 0 {
  13796. continue
  13797. }
  13798. str = append(str, v)
  13799. }
  13800. return string(str)
  13801. }
  13802. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13803. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13804. readCard := DllDef.MustFindProc("EcQuery")
  13805. pCardInfo := make([]byte, 8192)
  13806. pBusiCardInfo := make([]byte, 8192)
  13807. data := make(map[string]interface{})
  13808. //pData := make(map[string]interface{})
  13809. inputData := make(map[string]interface{})
  13810. inputData["orgId"] = code
  13811. inputData["businessType"] = "01101"
  13812. inputData["operatorId"] = operator_id
  13813. inputData["operatorName"] = operator_name
  13814. inputData["officeId"] = "001"
  13815. inputData["officeName"] = "血透室"
  13816. //
  13817. data["data"] = inputData
  13818. data["transType"] = "ec.query"
  13819. data["orgId"] = code
  13820. bytesData, _ := json.Marshal(data)
  13821. pCardInfo = bytesData
  13822. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13823. fmt.Println(ret2)
  13824. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13825. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13826. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13827. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13828. if ret2 != 0 {
  13829. return "", ""
  13830. }
  13831. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13832. }
  13833. func DeleteExtraSpace(s string) string {
  13834. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13835. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13836. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13837. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13838. s2 := make([]byte, len(s1)) //定义字符数组切片
  13839. copy(s2, s1) //将字符串复制到切片
  13840. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13841. for len(spc_index) > 0 { //找到适配项
  13842. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13843. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13844. }
  13845. return string(s2)
  13846. }
  13847. //对账
  13848. func (c *HisApiController) Post3202() {
  13849. start_time := c.GetString("start_time")
  13850. end_time := c.GetString("end_time")
  13851. //insutype := c.GetString("insutype")
  13852. clr_type := c.GetString("clr_type")
  13853. clr_org := c.GetString("clr_optins")
  13854. admin_user_id, _ := c.GetInt64("admin_user_id")
  13855. adminUser := c.GetAdminUserInfo()
  13856. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13857. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13858. if len(clr_org) == 0 {
  13859. clr_org = miConfig.MdtrtareaAdmvs
  13860. }
  13861. timeLayout := "2006-01-02"
  13862. loc, _ := time.LoadLocation("Local")
  13863. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13864. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13865. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13866. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  13867. //fixmedins_setl_cnt := int64(len(orders))
  13868. var medfee_sumamt float64
  13869. var acct_pay float64
  13870. var fund_pay_sumamt float64
  13871. for _, item := range orders {
  13872. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13873. acct_pay = acct_pay + item.AcctPay
  13874. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13875. }
  13876. //var medfee_sumamt_two float64
  13877. //var acct_pay_two float64
  13878. //var fund_pay_sumamt_two float64
  13879. //for _, item := range orders_two {
  13880. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  13881. // acct_pay_two = acct_pay_two + item.AcctPay
  13882. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  13883. //}
  13884. //var user_name string
  13885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13886. //if role.ID == 0 {
  13887. // user_name = "xxx"
  13888. //} else {
  13889. // user_name = role.UserName
  13890. //}
  13891. var res ResultSix
  13892. if config.IsOpen == 1 {
  13893. var bps []*models.BusinessParamsTwo
  13894. var bp models.BusinessParamsTwo
  13895. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  13896. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  13897. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  13898. bp.MedfeeSumamt = medfee_sumamt_str
  13899. bp.AcctPay = acct_pay_str
  13900. bp.FundPaySumamt = fund_pay_sumamt_str
  13901. bp.Insutype = "390"
  13902. bp.StmtBegndate = start_time
  13903. bp.ClrType = clr_type
  13904. bp.SetlOptins = clr_org
  13905. bp.StmtEnddate = end_time
  13906. bps = append(bps, &bp)
  13907. data := make(map[string]interface{})
  13908. data["bps"] = bps
  13909. data["org_name"] = miConfig.OrgName
  13910. data["doctor"] = role.UserName
  13911. data["fixmedins_code"] = miConfig.Code
  13912. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13913. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13914. if miConfig.MdtrtareaAdmvs == "421300" {
  13915. client := &http.Client{}
  13916. bytesData, _ := json.Marshal(data)
  13917. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  13918. resp, _ := client.Do(req)
  13919. defer resp.Body.Close()
  13920. body, ioErr := ioutil.ReadAll(resp.Body)
  13921. if ioErr != nil {
  13922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13924. return
  13925. }
  13926. var respJSON map[string]interface{}
  13927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13930. return
  13931. }
  13932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13933. userJSONBytes, _ := json.Marshal(respJSON)
  13934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13935. utils.ErrorLog("解析失败:%v", err)
  13936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13937. return
  13938. }
  13939. }
  13940. if res.Infcode == 0 {
  13941. c.ServeSuccessJSON(map[string]interface{}{
  13942. "msg": "发起成功",
  13943. })
  13944. } else {
  13945. c.ServeSuccessJSON(map[string]interface{}{
  13946. "code": -10,
  13947. "msg": res.ErrMsg,
  13948. })
  13949. }
  13950. }
  13951. }
  13952. func (c *HisApiController) Post3501() {
  13953. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13954. data := make(map[string]interface{})
  13955. var struct3501s []models.Struct3501
  13956. var struct3501 models.Struct3501
  13957. struct3501.OrgName = miConfig.OrgName
  13958. struct3501.AccessKey = miConfig.AccessKey
  13959. struct3501.RequestUrl = miConfig.Url
  13960. struct3501.SecretKey = miConfig.SecretKey
  13961. struct3501.ManuDate = "2022-08-17"
  13962. struct3501.FixmedinsBchno = ""
  13963. struct3501.ManuLotnum = ""
  13964. struct3501.RxFlag = "0"
  13965. struct3501.ExpyEnd = "2022-08-17"
  13966. struct3501.Invdate = "2022-08-17"
  13967. struct3501.InvCnt = "20.25"
  13968. struct3501.Memo = ""
  13969. struct3501.MedListCodg = "XB01ABD056B002020200517"
  13970. struct3501.FixmedinsHilistId = miConfig.Code
  13971. struct3501.FixmedinsHilistName = miConfig.OrgName
  13972. struct3501s = append(struct3501s, struct3501)
  13973. data["struct_3501s"] = struct3501s
  13974. client := &http.Client{}
  13975. bytesData, _ := json.Marshal(data)
  13976. var req *http.Request
  13977. if miConfig.MdtrtareaAdmvs == "320921" {
  13978. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13979. } else {
  13980. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  13981. }
  13982. resp, _ := client.Do(req)
  13983. defer resp.Body.Close()
  13984. body, ioErr := ioutil.ReadAll(resp.Body)
  13985. if ioErr != nil {
  13986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13988. return
  13989. }
  13990. var respJSON map[string]interface{}
  13991. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13994. return
  13995. }
  13996. var res ResultSix
  13997. var resSix10265 ResultSix10265 //1101结果
  13998. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13999. result, _ := json.Marshal(respJSON)
  14000. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14001. utils.ErrorLog("解析失败:%v", err)
  14002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14003. return
  14004. }
  14005. res.InfRefmsgid = resSix10265.InfRefmsgid
  14006. res.Output = resSix10265.Output
  14007. res.ErrMsg = resSix10265.ErrMsg
  14008. res.Cainfo = resSix10265.Cainfo
  14009. res.WarnMsg = resSix10265.WarnMsg
  14010. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14011. res.Infcode = infocode
  14012. if infocode == 0 {
  14013. c.ServeSuccessJSON(map[string]interface{}{
  14014. "msg": "上传成功",
  14015. })
  14016. return
  14017. } else {
  14018. c.ServeSuccessJSON(map[string]interface{}{
  14019. "failed_code": -10,
  14020. "msg": res.ErrMsg,
  14021. })
  14022. return
  14023. }
  14024. }
  14025. func (c *HisApiController) Post3502() {
  14026. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14027. data := make(map[string]interface{})
  14028. var struct3502s []models.Struct3502
  14029. var struct3502 models.Struct3502
  14030. struct3502.OrgName = miConfig.OrgName
  14031. struct3502.AccessKey = miConfig.AccessKey
  14032. struct3502.RequestUrl = miConfig.Url
  14033. struct3502.SecretKey = miConfig.SecretKey
  14034. struct3502.ManuDate = "2022-08-15"
  14035. struct3502.FixmedinsBchno = ""
  14036. struct3502.ManuLotnum = ""
  14037. struct3502.RxFlag = "0"
  14038. struct3502.ExpyEnd = "2022-08-15"
  14039. struct3502.Invdate = "2022-08-15"
  14040. struct3502.InvCnt = "20.25"
  14041. struct3502.Memo = ""
  14042. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14043. struct3502.FixmedinsHilistId = miConfig.Code
  14044. struct3502.FixmedinsHilistName = miConfig.OrgName
  14045. struct3502s = append(struct3502s, struct3502)
  14046. data["struct_3502s"] = struct3502s
  14047. client := &http.Client{}
  14048. bytesData, _ := json.Marshal(data)
  14049. var req *http.Request
  14050. if miConfig.MdtrtareaAdmvs == "320921" {
  14051. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14052. } else {
  14053. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14054. }
  14055. resp, _ := client.Do(req)
  14056. defer resp.Body.Close()
  14057. body, ioErr := ioutil.ReadAll(resp.Body)
  14058. if ioErr != nil {
  14059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14061. return
  14062. }
  14063. var respJSON map[string]interface{}
  14064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14067. return
  14068. }
  14069. var res ResultSix
  14070. var resSix10265 ResultSix10265 //1101结果
  14071. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14072. result, _ := json.Marshal(respJSON)
  14073. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14074. utils.ErrorLog("解析失败:%v", err)
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14076. return
  14077. }
  14078. res.InfRefmsgid = resSix10265.InfRefmsgid
  14079. res.Output = resSix10265.Output
  14080. res.ErrMsg = resSix10265.ErrMsg
  14081. res.Cainfo = resSix10265.Cainfo
  14082. res.WarnMsg = resSix10265.WarnMsg
  14083. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14084. res.Infcode = infocode
  14085. if infocode == 0 {
  14086. c.ServeSuccessJSON(map[string]interface{}{
  14087. "msg": "上传成功",
  14088. })
  14089. return
  14090. } else {
  14091. c.ServeSuccessJSON(map[string]interface{}{
  14092. "failed_code": -10,
  14093. "msg": res.ErrMsg,
  14094. })
  14095. return
  14096. }
  14097. }
  14098. func (c *HisApiController) Post3503() {
  14099. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14100. data := make(map[string]interface{})
  14101. var struct3501s []models.Struct3501
  14102. var struct3501 models.Struct3501
  14103. struct3501.OrgName = miConfig.OrgName
  14104. struct3501.AccessKey = miConfig.AccessKey
  14105. struct3501.RequestUrl = miConfig.Url
  14106. struct3501.SecretKey = miConfig.SecretKey
  14107. struct3501.ManuDate = "2022-08-15"
  14108. struct3501.FixmedinsBchno = ""
  14109. struct3501.ManuLotnum = ""
  14110. struct3501.RxFlag = "0"
  14111. struct3501.ExpyEnd = "2022-08-15"
  14112. struct3501.Invdate = "2022-08-15"
  14113. struct3501.InvCnt = "20.25"
  14114. struct3501.Memo = ""
  14115. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14116. struct3501.FixmedinsHilistId = miConfig.Code
  14117. struct3501.FixmedinsHilistName = miConfig.OrgName
  14118. struct3501s = append(struct3501s, struct3501)
  14119. data["struct_3501s"] = struct3501s
  14120. client := &http.Client{}
  14121. bytesData, _ := json.Marshal(data)
  14122. var req *http.Request
  14123. if miConfig.MdtrtareaAdmvs == "320921" {
  14124. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14125. } else {
  14126. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14127. }
  14128. resp, _ := client.Do(req)
  14129. defer resp.Body.Close()
  14130. body, ioErr := ioutil.ReadAll(resp.Body)
  14131. if ioErr != nil {
  14132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14134. return
  14135. }
  14136. var respJSON map[string]interface{}
  14137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14140. return
  14141. }
  14142. var res ResultSix
  14143. var resSix10265 ResultSix10265 //1101结果
  14144. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14145. result, _ := json.Marshal(respJSON)
  14146. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14147. utils.ErrorLog("解析失败:%v", err)
  14148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14149. return
  14150. }
  14151. res.InfRefmsgid = resSix10265.InfRefmsgid
  14152. res.Output = resSix10265.Output
  14153. res.ErrMsg = resSix10265.ErrMsg
  14154. res.Cainfo = resSix10265.Cainfo
  14155. res.WarnMsg = resSix10265.WarnMsg
  14156. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14157. res.Infcode = infocode
  14158. if infocode == 0 {
  14159. c.ServeSuccessJSON(map[string]interface{}{
  14160. "msg": "上传成功",
  14161. })
  14162. return
  14163. } else {
  14164. c.ServeSuccessJSON(map[string]interface{}{
  14165. "failed_code": -10,
  14166. "msg": res.ErrMsg,
  14167. })
  14168. return
  14169. }
  14170. }
  14171. func (c *HisApiController) Post3504() {
  14172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14173. data := make(map[string]interface{})
  14174. var struct3501s []models.Struct3501
  14175. var struct3501 models.Struct3501
  14176. struct3501.OrgName = miConfig.OrgName
  14177. struct3501.AccessKey = miConfig.AccessKey
  14178. struct3501.RequestUrl = miConfig.Url
  14179. struct3501.SecretKey = miConfig.SecretKey
  14180. struct3501.ManuDate = "2022-08-15"
  14181. struct3501.FixmedinsBchno = ""
  14182. struct3501.ManuLotnum = ""
  14183. struct3501.RxFlag = "0"
  14184. struct3501.ExpyEnd = "2022-08-15"
  14185. struct3501.Invdate = "2022-08-15"
  14186. struct3501.InvCnt = "20.25"
  14187. struct3501.Memo = ""
  14188. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14189. struct3501.FixmedinsHilistId = miConfig.Code
  14190. struct3501.FixmedinsHilistName = miConfig.OrgName
  14191. struct3501s = append(struct3501s, struct3501)
  14192. data["struct_3501s"] = struct3501s
  14193. client := &http.Client{}
  14194. bytesData, _ := json.Marshal(data)
  14195. var req *http.Request
  14196. if miConfig.MdtrtareaAdmvs == "320921" {
  14197. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14198. } else {
  14199. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14200. }
  14201. resp, _ := client.Do(req)
  14202. defer resp.Body.Close()
  14203. body, ioErr := ioutil.ReadAll(resp.Body)
  14204. if ioErr != nil {
  14205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14207. return
  14208. }
  14209. var respJSON map[string]interface{}
  14210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14213. return
  14214. }
  14215. var res ResultSix
  14216. var resSix10265 ResultSix10265 //1101结果
  14217. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14218. result, _ := json.Marshal(respJSON)
  14219. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14220. utils.ErrorLog("解析失败:%v", err)
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. res.InfRefmsgid = resSix10265.InfRefmsgid
  14225. res.Output = resSix10265.Output
  14226. res.ErrMsg = resSix10265.ErrMsg
  14227. res.Cainfo = resSix10265.Cainfo
  14228. res.WarnMsg = resSix10265.WarnMsg
  14229. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14230. res.Infcode = infocode
  14231. if infocode == 0 {
  14232. c.ServeSuccessJSON(map[string]interface{}{
  14233. "msg": "上传成功",
  14234. })
  14235. return
  14236. } else {
  14237. c.ServeSuccessJSON(map[string]interface{}{
  14238. "failed_code": -10,
  14239. "msg": res.ErrMsg,
  14240. })
  14241. return
  14242. }
  14243. }
  14244. func (c *HisApiController) Post3505() {
  14245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14246. data := make(map[string]interface{})
  14247. var struct3501s []models.Struct3501
  14248. var struct3501 models.Struct3501
  14249. struct3501.OrgName = miConfig.OrgName
  14250. struct3501.AccessKey = miConfig.AccessKey
  14251. struct3501.RequestUrl = miConfig.Url
  14252. struct3501.SecretKey = miConfig.SecretKey
  14253. struct3501.ManuDate = "2022-08-15"
  14254. struct3501.FixmedinsBchno = ""
  14255. struct3501.ManuLotnum = ""
  14256. struct3501.RxFlag = "0"
  14257. struct3501.ExpyEnd = "2022-08-15"
  14258. struct3501.Invdate = "2022-08-15"
  14259. struct3501.InvCnt = "20.25"
  14260. struct3501.Memo = ""
  14261. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14262. struct3501.FixmedinsHilistId = miConfig.Code
  14263. struct3501.FixmedinsHilistName = miConfig.OrgName
  14264. struct3501s = append(struct3501s, struct3501)
  14265. data["struct_3501s"] = struct3501s
  14266. client := &http.Client{}
  14267. bytesData, _ := json.Marshal(data)
  14268. var req *http.Request
  14269. if miConfig.MdtrtareaAdmvs == "320921" {
  14270. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14271. } else {
  14272. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14273. }
  14274. resp, _ := client.Do(req)
  14275. defer resp.Body.Close()
  14276. body, ioErr := ioutil.ReadAll(resp.Body)
  14277. if ioErr != nil {
  14278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14280. return
  14281. }
  14282. var respJSON map[string]interface{}
  14283. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14286. return
  14287. }
  14288. var res ResultSix
  14289. var resSix10265 ResultSix10265 //1101结果
  14290. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14291. result, _ := json.Marshal(respJSON)
  14292. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14293. utils.ErrorLog("解析失败:%v", err)
  14294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14295. return
  14296. }
  14297. res.InfRefmsgid = resSix10265.InfRefmsgid
  14298. res.Output = resSix10265.Output
  14299. res.ErrMsg = resSix10265.ErrMsg
  14300. res.Cainfo = resSix10265.Cainfo
  14301. res.WarnMsg = resSix10265.WarnMsg
  14302. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14303. res.Infcode = infocode
  14304. if infocode == 0 {
  14305. c.ServeSuccessJSON(map[string]interface{}{
  14306. "msg": "上传成功",
  14307. })
  14308. return
  14309. } else {
  14310. c.ServeSuccessJSON(map[string]interface{}{
  14311. "failed_code": -10,
  14312. "msg": res.ErrMsg,
  14313. })
  14314. return
  14315. }
  14316. }
  14317. func (c *HisApiController) Post3506() {
  14318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14319. data := make(map[string]interface{})
  14320. var struct3501s []models.Struct3501
  14321. var struct3501 models.Struct3501
  14322. struct3501.OrgName = miConfig.OrgName
  14323. struct3501.AccessKey = miConfig.AccessKey
  14324. struct3501.RequestUrl = miConfig.Url
  14325. struct3501.SecretKey = miConfig.SecretKey
  14326. struct3501.ManuDate = "2022-08-15"
  14327. struct3501.FixmedinsBchno = ""
  14328. struct3501.ManuLotnum = ""
  14329. struct3501.RxFlag = "0"
  14330. struct3501.ExpyEnd = "2022-08-15"
  14331. struct3501.Invdate = "2022-08-15"
  14332. struct3501.InvCnt = "20.25"
  14333. struct3501.Memo = ""
  14334. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14335. struct3501.FixmedinsHilistId = miConfig.Code
  14336. struct3501.FixmedinsHilistName = miConfig.OrgName
  14337. struct3501s = append(struct3501s, struct3501)
  14338. data["struct_3501s"] = struct3501s
  14339. client := &http.Client{}
  14340. bytesData, _ := json.Marshal(data)
  14341. var req *http.Request
  14342. if miConfig.MdtrtareaAdmvs == "320921" {
  14343. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14344. } else {
  14345. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14346. }
  14347. resp, _ := client.Do(req)
  14348. defer resp.Body.Close()
  14349. body, ioErr := ioutil.ReadAll(resp.Body)
  14350. if ioErr != nil {
  14351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14353. return
  14354. }
  14355. var respJSON map[string]interface{}
  14356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14359. return
  14360. }
  14361. var res ResultSix
  14362. var resSix10265 ResultSix10265 //1101结果
  14363. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14364. result, _ := json.Marshal(respJSON)
  14365. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14366. utils.ErrorLog("解析失败:%v", err)
  14367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14368. return
  14369. }
  14370. res.InfRefmsgid = resSix10265.InfRefmsgid
  14371. res.Output = resSix10265.Output
  14372. res.ErrMsg = resSix10265.ErrMsg
  14373. res.Cainfo = resSix10265.Cainfo
  14374. res.WarnMsg = resSix10265.WarnMsg
  14375. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14376. res.Infcode = infocode
  14377. if infocode == 0 {
  14378. c.ServeSuccessJSON(map[string]interface{}{
  14379. "msg": "上传成功",
  14380. })
  14381. return
  14382. } else {
  14383. c.ServeSuccessJSON(map[string]interface{}{
  14384. "failed_code": -10,
  14385. "msg": res.ErrMsg,
  14386. })
  14387. return
  14388. }
  14389. }
  14390. func (c *HisApiController) Post3507() {
  14391. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14392. data := make(map[string]interface{})
  14393. var struct3501s []models.Struct3501
  14394. var struct3501 models.Struct3501
  14395. struct3501.OrgName = miConfig.OrgName
  14396. struct3501.AccessKey = miConfig.AccessKey
  14397. struct3501.RequestUrl = miConfig.Url
  14398. struct3501.SecretKey = miConfig.SecretKey
  14399. struct3501.ManuDate = "2022-08-15"
  14400. struct3501.FixmedinsBchno = ""
  14401. struct3501.ManuLotnum = ""
  14402. struct3501.RxFlag = "0"
  14403. struct3501.ExpyEnd = "2022-08-15"
  14404. struct3501.Invdate = "2022-08-15"
  14405. struct3501.InvCnt = "20.25"
  14406. struct3501.Memo = ""
  14407. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14408. struct3501.FixmedinsHilistId = miConfig.Code
  14409. struct3501.FixmedinsHilistName = miConfig.OrgName
  14410. struct3501s = append(struct3501s, struct3501)
  14411. data["struct_3501s"] = struct3501s
  14412. client := &http.Client{}
  14413. bytesData, _ := json.Marshal(data)
  14414. var req *http.Request
  14415. if miConfig.MdtrtareaAdmvs == "320921" {
  14416. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14417. } else {
  14418. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14419. }
  14420. resp, _ := client.Do(req)
  14421. defer resp.Body.Close()
  14422. body, ioErr := ioutil.ReadAll(resp.Body)
  14423. if ioErr != nil {
  14424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14426. return
  14427. }
  14428. var respJSON map[string]interface{}
  14429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14432. return
  14433. }
  14434. var res ResultSix
  14435. var resSix10265 ResultSix10265 //1101结果
  14436. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14437. result, _ := json.Marshal(respJSON)
  14438. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14439. utils.ErrorLog("解析失败:%v", err)
  14440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14441. return
  14442. }
  14443. res.InfRefmsgid = resSix10265.InfRefmsgid
  14444. res.Output = resSix10265.Output
  14445. res.ErrMsg = resSix10265.ErrMsg
  14446. res.Cainfo = resSix10265.Cainfo
  14447. res.WarnMsg = resSix10265.WarnMsg
  14448. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14449. res.Infcode = infocode
  14450. if infocode == 0 {
  14451. c.ServeSuccessJSON(map[string]interface{}{
  14452. "msg": "上传成功",
  14453. })
  14454. return
  14455. } else {
  14456. c.ServeSuccessJSON(map[string]interface{}{
  14457. "failed_code": -10,
  14458. "msg": res.ErrMsg,
  14459. })
  14460. return
  14461. }
  14462. }