his_api_controller.go 595KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. //beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. //beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. //beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. //beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  94. }
  95. func (c *HisApiController) Get4201A() {
  96. order_id, _ := c.GetInt64("order_id")
  97. admin_user_id, _ := c.GetInt64("admin_user_id")
  98. order, _ := service.GetHisOrderByIDTwo(order_id)
  99. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  100. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  101. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  102. order_info = append(order_info, order_info_two...)
  103. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. department, _ := service.GetDepartMentDetail(his.Departments)
  106. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  107. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  108. if order.ID == 0 {
  109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  110. return
  111. }
  112. var struct4201A models.Struct4201A
  113. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  114. for _, items := range order_info {
  115. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  116. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  117. fsiOPFLD.MedType = "14"
  118. fsiOPFLD.BkkpSn = items.OrderNumber
  119. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  120. fsiOPFLD.FixmedinsCode = miConfig.Code
  121. fsiOPFLD.FixmedinsName = miConfig.OrgName
  122. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  123. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  124. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  125. if items.AdviceId > 0 && items.ProjectId == 0 {
  126. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  127. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  128. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  129. fsiOPFLD.BilgDeptName = department.Name
  130. fsiOPFLD.BilgDeptCodg = department.Number
  131. fsiOPFLD.BilgDrCode = doctor.DoctorCode
  132. fsiOPFLD.BilgDrName = doctor.UserName
  133. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  134. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  135. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  136. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  137. fsiOPFLD.BilgDeptName = department.Name
  138. fsiOPFLD.BilgDeptCodg = department.Number
  139. fsiOPFLD.BilgDrCode = doctor.DoctorCode
  140. fsiOPFLD.BilgDrName = doctor.UserName
  141. }
  142. //fsiOPFLD.DetItemFeeSumamt = items.DetItemFeeSumamt
  143. fsiOPFLD.MedChrgitmType = "09"
  144. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  145. fsiOPFLD.BilgDeptCodg = department.Number
  146. fsiOPFLD.BilgDeptName = department.Name
  147. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  148. }
  149. struct4201A.Fopfd = fsiOPFLDs
  150. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  151. }
  152. func (c *HisApiController) Get4202() {
  153. order_id, _ := c.GetInt64("order_id")
  154. admin_user_id, _ := c.GetInt64("admin_user_id")
  155. order, _ := service.GetHisOrderByIDTwo(order_id)
  156. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  157. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  159. if order.ID == 0 {
  160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  161. return
  162. }
  163. var struct4202 models.Struct4202
  164. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  165. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  166. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  167. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  168. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  169. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  170. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  171. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  172. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  173. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  174. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  175. var config []*models.HisXtDiagnoseConfig
  176. for _, item := range diagnosis_ids {
  177. id, _ := strconv.ParseInt(item, 10, 64)
  178. diagnosisConfig, _ := service.FindDiagnoseById(id)
  179. config = append(config, &diagnosisConfig)
  180. }
  181. var tempDiaginfos []models.OwnPayPatnDiagListD
  182. for index, item := range config {
  183. if index == 0 {
  184. var tempDiaginfo models.OwnPayPatnDiagListD
  185. tempDiaginfo.InoutDiagType = "1"
  186. tempDiaginfo.DiagCode = item.CountryCode
  187. tempDiaginfo.DiagName = item.CountryContentName
  188. tempDiaginfo.DiagType = "1"
  189. tempDiaginfo.DiagSrtNo = "1"
  190. tempDiaginfo.MaindiagFlag = "1"
  191. tempDiaginfo.ValiFlag = "1"
  192. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  193. } else {
  194. var tempDiaginfo models.OwnPayPatnDiagListD
  195. tempDiaginfo.DiagCode = item.CountryCode
  196. tempDiaginfo.DiagName = item.CountryContentName
  197. tempDiaginfo.DiagType = "2"
  198. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  199. tempDiaginfo.MaindiagFlag = "0"
  200. tempDiaginfo.ValiFlag = "1"
  201. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  202. }
  203. }
  204. struct4202.ODiagListD = tempDiaginfos
  205. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  206. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  207. var res2 ResultSix
  208. var respJSON2 map[string]interface{}
  209. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. userJSONBytes2, _ := json.Marshal(respJSON2)
  215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  216. utils.ErrorLog("解析失败:%v", err)
  217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  218. return
  219. }
  220. if res2.Infcode != 0 {
  221. c.ServeSuccessJSON(map[string]interface{}{
  222. "failed_code": -10,
  223. "msg": res2.ErrMsg,
  224. })
  225. return
  226. } else {
  227. c.ServeSuccessJSON(map[string]interface{}{
  228. "msg": "上传成功",
  229. })
  230. }
  231. }
  232. func (c *HisApiController) Get4203() {
  233. admin_user_id, _ := c.GetInt64("admin_user_id")
  234. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  235. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  236. order_id, _ := c.GetInt64("order_id")
  237. order, _ := service.GetHisOrderByIDTwo(order_id)
  238. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  239. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  240. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  241. var res2 ResultSix
  242. var respJSON2 map[string]interface{}
  243. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  246. return
  247. }
  248. userJSONBytes2, _ := json.Marshal(respJSON2)
  249. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  250. utils.ErrorLog("解析失败:%v", err)
  251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  252. return
  253. }
  254. if res2.Infcode != 0 {
  255. c.ServeSuccessJSON(map[string]interface{}{
  256. "failed_code": -10,
  257. "msg": res2.ErrMsg,
  258. })
  259. return
  260. } else {
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "msg": "上传成功",
  263. })
  264. }
  265. }
  266. //func (c *HisApiController) Get4205(){
  267. //
  268. //
  269. //}
  270. //func (c *HisApiController) Get4207(){
  271. //
  272. //
  273. //}
  274. //func (c *HisApiController) Get4208(){
  275. //
  276. //
  277. //}
  278. //func (c *HisApiController) Get4209(){
  279. //
  280. //
  281. //}
  282. type Result3101 struct {
  283. Infcode string `json:"infcode"`
  284. InfRefmsgid string `json:"inf_refmsgid"`
  285. RefmsgTime string `json:"refmsg_time"`
  286. RespondTime string `json:"respond_time"`
  287. Enctype string `json:"enctype"`
  288. Signtype string `json:"signtype"`
  289. ErrMsg string `json:"err_msg"`
  290. Output struct {
  291. Result []struct {
  292. JudgeResultDetailDtos []struct {
  293. VolaItemType string `json:"vola_item_type"`
  294. MdtrtID string `json:"mdtrt_id"`
  295. JrdID string `json:"jrd_id"`
  296. PatnID string `json:"patn_id"`
  297. RxID string `json:"rx_id"`
  298. VolaAmt interface{} `json:"vola_amt"`
  299. } `json:"judge_result_detail_dtos"`
  300. RuleID string `json:"rule_id"`
  301. VolaEvid string `json:"vola_evid"`
  302. MdtrtID string `json:"mdtrt_id"`
  303. RuleName string `json:"rule_name"`
  304. VolaAmtStas string `json:"vola_amt_stas"`
  305. JrID string `json:"jr_id"`
  306. PatnID string `json:"patn_id"`
  307. SevDeg string `json:"sev_deg"`
  308. VolaAmt float64 `json:"vola_amt"`
  309. VolaBhvrType string `json:"vola_bhvr_type"`
  310. VolaCont string `json:"vola_cont"`
  311. } `json:"result"`
  312. } `json:"output"`
  313. }
  314. func (c *HisApiController) ReadEleToken() {
  315. admin_user_id, _ := c.GetInt64("admin_user_id")
  316. his_patient_id, _ := c.GetInt64("his_patient_id")
  317. adminUser := c.GetAdminUserInfo()
  318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  319. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  320. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  321. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  322. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  323. if len(tokens) > 0 {
  324. c.ServeSuccessJSON(map[string]interface{}{
  325. "msg": "读取成功",
  326. })
  327. } else {
  328. c.ServeSuccessJSON(map[string]interface{}{
  329. "failed_code": -10,
  330. "msg": "读取失败",
  331. })
  332. }
  333. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  334. if initFlag == 0 {
  335. c.TestGetBasBaseInit()
  336. }
  337. token := c.GetEleBaseInfo()
  338. token = Remove0000(token)
  339. if len(token) > 0 {
  340. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  341. saveLog(result2, requestLog2, "1101", "获取人员信息")
  342. var res ResultTwo
  343. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  344. utils.ErrorLog("解析失败:%v", err)
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  346. return
  347. }
  348. if res.Infcode == 0 {
  349. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  350. if err == gorm.ErrRecordNotFound {
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  352. return
  353. } else if err != nil {
  354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  355. return
  356. } else {
  357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  359. infoStr := string(Iinfos)
  360. idetinfoStr := string(Idetinfos)
  361. psn := &models.HisPsn{
  362. PsnNo: res.Output.Baseinfo.PsnNo,
  363. Age: res.Output.Baseinfo.Age,
  364. PatientId: patient.ID,
  365. Certno: res.Output.Baseinfo.Certno,
  366. Brdy: res.Output.Baseinfo.Brdy,
  367. Gend: res.Output.Baseinfo.Gend,
  368. Naty: res.Output.Baseinfo.Naty,
  369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  370. PsnName: res.Output.Baseinfo.PsnName,
  371. Idetinfo: idetinfoStr,
  372. Insuinfo: infoStr,
  373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  374. CardInfo: "",
  375. VerifyNumber: token,
  376. }
  377. service.CreateHisPsn(psn)
  378. c.ServeSuccessJSON(map[string]interface{}{
  379. "msg": "读取成功",
  380. })
  381. }
  382. } else {
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  384. return
  385. }
  386. } else {
  387. c.ServeSuccessJSON(map[string]interface{}{
  388. "failed_code": -10,
  389. "msg": "读取失败",
  390. })
  391. }
  392. } else if miConfig.MdtrtareaAdmvs == "350500" {
  393. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  394. if len(errMsg) == 0 {
  395. type ELeData struct {
  396. Data struct {
  397. IdNo string `json:"idNo"`
  398. IdType string `json:"idType"`
  399. UserName string `json:"userName"`
  400. EcToken string `json:"ecToken"`
  401. InsuOrg string `json:"insuOrg"`
  402. Gender string `json:"gender"`
  403. Birthday string `json:"birthday"`
  404. Nationality string `json:"nationality"`
  405. Email string `json:"email"`
  406. Extra string `json:"extra"`
  407. } `json:"data"`
  408. Code int `json:"code"`
  409. Message string `json:"message"`
  410. }
  411. var ele ELeData
  412. err := json.Unmarshal([]byte(outPutInfo), &ele)
  413. if err != nil {
  414. utils.ErrorLog("解析失败:%v", err)
  415. }
  416. token := ele.Data.EcToken
  417. if len(token) > 0 {
  418. psn := &models.HisPsn{
  419. PsnNo: his.PsnNo,
  420. Age: 0,
  421. PatientId: his.PatientId,
  422. Certno: his.Certno,
  423. Brdy: his.Brdy,
  424. Gend: his.Gend,
  425. Naty: his.Naty,
  426. PsnCertType: his.PsnCertType,
  427. PsnName: his.PsnName,
  428. Idetinfo: his.Idetinfo,
  429. Insuinfo: his.Iinfo,
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. CardInfo: outPutInfo,
  432. VerifyNumber: token,
  433. }
  434. service.CreateHisPsn(psn)
  435. }
  436. if len(token) > 0 {
  437. c.ServeSuccessJSON(map[string]interface{}{
  438. "msg": "读取成功",
  439. })
  440. } else {
  441. c.ServeSuccessJSON(map[string]interface{}{
  442. "failed_code": -10,
  443. "msg": "读取失败",
  444. })
  445. }
  446. }
  447. } else if miConfig.MdtrtareaAdmvs == "360399" {
  448. if initFlag == 0 {
  449. c.TestGetJiangXiBasBaseInit()
  450. }
  451. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  452. type ELeData struct {
  453. Data struct {
  454. IdNo string `json:"idNo"`
  455. IdType string `json:"idType"`
  456. UserName string `json:"userName"`
  457. EcToken string `json:"ecToken"`
  458. InsuOrg string `json:"insuOrg"`
  459. Gender string `json:"gender"`
  460. Birthday string `json:"birthday"`
  461. Nationality string `json:"nationality"`
  462. Email string `json:"email"`
  463. Extra string `json:"extra"`
  464. } `json:"data"`
  465. Code int `json:"code"`
  466. Message string `json:"message"`
  467. }
  468. var ele ELeData
  469. err := json.Unmarshal([]byte(json_result), &ele)
  470. if err != nil {
  471. utils.ErrorLog("解析失败:%v", err)
  472. }
  473. token := ele.Data.EcToken
  474. token = Remove0000(token)
  475. fmt.Println(ele.Data.UserName)
  476. 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)
  477. saveLog(result2, requestLog2, "1101", "获取人员信息")
  478. var res ResultTwo
  479. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  480. utils.ErrorLog("解析失败:%v", err)
  481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  482. return
  483. }
  484. if res.Infcode == 0 {
  485. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  486. if err == gorm.ErrRecordNotFound {
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  488. return
  489. } else if err != nil {
  490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  491. return
  492. } else {
  493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  494. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  495. infoStr := string(Iinfos)
  496. idetinfoStr := string(Idetinfos)
  497. psn := &models.HisPsn{
  498. PsnNo: res.Output.Baseinfo.PsnNo,
  499. Age: res.Output.Baseinfo.Age,
  500. PatientId: patient.ID,
  501. Certno: res.Output.Baseinfo.Certno,
  502. Brdy: res.Output.Baseinfo.Brdy,
  503. Gend: res.Output.Baseinfo.Gend,
  504. Naty: res.Output.Baseinfo.Naty,
  505. PsnCertType: res.Output.Baseinfo.PsnCertType,
  506. PsnName: res.Output.Baseinfo.PsnName,
  507. Idetinfo: idetinfoStr,
  508. Insuinfo: infoStr,
  509. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  510. CardInfo: "",
  511. VerifyNumber: token,
  512. }
  513. service.CreateHisPsn(psn)
  514. c.ServeSuccessJSON(map[string]interface{}{
  515. "patient": patient,
  516. "number": token,
  517. })
  518. }
  519. } else {
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  521. return
  522. }
  523. } else if miConfig.MdtrtareaAdmvs == "430800" {
  524. if initFlag == 0 {
  525. c.TestGetJiangXiBasBaseInit()
  526. }
  527. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  528. type ELeData struct {
  529. Data struct {
  530. IdNo string `json:"idNo"`
  531. IdType string `json:"idType"`
  532. UserName string `json:"userName"`
  533. EcToken string `json:"ecToken"`
  534. InsuOrg string `json:"insuOrg"`
  535. Gender string `json:"gender"`
  536. Birthday string `json:"birthday"`
  537. Nationality string `json:"nationality"`
  538. Email string `json:"email"`
  539. Extra string `json:"extra"`
  540. } `json:"data"`
  541. Code int `json:"code"`
  542. Message string `json:"message"`
  543. }
  544. var ele ELeData
  545. err := json.Unmarshal([]byte(json_result), &ele)
  546. if err != nil {
  547. utils.ErrorLog("解析失败:%v", err)
  548. }
  549. token := ele.Data.EcToken
  550. token = Remove0000(token)
  551. fmt.Println(ele.Data.UserName)
  552. 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)
  553. saveLog(result2, requestLog2, "1101", "获取人员信息")
  554. var res ResultTwo
  555. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  556. utils.ErrorLog("解析失败:%v", err)
  557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  558. return
  559. }
  560. if res.Infcode == 0 {
  561. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  562. if err == gorm.ErrRecordNotFound {
  563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  564. return
  565. } else if err != nil {
  566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  567. return
  568. } else {
  569. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  570. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  571. infoStr := string(Iinfos)
  572. idetinfoStr := string(Idetinfos)
  573. psn := &models.HisPsn{
  574. PsnNo: res.Output.Baseinfo.PsnNo,
  575. Age: res.Output.Baseinfo.Age,
  576. PatientId: patient.ID,
  577. Certno: res.Output.Baseinfo.Certno,
  578. Brdy: res.Output.Baseinfo.Brdy,
  579. Gend: res.Output.Baseinfo.Gend,
  580. Naty: res.Output.Baseinfo.Naty,
  581. PsnCertType: res.Output.Baseinfo.PsnCertType,
  582. PsnName: res.Output.Baseinfo.PsnName,
  583. Idetinfo: idetinfoStr,
  584. Insuinfo: infoStr,
  585. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  586. CardInfo: "",
  587. VerifyNumber: token,
  588. }
  589. service.CreateHisPsn(psn)
  590. c.ServeSuccessJSON(map[string]interface{}{
  591. "patient": patient,
  592. "number": token,
  593. })
  594. }
  595. } else {
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  597. return
  598. }
  599. }
  600. }
  601. func (c *HisApiController) Get9001() {
  602. adminUser := c.GetAdminUserInfo()
  603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  604. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  605. if miConfig.MdtrtareaAdmvs == "350500" {
  606. service.GetFjAuthorizationInfo(miConfig.Code)
  607. } else if miConfig.MdtrtareaAdmvs == "131023" {
  608. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  609. var dat map[string]interface{}
  610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  611. fmt.Println(dat)
  612. } else {
  613. fmt.Println(err)
  614. }
  615. userJSONBytes, _ := json.Marshal(dat)
  616. var res models.Result9001
  617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  618. utils.ErrorLog("解析失败:%v", err)
  619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  620. return
  621. }
  622. } else {
  623. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  624. var dat map[string]interface{}
  625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  626. fmt.Println(dat)
  627. } else {
  628. fmt.Println(err)
  629. }
  630. userJSONBytes, _ := json.Marshal(dat)
  631. var res models.Result9001
  632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  633. utils.ErrorLog("解析失败:%v", err)
  634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  635. return
  636. }
  637. }
  638. }
  639. 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) {
  640. var res Result3101
  641. adminUser := c.GetAdminUserInfo()
  642. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  643. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  644. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  645. //record_time := c.GetString("record_time")
  646. //trig_scen := c.GetString("trig_scen")
  647. timeLayout := "2006-01-02"
  648. loc, _ := time.LoadLocation("Local")
  649. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  650. if err != nil {
  651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  652. return res
  653. }
  654. recordDateTime := theTime.Unix()
  655. var patientPrescription models.HisPrescriptionInfo
  656. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  657. //if patientPrescription.ID == 0 {
  658. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  659. //}
  660. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  661. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  662. //
  663. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  664. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  665. var pp models.PublicParams
  666. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  667. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  668. pp.FixmedinsName = miConfig.OrgName
  669. pp.FixmedinsCode = miConfig.Code
  670. pp.RequestUrl = miConfig.Url
  671. pp.Cainfo = miConfig.Cainfo
  672. pp.SecretKey = miConfig.SecretKey
  673. pp.AccessKey = miConfig.AccessKey
  674. pp.OpterName = roles.UserName
  675. var config []*models.HisXtDiagnoseConfig
  676. for _, item := range diagnosis_ids {
  677. id, _ := strconv.ParseInt(item, 10, 64)
  678. diagnosisConfig, _ := service.FindDiagnoseById(id)
  679. config = append(config, &diagnosisConfig)
  680. }
  681. var pd models.PatientDtos
  682. pd.PatnID = his.PsnNo
  683. pd.PatnName = his.Name
  684. pd.Gend = his.Gend
  685. pd.Brdy = his.Brdy
  686. pd.Poolarea = miConfig.MdtrtareaAdmvs
  687. pd.CurrMdtrtID = his.Number
  688. var fed models.FsiEncounterDtos
  689. fed.MdtrtID = his.Number
  690. fed.MedinsID = miConfig.Code
  691. fed.MedinsName = miConfig.OrgName
  692. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  693. fed.MedMdtrtType = "1"
  694. fed.MedinsType = "1"
  695. fed.MedinsLv = "11"
  696. tm := time.Unix(his.RecordDate, 0)
  697. s_tm := tm.Format("2006-01-02 15:04:05")
  698. fed.AdmDate = s_tm
  699. fed.DscgDate = s_tm
  700. fed.DscgMainDiseCodg = config[0].CountryCode
  701. fed.DscgMainDiseName = config[0].CountryContentName
  702. //诊断信息
  703. var fdds []*models.FsiDiagnoseDtos
  704. for index, item := range config {
  705. if index == 0 {
  706. var fdd models.FsiDiagnoseDtos
  707. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  708. fdd.InoutDiseType = "1"
  709. fdd.MaindiseFlag = "1"
  710. fdd.DiseDate = s_tm
  711. fdd.DiasSrtNo = "1"
  712. fdd.DiseName = item.CountryContentName
  713. fdd.DiseCodg = item.CountryCode
  714. fdds = append(fdds, &fdd)
  715. } else {
  716. var fdd models.FsiDiagnoseDtos
  717. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  718. fdd.InoutDiseType = "1"
  719. fdd.MaindiseFlag = "1"
  720. fdd.DiseDate = s_tm
  721. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  722. fdd.DiseName = item.CountryContentName
  723. fdd.DiseCodg = item.CountryCode
  724. fdds = append(fdds, &fdd)
  725. }
  726. }
  727. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  728. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  729. fed.AdmDeptName = department.Name
  730. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  731. fed.DscgDeptName = department.Name
  732. fed.MedMdtrtType = "1"
  733. fed.MedType = "11"
  734. //if his.Insutype == "390" {
  735. // fed.MedType = "1402"
  736. //} else {
  737. // fed.MedType = "9933"
  738. //}
  739. var orders []*models.FsiOrderDtos
  740. if trig_scen == "2" {
  741. //处方医嘱信息
  742. for _, item := range prescriptions {
  743. for _, subItem := range item.HisDoctorAdviceInfo {
  744. var order models.FsiOrderDtos
  745. order.RxID = strconv.FormatInt(item.ID, 10)
  746. order.Rxno = strconv.FormatInt(item.ID, 10)
  747. order.LongDrordFlag = "0"
  748. order.HilistType = "1"
  749. order.ChrgType = "1"
  750. order.DrordBhvr = "-"
  751. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  752. order.HosplistName = subItem.BaseDrugLib.DrugName
  753. order.HilistLv = "1"
  754. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  755. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  756. order.HosplistName = subItem.BaseDrugLib.DrugName
  757. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  758. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  759. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  760. order.OwnpayAmt = ""
  761. order.SelfpayAmt = ""
  762. order.Spec = ""
  763. order.SpecUnt = ""
  764. order.DrordBegnDate = s_tm
  765. order.DrordStopDate = ""
  766. order.DrordDrCodg = "1"
  767. order.DrordDeptName = department.Name
  768. order.DrordDrCodg = "1"
  769. order.DrordDrName = doctor_info.UserName
  770. order.DrordDrProfttl = ""
  771. order.CurrDrordFlag = "1"
  772. orders = append(orders, &order)
  773. }
  774. for _, subItem := range item.HisPrescriptionProject {
  775. if subItem.Type == 2 {
  776. var order models.FsiOrderDtos
  777. order.RxID = strconv.FormatInt(item.ID, 10)
  778. order.Rxno = strconv.FormatInt(item.ID, 10)
  779. order.LongDrordFlag = "0"
  780. order.HilistType = "1"
  781. order.ChrgType = "1"
  782. order.DrordBhvr = "-"
  783. order.HilistCode = subItem.HisProject.MedicalCode
  784. order.HosplistName = subItem.HisProject.ProjectName
  785. order.HilistLv = "1"
  786. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  787. order.HosplistCode = subItem.HisProject.MedicalCode
  788. order.HosplistName = subItem.HisProject.ProjectName
  789. order.Cnt = subItem.Count
  790. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  791. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  792. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  793. order.OwnpayAmt = ""
  794. order.SelfpayAmt = ""
  795. order.Spec = ""
  796. order.SpecUnt = ""
  797. order.DrordBegnDate = s_tm
  798. order.DrordStopDate = ""
  799. order.DrordDrCodg = "1"
  800. order.DrordDeptName = department.Name
  801. order.DrordDrCodg = "1"
  802. order.DrordDrName = doctor_info.UserName
  803. order.DrordDrProfttl = ""
  804. order.CurrDrordFlag = "1"
  805. orders = append(orders, &order)
  806. }
  807. if subItem.Type == 3 {
  808. var order models.FsiOrderDtos
  809. order.RxID = strconv.FormatInt(item.ID, 10)
  810. order.Rxno = strconv.FormatInt(item.ID, 10)
  811. order.LongDrordFlag = "0"
  812. order.HilistType = "1"
  813. order.ChrgType = "1"
  814. order.DrordBhvr = "-"
  815. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  816. order.HosplistName = subItem.GoodInfo.GoodName
  817. order.HilistLv = "1"
  818. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  819. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  820. order.HosplistName = subItem.GoodInfo.GoodName
  821. order.Cnt = subItem.Count
  822. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  823. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  824. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  825. order.OwnpayAmt = ""
  826. order.SelfpayAmt = ""
  827. order.Spec = ""
  828. order.SpecUnt = ""
  829. order.DrordBegnDate = s_tm
  830. order.DrordStopDate = ""
  831. order.DrordDrCodg = "1"
  832. order.DrordDeptName = department.Name
  833. order.DrordDrCodg = "1"
  834. order.DrordDrName = doctor_info.UserName
  835. order.DrordDrProfttl = ""
  836. order.CurrDrordFlag = "1"
  837. orders = append(orders, &order)
  838. }
  839. }
  840. }
  841. //处方医嘱信息
  842. }
  843. fed.MatnStas = "0"
  844. fed.MedfeeSumamt = "0"
  845. fed.OwnpayAmt = "0"
  846. fed.SelfpayAmt = "0"
  847. fed.AcctPayamt = "0"
  848. fed.MaAmt = "0"
  849. fed.HifpPayamt = "0"
  850. fed.SetlTotlnum = "1"
  851. fed.Insutype = his.Insutype
  852. fed.ReimFlag = "0"
  853. fed.OutSetlFlag = "0"
  854. var fopd []*models.FsiOperationDtosData
  855. data := make(map[string]interface{})
  856. data["fed"] = fed
  857. data["fdd"] = fdds
  858. data["fod"] = orders
  859. data["pd"] = pd
  860. data["pp"] = pp
  861. data["fopd"] = fopd
  862. data["trig_scen"] = trig_scen
  863. fmt.Println(data)
  864. fmt.Println(fed)
  865. fmt.Println(fdds)
  866. fmt.Println(orders)
  867. fmt.Println(pd)
  868. fmt.Println(pp)
  869. fmt.Println(fopd)
  870. client := &http.Client{}
  871. bytesData, _ := json.Marshal(data)
  872. var req *http.Request
  873. if miConfig.MdtrtareaAdmvs == "320921" {
  874. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  875. } else {
  876. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  877. }
  878. resp, _ := client.Do(req)
  879. defer resp.Body.Close()
  880. body, ioErr := ioutil.ReadAll(resp.Body)
  881. if ioErr != nil {
  882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return res
  885. }
  886. var respJSON map[string]interface{}
  887. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  890. return res
  891. }
  892. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  893. fmt.Println(respJSON)
  894. result, _ := json.Marshal(respJSON)
  895. fmt.Println(result)
  896. if err := json.Unmarshal([]byte(result), &res); err != nil {
  897. utils.ErrorLog("解析失败:%v", err)
  898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  899. return res
  900. }
  901. return res
  902. }
  903. 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) {
  904. adminUser := c.GetAdminUserInfo()
  905. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  906. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  907. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  908. //record_time := c.GetString("record_time")
  909. //trig_scen := c.GetString("trig_scen")
  910. timeLayout := "2006-01-02"
  911. loc, _ := time.LoadLocation("Local")
  912. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  913. if err != nil {
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  915. return res
  916. }
  917. recordDateTime := theTime.Unix()
  918. var patientPrescription models.HisPrescriptionInfo
  919. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  920. if patientPrescription.ID == 0 {
  921. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  922. }
  923. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  924. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  925. //
  926. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  927. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  928. var pp models.PublicParams
  929. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  930. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  931. pp.FixmedinsName = miConfig.OrgName
  932. pp.FixmedinsCode = miConfig.Code
  933. pp.RequestUrl = miConfig.Url
  934. pp.Cainfo = miConfig.Cainfo
  935. pp.SecretKey = miConfig.SecretKey
  936. pp.AccessKey = miConfig.AccessKey
  937. pp.OpterName = roles.UserName
  938. var config []*models.HisXtDiagnoseConfig
  939. for _, item := range diagnosis_ids {
  940. id, _ := strconv.ParseInt(item, 10, 64)
  941. diagnosisConfig, _ := service.FindDiagnoseById(id)
  942. config = append(config, &diagnosisConfig)
  943. }
  944. var pd models.PatientDtos
  945. pd.PatnID = his.PsnNo
  946. pd.PatnName = his.Name
  947. pd.Gend = his.Gend
  948. pd.Brdy = his.Brdy
  949. pd.Poolarea = his.InsuplcAdmdvs
  950. pd.CurrMdtrtID = his.Number
  951. var fed models.FsiEncounterDtos
  952. fed.MdtrtID = his.Number
  953. fed.MedinsID = miConfig.Code
  954. fed.MedinsName = miConfig.OrgName
  955. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  956. fed.MedMdtrtType = "1"
  957. fed.MedinsType = "1"
  958. fed.MedinsLv = "11"
  959. tm := time.Unix(his.RecordDate, 0)
  960. s_tm := tm.Format("2006-01-02 15:04:05")
  961. fed.AdmDate = s_tm
  962. fed.DscgDate = s_tm
  963. fed.DscgMainDiseCodg = config[0].CountryCode
  964. fed.DscgMainDiseName = config[0].CountryContentName
  965. //诊断信息
  966. var fdds []*models.FsiDiagnoseDtos
  967. for index, item := range config {
  968. if index == 0 {
  969. var fdd models.FsiDiagnoseDtos
  970. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  971. fdd.InoutDiseType = "1"
  972. fdd.MaindiseFlag = "1"
  973. fdd.DiseDate = s_tm
  974. fdd.DiasSrtNo = "1"
  975. fdd.DiseName = item.CountryContentName
  976. fdd.DiseCodg = item.CountryCode
  977. fdds = append(fdds, &fdd)
  978. } else {
  979. var fdd models.FsiDiagnoseDtos
  980. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  981. fdd.InoutDiseType = "1"
  982. fdd.MaindiseFlag = "1"
  983. fdd.DiseDate = s_tm
  984. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  985. fdd.DiseName = item.CountryContentName
  986. fdd.DiseCodg = item.CountryCode
  987. fdds = append(fdds, &fdd)
  988. }
  989. }
  990. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  991. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  992. fed.AdmDeptName = department.Name
  993. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  994. fed.DscgDeptName = department.Name
  995. fed.MedMdtrtType = "1"
  996. fed.MedType = "11"
  997. //if his.Insutype == "390" {
  998. // fed.MedType = "1402"
  999. //} else {
  1000. // fed.MedType = "9933"
  1001. //}
  1002. var orders []*models.FsiOrderDtos
  1003. if trig_scen == "2" {
  1004. //处方医嘱信息
  1005. for _, item := range prescriptions {
  1006. for _, subItem := range item.HisDoctorAdviceInfo {
  1007. var order models.FsiOrderDtos
  1008. order.RxID = strconv.FormatInt(item.ID, 10)
  1009. order.Rxno = strconv.FormatInt(item.ID, 10)
  1010. order.LongDrordFlag = "0"
  1011. order.HilistType = "1"
  1012. order.ChrgType = "1"
  1013. order.DrordBhvr = "-"
  1014. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1015. order.HosplistName = subItem.BaseDrugLib.DrugName
  1016. order.HilistLv = "1"
  1017. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1018. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1019. order.HosplistName = subItem.BaseDrugLib.DrugName
  1020. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1021. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1022. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1023. order.OwnpayAmt = ""
  1024. order.SelfpayAmt = ""
  1025. order.Spec = ""
  1026. order.SpecUnt = ""
  1027. order.DrordBegnDate = s_tm
  1028. order.DrordStopDate = ""
  1029. order.DrordDrCodg = "1"
  1030. order.DrordDeptName = department.Name
  1031. order.DrordDrCodg = "1"
  1032. order.DrordDrName = doctor_info.UserName
  1033. order.DrordDrProfttl = ""
  1034. order.CurrDrordFlag = "1"
  1035. orders = append(orders, &order)
  1036. }
  1037. for _, subItem := range item.HisPrescriptionProject {
  1038. if subItem.Type == 2 {
  1039. var order models.FsiOrderDtos
  1040. order.RxID = strconv.FormatInt(item.ID, 10)
  1041. order.Rxno = strconv.FormatInt(item.ID, 10)
  1042. order.LongDrordFlag = "0"
  1043. order.HilistType = "1"
  1044. order.ChrgType = "1"
  1045. order.DrordBhvr = "-"
  1046. order.HilistCode = subItem.HisProject.MedicalCode
  1047. order.HosplistName = subItem.HisProject.ProjectName
  1048. order.HilistLv = "1"
  1049. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1050. order.HosplistCode = subItem.HisProject.MedicalCode
  1051. order.HosplistName = subItem.HisProject.ProjectName
  1052. order.Cnt = subItem.Count
  1053. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1054. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1055. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1056. order.OwnpayAmt = ""
  1057. order.SelfpayAmt = ""
  1058. order.Spec = ""
  1059. order.SpecUnt = ""
  1060. order.DrordBegnDate = s_tm
  1061. order.DrordStopDate = ""
  1062. order.DrordDrCodg = "1"
  1063. order.DrordDeptName = department.Name
  1064. order.DrordDrCodg = "1"
  1065. order.DrordDrName = doctor_info.UserName
  1066. order.DrordDrProfttl = ""
  1067. order.CurrDrordFlag = "1"
  1068. orders = append(orders, &order)
  1069. }
  1070. if subItem.Type == 3 {
  1071. var order models.FsiOrderDtos
  1072. order.RxID = strconv.FormatInt(item.ID, 10)
  1073. order.Rxno = strconv.FormatInt(item.ID, 10)
  1074. order.LongDrordFlag = "0"
  1075. order.HilistType = "1"
  1076. order.ChrgType = "1"
  1077. order.DrordBhvr = "-"
  1078. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1079. order.HosplistName = subItem.GoodInfo.GoodName
  1080. order.HilistLv = "1"
  1081. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1082. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1083. order.HosplistName = subItem.GoodInfo.GoodName
  1084. order.Cnt = subItem.Count
  1085. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1086. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1087. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1088. order.OwnpayAmt = ""
  1089. order.SelfpayAmt = ""
  1090. order.Spec = ""
  1091. order.SpecUnt = ""
  1092. order.DrordBegnDate = s_tm
  1093. order.DrordStopDate = ""
  1094. order.DrordDrCodg = "1"
  1095. order.DrordDeptName = department.Name
  1096. order.DrordDrCodg = "1"
  1097. order.DrordDrName = doctor_info.UserName
  1098. order.DrordDrProfttl = ""
  1099. order.CurrDrordFlag = "1"
  1100. orders = append(orders, &order)
  1101. }
  1102. }
  1103. }
  1104. //处方医嘱信息
  1105. }
  1106. fed.MatnStas = "0"
  1107. fed.MedfeeSumamt = "0"
  1108. fed.OwnpayAmt = "0"
  1109. fed.SelfpayAmt = "0"
  1110. fed.AcctPayamt = "0"
  1111. fed.MaAmt = "0"
  1112. fed.HifpPayamt = "0"
  1113. fed.SetlTotlnum = "1"
  1114. fed.Insutype = his.Insutype
  1115. fed.ReimFlag = "0"
  1116. fed.OutSetlFlag = "0"
  1117. var fopd []*models.FsiOperationDtosData
  1118. data := make(map[string]interface{})
  1119. data["fed"] = fed
  1120. data["fdd"] = fdds
  1121. data["fod"] = orders
  1122. data["pd"] = pd
  1123. data["pp"] = pp
  1124. data["fopd"] = fopd
  1125. data["trig_scen"] = trig_scen
  1126. fmt.Println(data)
  1127. fmt.Println(fed)
  1128. fmt.Println(fdds)
  1129. fmt.Println(orders)
  1130. fmt.Println(pd)
  1131. fmt.Println(pp)
  1132. fmt.Println(fopd)
  1133. client := &http.Client{}
  1134. bytesData, _ := json.Marshal(data)
  1135. var req *http.Request
  1136. if miConfig.MdtrtareaAdmvs == "320921" {
  1137. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1138. } else {
  1139. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1140. }
  1141. resp, _ := client.Do(req)
  1142. defer resp.Body.Close()
  1143. body, ioErr := ioutil.ReadAll(resp.Body)
  1144. if ioErr != nil {
  1145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return res
  1148. }
  1149. var respJSON map[string]interface{}
  1150. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1153. return res
  1154. }
  1155. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1156. result, _ := json.Marshal(respJSON)
  1157. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1158. utils.ErrorLog("解析失败:%v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return res
  1161. }
  1162. return res
  1163. }
  1164. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1165. ////patient_id, _ := c.GetInt64("patient_id")
  1166. //order_id, _ := c.GetInt64("order_id")
  1167. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1168. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1169. //trig_scen := c.GetString("trig_scen")
  1170. adminUser := c.GetAdminUserInfo()
  1171. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1172. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1173. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1174. record_time := c.GetString("record_time")
  1175. order, _ := service.GetHisOrderByID(order_id)
  1176. timeLayout := "2006-01-02"
  1177. loc, _ := time.LoadLocation("Local")
  1178. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1179. if err != nil {
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1181. return
  1182. }
  1183. recordDateTime := theTime.Unix()
  1184. var patientPrescription models.HisPrescriptionInfo
  1185. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1186. if patientPrescription.ID == 0 {
  1187. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1188. }
  1189. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1190. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1191. //
  1192. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1193. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1194. var pp models.PublicParams
  1195. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1196. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1197. pp.FixmedinsName = miConfig.OrgName
  1198. pp.FixmedinsCode = miConfig.Code
  1199. pp.RequestUrl = miConfig.Url
  1200. pp.Cainfo = miConfig.Cainfo
  1201. pp.SecretKey = miConfig.SecretKey
  1202. pp.AccessKey = miConfig.AccessKey
  1203. pp.OpterName = roles.UserName
  1204. var config []*models.HisXtDiagnoseConfig
  1205. for _, item := range diagnosis_ids {
  1206. id, _ := strconv.ParseInt(item, 10, 64)
  1207. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1208. config = append(config, &diagnosisConfig)
  1209. }
  1210. var pd models.PatientDtos
  1211. pd.PatnID = his.PsnNo
  1212. pd.PatnName = his.Name
  1213. pd.Gend = his.Gend
  1214. pd.Brdy = his.Brdy
  1215. pd.Poolarea = his.InsuplcAdmdvs
  1216. pd.CurrMdtrtID = his.Number
  1217. var fed models.FsiEncounterDtos
  1218. fed.MdtrtID = his.Number
  1219. fed.MedinsID = miConfig.Code
  1220. fed.MedinsName = miConfig.OrgName
  1221. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1222. fed.MedMdtrtType = "1"
  1223. fed.MedinsType = "1"
  1224. fed.MedinsLv = "11"
  1225. tm := time.Unix(his.RecordDate, 0)
  1226. s_tm := tm.Format("2006-01-02 15:04:05")
  1227. fed.AdmDate = s_tm
  1228. fed.DscgDate = s_tm
  1229. fed.DscgMainDiseCodg = config[0].CountryCode
  1230. fed.DscgMainDiseName = config[0].CountryContentName
  1231. //诊断信息
  1232. var fdds []*models.FsiDiagnoseDtos
  1233. for index, item := range config {
  1234. if index == 0 {
  1235. var fdd models.FsiDiagnoseDtos
  1236. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1237. fdd.InoutDiseType = "1"
  1238. fdd.MaindiseFlag = "1"
  1239. fdd.DiseDate = s_tm
  1240. fdd.DiasSrtNo = "1"
  1241. fdd.DiseName = item.CountryContentName
  1242. fdd.DiseCodg = item.CountryCode
  1243. fdds = append(fdds, &fdd)
  1244. } else {
  1245. var fdd models.FsiDiagnoseDtos
  1246. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1247. fdd.InoutDiseType = "1"
  1248. fdd.MaindiseFlag = "1"
  1249. fdd.DiseDate = s_tm
  1250. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1251. fdd.DiseName = item.CountryContentName
  1252. fdd.DiseCodg = item.CountryCode
  1253. fdds = append(fdds, &fdd)
  1254. }
  1255. }
  1256. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1257. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1258. fed.AdmDeptName = department.Name
  1259. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1260. fed.DscgDeptName = department.Name
  1261. fed.MedType = order.MedType
  1262. //处方医嘱信息
  1263. var orders []*models.FsiOrderDtos
  1264. //for _, item := range prescriptions {
  1265. // for _, subItem := range item.HisDoctorAdviceInfo {
  1266. // var order models.FsiOrderDtos
  1267. // order.RxID = strconv.FormatInt(item.ID, 10)
  1268. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1269. // order.LongDrordFlag = "0"
  1270. // order.HilistType = "1"
  1271. // order.ChrgType = "1"
  1272. // order.DrordBhvr = "-"
  1273. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1274. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1275. // order.HilistLv = "1"
  1276. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1277. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1278. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1279. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1280. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1281. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1282. // order.OwnpayAmt = ""
  1283. // order.SelfpayAmt = ""
  1284. // order.Spec = ""
  1285. // order.SpecUnt = ""
  1286. // order.DrordBegnDate = s_tm
  1287. // order.DrordStopDate = ""
  1288. // order.DrordDrCodg = "1"
  1289. // order.DrordDeptName = department.Name
  1290. // order.DrordDrCodg = "1"
  1291. // order.DrordDrName = doctor_info.UserName
  1292. // order.DrordDrProfttl = ""
  1293. // order.CurrDrordFlag = "1"
  1294. // orders = append(orders, &order)
  1295. // }
  1296. // for _, subItem := range item.HisPrescriptionProject {
  1297. // if subItem.Type == 2 {
  1298. // var order models.FsiOrderDtos
  1299. // order.RxID = strconv.FormatInt(item.ID, 10)
  1300. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1301. // order.LongDrordFlag = "0"
  1302. // order.HilistType = "1"
  1303. // order.ChrgType = "1"
  1304. // order.DrordBhvr = "-"
  1305. // order.HilistCode = subItem.HisProject.MedicalCode
  1306. // order.HosplistName = subItem.HisProject.ProjectName
  1307. // order.HilistLv = "1"
  1308. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1309. // order.HosplistCode = subItem.HisProject.MedicalCode
  1310. // order.HosplistName = subItem.HisProject.ProjectName
  1311. // order.Cnt = subItem.Count
  1312. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1313. //
  1314. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1315. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1316. // order.OwnpayAmt = ""
  1317. // order.SelfpayAmt = ""
  1318. // order.Spec = ""
  1319. // order.SpecUnt = ""
  1320. // order.DrordBegnDate = s_tm
  1321. // order.DrordStopDate = ""
  1322. // order.DrordDrCodg = "1"
  1323. // order.DrordDeptName = department.Name
  1324. // order.DrordDrCodg = "1"
  1325. // order.DrordDrName = doctor_info.UserName
  1326. // order.DrordDrProfttl = ""
  1327. // order.CurrDrordFlag = "1"
  1328. // orders = append(orders, &order)
  1329. //
  1330. // }
  1331. // if subItem.Type == 3 {
  1332. //
  1333. // var order models.FsiOrderDtos
  1334. // order.RxID = strconv.FormatInt(item.ID, 10)
  1335. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1336. // order.LongDrordFlag = "0"
  1337. // order.HilistType = "1"
  1338. // order.ChrgType = "1"
  1339. // order.DrordBhvr = "-"
  1340. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1341. // order.HosplistName = subItem.GoodInfo.GoodName
  1342. // order.HilistLv = "1"
  1343. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1344. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1345. // order.HosplistName = subItem.GoodInfo.GoodName
  1346. // order.Cnt = subItem.Count
  1347. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1348. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1349. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1350. // order.OwnpayAmt = ""
  1351. // order.SelfpayAmt = ""
  1352. // order.Spec = ""
  1353. // order.SpecUnt = ""
  1354. // order.DrordBegnDate = s_tm
  1355. // order.DrordStopDate = ""
  1356. // order.DrordDrCodg = "1"
  1357. // order.DrordDeptName = department.Name
  1358. // order.DrordDrCodg = "1"
  1359. // order.DrordDrName = doctor_info.UserName
  1360. // order.DrordDrProfttl = ""
  1361. // order.CurrDrordFlag = "1"
  1362. // orders = append(orders, &order)
  1363. //
  1364. // }
  1365. // }
  1366. //}
  1367. for _, item := range prescriptions {
  1368. for _, subItem := range item.HisDoctorAdviceInfo {
  1369. var order models.FsiOrderDtos
  1370. order.RxID = strconv.FormatInt(item.ID, 10)
  1371. order.Rxno = strconv.FormatInt(item.ID, 10)
  1372. order.LongDrordFlag = "0"
  1373. order.HilistType = "1"
  1374. order.ChrgType = "1"
  1375. order.DrordBhvr = "-"
  1376. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1377. order.HosplistName = subItem.BaseDrugLib.DrugName
  1378. order.HilistLv = "1"
  1379. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1380. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1381. order.HosplistName = subItem.BaseDrugLib.DrugName
  1382. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1383. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1384. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1385. order.OwnpayAmt = ""
  1386. order.SelfpayAmt = ""
  1387. order.Spec = ""
  1388. order.SpecUnt = ""
  1389. order.DrordBegnDate = s_tm
  1390. order.DrordStopDate = ""
  1391. order.DrordDrCodg = "1"
  1392. order.DrordDeptName = department.Name
  1393. order.DrordDrCodg = "1"
  1394. order.DrordDrName = doctor_info.UserName
  1395. order.DrordDrProfttl = ""
  1396. order.CurrDrordFlag = "1"
  1397. orders = append(orders, &order)
  1398. }
  1399. for _, subItem := range item.HisPrescriptionProject {
  1400. if subItem.Type == 2 {
  1401. var order models.FsiOrderDtos
  1402. order.RxID = strconv.FormatInt(item.ID, 10)
  1403. order.Rxno = strconv.FormatInt(item.ID, 10)
  1404. order.LongDrordFlag = "0"
  1405. order.HilistType = "1"
  1406. order.ChrgType = "1"
  1407. order.DrordBhvr = "-"
  1408. order.HilistCode = subItem.HisProject.MedicalCode
  1409. order.HosplistName = subItem.HisProject.ProjectName
  1410. order.HilistLv = "1"
  1411. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1412. order.HosplistCode = subItem.HisProject.MedicalCode
  1413. order.HosplistName = subItem.HisProject.ProjectName
  1414. order.Cnt = subItem.Count
  1415. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1416. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1417. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1418. order.OwnpayAmt = ""
  1419. order.SelfpayAmt = ""
  1420. order.Spec = ""
  1421. order.SpecUnt = ""
  1422. order.DrordBegnDate = s_tm
  1423. order.DrordStopDate = ""
  1424. order.DrordDrCodg = "1"
  1425. order.DrordDeptName = department.Name
  1426. order.DrordDrCodg = "1"
  1427. order.DrordDrName = doctor_info.UserName
  1428. order.DrordDrProfttl = ""
  1429. order.CurrDrordFlag = "1"
  1430. orders = append(orders, &order)
  1431. }
  1432. if subItem.Type == 3 {
  1433. var order models.FsiOrderDtos
  1434. order.RxID = strconv.FormatInt(item.ID, 10)
  1435. order.Rxno = strconv.FormatInt(item.ID, 10)
  1436. order.LongDrordFlag = "0"
  1437. order.HilistType = "1"
  1438. order.ChrgType = "1"
  1439. order.DrordBhvr = "-"
  1440. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1441. order.HosplistName = subItem.GoodInfo.GoodName
  1442. order.HilistLv = "1"
  1443. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1444. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1445. order.HosplistName = subItem.GoodInfo.GoodName
  1446. order.Cnt = subItem.Count
  1447. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1448. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1449. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1450. order.OwnpayAmt = ""
  1451. order.SelfpayAmt = ""
  1452. order.Spec = ""
  1453. order.SpecUnt = ""
  1454. order.DrordBegnDate = s_tm
  1455. order.DrordStopDate = ""
  1456. order.DrordDrCodg = "1"
  1457. order.DrordDeptName = department.Name
  1458. order.DrordDrCodg = "1"
  1459. order.DrordDrName = doctor_info.UserName
  1460. order.DrordDrProfttl = ""
  1461. order.CurrDrordFlag = "1"
  1462. orders = append(orders, &order)
  1463. }
  1464. }
  1465. }
  1466. //处方医嘱信息
  1467. fed.MatnStas = "0"
  1468. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1469. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1470. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1471. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1472. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1473. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1474. fed.SetlTotlnum = "1"
  1475. fed.Insutype = his.Insutype
  1476. fed.ReimFlag = "0"
  1477. fed.OutSetlFlag = "0"
  1478. var fopd []*models.FsiOperationDtosData
  1479. data := make(map[string]interface{})
  1480. data["fed"] = fed
  1481. data["fdd"] = fdds
  1482. data["fod"] = orders
  1483. data["pd"] = pd
  1484. data["pp"] = pp
  1485. data["fopd"] = fopd
  1486. data["trig_scen"] = trig_scen
  1487. client := &http.Client{}
  1488. bytesData, _ := json.Marshal(data)
  1489. var req *http.Request
  1490. if miConfig.MdtrtareaAdmvs == "320921" {
  1491. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1492. } else {
  1493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1494. }
  1495. resp, _ := client.Do(req)
  1496. defer resp.Body.Close()
  1497. body, ioErr := ioutil.ReadAll(resp.Body)
  1498. if ioErr != nil {
  1499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. return res
  1502. }
  1503. var respJSON map[string]interface{}
  1504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1507. return res
  1508. }
  1509. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1510. result, _ := json.Marshal(respJSON)
  1511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1512. utils.ErrorLog("解析失败:%v", err)
  1513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. return res
  1515. }
  1516. return res
  1517. //手术操作集合
  1518. //手术操作集合
  1519. }
  1520. func (c *HisApiController) Check() {
  1521. psn_no := c.GetString("psn_no")
  1522. in := c.GetString("in")
  1523. mt := c.GetString("mt")
  1524. baseParams := models.BaseParams{
  1525. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1526. FixmedinsCode: "H15049901371",
  1527. InsuplcAdmdvs: "150499",
  1528. MdtrtareaAdmvs: "150499",
  1529. OrgName: "赤峰费森血液透析中心",
  1530. Doctor: "1111",
  1531. }
  1532. service.Gdyb2001(baseParams, psn_no, in, mt)
  1533. }
  1534. func (c *HisApiController) GetPsnNcdsInfo() {
  1535. admin_user_id, _ := c.GetInt64("admin_user_id")
  1536. patient_id, _ := c.GetInt64("patient_id")
  1537. id, _ := c.GetInt64("id")
  1538. adminUser := c.GetAdminUserInfo()
  1539. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1540. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1541. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1542. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1543. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1544. //
  1545. //if psn_record.ID == 0 {
  1546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1547. // return
  1548. //}
  1549. var res Result5301
  1550. var res10265 Result5301For10265
  1551. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1552. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1553. var api string
  1554. if miConfig.MdtrtareaAdmvs == "320921" {
  1555. 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 +
  1556. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1557. } else {
  1558. 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 +
  1559. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1560. }
  1561. resp, requestErr := http.Get(api)
  1562. if requestErr != nil {
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1564. return
  1565. }
  1566. body, ioErr := ioutil.ReadAll(resp.Body)
  1567. if ioErr != nil {
  1568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1570. return
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1579. result, _ := json.Marshal(respJSON)
  1580. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1581. utils.ErrorLog("解析失败:%v", err)
  1582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1583. return
  1584. }
  1585. res.ErrMsg = res10265.ErrMsg
  1586. res.Output = res10265.Output
  1587. res.InfRefmsgid = res10265.InfRefmsgid
  1588. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1589. res.Infcode = infocode
  1590. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1591. p, _ := service.GetHisPatientById(patient_id)
  1592. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1593. var dat map[string]interface{}
  1594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1595. fmt.Println(dat)
  1596. } else {
  1597. fmt.Println(err)
  1598. }
  1599. userJSONBytes, _ := json.Marshal(dat)
  1600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1601. utils.ErrorLog("解析失败:%v", err)
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. return
  1604. }
  1605. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1606. p, _ := service.GetHisPatientById(patient_id)
  1607. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1608. var dat map[string]interface{}
  1609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1610. fmt.Println(dat)
  1611. } else {
  1612. fmt.Println(err)
  1613. }
  1614. userJSONBytes, _ := json.Marshal(dat)
  1615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1616. utils.ErrorLog("解析失败:%v", err)
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. } else {
  1621. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1622. var dat map[string]interface{}
  1623. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1624. fmt.Println(dat)
  1625. } else {
  1626. fmt.Println(err)
  1627. }
  1628. userJSONBytes, _ := json.Marshal(dat)
  1629. if miConfig.Code == "H15049901371" {
  1630. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1631. utils.ErrorLog("解析失败:%v", err)
  1632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1633. return
  1634. }
  1635. res.InfRefmsgid = res10265.InfRefmsgid
  1636. res.Output = res10265.Output
  1637. res.ErrMsg = res10265.ErrMsg
  1638. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1639. res.Infcode = infocode
  1640. } else {
  1641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1642. utils.ErrorLog("解析失败:%v", err)
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1644. return
  1645. }
  1646. }
  1647. }
  1648. if res.Infcode == 0 {
  1649. c.ServeSuccessJSON(map[string]interface{}{
  1650. "result": res.Output.Result,
  1651. })
  1652. }
  1653. }
  1654. func (c *HisApiController) CheckInsutype() {
  1655. his_patient_id, _ := c.GetInt64("his_patient_id")
  1656. admin_user_id, _ := c.GetInt64("admin_user_id")
  1657. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1658. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1659. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1660. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1661. var dat map[string]interface{}
  1662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1663. fmt.Println(dat)
  1664. } else {
  1665. fmt.Println(err)
  1666. }
  1667. userJSONBytes, _ := json.Marshal(dat)
  1668. var res Result90100
  1669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1670. utils.ErrorLog("解析失败:%v", err)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. return
  1673. }
  1674. if res.Infcode != 0 {
  1675. c.ServeSuccessJSON(map[string]interface{}{
  1676. "failed_code": -10,
  1677. "msg": res.ErrMsg,
  1678. })
  1679. return
  1680. } else {
  1681. fmt.Println(res)
  1682. }
  1683. }
  1684. func (c *HisApiController) CheckCardPWD() {
  1685. card_pwd := c.GetString("card_pwd")
  1686. his_patient_id, _ := c.GetInt64("his_patient_id")
  1687. admin_user_id, _ := c.GetInt64("admin_user_id")
  1688. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1689. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1690. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1691. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1692. bas := strings.Split(psn.CardInfo, "|")
  1693. basNumber := bas[2]
  1694. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1695. var dat map[string]interface{}
  1696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1697. fmt.Println(dat)
  1698. } else {
  1699. fmt.Println(err)
  1700. }
  1701. userJSONBytes, _ := json.Marshal(dat)
  1702. var res Result90991
  1703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1704. utils.ErrorLog("解析失败:%v", err)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. return
  1707. }
  1708. if res.Infcode != 0 {
  1709. c.ServeSuccessJSON(map[string]interface{}{
  1710. "failed_code": -10,
  1711. "msg": res.ErrMsg,
  1712. })
  1713. return
  1714. } else {
  1715. if res.Output.Result.SscnoCheckStat == "0" {
  1716. var msg string
  1717. switch res.Output.Result.CardStat {
  1718. case "00":
  1719. msg = "未激活"
  1720. break
  1721. case "10":
  1722. msg = "激活"
  1723. break
  1724. case "20":
  1725. msg = "窗口挂失"
  1726. break
  1727. case "21":
  1728. msg = "电话挂失"
  1729. break
  1730. case "22":
  1731. msg = "单位网上申报挂失"
  1732. break
  1733. case "23":
  1734. msg = "保健办挂失"
  1735. break
  1736. case "24":
  1737. msg = "个人网上挂失"
  1738. break
  1739. case "25":
  1740. msg = "网上服务大厅挂失"
  1741. break
  1742. case "30":
  1743. msg = "注销"
  1744. break
  1745. case "40":
  1746. msg = "回收"
  1747. break
  1748. case "99":
  1749. msg = "制卡中(无效卡)"
  1750. break
  1751. }
  1752. c.ServeSuccessJSON(map[string]interface{}{
  1753. "failed_code": -10,
  1754. "msg": msg,
  1755. })
  1756. return
  1757. } else {
  1758. c.ServeSuccessJSON(map[string]interface{}{
  1759. "msg": "校验成功",
  1760. })
  1761. return
  1762. }
  1763. }
  1764. }
  1765. func (c *HisApiController) CheckCardPWDTwo() {
  1766. //card_pwd := c.GetString("card_pwd")
  1767. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1768. admin_user_id, _ := c.GetInt64("admin_user_id")
  1769. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1771. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1772. var dat map[string]interface{}
  1773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1774. fmt.Println(dat)
  1775. } else {
  1776. fmt.Println(err)
  1777. }
  1778. userJSONBytes, _ := json.Marshal(dat)
  1779. var res Result90991
  1780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1781. utils.ErrorLog("解析失败:%v", err)
  1782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1783. return
  1784. }
  1785. if res.Infcode != 0 {
  1786. c.ServeSuccessJSON(map[string]interface{}{
  1787. "failed_code": -10,
  1788. "msg": res.ErrMsg,
  1789. })
  1790. return
  1791. } else {
  1792. if res.Output.Result.SscnoCheckStat == "0" {
  1793. var msg string
  1794. switch res.Output.Result.CardStat {
  1795. case "00":
  1796. msg = "未激活"
  1797. break
  1798. case "10":
  1799. msg = "激活"
  1800. break
  1801. case "20":
  1802. msg = "窗口挂失"
  1803. break
  1804. case "21":
  1805. msg = "电话挂失"
  1806. break
  1807. case "22":
  1808. msg = "单位网上申报挂失"
  1809. break
  1810. case "23":
  1811. msg = "保健办挂失"
  1812. break
  1813. case "24":
  1814. msg = "个人网上挂失"
  1815. break
  1816. case "25":
  1817. msg = "网上服务大厅挂失"
  1818. break
  1819. case "30":
  1820. msg = "注销"
  1821. break
  1822. case "40":
  1823. msg = "回收"
  1824. break
  1825. case "99":
  1826. msg = "制卡中(无效卡)"
  1827. break
  1828. }
  1829. c.ServeSuccessJSON(map[string]interface{}{
  1830. "failed_code": -10,
  1831. "msg": msg,
  1832. })
  1833. return
  1834. } else {
  1835. c.ServeSuccessJSON(map[string]interface{}{
  1836. "msg": "校验成功",
  1837. })
  1838. return
  1839. }
  1840. }
  1841. }
  1842. type ELeCertData struct {
  1843. Data struct {
  1844. Extra string `json:"extra"`
  1845. IDNo string `json:"idNo"`
  1846. IDType string `json:"idType"`
  1847. EcToken string `json:"ecToken"`
  1848. InsuOrg string `json:"insuOrg"`
  1849. UserName string `json:"userName"`
  1850. EcIndexNo string `json:"ecIndexNo"`
  1851. Gender string `json:"gender"`
  1852. Birthday string `json:"birthday"`
  1853. Nationality string `json:"nationality"`
  1854. Email string `json:"email"`
  1855. } `json:"OutData"`
  1856. }
  1857. func (c *HisApiController) ReadCard() {
  1858. id_card_type, _ := c.GetInt64("id_card_type")
  1859. admin_user_id, _ := c.GetInt64("admin_user_id")
  1860. certificates, _ := c.GetInt64("certificates")
  1861. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1863. switch id_card_type {
  1864. case 1:
  1865. if miConfig.MdtrtareaAdmvs == "421300" {
  1866. var res ResultTwo
  1867. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1868. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1869. "&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)
  1870. resp, requestErr := http.Get(api)
  1871. if requestErr != nil {
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1873. return
  1874. }
  1875. body, ioErr := ioutil.ReadAll(resp.Body)
  1876. if ioErr != nil {
  1877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1879. return
  1880. }
  1881. var respJSON map[string]interface{}
  1882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1885. return
  1886. }
  1887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1888. result, _ := json.Marshal(respJSON)
  1889. fmt.Println("log")
  1890. fmt.Println(string(result))
  1891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1892. utils.ErrorLog("解析失败:%v", err)
  1893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1894. return
  1895. }
  1896. if res.Infcode == 0 {
  1897. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1898. if err == gorm.ErrRecordNotFound {
  1899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1900. return
  1901. } else if err != nil {
  1902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1903. return
  1904. } else {
  1905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1907. infoStr := string(Iinfos)
  1908. idetinfoStr := string(Idetinfos)
  1909. psn := &models.HisPsn{
  1910. PsnNo: res.Output.Baseinfo.PsnNo,
  1911. Age: res.Output.Baseinfo.Age,
  1912. PatientId: patient.ID,
  1913. Certno: res.Output.Baseinfo.Certno,
  1914. Brdy: res.Output.Baseinfo.Brdy,
  1915. Gend: res.Output.Baseinfo.Gend,
  1916. Naty: res.Output.Baseinfo.Naty,
  1917. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1918. PsnName: res.Output.Baseinfo.PsnName,
  1919. Idetinfo: idetinfoStr,
  1920. Insuinfo: infoStr,
  1921. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1922. }
  1923. service.CreateHisPsn(psn)
  1924. c.ServeSuccessJSON(map[string]interface{}{
  1925. "patient": patient,
  1926. "number": res.Output.Baseinfo.Certno,
  1927. })
  1928. }
  1929. } else {
  1930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1931. return
  1932. }
  1933. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1934. var api string
  1935. if miConfig.MdtrtareaAdmvs == "320921" {
  1936. 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 +
  1937. "&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
  1938. fmt.Println(api)
  1939. } else {
  1940. 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 +
  1941. "&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)
  1942. }
  1943. resp, requestErr := http.Get(api)
  1944. if requestErr != nil {
  1945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1946. return
  1947. }
  1948. body, ioErr := ioutil.ReadAll(resp.Body)
  1949. if ioErr != nil {
  1950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1952. return
  1953. }
  1954. var respJSON map[string]interface{}
  1955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1958. return
  1959. }
  1960. var status string
  1961. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1962. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1963. //console.log()
  1964. fmt.Println("type===")
  1965. fmt.Println(card_type)
  1966. var token string
  1967. var res ResultTwo //1101结果
  1968. var res10265 ResultTwo10265 //1101结果
  1969. var card_info string //卡信息
  1970. var busi_card_info string
  1971. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1972. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1973. if status == "0" { //读卡成功
  1974. if card_type == "1" {
  1975. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1976. result, _ := json.Marshal(respJSON)
  1977. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1978. utils.ErrorLog("解析失败:%v", err)
  1979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1980. return
  1981. }
  1982. res.ErrMsg = res10265.ErrMsg
  1983. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1984. res.Infcode = infocode
  1985. res.Output = res10265.Output
  1986. res.InfRefmsgid = res10265.InfRefmsgid
  1987. } else {
  1988. //var card_info string //卡信息
  1989. //var busi_card_info string
  1990. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1991. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1992. //fmt.Println(card_info)
  1993. //fmt.Println(busi_card_info)
  1994. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1995. result, _ := json.Marshal(respJSON)
  1996. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1997. utils.ErrorLog("解析失败:%v", err)
  1998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1999. return
  2000. }
  2001. res.ErrMsg = res10265.ErrMsg
  2002. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2003. res.Infcode = infocode
  2004. res.Output = res10265.Output
  2005. res.InfRefmsgid = res10265.InfRefmsgid
  2006. }
  2007. if res.Infcode == 0 {
  2008. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2009. if err == gorm.ErrRecordNotFound {
  2010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2011. return
  2012. } else if err != nil {
  2013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2014. return
  2015. } else {
  2016. if card_type == "1" {
  2017. bas := strings.Split(card_info, "|")
  2018. basNumber := bas[2]
  2019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2021. infoStr := string(Iinfos)
  2022. idetinfoStr := string(Idetinfos)
  2023. psn := &models.HisPsn{
  2024. PsnNo: res.Output.Baseinfo.PsnNo,
  2025. Age: res.Output.Baseinfo.Age,
  2026. PatientId: patient.ID,
  2027. Certno: res.Output.Baseinfo.Certno,
  2028. Brdy: res.Output.Baseinfo.Brdy,
  2029. Gend: res.Output.Baseinfo.Gend,
  2030. Naty: res.Output.Baseinfo.Naty,
  2031. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2032. PsnName: res.Output.Baseinfo.PsnName,
  2033. Idetinfo: idetinfoStr,
  2034. Insuinfo: infoStr,
  2035. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2036. CardInfo: card_info,
  2037. VerifyNumber: busi_card_info,
  2038. }
  2039. service.CreateHisPsn(psn)
  2040. var rf []*ResultFive
  2041. json.Unmarshal([]byte(infoStr), &rf)
  2042. var insutypes []*ResultFive
  2043. var insutype string
  2044. var is390 int = 0
  2045. var is310 int = 0
  2046. for _, item := range rf {
  2047. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2048. insutypes = append(insutypes, item)
  2049. }
  2050. }
  2051. if len(insutypes) == 1 {
  2052. insutype = insutypes[0].Insutype
  2053. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2054. } else {
  2055. for _, i := range insutypes {
  2056. if i.Insutype == "390" {
  2057. is390 = 1
  2058. }
  2059. if i.Insutype == "310" {
  2060. is310 = 1
  2061. }
  2062. }
  2063. }
  2064. if is390 == 1 {
  2065. insutype = "390"
  2066. }
  2067. if is310 == 1 {
  2068. insutype = "310"
  2069. }
  2070. if len(insutypes) == 0 {
  2071. insutype = "310"
  2072. }
  2073. c.ServeSuccessJSON(map[string]interface{}{
  2074. "patient": patient,
  2075. "number": basNumber,
  2076. "insutype": insutype,
  2077. })
  2078. } else {
  2079. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2080. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2081. infoStr := string(Iinfos)
  2082. idetinfoStr := string(Idetinfos)
  2083. psn := &models.HisPsn{
  2084. PsnNo: res.Output.Baseinfo.PsnNo,
  2085. Age: res.Output.Baseinfo.Age,
  2086. PatientId: patient.ID,
  2087. Certno: res.Output.Baseinfo.Certno,
  2088. Brdy: res.Output.Baseinfo.Brdy,
  2089. Gend: res.Output.Baseinfo.Gend,
  2090. Naty: res.Output.Baseinfo.Naty,
  2091. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2092. PsnName: res.Output.Baseinfo.PsnName,
  2093. Idetinfo: idetinfoStr,
  2094. Insuinfo: infoStr,
  2095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2096. CardInfo: card_info,
  2097. VerifyNumber: token,
  2098. }
  2099. service.CreateHisPsn(psn)
  2100. c.ServeSuccessJSON(map[string]interface{}{
  2101. "patient": patient,
  2102. "number": token,
  2103. })
  2104. }
  2105. }
  2106. } else {
  2107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2108. return
  2109. }
  2110. } else { //读卡失败
  2111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2112. return
  2113. }
  2114. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2115. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2116. cardnum = DeleteExtraSpaceTwo(cardnum)
  2117. cardCode = DeleteExtraSpaceTwo(cardCode)
  2118. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2119. name = DeleteExtraSpaceTwo(name)
  2120. errmsg = DeleteExtraSpaceTwo(errmsg)
  2121. cardnum = Remove0000(cardnum)
  2122. cardCode = Remove0000(cardCode)
  2123. id_card_no = Remove0000(id_card_no)
  2124. name = Remove0000(name)
  2125. errmsg = Remove0000(errmsg)
  2126. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2127. 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)
  2128. saveLog(result, requestLog, "1101", "获取人员信息")
  2129. fmt.Println(errMsgLog)
  2130. if len(errMsgLog) > 0 {
  2131. } else {
  2132. var dat map[string]interface{}
  2133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2134. fmt.Println(dat)
  2135. } else {
  2136. fmt.Println(err)
  2137. }
  2138. userJSONBytes, _ := json.Marshal(dat)
  2139. var res ResultTwo
  2140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2141. utils.ErrorLog("解析失败:%v", err)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2143. return
  2144. }
  2145. res.ErrMsg = errMsgLog
  2146. if res.Infcode == 0 {
  2147. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2148. if err == gorm.ErrRecordNotFound {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2150. return
  2151. } else if err != nil {
  2152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2153. return
  2154. } else {
  2155. fmt.Println(res)
  2156. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2157. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2158. infoStr := string(Iinfos)
  2159. idetinfoStr := string(Idetinfos)
  2160. psn := &models.HisPsn{
  2161. PsnNo: res.Output.Baseinfo.PsnNo,
  2162. Age: res.Output.Baseinfo.Age,
  2163. PatientId: patient.ID,
  2164. Certno: res.Output.Baseinfo.Certno,
  2165. Brdy: res.Output.Baseinfo.Brdy,
  2166. Gend: res.Output.Baseinfo.Gend,
  2167. Naty: res.Output.Baseinfo.Naty,
  2168. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2169. PsnName: res.Output.Baseinfo.PsnName,
  2170. Idetinfo: idetinfoStr,
  2171. Insuinfo: infoStr,
  2172. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2173. CardInfo: basStr,
  2174. VerifyNumber: "",
  2175. }
  2176. service.CreateHisPsn(psn)
  2177. var rf []*ResultFive
  2178. json.Unmarshal([]byte(infoStr), &rf)
  2179. var insutypes []*ResultFive
  2180. var insutype string
  2181. var is390 int = 0
  2182. var is310 int = 0
  2183. for _, item := range rf {
  2184. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2185. insutypes = append(insutypes, item)
  2186. }
  2187. }
  2188. if len(insutypes) == 1 {
  2189. insutype = insutypes[0].Insutype
  2190. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2191. } else {
  2192. for _, i := range insutypes {
  2193. if i.Insutype == "390" {
  2194. is390 = 1
  2195. }
  2196. if i.Insutype == "310" {
  2197. is310 = 1
  2198. }
  2199. }
  2200. }
  2201. if is390 == 1 {
  2202. insutype = "390"
  2203. }
  2204. if is310 == 1 {
  2205. insutype = "310"
  2206. }
  2207. if len(insutypes) == 0 {
  2208. insutype = "390"
  2209. }
  2210. c.ServeSuccessJSON(map[string]interface{}{
  2211. "patient": patient,
  2212. "number": cardnum,
  2213. "insutype": insutype,
  2214. })
  2215. }
  2216. } else {
  2217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2218. return
  2219. }
  2220. }
  2221. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2222. fmt.Println(initFlag)
  2223. fmt.Println("initFlag")
  2224. if initFlag == 0 {
  2225. c.TestGetJiangXiBasBaseInit()
  2226. }
  2227. basStr := c.GetBasBaseInfo()
  2228. if len(basStr) == 0 {
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2230. return
  2231. }
  2232. fmt.Println(basStr)
  2233. bas := strings.Split(basStr, "|")
  2234. basNumber := bas[1]
  2235. fmt.Println(basNumber)
  2236. card_sn := bas[3]
  2237. fmt.Println(card_sn)
  2238. 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, "")
  2239. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2240. var dat map[string]interface{}
  2241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2242. fmt.Println(dat)
  2243. } else {
  2244. fmt.Println(err)
  2245. }
  2246. userJSONBytes, _ := json.Marshal(dat)
  2247. var res ResultTwo
  2248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2249. utils.ErrorLog("解析失败:%v", err)
  2250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. return
  2252. }
  2253. if res.Infcode == 0 {
  2254. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2255. if err == gorm.ErrRecordNotFound {
  2256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2257. return
  2258. } else if err != nil {
  2259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2260. return
  2261. } else {
  2262. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2263. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2264. infoStr := string(Iinfos)
  2265. idetinfoStr := string(Idetinfos)
  2266. psn := &models.HisPsn{
  2267. PsnNo: res.Output.Baseinfo.PsnNo,
  2268. Age: res.Output.Baseinfo.Age,
  2269. PatientId: patient.ID,
  2270. Certno: res.Output.Baseinfo.Certno,
  2271. Brdy: res.Output.Baseinfo.Brdy,
  2272. Gend: res.Output.Baseinfo.Gend,
  2273. Naty: res.Output.Baseinfo.Naty,
  2274. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2275. PsnName: res.Output.Baseinfo.PsnName,
  2276. Idetinfo: idetinfoStr,
  2277. Insuinfo: infoStr,
  2278. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2279. CardInfo: basStr,
  2280. VerifyNumber: "",
  2281. }
  2282. service.CreateHisPsn(psn)
  2283. var rf []*ResultFive
  2284. json.Unmarshal([]byte(infoStr), &rf)
  2285. var insutypes []*ResultFive
  2286. var insutype string
  2287. var is390 int = 0
  2288. var is310 int = 0
  2289. for _, item := range rf {
  2290. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2291. insutypes = append(insutypes, item)
  2292. }
  2293. }
  2294. if len(insutypes) == 1 {
  2295. insutype = insutypes[0].Insutype
  2296. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2297. } else {
  2298. for _, i := range insutypes {
  2299. if i.Insutype == "390" {
  2300. is390 = 1
  2301. }
  2302. if i.Insutype == "310" {
  2303. is310 = 1
  2304. }
  2305. }
  2306. }
  2307. if is390 == 1 {
  2308. insutype = "390"
  2309. }
  2310. if is310 == 1 {
  2311. insutype = "310"
  2312. }
  2313. if len(insutypes) == 0 {
  2314. insutype = "310"
  2315. }
  2316. c.ServeSuccessJSON(map[string]interface{}{
  2317. "patient": patient,
  2318. "number": basNumber,
  2319. "insutype": insutype,
  2320. })
  2321. }
  2322. } else {
  2323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2324. return
  2325. }
  2326. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2327. fmt.Println(initFlag)
  2328. fmt.Println("initFlag")
  2329. if initFlag == 0 {
  2330. c.TestGetHnBasBaseInit()
  2331. }
  2332. basStr := c.GetBasBaseInfo()
  2333. if len(basStr) == 0 {
  2334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2335. return
  2336. }
  2337. fmt.Println(basStr)
  2338. bas := strings.Split(basStr, "|")
  2339. basNumber := bas[1]
  2340. fmt.Println(basNumber)
  2341. card_sn := bas[3]
  2342. card_no := bas[2]
  2343. fmt.Println(card_sn)
  2344. name := bas[4]
  2345. name = ConvertToString(name, "gbk", "utf-8")
  2346. 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)
  2347. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2348. var dat map[string]interface{}
  2349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2350. fmt.Println(dat)
  2351. } else {
  2352. fmt.Println(err)
  2353. }
  2354. userJSONBytes, _ := json.Marshal(dat)
  2355. var res ResultTwo
  2356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2357. utils.ErrorLog("解析失败:%v", err)
  2358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2359. return
  2360. }
  2361. if res.Infcode == 0 {
  2362. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2363. if err == gorm.ErrRecordNotFound {
  2364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2365. return
  2366. } else if err != nil {
  2367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2368. return
  2369. } else {
  2370. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2371. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2372. infoStr := string(Iinfos)
  2373. idetinfoStr := string(Idetinfos)
  2374. psn := &models.HisPsn{
  2375. PsnNo: res.Output.Baseinfo.PsnNo,
  2376. Age: res.Output.Baseinfo.Age,
  2377. PatientId: patient.ID,
  2378. Certno: res.Output.Baseinfo.Certno,
  2379. Brdy: res.Output.Baseinfo.Brdy,
  2380. Gend: res.Output.Baseinfo.Gend,
  2381. Naty: res.Output.Baseinfo.Naty,
  2382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2383. PsnName: res.Output.Baseinfo.PsnName,
  2384. Idetinfo: idetinfoStr,
  2385. Insuinfo: infoStr,
  2386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2387. CardInfo: basStr,
  2388. VerifyNumber: "",
  2389. }
  2390. service.CreateHisPsn(psn)
  2391. var rf []*ResultFive
  2392. json.Unmarshal([]byte(infoStr), &rf)
  2393. var insutypes []*ResultFive
  2394. var insutype string
  2395. var is390 int = 0
  2396. var is310 int = 0
  2397. for _, item := range rf {
  2398. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2399. insutypes = append(insutypes, item)
  2400. }
  2401. }
  2402. if len(insutypes) == 1 {
  2403. insutype = insutypes[0].Insutype
  2404. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2405. } else {
  2406. for _, i := range insutypes {
  2407. if i.Insutype == "390" {
  2408. is390 = 1
  2409. }
  2410. if i.Insutype == "310" {
  2411. is310 = 1
  2412. }
  2413. }
  2414. }
  2415. if is390 == 1 {
  2416. insutype = "390"
  2417. }
  2418. if is310 == 1 {
  2419. insutype = "310"
  2420. }
  2421. if len(insutypes) == 0 {
  2422. insutype = "310"
  2423. }
  2424. c.ServeSuccessJSON(map[string]interface{}{
  2425. "patient": patient,
  2426. "number": basNumber,
  2427. "insutype": insutype,
  2428. })
  2429. }
  2430. } else {
  2431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2432. return
  2433. }
  2434. } else {
  2435. if initFlag == 0 {
  2436. c.TestGetBasBaseInit()
  2437. }
  2438. basStr := c.GetBasBaseInfo()
  2439. if len(basStr) == 0 {
  2440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2441. return
  2442. }
  2443. fmt.Println(basStr)
  2444. bas := strings.Split(basStr, "|")
  2445. basNumber := bas[1]
  2446. fmt.Println(basNumber)
  2447. card_sn := bas[3]
  2448. fmt.Println(card_sn)
  2449. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2450. var dat map[string]interface{}
  2451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2452. fmt.Println(dat)
  2453. } else {
  2454. fmt.Println(err)
  2455. }
  2456. userJSONBytes, _ := json.Marshal(dat)
  2457. var res ResultTwo
  2458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2459. utils.ErrorLog("解析失败:%v", err)
  2460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2461. return
  2462. }
  2463. if res.Infcode == 0 {
  2464. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2465. if err == gorm.ErrRecordNotFound {
  2466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2467. return
  2468. } else if err != nil {
  2469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2470. return
  2471. } else {
  2472. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2473. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2474. infoStr := string(Iinfos)
  2475. idetinfoStr := string(Idetinfos)
  2476. psn := &models.HisPsn{
  2477. PsnNo: res.Output.Baseinfo.PsnNo,
  2478. Age: res.Output.Baseinfo.Age,
  2479. PatientId: patient.ID,
  2480. Certno: res.Output.Baseinfo.Certno,
  2481. Brdy: res.Output.Baseinfo.Brdy,
  2482. Gend: res.Output.Baseinfo.Gend,
  2483. Naty: res.Output.Baseinfo.Naty,
  2484. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2485. PsnName: res.Output.Baseinfo.PsnName,
  2486. Idetinfo: idetinfoStr,
  2487. Insuinfo: infoStr,
  2488. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2489. CardInfo: basStr,
  2490. VerifyNumber: "",
  2491. }
  2492. service.CreateHisPsn(psn)
  2493. c.ServeSuccessJSON(map[string]interface{}{
  2494. "patient": patient,
  2495. "number": basNumber,
  2496. })
  2497. }
  2498. } else {
  2499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2500. return
  2501. }
  2502. break
  2503. }
  2504. case 2:
  2505. if miConfig.MdtrtareaAdmvs == "430800" {
  2506. if initFlag == 0 {
  2507. c.TestGetHnBasBaseInit()
  2508. }
  2509. SFZStr := c.GetSFZBaseInfo()
  2510. if len(SFZStr) == 0 {
  2511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2512. return
  2513. }
  2514. fmt.Println(SFZStr)
  2515. id_card_str := strings.Split(SFZStr, "^")
  2516. card_no := id_card_str[0]
  2517. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2518. //name := id_card_str[1]
  2519. //name = ConvertToString(name, "gbk", "utf-8")
  2520. 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)
  2521. var dat map[string]interface{}
  2522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2523. fmt.Println(dat)
  2524. } else {
  2525. fmt.Println(err)
  2526. }
  2527. userJSONBytes, _ := json.Marshal(dat)
  2528. var res ResultTwo
  2529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2530. utils.ErrorLog("解析失败:%v", err)
  2531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2532. return
  2533. }
  2534. if res.Infcode == 0 {
  2535. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2536. if err == gorm.ErrRecordNotFound {
  2537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2538. return
  2539. } else if err != nil {
  2540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2541. return
  2542. } else {
  2543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2545. infoStr := string(Iinfos)
  2546. idetinfoStr := string(Idetinfos)
  2547. psn := &models.HisPsn{
  2548. PsnNo: res.Output.Baseinfo.PsnNo,
  2549. Age: res.Output.Baseinfo.Age,
  2550. PatientId: patient.ID,
  2551. Certno: res.Output.Baseinfo.Certno,
  2552. Brdy: res.Output.Baseinfo.Brdy,
  2553. Gend: res.Output.Baseinfo.Gend,
  2554. Naty: res.Output.Baseinfo.Naty,
  2555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2556. PsnName: res.Output.Baseinfo.PsnName,
  2557. Idetinfo: idetinfoStr,
  2558. Insuinfo: infoStr,
  2559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2560. CardInfo: SFZStr,
  2561. VerifyNumber: "",
  2562. }
  2563. service.CreateHisPsn(psn)
  2564. var rf []*ResultFive
  2565. json.Unmarshal([]byte(infoStr), &rf)
  2566. var insutypes []*ResultFive
  2567. var insutype string
  2568. var is390 int = 0
  2569. var is310 int = 0
  2570. for _, item := range rf {
  2571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2572. insutypes = append(insutypes, item)
  2573. }
  2574. }
  2575. if len(insutypes) == 1 {
  2576. insutype = insutypes[0].Insutype
  2577. } else {
  2578. for _, i := range insutypes {
  2579. if i.Insutype == "390" {
  2580. is390 = 1
  2581. }
  2582. if i.Insutype == "310" {
  2583. is310 = 1
  2584. }
  2585. }
  2586. }
  2587. if is390 == 1 {
  2588. insutype = "390"
  2589. }
  2590. if is310 == 1 {
  2591. insutype = "310"
  2592. }
  2593. if len(insutypes) == 0 {
  2594. insutype = "310"
  2595. }
  2596. c.ServeSuccessJSON(map[string]interface{}{
  2597. "patient": patient,
  2598. "number": card_no,
  2599. "insutype": insutype,
  2600. })
  2601. }
  2602. } else {
  2603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2604. return
  2605. }
  2606. } else {
  2607. SFZStr := c.GetSFZBaseInfo()
  2608. id_card_str := strings.Split(SFZStr, "^")
  2609. id_card_number := id_card_str[0]
  2610. card_sn := ""
  2611. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2612. var dat map[string]interface{}
  2613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2614. fmt.Println(dat)
  2615. } else {
  2616. fmt.Println(err)
  2617. }
  2618. userJSONBytes, _ := json.Marshal(dat)
  2619. var res ResultTwo
  2620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2621. utils.ErrorLog("解析失败:%v", err)
  2622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2623. return
  2624. }
  2625. if res.Infcode == 0 {
  2626. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2627. if err == gorm.ErrRecordNotFound {
  2628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2629. return
  2630. } else if err != nil {
  2631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2632. return
  2633. } else {
  2634. c.ServeSuccessJSON(map[string]interface{}{
  2635. "patient": patient,
  2636. "number": id_card_number,
  2637. })
  2638. }
  2639. } else {
  2640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2641. return
  2642. }
  2643. }
  2644. break
  2645. case 3:
  2646. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2647. var api string
  2648. if miConfig.MdtrtareaAdmvs == "320921" {
  2649. 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 +
  2650. "&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
  2651. fmt.Println(api)
  2652. } else {
  2653. 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 +
  2654. "&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)
  2655. }
  2656. resp, requestErr := http.Get(api)
  2657. if requestErr != nil {
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. body, ioErr := ioutil.ReadAll(resp.Body)
  2662. if ioErr != nil {
  2663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. var respJSON map[string]interface{}
  2668. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. return
  2672. }
  2673. var status string
  2674. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2675. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2676. var token string
  2677. var res ResultTwo //1101结果
  2678. var res10265 ResultTwo10265 //1101结果
  2679. var card_info string //卡信息
  2680. var busi_card_info string
  2681. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2682. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2683. if status == "0" { //读卡成功
  2684. if card_type == "1" {
  2685. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2686. result, _ := json.Marshal(respJSON)
  2687. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2688. utils.ErrorLog("解析失败:%v", err)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. res.ErrMsg = res10265.ErrMsg
  2693. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2694. res.Infcode = infocode
  2695. res.Output = res10265.Output
  2696. res.InfRefmsgid = res10265.InfRefmsgid
  2697. } else {
  2698. //var card_info string //卡信息
  2699. //var busi_card_info string
  2700. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2701. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2702. //fmt.Println(card_info)
  2703. //fmt.Println(busi_card_info)
  2704. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2705. result, _ := json.Marshal(respJSON)
  2706. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2707. utils.ErrorLog("解析失败:%v", err)
  2708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2709. return
  2710. }
  2711. res.ErrMsg = res10265.ErrMsg
  2712. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2713. res.Infcode = infocode
  2714. res.Output = res10265.Output
  2715. res.InfRefmsgid = res10265.InfRefmsgid
  2716. }
  2717. if res.Infcode == 0 {
  2718. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2719. if err == gorm.ErrRecordNotFound {
  2720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2721. return
  2722. } else if err != nil {
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2724. return
  2725. } else {
  2726. if card_type == "1" {
  2727. bas := strings.Split(card_info, "|")
  2728. basNumber := bas[2]
  2729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2731. infoStr := string(Iinfos)
  2732. idetinfoStr := string(Idetinfos)
  2733. psn := &models.HisPsn{
  2734. PsnNo: res.Output.Baseinfo.PsnNo,
  2735. Age: res.Output.Baseinfo.Age,
  2736. PatientId: patient.ID,
  2737. Certno: res.Output.Baseinfo.Certno,
  2738. Brdy: res.Output.Baseinfo.Brdy,
  2739. Gend: res.Output.Baseinfo.Gend,
  2740. Naty: res.Output.Baseinfo.Naty,
  2741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2742. PsnName: res.Output.Baseinfo.PsnName,
  2743. Idetinfo: idetinfoStr,
  2744. Insuinfo: infoStr,
  2745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2746. CardInfo: card_info,
  2747. VerifyNumber: busi_card_info,
  2748. }
  2749. service.CreateHisPsn(psn)
  2750. c.ServeSuccessJSON(map[string]interface{}{
  2751. "patient": patient,
  2752. "number": basNumber,
  2753. })
  2754. } else {
  2755. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2756. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2757. infoStr := string(Iinfos)
  2758. idetinfoStr := string(Idetinfos)
  2759. psn := &models.HisPsn{
  2760. PsnNo: res.Output.Baseinfo.PsnNo,
  2761. Age: res.Output.Baseinfo.Age,
  2762. PatientId: patient.ID,
  2763. Certno: res.Output.Baseinfo.Certno,
  2764. Brdy: res.Output.Baseinfo.Brdy,
  2765. Gend: res.Output.Baseinfo.Gend,
  2766. Naty: res.Output.Baseinfo.Naty,
  2767. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2768. PsnName: res.Output.Baseinfo.PsnName,
  2769. Idetinfo: idetinfoStr,
  2770. Insuinfo: infoStr,
  2771. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2772. CardInfo: card_info,
  2773. VerifyNumber: token,
  2774. }
  2775. service.CreateHisPsn(psn)
  2776. var rf []*ResultFive
  2777. json.Unmarshal([]byte(infoStr), &rf)
  2778. var insutypes []*ResultFive
  2779. var insutype string
  2780. var is390 int = 0
  2781. var is310 int = 0
  2782. for _, item := range rf {
  2783. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2784. insutypes = append(insutypes, item)
  2785. }
  2786. }
  2787. if len(insutypes) == 1 {
  2788. insutype = insutypes[0].Insutype
  2789. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2790. } else {
  2791. for _, i := range insutypes {
  2792. if i.Insutype == "390" {
  2793. is390 = 1
  2794. }
  2795. if i.Insutype == "310" {
  2796. is310 = 1
  2797. }
  2798. }
  2799. }
  2800. if is390 == 1 {
  2801. insutype = "390"
  2802. }
  2803. if is310 == 1 {
  2804. insutype = "310"
  2805. }
  2806. if len(insutypes) == 0 {
  2807. insutype = "310"
  2808. }
  2809. c.ServeSuccessJSON(map[string]interface{}{
  2810. "patient": patient,
  2811. "number": token,
  2812. "insutype": insutype,
  2813. })
  2814. }
  2815. }
  2816. } else {
  2817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2818. return
  2819. }
  2820. } else { //读卡失败
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2822. return
  2823. }
  2824. }
  2825. break
  2826. case 4:
  2827. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2828. var api string
  2829. if miConfig.MdtrtareaAdmvs == "320921" {
  2830. 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 +
  2831. "&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
  2832. fmt.Println(api)
  2833. } else {
  2834. 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 +
  2835. "&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)
  2836. }
  2837. resp, requestErr := http.Get(api)
  2838. if requestErr != nil {
  2839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2840. return
  2841. }
  2842. body, ioErr := ioutil.ReadAll(resp.Body)
  2843. if ioErr != nil {
  2844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2846. return
  2847. }
  2848. var respJSON map[string]interface{}
  2849. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. var status string
  2855. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2856. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2857. var token string
  2858. var res ResultTwo //1101结果
  2859. var res10265 ResultTwo10265 //1101结果
  2860. if status == "0" { //读卡成功
  2861. var card_info string //卡信息
  2862. var busi_card_info string
  2863. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2864. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2865. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2866. fmt.Println(card_info)
  2867. fmt.Println(busi_card_info)
  2868. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2869. result, _ := json.Marshal(respJSON)
  2870. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. res.ErrMsg = res10265.ErrMsg
  2876. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2877. res.Infcode = infocode
  2878. res.Output = res10265.Output
  2879. res.InfRefmsgid = res10265.InfRefmsgid
  2880. if res.Infcode == 0 {
  2881. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2882. if err == gorm.ErrRecordNotFound {
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2884. return
  2885. } else if err != nil {
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2887. return
  2888. } else {
  2889. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2890. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2891. infoStr := string(Iinfos)
  2892. idetinfoStr := string(Idetinfos)
  2893. psn := &models.HisPsn{
  2894. PsnNo: res.Output.Baseinfo.PsnNo,
  2895. Age: res.Output.Baseinfo.Age,
  2896. PatientId: patient.ID,
  2897. Certno: res.Output.Baseinfo.Certno,
  2898. Brdy: res.Output.Baseinfo.Brdy,
  2899. Gend: res.Output.Baseinfo.Gend,
  2900. Naty: res.Output.Baseinfo.Naty,
  2901. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2902. PsnName: res.Output.Baseinfo.PsnName,
  2903. Idetinfo: idetinfoStr,
  2904. Insuinfo: infoStr,
  2905. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2906. CardInfo: card_info,
  2907. VerifyNumber: token,
  2908. }
  2909. var rf []*ResultFive
  2910. json.Unmarshal([]byte(infoStr), &rf)
  2911. var insutypes []*ResultFive
  2912. var insutype string
  2913. var is390 int = 0
  2914. var is310 int = 0
  2915. for _, item := range rf {
  2916. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2917. insutypes = append(insutypes, item)
  2918. }
  2919. }
  2920. if len(insutypes) == 1 {
  2921. insutype = insutypes[0].Insutype
  2922. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2923. } else {
  2924. for _, i := range insutypes {
  2925. if i.Insutype == "390" {
  2926. is390 = 1
  2927. }
  2928. if i.Insutype == "310" {
  2929. is310 = 1
  2930. }
  2931. }
  2932. }
  2933. if is390 == 1 {
  2934. insutype = "390"
  2935. }
  2936. if is310 == 1 {
  2937. insutype = "310"
  2938. }
  2939. if len(insutypes) == 0 {
  2940. insutype = "310"
  2941. }
  2942. service.CreateHisPsn(psn)
  2943. c.ServeSuccessJSON(map[string]interface{}{
  2944. "patient": patient,
  2945. "number": token,
  2946. "insutype": insutype,
  2947. })
  2948. }
  2949. } else {
  2950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2951. return
  2952. }
  2953. } else { //读卡失败
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2955. return
  2956. }
  2957. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2958. if initFlag == 0 {
  2959. c.TestGetBasBaseInit()
  2960. }
  2961. token := c.GetEleBaseInfo()
  2962. token = Remove0000(token)
  2963. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  2964. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2965. //
  2966. var res ResultTwo
  2967. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2968. utils.ErrorLog("解析失败:%v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2983. infoStr := string(Iinfos)
  2984. idetinfoStr := string(Idetinfos)
  2985. psn := &models.HisPsn{
  2986. PsnNo: res.Output.Baseinfo.PsnNo,
  2987. Age: res.Output.Baseinfo.Age,
  2988. PatientId: patient.ID,
  2989. Certno: res.Output.Baseinfo.Certno,
  2990. Brdy: res.Output.Baseinfo.Brdy,
  2991. Gend: res.Output.Baseinfo.Gend,
  2992. Naty: res.Output.Baseinfo.Naty,
  2993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2994. PsnName: res.Output.Baseinfo.PsnName,
  2995. Idetinfo: idetinfoStr,
  2996. Insuinfo: infoStr,
  2997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2998. CardInfo: "",
  2999. VerifyNumber: token,
  3000. }
  3001. service.CreateHisPsn(psn)
  3002. c.ServeSuccessJSON(map[string]interface{}{
  3003. "patient": patient,
  3004. "number": token,
  3005. })
  3006. }
  3007. } else {
  3008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3009. return
  3010. }
  3011. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3012. if initFlag == 0 {
  3013. c.TestGetBasBaseInit()
  3014. }
  3015. token := c.GetEleBaseInfo()
  3016. token = Remove0000(token)
  3017. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3018. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3019. //
  3020. var res ResultTwo
  3021. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. return
  3025. }
  3026. if res.Infcode == 0 {
  3027. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3028. if err == gorm.ErrRecordNotFound {
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3030. return
  3031. } else if err != nil {
  3032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3033. return
  3034. } else {
  3035. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3036. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3037. infoStr := string(Iinfos)
  3038. idetinfoStr := string(Idetinfos)
  3039. psn := &models.HisPsn{
  3040. PsnNo: res.Output.Baseinfo.PsnNo,
  3041. Age: res.Output.Baseinfo.Age,
  3042. PatientId: patient.ID,
  3043. Certno: res.Output.Baseinfo.Certno,
  3044. Brdy: res.Output.Baseinfo.Brdy,
  3045. Gend: res.Output.Baseinfo.Gend,
  3046. Naty: res.Output.Baseinfo.Naty,
  3047. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3048. PsnName: res.Output.Baseinfo.PsnName,
  3049. Idetinfo: idetinfoStr,
  3050. Insuinfo: infoStr,
  3051. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3052. CardInfo: "",
  3053. VerifyNumber: token,
  3054. }
  3055. service.CreateHisPsn(psn)
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "patient": patient,
  3058. "number": token,
  3059. })
  3060. }
  3061. } else {
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3063. return
  3064. }
  3065. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3066. //if initFlag == 0 {
  3067. c.TestGetJiangXiBasBaseInit()
  3068. //}
  3069. //if initEleFlag == 0 {
  3070. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3071. //}
  3072. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3073. type ELeData struct {
  3074. Data struct {
  3075. IdNo string `json:"idNo"`
  3076. IdType string `json:"idType"`
  3077. UserName string `json:"userName"`
  3078. EcToken string `json:"ecToken"`
  3079. InsuOrg string `json:"insuOrg"`
  3080. Gender string `json:"gender"`
  3081. Birthday string `json:"birthday"`
  3082. Nationality string `json:"nationality"`
  3083. Email string `json:"email"`
  3084. Extra string `json:"extra"`
  3085. } `json:"data"`
  3086. Code int `json:"code"`
  3087. Message string `json:"message"`
  3088. }
  3089. var ele ELeData
  3090. err := json.Unmarshal([]byte(json_result), &ele)
  3091. if err != nil {
  3092. utils.ErrorLog("解析失败:%v", err)
  3093. }
  3094. token := ele.Data.EcToken
  3095. token = Remove0000(token)
  3096. 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)
  3097. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3098. var res ResultTwo
  3099. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3100. utils.ErrorLog("解析失败:%v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. if res.Infcode == 0 {
  3105. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3106. if err == gorm.ErrRecordNotFound {
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3108. return
  3109. } else if err != nil {
  3110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3111. return
  3112. } else {
  3113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3115. infoStr := string(Iinfos)
  3116. idetinfoStr := string(Idetinfos)
  3117. psn := &models.HisPsn{
  3118. PsnNo: res.Output.Baseinfo.PsnNo,
  3119. Age: res.Output.Baseinfo.Age,
  3120. PatientId: patient.ID,
  3121. Certno: res.Output.Baseinfo.Certno,
  3122. Brdy: res.Output.Baseinfo.Brdy,
  3123. Gend: res.Output.Baseinfo.Gend,
  3124. Naty: res.Output.Baseinfo.Naty,
  3125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3126. PsnName: res.Output.Baseinfo.PsnName,
  3127. Idetinfo: idetinfoStr,
  3128. Insuinfo: infoStr,
  3129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3130. CardInfo: "",
  3131. VerifyNumber: token,
  3132. }
  3133. service.CreateHisPsn(psn)
  3134. var rf []*ResultFive
  3135. json.Unmarshal([]byte(infoStr), &rf)
  3136. var insutypes []*ResultFive
  3137. var insutype string
  3138. var is390 int = 0
  3139. var is310 int = 0
  3140. for _, item := range rf {
  3141. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3142. insutypes = append(insutypes, item)
  3143. }
  3144. }
  3145. if len(insutypes) == 1 {
  3146. insutype = insutypes[0].Insutype
  3147. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3148. } else {
  3149. for _, i := range insutypes {
  3150. if i.Insutype == "390" {
  3151. is390 = 1
  3152. }
  3153. if i.Insutype == "310" {
  3154. is310 = 1
  3155. }
  3156. }
  3157. }
  3158. if is390 == 1 {
  3159. insutype = "390"
  3160. }
  3161. if is310 == 1 {
  3162. insutype = "310"
  3163. }
  3164. if len(insutypes) == 0 {
  3165. insutype = "310"
  3166. }
  3167. c.ServeSuccessJSON(map[string]interface{}{
  3168. "patient": patient,
  3169. "number": token,
  3170. "insutype": insutype,
  3171. })
  3172. }
  3173. } else {
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3175. return
  3176. }
  3177. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3178. //if initFlag == 0 {
  3179. c.TestGetJiangXiBasBaseInit()
  3180. //}
  3181. //if initEleFlag == 0 {
  3182. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3183. //}
  3184. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3185. type ELeData struct {
  3186. Data struct {
  3187. IdNo string `json:"idNo"`
  3188. IdType string `json:"idType"`
  3189. UserName string `json:"userName"`
  3190. EcToken string `json:"ecToken"`
  3191. InsuOrg string `json:"insuOrg"`
  3192. Gender string `json:"gender"`
  3193. Birthday string `json:"birthday"`
  3194. Nationality string `json:"nationality"`
  3195. Email string `json:"email"`
  3196. Extra string `json:"extra"`
  3197. } `json:"data"`
  3198. Code int `json:"code"`
  3199. Message string `json:"message"`
  3200. }
  3201. var ele ELeData
  3202. err := json.Unmarshal([]byte(json_result), &ele)
  3203. if err != nil {
  3204. utils.ErrorLog("解析失败:%v", err)
  3205. }
  3206. token := ele.Data.EcToken
  3207. token = Remove0000(token)
  3208. 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)
  3209. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3210. var res ResultTwo
  3211. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3212. utils.ErrorLog("解析失败:%v", err)
  3213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3214. return
  3215. }
  3216. if res.Infcode == 0 {
  3217. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3218. if err == gorm.ErrRecordNotFound {
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3220. return
  3221. } else if err != nil {
  3222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3223. return
  3224. } else {
  3225. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3226. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3227. infoStr := string(Iinfos)
  3228. idetinfoStr := string(Idetinfos)
  3229. psn := &models.HisPsn{
  3230. PsnNo: res.Output.Baseinfo.PsnNo,
  3231. Age: res.Output.Baseinfo.Age,
  3232. PatientId: patient.ID,
  3233. Certno: res.Output.Baseinfo.Certno,
  3234. Brdy: res.Output.Baseinfo.Brdy,
  3235. Gend: res.Output.Baseinfo.Gend,
  3236. Naty: res.Output.Baseinfo.Naty,
  3237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3238. PsnName: res.Output.Baseinfo.PsnName,
  3239. Idetinfo: idetinfoStr,
  3240. Insuinfo: infoStr,
  3241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3242. CardInfo: "",
  3243. VerifyNumber: token,
  3244. }
  3245. service.CreateHisPsn(psn)
  3246. var rf []*ResultFive
  3247. json.Unmarshal([]byte(infoStr), &rf)
  3248. var insutypes []*ResultFive
  3249. var insutype string
  3250. var is390 int = 0
  3251. var is310 int = 0
  3252. for _, item := range rf {
  3253. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3254. insutypes = append(insutypes, item)
  3255. }
  3256. }
  3257. if len(insutypes) == 1 {
  3258. insutype = insutypes[0].Insutype
  3259. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3260. } else {
  3261. for _, i := range insutypes {
  3262. if i.Insutype == "390" {
  3263. is390 = 1
  3264. }
  3265. if i.Insutype == "310" {
  3266. is310 = 1
  3267. }
  3268. }
  3269. }
  3270. if is390 == 1 {
  3271. insutype = "390"
  3272. }
  3273. if is310 == 1 {
  3274. insutype = "310"
  3275. }
  3276. if len(insutypes) == 0 {
  3277. insutype = "310"
  3278. }
  3279. c.ServeSuccessJSON(map[string]interface{}{
  3280. "patient": patient,
  3281. "number": token,
  3282. "insutype": insutype,
  3283. })
  3284. }
  3285. } else {
  3286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3287. return
  3288. }
  3289. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3290. type ELeData struct {
  3291. Code string `json:"code"`
  3292. Data struct {
  3293. Aac002 string `json:"aac002"`
  3294. Aaz500 string `json:"aaz500"`
  3295. ActCardNo string `json:"actCardNo"`
  3296. Bab520 string `json:"bab520"`
  3297. Bkz543 string `json:"bkz543"`
  3298. BusinessType string `json:"businessType"`
  3299. CertfCodg string `json:"certfCodg"`
  3300. EcIndexNo string `json:"ecIndexNo"`
  3301. EcToken string `json:"ecToken"`
  3302. ID0000 string `json:"id0000"`
  3303. IDNo string `json:"idNo"`
  3304. IDType string `json:"idType"`
  3305. Idcode string `json:"idcode"`
  3306. IdentityToken string `json:"identity_token"`
  3307. InsuOrg string `json:"insuOrg"`
  3308. OfficeID string `json:"officeId"`
  3309. OfficeName string `json:"officeName"`
  3310. OperatorID string `json:"operatorId"`
  3311. OperatorName string `json:"operatorName"`
  3312. OrgID string `json:"orgId"`
  3313. UserName string `json:"userName"`
  3314. } `json:"data"`
  3315. Infno interface{} `json:"infno"`
  3316. Message string `json:"message"`
  3317. OrgID string `json:"orgId"`
  3318. TransType string `json:"transType"`
  3319. }
  3320. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3321. outPutInfo = Remove0000(outPutInfo)
  3322. if len(outPutInfo) > 0 {
  3323. var ele ELeData
  3324. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3325. if err != nil {
  3326. utils.ErrorLog("解析失败:%v", err)
  3327. }
  3328. token := ele.Data.EcToken
  3329. fmt.Println(inputInfo)
  3330. fmt.Println(outPutInfo)
  3331. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3332. saveLog(result, requestLog, "1101", "获取人员信息")
  3333. var dat map[string]interface{}
  3334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3335. fmt.Println(dat)
  3336. } else {
  3337. fmt.Println(err)
  3338. }
  3339. userJSONBytes, _ := json.Marshal(dat)
  3340. var res ResultTwo
  3341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. res.ErrMsg = errMsgLog
  3347. if res.Infcode == 0 {
  3348. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3349. if err == gorm.ErrRecordNotFound {
  3350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3351. return
  3352. } else if err != nil {
  3353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3354. return
  3355. } else {
  3356. fmt.Println(res)
  3357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3359. infoStr := string(Iinfos)
  3360. idetinfoStr := string(Idetinfos)
  3361. psn := &models.HisPsn{
  3362. PsnNo: res.Output.Baseinfo.PsnNo,
  3363. Age: res.Output.Baseinfo.Age,
  3364. PatientId: patient.ID,
  3365. Certno: res.Output.Baseinfo.Certno,
  3366. Brdy: res.Output.Baseinfo.Brdy,
  3367. Gend: res.Output.Baseinfo.Gend,
  3368. Naty: res.Output.Baseinfo.Naty,
  3369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3370. PsnName: res.Output.Baseinfo.PsnName,
  3371. Idetinfo: idetinfoStr,
  3372. Insuinfo: infoStr,
  3373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3374. CardInfo: outPutInfo,
  3375. VerifyNumber: token,
  3376. InsuplcAdmdvs: ele.Data.InsuOrg,
  3377. }
  3378. service.CreateHisPsn(psn)
  3379. var rf []*ResultFive
  3380. json.Unmarshal([]byte(infoStr), &rf)
  3381. var insutypes []*ResultFive
  3382. var insutype string
  3383. var is390 int = 0
  3384. var is310 int = 0
  3385. for _, item := range rf {
  3386. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3387. insutypes = append(insutypes, item)
  3388. }
  3389. }
  3390. if len(insutypes) == 1 {
  3391. insutype = insutypes[0].Insutype
  3392. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3393. } else {
  3394. for _, i := range insutypes {
  3395. if i.Insutype == "390" {
  3396. is390 = 1
  3397. }
  3398. if i.Insutype == "310" {
  3399. is310 = 1
  3400. }
  3401. }
  3402. }
  3403. if is390 == 1 {
  3404. insutype = "390"
  3405. }
  3406. if is310 == 1 {
  3407. insutype = "310"
  3408. }
  3409. if len(insutypes) == 0 {
  3410. insutype = "310"
  3411. }
  3412. c.ServeSuccessJSON(map[string]interface{}{
  3413. "patient": patient,
  3414. "number": token,
  3415. "insutype": insutype,
  3416. })
  3417. }
  3418. } else {
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3420. return
  3421. }
  3422. }
  3423. }
  3424. break
  3425. }
  3426. }
  3427. var initFlag int64 = 0
  3428. var initEleFlag int64 = 0
  3429. func (c *HisApiController) TestGetBasBaseInit() {
  3430. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3431. Iinit := DllDef.MustFindProc("Init")
  3432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3433. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3434. if ret != 0 {
  3435. fmt.Println("SSCard的报错原因:", err)
  3436. fmt.Println("SSCard的运算结果为:", ret)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3438. return
  3439. }
  3440. result := int(ret)
  3441. fmt.Println("SSCard的运算结果为1:", result)
  3442. initFlag = 1
  3443. return
  3444. }
  3445. func (c *HisApiController) HandleJiangXiReadCard() {
  3446. fmt.Println("~~~~~~")
  3447. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3448. admin_user_id, _ := c.GetInt64("admin_user_id")
  3449. id_card_type, _ := c.GetInt64("id_card_type")
  3450. //certificates, _ := c.GetInt64("certificates")
  3451. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3452. if initFlag == 0 {
  3453. c.TestGetJiangXiBasBaseInit()
  3454. }
  3455. basStr := c.GetBasBaseInfo()
  3456. if len(basStr) == 0 {
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3458. return
  3459. }
  3460. fmt.Println(basStr)
  3461. bas := strings.Split(basStr, "|")
  3462. basNumber := bas[1]
  3463. fmt.Println(basNumber)
  3464. card_sn := bas[3]
  3465. fmt.Println(card_sn)
  3466. 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, "")
  3467. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3468. var dat map[string]interface{}
  3469. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3470. fmt.Println(dat)
  3471. } else {
  3472. fmt.Println(err)
  3473. }
  3474. userJSONBytes, _ := json.Marshal(dat)
  3475. var res ResultTwo
  3476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3477. utils.ErrorLog("解析失败:%v", err)
  3478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3479. return
  3480. }
  3481. if res.Infcode == 0 {
  3482. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3483. if err == gorm.ErrRecordNotFound {
  3484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3485. return
  3486. } else if err != nil {
  3487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3488. return
  3489. } else {
  3490. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3491. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3492. infoStr := string(Iinfos)
  3493. idetinfoStr := string(Idetinfos)
  3494. psn := &models.HisPsn{
  3495. PsnNo: res.Output.Baseinfo.PsnNo,
  3496. Age: res.Output.Baseinfo.Age,
  3497. PatientId: patient.ID,
  3498. Certno: res.Output.Baseinfo.Certno,
  3499. Brdy: res.Output.Baseinfo.Brdy,
  3500. Gend: res.Output.Baseinfo.Gend,
  3501. Naty: res.Output.Baseinfo.Naty,
  3502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3503. PsnName: res.Output.Baseinfo.PsnName,
  3504. Idetinfo: idetinfoStr,
  3505. Insuinfo: infoStr,
  3506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3507. CardInfo: basStr,
  3508. VerifyNumber: "",
  3509. }
  3510. service.CreateHisPsn(psn)
  3511. c.ServeSuccessJSON(map[string]interface{}{
  3512. "patient": patient,
  3513. "number": basNumber,
  3514. })
  3515. }
  3516. } else {
  3517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3518. return
  3519. }
  3520. }
  3521. func (c *HisApiController) TestGetHnBasBaseInit() {
  3522. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3523. Iinit := DllDef.MustFindProc("Init")
  3524. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3525. //http://10.77.211.236/CSB/hsa-fsi-1303
  3526. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3527. if ret != 0 {
  3528. fmt.Println("SSCard的报错原因:", err)
  3529. fmt.Println("SSCard的运算结果为:", ret)
  3530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3531. return
  3532. }
  3533. result := int(ret)
  3534. fmt.Println("SSCard的运算结果为1:", result)
  3535. initFlag = 1
  3536. return
  3537. }
  3538. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3539. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3540. Iinit := DllDef.MustFindProc("Init")
  3541. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3542. //http://10.77.211.236/CSB/hsa-fsi-1303
  3543. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3544. if ret != 0 {
  3545. fmt.Println("SSCard的报错原因:", err)
  3546. fmt.Println("SSCard的运算结果为:", ret)
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3548. return
  3549. }
  3550. result := int(ret)
  3551. fmt.Println("SSCard的运算结果为1:", result)
  3552. initFlag = 1
  3553. return
  3554. }
  3555. func (c *HisApiController) GetSFZBaseInfo() string {
  3556. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3557. readCard := DllDef.MustFindProc("ReadSFZ")
  3558. if readCard == nil {
  3559. fmt.Println("readcard is nil")
  3560. readCard = DllDef.MustFindProc("ReadSFZ")
  3561. }
  3562. str := make([]byte, 8096)
  3563. str1 := make([]byte, 8096)
  3564. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3565. fmt.Println(r)
  3566. return Remove0000(string(str))
  3567. }
  3568. func (c *HisApiController) GetEleBaseInfo() string {
  3569. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3570. readCard := DllDef.MustFindProc("GetQRBase")
  3571. fmt.Println(readCard)
  3572. if readCard == nil {
  3573. fmt.Println("readcard is nil")
  3574. readCard = DllDef.MustFindProc("GetQRBase")
  3575. }
  3576. str := make([]byte, 1024)
  3577. str1 := make([]byte, 1024)
  3578. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3579. fmt.Println(ret2)
  3580. fmt.Println(string(str1))
  3581. fmt.Println(string(str))
  3582. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3583. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3584. if ret2 != 0 {
  3585. return ""
  3586. }
  3587. return string(str)
  3588. }
  3589. func GetJxEleBaseInfo(org_id int64) string {
  3590. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3591. readCard := DllDef.MustFindProc("NationEcTrans")
  3592. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3593. if readCard == nil {
  3594. fmt.Println("readcard is nil")
  3595. readCard = DllDef.MustFindProc("NationEcTrans")
  3596. }
  3597. str1 := make([]byte, 1024)
  3598. data := make(map[string]interface{})
  3599. inputData := make(map[string]interface{})
  3600. inputData["orgId"] = miConfig.Code
  3601. inputData["businessType"] = "01101"
  3602. inputData["operatorId"] = "test001"
  3603. inputData["operatorName"] = "cn"
  3604. inputData["officeId"] = "32760"
  3605. inputData["officeName"] = "waike"
  3606. inputData["deviceType"] = ""
  3607. data["data"] = inputData
  3608. data["transType"] = "ec.query"
  3609. data["extra "] = ""
  3610. data["orgId"] = miConfig.Code
  3611. bytesData, _ := json.Marshal(data)
  3612. //bytesData, _ := json.Marshal(data)
  3613. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3614. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3615. fmt.Println(ret2)
  3616. fmt.Println(string(str1))
  3617. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3618. if ret2 != 0 {
  3619. return ""
  3620. }
  3621. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3622. }
  3623. func GetJxEleBaseInitInfo(org_id int64) string {
  3624. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3625. readCard := DllDef.MustFindProc("NationEcTrans")
  3626. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3627. if readCard == nil {
  3628. fmt.Println("readcard is nil")
  3629. readCard = DllDef.MustFindProc("NationEcTrans")
  3630. }
  3631. str1 := make([]byte, 2048)
  3632. data := make(map[string]interface{})
  3633. inputData := make(map[string]interface{})
  3634. inputData["orgId"] = miConfig.Code
  3635. inputData["businessType"] = "01101"
  3636. inputData["operatorId"] = "1"
  3637. inputData["operatorName"] = "huangchuang"
  3638. inputData["officeId"] = "101"
  3639. inputData["officeName"] = "xuetou"
  3640. inputData["deviceType"] = ""
  3641. data["data"] = inputData
  3642. data["transType"] = "ec.query"
  3643. data["orgId"] = miConfig.Code
  3644. bytesData, _ := json.Marshal(data)
  3645. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3646. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3647. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3648. fmt.Println(ret2)
  3649. fmt.Println(string(str1))
  3650. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3651. if ret2 != 0 {
  3652. return ""
  3653. }
  3654. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3655. initEleFlag = 1
  3656. }
  3657. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3658. }
  3659. func (c *HisApiController) GetBasBaseInfo() string {
  3660. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3661. readCard := DllDef.MustFindProc("ReadCardBas")
  3662. if readCard == nil {
  3663. fmt.Println("readcard is nil")
  3664. readCard = DllDef.MustFindProc("ReadCardBas")
  3665. }
  3666. str := make([]byte, 1024)
  3667. str1 := make([]byte, 1024)
  3668. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3669. fmt.Println(string(str1))
  3670. fmt.Println(string(str))
  3671. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3672. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3673. if ret2 != 0 {
  3674. return ""
  3675. }
  3676. return string(str)
  3677. }
  3678. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3679. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3680. readCard := DllDef.MustFindProc("read_cardinfo")
  3681. if readCard == nil {
  3682. fmt.Println("readcard is nil")
  3683. readCard = DllDef.MustFindProc("read_cardinfo")
  3684. }
  3685. str := make([]byte, 1024) //卡号
  3686. str1 := make([]byte, 1024) //卡识别码
  3687. str2 := make([]byte, 1024) //身份证号
  3688. str3 := make([]byte, 1024) //姓名
  3689. str4 := make([]byte, 1024) //错误信息
  3690. 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])))
  3691. fmt.Println(string(str1))
  3692. fmt.Println(string(str))
  3693. fmt.Println(string(str2))
  3694. fmt.Println(string(str3))
  3695. fmt.Println(string(str4))
  3696. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3697. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3698. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3699. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3700. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3701. if ret2 != 0 {
  3702. return "", "", "", "", ""
  3703. }
  3704. return string(str), string(str1), string(str2), string(str3), string(str4)
  3705. }
  3706. type CustomFundPay struct {
  3707. FundPayType string `json:"fund_pay_type"`
  3708. FundPayamt float64 `json:"fund_payamt"`
  3709. }
  3710. func (c *HisApiController) GetSettleList() {
  3711. order_id, _ := c.GetInt64("order_id")
  3712. admin_user_id, _ := c.GetInt64("admin_user_id")
  3713. order, _ := service.GetHisOrderByIDTwo(order_id)
  3714. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3715. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3716. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3717. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3718. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3719. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3720. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3721. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3722. if order.ID == 0 {
  3723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3724. return
  3725. }
  3726. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3727. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3728. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3729. //fmt.Println(count)
  3730. //var zero string
  3731. //number := count + 1
  3732. //if number >= 1000 {
  3733. // zero = "0000" + strconv.FormatInt(number, 10)
  3734. //} else if number >= 10000 {
  3735. // zero = "000" + strconv.FormatInt(number, 10)
  3736. //} else if number >= 100000 {
  3737. // zero = "00" + strconv.FormatInt(number, 10)
  3738. //} else if number >= 1000000 {
  3739. // zero = "0" + strconv.FormatInt(number, 10)
  3740. //} else {
  3741. // zero = strconv.FormatInt(number, 10)
  3742. //}
  3743. //fmt.Println(zero)
  3744. struct4101 := service.Struct4101{
  3745. PsnNo: order.PsnNo,
  3746. MdtrtId: order.MdtrtId,
  3747. SetlId: order.SetlId,
  3748. PsnName: order.PsnName,
  3749. Gend: order.Gend,
  3750. Brdy: his.Brdy,
  3751. Age: his.Age,
  3752. Naty: order.Naty,
  3753. PatnCertType: "01",
  3754. Certno: order.Certno,
  3755. Prfs: "90",
  3756. ConerName: roles[0].UserName,
  3757. PatnRlts: "99",
  3758. ConerAddr: miConfig.OrgName,
  3759. ConerTel: admin.Mobile,
  3760. HiType: order.Insutype,
  3761. Insuplc: miConfig.InsuplcAdmdvs,
  3762. MaindiagFlag: "1",
  3763. BillCode: order.SetlId,
  3764. BillNo: order.SetlId,
  3765. BizSn: order.Number,
  3766. PsnSelfPay: order.PsnPartAmt,
  3767. PsnOwnPay: order.PsnPartAmt,
  3768. AcctPay: order.AcctPay,
  3769. PsnCashpay: order.PsnCashPay,
  3770. HiPaymtd: "1",
  3771. Hsorg: miConfig.InsuplcAdmdvs,
  3772. HsorgOpter: miConfig.InsuplcAdmdvs,
  3773. MedinsFillPsn: curRoles.UserName,
  3774. MedinsFillDept: depart.Name,
  3775. IptMedType: "2",
  3776. }
  3777. struct4101.SetlBegnDate = order.SetlTime
  3778. struct4101.SetlEndDate = order.SetlTime
  3779. time_arr := strings.Split(order.SetlTime, " ")
  3780. struct4101.AdmTime = time_arr[0]
  3781. struct4101.AdmEndTime = time_arr[0]
  3782. var rf []CustomFundPay
  3783. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3784. var tempFunPays []service.CustomStruct
  3785. for _, item := range rf {
  3786. var tempFunPay service.CustomStruct
  3787. tempFunPay.FundPayamt = item.FundPayamt
  3788. tempFunPay.FundPayType = item.FundPayType
  3789. tempFunPays = append(tempFunPays, tempFunPay)
  3790. }
  3791. struct4101.CustomStruct = tempFunPays
  3792. var tempDiaginfos []service.DiaginfoStructTwo
  3793. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3794. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3795. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3796. var config []*models.HisXtDiagnoseConfig
  3797. for _, item := range diagnosis_ids {
  3798. id, _ := strconv.ParseInt(item, 10, 64)
  3799. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3800. config = append(config, &diagnosisConfig)
  3801. }
  3802. for index, item := range config {
  3803. if index == 0 {
  3804. var tempDiaginfo service.DiaginfoStructTwo
  3805. tempDiaginfo.DiagCode = item.CountryCode
  3806. tempDiaginfo.DiagName = item.CountryContentName
  3807. tempDiaginfo.DiagType = "1"
  3808. tempDiaginfo.MaindiagFlag = "1"
  3809. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3810. } else {
  3811. var tempDiaginfo service.DiaginfoStructTwo
  3812. tempDiaginfo.DiagCode = item.CountryCode
  3813. tempDiaginfo.DiagName = item.CountryContentName
  3814. tempDiaginfo.DiagType = "2"
  3815. tempDiaginfo.MaindiagFlag = "0"
  3816. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3817. }
  3818. }
  3819. struct4101.Diseinfo = tempDiaginfos
  3820. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3821. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3822. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3823. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3824. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3825. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3826. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3827. var iteminfo service.IteminfoStruct
  3828. var bedCostTotal float64 = 0 //床位总费
  3829. var bedCostSelfTotal float64 = 0 //床位自费
  3830. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3831. var operationCostTotal float64 = 0 //手术费
  3832. var operationCostSelfTotal float64 = 0 //手术费
  3833. var operationCostPartSelfTotal float64 = 0 //手术费
  3834. var otherCostTotal float64 = 0 //其他费用
  3835. var otherCostSelfTotal float64 = 0 //其他费用
  3836. var otherCostPartSelfTotal float64 = 0 //其他费用
  3837. var materialCostTotal float64 = 0 //材料费
  3838. var materialCostSelfTotal float64 = 0 //材料费
  3839. var materialCostPartSelfTotal float64 = 0 //材料费
  3840. var westernMedicineCostTotal float64 = 0 //西药费
  3841. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3842. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3843. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3844. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3845. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3846. var checkCostTotal float64 = 0 //检查费
  3847. var checkCostSelfTotal float64 = 0 //检查费
  3848. var checkCostPartSelfTotal float64 = 0 //检查费
  3849. var laboratoryCostTotal float64 = 0 //化验费
  3850. var laboratoryCostSelfTotal float64 = 0 //化验费
  3851. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3852. var treatCostTotal float64 = 0 //治疗费用
  3853. var treatCostSelfTotal float64 = 0 //治疗费用
  3854. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3855. decimal.DivisionPrecision = 2
  3856. var bed_fulamt_ownpay_amt float64 = 0
  3857. var operation_fulamt_ownpay_amt float64 = 0
  3858. var other_fulamt_ownpay_amt float64 = 0
  3859. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3860. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3861. var check_fulamt_ownpay_amt float64 = 0
  3862. var material_fulamt_ownpay_amt float64 = 0
  3863. var laboratory_fulamt_ownpay_amt float64 = 0
  3864. var treat_fulamt_ownpay_amt float64 = 0
  3865. var bed_claa_sunmfee float64 = 0
  3866. var bed_clab_amt float64 = 0
  3867. var bed_other_amt float64 = 0
  3868. var operation_claa_sunmfee float64 = 0
  3869. var operation_clab_amt float64 = 0
  3870. var operation_other_amt float64 = 0
  3871. var other_claa_sunmfee float64 = 0
  3872. var other_clab_amt float64 = 0
  3873. var other_other_amt float64 = 0
  3874. var westernMedicine_claa_sunmfee float64 = 0
  3875. var westernMedicine_clab_amt float64 = 0
  3876. var westernMedicine_other_amt float64 = 0
  3877. var chineseTraditional_claa_sunmfee float64 = 0
  3878. var chineseTraditional_clab_amt float64 = 0
  3879. var chineseTraditional_other_amt float64 = 0
  3880. var check_claa_sunmfee float64 = 0
  3881. var check_clab_amt float64 = 0
  3882. var check_other_amt float64 = 0
  3883. var material_claa_sunmfee float64 = 0
  3884. var material_clab_amt float64 = 0
  3885. var material_other_amt float64 = 0
  3886. var laboratory_claa_sunmfee float64 = 0
  3887. var laboratory_clab_amt float64 = 0
  3888. var laboratory_other_amt float64 = 0
  3889. var treat_claa_sunmfee float64 = 0
  3890. var treat_clab_amt float64 = 0
  3891. var treat_other_amt float64 = 0
  3892. for _, item := range order.HisOrderInfo {
  3893. if item.MedChrgitmType == "01" { //床位费
  3894. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3895. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3896. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3897. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3898. if item.ChrgitmLv == "1" {
  3899. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3900. }
  3901. if item.ChrgitmLv == "2" {
  3902. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3903. }
  3904. if item.ChrgitmLv == "3" {
  3905. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3906. }
  3907. }
  3908. if item.MedChrgitmType == "03" { //检查费
  3909. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3910. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3911. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3912. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3913. if item.ChrgitmLv == "1" {
  3914. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3915. }
  3916. if item.ChrgitmLv == "2" {
  3917. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3918. }
  3919. if item.ChrgitmLv == "3" {
  3920. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3921. }
  3922. }
  3923. if item.MedChrgitmType == "04" { //化验费
  3924. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3925. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3926. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3927. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3928. if item.ChrgitmLv == "1" {
  3929. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3930. }
  3931. if item.ChrgitmLv == "2" {
  3932. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3933. }
  3934. if item.ChrgitmLv == "3" {
  3935. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3936. }
  3937. }
  3938. if item.MedChrgitmType == "05" { //治疗费
  3939. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3940. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3941. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3942. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3943. if item.ChrgitmLv == "1" {
  3944. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3945. }
  3946. if item.ChrgitmLv == "2" {
  3947. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3948. }
  3949. if item.ChrgitmLv == "3" {
  3950. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3951. }
  3952. }
  3953. if item.MedChrgitmType == "06" { //手术费
  3954. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3955. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3956. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3957. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3958. if item.ChrgitmLv == "1" {
  3959. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3960. }
  3961. if item.ChrgitmLv == "2" {
  3962. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3963. }
  3964. if item.ChrgitmLv == "3" {
  3965. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3966. }
  3967. }
  3968. if item.MedChrgitmType == "08" { //材料费
  3969. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3970. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3971. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3972. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3973. if item.ChrgitmLv == "1" {
  3974. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3975. }
  3976. if item.ChrgitmLv == "2" {
  3977. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3978. }
  3979. if item.ChrgitmLv == "3" {
  3980. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3981. }
  3982. }
  3983. if item.MedChrgitmType == "09" { //西药费
  3984. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3985. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3986. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3987. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3988. if item.ChrgitmLv == "1" {
  3989. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3990. }
  3991. if item.ChrgitmLv == "2" {
  3992. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3993. }
  3994. if item.ChrgitmLv == "3" {
  3995. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3996. }
  3997. }
  3998. if item.MedChrgitmType == "11" { //中成费
  3999. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4000. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4001. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4002. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4003. if item.ChrgitmLv == "1" {
  4004. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4005. }
  4006. if item.ChrgitmLv == "2" {
  4007. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4008. }
  4009. if item.ChrgitmLv == "3" {
  4010. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4011. }
  4012. }
  4013. if item.MedChrgitmType == "14" { //其他费
  4014. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4015. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4016. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4017. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4018. if item.ChrgitmLv == "1" {
  4019. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4020. }
  4021. if item.ChrgitmLv == "2" {
  4022. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4023. }
  4024. if item.ChrgitmLv == "3" {
  4025. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4026. }
  4027. }
  4028. }
  4029. var iteminfoStructs []service.IteminfoStruct
  4030. if bedCostTotal != 0 {
  4031. iteminfo.MedChrgitm = "01"
  4032. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4033. iteminfo.Amt = bedCostTotal
  4034. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4035. iteminfo.ClabAmt = bed_clab_amt
  4036. iteminfo.OthAmt = bed_other_amt
  4037. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4038. }
  4039. if checkCostTotal != 0 {
  4040. iteminfo.MedChrgitm = "03"
  4041. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4042. iteminfo.Amt = checkCostTotal
  4043. iteminfo.ClaaSumfee = check_claa_sunmfee
  4044. iteminfo.ClabAmt = check_clab_amt
  4045. iteminfo.OthAmt = check_other_amt
  4046. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4047. }
  4048. if laboratoryCostTotal != 0 {
  4049. iteminfo.MedChrgitm = "04"
  4050. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4051. iteminfo.Amt = laboratoryCostTotal
  4052. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4053. iteminfo.ClabAmt = laboratory_clab_amt
  4054. iteminfo.OthAmt = laboratory_other_amt
  4055. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4056. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4057. }
  4058. if treatCostTotal != 0 {
  4059. iteminfo.MedChrgitm = "05"
  4060. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4061. iteminfo.Amt = treatCostTotal
  4062. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4063. iteminfo.ClabAmt = treat_clab_amt
  4064. iteminfo.OthAmt = treat_other_amt
  4065. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4066. //(struct4101.IteminfoStruct, iteminfo)
  4067. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4068. }
  4069. if operationCostTotal != 0 {
  4070. iteminfo.MedChrgitm = "06"
  4071. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4072. iteminfo.Amt = operationCostTotal
  4073. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4074. iteminfo.ClabAmt = operation_clab_amt
  4075. iteminfo.OthAmt = operation_other_amt
  4076. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4077. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4078. }
  4079. if materialCostTotal != 0 {
  4080. iteminfo.MedChrgitm = "08"
  4081. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4082. iteminfo.Amt = materialCostTotal
  4083. iteminfo.ClaaSumfee = material_claa_sunmfee
  4084. iteminfo.ClabAmt = material_clab_amt
  4085. iteminfo.OthAmt = material_other_amt
  4086. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4087. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4088. }
  4089. if westernMedicineCostTotal != 0 {
  4090. iteminfo.MedChrgitm = "09"
  4091. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4092. iteminfo.Amt = westernMedicineCostTotal
  4093. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4094. iteminfo.ClabAmt = westernMedicine_clab_amt
  4095. iteminfo.OthAmt = westernMedicine_other_amt
  4096. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4097. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4098. }
  4099. if chineseTraditionalMedicineCostTotal != 0 {
  4100. iteminfo.MedChrgitm = "11"
  4101. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4102. iteminfo.Amt = westernMedicineCostTotal
  4103. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4104. iteminfo.ClabAmt = westernMedicine_clab_amt
  4105. iteminfo.OthAmt = westernMedicine_other_amt
  4106. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4107. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4108. }
  4109. if otherCostTotal != 0 {
  4110. iteminfo.MedChrgitm = "14"
  4111. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4112. iteminfo.Amt = otherCostTotal
  4113. iteminfo.ClaaSumfee = other_claa_sunmfee
  4114. iteminfo.ClabAmt = other_clab_amt
  4115. iteminfo.OthAmt = other_other_amt
  4116. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4117. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4118. }
  4119. struct4101.IteminfoStruct = iteminfoStructs
  4120. struct4101.Ntly = "中国"
  4121. struct4101.AdmCaty = "A03.06"
  4122. struct4101.DoctorName = doctor.UserName
  4123. struct4101.DoctorCode = doctor.DoctorNumber
  4124. var res ResultSeventeen
  4125. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4126. struct4101.BillCode = order.Number
  4127. struct4101.BillNo = order.SetlId
  4128. var resOther ResultSeventeenOther
  4129. var pp models.PublicParams
  4130. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4131. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4132. pp.FixmedinsName = miConfig.OrgName
  4133. pp.FixmedinsCode = miConfig.Code
  4134. pp.RequestUrl = miConfig.Url
  4135. pp.Cainfo = miConfig.Cainfo
  4136. pp.SecretKey = miConfig.SecretKey
  4137. pp.AccessKey = miConfig.AccessKey
  4138. pp.OpterName = curRoles.UserName
  4139. client := &http.Client{}
  4140. var req *http.Request
  4141. data := make(map[string]interface{})
  4142. data["struct4101"] = struct4101
  4143. data["pp"] = pp
  4144. bytesData, _ := json.Marshal(data)
  4145. if miConfig.MdtrtareaAdmvs == "320921" {
  4146. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4147. } else {
  4148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4149. }
  4150. resp, _ := client.Do(req)
  4151. defer resp.Body.Close()
  4152. body, ioErr := ioutil.ReadAll(resp.Body)
  4153. if ioErr != nil {
  4154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4156. return
  4157. }
  4158. var respJSON map[string]interface{}
  4159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4162. return
  4163. }
  4164. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4165. userJSONBytes, _ := json.Marshal(respJSON)
  4166. fmt.Println("log")
  4167. fmt.Println(string(userJSONBytes))
  4168. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4169. utils.ErrorLog("解析失败:%v", err)
  4170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4171. return
  4172. }
  4173. res.InfRefmsgid = resOther.InfRefmsgid
  4174. res.Output = resOther.Output
  4175. res.ErrMsg = resOther.ErrMsg
  4176. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4177. res.Infcode = infocode
  4178. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4179. var pp models.PublicParams
  4180. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4181. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4182. pp.FixmedinsName = miConfig.OrgName
  4183. pp.FixmedinsCode = miConfig.Code
  4184. pp.RequestUrl = miConfig.Url
  4185. pp.Cainfo = miConfig.Cainfo
  4186. pp.SecretKey = miConfig.SecretKey
  4187. pp.AccessKey = miConfig.AccessKey
  4188. pp.OpterName = curRoles.UserName
  4189. result, _ := service.Jxyb4101(struct4101, pp)
  4190. var dat map[string]interface{}
  4191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4192. fmt.Println(dat)
  4193. } else {
  4194. fmt.Println(err)
  4195. }
  4196. userJSONBytes, _ := json.Marshal(dat)
  4197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4203. var pp models.PublicParams
  4204. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4205. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4206. pp.FixmedinsName = miConfig.OrgName
  4207. pp.FixmedinsCode = miConfig.Code
  4208. pp.RequestUrl = miConfig.Url
  4209. pp.Cainfo = miConfig.Cainfo
  4210. pp.SecretKey = miConfig.SecretKey
  4211. pp.AccessKey = miConfig.AccessKey
  4212. pp.OpterName = curRoles.UserName
  4213. result, _ := service.Hnyb4101(struct4101, pp)
  4214. var dat map[string]interface{}
  4215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4216. fmt.Println(dat)
  4217. } else {
  4218. fmt.Println(err)
  4219. }
  4220. userJSONBytes, _ := json.Marshal(dat)
  4221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. } else {
  4227. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4228. var dat map[string]interface{}
  4229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4230. fmt.Println(dat)
  4231. } else {
  4232. fmt.Println(err)
  4233. }
  4234. userJSONBytes, _ := json.Marshal(dat)
  4235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4236. utils.ErrorLog("解析失败:%v", err)
  4237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4238. return
  4239. }
  4240. }
  4241. if res.Infcode != 0 {
  4242. c.ServeSuccessJSON(map[string]interface{}{
  4243. "failed_code": -10,
  4244. "msg": res.ErrMsg,
  4245. })
  4246. return
  4247. } else {
  4248. //order.FaPiaoNumber = zero
  4249. //order.FaPiaoCode = last_order.FaPiaoCode
  4250. //service.UpdateOrder(order)
  4251. hisFundSettleListResult := &models.HisFundSettleListResult{
  4252. Number: res.Output.SetlListId,
  4253. Status: 1,
  4254. Ctime: time.Now().Unix(),
  4255. Mtime: time.Now().Unix(),
  4256. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4257. IsUpload: 1,
  4258. OrderId: order_id,
  4259. }
  4260. service.CreateUploadRecord(hisFundSettleListResult)
  4261. c.ServeSuccessJSON(map[string]interface{}{
  4262. "msg": "上传成功",
  4263. "result": hisFundSettleListResult,
  4264. })
  4265. return
  4266. }
  4267. }
  4268. func (c *HisApiController) GetSettleListHospital() {
  4269. order_id, _ := c.GetInt64("order_id")
  4270. admin_user_id, _ := c.GetInt64("admin_user_id")
  4271. order, _ := service.GetHisOrderByIDTwo(order_id)
  4272. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4273. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4274. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4276. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4278. if order.ID == 0 {
  4279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4280. return
  4281. }
  4282. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4283. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4284. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4285. fmt.Println(count)
  4286. var zero string
  4287. number := count + 1
  4288. if number >= 1000 {
  4289. zero = "0000" + strconv.FormatInt(number, 10)
  4290. } else if number >= 10000 {
  4291. zero = "000" + strconv.FormatInt(number, 10)
  4292. } else if number >= 100000 {
  4293. zero = "00" + strconv.FormatInt(number, 10)
  4294. } else if number >= 1000000 {
  4295. zero = "0" + strconv.FormatInt(number, 10)
  4296. } else {
  4297. zero = strconv.FormatInt(number, 10)
  4298. }
  4299. fmt.Println(zero)
  4300. struct4101 := service.Struct4101{
  4301. PsnNo: order.PsnNo,
  4302. MdtrtId: order.MdtrtId,
  4303. SetlId: order.SetlId,
  4304. PsnName: order.PsnName,
  4305. Gend: order.Gend,
  4306. Brdy: his.Brdy,
  4307. Age: int64(order.Age),
  4308. Naty: order.Naty,
  4309. PatnCertType: "01",
  4310. Certno: order.Certno,
  4311. Prfs: "90",
  4312. ConerName: roles[0].UserName,
  4313. PatnRlts: "99",
  4314. ConerAddr: miConfig.OrgName,
  4315. ConerTel: admin.Mobile,
  4316. HiType: order.Insutype,
  4317. Insuplc: miConfig.InsuplcAdmdvs,
  4318. MaindiagFlag: "1",
  4319. BillCode: order.SetlId,
  4320. BillNo: order.SetlId,
  4321. BizSn: order.Number,
  4322. PsnSelfPay: order.PsnPartAmt,
  4323. PsnOwnPay: order.PsnPartAmt,
  4324. AcctPay: order.AcctPay,
  4325. PsnCashpay: order.PsnCashPay,
  4326. HiPaymtd: "1",
  4327. Hsorg: miConfig.InsuplcAdmdvs,
  4328. HsorgOpter: miConfig.InsuplcAdmdvs,
  4329. MedinsFillPsn: curRoles.UserName,
  4330. MedinsFillDept: depart.Name,
  4331. IptMedType: "2",
  4332. AdmTime: his.InHosptialTime,
  4333. AdmEndTime: his.OutHosptialTime,
  4334. }
  4335. struct4101.SetlBegnDate = order.SetlTime
  4336. struct4101.SetlEndDate = order.SetlTime
  4337. var rf []CustomFundPay
  4338. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4339. var tempFunPays []service.CustomStruct
  4340. for _, item := range rf {
  4341. var tempFunPay service.CustomStruct
  4342. tempFunPay.FundPayamt = item.FundPayamt
  4343. tempFunPay.FundPayType = item.FundPayType
  4344. tempFunPays = append(tempFunPays, tempFunPay)
  4345. }
  4346. struct4101.CustomStruct = tempFunPays
  4347. var tempDiaginfos []service.DiaginfoStructTwo
  4348. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4349. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4350. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4351. var config []*models.HisXtDiagnoseConfig
  4352. for _, item := range diagnosis_ids {
  4353. id, _ := strconv.ParseInt(item, 10, 64)
  4354. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4355. config = append(config, &diagnosisConfig)
  4356. }
  4357. for index, item := range config {
  4358. if index == 0 {
  4359. var tempDiaginfo service.DiaginfoStructTwo
  4360. tempDiaginfo.DiagCode = item.CountryCode
  4361. tempDiaginfo.DiagName = item.CountryContentName
  4362. tempDiaginfo.DiagType = "1"
  4363. tempDiaginfo.MaindiagFlag = "1"
  4364. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4365. } else {
  4366. var tempDiaginfo service.DiaginfoStructTwo
  4367. tempDiaginfo.DiagCode = item.CountryCode
  4368. tempDiaginfo.DiagName = item.CountryContentName
  4369. tempDiaginfo.DiagType = "2"
  4370. tempDiaginfo.MaindiagFlag = "0"
  4371. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4372. }
  4373. }
  4374. struct4101.Diseinfo = tempDiaginfos
  4375. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4376. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4377. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4378. tempOpspdiseinfo2.OprnOprtCode = ""
  4379. tempOpspdiseinfo2.OprnOprtName = ""
  4380. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4381. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4382. var iteminfo service.IteminfoStruct
  4383. var bedCostTotal float64 = 0 //床位总费
  4384. var bedCostSelfTotal float64 = 0 //床位自费
  4385. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4386. var operationCostTotal float64 = 0 //手术费
  4387. var operationCostSelfTotal float64 = 0 //手术费
  4388. var operationCostPartSelfTotal float64 = 0 //手术费
  4389. var otherCostTotal float64 = 0 //其他费用
  4390. var otherCostSelfTotal float64 = 0 //其他费用
  4391. var otherCostPartSelfTotal float64 = 0 //其他费用
  4392. var materialCostTotal float64 = 0 //材料费
  4393. var materialCostSelfTotal float64 = 0 //材料费
  4394. var materialCostPartSelfTotal float64 = 0 //材料费
  4395. var westernMedicineCostTotal float64 = 0 //西药费
  4396. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4397. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4398. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4399. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4400. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4401. var checkCostTotal float64 = 0 //检查费
  4402. var checkCostSelfTotal float64 = 0 //检查费
  4403. var checkCostPartSelfTotal float64 = 0 //检查费
  4404. var laboratoryCostTotal float64 = 0 //化验费
  4405. var laboratoryCostSelfTotal float64 = 0 //化验费
  4406. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4407. var treatCostTotal float64 = 0 //治疗费用
  4408. var treatCostSelfTotal float64 = 0 //治疗费用
  4409. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4410. decimal.DivisionPrecision = 2
  4411. var bed_fulamt_ownpay_amt float64 = 0
  4412. var operation_fulamt_ownpay_amt float64 = 0
  4413. var other_fulamt_ownpay_amt float64 = 0
  4414. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4415. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4416. var check_fulamt_ownpay_amt float64 = 0
  4417. var material_fulamt_ownpay_amt float64 = 0
  4418. var laboratory_fulamt_ownpay_amt float64 = 0
  4419. var treat_fulamt_ownpay_amt float64 = 0
  4420. var bed_claa_sunmfee float64 = 0
  4421. var bed_clab_amt float64 = 0
  4422. var bed_other_amt float64 = 0
  4423. var operation_claa_sunmfee float64 = 0
  4424. var operation_clab_amt float64 = 0
  4425. var operation_other_amt float64 = 0
  4426. var other_claa_sunmfee float64 = 0
  4427. var other_clab_amt float64 = 0
  4428. var other_other_amt float64 = 0
  4429. var westernMedicine_claa_sunmfee float64 = 0
  4430. var westernMedicine_clab_amt float64 = 0
  4431. var westernMedicine_other_amt float64 = 0
  4432. var chineseTraditional_claa_sunmfee float64 = 0
  4433. var chineseTraditional_clab_amt float64 = 0
  4434. var chineseTraditional_other_amt float64 = 0
  4435. var check_claa_sunmfee float64 = 0
  4436. var check_clab_amt float64 = 0
  4437. var check_other_amt float64 = 0
  4438. var material_claa_sunmfee float64 = 0
  4439. var material_clab_amt float64 = 0
  4440. var material_other_amt float64 = 0
  4441. var laboratory_claa_sunmfee float64 = 0
  4442. var laboratory_clab_amt float64 = 0
  4443. var laboratory_other_amt float64 = 0
  4444. var treat_claa_sunmfee float64 = 0
  4445. var treat_clab_amt float64 = 0
  4446. var treat_other_amt float64 = 0
  4447. for _, item := range order.HisOrderInfo {
  4448. if item.MedChrgitmType == "01" { //床位费
  4449. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4450. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4451. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4452. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4453. if item.ChrgitmLv == "1" {
  4454. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4455. }
  4456. if item.ChrgitmLv == "2" {
  4457. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4458. }
  4459. if item.ChrgitmLv == "3" {
  4460. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4461. }
  4462. }
  4463. if item.MedChrgitmType == "03" { //检查费
  4464. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4465. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4466. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4467. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4468. if item.ChrgitmLv == "1" {
  4469. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4470. }
  4471. if item.ChrgitmLv == "2" {
  4472. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4473. }
  4474. if item.ChrgitmLv == "3" {
  4475. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4476. }
  4477. }
  4478. if item.MedChrgitmType == "04" { //化验费
  4479. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4480. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4481. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4482. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4483. if item.ChrgitmLv == "1" {
  4484. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4485. }
  4486. if item.ChrgitmLv == "2" {
  4487. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4488. }
  4489. if item.ChrgitmLv == "3" {
  4490. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4491. }
  4492. }
  4493. if item.MedChrgitmType == "05" { //治疗费
  4494. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4495. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4496. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4497. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4498. if item.ChrgitmLv == "1" {
  4499. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4500. }
  4501. if item.ChrgitmLv == "2" {
  4502. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4503. }
  4504. if item.ChrgitmLv == "3" {
  4505. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4506. }
  4507. }
  4508. if item.MedChrgitmType == "06" { //手术费
  4509. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4510. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4511. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4512. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4513. if item.ChrgitmLv == "1" {
  4514. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4515. }
  4516. if item.ChrgitmLv == "2" {
  4517. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4518. }
  4519. if item.ChrgitmLv == "3" {
  4520. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4521. }
  4522. }
  4523. if item.MedChrgitmType == "08" { //材料费
  4524. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4525. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4526. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4527. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4528. if item.ChrgitmLv == "1" {
  4529. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4530. }
  4531. if item.ChrgitmLv == "2" {
  4532. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4533. }
  4534. if item.ChrgitmLv == "3" {
  4535. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4536. }
  4537. }
  4538. if item.MedChrgitmType == "09" { //西药费
  4539. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4540. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4541. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4542. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4543. if item.ChrgitmLv == "1" {
  4544. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4545. }
  4546. if item.ChrgitmLv == "2" {
  4547. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4548. }
  4549. if item.ChrgitmLv == "3" {
  4550. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4551. }
  4552. }
  4553. if item.MedChrgitmType == "11" { //中成费
  4554. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4555. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4556. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4557. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4558. if item.ChrgitmLv == "1" {
  4559. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4560. }
  4561. if item.ChrgitmLv == "2" {
  4562. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4563. }
  4564. if item.ChrgitmLv == "3" {
  4565. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4566. }
  4567. }
  4568. if item.MedChrgitmType == "14" { //其他费
  4569. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4570. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4571. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4572. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4573. if item.ChrgitmLv == "1" {
  4574. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4575. }
  4576. if item.ChrgitmLv == "2" {
  4577. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4578. }
  4579. if item.ChrgitmLv == "3" {
  4580. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4581. }
  4582. }
  4583. }
  4584. var iteminfoStructs []service.IteminfoStruct
  4585. if bedCostTotal != 0 {
  4586. iteminfo.MedChrgitm = "01"
  4587. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4588. iteminfo.Amt = bedCostTotal
  4589. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4590. iteminfo.ClabAmt = bed_clab_amt
  4591. iteminfo.OthAmt = bed_other_amt
  4592. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4593. }
  4594. if checkCostTotal != 0 {
  4595. iteminfo.MedChrgitm = "03"
  4596. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4597. iteminfo.Amt = checkCostTotal
  4598. iteminfo.ClaaSumfee = check_claa_sunmfee
  4599. iteminfo.ClabAmt = check_clab_amt
  4600. iteminfo.OthAmt = check_other_amt
  4601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4602. }
  4603. if laboratoryCostTotal != 0 {
  4604. iteminfo.MedChrgitm = "04"
  4605. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4606. iteminfo.Amt = laboratoryCostTotal
  4607. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4608. iteminfo.ClabAmt = laboratory_clab_amt
  4609. iteminfo.OthAmt = laboratory_other_amt
  4610. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4611. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4612. }
  4613. if treatCostTotal != 0 {
  4614. iteminfo.MedChrgitm = "05"
  4615. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4616. iteminfo.Amt = treatCostTotal
  4617. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4618. iteminfo.ClabAmt = treat_clab_amt
  4619. iteminfo.OthAmt = treat_other_amt
  4620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4621. //(struct4101.IteminfoStruct, iteminfo)
  4622. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4623. }
  4624. if operationCostTotal != 0 {
  4625. iteminfo.MedChrgitm = "06"
  4626. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4627. iteminfo.Amt = operationCostTotal
  4628. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4629. iteminfo.ClabAmt = operation_clab_amt
  4630. iteminfo.OthAmt = operation_other_amt
  4631. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4633. }
  4634. if materialCostTotal != 0 {
  4635. iteminfo.MedChrgitm = "08"
  4636. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4637. iteminfo.Amt = materialCostTotal
  4638. iteminfo.ClaaSumfee = material_claa_sunmfee
  4639. iteminfo.ClabAmt = material_clab_amt
  4640. iteminfo.OthAmt = material_other_amt
  4641. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4643. }
  4644. if westernMedicineCostTotal != 0 {
  4645. iteminfo.MedChrgitm = "09"
  4646. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4647. iteminfo.Amt = westernMedicineCostTotal
  4648. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4649. iteminfo.ClabAmt = westernMedicine_clab_amt
  4650. iteminfo.OthAmt = westernMedicine_other_amt
  4651. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4652. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4653. }
  4654. if chineseTraditionalMedicineCostTotal != 0 {
  4655. iteminfo.MedChrgitm = "11"
  4656. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4657. iteminfo.Amt = westernMedicineCostTotal
  4658. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4659. iteminfo.ClabAmt = westernMedicine_clab_amt
  4660. iteminfo.OthAmt = westernMedicine_other_amt
  4661. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4662. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4663. }
  4664. if otherCostTotal != 0 {
  4665. iteminfo.MedChrgitm = "14"
  4666. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4667. iteminfo.Amt = otherCostTotal
  4668. iteminfo.ClaaSumfee = other_claa_sunmfee
  4669. iteminfo.ClabAmt = other_clab_amt
  4670. iteminfo.OthAmt = other_other_amt
  4671. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4673. }
  4674. struct4101.IteminfoStruct = iteminfoStructs
  4675. struct4101.Ntly = "中国"
  4676. struct4101.AdmCaty = "A03.06"
  4677. var resOther ResultSeventeenOther
  4678. var res ResultSeventeen
  4679. if miConfig.MdtrtareaAdmvs == "150499" {
  4680. var pp models.PublicParams
  4681. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4682. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4683. pp.FixmedinsName = miConfig.OrgName
  4684. pp.FixmedinsCode = miConfig.Code
  4685. pp.RequestUrl = miConfig.Url
  4686. pp.Cainfo = miConfig.Cainfo
  4687. pp.SecretKey = miConfig.SecretKey
  4688. pp.AccessKey = miConfig.AccessKey
  4689. pp.OpterName = curRoles.UserName
  4690. client := &http.Client{}
  4691. var req *http.Request
  4692. data := make(map[string]interface{})
  4693. data["struct4101"] = struct4101
  4694. data["pp"] = pp
  4695. bytesData, _ := json.Marshal(data)
  4696. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4697. resp, _ := client.Do(req)
  4698. defer resp.Body.Close()
  4699. body, ioErr := ioutil.ReadAll(resp.Body)
  4700. if ioErr != nil {
  4701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4703. return
  4704. }
  4705. var respJSON map[string]interface{}
  4706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4712. userJSONBytes, _ := json.Marshal(respJSON)
  4713. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4714. utils.ErrorLog("解析失败:%v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. res.InfRefmsgid = resOther.InfRefmsgid
  4719. res.Output = resOther.Output
  4720. res.ErrMsg = resOther.ErrMsg
  4721. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4722. res.Infcode = infocode
  4723. } else {
  4724. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4725. var dat map[string]interface{}
  4726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4727. fmt.Println(dat)
  4728. } else {
  4729. fmt.Println(err)
  4730. }
  4731. userJSONBytes, _ := json.Marshal(dat)
  4732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4733. utils.ErrorLog("解析失败:%v", err)
  4734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4735. return
  4736. }
  4737. }
  4738. if res.Infcode != 0 {
  4739. c.ServeSuccessJSON(map[string]interface{}{
  4740. "failed_code": -10,
  4741. "msg": res.ErrMsg,
  4742. })
  4743. return
  4744. } else {
  4745. if miConfig.MdtrtareaAdmvs != "150499" {
  4746. order.FaPiaoNumber = zero
  4747. order.FaPiaoCode = last_order.FaPiaoCode
  4748. service.UpdateOrder(order)
  4749. }
  4750. hisFundSettleListResult := &models.HisFundSettleListResult{
  4751. Number: res.Output.SetlListId,
  4752. Status: 1,
  4753. Ctime: time.Now().Unix(),
  4754. Mtime: time.Now().Unix(),
  4755. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4756. IsUpload: 1,
  4757. OrderId: order_id,
  4758. }
  4759. service.CreateUploadRecord(hisFundSettleListResult)
  4760. c.ServeSuccessJSON(map[string]interface{}{
  4761. "msg": "上传成功",
  4762. "result": hisFundSettleListResult,
  4763. })
  4764. return
  4765. }
  4766. }
  4767. func (c *HisApiController) GetBatchSettleList() {
  4768. orders, _ := service.GetAllHisOrder(10106)
  4769. for _, item := range orders {
  4770. order_id := item.ID
  4771. order, _ := service.GetHisOrderByIDTwo(order_id)
  4772. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4773. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4774. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4775. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4776. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4778. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4779. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4780. if order.ID == 0 {
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4782. return
  4783. }
  4784. if his.BalanceAccountsType == 2 {
  4785. continue
  4786. }
  4787. struct4101 := service.Struct4101{
  4788. PsnNo: order.PsnNo,
  4789. MdtrtId: order.MdtrtId,
  4790. SetlId: order.SetlId,
  4791. PsnName: order.PsnName,
  4792. Gend: order.Gend,
  4793. Brdy: his.Brdy,
  4794. Age: his.Age,
  4795. Naty: order.Naty,
  4796. PatnCertType: "01",
  4797. Certno: order.Certno,
  4798. Prfs: "90",
  4799. ConerName: roles[0].UserName,
  4800. PatnRlts: "99",
  4801. ConerAddr: miConfig.OrgName,
  4802. ConerTel: admin.Mobile,
  4803. HiType: order.Insutype,
  4804. Insuplc: his.InsuplcAdmdvs,
  4805. MaindiagFlag: "1",
  4806. BillCode: order.SetlId,
  4807. BillNo: order.SetlId,
  4808. BizSn: order.Number,
  4809. PsnSelfPay: order.PsnPartAmt,
  4810. PsnOwnPay: order.PsnPartAmt,
  4811. AcctPay: order.AcctPay,
  4812. PsnCashpay: order.PsnCashPay,
  4813. HiPaymtd: "1",
  4814. Hsorg: his.InsuplcAdmdvs,
  4815. HsorgOpter: his.InsuplcAdmdvs,
  4816. MedinsFillPsn: curRoles.UserName,
  4817. MedinsFillDept: depart.Name,
  4818. IptMedType: "2",
  4819. }
  4820. struct4101.SetlBegnDate = order.SetlTime
  4821. struct4101.SetlEndDate = order.SetlTime
  4822. //if order.SettleType == 1 {
  4823. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4824. // dateStr := t.Format("2006-01-02")
  4825. // struct4101.SetlBegnDate = dateStr
  4826. // struct4101.SetlEndDate = dateStr
  4827. //} else {
  4828. // t := time.Unix(int64(order.SettleStartTime), 0)
  4829. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4830. // dateStartStr := t.Format("2006-01-02")
  4831. // dateEndStr := t2.Format("2006-01-02")
  4832. // struct4101.SetlBegnDate = dateStartStr
  4833. // struct4101.SetlEndDate = dateEndStr
  4834. //}
  4835. var rf []CustomFundPay
  4836. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4837. var tempFunPays []service.CustomStruct
  4838. var tempFunPay610100 service.CustomStruct
  4839. for _, item := range rf {
  4840. if item.FundPayType == "610100" {
  4841. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4842. tempFunPay610100.FundPayType = item.FundPayType
  4843. } else {
  4844. var tempFunPay service.CustomStruct
  4845. tempFunPay.FundPayamt = item.FundPayamt
  4846. tempFunPay.FundPayType = item.FundPayType
  4847. tempFunPays = append(tempFunPays, tempFunPay)
  4848. }
  4849. }
  4850. tempFunPays = append(tempFunPays, tempFunPay610100)
  4851. struct4101.CustomStruct = tempFunPays
  4852. var tempDiaginfos []service.DiaginfoStructTwo
  4853. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4854. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4855. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4856. var config []*models.HisXtDiagnoseConfig
  4857. for _, item := range diagnosis_ids {
  4858. id, _ := strconv.ParseInt(item, 10, 64)
  4859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4860. config = append(config, &diagnosisConfig)
  4861. }
  4862. for index, item := range config {
  4863. if index == 0 {
  4864. var tempDiaginfo service.DiaginfoStructTwo
  4865. tempDiaginfo.DiagCode = item.CountryCode
  4866. tempDiaginfo.DiagName = item.CountryContentName
  4867. tempDiaginfo.DiagType = "1"
  4868. tempDiaginfo.MaindiagFlag = "1"
  4869. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4870. } else {
  4871. var tempDiaginfo service.DiaginfoStructTwo
  4872. tempDiaginfo.DiagCode = item.CountryCode
  4873. tempDiaginfo.DiagName = item.CountryContentName
  4874. tempDiaginfo.DiagType = "2"
  4875. tempDiaginfo.MaindiagFlag = "0"
  4876. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4877. }
  4878. }
  4879. struct4101.Diseinfo = tempDiaginfos
  4880. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4881. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4882. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4883. tempOpspdiseinfo2.OprnOprtCode = ""
  4884. tempOpspdiseinfo2.OprnOprtName = ""
  4885. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4886. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4887. var iteminfo service.IteminfoStruct
  4888. var bedCostTotal float64 = 0 //床位总费
  4889. var bedCostSelfTotal float64 = 0 //床位自费
  4890. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4891. var examineCostTotal float64 = 0 //诊查总费
  4892. var examineCostSelfTotal float64 = 0 //诊查自费
  4893. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4894. var nursingCostTotal float64 = 0 //护理总费
  4895. var nursingCostSelfTotal float64 = 0 //护理自费
  4896. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4897. var chineseMedicineCostTotal float64 = 0 //中成药
  4898. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4899. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4900. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4901. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4902. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4903. var registerCostTotal float64 = 0 //一般诊疗费
  4904. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4905. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4906. var operationCostTotal float64 = 0 //手术费
  4907. var operationCostSelfTotal float64 = 0 //手术费
  4908. var operationCostPartSelfTotal float64 = 0 //手术费
  4909. var otherCostTotal float64 = 0 //其他费用
  4910. var otherCostSelfTotal float64 = 0 //其他费用
  4911. var otherCostPartSelfTotal float64 = 0 //其他费用
  4912. var materialCostTotal float64 = 0 //材料费
  4913. var materialCostSelfTotal float64 = 0 //材料费
  4914. var materialCostPartSelfTotal float64 = 0 //材料费
  4915. var westernMedicineCostTotal float64 = 0 //西药费
  4916. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4917. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4918. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4919. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4920. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4921. var checkCostTotal float64 = 0 //检查费
  4922. var checkCostSelfTotal float64 = 0 //检查费
  4923. var checkCostPartSelfTotal float64 = 0 //检查费
  4924. var laboratoryCostTotal float64 = 0 //化验费
  4925. var laboratoryCostSelfTotal float64 = 0 //化验费
  4926. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4927. var treatCostTotal float64 = 0 //治疗费用
  4928. var treatCostSelfTotal float64 = 0 //治疗费用
  4929. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4930. decimal.DivisionPrecision = 2
  4931. var bed_fulamt_ownpay_amt float64 = 0
  4932. var examine_fulamt_ownpay_amt float64 = 0
  4933. var nursing_fulamt_ownpay_amt float64 = 0
  4934. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4935. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4936. var register_fulamt_ownpay_amt float64 = 0
  4937. var operation_fulamt_ownpay_amt float64 = 0
  4938. var other_fulamt_ownpay_amt float64 = 0
  4939. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4940. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4941. var check_fulamt_ownpay_amt float64 = 0
  4942. var material_fulamt_ownpay_amt float64 = 0
  4943. var laboratory_fulamt_ownpay_amt float64 = 0
  4944. var treat_fulamt_ownpay_amt float64 = 0
  4945. var bed_claa_sunmfee float64 = 0
  4946. var bed_clab_amt float64 = 0
  4947. var bed_other_amt float64 = 0
  4948. var examine_claa_sunmfee float64 = 0
  4949. var examine_clab_amt float64 = 0
  4950. var examine_other_amt float64 = 0
  4951. var nursing_claa_sunmfee float64 = 0
  4952. var nursing_clab_amt float64 = 0
  4953. var nursing_other_amt float64 = 0
  4954. var chinese_medicine_claa_sunmfee float64 = 0
  4955. var chinese_medicine_clab_amt float64 = 0
  4956. var chinese_medicine_other_amt float64 = 0
  4957. var commonly_treatment_claa_sunmfee float64 = 0
  4958. var commonly_treatment_clab_amt float64 = 0
  4959. var commonly_treatment_other_amt float64 = 0
  4960. var operation_claa_sunmfee float64 = 0
  4961. var operation_clab_amt float64 = 0
  4962. var operation_other_amt float64 = 0
  4963. var other_claa_sunmfee float64 = 0
  4964. var other_clab_amt float64 = 0
  4965. var other_other_amt float64 = 0
  4966. var westernMedicine_claa_sunmfee float64 = 0
  4967. var westernMedicine_clab_amt float64 = 0
  4968. var westernMedicine_other_amt float64 = 0
  4969. var chineseTraditional_claa_sunmfee float64 = 0
  4970. var chineseTraditional_clab_amt float64 = 0
  4971. var chineseTraditional_other_amt float64 = 0
  4972. var check_claa_sunmfee float64 = 0
  4973. var check_clab_amt float64 = 0
  4974. var check_other_amt float64 = 0
  4975. var material_claa_sunmfee float64 = 0
  4976. var material_clab_amt float64 = 0
  4977. var material_other_amt float64 = 0
  4978. var laboratory_claa_sunmfee float64 = 0
  4979. var laboratory_clab_amt float64 = 0
  4980. var laboratory_other_amt float64 = 0
  4981. var treat_claa_sunmfee float64 = 0
  4982. var treat_clab_amt float64 = 0
  4983. var treat_other_amt float64 = 0
  4984. var register_claa_sunmfee float64 = 0
  4985. var register_clab_amt float64 = 0
  4986. var register_other_amt float64 = 0
  4987. for _, item := range order.HisOrderInfo {
  4988. if item.MedChrgitmType == "01" { //床位费
  4989. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4990. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4991. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4992. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4993. if item.ChrgitmLv == "1" {
  4994. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4995. }
  4996. if item.ChrgitmLv == "2" {
  4997. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4998. }
  4999. if item.ChrgitmLv == "3" {
  5000. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5001. }
  5002. }
  5003. if item.MedChrgitmType == "02" { //诊查
  5004. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5005. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5006. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5007. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5008. if item.ChrgitmLv == "1" {
  5009. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5010. }
  5011. if item.ChrgitmLv == "2" {
  5012. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5013. }
  5014. if item.ChrgitmLv == "3" {
  5015. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5016. }
  5017. }
  5018. if item.MedChrgitmType == "03" { //检查费
  5019. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5020. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5021. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5022. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5023. if item.ChrgitmLv == "1" {
  5024. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5025. }
  5026. if item.ChrgitmLv == "2" {
  5027. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5028. }
  5029. if item.ChrgitmLv == "3" {
  5030. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5031. }
  5032. }
  5033. if item.MedChrgitmType == "04" { //化验费
  5034. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5035. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5036. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5037. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5038. if item.ChrgitmLv == "1" {
  5039. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5040. }
  5041. if item.ChrgitmLv == "2" {
  5042. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5043. }
  5044. if item.ChrgitmLv == "3" {
  5045. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5046. }
  5047. }
  5048. if item.MedChrgitmType == "05" { //治疗费
  5049. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5050. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5051. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5052. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5053. if item.ChrgitmLv == "1" {
  5054. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5055. }
  5056. if item.ChrgitmLv == "2" {
  5057. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5058. }
  5059. if item.ChrgitmLv == "3" {
  5060. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5061. }
  5062. }
  5063. if item.MedChrgitmType == "06" { //手术费
  5064. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5065. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5066. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5067. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5068. if item.ChrgitmLv == "1" {
  5069. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5070. }
  5071. if item.ChrgitmLv == "2" {
  5072. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5073. }
  5074. if item.ChrgitmLv == "3" {
  5075. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5076. }
  5077. }
  5078. if item.MedChrgitmType == "07" { //手术费
  5079. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5080. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5081. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5082. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5083. if item.ChrgitmLv == "1" {
  5084. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5085. }
  5086. if item.ChrgitmLv == "2" {
  5087. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5088. }
  5089. if item.ChrgitmLv == "3" {
  5090. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5091. }
  5092. }
  5093. if item.MedChrgitmType == "08" { //材料费
  5094. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5095. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5096. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5097. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5098. if item.ChrgitmLv == "1" {
  5099. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5100. }
  5101. if item.ChrgitmLv == "2" {
  5102. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5103. }
  5104. if item.ChrgitmLv == "3" {
  5105. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5106. }
  5107. }
  5108. if item.MedChrgitmType == "09" { //西药费
  5109. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5110. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5111. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5112. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5113. if item.ChrgitmLv == "1" {
  5114. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5115. }
  5116. if item.ChrgitmLv == "2" {
  5117. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5118. }
  5119. if item.ChrgitmLv == "3" {
  5120. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5121. }
  5122. }
  5123. if item.MedChrgitmType == "10" { //中药饮片
  5124. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5125. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5126. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5127. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5128. if item.ChrgitmLv == "1" {
  5129. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5130. }
  5131. if item.ChrgitmLv == "2" {
  5132. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5133. }
  5134. if item.ChrgitmLv == "3" {
  5135. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5136. }
  5137. }
  5138. if item.MedChrgitmType == "11" { //中成费
  5139. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5140. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5141. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5142. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5143. if item.ChrgitmLv == "1" {
  5144. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5145. }
  5146. if item.ChrgitmLv == "2" {
  5147. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5148. }
  5149. if item.ChrgitmLv == "3" {
  5150. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5151. }
  5152. }
  5153. if item.MedChrgitmType == "12" { //中成费
  5154. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5155. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5156. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5157. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5158. if item.ChrgitmLv == "1" {
  5159. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5160. }
  5161. if item.ChrgitmLv == "2" {
  5162. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5163. }
  5164. if item.ChrgitmLv == "3" {
  5165. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5166. }
  5167. }
  5168. if item.MedChrgitmType == "13" { //中成费
  5169. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5170. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5171. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5172. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5173. if item.ChrgitmLv == "1" {
  5174. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5175. }
  5176. if item.ChrgitmLv == "2" {
  5177. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5178. }
  5179. if item.ChrgitmLv == "3" {
  5180. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5181. }
  5182. }
  5183. if item.MedChrgitmType == "14" { //其他费
  5184. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5185. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5186. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5187. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5188. if item.ChrgitmLv == "1" {
  5189. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5190. }
  5191. if item.ChrgitmLv == "2" {
  5192. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5193. }
  5194. if item.ChrgitmLv == "3" {
  5195. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5196. }
  5197. }
  5198. }
  5199. var iteminfoStructs []service.IteminfoStruct
  5200. if bedCostTotal != 0 {
  5201. iteminfo.MedChrgitm = "01"
  5202. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5203. iteminfo.Amt = bedCostTotal
  5204. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5205. iteminfo.ClabAmt = bed_clab_amt
  5206. iteminfo.OthAmt = bed_other_amt
  5207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5208. }
  5209. if examineCostTotal != 0 {
  5210. iteminfo.MedChrgitm = "02"
  5211. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5212. iteminfo.Amt = examineCostTotal
  5213. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5214. iteminfo.ClabAmt = examine_clab_amt
  5215. iteminfo.OthAmt = examine_other_amt
  5216. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5218. }
  5219. if checkCostTotal != 0 {
  5220. iteminfo.MedChrgitm = "03"
  5221. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5222. iteminfo.Amt = checkCostTotal
  5223. iteminfo.ClaaSumfee = check_claa_sunmfee
  5224. iteminfo.ClabAmt = check_clab_amt
  5225. iteminfo.OthAmt = check_other_amt
  5226. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5227. }
  5228. if laboratoryCostTotal != 0 {
  5229. iteminfo.MedChrgitm = "04"
  5230. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5231. iteminfo.Amt = laboratoryCostTotal
  5232. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5233. iteminfo.ClabAmt = laboratory_clab_amt
  5234. iteminfo.OthAmt = laboratory_other_amt
  5235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5237. }
  5238. if treatCostTotal != 0 {
  5239. iteminfo.MedChrgitm = "05"
  5240. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5241. iteminfo.Amt = treatCostTotal
  5242. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5243. iteminfo.ClabAmt = treat_clab_amt
  5244. iteminfo.OthAmt = treat_other_amt
  5245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5246. //(struct4101.IteminfoStruct, iteminfo)
  5247. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5248. }
  5249. if operationCostTotal != 0 {
  5250. iteminfo.MedChrgitm = "06"
  5251. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5252. iteminfo.Amt = operationCostTotal
  5253. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5254. iteminfo.ClabAmt = operation_clab_amt
  5255. iteminfo.OthAmt = operation_other_amt
  5256. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5257. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5258. }
  5259. if nursingCostTotal != 0 {
  5260. iteminfo.MedChrgitm = "07"
  5261. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5262. iteminfo.Amt = nursingCostTotal
  5263. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5264. iteminfo.ClabAmt = nursing_clab_amt
  5265. iteminfo.OthAmt = nursing_other_amt
  5266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5267. }
  5268. if materialCostTotal != 0 {
  5269. iteminfo.MedChrgitm = "08"
  5270. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5271. iteminfo.Amt = materialCostTotal
  5272. iteminfo.ClaaSumfee = material_claa_sunmfee
  5273. iteminfo.ClabAmt = material_clab_amt
  5274. iteminfo.OthAmt = material_other_amt
  5275. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5276. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5277. }
  5278. if westernMedicineCostTotal != 0 {
  5279. iteminfo.MedChrgitm = "09"
  5280. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5281. iteminfo.Amt = westernMedicineCostTotal
  5282. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5283. iteminfo.ClabAmt = westernMedicine_clab_amt
  5284. iteminfo.OthAmt = westernMedicine_other_amt
  5285. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5286. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5287. }
  5288. if chineseMedicineCostTotal != 0 {
  5289. iteminfo.MedChrgitm = "10"
  5290. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5291. iteminfo.Amt = chineseMedicineCostTotal
  5292. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5293. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5294. iteminfo.OthAmt = chinese_medicine_other_amt
  5295. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5296. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5297. }
  5298. if chineseTraditionalMedicineCostTotal != 0 {
  5299. iteminfo.MedChrgitm = "11"
  5300. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5301. iteminfo.Amt = westernMedicineCostTotal
  5302. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5303. iteminfo.ClabAmt = westernMedicine_clab_amt
  5304. iteminfo.OthAmt = westernMedicine_other_amt
  5305. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5307. }
  5308. if commonlyTreatmentCostTotal != 0 {
  5309. iteminfo.MedChrgitm = "12"
  5310. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5311. iteminfo.Amt = commonlyTreatmentCostTotal
  5312. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5313. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5314. iteminfo.OthAmt = commonly_treatment_other_amt
  5315. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5316. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5317. }
  5318. if registerCostTotal != 0 {
  5319. iteminfo.MedChrgitm = "13"
  5320. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5321. iteminfo.Amt = registerCostTotal
  5322. iteminfo.ClaaSumfee = register_claa_sunmfee
  5323. iteminfo.ClabAmt = register_clab_amt
  5324. iteminfo.OthAmt = register_other_amt
  5325. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5326. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5327. }
  5328. if otherCostTotal != 0 {
  5329. iteminfo.MedChrgitm = "14"
  5330. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5331. iteminfo.Amt = otherCostTotal
  5332. iteminfo.ClaaSumfee = other_claa_sunmfee
  5333. iteminfo.ClabAmt = other_clab_amt
  5334. iteminfo.OthAmt = other_other_amt
  5335. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5336. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5337. }
  5338. struct4101.IteminfoStruct = iteminfoStructs
  5339. time_arr := strings.Split(order.SetlTime, " ")
  5340. struct4101.AdmTime = time_arr[0]
  5341. struct4101.AdmEndTime = time_arr[0]
  5342. struct4101.DoctorName = doctor.UserName
  5343. struct4101.DoctorCode = doctor.DoctorNumber
  5344. struct4101.Ntly = "中国"
  5345. struct4101.AdmCaty = "A03.06"
  5346. var res ResultSeventeen
  5347. if miConfig.MdtrtareaAdmvs == "421300" {
  5348. data := make(map[string]interface{})
  5349. data["struct4101"] = struct4101
  5350. data["secret_key"] = miConfig.SecretKey
  5351. data["org_name"] = miConfig.OrgName
  5352. data["opera"] = curRoles.UserName
  5353. data["code"] = miConfig.Code
  5354. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5355. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5356. client := &http.Client{}
  5357. bytesData, _ := json.Marshal(data)
  5358. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5359. resp, _ := client.Do(req)
  5360. defer resp.Body.Close()
  5361. body, ioErr := ioutil.ReadAll(resp.Body)
  5362. if ioErr != nil {
  5363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5365. return
  5366. }
  5367. var respJSON map[string]interface{}
  5368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5374. userJSONBytes, _ := json.Marshal(respJSON)
  5375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5376. utils.ErrorLog("解析失败:%v", err)
  5377. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5378. adminUser := c.GetAdminUserInfo()
  5379. errlog := &models.HisOrderError{
  5380. UserOrgId: adminUser.CurrentOrgId,
  5381. Ctime: time.Now().Unix(),
  5382. Mtime: time.Now().Unix(),
  5383. ErrMsg: res.ErrMsg + "解析失败",
  5384. Status: 1,
  5385. PatientId: order_id,
  5386. Stage: 10088,
  5387. }
  5388. service.CreateErrMsgLog(errlog)
  5389. continue
  5390. }
  5391. } else {
  5392. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5393. fmt.Println(result)
  5394. var dat map[string]interface{}
  5395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5396. fmt.Println(dat)
  5397. } else {
  5398. fmt.Println(err)
  5399. }
  5400. userJSONBytes, _ := json.Marshal(dat)
  5401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5402. utils.ErrorLog("解析失败:%v", err)
  5403. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5404. adminUser := c.GetAdminUserInfo()
  5405. errlog := &models.HisOrderError{
  5406. UserOrgId: adminUser.CurrentOrgId,
  5407. Ctime: time.Now().Unix(),
  5408. Mtime: time.Now().Unix(),
  5409. ErrMsg: res.ErrMsg + "解析失败",
  5410. Status: 1,
  5411. PatientId: order_id,
  5412. Stage: 10106,
  5413. }
  5414. service.CreateErrMsgLog(errlog)
  5415. continue
  5416. }
  5417. }
  5418. if res.Infcode != 0 {
  5419. adminUser := c.GetAdminUserInfo()
  5420. errlog := &models.HisOrderError{
  5421. UserOrgId: adminUser.CurrentOrgId,
  5422. Ctime: time.Now().Unix(),
  5423. Mtime: time.Now().Unix(),
  5424. ErrMsg: res.ErrMsg,
  5425. Status: 1,
  5426. PatientId: order_id,
  5427. Stage: 10106,
  5428. }
  5429. service.CreateErrMsgLog(errlog)
  5430. continue
  5431. } else {
  5432. hisFundSettleListResult := &models.HisFundSettleListResult{
  5433. Number: res.Output.SetlListId,
  5434. Status: 1,
  5435. Ctime: time.Now().Unix(),
  5436. Mtime: time.Now().Unix(),
  5437. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5438. IsUpload: 1,
  5439. OrderId: order_id,
  5440. }
  5441. service.CreateUploadRecord(hisFundSettleListResult)
  5442. continue
  5443. }
  5444. }
  5445. }
  5446. func (c *HisApiController) GetOrgInfo() {
  5447. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5448. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5449. }
  5450. func (c *HisApiController) GetHisPatientInfo() {
  5451. medical_insurance_card := c.GetString("medical_insurance_card")
  5452. id_card_type, _ := c.GetInt64("id_card_type")
  5453. id_card := c.GetString("id_card")
  5454. adminInfo := c.GetAdminUserInfo()
  5455. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5456. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5457. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5458. IdCardNo := ""
  5459. if id_card_type == 1 {
  5460. IdCardNo = medical_insurance_card
  5461. } else if id_card_type == 2 {
  5462. IdCardNo = id_card
  5463. }
  5464. if config.IsOpen == 1 {
  5465. 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
  5466. resp, requestErr := http.Get(api)
  5467. if requestErr != nil {
  5468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5469. return
  5470. }
  5471. defer resp.Body.Close()
  5472. body, ioErr := ioutil.ReadAll(resp.Body)
  5473. if ioErr != nil {
  5474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5476. return
  5477. }
  5478. var respJSON map[string]interface{}
  5479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5482. return
  5483. }
  5484. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5485. userJSONBytes, _ := json.Marshal(userJSON)
  5486. var res ResultTwo
  5487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5488. utils.ErrorLog("解析失败:%v", err)
  5489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5490. return
  5491. }
  5492. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5493. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5494. infoStr := string(Iinfos)
  5495. idetinfoStr := string(Idetinfos)
  5496. if res.Infcode == 0 {
  5497. his := models.VMHisPatient{
  5498. Status: 1,
  5499. Ctime: time.Now().Unix(),
  5500. Mtime: time.Now().Unix(),
  5501. PsnNo: res.Output.Baseinfo.PsnNo,
  5502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5503. Certno: res.Output.Baseinfo.Certno,
  5504. PsnName: res.Output.Baseinfo.PsnName,
  5505. Gend: res.Output.Baseinfo.Gend,
  5506. Naty: res.Output.Baseinfo.Naty,
  5507. Brdy: res.Output.Baseinfo.Brdy,
  5508. Age: res.Output.Baseinfo.Age,
  5509. Iinfo: infoStr,
  5510. Idetinfo: idetinfoStr,
  5511. UserOrgId: adminInfo.CurrentOrgId,
  5512. IsReturn: 1,
  5513. IdCardType: id_card_type,
  5514. }
  5515. c.ServeSuccessJSON(map[string]interface{}{
  5516. "info": his,
  5517. })
  5518. } else {
  5519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5520. return
  5521. }
  5522. }
  5523. }
  5524. //func GetBasBaseInfo() (jsonStr string, err error) {
  5525. //
  5526. // handle := syscall.NewLazyDLL("SSCard.dll")
  5527. // add := handle.NewProc("ReadCardBas")
  5528. // str := make([]byte, 1024)
  5529. // str1 := make([]byte, 1024)
  5530. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5531. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5532. //
  5533. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5534. //
  5535. // fmt.Println("> Add(4,5)的结果为:", ret)
  5536. // handle.Release()
  5537. //
  5538. // return "", nil
  5539. //
  5540. //}
  5541. //func GetQRBaseInfo() (jsonStr string, err error) {
  5542. // handle := syscall.LoadDLL("SSCard.dll")
  5543. // ReadCardBas := handle.FindProc("GetQRBase")
  5544. //
  5545. // str := make([]byte, 256)
  5546. // str1 := make([]byte, 256)
  5547. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5548. //
  5549. // fmt.Println(string(str))
  5550. // fmt.Println(r)
  5551. // return string(str), nil
  5552. //}
  5553. //func CardInit() int {
  5554. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5555. // add := DllTestDef.MustFindProc("Init")
  5556. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5557. // if err != nil {
  5558. // fmt.Println("SSCard的运算结果为:", ret)
  5559. // }
  5560. // result := int(ret)
  5561. // return result
  5562. //}
  5563. //func CardInit() int {
  5564. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5565. // if err != nil {
  5566. // fmt.Println("SSCard的运算结果为:", ret)
  5567. // }
  5568. // fmt.Println(err)
  5569. // result := int(ret)
  5570. // return result
  5571. //}
  5572. func IntPtr(n int) uintptr {
  5573. return uintptr(n)
  5574. }
  5575. func StrPtr(s string) uintptr {
  5576. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5577. }
  5578. type Result2001 struct {
  5579. Cainfo interface{} `json:"cainfo"`
  5580. ErrMsg string `json:"err_msg"`
  5581. InfRefmsgid string `json:"inf_refmsgid"`
  5582. Infcode int64 `json:"infcode"`
  5583. Output struct {
  5584. Trtinfo struct {
  5585. PsnNo string `json:"psn_no"`
  5586. TrtChkType string `json:"trt_chk_type"`
  5587. FundPayType string `json:"fund_pay_type"`
  5588. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5589. Begndate string `json:"begndate"`
  5590. Enddate string `json:"enddate"`
  5591. TrtChkRslt string `json:"trt_chk_rslt"`
  5592. } `json:"trtinfo"`
  5593. } `json:"output"`
  5594. RefmsgTime string `json:"refmsg_time"`
  5595. RespondTime string `json:"respond_time"`
  5596. Signtype interface{} `json:"signtype"`
  5597. WarnMsg interface{} `json:"warn_msg"`
  5598. }
  5599. type Result2001Org10265 struct {
  5600. Cainfo interface{} `json:"cainfo"`
  5601. ErrMsg string `json:"err_msg"`
  5602. InfRefmsgid string `json:"inf_refmsgid"`
  5603. Infcode string `json:"infcode"`
  5604. Output struct {
  5605. Trtinfo struct {
  5606. PsnNo string `json:"psn_no"`
  5607. TrtChkType string `json:"trt_chk_type"`
  5608. FundPayType string `json:"fund_pay_type"`
  5609. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5610. Begndate string `json:"begndate"`
  5611. Enddate string `json:"enddate"`
  5612. TrtChkRslt string `json:"trt_chk_rslt"`
  5613. } `json:"trtinfo"`
  5614. } `json:"output"`
  5615. RefmsgTime string `json:"refmsg_time"`
  5616. RespondTime string `json:"respond_time"`
  5617. Signtype interface{} `json:"signtype"`
  5618. WarnMsg interface{} `json:"warn_msg"`
  5619. }
  5620. type ResultTwo struct {
  5621. ErrMsg string `json:"err_msg"`
  5622. InfRefmsgid string `json:"inf_refmsgid"`
  5623. Infcode int64 `json:"infcode"`
  5624. Output struct {
  5625. Baseinfo struct {
  5626. Age float64 `json:"age"`
  5627. Brdy string `json:"brdy"`
  5628. Certno string `json:"certno"`
  5629. Gend string `json:"gend"`
  5630. Naty string `json:"naty"`
  5631. PsnCertType string `json:"psn_cert_type"`
  5632. PsnName string `json:"psn_name"`
  5633. PsnNo string `json:"psn_no"`
  5634. } `json:"baseinfo"`
  5635. Idetinfo []interface{} `json:"idetinfo"`
  5636. Iinfo []struct {
  5637. Balc float64 `json:"balc"`
  5638. CvlservFlag string `json:"cvlserv_flag"`
  5639. EmpName string `json:"emp_name"`
  5640. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5641. Insutype string `json:"insutype"`
  5642. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5643. PausInsuDate string `json:"paus_insu_date"`
  5644. PsnInsuDate string `json:"psn_insu_date"`
  5645. PsnInsuStas string `json:"psn_insu_stas"`
  5646. PsnType string `json:"psn_type"`
  5647. } `json:"insuinfo"`
  5648. } `json:"output"`
  5649. RefmsgTime string `json:"refmsg_time"`
  5650. RespondTime string `json:"respond_time"`
  5651. Signtype interface{} `json:"signtype"`
  5652. WarnInfo interface{} `json:"warn_info"`
  5653. }
  5654. type ResultTwo10265 struct {
  5655. ErrMsg string `json:"err_msg"`
  5656. InfRefmsgid string `json:"inf_refmsgid"`
  5657. Infcode string `json:"infcode"`
  5658. Output struct {
  5659. Baseinfo struct {
  5660. Age float64 `json:"age"`
  5661. Brdy string `json:"brdy"`
  5662. Certno string `json:"certno"`
  5663. Gend string `json:"gend"`
  5664. Naty string `json:"naty"`
  5665. PsnCertType string `json:"psn_cert_type"`
  5666. PsnName string `json:"psn_name"`
  5667. PsnNo string `json:"psn_no"`
  5668. } `json:"baseinfo"`
  5669. Idetinfo []interface{} `json:"idetinfo"`
  5670. Iinfo []struct {
  5671. Balc float64 `json:"balc"`
  5672. CvlservFlag string `json:"cvlserv_flag"`
  5673. EmpName string `json:"emp_name"`
  5674. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5675. Insutype string `json:"insutype"`
  5676. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5677. PausInsuDate string `json:"paus_insu_date"`
  5678. PsnInsuDate string `json:"psn_insu_date"`
  5679. PsnInsuStas string `json:"psn_insu_stas"`
  5680. PsnType string `json:"psn_type"`
  5681. } `json:"insuinfo"`
  5682. } `json:"output"`
  5683. RefmsgTime string `json:"refmsg_time"`
  5684. RespondTime string `json:"respond_time"`
  5685. Signtype interface{} `json:"signtype"`
  5686. WarnInfo interface{} `json:"warn_info"`
  5687. }
  5688. type ResultThree struct {
  5689. Cainfo interface{} `json:"cainfo"`
  5690. ErrMsg string `json:"err_msg"`
  5691. InfRefmsgid string `json:"inf_refmsgid"`
  5692. Infcode int64 `json:"infcode"`
  5693. Output struct {
  5694. Data struct {
  5695. IptOtpNo string `json:"ipt_otp_no"`
  5696. MdtrtID string `json:"mdtrt_id"`
  5697. PsnNo string `json:"psn_no"`
  5698. } `json:"data"`
  5699. } `json:"output"`
  5700. RefmsgTime string `json:"refmsg_time"`
  5701. RespondTime string `json:"respond_time"`
  5702. Signtype interface{} `json:"signtype"`
  5703. WarnMsg interface{} `json:"warn_msg"`
  5704. }
  5705. type ResultThree10265 struct {
  5706. Cainfo interface{} `json:"cainfo"`
  5707. ErrMsg string `json:"err_msg"`
  5708. InfRefmsgid string `json:"inf_refmsgid"`
  5709. Infcode string `json:"infcode"`
  5710. Output struct {
  5711. Data struct {
  5712. IptOtpNo string `json:"ipt_otp_no"`
  5713. MdtrtID string `json:"mdtrt_id"`
  5714. PsnNo string `json:"psn_no"`
  5715. } `json:"data"`
  5716. } `json:"output"`
  5717. RefmsgTime string `json:"refmsg_time"`
  5718. RespondTime string `json:"respond_time"`
  5719. Signtype interface{} `json:"signtype"`
  5720. WarnMsg interface{} `json:"warn_msg"`
  5721. }
  5722. type ResultFour struct {
  5723. Cainfo string `json:"cainfo"`
  5724. ErrMsg string `json:"err_msg"`
  5725. InfRefmsgid string `json:"inf_refmsgid"`
  5726. Infcode int64 `json:"infcode"`
  5727. Output struct {
  5728. Result []struct {
  5729. BasMednFlag string `json:"bas_medn_flag"`
  5730. ChldMedcFlag string `json:"chld_medc_flag"`
  5731. ChrgitmLv string `json:"chrgitm_lv"`
  5732. Cnt float64 `json:"cnt"`
  5733. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5734. DrtReimFlag string `json:"drt_reim_flag"`
  5735. FeedetlSn string `json:"feedetl_sn"`
  5736. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5737. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5738. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5739. ListSpItemFlag string `json:"list_sp_item_flag"`
  5740. LmtUsedFlag string `json:"lmt_used_flag"`
  5741. MedChrgitmType string `json:"med_chrgitm_type"`
  5742. Memo string `json:"memo"`
  5743. OverlmtAmt float64 `json:"overlmt_amt"`
  5744. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5745. Pric float64 `json:"pric"`
  5746. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5747. SelfpayProp float64 `json:"selfpay_prop"`
  5748. } `json:"result"`
  5749. } `json:"output"`
  5750. RefmsgTime string `json:"refmsg_time"`
  5751. RespondTime string `json:"respond_time"`
  5752. Signtype string `json:"signtype"`
  5753. WarnMsg string `json:"warn_msg"`
  5754. }
  5755. type ResultFour10265 struct {
  5756. Cainfo string `json:"cainfo"`
  5757. ErrMsg string `json:"err_msg"`
  5758. InfRefmsgid string `json:"inf_refmsgid"`
  5759. Infcode string `json:"infcode"`
  5760. Output struct {
  5761. Result []struct {
  5762. BasMednFlag string `json:"bas_medn_flag"`
  5763. ChldMedcFlag string `json:"chld_medc_flag"`
  5764. ChrgitmLv string `json:"chrgitm_lv"`
  5765. Cnt float64 `json:"cnt"`
  5766. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5767. DrtReimFlag string `json:"drt_reim_flag"`
  5768. FeedetlSn string `json:"feedetl_sn"`
  5769. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5770. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5771. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5772. ListSpItemFlag string `json:"list_sp_item_flag"`
  5773. LmtUsedFlag string `json:"lmt_used_flag"`
  5774. MedChrgitmType string `json:"med_chrgitm_type"`
  5775. Memo string `json:"memo"`
  5776. OverlmtAmt float64 `json:"overlmt_amt"`
  5777. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5778. Pric float64 `json:"pric"`
  5779. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5780. SelfpayProp float64 `json:"selfpay_prop"`
  5781. } `json:"result"`
  5782. } `json:"output"`
  5783. RefmsgTime string `json:"refmsg_time"`
  5784. RespondTime string `json:"respond_time"`
  5785. Signtype string `json:"signtype"`
  5786. WarnMsg string `json:"warn_msg"`
  5787. }
  5788. type ResultMemo struct {
  5789. InsuAdmdvs string `json:"insuAdmdvs"`
  5790. }
  5791. //[{"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}]
  5792. type ResultIDInfo struct {
  5793. Begntime string `json:"begntime"`
  5794. Endtime string `json:"endtime"`
  5795. Memo string `json:"memo"`
  5796. }
  5797. type ResultFive struct {
  5798. Balc float64 `json:"balc"`
  5799. CvlservFlag string `json:"cvlserv_flag"`
  5800. EmpName string `json:"emp_name"`
  5801. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5802. Insutype string `json:"insutype"`
  5803. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5804. PausInsuDate string `json:"paus_insu_date"`
  5805. PsnInsuDate string `json:"psn_insu_date"`
  5806. PsnInsuStas string `json:"psn_insu_stas"`
  5807. PsnType string `json:"psn_type"`
  5808. }
  5809. type ResultSix struct {
  5810. Cainfo interface{} `json:"cainfo"`
  5811. ErrMsg string `json:"err_msg"`
  5812. InfRefmsgid string `json:"inf_refmsgid"`
  5813. Infcode int64 `json:"infcode"`
  5814. Output struct {
  5815. } `json:"output"`
  5816. RefmsgTime string `json:"refmsg_time"`
  5817. RespondTime string `json:"respond_time"`
  5818. Signtype interface{} `json:"signtype"`
  5819. WarnMsg interface{} `json:"warn_msg"`
  5820. }
  5821. type ResultSix10265 struct {
  5822. Cainfo interface{} `json:"cainfo"`
  5823. ErrMsg string `json:"err_msg"`
  5824. InfRefmsgid string `json:"inf_refmsgid"`
  5825. Infcode string `json:"infcode"`
  5826. Output struct {
  5827. } `json:"output"`
  5828. RefmsgTime string `json:"refmsg_time"`
  5829. RespondTime string `json:"respond_time"`
  5830. Signtype interface{} `json:"signtype"`
  5831. WarnMsg interface{} `json:"warn_msg"`
  5832. }
  5833. type ResultSeven struct {
  5834. Cainfo string `json:"cainfo"`
  5835. ErrMsg string `json:"err_msg"`
  5836. InfRefmsgid string `json:"inf_refmsgid"`
  5837. Infcode int64 `json:"infcode"`
  5838. Output struct {
  5839. Setldetail []interface{} `json:"setldetail"`
  5840. Setlinfo struct {
  5841. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5842. AcctPay float64 `json:"acct_pay"`
  5843. ActPayDedc float64 `json:"act_pay_dedc"`
  5844. Age float64 `json:"age"`
  5845. Balc float64 `json:"balc"`
  5846. Brdy string `json:"brdy"`
  5847. Certno string `json:"certno"`
  5848. ClrOptins string `json:"clr_optins"`
  5849. ClrType string `json:"clr_type"`
  5850. ClrWay string `json:"clr_way"`
  5851. CvlservFlag string `json:"cvlserv_flag"`
  5852. CvlservPay float64 `json:"cvlserv_pay"`
  5853. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5854. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5855. Gend string `json:"gend"`
  5856. HifesPay float64 `json:"hifes_pay"`
  5857. HifmiPay float64 `json:"hifmi_pay"`
  5858. HifpPay float64 `json:"hifp_pay"`
  5859. HospPartAmt float64 `json:"hosp_part_amt"`
  5860. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5861. Insutype string `json:"insutype"`
  5862. MafPay float64 `json:"maf_pay"`
  5863. MdtrtCertType string `json:"mdtrt_cert_type"`
  5864. HifobPay float64 `json:"hifob_pay"`
  5865. MdtrtID string `json:"mdtrt_id"`
  5866. MedType string `json:"med_type"`
  5867. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5868. MedinsSetlID string `json:"medins_setl_id"`
  5869. Naty string `json:"naty"`
  5870. OthPay float64 `json:"oth_pay"`
  5871. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5872. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5873. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5874. PsnCashPay float64 `json:"psn_cash_pay"`
  5875. PsnCertType string `json:"psn_cert_type"`
  5876. PsnName string `json:"psn_name"`
  5877. PsnNo string `json:"psn_no"`
  5878. PsnPartAmt float64 `json:"psn_part_amt"`
  5879. PsnType string `json:"psn_type"`
  5880. SetlID string `json:"setl_id"`
  5881. SetlTime string `json:"setl_time"`
  5882. } `json:"setlinfo"`
  5883. } `json:"output"`
  5884. RefmsgTime string `json:"refmsg_time"`
  5885. RespondTime string `json:"respond_time"`
  5886. Signtype interface{} `json:"signtype"`
  5887. WarnMsg interface{} `json:"warn_msg"`
  5888. }
  5889. type ResultSeven10265 struct {
  5890. Cainfo string `json:"cainfo"`
  5891. ErrMsg string `json:"err_msg"`
  5892. InfRefmsgid string `json:"inf_refmsgid"`
  5893. Infcode string `json:"infcode"`
  5894. Output struct {
  5895. Setldetail []interface{} `json:"setldetail"`
  5896. Setlinfo struct {
  5897. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5898. AcctPay float64 `json:"acct_pay"`
  5899. ActPayDedc float64 `json:"act_pay_dedc"`
  5900. Age float64 `json:"age"`
  5901. Balc float64 `json:"balc"`
  5902. Brdy string `json:"brdy"`
  5903. Certno string `json:"certno"`
  5904. ClrOptins string `json:"clr_optins"`
  5905. ClrType string `json:"clr_type"`
  5906. ClrWay string `json:"clr_way"`
  5907. CvlservFlag string `json:"cvlserv_flag"`
  5908. CvlservPay float64 `json:"cvlserv_pay"`
  5909. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5910. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5911. Gend string `json:"gend"`
  5912. HifesPay float64 `json:"hifes_pay"`
  5913. HifmiPay float64 `json:"hifmi_pay"`
  5914. HifpPay float64 `json:"hifp_pay"`
  5915. HospPartAmt float64 `json:"hosp_part_amt"`
  5916. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5917. Insutype string `json:"insutype"`
  5918. MafPay float64 `json:"maf_pay"`
  5919. MdtrtCertType string `json:"mdtrt_cert_type"`
  5920. HifobPay float64 `json:"hifob_pay"`
  5921. MdtrtID string `json:"mdtrt_id"`
  5922. MedType string `json:"med_type"`
  5923. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5924. MedinsSetlID string `json:"medins_setl_id"`
  5925. Naty string `json:"naty"`
  5926. OthPay float64 `json:"oth_pay"`
  5927. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5928. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5929. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5930. PsnCashPay float64 `json:"psn_cash_pay"`
  5931. PsnCertType string `json:"psn_cert_type"`
  5932. PsnName string `json:"psn_name"`
  5933. PsnNo string `json:"psn_no"`
  5934. PsnPartAmt float64 `json:"psn_part_amt"`
  5935. PsnType string `json:"psn_type"`
  5936. SetlID string `json:"setl_id"`
  5937. SetlTime string `json:"setl_time"`
  5938. } `json:"setlinfo"`
  5939. } `json:"output"`
  5940. RefmsgTime string `json:"refmsg_time"`
  5941. RespondTime string `json:"respond_time"`
  5942. Signtype interface{} `json:"signtype"`
  5943. WarnMsg interface{} `json:"warn_msg"`
  5944. }
  5945. type ResultEight struct {
  5946. Cainfo string `json:"cainfo"`
  5947. ErrMsg string `json:"err_msg"`
  5948. InfRefmsgid string `json:"inf_refmsgid"`
  5949. Infcode int64 `json:"infcode"`
  5950. Output struct {
  5951. Stmtinfo struct {
  5952. SetlOptins string `json:"setl_optins"`
  5953. StmtRslt string `json:"stmt_rslt"`
  5954. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5955. } `json:"stmtinfo"`
  5956. } `json:"output"`
  5957. RefmsgTime string `json:"refmsg_time"`
  5958. RespondTime string `json:"respond_time"`
  5959. Signtype interface{} `json:"signtype"`
  5960. WarnMsg interface{} `json:"warn_msg"`
  5961. }
  5962. type ResultEightFor10188 struct {
  5963. Cainfo string `json:"cainfo"`
  5964. ErrMsg string `json:"err_msg"`
  5965. InfRefmsgid string `json:"inf_refmsgid"`
  5966. Infcode string `json:"infcode"`
  5967. Output struct {
  5968. Stmtinfo struct {
  5969. SetlOptins string `json:"setl_optins"`
  5970. StmtRslt string `json:"stmt_rslt"`
  5971. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5972. } `json:"stmtinfo"`
  5973. } `json:"output"`
  5974. RefmsgTime string `json:"refmsg_time"`
  5975. RespondTime string `json:"respond_time"`
  5976. Signtype interface{} `json:"signtype"`
  5977. WarnMsg interface{} `json:"warn_msg"`
  5978. }
  5979. type ResultNine struct {
  5980. Cainfo string `json:"cainfo"`
  5981. ErrMsg string `json:"err_msg"`
  5982. InfRefmsgid string `json:"inf_refmsgid"`
  5983. Infcode int64 `json:"infcode"`
  5984. Output struct {
  5985. FileQuryNo string `json:"file_qury_no"`
  5986. } `json:"output"`
  5987. RefmsgTime string `json:"refmsg_time"`
  5988. RespondTime string `json:"respond_time"`
  5989. Signtype interface{} `json:"signtype"`
  5990. WarnMsg interface{} `json:"warn_msg"`
  5991. }
  5992. type ResultTen struct {
  5993. Cainfo string `json:"cainfo"`
  5994. ErrMsg string `json:"err_msg"`
  5995. InfRefmsgid string `json:"inf_refmsgid"`
  5996. Infcode int64 `json:"infcode"`
  5997. Output struct {
  5998. DldEndtime string `json:"dld_endtime"`
  5999. FileQuryNo string `json:"file_qury_no"`
  6000. Filename string `json:"filename"`
  6001. } `json:"output"`
  6002. RefmsgTime string `json:"refmsg_time"`
  6003. RespondTime string `json:"respond_time"`
  6004. Signtype interface{} `json:"signtype"`
  6005. WarnMsg interface{} `json:"warn_msg"`
  6006. }
  6007. //type Autogenerated struct {
  6008. // Output struct {
  6009. // Setlinfo struct {
  6010. // SetlTime string `json:"setl_time"`
  6011. // CvlservPay float64 `json:"cvlserv_pay"`
  6012. // Year string `json:"year"`
  6013. // MedType string `json:"med_type"`
  6014. // PsnPay float64 `json:"psn_pay"`
  6015. // OpterID string `json:"opter_id"`
  6016. // Begndate string `json:"begndate"`
  6017. // FlxempeFlag string `json:"flxempe_flag"`
  6018. // HifmiPay float64 `json:"hifmi_pay"`
  6019. // PsnNo string `json:"psn_no"`
  6020. // ActPayDedc float64 `json:"act_pay_dedc"`
  6021. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6022. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6023. // ClrWay string `json:"clr_way"`
  6024. // OthPay float64 `json:"oth_pay"`
  6025. // Gend string `json:"gend"`
  6026. // MdtrtID string `json:"mdtrt_id"`
  6027. // AcctPay float64 `json:"acct_pay"`
  6028. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6029. // Insutype string `json:"insutype"`
  6030. // Invono interface{} `json:"invono"`
  6031. // Enddate string `json:"enddate"`
  6032. // CashPayamt float64 `json:"cash_payamt"`
  6033. // PsnType string `json:"psn_type"`
  6034. // FixmedinsName string `json:"fixmedins_name"`
  6035. // HifpPay float64 `json:"hifp_pay"`
  6036. // NewFlag interface{} `json:"new_flag"`
  6037. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6038. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6039. // PayLoc string `json:"pay_loc"`
  6040. // ClrType string `json:"clr_type"`
  6041. // RefdSetlFlag string `json:"refd_setl_flag"`
  6042. // CvlservFlag string `json:"cvlserv_flag"`
  6043. // EmpName string `json:"emp_name"`
  6044. // Brdy string `json:"brdy"`
  6045. // Naty string `json:"naty"`
  6046. // Certno string `json:"certno"`
  6047. // DiseCode string `json:"dise_code"`
  6048. // FixmedinsCode string `json:"fixmedins_code"`
  6049. // DedcHospLv string `json:"dedc_hosp_lv"`
  6050. // OpterName string `json:"opter_name"`
  6051. // Balc float64 `json:"balc"`
  6052. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6053. // PsnCertType string `json:"psn_cert_type"`
  6054. // HifobPay float64 `json:"hifob_pay"`
  6055. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6056. // HifesPay float64 `json:"hifes_pay"`
  6057. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6058. // OptTime string `json:"opt_time"`
  6059. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6060. // SetlID string `json:"setl_id"`
  6061. // MafPay float64 `json:"maf_pay"`
  6062. // PsnName string `json:"psn_name"`
  6063. // InsuOptins interface{} `json:"insu_optins"`
  6064. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6065. // ClrOptins string `json:"clr_optins"`
  6066. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6067. // DiseName string `json:"dise_name"`
  6068. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6069. // Age float64 `json:"age"`
  6070. // DtrtCertType string `json:"dtrt_cert_type"`
  6071. // HospLv string `json:"hosp_lv"`
  6072. // } `json:"setlinfo"`
  6073. // Setldetail []struct {
  6074. // FundPayType string `json:"fund_pay_type"`
  6075. // FundPayamt float64 `json:"fund_payamt"`
  6076. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6077. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6078. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6079. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6080. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6081. // } `json:"setldetail"`
  6082. // } `json:"output"`
  6083. // Infcode int `json:"infcode"`
  6084. // WarnMsg interface{} `json:"warn_msg"`
  6085. // Cainfo interface{} `json:"cainfo"`
  6086. // ErrMsg interface{} `json:"err_msg"`
  6087. // RefmsgTime string `json:"refmsg_time"`
  6088. // Signtype interface{} `json:"signtype"`
  6089. // RespondTime string `json:"respond_time"`
  6090. // InfRefmsgid string `json:"inf_refmsgid"`
  6091. //}
  6092. type ResultEleven struct {
  6093. Cainfo string `json:"cainfo"`
  6094. ErrMsg string `json:"err_msg"`
  6095. InfRefmsgid string `json:"inf_refmsgid"`
  6096. Infcode int64 `json:"infcode"`
  6097. Output struct {
  6098. Setlinfo struct {
  6099. SetlTime string `json:"setl_time"`
  6100. CvlservPay float64 `json:"cvlserv_pay"`
  6101. Year string `json:"year"`
  6102. MedType string `json:"med_type"`
  6103. PsnPay float64 `json:"psn_pay"`
  6104. OpterID string `json:"opter_id"`
  6105. Begndate string `json:"begndate"`
  6106. FlxempeFlag string `json:"flxempe_flag"`
  6107. HifmiPay float64 `json:"hifmi_pay"`
  6108. PsnNo string `json:"psn_no"`
  6109. ActPayDedc float64 `json:"act_pay_dedc"`
  6110. MedinsSetlID interface{} `json:"medins_setl_id"`
  6111. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6112. ClrWay string `json:"clr_way"`
  6113. OthPay float64 `json:"oth_pay"`
  6114. Gend string `json:"gend"`
  6115. MdtrtID string `json:"mdtrt_id"`
  6116. AcctPay float64 `json:"acct_pay"`
  6117. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6118. Insutype string `json:"insutype"`
  6119. Invono interface{} `json:"invono"`
  6120. Enddate string `json:"enddate"`
  6121. CashPayamt float64 `json:"cash_payamt"`
  6122. PsnType string `json:"psn_type"`
  6123. FixmedinsName string `json:"fixmedins_name"`
  6124. HifpPay float64 `json:"hifp_pay"`
  6125. NewFlag interface{} `json:"new_flag"`
  6126. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6127. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6128. PayLoc string `json:"pay_loc"`
  6129. ClrType string `json:"clr_type"`
  6130. RefdSetlFlag string `json:"refd_setl_flag"`
  6131. CvlservFlag string `json:"cvlserv_flag"`
  6132. EmpName string `json:"emp_name"`
  6133. Brdy string `json:"brdy"`
  6134. Naty string `json:"naty"`
  6135. Certno string `json:"certno"`
  6136. DiseCode string `json:"dise_code"`
  6137. FixmedinsCode string `json:"fixmedins_code"`
  6138. DedcHospLv string `json:"dedc_hosp_lv"`
  6139. OpterName string `json:"opter_name"`
  6140. Balc float64 `json:"balc"`
  6141. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6142. PsnCertType string `json:"psn_cert_type"`
  6143. HifobPay float64 `json:"hifob_pay"`
  6144. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6145. HifesPay float64 `json:"hifes_pay"`
  6146. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6147. OptTime string `json:"opt_time"`
  6148. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6149. SetlID string `json:"setl_id"`
  6150. MafPay float64 `json:"maf_pay"`
  6151. PsnName string `json:"psn_name"`
  6152. InsuOptins interface{} `json:"insu_optins"`
  6153. PrefFundPay interface{} `json:"pref_fund_pay"`
  6154. ClrOptins string `json:"clr_optins"`
  6155. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6156. DiseName string `json:"dise_name"`
  6157. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6158. Age float64 `json:"age"`
  6159. DtrtCertType string `json:"dtrt_cert_type"`
  6160. HospLv string `json:"hosp_lv"`
  6161. PsnCashPay float64
  6162. } `json:"setlinfo"`
  6163. } `json:"output"`
  6164. RefmsgTime string `json:"refmsg_time"`
  6165. RespondTime string `json:"respond_time"`
  6166. Signtype interface{} `json:"signtype"`
  6167. WarnMsg interface{} `json:"warn_msg"`
  6168. }
  6169. type ResultEleven10265 struct {
  6170. Cainfo string `json:"cainfo"`
  6171. ErrMsg string `json:"err_msg"`
  6172. InfRefmsgid string `json:"inf_refmsgid"`
  6173. Infcode string `json:"infcode"`
  6174. Output struct {
  6175. Setlinfo struct {
  6176. SetlTime string `json:"setl_time"`
  6177. CvlservPay float64 `json:"cvlserv_pay"`
  6178. Year string `json:"year"`
  6179. MedType string `json:"med_type"`
  6180. PsnPay float64 `json:"psn_pay"`
  6181. OpterID string `json:"opter_id"`
  6182. Begndate string `json:"begndate"`
  6183. FlxempeFlag string `json:"flxempe_flag"`
  6184. HifmiPay float64 `json:"hifmi_pay"`
  6185. PsnNo string `json:"psn_no"`
  6186. ActPayDedc float64 `json:"act_pay_dedc"`
  6187. MedinsSetlID interface{} `json:"medins_setl_id"`
  6188. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6189. ClrWay string `json:"clr_way"`
  6190. OthPay float64 `json:"oth_pay"`
  6191. Gend string `json:"gend"`
  6192. MdtrtID string `json:"mdtrt_id"`
  6193. AcctPay float64 `json:"acct_pay"`
  6194. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6195. Insutype string `json:"insutype"`
  6196. Invono interface{} `json:"invono"`
  6197. Enddate string `json:"enddate"`
  6198. CashPayamt float64 `json:"cash_payamt"`
  6199. PsnType string `json:"psn_type"`
  6200. FixmedinsName string `json:"fixmedins_name"`
  6201. HifpPay float64 `json:"hifp_pay"`
  6202. NewFlag interface{} `json:"new_flag"`
  6203. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6204. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6205. PayLoc string `json:"pay_loc"`
  6206. ClrType string `json:"clr_type"`
  6207. RefdSetlFlag string `json:"refd_setl_flag"`
  6208. CvlservFlag string `json:"cvlserv_flag"`
  6209. EmpName string `json:"emp_name"`
  6210. Brdy string `json:"brdy"`
  6211. Naty string `json:"naty"`
  6212. Certno string `json:"certno"`
  6213. DiseCode string `json:"dise_code"`
  6214. FixmedinsCode string `json:"fixmedins_code"`
  6215. DedcHospLv string `json:"dedc_hosp_lv"`
  6216. OpterName string `json:"opter_name"`
  6217. Balc float64 `json:"balc"`
  6218. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6219. PsnCertType string `json:"psn_cert_type"`
  6220. HifobPay float64 `json:"hifob_pay"`
  6221. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6222. HifesPay float64 `json:"hifes_pay"`
  6223. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6224. OptTime string `json:"opt_time"`
  6225. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6226. SetlID string `json:"setl_id"`
  6227. MafPay float64 `json:"maf_pay"`
  6228. PsnName string `json:"psn_name"`
  6229. InsuOptins interface{} `json:"insu_optins"`
  6230. PrefFundPay interface{} `json:"pref_fund_pay"`
  6231. ClrOptins string `json:"clr_optins"`
  6232. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6233. DiseName string `json:"dise_name"`
  6234. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6235. Age float64 `json:"age"`
  6236. DtrtCertType string `json:"dtrt_cert_type"`
  6237. HospLv string `json:"hosp_lv"`
  6238. PsnCashPay float64
  6239. } `json:"setlinfo"`
  6240. } `json:"output"`
  6241. RefmsgTime string `json:"refmsg_time"`
  6242. RespondTime string `json:"respond_time"`
  6243. Signtype interface{} `json:"signtype"`
  6244. WarnMsg interface{} `json:"warn_msg"`
  6245. }
  6246. type ResultTwelve struct {
  6247. Cainfo string `json:"cainfo"`
  6248. ErrMsg string `json:"err_msg"`
  6249. InfRefmsgid string `json:"inf_refmsgid"`
  6250. Infcode int64 `json:"infcode"`
  6251. Output struct {
  6252. MdtrtId string `json:"mdtrt_id"`
  6253. ChrgBchno string `json:"chrg_bchno"`
  6254. PsnNo string `json:"psn_no"`
  6255. } `json:"output"`
  6256. RefmsgTime string `json:"refmsg_time"`
  6257. RespondTime string `json:"respond_time"`
  6258. Signtype interface{} `json:"signtype"`
  6259. WarnMsg interface{} `json:"warn_msg"`
  6260. }
  6261. type ResultThirteen struct {
  6262. ErrMsg string `json:"err_msg"`
  6263. InfRefmsgid string `json:"inf_refmsgid"`
  6264. Infcode int64 `json:"infcode"`
  6265. Output struct {
  6266. Result struct {
  6267. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6268. } `json:"result"`
  6269. } `json:"output"`
  6270. RefmsgTime string `json:"refmsg_time"`
  6271. RespondTime string `json:"respond_time"`
  6272. Signtype interface{} `json:"signtype"`
  6273. WarnInfo interface{} `json:"warn_info"`
  6274. }
  6275. type ResultThirteen10265 struct {
  6276. ErrMsg string `json:"err_msg"`
  6277. InfRefmsgid string `json:"inf_refmsgid"`
  6278. Infcode string `json:"infcode"`
  6279. Output struct {
  6280. Result struct {
  6281. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6282. } `json:"result"`
  6283. } `json:"output"`
  6284. RefmsgTime string `json:"refmsg_time"`
  6285. RespondTime string `json:"respond_time"`
  6286. Signtype interface{} `json:"signtype"`
  6287. WarnInfo interface{} `json:"warn_info"`
  6288. }
  6289. type ResultFourteen struct {
  6290. ErrMsg string `json:"err_msg"`
  6291. InfRefmsgid string `json:"inf_refmsgid"`
  6292. Infcode int64 `json:"infcode"`
  6293. Output struct {
  6294. } `json:"output"`
  6295. RefmsgTime string `json:"refmsg_time"`
  6296. RespondTime string `json:"respond_time"`
  6297. Signtype interface{} `json:"signtype"`
  6298. WarnInfo interface{} `json:"warn_info"`
  6299. }
  6300. type ResultFourteen10265 struct {
  6301. ErrMsg string `json:"err_msg"`
  6302. InfRefmsgid string `json:"inf_refmsgid"`
  6303. Infcode string `json:"infcode"`
  6304. Output struct {
  6305. } `json:"output"`
  6306. RefmsgTime string `json:"refmsg_time"`
  6307. RespondTime string `json:"respond_time"`
  6308. Signtype interface{} `json:"signtype"`
  6309. WarnInfo interface{} `json:"warn_info"`
  6310. }
  6311. type ResultSixteen struct {
  6312. Cainfo string `json:"cainfo"`
  6313. ErrMsg string `json:"err_msg"`
  6314. InfRefmsgid string `json:"inf_refmsgid"`
  6315. Infcode int64 `json:"infcode"`
  6316. Output struct {
  6317. Setldetail []interface{} `json:"setldetail"`
  6318. Setlinfo struct {
  6319. MdtrtID string `json:"mdtrt_id"`
  6320. SetlID string `json:"setl_id"`
  6321. ClrOptins string `json:"clr_optins"`
  6322. SetlTime string `json:"setl_time"`
  6323. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6324. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6325. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6326. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6327. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6328. ActPayDedc float64 `json:"act_pay_dedc"`
  6329. HifpPay float64 `json:"hifp_pay"`
  6330. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6331. Lfpay float64 `json:"selfpay"`
  6332. CvlservPay float64 `json:"cvlserv_pay"`
  6333. HifesPay float64 `json:"hifes_pay"`
  6334. HifmiPay float64 `json:"hifmi_pay"`
  6335. HifobPay float64 `json:"hifob_pay"`
  6336. MafPay float64 `json:"maf_pay"`
  6337. OthPay float64 `json:"oth_pay"`
  6338. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6339. PsnPartAmt float64 `json:"psn_part_amt"`
  6340. AcctPay float64 `json:"acct_pay"`
  6341. Balc float64 `json:"balc"`
  6342. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6343. HospPartAmt float64 `json:"hosp_part_amt"`
  6344. MedinsSetlID string `json:"medins_setl_id"`
  6345. PdnCashPay string `json:"pdn_cash_pay"`
  6346. } `json:"setlinfo"`
  6347. } `json:"output"`
  6348. RefmsgTime string `json:"refmsg_time"`
  6349. RespondTime string `json:"respond_time"`
  6350. Signtype interface{} `json:"signtype"`
  6351. WarnMsg interface{} `json:"warn_msg"`
  6352. }
  6353. type ResultSixteen10265 struct {
  6354. Cainfo string `json:"cainfo"`
  6355. ErrMsg string `json:"err_msg"`
  6356. InfRefmsgid string `json:"inf_refmsgid"`
  6357. Infcode string `json:"infcode"`
  6358. Output struct {
  6359. Setldetail []interface{} `json:"setldetail"`
  6360. Setlinfo struct {
  6361. MdtrtID string `json:"mdtrt_id"`
  6362. SetlID string `json:"setl_id"`
  6363. ClrOptins string `json:"clr_optins"`
  6364. SetlTime string `json:"setl_time"`
  6365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6367. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6368. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6369. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6370. ActPayDedc float64 `json:"act_pay_dedc"`
  6371. HifpPay float64 `json:"hifp_pay"`
  6372. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6373. Lfpay float64 `json:"selfpay"`
  6374. CvlservPay float64 `json:"cvlserv_pay"`
  6375. HifesPay float64 `json:"hifes_pay"`
  6376. HifmiPay float64 `json:"hifmi_pay"`
  6377. HifobPay float64 `json:"hifob_pay"`
  6378. MafPay float64 `json:"maf_pay"`
  6379. OthPay float64 `json:"oth_pay"`
  6380. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6381. PsnPartAmt float64 `json:"psn_part_amt"`
  6382. AcctPay float64 `json:"acct_pay"`
  6383. Balc float64 `json:"balc"`
  6384. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6385. HospPartAmt float64 `json:"hosp_part_amt"`
  6386. MedinsSetlID string `json:"medins_setl_id"`
  6387. PdnCashPay string `json:"pdn_cash_pay"`
  6388. } `json:"setlinfo"`
  6389. } `json:"output"`
  6390. RefmsgTime string `json:"refmsg_time"`
  6391. RespondTime string `json:"respond_time"`
  6392. Signtype interface{} `json:"signtype"`
  6393. WarnMsg interface{} `json:"warn_msg"`
  6394. }
  6395. type ResultSeventeen struct {
  6396. ErrMsg string `json:"err_msg"`
  6397. InfRefmsgid string `json:"inf_refmsgid"`
  6398. Infcode int64 `json:"infcode"`
  6399. Output struct {
  6400. SetlListId string `json:"setl_list_id"`
  6401. } `json:"output"`
  6402. RefmsgTime string `json:"refmsg_time"`
  6403. RespondTime string `json:"respond_time"`
  6404. Signtype string `json:"signtype"`
  6405. WarnInfo string `json:"warn_info"`
  6406. }
  6407. type ResultSeventeenOther struct {
  6408. ErrMsg string `json:"err_msg"`
  6409. InfRefmsgid string `json:"inf_refmsgid"`
  6410. Infcode string `json:"infcode"`
  6411. Output struct {
  6412. SetlListId string `json:"setl_list_id"`
  6413. } `json:"output"`
  6414. RefmsgTime string `json:"refmsg_time"`
  6415. RespondTime string `json:"respond_time"`
  6416. Signtype string `json:"signtype"`
  6417. WarnInfo string `json:"warn_info"`
  6418. }
  6419. type Result90991 struct {
  6420. ErrMsg string `json:"err_msg"`
  6421. InfRefmsgid string `json:"inf_refmsgid"`
  6422. Infcode int64 `json:"infcode"`
  6423. Output struct {
  6424. Result struct {
  6425. PsnNo string `json:"psn_no"`
  6426. CardStat string `json:"card_stat"`
  6427. Certno string `json:"certno"`
  6428. PsnName string `json:"psn_name"`
  6429. CheckStat string `json:"check_stat"`
  6430. SscnoCheckStat string `json:"sscno_check_stat"`
  6431. } `json:"result"`
  6432. } `json:"output"`
  6433. RefmsgTime string `json:"refmsg_time"`
  6434. RespondTime string `json:"respond_time"`
  6435. Signtype interface{} `json:"signtype"`
  6436. WarnInfo interface{} `json:"warn_info"`
  6437. }
  6438. type Result90100 struct {
  6439. ErrMsg string `json:"err_msg"`
  6440. InfRefmsgid string `json:"inf_refmsgid"`
  6441. Infcode int64 `json:"infcode"`
  6442. Output struct {
  6443. PoolareaNo string `json:"poolarea_no"`
  6444. PoolareaNoName string `json:"poolarea_no_name"`
  6445. Insutype string `json:"insutype"`
  6446. InsutypeName string `json:"insutype_name"`
  6447. ClctType string `json:"clct_type"`
  6448. ClctTypeName string `json:"clct_type_name"`
  6449. ClctFlag string `json:"clct_flag"`
  6450. ClctFlagName string `json:"clct_flag_name"`
  6451. AccrymBegn string `json:"accrym_begn"`
  6452. AccrymEnd string `json:"accrym_end"`
  6453. ClctTime string `json:"clct_time"`
  6454. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6455. } `json:"output"`
  6456. RefmsgTime string `json:"refmsg_time"`
  6457. RespondTime string `json:"respond_time"`
  6458. Signtype interface{} `json:"signtype"`
  6459. WarnInfo interface{} `json:"warn_info"`
  6460. }
  6461. type Custom struct {
  6462. DetItemFeeSumamt string
  6463. Cut string
  6464. FeedetlSn string
  6465. Price string
  6466. MedListCodg string
  6467. Type int64
  6468. AdviceId int64
  6469. ProjectId int64
  6470. ItemId int64
  6471. }
  6472. type Result5301 struct {
  6473. ErrMsg string `json:"err_msg"`
  6474. InfRefmsgid string `json:"inf_refmsgid"`
  6475. Infcode int64 `json:"infcode"`
  6476. Output struct {
  6477. Result []struct {
  6478. OpspDiseCode string `json:"opsp_dise_code"`
  6479. OpspDiseName string `json:"opsp_dise_name"`
  6480. Begndate string `json:"begndate"`
  6481. Enddate string `json:"enddate"`
  6482. } `json:"feedetail"`
  6483. } `json:"output"`
  6484. RefmsgTime string `json:"refmsg_time"`
  6485. RespondTime string `json:"respond_time"`
  6486. Signtype interface{} `json:"signtype"`
  6487. WarnInfo interface{} `json:"warn_info"`
  6488. }
  6489. type Result5301For10265 struct {
  6490. ErrMsg string `json:"err_msg"`
  6491. InfRefmsgid string `json:"inf_refmsgid"`
  6492. Infcode string `json:"infcode"`
  6493. Output struct {
  6494. Result []struct {
  6495. OpspDiseCode string `json:"opsp_dise_code"`
  6496. OpspDiseName string `json:"opsp_dise_name"`
  6497. Begndate string `json:"begndate"`
  6498. Enddate string `json:"enddate"`
  6499. } `json:"feedetail"`
  6500. } `json:"output"`
  6501. RefmsgTime string `json:"refmsg_time"`
  6502. RespondTime string `json:"respond_time"`
  6503. Signtype interface{} `json:"signtype"`
  6504. WarnInfo interface{} `json:"warn_info"`
  6505. }
  6506. //获取个人信息----挂号-----上传就诊信息
  6507. func (c *HisApiController) GetRegisterInfo() {
  6508. id, _ := c.GetInt64("id")
  6509. record_time := c.GetString("record_time")
  6510. settlementValue, _ := c.GetInt64("settlement_value")
  6511. medical_insurance_card := c.GetString("medical_insurance_card")
  6512. name := c.GetString("name")
  6513. id_card_type, _ := c.GetInt64("id_card_type")
  6514. certificates, _ := c.GetInt64("certificates")
  6515. medical_care, _ := c.GetInt64("medical_care")
  6516. birthday := c.GetString("birthday")
  6517. id_card := c.GetString("id_card")
  6518. register_type, _ := c.GetInt64("register")
  6519. doctor, _ := c.GetInt64("doctor")
  6520. department, _ := c.GetInt64("department")
  6521. gender, _ := c.GetInt64("sex")
  6522. registration_fee, _ := c.GetFloat("registration_fee")
  6523. medical_expenses, _ := c.GetFloat("medical_expenses")
  6524. social_type, _ := c.GetInt64("social_type")
  6525. med_type := c.GetString("social_type")
  6526. admin_user_id, _ := c.GetInt64("admin_user_id")
  6527. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6528. timeLayout := "2006-01-02"
  6529. loc, _ := time.LoadLocation("Local")
  6530. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6531. birthUnix := birthdays.Unix()
  6532. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6533. if err != nil {
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6535. return
  6536. }
  6537. recordDateTime := theTime.Unix()
  6538. adminInfo := c.GetAdminUserInfo()
  6539. var patient service.Patients
  6540. if id == 0 {
  6541. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6542. } else {
  6543. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6544. }
  6545. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6546. if patientPrescription.ID == 0 {
  6547. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6548. }
  6549. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6550. if patient.ID == 0 {
  6551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6552. return
  6553. }
  6554. if len(patient.IdCardNo) == 0 {
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6556. return
  6557. }
  6558. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6559. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6560. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6561. //就诊结算未完成,不能进行二次挂号
  6562. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6563. if len(his) >= 1 {
  6564. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6565. if len(his) >= 1 && order.ID == 0 {
  6566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6567. return
  6568. }
  6569. }
  6570. //var register_log string
  6571. if config.IsOpen == 1 {
  6572. var res ResultTwo
  6573. var res10265 ResultTwo10265
  6574. var PsnNo string
  6575. var PsnCertType string
  6576. var Certno string
  6577. var PsnName string
  6578. var Gend string
  6579. var Naty string
  6580. var Brdy string
  6581. var Age float64
  6582. var infoStr string
  6583. var idetinfoStr string
  6584. var infocode int64
  6585. var verify_number string
  6586. fmt.Println(verify_number)
  6587. if miConfig.MdtrtareaAdmvs == "421300" {
  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. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6601. psn_info, _ := service.GetPsnByPatientId(id)
  6602. PsnNo = psn_info.PsnNo
  6603. PsnCertType = psn_info.PsnCertType
  6604. Certno = psn_info.Certno
  6605. PsnName = psn_info.PsnName
  6606. Gend = psn_info.Gend
  6607. Naty = psn_info.Naty
  6608. Brdy = psn_info.Brdy
  6609. Age = psn_info.Age
  6610. infoStr = psn_info.Insuinfo
  6611. idetinfoStr = psn_info.Idetinfo
  6612. infocode = 0
  6613. verify_number = psn_info.VerifyNumber
  6614. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6615. if id_card_type == 1 {
  6616. psn_info, _ := service.GetPsnByPatientId(id)
  6617. PsnNo = psn_info.PsnNo
  6618. PsnCertType = psn_info.PsnCertType
  6619. Certno = psn_info.Certno
  6620. PsnName = psn_info.PsnName
  6621. Gend = psn_info.Gend
  6622. Naty = psn_info.Naty
  6623. Brdy = psn_info.Brdy
  6624. Age = psn_info.Age
  6625. infoStr = psn_info.Insuinfo
  6626. idetinfoStr = psn_info.Idetinfo
  6627. infocode = 0
  6628. verify_number = psn_info.VerifyNumber
  6629. } else if id_card_type == 2 {
  6630. 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)
  6631. fmt.Println(errMsgLog)
  6632. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6633. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6634. utils.ErrorLog("解析失败:%v", err)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. return
  6637. }
  6638. PsnNo = res.Output.Baseinfo.PsnNo
  6639. PsnCertType = res.Output.Baseinfo.PsnCertType
  6640. Certno = res.Output.Baseinfo.Certno
  6641. PsnName = res.Output.Baseinfo.PsnName
  6642. Gend = res.Output.Baseinfo.Gend
  6643. Naty = res.Output.Baseinfo.Naty
  6644. Brdy = res.Output.Baseinfo.Brdy
  6645. Age = res.Output.Baseinfo.Age
  6646. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6647. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6648. infoStr = string(Iinfos)
  6649. idetinfoStr = string(Idetinfos)
  6650. infocode = res.Infcode
  6651. }
  6652. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6653. if id_card_type == 1 {
  6654. psn_info, _ := service.GetPsnByPatientId(id)
  6655. PsnNo = psn_info.PsnNo
  6656. PsnCertType = psn_info.PsnCertType
  6657. Certno = psn_info.Certno
  6658. PsnName = psn_info.PsnName
  6659. Gend = psn_info.Gend
  6660. Naty = psn_info.Naty
  6661. Brdy = psn_info.Brdy
  6662. Age = psn_info.Age
  6663. infoStr = psn_info.Insuinfo
  6664. idetinfoStr = psn_info.Idetinfo
  6665. infocode = 0
  6666. verify_number = psn_info.VerifyNumber
  6667. } else if id_card_type == 2 {
  6668. 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, "")
  6669. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6671. utils.ErrorLog("解析失败:%v", err)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. return
  6674. }
  6675. PsnNo = res.Output.Baseinfo.PsnNo
  6676. PsnCertType = res.Output.Baseinfo.PsnCertType
  6677. Certno = res.Output.Baseinfo.Certno
  6678. PsnName = res.Output.Baseinfo.PsnName
  6679. Gend = res.Output.Baseinfo.Gend
  6680. Naty = res.Output.Baseinfo.Naty
  6681. Brdy = res.Output.Baseinfo.Brdy
  6682. Age = res.Output.Baseinfo.Age
  6683. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6684. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6685. infoStr = string(Iinfos)
  6686. idetinfoStr = string(Idetinfos)
  6687. infocode = res.Infcode
  6688. }
  6689. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6690. if id_card_type == 1 {
  6691. psn_info, _ := service.GetPsnByPatientId(id)
  6692. PsnNo = psn_info.PsnNo
  6693. PsnCertType = psn_info.PsnCertType
  6694. Certno = psn_info.Certno
  6695. PsnName = psn_info.PsnName
  6696. Gend = psn_info.Gend
  6697. Naty = psn_info.Naty
  6698. Brdy = psn_info.Brdy
  6699. Age = psn_info.Age
  6700. infoStr = psn_info.Insuinfo
  6701. idetinfoStr = psn_info.Idetinfo
  6702. infocode = 0
  6703. verify_number = psn_info.VerifyNumber
  6704. } else if id_card_type == 2 {
  6705. 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)
  6706. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6707. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6708. utils.ErrorLog("解析失败:%v", err)
  6709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6710. return
  6711. }
  6712. PsnNo = res.Output.Baseinfo.PsnNo
  6713. PsnCertType = res.Output.Baseinfo.PsnCertType
  6714. Certno = res.Output.Baseinfo.Certno
  6715. PsnName = res.Output.Baseinfo.PsnName
  6716. Gend = res.Output.Baseinfo.Gend
  6717. Naty = res.Output.Baseinfo.Naty
  6718. Brdy = res.Output.Baseinfo.Brdy
  6719. Age = res.Output.Baseinfo.Age
  6720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6722. infoStr = string(Iinfos)
  6723. idetinfoStr = string(Idetinfos)
  6724. infocode = res.Infcode
  6725. }
  6726. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6727. var result string
  6728. var requestLog string
  6729. 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), "")
  6730. if id_card_type == 4 {
  6731. psn_info, _ := service.GetPsnByPatientId(id)
  6732. PsnNo = psn_info.PsnNo
  6733. PsnCertType = psn_info.PsnCertType
  6734. Certno = psn_info.Certno
  6735. PsnName = psn_info.PsnName
  6736. Gend = psn_info.Gend
  6737. Naty = psn_info.Naty
  6738. Brdy = psn_info.Brdy
  6739. Age = psn_info.Age
  6740. infoStr = psn_info.Insuinfo
  6741. idetinfoStr = psn_info.Idetinfo
  6742. infocode = 0
  6743. verify_number = psn_info.VerifyNumber
  6744. } else {
  6745. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6746. if miConfig.Code == "H15049901371" {
  6747. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6748. utils.ErrorLog("解析失败:%v", err)
  6749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6750. return
  6751. }
  6752. res.ErrMsg = res10265.ErrMsg
  6753. res.Output = res10265.Output
  6754. res.InfRefmsgid = res10265.InfRefmsgid
  6755. } else {
  6756. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6757. utils.ErrorLog("解析失败:%v", err)
  6758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6759. return
  6760. }
  6761. }
  6762. PsnNo = res.Output.Baseinfo.PsnNo
  6763. PsnCertType = res.Output.Baseinfo.PsnCertType
  6764. Certno = res.Output.Baseinfo.Certno
  6765. PsnName = res.Output.Baseinfo.PsnName
  6766. Gend = res.Output.Baseinfo.Gend
  6767. Naty = res.Output.Baseinfo.Naty
  6768. Brdy = res.Output.Baseinfo.Brdy
  6769. Age = res.Output.Baseinfo.Age
  6770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6771. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6772. infoStr = string(Iinfos)
  6773. idetinfoStr = string(Idetinfos)
  6774. if miConfig.Code == "H15049901371" {
  6775. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6776. } else {
  6777. infocode = res.Infcode
  6778. }
  6779. }
  6780. } else {
  6781. var result string
  6782. var requestLog string
  6783. if miConfig.UserOrgId == 10138 {
  6784. if id_card_type != 4 {
  6785. //psn_info, _ := service.GetPsnByPatientId(id)
  6786. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6787. 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)
  6788. }
  6789. } else {
  6790. 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)
  6791. }
  6792. if id_card_type == 4 {
  6793. psn_info, _ := service.GetPsnByPatientId(id)
  6794. PsnNo = psn_info.PsnNo
  6795. PsnCertType = psn_info.PsnCertType
  6796. Certno = psn_info.Certno
  6797. PsnName = psn_info.PsnName
  6798. Gend = psn_info.Gend
  6799. Naty = psn_info.Naty
  6800. Brdy = psn_info.Brdy
  6801. Age = psn_info.Age
  6802. infoStr = psn_info.Insuinfo
  6803. idetinfoStr = psn_info.Idetinfo
  6804. infocode = 0
  6805. verify_number = psn_info.VerifyNumber
  6806. } else {
  6807. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6808. if miConfig.Code == "H15049901371" {
  6809. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6810. utils.ErrorLog("解析失败:%v", err)
  6811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6812. return
  6813. }
  6814. res.ErrMsg = res10265.ErrMsg
  6815. res.Output = res10265.Output
  6816. res.InfRefmsgid = res10265.InfRefmsgid
  6817. } else {
  6818. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6819. utils.ErrorLog("解析失败:%v", err)
  6820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6821. return
  6822. }
  6823. }
  6824. PsnNo = res.Output.Baseinfo.PsnNo
  6825. PsnCertType = res.Output.Baseinfo.PsnCertType
  6826. Certno = res.Output.Baseinfo.Certno
  6827. PsnName = res.Output.Baseinfo.PsnName
  6828. Gend = res.Output.Baseinfo.Gend
  6829. Naty = res.Output.Baseinfo.Naty
  6830. Brdy = res.Output.Baseinfo.Brdy
  6831. Age = res.Output.Baseinfo.Age
  6832. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6833. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6834. infoStr = string(Iinfos)
  6835. idetinfoStr = string(Idetinfos)
  6836. if miConfig.Code == "H15049901371" {
  6837. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6838. } else {
  6839. infocode = res.Infcode
  6840. }
  6841. }
  6842. }
  6843. if infocode == 0 {
  6844. his := models.VMHisPatient{
  6845. Name: name,
  6846. Gender: gender,
  6847. Birthday: birthUnix,
  6848. MedicalTreatmentType: medical_care,
  6849. IdType: certificates,
  6850. IdCardNo: id_card,
  6851. BalanceAccountsType: settlementValue,
  6852. SocialType: social_type,
  6853. MedicalInsuranceNumber: medical_insurance_card,
  6854. RegisterType: register_type,
  6855. RegisterCost: registration_fee,
  6856. TreatmentCost: medical_expenses,
  6857. Status: 1,
  6858. Ctime: time.Now().Unix(),
  6859. Mtime: time.Now().Unix(),
  6860. PsnNo: PsnNo,
  6861. PsnCertType: PsnCertType,
  6862. Certno: Certno,
  6863. PsnName: PsnName,
  6864. Gend: Gend,
  6865. Naty: Naty,
  6866. Brdy: Brdy,
  6867. Age: Age,
  6868. Iinfo: infoStr,
  6869. Idetinfo: idetinfoStr,
  6870. PatientId: patient.ID,
  6871. RecordDate: theTime.Unix(),
  6872. UserOrgId: adminInfo.CurrentOrgId,
  6873. AdminUserId: admin_user_id,
  6874. IsReturn: 1,
  6875. IdCardType: id_card_type,
  6876. Doctor: doctor,
  6877. Departments: department,
  6878. }
  6879. timestamp := time.Now().Unix()
  6880. tempTime := time.Unix(timestamp, 0)
  6881. timeFormat := tempTime.Format("20060102150405")
  6882. chrgBchno := rand.Intn(100000) + 10000
  6883. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6884. his.Number = ipt_otp_no
  6885. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6886. department, _ := service.GetDepartMentDetail(department)
  6887. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6888. IdCardNo := ""
  6889. if id_card_type == 1 {
  6890. // IdCardNo = medical_insurance_card
  6891. IdCardNo = patient.IdCardNo
  6892. } else {
  6893. IdCardNo = patient.IdCardNo
  6894. }
  6895. var rf []*ResultFive
  6896. json.Unmarshal([]byte(his.Iinfo), &rf)
  6897. var insutypes []*ResultFive
  6898. var insutype string
  6899. var insuplc_admdvs_temp string
  6900. var is390 int = 0
  6901. var is310 int = 0
  6902. for _, item := range rf {
  6903. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6904. insutypes = append(insutypes, item)
  6905. }
  6906. }
  6907. if len(insutypes) == 1 {
  6908. insutype = insutypes[0].Insutype
  6909. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6910. } else {
  6911. for _, i := range insutypes {
  6912. if i.Insutype == "390" {
  6913. is390 = 1
  6914. }
  6915. if i.Insutype == "310" {
  6916. is310 = 1
  6917. }
  6918. }
  6919. }
  6920. if is390 == 1 {
  6921. insutype = "390"
  6922. }
  6923. if is310 == 1 {
  6924. insutype = "310"
  6925. }
  6926. if len(insutypes) == 0 {
  6927. insutype = "310"
  6928. }
  6929. if len(insutypes) == 2 {
  6930. insutype = med_type
  6931. }
  6932. if len(med_type) > 0 {
  6933. insutype = med_type
  6934. }
  6935. var infocode int64
  6936. var resThree ResultThree
  6937. var resThree10265 ResultThree10265
  6938. if len(insuplc_admdvs) == 0 {
  6939. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6940. } else {
  6941. insuplc_admdvs_temp = insuplc_admdvs
  6942. }
  6943. if miConfig.MdtrtareaAdmvs == "350500" {
  6944. var rf []*ResultIDInfo
  6945. json.Unmarshal([]byte(idetinfoStr), &rf)
  6946. if len(rf) > 0 {
  6947. if len(rf[0].Memo) > 0 {
  6948. fmt.Println("122222222222222")
  6949. content := rf[0].Memo[1:len(rf[0].Memo)]
  6950. content2 := content[:len(content)-1]
  6951. fmt.Println(content2)
  6952. //var rf2 ResultMemo
  6953. //json.Unmarshal([]byte(content2), &rf2)
  6954. //fmt.Println(rf2)
  6955. //fmt.Println(rf2.InsuAdmdvs)
  6956. arr := strings.Split(content2, ",")
  6957. var tarstring string
  6958. for _, item := range arr {
  6959. if find := strings.Contains(item, "insuAdmdvs"); find {
  6960. tarstring = item
  6961. }
  6962. }
  6963. fmt.Println(tarstring)
  6964. if len(tarstring) > 0 {
  6965. arr := strings.Split(tarstring, ":")
  6966. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  6967. //insuplc_admdvs_temp = arr[1]
  6968. }
  6969. }
  6970. }
  6971. }
  6972. if miConfig.MdtrtareaAdmvs == "421300" {
  6973. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6974. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6975. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6976. "&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
  6977. resp, requestErr := http.Get(api)
  6978. if requestErr != nil {
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. return
  6981. }
  6982. body, ioErr := ioutil.ReadAll(resp.Body)
  6983. if ioErr != nil {
  6984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. var respJSON map[string]interface{}
  6989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6995. result, _ := json.Marshal(respJSON)
  6996. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6997. utils.ErrorLog("解析失败:%v", err)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. infocode = resThree.Infcode
  7002. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7003. psn_info, _ := service.GetPsnByPatientId(id)
  7004. his.PsnNo = psn_info.PsnNo
  7005. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7006. var cert_no string
  7007. if id_card_type == 3 {
  7008. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7009. cert_no = IdCardNo
  7010. } else if id_card_type == 4 {
  7011. cert_no = IdCardNo
  7012. psn_info.VerifyNumber = psn_info.VerifyNumber
  7013. } else {
  7014. bas := strings.Split(psn_info.CardInfo, "|")
  7015. cert_no = bas[2]
  7016. }
  7017. var hisPrescription []*models.HisPrescription
  7018. for _, item := range rf {
  7019. if item.Insutype == insutype {
  7020. //insuplc_admdvs = item.InsuplcAdmdvs
  7021. his.InsuplcAdmdvs = insuplc_admdvs
  7022. }
  7023. }
  7024. his.Insutype = insutype
  7025. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7026. fmt.Println(res3101)
  7027. fmt.Println(res3101.Infcode)
  7028. if res3101.Infcode == "0" {
  7029. fmt.Println("33333333")
  7030. if len(res3101.Output.Result) > 0 {
  7031. fmt.Println("222222")
  7032. for _, item := range res3101.Output.Result {
  7033. if len(res3101.ErrMsg) == 0 {
  7034. res3101.ErrMsg = item.VolaCont
  7035. } else {
  7036. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7037. }
  7038. }
  7039. c.ServeSuccessJSON(map[string]interface{}{
  7040. "failed_code": -10,
  7041. "msg": res3101.ErrMsg,
  7042. })
  7043. return
  7044. } else {
  7045. fmt.Println("11111")
  7046. var api string
  7047. if miConfig.MdtrtareaAdmvs == "320921" {
  7048. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7049. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7050. "&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
  7051. } else {
  7052. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7053. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7054. "&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
  7055. }
  7056. resp, requestErr := http.Get(api)
  7057. if requestErr != nil {
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. return
  7060. }
  7061. body, ioErr := ioutil.ReadAll(resp.Body)
  7062. if ioErr != nil {
  7063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7065. return
  7066. }
  7067. var respJSON map[string]interface{}
  7068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7071. return
  7072. }
  7073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7074. result, _ := json.Marshal(respJSON)
  7075. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7076. utils.ErrorLog("解析失败:%v", err)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. resThree.ErrMsg = resThree10265.ErrMsg
  7081. resThree.Output = resThree10265.Output
  7082. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7083. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7084. }
  7085. } else if res3101.Infcode != "0" {
  7086. c.ServeSuccessJSON(map[string]interface{}{
  7087. "failed_code": -10,
  7088. "msg": res3101.ErrMsg,
  7089. })
  7090. return
  7091. }
  7092. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7093. psn_info, _ := service.GetPsnByPatientId(id)
  7094. var cert_no string
  7095. if id_card_type == 1 {
  7096. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7097. } else if id_card_type == 4 {
  7098. cert_no = psn_info.VerifyNumber
  7099. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7100. } else {
  7101. cert_no = psn_info.VerifyNumber
  7102. }
  7103. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  7104. saveLog(result, requestLog, "2201", "挂号")
  7105. if miConfig.Code == "H15049901371" {
  7106. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7107. utils.ErrorLog("解析失败:%v", err)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. return
  7110. }
  7111. resThree.ErrMsg = resThree10265.ErrMsg
  7112. resThree.Output = resThree10265.Output
  7113. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7114. } else {
  7115. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7116. utils.ErrorLog("解析失败:%v", err)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. return
  7119. }
  7120. }
  7121. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7122. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7123. psn_info, _ := service.GetPsnByPatientId(id)
  7124. var result string
  7125. var requestLog string
  7126. if id_card_type == 1 {
  7127. bas := strings.Split(psn_info.CardInfo, "|")
  7128. basNumber := bas[2]
  7129. card_sn := bas[3]
  7130. 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)
  7131. saveLog(result, requestLog, "2201A", "挂号")
  7132. } else if id_card_type == 2 {
  7133. 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, "", "")
  7134. saveLog(result, requestLog, "2201A", "挂号")
  7135. } else {
  7136. 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, "", "")
  7137. saveLog(result, requestLog, "2201A", "挂号")
  7138. }
  7139. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7140. utils.ErrorLog("解析失败:%v", err)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. return
  7143. }
  7144. infocode = resThree.Infcode
  7145. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7146. psn_info, _ := service.GetPsnByPatientId(id)
  7147. var result string
  7148. var requestLog string
  7149. if id_card_type == 1 {
  7150. bas := strings.Split(psn_info.CardInfo, "|")
  7151. basNumber := bas[2]
  7152. card_sn := bas[3]
  7153. 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)
  7154. saveLog(result, requestLog, "2201A", "挂号")
  7155. } else if id_card_type == 2 {
  7156. 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, "", "")
  7157. saveLog(result, requestLog, "2201A", "挂号")
  7158. } else {
  7159. 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, "", "")
  7160. saveLog(result, requestLog, "2201A", "挂号")
  7161. }
  7162. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7163. utils.ErrorLog("解析失败:%v", err)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. return
  7166. }
  7167. infocode = resThree.Infcode
  7168. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7169. psn_info, _ := service.GetPsnByPatientId(id)
  7170. 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)
  7171. saveLog(result, requestLog, "2201A", "挂号")
  7172. if miConfig.Code == "H15049901371" {
  7173. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7174. utils.ErrorLog("解析失败:%v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. resThree.ErrMsg = resThree10265.ErrMsg
  7179. resThree.Output = resThree10265.Output
  7180. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7181. } else {
  7182. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7183. utils.ErrorLog("解析失败:%v", err)
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. }
  7188. if miConfig.Code == "H15049901371" {
  7189. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7190. } else {
  7191. infocode = resThree.Infcode
  7192. }
  7193. } else {
  7194. psn_info, _ := service.GetPsnByPatientId(id)
  7195. 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)
  7196. saveLog(result, requestLog, "2201A", "挂号")
  7197. if miConfig.Code == "H15049901371" {
  7198. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7199. utils.ErrorLog("解析失败:%v", err)
  7200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7201. return
  7202. }
  7203. resThree.ErrMsg = resThree10265.ErrMsg
  7204. resThree.Output = resThree10265.Output
  7205. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7206. } else {
  7207. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7208. utils.ErrorLog("解析失败:%v", err)
  7209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7210. return
  7211. }
  7212. }
  7213. if miConfig.Code == "H15049901371" {
  7214. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7215. } else {
  7216. infocode = resThree.Infcode
  7217. }
  7218. }
  7219. if infocode != 0 {
  7220. adminUser := c.GetAdminUserInfo()
  7221. errlog := &models.HisOrderError{
  7222. UserOrgId: adminUser.CurrentOrgId,
  7223. Ctime: time.Now().Unix(),
  7224. Mtime: time.Now().Unix(),
  7225. ErrMsg: resThree.ErrMsg,
  7226. Status: 1,
  7227. PatientId: id,
  7228. RecordTime: recordDateTime,
  7229. Stage: 2,
  7230. }
  7231. service.CreateErrMsgLog(errlog)
  7232. c.ServeSuccessJSON(map[string]interface{}{
  7233. "failed_code": -10,
  7234. "msg": resThree.ErrMsg,
  7235. })
  7236. return
  7237. }
  7238. his.Number = resThree.Output.Data.MdtrtID
  7239. his.PsnNo = resThree.Output.Data.PsnNo
  7240. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7241. his.IdCardNo = patient.IdCardNo
  7242. his.PhoneNumber = patient.Phone
  7243. his.UserOrgId = adminInfo.CurrentOrgId
  7244. his.Insutype = insutype
  7245. his.Ctime = time.Now().Unix()
  7246. his.Mtime = time.Now().Unix()
  7247. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7248. his.Status = 1
  7249. service.UpdateHisPatientStatus(&his)
  7250. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7251. c.ServeSuccessJSON(map[string]interface{}{
  7252. "his_info": his,
  7253. })
  7254. } else {
  7255. adminUser := c.GetAdminUserInfo()
  7256. errlog := &models.HisOrderError{
  7257. UserOrgId: adminUser.CurrentOrgId,
  7258. Ctime: time.Now().Unix(),
  7259. Mtime: time.Now().Unix(),
  7260. ErrMsg: res.ErrMsg,
  7261. Status: 1,
  7262. PatientId: id,
  7263. RecordTime: recordDateTime,
  7264. Stage: 1,
  7265. }
  7266. service.CreateErrMsgLog(errlog)
  7267. c.ServeSuccessJSON(map[string]interface{}{
  7268. "failed_code": -10,
  7269. "msg": res.ErrMsg,
  7270. })
  7271. return
  7272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7273. }
  7274. }
  7275. }
  7276. //上传明细----预结算----确认订单
  7277. func (c *HisApiController) GetUploadInfo() {
  7278. id, _ := c.GetInt64("id")
  7279. record_time := c.GetString("record_time")
  7280. his_patient_id, _ := c.GetInt64("his_patient_id")
  7281. order_id, _ := c.GetInt64("order_id")
  7282. pay_way, _ := c.GetInt64("pay_way")
  7283. pay_price, _ := c.GetFloat("pay_price")
  7284. pay_card_no := c.GetString("pay_card_no")
  7285. discount_price, _ := c.GetFloat("discount_price")
  7286. preferential_price, _ := c.GetFloat("preferential_price")
  7287. reality_price, _ := c.GetFloat("reality_price")
  7288. found_price, _ := c.GetFloat("found_price")
  7289. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7290. private_price, _ := c.GetFloat("private_price")
  7291. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7292. admin_user_id, _ := c.GetInt64("admin_user_id")
  7293. fapiao_code := c.GetString("fapiao_code")
  7294. fapiao_number := c.GetString("fapiao_number")
  7295. diagnosis_id := c.GetString("diagnosis")
  7296. sick_type, _ := c.GetInt64("sick_type")
  7297. reg_type, _ := c.GetInt64("p_type")
  7298. begin_time := c.GetString("begin_time")
  7299. id_str := c.GetString("ids")
  7300. ids_arr := strings.Split(id_str, ",")
  7301. timeLayout := "2006-01-02"
  7302. loc, _ := time.LoadLocation("Local")
  7303. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7304. if err != nil {
  7305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7306. return
  7307. }
  7308. recordDateTime := theTime.Unix()
  7309. adminUser := c.GetAdminUserInfo()
  7310. var tempOrder models.HisOrder
  7311. tempOrder, _ = service.GetHisOrderByID(order_id)
  7312. var prescriptions []*models.HisPrescription
  7313. var start_time int64
  7314. var end_time int64
  7315. //押金模块
  7316. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7317. tmp_decimal := c.GetString("tmp_decimal")
  7318. var decimal float64 //本次使用的押金
  7319. var errmsg error
  7320. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7321. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7322. return
  7323. }
  7324. if len(tmp_decimal) > 0 {
  7325. if tmp_decimal[0] == 45 {
  7326. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7327. return
  7328. }
  7329. }
  7330. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7331. fmt.Println(errs)
  7332. decimal = tt
  7333. //if adminUser.CurrentOrgId == 10106{
  7334. // if len(fapiao_code) == 0{
  7335. // fapiao_code = "144072080589"
  7336. // }
  7337. // if len(fapiao_number) == 0{
  7338. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7339. // if order.ID == 0{
  7340. // fapiao_number = "00001520"
  7341. // }else{
  7342. // //fapiao_code = "00001520"
  7343. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7344. // var zero string
  7345. // if fpNumber >= 1000{
  7346. // zero = "0000" + strconv.Itoa(fpNumber)
  7347. // }else if fpNumber >= 10000{
  7348. // zero = "000" + strconv.Itoa(fpNumber)
  7349. // } else if fpNumber >= 100000{
  7350. // zero = "00" + strconv.Itoa(fpNumber)
  7351. // } else if fpNumber >= 1000000{
  7352. // zero = "0" + strconv.Itoa(fpNumber)
  7353. // }else {
  7354. // zero = strconv.Itoa(fpNumber)
  7355. // }
  7356. // fapiao_number = zero
  7357. // }
  7358. // }
  7359. //}
  7360. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7361. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7362. var patientPrescription models.HisPrescriptionInfo
  7363. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7364. if patientPrescription.ID == 0 {
  7365. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7366. }
  7367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7368. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7369. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7370. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7371. var config []*models.HisXtDiagnoseConfig
  7372. for _, item := range diagnosis_ids {
  7373. id, _ := strconv.ParseInt(item, 10, 64)
  7374. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7375. config = append(config, &diagnosisConfig)
  7376. }
  7377. sickConfig, _ := service.FindSickById(sick_type)
  7378. //if tempOrder.ID == 0 {
  7379. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7380. //}
  7381. if tempOrder.ID == 0 {
  7382. var result string
  7383. var requestLog string
  7384. var res2 ResultSix
  7385. var ressix10265 ResultSix10265
  7386. if miConfig.MdtrtareaAdmvs == "421300" {
  7387. data := make(map[string]interface{})
  7388. client := &http.Client{}
  7389. data["psn_no"] = his.PsnNo
  7390. data["mdtrt_id"] = his.Number
  7391. data["opter"] = roles.UserName
  7392. data["org_name"] = miConfig.OrgName
  7393. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7394. data["doctor_id"] = doctor_info.DoctorNumber
  7395. data["doctor_name"] = doctor_info.UserName
  7396. data["department"] = department.Name
  7397. data["fixmedins_code"] = miConfig.Code
  7398. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7399. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7400. data["secret_key"] = miConfig.SecretKey
  7401. data["sick_code"] = sickConfig.CountryCode
  7402. data["sick_name"] = sickConfig.ClassName
  7403. data["dept"] = strconv.FormatInt(department.ID, 10)
  7404. data["config"] = config
  7405. data["begin_time"] = begin_time
  7406. bytesData, _ := json.Marshal(data)
  7407. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7408. resp, _ := client.Do(req)
  7409. defer resp.Body.Close()
  7410. body, ioErr := ioutil.ReadAll(resp.Body)
  7411. if ioErr != nil {
  7412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. return
  7415. }
  7416. var respJSON map[string]interface{}
  7417. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7420. return
  7421. }
  7422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7423. userJSONBytes, _ := json.Marshal(respJSON)
  7424. fmt.Println("log")
  7425. fmt.Println(string(userJSONBytes))
  7426. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7427. utils.ErrorLog("解析失败:%v", err)
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. return
  7430. }
  7431. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7432. data := make(map[string]interface{})
  7433. client := &http.Client{}
  7434. data["psn_no"] = his.PsnNo
  7435. data["mdtrt_id"] = his.Number
  7436. data["doctor"] = roles.UserName
  7437. data["department"] = department.Name
  7438. data["org_name"] = miConfig.OrgName
  7439. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7440. data["doctor_id"] = doctor_info.DoctorNumber
  7441. data["new_doctor_name"] = doctor_info.UserName
  7442. data["fixmedins_code"] = miConfig.Code
  7443. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7444. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7445. data["secret_key"] = miConfig.SecretKey
  7446. data["sick_code"] = sickConfig.CountryCode
  7447. data["sick_name"] = sickConfig.ClassName
  7448. data["url"] = miConfig.Url
  7449. data["ak"] = miConfig.AccessKey
  7450. data["begin_time"] = begin_time
  7451. data["cainfo"] = miConfig.Cainfo
  7452. data["dept"] = strconv.FormatInt(department.ID, 10)
  7453. data["config"] = config
  7454. bytesData, _ := json.Marshal(data)
  7455. var req *http.Request
  7456. if miConfig.MdtrtareaAdmvs == "320921" {
  7457. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7458. //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 +
  7459. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7460. } else {
  7461. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7462. }
  7463. resp, _ := client.Do(req)
  7464. defer resp.Body.Close()
  7465. body, ioErr := ioutil.ReadAll(resp.Body)
  7466. if ioErr != nil {
  7467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. var respJSON map[string]interface{}
  7472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7478. userJSONBytes, _ := json.Marshal(respJSON)
  7479. fmt.Println("log")
  7480. fmt.Println(string(userJSONBytes))
  7481. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7482. utils.ErrorLog("解析失败:%v", err)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7487. res2.Output = ressix10265.Output
  7488. res2.ErrMsg = ressix10265.ErrMsg
  7489. res2.Cainfo = ressix10265.Cainfo
  7490. res2.WarnMsg = ressix10265.WarnMsg
  7491. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7492. res2.Infcode = infocode
  7493. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7494. 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)
  7495. saveLog(result, requestLog, "2203", "上传就诊信息")
  7496. var respJSON2 map[string]interface{}
  7497. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7500. return
  7501. }
  7502. userJSONBytes2, _ := json.Marshal(respJSON2)
  7503. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7504. utils.ErrorLog("解析失败:%v", err)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. } else {
  7509. if miConfig.MdtrtareaAdmvs == "440781" { //
  7510. 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)
  7511. } else {
  7512. if miConfig.Code == "H15049901371" {
  7513. //赤峰地区国家医保医疗类别
  7514. //职工透析:医疗类别选特殊情况门诊990502
  7515. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7516. var med_type string
  7517. if his.Insutype == "390" {
  7518. if reg_type == 14 {
  7519. med_type = "9933"
  7520. } else if reg_type == 11 {
  7521. med_type = "11"
  7522. }
  7523. } else if his.Insutype == "310" {
  7524. if reg_type == 14 {
  7525. med_type = "990502"
  7526. } else if reg_type == 11 {
  7527. med_type = "11"
  7528. }
  7529. }
  7530. 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)
  7531. } else {
  7532. 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)
  7533. }
  7534. }
  7535. saveLog(result, requestLog, "2203", "上传就诊信息")
  7536. var respJSON2 map[string]interface{}
  7537. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. userJSONBytes2, _ := json.Marshal(respJSON2)
  7543. if miConfig.Code == "H15049901371" {
  7544. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7545. utils.ErrorLog("解析失败:%v", err)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7550. res2.Output = ressix10265.Output
  7551. res2.ErrMsg = ressix10265.ErrMsg
  7552. res2.Cainfo = ressix10265.Cainfo
  7553. res2.WarnMsg = ressix10265.WarnMsg
  7554. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7555. res2.Infcode = infocode
  7556. } else {
  7557. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7558. utils.ErrorLog("解析失败:%v", err)
  7559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7560. return
  7561. }
  7562. }
  7563. }
  7564. if res2.Infcode != 0 {
  7565. adminUser := c.GetAdminUserInfo()
  7566. errlog := &models.HisOrderError{
  7567. UserOrgId: adminUser.CurrentOrgId,
  7568. Ctime: time.Now().Unix(),
  7569. Mtime: time.Now().Unix(),
  7570. ErrMsg: res2.ErrMsg,
  7571. Status: 1,
  7572. PatientId: id,
  7573. RecordTime: recordDateTime,
  7574. Stage: 3,
  7575. }
  7576. service.CreateErrMsgLog(errlog)
  7577. c.ServeSuccessJSON(map[string]interface{}{
  7578. "failed_code": -10,
  7579. "msg": res2.ErrMsg,
  7580. })
  7581. return
  7582. } else {
  7583. his.Diagnosis = diagnosis_id
  7584. his.SickType = sickConfig.ID
  7585. //var p_type int64
  7586. //if reg_type == 1111 || reg_type == 1112 {
  7587. // p_type = 11
  7588. //
  7589. //}
  7590. his.PType = fmt.Sprintf("%d", reg_type)
  7591. service.UpdateHisPatientThree(&his)
  7592. data := make(map[string]interface{})
  7593. if settle_accounts_type == 1 { //日结
  7594. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7595. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7596. } else {
  7597. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7598. }
  7599. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7600. data["pre"] = prescriptions
  7601. } else { //月结
  7602. start_time_str := c.GetString("start_time")
  7603. end_time_str := c.GetString("end_time")
  7604. timeLayout := "2006-01-02"
  7605. loc, _ := time.LoadLocation("Local")
  7606. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7607. if err != nil {
  7608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7609. return
  7610. }
  7611. recordStartTime := theStartTime.Unix()
  7612. start_time = recordStartTime
  7613. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7614. if err != nil {
  7615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7616. return
  7617. }
  7618. recordEndTime := theEndTime.Unix()
  7619. end_time = recordEndTime
  7620. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7621. data["pre"] = prescriptions
  7622. }
  7623. timestamp := time.Now().Unix()
  7624. tempTime := time.Unix(timestamp, 0)
  7625. timeFormat := tempTime.Format("20060102150405")
  7626. chrgBchno := rand.Intn(100000) + 10000
  7627. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7628. strconv.FormatInt(his.PatientId, 10)
  7629. client := &http.Client{}
  7630. data["psn_no"] = his.PsnNo
  7631. data["mdtrt_id"] = his.Number
  7632. data["chrg_bchno"] = chrg_bchno
  7633. data["org_name"] = miConfig.OrgName
  7634. data["doctor"] = doctor_info.UserName
  7635. data["doctor_id"] = doctor_info.DoctorNumber
  7636. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7637. data["fixmedins_code"] = miConfig.Code
  7638. data["opter"] = roles.UserName
  7639. data["dept_code"] = department.Number
  7640. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7642. data["secret_key"] = miConfig.SecretKey
  7643. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7644. data["url"] = miConfig.Url
  7645. data["ak"] = miConfig.AccessKey
  7646. data["new_doctor_name"] = patientPrescription.Doctor
  7647. data["diag_code"] = sickConfig.CountryCode
  7648. data["cainfo"] = miConfig.Cainfo
  7649. data["opter"] = roles.UserName
  7650. var ids []int64
  7651. for _, item := range prescriptions {
  7652. ids = append(ids, item.ID)
  7653. }
  7654. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7655. if config.IsOpen == 1 { //对接了医保,走医保流程
  7656. var res ResultFour
  7657. var resFour10265 ResultFour10265
  7658. if miConfig.MdtrtareaAdmvs == "421300" {
  7659. bytesData, _ := json.Marshal(data)
  7660. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7661. resp, _ := client.Do(req)
  7662. defer resp.Body.Close()
  7663. body, ioErr := ioutil.ReadAll(resp.Body)
  7664. if ioErr != nil {
  7665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7667. return
  7668. }
  7669. var respJSON map[string]interface{}
  7670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. return
  7674. }
  7675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7676. userJSONBytes, _ := json.Marshal(respJSON)
  7677. fmt.Println("log")
  7678. fmt.Println(string(userJSONBytes))
  7679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7680. utils.ErrorLog("解析失败:%v", err)
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7685. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7686. if result3101.Infcode == "0" {
  7687. if len(result3101.Output.Result) > 0 {
  7688. var errMsgs []string
  7689. for _, item := range result3101.Output.Result {
  7690. errMsgs = append(errMsgs, item.VolaCont)
  7691. }
  7692. c.ServeSuccessJSON(map[string]interface{}{
  7693. "failed_code": -10,
  7694. "msg": errMsgs,
  7695. })
  7696. return
  7697. }
  7698. }
  7699. if miConfig.MdtrtareaAdmvs == "320921" {
  7700. data["doctor_id"] = "D320923012139"
  7701. } else {
  7702. data["doctor_id"] = "D371621008686"
  7703. }
  7704. bytesData, _ := json.Marshal(data)
  7705. var req *http.Request
  7706. if miConfig.MdtrtareaAdmvs == "320921" {
  7707. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7708. } else {
  7709. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7710. }
  7711. resp, _ := client.Do(req)
  7712. defer resp.Body.Close()
  7713. body, ioErr := ioutil.ReadAll(resp.Body)
  7714. if ioErr != nil {
  7715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. var respJSON map[string]interface{}
  7720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. return
  7724. }
  7725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7726. userJSONBytes, _ := json.Marshal(respJSON)
  7727. fmt.Println("log")
  7728. fmt.Println(string(userJSONBytes))
  7729. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7730. utils.ErrorLog("解析失败:%v", err)
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. res.InfRefmsgid = resFour10265.InfRefmsgid
  7735. res.Output = resFour10265.Output
  7736. res.ErrMsg = resFour10265.ErrMsg
  7737. res.Cainfo = resFour10265.Cainfo
  7738. res.WarnMsg = resFour10265.WarnMsg
  7739. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7740. res.Infcode = infocode
  7741. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7742. 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)
  7743. var dat map[string]interface{}
  7744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7745. fmt.Println(dat)
  7746. } else {
  7747. fmt.Println(err)
  7748. }
  7749. saveLog(result, request_log, "2204", "上传费用明细")
  7750. userJSONBytes, _ := json.Marshal(dat)
  7751. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7752. utils.ErrorLog("解析失败:%v", err)
  7753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7754. return
  7755. }
  7756. res.InfRefmsgid = resFour10265.InfRefmsgid
  7757. res.Output = resFour10265.Output
  7758. res.ErrMsg = resFour10265.ErrMsg
  7759. res.Cainfo = resFour10265.Cainfo
  7760. res.WarnMsg = resFour10265.WarnMsg
  7761. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7762. res.Infcode = infocode
  7763. } else {
  7764. if miConfig.Code == "H15049901371" {
  7765. 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)
  7766. var dat map[string]interface{}
  7767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7768. fmt.Println(dat)
  7769. } else {
  7770. fmt.Println(err)
  7771. }
  7772. saveLog(result, request_log, "2204", "上传费用明细")
  7773. userJSONBytes, _ := json.Marshal(dat)
  7774. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7775. utils.ErrorLog("解析失败:%v", err)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. res.InfRefmsgid = resFour10265.InfRefmsgid
  7780. res.Output = resFour10265.Output
  7781. res.ErrMsg = resFour10265.ErrMsg
  7782. res.Cainfo = resFour10265.Cainfo
  7783. res.WarnMsg = resFour10265.WarnMsg
  7784. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7785. res.Infcode = infocode
  7786. } else {
  7787. 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)
  7788. var dat map[string]interface{}
  7789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7790. fmt.Println(dat)
  7791. } else {
  7792. fmt.Println(err)
  7793. }
  7794. saveLog(result, request_log, "2204", "上传费用明细")
  7795. userJSONBytes, _ := json.Marshal(dat)
  7796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. }
  7802. }
  7803. if res.Infcode == 0 {
  7804. order := &models.HisOrder{
  7805. UserOrgId: adminUser.CurrentOrgId,
  7806. HisPatientId: his.ID,
  7807. PatientId: his.PatientId,
  7808. SettleAccountsDate: recordDateTime,
  7809. MdtrtId: his.Number,
  7810. PsnNo: his.PsnNo,
  7811. MedType: strconv.FormatInt(reg_type, 10),
  7812. Ctime: time.Now().Unix(),
  7813. Mtime: time.Now().Unix(),
  7814. Status: 1,
  7815. Number: chrg_bchno,
  7816. Infcode: res.Infcode,
  7817. WarnMsg: res.WarnMsg,
  7818. Cainfo: res.Cainfo,
  7819. ErrMsg: res.ErrMsg,
  7820. RespondTime: res.RefmsgTime,
  7821. InfRefmsgid: res.InfRefmsgid,
  7822. OrderStatus: 1,
  7823. PayWay: pay_way,
  7824. PayPrice: pay_price,
  7825. PayCardNo: pay_card_no,
  7826. DiscountPrice: discount_price,
  7827. PreferentialPrice: preferential_price,
  7828. RealityPrice: reality_price,
  7829. FoundPrice: found_price,
  7830. MedicalInsurancePrice: medical_insurance_price,
  7831. PrivatePrice: private_price,
  7832. IsMedicineInsurance: 1,
  7833. SettleType: settle_accounts_type,
  7834. SettleStartTime: start_time,
  7835. SettleEndTime: end_time,
  7836. Creator: roles.AdminUserId,
  7837. Modify: roles.AdminUserId,
  7838. FaPiaoNumber: fapiao_number,
  7839. FaPiaoCode: fapiao_code,
  7840. PType: 2,
  7841. Diagnosis: diagnosis_id,
  7842. }
  7843. err = service.CreateOrder(order)
  7844. if err != nil {
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7846. return
  7847. }
  7848. for _, item := range res.Output.Result {
  7849. temp := strings.Split(item.FeedetlSn, "-")
  7850. var advice_id int64 = 0
  7851. var project_id int64 = 0
  7852. var types int64 = 0
  7853. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7854. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7855. if temp[1] == "1" {
  7856. advice_id = id
  7857. project_id = 0
  7858. } else if temp[1] == "2" {
  7859. advice_id = 0
  7860. project_id = id
  7861. }
  7862. if item.MedChrgitmType == "9" {
  7863. item.MedChrgitmType = "09"
  7864. }
  7865. info := &models.HisOrderInfo{
  7866. OrderNumber: order.Number,
  7867. FeedetlSn: item.FeedetlSn,
  7868. UploadDate: time.Now().Unix(),
  7869. AdviceId: advice_id,
  7870. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7871. Cnt: item.Cnt,
  7872. Pric: float64(item.Pric),
  7873. PatientId: his.PatientId,
  7874. PricUplmtAmt: item.PricUplmtAmt,
  7875. SelfpayProp: item.SelfpayProp,
  7876. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7877. OverlmtAmt: item.OverlmtAmt,
  7878. PreselfpayAmt: item.PreselfpayAmt,
  7879. BasMednFlag: item.BasMednFlag,
  7880. MedChrgitmType: item.MedChrgitmType,
  7881. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7882. Status: 1,
  7883. Memo: item.Memo,
  7884. Mtime: time.Now().Unix(),
  7885. InscpScpAmt: item.InscpScpAmt,
  7886. DrtReimFlag: item.DrtReimFlag,
  7887. Ctime: time.Now().Unix(),
  7888. ListSpItemFlag: item.ListSpItemFlag,
  7889. ChldMedcFlag: item.ChldMedcFlag,
  7890. LmtUsedFlag: item.LmtUsedFlag,
  7891. ChrgitmLv: item.ChrgitmLv,
  7892. UserOrgId: adminUser.CurrentOrgId,
  7893. HisPatientId: his.ID,
  7894. OrderId: order.ID,
  7895. ProjectId: project_id,
  7896. Type: types,
  7897. }
  7898. service.CreateOrderInfo(info)
  7899. }
  7900. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7901. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7902. var total float64
  7903. for _, item := range prescriptions {
  7904. if item.Type == 1 { //药品
  7905. for _, subItem := range item.HisDoctorAdviceInfo {
  7906. total = total + (subItem.Price * subItem.PrescribingNumber)
  7907. }
  7908. }
  7909. if item.Type == 2 { //项目
  7910. for _, subItem := range item.HisPrescriptionProject {
  7911. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7912. total = total + (subItem.Price * cnt)
  7913. }
  7914. }
  7915. }
  7916. for _, item := range prescriptions {
  7917. for _, subItem := range item.HisAdditionalCharge {
  7918. total = total + (subItem.Price * float64(subItem.Count))
  7919. }
  7920. }
  7921. var allTotal string
  7922. if adminUser.CurrentOrgId == 9919 {
  7923. allTotal = fmt.Sprintf("%.4f", total)
  7924. } else {
  7925. allTotal = fmt.Sprintf("%.4f", total)
  7926. }
  7927. if res.Infcode == 0 {
  7928. var rf []*ResultFive
  7929. json.Unmarshal([]byte(his.Iinfo), &rf)
  7930. chrg_bchno := chrg_bchno
  7931. cert_no := his.Certno
  7932. var insutypes []string
  7933. var insutype string
  7934. var is390 int = 0
  7935. var is310 int = 0
  7936. for _, item := range rf {
  7937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7938. insutypes = append(insutypes, item.Insutype)
  7939. }
  7940. }
  7941. if len(insutypes) == 1 {
  7942. insutype = insutypes[0]
  7943. } else {
  7944. for _, i := range insutypes {
  7945. if i == "390" {
  7946. is390 = 1
  7947. }
  7948. if i == "310" {
  7949. is310 = 1
  7950. }
  7951. }
  7952. }
  7953. if is390 == 1 {
  7954. insutype = "390"
  7955. }
  7956. if is310 == 1 {
  7957. insutype = "310"
  7958. }
  7959. if len(insutypes) == 0 {
  7960. insutype = "310"
  7961. }
  7962. if len(insutypes) == 2 {
  7963. insutype = strconv.FormatInt(his.SocialType, 10)
  7964. }
  7965. insutype = strconv.FormatInt(his.SocialType, 10)
  7966. //insutype = "390"
  7967. if his.IdCardType == 1 {
  7968. // cert_no = his.MedicalInsuranceNumber
  7969. cert_no = his.Certno
  7970. } else {
  7971. cert_no = his.Certno
  7972. }
  7973. var res ResultSeven
  7974. var resSeven10265 ResultSeven10265
  7975. var src_resquest string
  7976. var result2 string
  7977. var acct_used_flag string
  7978. fmt.Println("pay_way")
  7979. fmt.Println(pay_way)
  7980. fmt.Println("pay_way")
  7981. if pay_way == 4 {
  7982. acct_used_flag = "1"
  7983. } else {
  7984. acct_used_flag = "0"
  7985. }
  7986. if miConfig.MdtrtareaAdmvs == "421300" {
  7987. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7988. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7989. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7991. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7992. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7993. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7994. resp, requestErr := http.Get(api)
  7995. if requestErr != nil {
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. body, ioErr := ioutil.ReadAll(resp.Body)
  8000. if ioErr != nil {
  8001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. var respJSON map[string]interface{}
  8006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8009. return
  8010. }
  8011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8012. result, _ := json.Marshal(respJSON)
  8013. if miConfig.Code == "H15049901371" {
  8014. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8015. utils.ErrorLog("解析失败:%v", err)
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8017. return
  8018. }
  8019. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8020. res.Output = resSeven10265.Output
  8021. res.ErrMsg = resSeven10265.ErrMsg
  8022. res.Cainfo = resSeven10265.Cainfo
  8023. res.WarnMsg = resSeven10265.WarnMsg
  8024. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8025. res.Infcode = infocode
  8026. } else {
  8027. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8028. utils.ErrorLog("解析失败:%v", err)
  8029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8030. return
  8031. }
  8032. }
  8033. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8034. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8035. if result3101.Infcode == "0" {
  8036. if len(result3101.Output.Result) > 0 {
  8037. var errMsgs []string
  8038. for _, item := range result3101.Output.Result {
  8039. errMsgs = append(errMsgs, item.VolaCont)
  8040. }
  8041. c.ServeSuccessJSON(map[string]interface{}{
  8042. "failed_code": -10,
  8043. "msg": errMsgs,
  8044. })
  8045. return
  8046. } else {
  8047. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8048. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8049. bas := strings.Split(psn_info.CardInfo, "|")
  8050. if his.IdCardType == 1 {
  8051. cert_no = bas[2]
  8052. } else if his.IdCardType == 3 {
  8053. cert_no = his.Certno
  8054. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8055. } else if his.IdCardType == 4 {
  8056. cert_no = his.Certno
  8057. psn_info.VerifyNumber = psn_info.VerifyNumber
  8058. }
  8059. var api string
  8060. if miConfig.MdtrtareaAdmvs == "320921" {
  8061. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8062. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8063. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8064. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8065. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8066. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8067. "&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
  8068. } else {
  8069. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8070. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8071. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8073. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8074. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8075. "&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
  8076. }
  8077. resp, requestErr := http.Get(api)
  8078. if requestErr != nil {
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. return
  8081. }
  8082. body, ioErr := ioutil.ReadAll(resp.Body)
  8083. if ioErr != nil {
  8084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8086. return
  8087. }
  8088. var respJSON map[string]interface{}
  8089. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8095. result, _ := json.Marshal(respJSON)
  8096. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8097. utils.ErrorLog("解析失败:%v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8102. res.Output = resSeven10265.Output
  8103. res.ErrMsg = resSeven10265.ErrMsg
  8104. res.Cainfo = resSeven10265.Cainfo
  8105. res.WarnMsg = resSeven10265.WarnMsg
  8106. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8107. res.Infcode = infocode
  8108. }
  8109. }
  8110. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8111. var cert_no string
  8112. if his.IdCardType == 4 {
  8113. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8114. cert_no = psn_info.VerifyNumber
  8115. 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)
  8116. } else if his.IdCardType == 1 {
  8117. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8118. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8119. 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)
  8120. }
  8121. //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)
  8122. var dat map[string]interface{}
  8123. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8124. fmt.Println(dat)
  8125. } else {
  8126. fmt.Println(err)
  8127. }
  8128. saveLog(result2, src_resquest, "2207", "结算")
  8129. userJSONBytes, _ := json.Marshal(dat)
  8130. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8131. utils.ErrorLog("解析失败:%v", err)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8136. res.Output = resSeven10265.Output
  8137. res.ErrMsg = resSeven10265.ErrMsg
  8138. res.Cainfo = resSeven10265.Cainfo
  8139. res.WarnMsg = resSeven10265.WarnMsg
  8140. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8141. res.Infcode = infocode
  8142. } else {
  8143. if miConfig.Code == "H15049901371" {
  8144. //赤峰地区国家医保医疗类别
  8145. //职工透析:医疗类别选特殊情况门诊990502
  8146. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8147. var med_type string
  8148. if his.Insutype == "390" {
  8149. if reg_type == 14 {
  8150. med_type = "9933"
  8151. } else if reg_type == 11 {
  8152. med_type = "11"
  8153. }
  8154. } else if his.Insutype == "310" {
  8155. if reg_type == 14 {
  8156. med_type = "990502"
  8157. } else if reg_type == 11 {
  8158. med_type = "11"
  8159. }
  8160. }
  8161. 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, "")
  8162. } else {
  8163. if his.IdCardType == 4 {
  8164. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8165. var token string
  8166. token = psn_info.VerifyNumber
  8167. 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)
  8168. } else {
  8169. 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, "")
  8170. }
  8171. }
  8172. //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)
  8173. var dat map[string]interface{}
  8174. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8175. fmt.Println(dat)
  8176. } else {
  8177. fmt.Println(err)
  8178. }
  8179. saveLog(result2, src_resquest, "2207", "结算")
  8180. userJSONBytes, _ := json.Marshal(dat)
  8181. if miConfig.Code == "H15049901371" {
  8182. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8183. utils.ErrorLog("解析失败:%v", err)
  8184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8185. return
  8186. }
  8187. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8188. res.Output = resSeven10265.Output
  8189. res.ErrMsg = resSeven10265.ErrMsg
  8190. res.Cainfo = resSeven10265.Cainfo
  8191. res.WarnMsg = resSeven10265.WarnMsg
  8192. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8193. res.Infcode = infocode
  8194. } else {
  8195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8196. utils.ErrorLog("解析失败:%v", err)
  8197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. return
  8199. }
  8200. }
  8201. }
  8202. if res.Infcode != 0 {
  8203. errlog := &models.HisOrderError{
  8204. UserOrgId: adminUser.CurrentOrgId,
  8205. Ctime: time.Now().Unix(),
  8206. Mtime: time.Now().Unix(),
  8207. Number: chrg_bchno,
  8208. ErrMsg: res.ErrMsg,
  8209. Status: 1,
  8210. PatientId: id,
  8211. RecordTime: recordDateTime,
  8212. Stage: 6,
  8213. }
  8214. service.CreateErrMsgLog(errlog)
  8215. c.ServeSuccessJSON(map[string]interface{}{
  8216. "failed_code": -10,
  8217. "msg": res.ErrMsg,
  8218. })
  8219. return
  8220. } else {
  8221. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8222. order.OrderStatus = 2
  8223. order.Status = 1
  8224. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8225. order.SetlId = res.Output.Setlinfo.SetlID
  8226. order.PsnNo = res.Output.Setlinfo.PsnNo
  8227. order.PsnName = res.Output.Setlinfo.PsnName
  8228. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8229. order.Certno = res.Output.Setlinfo.Certno
  8230. order.Gend = res.Output.Setlinfo.Gend
  8231. order.Naty = res.Output.Setlinfo.Naty
  8232. order.Age = res.Output.Setlinfo.Age
  8233. order.Insutype = res.Output.Setlinfo.Insutype
  8234. order.PsnType = res.Output.Setlinfo.PsnType
  8235. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8236. order.SetlTime = res.Output.Setlinfo.SetlTime
  8237. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8238. if res.Output.Setlinfo.MedType == "140101" {
  8239. order.MedType = "14"
  8240. } else {
  8241. order.MedType = res.Output.Setlinfo.MedType
  8242. }
  8243. if reg_type == 1112 {
  8244. order.MedType = "1112"
  8245. }
  8246. if reg_type == 1111 {
  8247. order.MedType = "1111"
  8248. }
  8249. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8250. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8251. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8252. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8253. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8254. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8255. order.HifpPay = res.Output.Setlinfo.HifpPay
  8256. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8257. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8258. order.HifesPay = res.Output.Setlinfo.HifesPay
  8259. order.HifobPay = res.Output.Setlinfo.HifobPay
  8260. order.MafPay = res.Output.Setlinfo.MafPay
  8261. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8262. order.OthPay = res.Output.Setlinfo.OthPay
  8263. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8264. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8265. order.AcctPay = res.Output.Setlinfo.AcctPay
  8266. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8267. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8268. order.Balc = res.Output.Setlinfo.Balc
  8269. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8270. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8271. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8272. order.ClrType = res.Output.Setlinfo.ClrType
  8273. order.ClrWay = res.Output.Setlinfo.ClrWay
  8274. order.Creator = order.Creator
  8275. order.Modify = roles.AdminUserId
  8276. order.RequestLog = src_resquest
  8277. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8278. detailStr := string(setlDetail)
  8279. order.SetlDetail = detailStr
  8280. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8281. err = service.UpDateOrder(order)
  8282. if err == nil {
  8283. //判断是否使用了押金
  8284. if dec_way == "true" {
  8285. tmpstring := strconv.FormatInt(order.ID, 10)
  8286. order.Decimal = decimal
  8287. service.UpDateOrder(order)
  8288. //扣押金
  8289. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8290. if errmsg != nil {
  8291. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8292. return
  8293. }
  8294. }
  8295. c.ServeSuccessJSON(map[string]interface{}{
  8296. "msg": "结算成功",
  8297. })
  8298. } else {
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8300. return
  8301. }
  8302. }
  8303. } else {
  8304. adminUser := c.GetAdminUserInfo()
  8305. errlog := &models.HisOrderError{
  8306. UserOrgId: adminUser.CurrentOrgId,
  8307. Ctime: time.Now().Unix(),
  8308. Mtime: time.Now().Unix(),
  8309. ErrMsg: res.ErrMsg,
  8310. Status: 1,
  8311. PatientId: id,
  8312. RecordTime: recordDateTime,
  8313. Stage: 4,
  8314. }
  8315. service.CreateErrMsgLog(errlog)
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8317. return
  8318. }
  8319. } else {
  8320. adminUser := c.GetAdminUserInfo()
  8321. errlog := &models.HisOrderError{
  8322. UserOrgId: adminUser.CurrentOrgId,
  8323. Ctime: time.Now().Unix(),
  8324. Mtime: time.Now().Unix(),
  8325. ErrMsg: res.ErrMsg,
  8326. Status: 1,
  8327. PatientId: id,
  8328. RecordTime: recordDateTime,
  8329. Stage: 4,
  8330. }
  8331. service.CreateErrMsgLog(errlog)
  8332. c.ServeSuccessJSON(map[string]interface{}{
  8333. "failed_code": -10,
  8334. "msg": res.ErrMsg,
  8335. })
  8336. return
  8337. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8338. //return
  8339. }
  8340. }
  8341. }
  8342. } else if tempOrder.ID > 0 {
  8343. if tempOrder.IsPre == 1 {
  8344. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8345. var rf []*ResultFive
  8346. json.Unmarshal([]byte(his.Iinfo), &rf)
  8347. chrg_bchno := tempOrder.Number
  8348. cert_no := his.Certno
  8349. var insutypes []string
  8350. var insutype string
  8351. var is390 int = 0
  8352. var is310 int = 0
  8353. for _, item := range rf {
  8354. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8355. insutypes = append(insutypes, item.Insutype)
  8356. }
  8357. }
  8358. if len(insutypes) == 1 {
  8359. insutype = insutypes[0]
  8360. } else {
  8361. for _, i := range insutypes {
  8362. if i == "390" {
  8363. is390 = 1
  8364. }
  8365. if i == "310" {
  8366. is310 = 1
  8367. }
  8368. }
  8369. }
  8370. if is390 == 1 {
  8371. insutype = "390"
  8372. }
  8373. if is310 == 1 {
  8374. insutype = "310"
  8375. }
  8376. if len(insutypes) == 0 {
  8377. insutype = "310"
  8378. }
  8379. if len(insutypes) == 2 {
  8380. insutype = strconv.FormatInt(his.SocialType, 64)
  8381. }
  8382. //insutype = "390"
  8383. if his.IdCardType == 1 {
  8384. // cert_no = his.MedicalInsuranceNumber
  8385. cert_no = his.Certno
  8386. } else {
  8387. cert_no = his.Certno
  8388. }
  8389. var res ResultSeven
  8390. var resSeven10265 ResultSeven10265
  8391. var src_resquest string
  8392. var result2 string
  8393. var acct_used_flag string
  8394. fmt.Println("pay_way")
  8395. fmt.Println(pay_way)
  8396. fmt.Println("pay_way")
  8397. if pay_way == 4 {
  8398. acct_used_flag = "1"
  8399. } else {
  8400. acct_used_flag = "0"
  8401. }
  8402. if miConfig.MdtrtareaAdmvs == "421300" {
  8403. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8404. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8405. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8406. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8407. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8408. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8409. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8410. resp, requestErr := http.Get(api)
  8411. if requestErr != nil {
  8412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. return
  8414. }
  8415. body, ioErr := ioutil.ReadAll(resp.Body)
  8416. if ioErr != nil {
  8417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. var respJSON map[string]interface{}
  8422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8428. result, _ := json.Marshal(respJSON)
  8429. fmt.Println("log")
  8430. fmt.Println(string(result))
  8431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8437. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8438. if result3101.Infcode == "0" {
  8439. if len(result3101.Output.Result) > 0 {
  8440. var errMsgs []string
  8441. for _, item := range result3101.Output.Result {
  8442. errMsgs = append(errMsgs, item.VolaCont)
  8443. }
  8444. c.ServeSuccessJSON(map[string]interface{}{
  8445. "failed_code": -10,
  8446. "msg": errMsgs,
  8447. })
  8448. return
  8449. } else {
  8450. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8451. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8452. bas := strings.Split(psn_info.CardInfo, "|")
  8453. if his.IdCardType == 1 {
  8454. cert_no = bas[2]
  8455. } else if his.IdCardType == 3 {
  8456. cert_no = his.Certno
  8457. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8458. } else if his.IdCardType == 4 {
  8459. cert_no = his.Certno
  8460. psn_info.VerifyNumber = psn_info.VerifyNumber
  8461. }
  8462. //江苏地区国家医保医疗类别
  8463. //职工透析:医疗类别选特殊情况门诊9933
  8464. //居民血透门慢: 医疗类别选门诊慢病1402
  8465. //var med_type string
  8466. //if his.Insutype == "310" {
  8467. // if reg_type == 14 {
  8468. // med_type = "9933"
  8469. // } else if reg_type == 11 {
  8470. // med_type = "11"
  8471. //
  8472. // }
  8473. //} else if his.Insutype == "390" {
  8474. // if reg_type == 14 {
  8475. // med_type = "1402"
  8476. // } else if reg_type == 11 {
  8477. // med_type = "11"
  8478. // }
  8479. //}
  8480. var api string
  8481. if miConfig.MdtrtareaAdmvs == "320921" {
  8482. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8483. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8484. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8485. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8486. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8487. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8488. "&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
  8489. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8490. } else {
  8491. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8492. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8493. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8494. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8496. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8497. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8498. "&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
  8499. }
  8500. resp, requestErr := http.Get(api)
  8501. if requestErr != nil {
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. body, ioErr := ioutil.ReadAll(resp.Body)
  8506. if ioErr != nil {
  8507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8509. return
  8510. }
  8511. var respJSON map[string]interface{}
  8512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8515. return
  8516. }
  8517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8518. result, _ := json.Marshal(respJSON)
  8519. fmt.Println("log")
  8520. fmt.Println(string(result))
  8521. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8522. utils.ErrorLog("解析失败:%v", err)
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8524. return
  8525. }
  8526. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8527. res.Output = resSeven10265.Output
  8528. res.ErrMsg = resSeven10265.ErrMsg
  8529. res.Cainfo = resSeven10265.Cainfo
  8530. res.WarnMsg = resSeven10265.WarnMsg
  8531. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8532. res.Infcode = infocode
  8533. }
  8534. }
  8535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8536. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8537. var cert_no string
  8538. if his.IdCardType == 1 {
  8539. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8540. } else {
  8541. cert_no = psn_info.VerifyNumber
  8542. }
  8543. 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)
  8544. var dat map[string]interface{}
  8545. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8546. fmt.Println(dat)
  8547. } else {
  8548. fmt.Println(err)
  8549. }
  8550. saveLog(result2, src_resquest, "2207", "结算")
  8551. userJSONBytes, _ := json.Marshal(dat)
  8552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8553. utils.ErrorLog("解析失败:%v", err)
  8554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8555. return
  8556. }
  8557. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8558. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8559. var cert_no string
  8560. if his.IdCardType == 1 {
  8561. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8562. } else if his.IdCardType == 2 {
  8563. cert_no = his.IdCardNo
  8564. } else {
  8565. cert_no = psn_info.VerifyNumber
  8566. }
  8567. 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, "")
  8568. var dat map[string]interface{}
  8569. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8570. fmt.Println(dat)
  8571. } else {
  8572. fmt.Println(err)
  8573. }
  8574. saveLog(result2, src_resquest, "2207", "结算")
  8575. userJSONBytes, _ := json.Marshal(dat)
  8576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8577. utils.ErrorLog("解析失败:%v", err)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8582. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8583. var cert_no string
  8584. if his.IdCardType == 1 {
  8585. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8586. } else if his.IdCardType == 2 {
  8587. cert_no = his.IdCardNo
  8588. } else {
  8589. cert_no = psn_info.VerifyNumber
  8590. }
  8591. 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, "")
  8592. var dat map[string]interface{}
  8593. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8594. fmt.Println(dat)
  8595. } else {
  8596. fmt.Println(err)
  8597. }
  8598. saveLog(result2, src_resquest, "2207", "结算")
  8599. userJSONBytes, _ := json.Marshal(dat)
  8600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8601. utils.ErrorLog("解析失败:%v", err)
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8603. return
  8604. }
  8605. } else {
  8606. var src_resquest string
  8607. if miConfig.Code == "H15049901371" {
  8608. //赤峰地区国家医保医疗类别
  8609. //职工透析:医疗类别选特殊情况门诊990502
  8610. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8611. var med_type string
  8612. if his.Insutype == "390" {
  8613. if reg_type == 14 {
  8614. med_type = "9933"
  8615. } else if reg_type == 11 {
  8616. med_type = "11"
  8617. }
  8618. } else if his.Insutype == "310" {
  8619. if reg_type == 14 {
  8620. med_type = "990502"
  8621. } else if reg_type == 11 {
  8622. med_type = "11"
  8623. }
  8624. }
  8625. 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, "")
  8626. } else {
  8627. if his.IdCardType == 4 {
  8628. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8629. token := psn_info.VerifyNumber
  8630. 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)
  8631. } else {
  8632. 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, "")
  8633. }
  8634. }
  8635. var dat map[string]interface{}
  8636. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8637. fmt.Println(dat)
  8638. } else {
  8639. fmt.Println(err)
  8640. }
  8641. saveLog(result2, src_resquest, "2207", "结算")
  8642. userJSONBytes, _ := json.Marshal(dat)
  8643. if miConfig.Code == "H15049901371" {
  8644. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8645. utils.ErrorLog("解析失败:%v", err)
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8650. res.Output = resSeven10265.Output
  8651. res.ErrMsg = resSeven10265.ErrMsg
  8652. res.Cainfo = resSeven10265.Cainfo
  8653. res.WarnMsg = resSeven10265.WarnMsg
  8654. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8655. res.Infcode = infocode
  8656. } else {
  8657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8658. utils.ErrorLog("解析失败:%v", err)
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. }
  8663. }
  8664. if res.Infcode != 0 {
  8665. errlog := &models.HisOrderError{
  8666. UserOrgId: adminUser.CurrentOrgId,
  8667. Ctime: time.Now().Unix(),
  8668. Mtime: time.Now().Unix(),
  8669. Number: chrg_bchno,
  8670. ErrMsg: res.ErrMsg,
  8671. Status: 1,
  8672. PatientId: id,
  8673. RecordTime: recordDateTime,
  8674. Stage: 6,
  8675. }
  8676. service.CreateErrMsgLog(errlog)
  8677. c.ServeSuccessJSON(map[string]interface{}{
  8678. "failed_code": -10,
  8679. "msg": res.ErrMsg,
  8680. })
  8681. return
  8682. } else {
  8683. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8684. order.OrderStatus = 2
  8685. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8686. order.SetlId = res.Output.Setlinfo.SetlID
  8687. order.PsnNo = res.Output.Setlinfo.PsnNo
  8688. order.PsnName = res.Output.Setlinfo.PsnName
  8689. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8690. order.Certno = res.Output.Setlinfo.Certno
  8691. order.Gend = res.Output.Setlinfo.Gend
  8692. order.Naty = res.Output.Setlinfo.Naty
  8693. order.Age = res.Output.Setlinfo.Age
  8694. order.Insutype = res.Output.Setlinfo.Insutype
  8695. order.PsnType = res.Output.Setlinfo.PsnType
  8696. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8697. order.SetlTime = res.Output.Setlinfo.SetlTime
  8698. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8699. //order.MedType = res.Output.Setlinfo.MedType
  8700. if reg_type == 1112 {
  8701. order.MedType = "1112"
  8702. }
  8703. if reg_type == 1111 {
  8704. order.MedType = "1111"
  8705. }
  8706. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8707. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8708. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8709. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8710. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8711. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8712. order.HifpPay = res.Output.Setlinfo.HifpPay
  8713. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8714. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8715. order.HifesPay = res.Output.Setlinfo.HifesPay
  8716. order.HifobPay = res.Output.Setlinfo.HifobPay
  8717. order.MafPay = res.Output.Setlinfo.MafPay
  8718. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8719. order.OthPay = res.Output.Setlinfo.OthPay
  8720. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8721. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8722. order.AcctPay = res.Output.Setlinfo.AcctPay
  8723. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8724. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8725. order.Balc = res.Output.Setlinfo.Balc
  8726. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8727. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8728. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8729. order.ClrWay = res.Output.Setlinfo.ClrWay
  8730. order.Creator = order.Creator
  8731. order.Modify = roles.AdminUserId
  8732. order.RequestLog = src_resquest
  8733. order.Diagnosis = diagnosis_id
  8734. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8735. detailStr := string(setlDetail)
  8736. order.SetlDetail = detailStr
  8737. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8738. err = service.UpDateOrder(order)
  8739. if err == nil {
  8740. //判断是否使用了押金
  8741. if dec_way == "true" {
  8742. tmpstring := strconv.FormatInt(order.ID, 10)
  8743. //扣押金
  8744. order.Decimal = decimal
  8745. service.UpDateOrder(order)
  8746. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8747. if errmsg != nil {
  8748. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8749. return
  8750. }
  8751. }
  8752. c.ServeSuccessJSON(map[string]interface{}{
  8753. "msg": "结算成功",
  8754. })
  8755. } else {
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8757. return
  8758. }
  8759. }
  8760. }
  8761. }
  8762. }
  8763. //func (c *HisApiController) GetPreUploadInfo() {
  8764. // id, _ := c.GetInt64("id")
  8765. // record_time := c.GetString("record_time")
  8766. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8767. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8768. //
  8769. // timeLayout := "2006-01-02"
  8770. // loc, _ := time.LoadLocation("Local")
  8771. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8772. // if err != nil {
  8773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8774. // return
  8775. // }
  8776. // recordDateTime := theTime.Unix()
  8777. // adminUser := c.GetAdminUserInfo()
  8778. //
  8779. // var prescriptions []*models.HisPrescription
  8780. //
  8781. // var start_time int64
  8782. // var end_time int64
  8783. //
  8784. // data := make(map[string]interface{})
  8785. // if settle_accounts_type == 1 { //日结
  8786. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8787. // data["pre"] = prescriptions
  8788. //
  8789. // } else { //月结
  8790. // start_time_str := c.GetString("start_time")
  8791. // end_time_str := c.GetString("end_time")
  8792. // timeLayout := "2006-01-02"
  8793. // loc, _ := time.LoadLocation("Local")
  8794. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8795. // if err != nil {
  8796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8797. // return
  8798. // }
  8799. // recordStartTime := theStartTime.Unix()
  8800. // start_time = recordStartTime
  8801. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8802. // if err != nil {
  8803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8804. // return
  8805. // }
  8806. // recordEndTime := theEndTime.Unix()
  8807. // end_time = recordEndTime
  8808. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8809. // data["pre"] = prescriptions
  8810. //
  8811. // }
  8812. //
  8813. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8814. //
  8815. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8816. // timestamp := time.Now().Unix()
  8817. // tempTime := time.Unix(timestamp, 0)
  8818. // timeFormat := tempTime.Format("20060102150405")
  8819. // chrgBchno := rand.Intn(100000) + 10000
  8820. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8821. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8822. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8823. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8824. // strconv.FormatInt(his.PatientId, 10)
  8825. // client := &http.Client{}
  8826. // data["psn_no"] = his.PsnNo
  8827. // data["mdtrt_id"] = his.Number
  8828. // data["chrg_bchno"] = chrg_bchno
  8829. // data["org_name"] = miConfig.OrgName
  8830. // data["doctor"] = roles.UserName
  8831. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8832. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8833. // data["fixmedins_code"] = miConfig.Code
  8834. // data["dept_code"] = department.Number
  8835. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8836. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8837. // data["secret_key"] = miConfig.SecretKey
  8838. // var ids []int64
  8839. //
  8840. // for _, item := range prescriptions {
  8841. // ids = append(ids, item.ID)
  8842. // }
  8843. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8844. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8845. // bytesData, _ := json.Marshal(data)
  8846. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8847. // resp, _ := client.Do(req)
  8848. // defer resp.Body.Close()
  8849. // body, ioErr := ioutil.ReadAll(resp.Body)
  8850. // if ioErr != nil {
  8851. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8853. // return
  8854. // }
  8855. // var respJSON map[string]interface{}
  8856. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8857. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. // return
  8860. // }
  8861. //
  8862. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8863. // userJSONBytes, _ := json.Marshal(respJSON)
  8864. // var res ResultFour
  8865. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8866. // utils.ErrorLog("解析失败:%v", err)
  8867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. // return
  8869. // }
  8870. //
  8871. // if res.Infcode == 0 {
  8872. // order := &models.HisOrder{
  8873. // UserOrgId: adminUser.CurrentOrgId,
  8874. // HisPatientId: his.ID,
  8875. // PatientId: his.PatientId,
  8876. // SettleAccountsDate: recordDateTime,
  8877. // Ctime: time.Now().Unix(),
  8878. // Mtime: time.Now().Unix(),
  8879. // Status: 1,
  8880. // Number: chrg_bchno,
  8881. // Infcode: res.Infcode,
  8882. // WarnMsg: res.WarnMsg,
  8883. // Cainfo: res.Cainfo,
  8884. // ErrMsg: res.ErrMsg,
  8885. // RespondTime: res.RefmsgTime,
  8886. // InfRefmsgid: res.InfRefmsgid,
  8887. // OrderStatus: 1,
  8888. // IsMedicineInsurance: 1,
  8889. // SettleType: settle_accounts_type,
  8890. // SettleStartTime: start_time,
  8891. // SettleEndTime: end_time,
  8892. // Creator: roles.ID,
  8893. // Modify: roles.ID,
  8894. // PType: 2,
  8895. // }
  8896. // err = service.CreateOrder(order)
  8897. // if err != nil {
  8898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8899. // return
  8900. // }
  8901. //
  8902. // for _, item := range res.Output.Result {
  8903. // temp := strings.Split(item.FeedetlSn, "-")
  8904. // var advice_id int64 = 0
  8905. // var project_id int64 = 0
  8906. // var types int64 = 0
  8907. //
  8908. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8909. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8910. //
  8911. // if temp[1] == "1" {
  8912. // advice_id = id
  8913. // project_id = 0
  8914. // } else if temp[1] == "2" {
  8915. // advice_id = 0
  8916. // project_id = id
  8917. // }
  8918. //
  8919. // info := &models.HisOrderInfo{
  8920. // OrderNumber: order.Number,
  8921. // FeedetlSn: item.FeedetlSn,
  8922. // UploadDate: time.Now().Unix(),
  8923. // AdviceId: advice_id,
  8924. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8925. // Cnt: item.Cnt,
  8926. // Pric: float64(item.Pric),
  8927. // PatientId: his.PatientId,
  8928. // PricUplmtAmt: item.PricUplmtAmt,
  8929. // SelfpayProp: item.SelfpayProp,
  8930. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8931. // OverlmtAmt: item.OverlmtAmt,
  8932. // PreselfpayAmt: item.PreselfpayAmt,
  8933. // BasMednFlag: item.BasMednFlag,
  8934. // MedChrgitmType: item.MedChrgitmType,
  8935. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8936. // Status: 1,
  8937. // Memo: item.Memo,
  8938. // Mtime: time.Now().Unix(),
  8939. // InscpScpAmt: item.InscpScpAmt,
  8940. // DrtReimFlag: item.DrtReimFlag,
  8941. // Ctime: time.Now().Unix(),
  8942. // ListSpItemFlag: item.ListSpItemFlag,
  8943. // ChldMedcFlag: item.ChldMedcFlag,
  8944. // LmtUsedFlag: item.LmtUsedFlag,
  8945. // ChrgitmLv: item.ChrgitmLv,
  8946. // UserOrgId: adminUser.CurrentOrgId,
  8947. // HisPatientId: his.ID,
  8948. // OrderId: order.ID,
  8949. // ProjectId: project_id,
  8950. // Type: types,
  8951. // }
  8952. // service.CreateOrderInfo(info)
  8953. //
  8954. // }
  8955. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8956. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8957. //
  8958. // var total float64
  8959. // for _, item := range prescriptions {
  8960. // if item.Type == 1 { //药品
  8961. // for _, subItem := range item.HisDoctorAdviceInfo {
  8962. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8963. // }
  8964. // }
  8965. // if item.Type == 2 { //项目
  8966. // for _, subItem := range item.HisPrescriptionProject {
  8967. // total = total + (subItem.Price * float64(subItem.Count))
  8968. // }
  8969. // }
  8970. // }
  8971. //
  8972. // for _, item := range prescriptions {
  8973. // for _, subItem := range item.HisAdditionalCharge {
  8974. // total = total + (subItem.Price * float64(subItem.Count))
  8975. // }
  8976. // }
  8977. //
  8978. // allTotal := fmt.Sprintf("%.2f", total)
  8979. // if res.Infcode == 0 {
  8980. // var rf []*ResultFive
  8981. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8982. // psn_no := his.PsnNo
  8983. // mdtrt_id := his.Number
  8984. // chrg_bchno := chrg_bchno
  8985. // cert_no := his.Certno
  8986. // insutype := rf[0].Insutype
  8987. //
  8988. // if his.IdCardType == 1 {
  8989. // cert_no = his.MedicalInsuranceNumber
  8990. //
  8991. // } else {
  8992. //
  8993. // cert_no = his.Certno
  8994. //
  8995. // }
  8996. //
  8997. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8998. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8999. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9000. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9001. // resp, requestErr := http.Get(api)
  9002. // if requestErr != nil {
  9003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9004. // return
  9005. // }
  9006. // defer resp.Body.Close()
  9007. // body, ioErr := ioutil.ReadAll(resp.Body)
  9008. // if ioErr != nil {
  9009. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. // return
  9012. // }
  9013. // var respJSON map[string]interface{}
  9014. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9015. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9017. // return
  9018. // }
  9019. // fmt.Println(respJSON)
  9020. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9021. // userJSONBytes, _ := json.Marshal(respJSON)
  9022. // var res ResultSeven
  9023. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9024. // utils.ErrorLog("解析失败:%v", err)
  9025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9026. // return
  9027. // }
  9028. // if res.Infcode != 0 {
  9029. // errlog := &models.HisOrderError{
  9030. // UserOrgId: adminUser.CurrentOrgId,
  9031. // Ctime: time.Now().Unix(),
  9032. // Mtime: time.Now().Unix(),
  9033. // Number: chrg_bchno,
  9034. // ErrMsg: res.ErrMsg,
  9035. // Status: 1,
  9036. // PatientId: id,
  9037. // RecordTime: recordDateTime,
  9038. // Stage: 7,
  9039. // }
  9040. // service.CreateErrMsgLog(errlog)
  9041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9042. // return
  9043. // } else {
  9044. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9045. // order.OrderStatus = 1
  9046. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9047. // order.SetlId = res.Output.Setlinfo.SetlID
  9048. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9049. // order.PsnName = res.Output.Setlinfo.PsnName
  9050. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9051. // order.Certno = res.Output.Setlinfo.Certno
  9052. // order.Gend = res.Output.Setlinfo.Gend
  9053. // order.Naty = res.Output.Setlinfo.Naty
  9054. // order.Age = res.Output.Setlinfo.Age
  9055. // order.Insutype = res.Output.Setlinfo.Insutype
  9056. // order.PsnType = res.Output.Setlinfo.PsnType
  9057. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9058. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9059. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9060. // order.MedType = res.Output.Setlinfo.MedType
  9061. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9062. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9063. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9064. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9065. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9066. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9067. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9068. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9069. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9070. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9071. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9072. // order.MafPay = res.Output.Setlinfo.MafPay
  9073. // order.OthPay = res.Output.Setlinfo.OthPay
  9074. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9075. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9076. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9077. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9078. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9079. // order.Balc = res.Output.Setlinfo.Balc
  9080. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9081. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9082. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9083. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9084. // order.Creator = order.Creator
  9085. // order.Modify = roles.ID
  9086. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9087. // detailStr := string(setlDetail)
  9088. // order.SetlDetail = detailStr
  9089. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9090. // err = service.UpDateOrder(order)
  9091. // if err == nil {
  9092. // c.ServeSuccessJSON(map[string]interface{}{
  9093. // "msg": "预结算成功",
  9094. // })
  9095. // } else {
  9096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9097. // return
  9098. // }
  9099. // }
  9100. // } else {
  9101. // adminUser := c.GetAdminUserInfo()
  9102. // errlog := &models.HisOrderError{
  9103. // UserOrgId: adminUser.CurrentOrgId,
  9104. // Ctime: time.Now().Unix(),
  9105. // Mtime: time.Now().Unix(),
  9106. // ErrMsg: res.ErrMsg,
  9107. // Status: 1,
  9108. // PatientId: id,
  9109. // RecordTime: recordDateTime,
  9110. // Stage: 4,
  9111. // }
  9112. // service.CreateErrMsgLog(errlog)
  9113. //
  9114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9115. // return
  9116. // }
  9117. // } else {
  9118. // adminUser := c.GetAdminUserInfo()
  9119. // errlog := &models.HisOrderError{
  9120. // UserOrgId: adminUser.CurrentOrgId,
  9121. // Ctime: time.Now().Unix(),
  9122. // Mtime: time.Now().Unix(),
  9123. // ErrMsg: res.ErrMsg,
  9124. // Status: 1,
  9125. // PatientId: id,
  9126. // RecordTime: recordDateTime,
  9127. // Stage: 4,
  9128. // }
  9129. // service.CreateErrMsgLog(errlog)
  9130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9131. // return
  9132. // }
  9133. //
  9134. // } else {
  9135. // var total float64
  9136. // for _, item := range prescriptions {
  9137. // if item.Type == 1 { //药品
  9138. // for _, subItem := range item.HisDoctorAdviceInfo {
  9139. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9140. // }
  9141. // }
  9142. // if item.Type == 2 { //项目
  9143. // for _, subItem := range item.HisPrescriptionProject {
  9144. // total = total + (subItem.Price * float64(subItem.Count))
  9145. // }
  9146. // }
  9147. //
  9148. // for _, subItem := range item.HisAdditionalCharge {
  9149. // total = total + (subItem.Price * float64(subItem.Count))
  9150. // }
  9151. // }
  9152. //
  9153. // allTotal := fmt.Sprintf("%.2f", total)
  9154. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9155. // order := &models.HisOrder{
  9156. // UserOrgId: adminUser.CurrentOrgId,
  9157. // HisPatientId: his.ID,
  9158. // PatientId: id,
  9159. // SettleAccountsDate: recordDateTime,
  9160. // Ctime: time.Now().Unix(),
  9161. // Mtime: time.Now().Unix(),
  9162. // Status: 1,
  9163. // OrderStatus: 2,
  9164. // Number: chrg_bchno,
  9165. // MedfeeSumamt: totals,
  9166. // }
  9167. // err = service.CreateOrder(order)
  9168. // if err != nil {
  9169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9170. // return
  9171. // }
  9172. //
  9173. // var customs []*Custom
  9174. // for _, item := range prescriptions {
  9175. //
  9176. // if item.Type == 1 { //药品
  9177. // for _, subItem := range item.HisDoctorAdviceInfo {
  9178. // cus := &Custom{
  9179. // AdviceId: subItem.ID,
  9180. // ProjectId: 0,
  9181. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9182. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9183. // FeedetlSn: subItem.FeedetlSn,
  9184. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9185. // MedListCodg: subItem.MedListCodg,
  9186. // Type: 1,
  9187. // }
  9188. // customs = append(customs, cus)
  9189. // }
  9190. // }
  9191. //
  9192. // if item.Type == 2 { //项目
  9193. // for _, subItem := range item.HisPrescriptionProject {
  9194. //
  9195. // cus := &Custom{
  9196. // AdviceId: 0,
  9197. // ProjectId: subItem.ID,
  9198. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9199. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9200. // FeedetlSn: subItem.FeedetlSn,
  9201. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9202. // MedListCodg: subItem.MedListCodg,
  9203. // Type: 2,
  9204. // }
  9205. //
  9206. // customs = append(customs, cus)
  9207. // }
  9208. // }
  9209. //
  9210. // for _, item := range item.HisAdditionalCharge {
  9211. // cus := &Custom{
  9212. // ItemId: item.ID,
  9213. // AdviceId: 0,
  9214. // ProjectId: 0,
  9215. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9216. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9217. // FeedetlSn: item.FeedetlSn,
  9218. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9219. // MedListCodg: item.XtHisAddtionConfig.Code,
  9220. // Type: 3,
  9221. // }
  9222. //
  9223. // customs = append(customs, cus)
  9224. // }
  9225. //
  9226. // }
  9227. //
  9228. // for _, item := range customs {
  9229. // var advice_id int64 = 0
  9230. // var project_id int64 = 0
  9231. // var item_id int64 = 0
  9232. //
  9233. // var types int64 = 0
  9234. //
  9235. // if item.Type == 1 {
  9236. // advice_id = item.AdviceId
  9237. // project_id = 0
  9238. // item_id = 0
  9239. // } else if item.Type == 2 {
  9240. // advice_id = 0
  9241. // item_id = 0
  9242. //
  9243. // project_id = item.ProjectId
  9244. // } else if item.Type == 3 {
  9245. // advice_id = 0
  9246. // item_id = item.ItemId
  9247. // project_id = 0
  9248. // }
  9249. //
  9250. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9251. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9252. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9253. //
  9254. // info := &models.HisOrderInfo{
  9255. // OrderNumber: order.Number,
  9256. // UploadDate: time.Now().Unix(),
  9257. // AdviceId: advice_id,
  9258. // DetItemFeeSumamt: detItemFeeSumamt,
  9259. // Cnt: cut,
  9260. // Pric: pric,
  9261. // PatientId: id,
  9262. // Status: 1,
  9263. // Mtime: time.Now().Unix(),
  9264. // Ctime: time.Now().Unix(),
  9265. // UserOrgId: adminUser.CurrentOrgId,
  9266. // HisPatientId: his.ID,
  9267. // OrderId: order.ID,
  9268. // ProjectId: project_id,
  9269. // Type: types,
  9270. // ItemId: item_id,
  9271. // }
  9272. // service.CreateOrderInfo(info)
  9273. // }
  9274. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9275. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9276. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9277. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9278. // if err == nil {
  9279. // c.ServeSuccessJSON(map[string]interface{}{
  9280. // "msg": "结算成功",
  9281. // })
  9282. // } else {
  9283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9284. // return
  9285. // }
  9286. // }
  9287. //}
  9288. //上传明细-预结算-
  9289. func (c *HisApiController) GetPreUploadInfo() {
  9290. id, _ := c.GetInt64("id")
  9291. record_time := c.GetString("record_time")
  9292. his_patient_id, _ := c.GetInt64("his_patient_id")
  9293. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9294. admin_user_id, _ := c.GetInt64("admin_user_id")
  9295. diagnosis_id := c.GetString("diagnosis")
  9296. sick_type, _ := c.GetInt64("sick_type")
  9297. reg_type, _ := c.GetInt64("p_type")
  9298. begin_time := c.GetString("begin_time")
  9299. id_str := c.GetString("ids")
  9300. ids_arr := strings.Split(id_str, ",")
  9301. timeLayout := "2006-01-02"
  9302. loc, _ := time.LoadLocation("Local")
  9303. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9304. if err != nil {
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9306. return
  9307. }
  9308. recordDateTime := theTime.Unix()
  9309. adminUser := c.GetAdminUserInfo()
  9310. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9311. var config []*models.HisXtDiagnoseConfig
  9312. for _, item := range diagnosis_ids {
  9313. id, _ := strconv.ParseInt(item, 10, 64)
  9314. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9315. config = append(config, &diagnosisConfig)
  9316. }
  9317. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9318. sickConfig, _ := service.FindSickById(sick_type)
  9319. var prescriptions []*models.HisPrescription
  9320. var start_time int64
  9321. var end_time int64
  9322. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9323. fmt.Println(his_patient_id)
  9324. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9325. timestamp := time.Now().Unix()
  9326. tempTime := time.Unix(timestamp, 0)
  9327. timeFormat := tempTime.Format("20060102150405")
  9328. chrgBchno := rand.Intn(100000) + 10000
  9329. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9330. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9331. var patientPrescription models.HisPrescriptionInfo
  9332. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9333. if patientPrescription.ID == 0 {
  9334. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9335. }
  9336. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9337. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9338. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9339. strconv.FormatInt(his.PatientId, 10)
  9340. var res2 ResultSix
  9341. var resSix10265 ResultSix10265
  9342. //var time_stamp string
  9343. if miConfig.MdtrtareaAdmvs == "421300" {
  9344. data := make(map[string]interface{})
  9345. client := &http.Client{}
  9346. data["psn_no"] = his.PsnNo
  9347. data["mdtrt_id"] = his.Number
  9348. data["department"] = department.Name
  9349. data["org_name"] = miConfig.OrgName
  9350. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9351. data["doctor_id"] = doctor_info.DoctorNumber
  9352. data["doctor_name"] = roles.UserName
  9353. data["fixmedins_code"] = miConfig.Code
  9354. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9355. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9356. data["secret_key"] = miConfig.SecretKey
  9357. data["sick_code"] = sickConfig.CountryCode
  9358. data["sick_name"] = sickConfig.ClassName
  9359. data["begin_time"] = begin_time
  9360. data["dept"] = strconv.FormatInt(department.ID, 10)
  9361. data["config"] = config
  9362. data["opter"] = roles.UserName
  9363. fmt.Println(data)
  9364. bytesData, _ := json.Marshal(data)
  9365. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9366. resp, _ := client.Do(req)
  9367. defer resp.Body.Close()
  9368. body, ioErr := ioutil.ReadAll(resp.Body)
  9369. if ioErr != nil {
  9370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. var respJSON map[string]interface{}
  9375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9381. userJSONBytes, _ := json.Marshal(respJSON)
  9382. fmt.Println("log")
  9383. fmt.Println(string(userJSONBytes))
  9384. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9385. utils.ErrorLog("解析失败:%v", err)
  9386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9387. return
  9388. }
  9389. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9390. data := make(map[string]interface{})
  9391. client := &http.Client{}
  9392. data["psn_no"] = his.PsnNo
  9393. data["mdtrt_id"] = his.Number
  9394. data["doctor"] = roles.UserName
  9395. data["department"] = department.Name
  9396. data["org_name"] = miConfig.OrgName
  9397. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9398. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9399. data["fixmedins_code"] = miConfig.Code
  9400. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9401. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9402. data["secret_key"] = miConfig.SecretKey
  9403. data["sick_code"] = sickConfig.CountryCode
  9404. data["sick_name"] = sickConfig.ClassName
  9405. data["begin_time"] = begin_time
  9406. data["dept"] = strconv.FormatInt(department.ID, 10)
  9407. data["config"] = config
  9408. data["url"] = miConfig.Url
  9409. data["ak"] = miConfig.AccessKey
  9410. data["cainfo"] = miConfig.Cainfo
  9411. bytesData, _ := json.Marshal(data)
  9412. var req *http.Request
  9413. if miConfig.MdtrtareaAdmvs == "320921" {
  9414. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9415. } else {
  9416. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9417. }
  9418. resp, _ := client.Do(req)
  9419. defer resp.Body.Close()
  9420. body, ioErr := ioutil.ReadAll(resp.Body)
  9421. if ioErr != nil {
  9422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9424. return
  9425. }
  9426. var respJSON map[string]interface{}
  9427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9430. return
  9431. }
  9432. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9433. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9434. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9436. userJSONBytes, _ := json.Marshal(respJSON)
  9437. fmt.Println("log")
  9438. fmt.Println(string(userJSONBytes))
  9439. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9440. utils.ErrorLog("解析失败:%v", err)
  9441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9442. return
  9443. }
  9444. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9445. res2.Output = resSix10265.Output
  9446. res2.ErrMsg = resSix10265.ErrMsg
  9447. res2.Cainfo = resSix10265.Cainfo
  9448. res2.WarnMsg = resSix10265.WarnMsg
  9449. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9450. res2.Infcode = infocode
  9451. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9452. 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)
  9453. saveLog(result, requestLog, "2203", "上传就诊信息")
  9454. var respJSON2 map[string]interface{}
  9455. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9458. return
  9459. }
  9460. userJSONBytes2, _ := json.Marshal(respJSON2)
  9461. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9462. utils.ErrorLog("解析失败:%v", err)
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. return
  9465. }
  9466. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9467. var result string
  9468. var requestLog string
  9469. 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, "")
  9470. saveLog(result, requestLog, "2203", "上传就诊信息")
  9471. var respJSON2 map[string]interface{}
  9472. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. return
  9476. }
  9477. userJSONBytes2, _ := json.Marshal(respJSON2)
  9478. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9479. utils.ErrorLog("解析失败:%v", err)
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9484. var result string
  9485. var requestLog string
  9486. 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, "")
  9487. saveLog(result, requestLog, "2203", "上传就诊信息")
  9488. var respJSON2 map[string]interface{}
  9489. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9492. return
  9493. }
  9494. userJSONBytes2, _ := json.Marshal(respJSON2)
  9495. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9496. utils.ErrorLog("解析失败:%v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. } else {
  9501. var result string
  9502. var requestLog string
  9503. if miConfig.MdtrtareaAdmvs == "440781" { //
  9504. 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)
  9505. } else {
  9506. if miConfig.Code == "H15049901371" {
  9507. //赤峰地区国家医保医疗类别
  9508. //职工透析:医疗类别选特殊情况门诊990502
  9509. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9510. var med_type string
  9511. if his.Insutype == "390" {
  9512. if reg_type == 14 {
  9513. med_type = "9933"
  9514. } else if reg_type == 11 {
  9515. med_type = "11"
  9516. }
  9517. } else if his.Insutype == "310" {
  9518. if reg_type == 14 {
  9519. med_type = "990502"
  9520. } else if reg_type == 11 {
  9521. med_type = "11"
  9522. }
  9523. }
  9524. 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)
  9525. } else {
  9526. 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)
  9527. }
  9528. saveLog(result, requestLog, "2203", "上传就诊信息")
  9529. var respJSON2 map[string]interface{}
  9530. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9533. return
  9534. }
  9535. userJSONBytes2, _ := json.Marshal(respJSON2)
  9536. if miConfig.Code == "H15049901371" {
  9537. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9538. utils.ErrorLog("解析失败:%v", err)
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9540. return
  9541. }
  9542. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9543. res2.Output = resSix10265.Output
  9544. res2.ErrMsg = resSix10265.ErrMsg
  9545. res2.Cainfo = resSix10265.Cainfo
  9546. res2.WarnMsg = resSix10265.WarnMsg
  9547. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9548. res2.Infcode = infocode
  9549. } else {
  9550. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9551. utils.ErrorLog("解析失败:%v", err)
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9553. return
  9554. }
  9555. }
  9556. }
  9557. }
  9558. if res2.Infcode != 0 {
  9559. adminUser := c.GetAdminUserInfo()
  9560. errlog := &models.HisOrderError{
  9561. UserOrgId: adminUser.CurrentOrgId,
  9562. Ctime: time.Now().Unix(),
  9563. Mtime: time.Now().Unix(),
  9564. ErrMsg: res2.ErrMsg,
  9565. Status: 1,
  9566. PatientId: id,
  9567. RecordTime: recordDateTime,
  9568. Stage: 3,
  9569. }
  9570. service.CreateErrMsgLog(errlog)
  9571. c.ServeSuccessJSON(map[string]interface{}{
  9572. "failed_code": -10,
  9573. "msg": res2.ErrMsg,
  9574. })
  9575. return
  9576. } else {
  9577. his.Diagnosis = diagnosis_id
  9578. his.SickType = sickConfig.ID
  9579. his.PType = fmt.Sprintf("%d", reg_type)
  9580. service.UpdateHisPatientThree(&his)
  9581. data := make(map[string]interface{})
  9582. if settle_accounts_type == 1 { //日结
  9583. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9584. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9585. } else {
  9586. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9587. }
  9588. data["pre"] = prescriptions
  9589. } else { //月结
  9590. start_time_str := c.GetString("start_time")
  9591. end_time_str := c.GetString("end_time")
  9592. timeLayout := "2006-01-02"
  9593. loc, _ := time.LoadLocation("Local")
  9594. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9595. if err != nil {
  9596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9597. return
  9598. }
  9599. recordStartTime := theStartTime.Unix()
  9600. start_time = recordStartTime
  9601. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9602. if err != nil {
  9603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9604. return
  9605. }
  9606. recordEndTime := theEndTime.Unix()
  9607. end_time = recordEndTime
  9608. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9609. data["pre"] = prescriptions
  9610. }
  9611. client := &http.Client{}
  9612. data["psn_no"] = his.PsnNo
  9613. data["mdtrt_id"] = his.Number
  9614. data["chrg_bchno"] = chrg_bchno
  9615. data["org_name"] = miConfig.OrgName
  9616. data["doctor"] = doctor_info.UserName
  9617. data["doctor_id"] = doctor_info.DoctorNumber
  9618. data["dept"] = department.Name
  9619. data["fixmedins_code"] = miConfig.Code
  9620. data["opter"] = roles.UserName
  9621. data["dept_code"] = department.Number
  9622. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9624. data["secret_key"] = miConfig.SecretKey
  9625. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9626. data["url"] = miConfig.Url
  9627. data["ak"] = miConfig.AccessKey
  9628. data["new_doctor_name"] = patientPrescription.Doctor
  9629. data["diag_code"] = sickConfig.CountryCode
  9630. data["cainfo"] = miConfig.Cainfo
  9631. data["opter"] = roles.UserName
  9632. var ids []int64
  9633. for _, item := range prescriptions {
  9634. ids = append(ids, item.ID)
  9635. }
  9636. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9637. if config.IsOpen == 1 { //对接了医保,走医保流程
  9638. var res ResultFour
  9639. var resFour10265 ResultFour10265
  9640. if miConfig.MdtrtareaAdmvs == "421300" {
  9641. bytesData, _ := json.Marshal(data)
  9642. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9643. resp, _ := client.Do(req)
  9644. defer resp.Body.Close()
  9645. body, ioErr := ioutil.ReadAll(resp.Body)
  9646. if ioErr != nil {
  9647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9649. return
  9650. }
  9651. var respJSON map[string]interface{}
  9652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. return
  9656. }
  9657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9658. userJSONBytes, _ := json.Marshal(respJSON)
  9659. fmt.Println("log")
  9660. fmt.Println(string(userJSONBytes))
  9661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9662. utils.ErrorLog("解析失败:%v", err)
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9664. return
  9665. }
  9666. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9667. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9668. if result3101.Infcode == "0" {
  9669. if len(result3101.Output.Result) > 0 {
  9670. var errMsgs []string
  9671. for _, item := range result3101.Output.Result {
  9672. errMsgs = append(errMsgs, item.VolaCont)
  9673. }
  9674. c.ServeSuccessJSON(map[string]interface{}{
  9675. "failed_code": -10,
  9676. "msg": errMsgs,
  9677. })
  9678. return
  9679. } else {
  9680. if miConfig.MdtrtareaAdmvs == "320921" {
  9681. data["doctor_id"] = "D320923012139"
  9682. } else {
  9683. data["doctor_id"] = "D371621008686"
  9684. }
  9685. bytesData, _ := json.Marshal(data)
  9686. var req *http.Request
  9687. if miConfig.MdtrtareaAdmvs == "320921" {
  9688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9689. } else {
  9690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9691. }
  9692. resp, _ := client.Do(req)
  9693. defer resp.Body.Close()
  9694. body, ioErr := ioutil.ReadAll(resp.Body)
  9695. if ioErr != nil {
  9696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9698. return
  9699. }
  9700. var respJSON map[string]interface{}
  9701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9704. return
  9705. }
  9706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9707. userJSONBytes, _ := json.Marshal(respJSON)
  9708. fmt.Println("log")
  9709. fmt.Println(string(userJSONBytes))
  9710. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9711. utils.ErrorLog("解析失败:%v", err)
  9712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9713. return
  9714. }
  9715. res.InfRefmsgid = resFour10265.InfRefmsgid
  9716. res.Output = resFour10265.Output
  9717. res.ErrMsg = resFour10265.ErrMsg
  9718. res.Cainfo = resFour10265.Cainfo
  9719. res.WarnMsg = resFour10265.WarnMsg
  9720. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9721. res.Infcode = infocode
  9722. }
  9723. }
  9724. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9725. 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)
  9726. var dat map[string]interface{}
  9727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9728. fmt.Println(dat)
  9729. } else {
  9730. fmt.Println(err)
  9731. }
  9732. saveLog(result, request_log, "2204", "上传费用明细")
  9733. userJSONBytes, _ := json.Marshal(dat)
  9734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9735. utils.ErrorLog("解析失败:%v", err)
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9737. return
  9738. }
  9739. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9740. 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, "", "")
  9741. var dat map[string]interface{}
  9742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9743. fmt.Println(dat)
  9744. } else {
  9745. fmt.Println(err)
  9746. }
  9747. saveLog(result, request_log, "2204", "上传费用明细")
  9748. userJSONBytes, _ := json.Marshal(dat)
  9749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9755. 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, "", "")
  9756. var dat map[string]interface{}
  9757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9758. fmt.Println(dat)
  9759. } else {
  9760. fmt.Println(err)
  9761. }
  9762. saveLog(result, request_log, "2204", "上传费用明细")
  9763. userJSONBytes, _ := json.Marshal(dat)
  9764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9765. utils.ErrorLog("解析失败:%v", err)
  9766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9767. return
  9768. }
  9769. } else {
  9770. if miConfig.Code == "H15049901371" {
  9771. 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)
  9772. var dat map[string]interface{}
  9773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9774. fmt.Println(dat)
  9775. } else {
  9776. fmt.Println(err)
  9777. }
  9778. saveLog(result, request_log, "2204", "上传费用明细")
  9779. userJSONBytes, _ := json.Marshal(dat)
  9780. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9781. utils.ErrorLog("解析失败:%v", err)
  9782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9783. return
  9784. }
  9785. res.InfRefmsgid = resFour10265.InfRefmsgid
  9786. res.Output = resFour10265.Output
  9787. res.ErrMsg = resFour10265.ErrMsg
  9788. res.Cainfo = resFour10265.Cainfo
  9789. res.WarnMsg = resFour10265.WarnMsg
  9790. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9791. res.Infcode = infocode
  9792. } else {
  9793. 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)
  9794. var dat map[string]interface{}
  9795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9796. fmt.Println(dat)
  9797. } else {
  9798. fmt.Println(err)
  9799. }
  9800. saveLog(result, request_log, "2204", "上传费用明细")
  9801. userJSONBytes, _ := json.Marshal(dat)
  9802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9803. utils.ErrorLog("解析失败:%v", err)
  9804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9805. return
  9806. }
  9807. }
  9808. }
  9809. if res.Infcode == 0 {
  9810. order := &models.HisOrder{
  9811. UserOrgId: adminUser.CurrentOrgId,
  9812. HisPatientId: his.ID,
  9813. PatientId: his.PatientId,
  9814. SettleAccountsDate: recordDateTime,
  9815. Ctime: time.Now().Unix(),
  9816. Mtime: time.Now().Unix(),
  9817. MdtrtId: his.Number,
  9818. PsnNo: his.PsnNo,
  9819. MedType: strconv.FormatInt(reg_type, 10),
  9820. Status: 1,
  9821. Number: chrg_bchno,
  9822. Infcode: res.Infcode,
  9823. WarnMsg: res.WarnMsg,
  9824. Cainfo: res.Cainfo,
  9825. ErrMsg: res.ErrMsg,
  9826. RespondTime: res.RefmsgTime,
  9827. InfRefmsgid: res.InfRefmsgid,
  9828. OrderStatus: 1,
  9829. IsMedicineInsurance: 1,
  9830. SettleType: settle_accounts_type,
  9831. SettleStartTime: start_time,
  9832. SettleEndTime: end_time,
  9833. Creator: roles.AdminUserId,
  9834. Modify: roles.AdminUserId,
  9835. PType: 2,
  9836. Diagnosis: diagnosis_id,
  9837. }
  9838. err = service.CreateOrder(order)
  9839. if err != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9841. return
  9842. }
  9843. for _, item := range res.Output.Result {
  9844. temp := strings.Split(item.FeedetlSn, "-")
  9845. var advice_id int64 = 0
  9846. var project_id int64 = 0
  9847. var types int64 = 0
  9848. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9849. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9850. if temp[1] == "1" {
  9851. advice_id = id
  9852. project_id = 0
  9853. } else if temp[1] == "2" {
  9854. advice_id = 0
  9855. project_id = id
  9856. }
  9857. info := &models.HisOrderInfo{
  9858. OrderNumber: order.Number,
  9859. FeedetlSn: item.FeedetlSn,
  9860. UploadDate: time.Now().Unix(),
  9861. AdviceId: advice_id,
  9862. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9863. Cnt: item.Cnt,
  9864. Pric: float64(item.Pric),
  9865. PatientId: his.PatientId,
  9866. PricUplmtAmt: item.PricUplmtAmt,
  9867. SelfpayProp: item.SelfpayProp,
  9868. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9869. OverlmtAmt: item.OverlmtAmt,
  9870. PreselfpayAmt: item.PreselfpayAmt,
  9871. BasMednFlag: item.BasMednFlag,
  9872. MedChrgitmType: item.MedChrgitmType,
  9873. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9874. Status: 1,
  9875. Memo: item.Memo,
  9876. Mtime: time.Now().Unix(),
  9877. InscpScpAmt: item.InscpScpAmt,
  9878. DrtReimFlag: item.DrtReimFlag,
  9879. Ctime: time.Now().Unix(),
  9880. ListSpItemFlag: item.ListSpItemFlag,
  9881. ChldMedcFlag: item.ChldMedcFlag,
  9882. LmtUsedFlag: item.LmtUsedFlag,
  9883. ChrgitmLv: item.ChrgitmLv,
  9884. UserOrgId: adminUser.CurrentOrgId,
  9885. HisPatientId: his.ID,
  9886. OrderId: order.ID,
  9887. ProjectId: project_id,
  9888. Type: types,
  9889. }
  9890. service.CreateOrderInfo(info)
  9891. }
  9892. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9893. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9894. var total float64
  9895. for _, item := range prescriptions {
  9896. if item.Type == 1 { //药品
  9897. for _, subItem := range item.HisDoctorAdviceInfo {
  9898. total = total + (subItem.Price * subItem.PrescribingNumber)
  9899. }
  9900. }
  9901. if item.Type == 2 { //项目
  9902. for _, subItem := range item.HisPrescriptionProject {
  9903. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9904. total = total + (subItem.Price * cnt)
  9905. }
  9906. }
  9907. }
  9908. for _, item := range prescriptions {
  9909. for _, subItem := range item.HisAdditionalCharge {
  9910. total = total + (subItem.Price * float64(subItem.Count))
  9911. }
  9912. }
  9913. allTotal := fmt.Sprintf("%.4f", total)
  9914. if res.Infcode == 0 {
  9915. var rf []*ResultFive
  9916. json.Unmarshal([]byte(his.Iinfo), &rf)
  9917. chrg_bchno := chrg_bchno
  9918. cert_no := his.Certno
  9919. var insutypes []string
  9920. var insutype string
  9921. var is390 int = 0
  9922. var is310 int = 0
  9923. for _, item := range rf {
  9924. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9925. insutypes = append(insutypes, item.Insutype)
  9926. }
  9927. }
  9928. if len(insutypes) == 1 {
  9929. insutype = insutypes[0]
  9930. } else {
  9931. for _, i := range insutypes {
  9932. if i == "390" {
  9933. is390 = 1
  9934. }
  9935. if i == "310" {
  9936. is310 = 1
  9937. }
  9938. }
  9939. }
  9940. if is390 == 1 {
  9941. insutype = "390"
  9942. }
  9943. if is310 == 1 {
  9944. insutype = "310"
  9945. }
  9946. if len(insutypes) == 0 {
  9947. insutype = "310"
  9948. }
  9949. if len(insutypes) == 2 {
  9950. insutype = strconv.FormatInt(his.SocialType, 64)
  9951. }
  9952. //insutype = "390"
  9953. if his.IdCardType == 1 {
  9954. cert_no = his.MedicalInsuranceNumber
  9955. } else {
  9956. cert_no = his.Certno
  9957. }
  9958. var res ResultSeven
  9959. var resSeven10265 ResultSeven10265
  9960. if miConfig.MdtrtareaAdmvs == "421300" {
  9961. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9962. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9963. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9964. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9965. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9966. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9967. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9968. resp, requestErr := http.Get(api)
  9969. if requestErr != nil {
  9970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9971. return
  9972. }
  9973. body, ioErr := ioutil.ReadAll(resp.Body)
  9974. if ioErr != nil {
  9975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9977. return
  9978. }
  9979. var respJSON map[string]interface{}
  9980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9986. result, _ := json.Marshal(respJSON)
  9987. fmt.Println("log")
  9988. fmt.Println(string(result))
  9989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9990. utils.ErrorLog("解析失败:%v", err)
  9991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9992. return
  9993. }
  9994. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9995. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9996. if result3101.Infcode == "0" {
  9997. if len(result3101.Output.Result) > 0 {
  9998. var errMsgs []string
  9999. for _, item := range result3101.Output.Result {
  10000. errMsgs = append(errMsgs, item.VolaCont)
  10001. }
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "failed_code": -10,
  10004. "msg": errMsgs,
  10005. })
  10006. return
  10007. } else {
  10008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10009. if his.IdCardType != 4 {
  10010. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10011. bas := strings.Split(psn_info.CardInfo, "|")
  10012. if his.IdCardType == 1 {
  10013. cert_no = bas[2]
  10014. } else {
  10015. cert_no = bas[1]
  10016. }
  10017. } else {
  10018. cert_no = his.Certno
  10019. }
  10020. //江苏地区国家医保医疗类别
  10021. //职工透析:医疗类别选特殊情况门诊9933
  10022. //居民血透门慢: 医疗类别选门诊慢病1402
  10023. //var med_type string
  10024. //if his.Insutype == "310" {
  10025. // if reg_type == 14 {
  10026. // med_type = "9933"
  10027. // } else if reg_type == 11 {
  10028. // med_type = "11"
  10029. //
  10030. // }
  10031. //} else if his.Insutype == "390" {
  10032. // if reg_type == 14 {
  10033. // med_type = "1402"
  10034. // } else if reg_type == 11 {
  10035. // med_type = "11"
  10036. // }
  10037. //}
  10038. var api string
  10039. if miConfig.MdtrtareaAdmvs == "320921" {
  10040. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10041. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10042. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10044. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10045. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10046. "&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
  10047. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10048. } else {
  10049. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10050. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10051. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10052. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10054. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10055. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10056. "&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
  10057. }
  10058. resp, requestErr := http.Get(api)
  10059. if requestErr != nil {
  10060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10061. return
  10062. }
  10063. body, ioErr := ioutil.ReadAll(resp.Body)
  10064. if ioErr != nil {
  10065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10067. return
  10068. }
  10069. var respJSON map[string]interface{}
  10070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10073. return
  10074. }
  10075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10076. result, _ := json.Marshal(respJSON)
  10077. fmt.Println("log")
  10078. fmt.Println(string(result))
  10079. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10080. utils.ErrorLog("解析失败:%v", err)
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10082. return
  10083. }
  10084. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10085. res.Output = resSeven10265.Output
  10086. res.ErrMsg = resSeven10265.ErrMsg
  10087. res.Cainfo = resSeven10265.Cainfo
  10088. res.WarnMsg = resSeven10265.WarnMsg
  10089. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10090. res.Infcode = infocode
  10091. }
  10092. }
  10093. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10094. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  10095. var result string
  10096. var request_log string
  10097. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10098. 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)
  10099. } else {
  10100. 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)
  10101. }
  10102. var dat map[string]interface{}
  10103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10104. fmt.Println(dat)
  10105. } else {
  10106. fmt.Println(err)
  10107. }
  10108. saveLog(result, request_log, "2206", "预结算")
  10109. userJSONBytes, _ := json.Marshal(dat)
  10110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10111. utils.ErrorLog("解析失败:%v", err)
  10112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10113. return
  10114. }
  10115. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10116. var result string
  10117. var request_log string
  10118. if his.IdCardType == 2 {
  10119. 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, "")
  10120. } else if his.IdCardType == 1 {
  10121. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10122. bas := strings.Split(psn_info.CardInfo, "|")
  10123. basNumber := bas[2]
  10124. card_sn := bas[3]
  10125. 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)
  10126. } else {
  10127. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10128. 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, "")
  10129. }
  10130. var dat map[string]interface{}
  10131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10132. fmt.Println(dat)
  10133. } else {
  10134. fmt.Println(err)
  10135. }
  10136. saveLog(result, request_log, "2206", "预结算")
  10137. userJSONBytes, _ := json.Marshal(dat)
  10138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10139. utils.ErrorLog("解析失败:%v", err)
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return
  10142. }
  10143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10144. var result string
  10145. var request_log string
  10146. if his.IdCardType == 2 {
  10147. 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, "")
  10148. } else if his.IdCardType == 1 {
  10149. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10150. bas := strings.Split(psn_info.CardInfo, "|")
  10151. basNumber := bas[2]
  10152. card_sn := bas[3]
  10153. 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)
  10154. } else {
  10155. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10156. 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, "")
  10157. }
  10158. var dat map[string]interface{}
  10159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10160. fmt.Println(dat)
  10161. } else {
  10162. fmt.Println(err)
  10163. }
  10164. saveLog(result, request_log, "2206", "预结算")
  10165. userJSONBytes, _ := json.Marshal(dat)
  10166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10167. utils.ErrorLog("解析失败:%v", err)
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10169. return
  10170. }
  10171. } else {
  10172. var result string
  10173. var request_log string
  10174. if miConfig.Code == "H15049901371" {
  10175. //赤峰地区国家医保医疗类别
  10176. //职工透析:医疗类别选特殊情况门诊990502
  10177. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10178. var med_type string
  10179. if his.Insutype == "390" {
  10180. if reg_type == 14 {
  10181. med_type = "9933"
  10182. } else if reg_type == 11 {
  10183. med_type = "11"
  10184. }
  10185. } else if his.Insutype == "310" {
  10186. if reg_type == 14 {
  10187. med_type = "990502"
  10188. } else if reg_type == 11 {
  10189. med_type = "11"
  10190. }
  10191. }
  10192. 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)
  10193. } else {
  10194. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10195. if his.IdCardType == 4 {
  10196. 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)
  10197. } else {
  10198. 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)
  10199. }
  10200. }
  10201. var dat map[string]interface{}
  10202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10203. fmt.Println(dat)
  10204. } else {
  10205. fmt.Println(err)
  10206. }
  10207. saveLog(result, request_log, "2206", "预结算")
  10208. //userJSONBytes, _ := json.Marshal(dat)
  10209. //
  10210. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10211. // utils.ErrorLog("解析失败:%v", err)
  10212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. // return
  10214. //}
  10215. userJSONBytes, _ := json.Marshal(dat)
  10216. if miConfig.Code == "H15049901371" {
  10217. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10218. utils.ErrorLog("解析失败:%v", err)
  10219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10220. return
  10221. }
  10222. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10223. res.Output = resSeven10265.Output
  10224. res.ErrMsg = resSeven10265.ErrMsg
  10225. res.Cainfo = resSeven10265.Cainfo
  10226. res.WarnMsg = resSeven10265.WarnMsg
  10227. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10228. res.Infcode = infocode
  10229. } else {
  10230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10231. utils.ErrorLog("解析失败:%v", err)
  10232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. return
  10234. }
  10235. }
  10236. }
  10237. if res.Infcode != 0 {
  10238. errlog := &models.HisOrderError{
  10239. UserOrgId: adminUser.CurrentOrgId,
  10240. Ctime: time.Now().Unix(),
  10241. Mtime: time.Now().Unix(),
  10242. Number: chrg_bchno,
  10243. ErrMsg: res.ErrMsg,
  10244. Status: 1,
  10245. PatientId: id,
  10246. RecordTime: recordDateTime,
  10247. Stage: 20,
  10248. }
  10249. service.CreateErrMsgLog(errlog)
  10250. c.ServeSuccessJSON(map[string]interface{}{
  10251. "failed_code": -10,
  10252. "msg": res.ErrMsg,
  10253. })
  10254. return
  10255. } else {
  10256. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10257. order.OrderStatus = 1
  10258. order.IsPre = 1
  10259. order.Status = 1
  10260. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10261. order.SetlId = res.Output.Setlinfo.SetlID
  10262. order.PsnNo = res.Output.Setlinfo.PsnNo
  10263. order.PsnName = res.Output.Setlinfo.PsnName
  10264. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10265. order.Certno = res.Output.Setlinfo.Certno
  10266. order.Gend = res.Output.Setlinfo.Gend
  10267. order.Naty = res.Output.Setlinfo.Naty
  10268. order.Age = res.Output.Setlinfo.Age
  10269. order.Insutype = res.Output.Setlinfo.Insutype
  10270. order.PsnType = res.Output.Setlinfo.PsnType
  10271. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10272. order.SetlTime = res.Output.Setlinfo.SetlTime
  10273. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10274. if res.Output.Setlinfo.MedType == "140101" {
  10275. order.MedType = "14"
  10276. } else {
  10277. order.MedType = res.Output.Setlinfo.MedType
  10278. }
  10279. if reg_type == 1112 {
  10280. order.MedType = "1112"
  10281. }
  10282. if reg_type == 1111 {
  10283. order.MedType = "1111"
  10284. }
  10285. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10286. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10287. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10288. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10289. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10290. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10291. order.HifpPay = res.Output.Setlinfo.HifpPay
  10292. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10293. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10294. order.HifesPay = res.Output.Setlinfo.HifesPay
  10295. order.HifobPay = res.Output.Setlinfo.HifobPay
  10296. order.MafPay = res.Output.Setlinfo.MafPay
  10297. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10298. order.OthPay = res.Output.Setlinfo.OthPay
  10299. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10300. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10301. order.AcctPay = res.Output.Setlinfo.AcctPay
  10302. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10303. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10304. order.Balc = res.Output.Setlinfo.Balc
  10305. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10306. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10307. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10308. order.ClrWay = res.Output.Setlinfo.ClrWay
  10309. order.Creator = order.Creator
  10310. order.Modify = roles.AdminUserId
  10311. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10312. detailStr := string(setlDetail)
  10313. order.SetlDetail = detailStr
  10314. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10315. err = service.UpDateOrder(order)
  10316. if err == nil {
  10317. c.ServeSuccessJSON(map[string]interface{}{
  10318. "msg": "预结算成功",
  10319. })
  10320. } else {
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10322. return
  10323. }
  10324. }
  10325. } else {
  10326. adminUser := c.GetAdminUserInfo()
  10327. errlog := &models.HisOrderError{
  10328. UserOrgId: adminUser.CurrentOrgId,
  10329. Ctime: time.Now().Unix(),
  10330. Mtime: time.Now().Unix(),
  10331. ErrMsg: res.ErrMsg,
  10332. Status: 1,
  10333. PatientId: id,
  10334. RecordTime: recordDateTime,
  10335. Stage: 4,
  10336. }
  10337. service.CreateErrMsgLog(errlog)
  10338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10339. return
  10340. }
  10341. } else {
  10342. adminUser := c.GetAdminUserInfo()
  10343. errlog := &models.HisOrderError{
  10344. UserOrgId: adminUser.CurrentOrgId,
  10345. Ctime: time.Now().Unix(),
  10346. Mtime: time.Now().Unix(),
  10347. ErrMsg: res.ErrMsg,
  10348. Status: 1,
  10349. PatientId: id,
  10350. RecordTime: recordDateTime,
  10351. Stage: 4,
  10352. }
  10353. service.CreateErrMsgLog(errlog)
  10354. c.ServeSuccessJSON(map[string]interface{}{
  10355. "failed_code": -10,
  10356. "msg": res.ErrMsg,
  10357. })
  10358. return
  10359. }
  10360. }
  10361. }
  10362. }
  10363. //退款
  10364. func (c *HisApiController) Refund() {
  10365. order_id, _ := c.GetInt64("order_id")
  10366. admin_user_id, _ := c.GetInt64("admin_user_id")
  10367. adminUser := c.GetAdminUserInfo()
  10368. var order models.HisOrder
  10369. order, _ = service.GetHisOrderByID(order_id)
  10370. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10371. if order.ID == 0 {
  10372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10373. return
  10374. }
  10375. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10376. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10377. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10378. if config.IsOpen == 1 { //对接了医保,走医保流程
  10379. var res ResultSixteen
  10380. var resSixteen10265 ResultSixteen10265
  10381. var src_resquest string
  10382. var result string
  10383. if miConfig.MdtrtareaAdmvs == "421300" {
  10384. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10385. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10386. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10387. resp3, requestErr3 := http.Get(api3)
  10388. if requestErr3 != nil {
  10389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10390. return
  10391. }
  10392. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10393. if ioErr3 != nil {
  10394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10396. return
  10397. }
  10398. var respJSON3 map[string]interface{}
  10399. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10405. userJSONBytes3, _ := json.Marshal(respJSON3)
  10406. fmt.Println("log")
  10407. fmt.Println(string(userJSONBytes3))
  10408. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10409. utils.ErrorLog("解析失败:%v", err)
  10410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10411. return
  10412. }
  10413. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10414. var api3 string
  10415. if miConfig.MdtrtareaAdmvs == "320921" {
  10416. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10417. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10418. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10419. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10420. } else {
  10421. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10422. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10423. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10424. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10425. }
  10426. resp3, requestErr3 := http.Get(api3)
  10427. if requestErr3 != nil {
  10428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10429. return
  10430. }
  10431. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10432. if ioErr3 != nil {
  10433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10435. return
  10436. }
  10437. var respJSON3 map[string]interface{}
  10438. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10441. return
  10442. }
  10443. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10444. userJSONBytes3, _ := json.Marshal(respJSON3)
  10445. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10446. utils.ErrorLog("解析失败:%v", err)
  10447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10448. return
  10449. }
  10450. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10451. res.Output = resSixteen10265.Output
  10452. res.ErrMsg = resSixteen10265.ErrMsg
  10453. res.Cainfo = resSixteen10265.Cainfo
  10454. res.WarnMsg = resSixteen10265.WarnMsg
  10455. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10456. res.Infcode = infocode
  10457. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10458. 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)
  10459. var dat map[string]interface{}
  10460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10461. fmt.Println(dat)
  10462. } else {
  10463. fmt.Println(err)
  10464. }
  10465. saveLog(result, src_resquest, "2208", "退费")
  10466. userJSONBytes, _ := json.Marshal(dat)
  10467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10468. utils.ErrorLog("解析失败:%v", err)
  10469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10470. return
  10471. }
  10472. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10473. 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, "")
  10474. var dat map[string]interface{}
  10475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10476. fmt.Println(dat)
  10477. } else {
  10478. fmt.Println(err)
  10479. }
  10480. saveLog(result, src_resquest, "2208", "退费")
  10481. userJSONBytes, _ := json.Marshal(dat)
  10482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10483. utils.ErrorLog("解析失败:%v", err)
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. return
  10486. }
  10487. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10488. 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, "")
  10489. var dat map[string]interface{}
  10490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10491. fmt.Println(dat)
  10492. } else {
  10493. fmt.Println(err)
  10494. }
  10495. saveLog(result, src_resquest, "2208", "退费")
  10496. userJSONBytes, _ := json.Marshal(dat)
  10497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10498. utils.ErrorLog("解析失败:%v", err)
  10499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10500. return
  10501. }
  10502. } else {
  10503. if miConfig.Code == "H15049901371" {
  10504. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10505. var dat map[string]interface{}
  10506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10507. fmt.Println(dat)
  10508. } else {
  10509. fmt.Println(err)
  10510. }
  10511. saveLog(result, src_resquest, "2208", "退费")
  10512. userJSONBytes, _ := json.Marshal(dat)
  10513. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10514. utils.ErrorLog("解析失败:%v", err)
  10515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10516. return
  10517. }
  10518. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10519. res.Output = resSixteen10265.Output
  10520. res.ErrMsg = resSixteen10265.ErrMsg
  10521. res.Cainfo = resSixteen10265.Cainfo
  10522. res.WarnMsg = resSixteen10265.WarnMsg
  10523. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10524. res.Infcode = infocode
  10525. } else {
  10526. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10527. var dat map[string]interface{}
  10528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10529. fmt.Println(dat)
  10530. } else {
  10531. fmt.Println(err)
  10532. }
  10533. saveLog(result, src_resquest, "2208", "退费")
  10534. userJSONBytes, _ := json.Marshal(dat)
  10535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10536. utils.ErrorLog("解析失败:%v", err)
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10538. return
  10539. }
  10540. }
  10541. }
  10542. if res.Infcode == 0 {
  10543. var res2 ResultSix
  10544. var resSix10265 ResultSix10265
  10545. if miConfig.MdtrtareaAdmvs == "421300" {
  10546. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10547. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10548. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10549. resp3, requestErr3 := http.Get(api3)
  10550. if requestErr3 != nil {
  10551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10552. return
  10553. }
  10554. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10555. if ioErr3 != nil {
  10556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10558. return
  10559. }
  10560. var respJSON3 map[string]interface{}
  10561. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10564. return
  10565. }
  10566. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10567. userJSONBytes3, _ := json.Marshal(respJSON3)
  10568. fmt.Println("log")
  10569. fmt.Println(string(userJSONBytes3))
  10570. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10571. utils.ErrorLog("解析失败:%v", err)
  10572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10573. return
  10574. }
  10575. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10576. var api3 string
  10577. if miConfig.MdtrtareaAdmvs == "320921" {
  10578. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10579. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10580. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10581. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10582. } else {
  10583. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10584. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10585. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10586. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10587. }
  10588. resp3, requestErr3 := http.Get(api3)
  10589. if requestErr3 != nil {
  10590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10591. return
  10592. }
  10593. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10594. if ioErr3 != nil {
  10595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10597. return
  10598. }
  10599. var respJSON3 map[string]interface{}
  10600. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10603. return
  10604. }
  10605. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10606. userJSONBytes3, _ := json.Marshal(respJSON3)
  10607. fmt.Println("log")
  10608. fmt.Println(string(userJSONBytes3))
  10609. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10610. utils.ErrorLog("解析失败:%v", err)
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10612. return
  10613. }
  10614. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10615. res2.Output = resSix10265.Output
  10616. res2.ErrMsg = resSix10265.ErrMsg
  10617. res2.Cainfo = resSix10265.Cainfo
  10618. res2.WarnMsg = resSix10265.WarnMsg
  10619. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10620. res2.Infcode = infocode
  10621. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10622. 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)
  10623. var dat map[string]interface{}
  10624. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10625. fmt.Println(dat)
  10626. } else {
  10627. fmt.Println(err)
  10628. }
  10629. saveLog(result2, src_request, "2205", "撤销明细")
  10630. userJSONBytes, _ := json.Marshal(dat)
  10631. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10632. utils.ErrorLog("解析失败:%v", err)
  10633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10634. return
  10635. }
  10636. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10637. 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, "")
  10638. var dat map[string]interface{}
  10639. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10640. fmt.Println(dat)
  10641. } else {
  10642. fmt.Println(err)
  10643. }
  10644. saveLog(result2, src_request, "2205", "撤销明细")
  10645. userJSONBytes, _ := json.Marshal(dat)
  10646. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10647. utils.ErrorLog("解析失败:%v", err)
  10648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10649. return
  10650. }
  10651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10652. 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, "")
  10653. var dat map[string]interface{}
  10654. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10655. fmt.Println(dat)
  10656. } else {
  10657. fmt.Println(err)
  10658. }
  10659. saveLog(result2, src_request, "2205", "撤销明细")
  10660. userJSONBytes, _ := json.Marshal(dat)
  10661. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10662. utils.ErrorLog("解析失败:%v", err)
  10663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10664. return
  10665. }
  10666. } else {
  10667. if miConfig.Code == "H15049901371" {
  10668. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10669. var dat map[string]interface{}
  10670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10671. fmt.Println(dat)
  10672. } else {
  10673. fmt.Println(err)
  10674. }
  10675. saveLog(result2, src_request, "2205", "撤销明细")
  10676. userJSONBytes, _ := json.Marshal(dat)
  10677. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10678. utils.ErrorLog("解析失败:%v", err)
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10680. return
  10681. }
  10682. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10683. res2.Output = resSix10265.Output
  10684. res2.ErrMsg = resSix10265.ErrMsg
  10685. res2.Cainfo = resSix10265.Cainfo
  10686. res2.WarnMsg = resSix10265.WarnMsg
  10687. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10688. res2.Infcode = infocode
  10689. } else {
  10690. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10691. var dat map[string]interface{}
  10692. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10693. fmt.Println(dat)
  10694. } else {
  10695. fmt.Println(err)
  10696. }
  10697. saveLog(result2, src_request, "2205", "撤销明细")
  10698. userJSONBytes, _ := json.Marshal(dat)
  10699. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10700. utils.ErrorLog("解析失败:%v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. }
  10705. }
  10706. if res2.Infcode == 0 {
  10707. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10708. if err == nil {
  10709. //当押金不为零时产生退费记录
  10710. if order.Decimal != 0 {
  10711. tmp := strconv.FormatInt(order.ID, 10)
  10712. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10713. if err != nil {
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10715. return
  10716. }
  10717. }
  10718. c.ServeSuccessJSON(map[string]interface{}{
  10719. "msg": "退费成功",
  10720. })
  10721. } else {
  10722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10723. return
  10724. }
  10725. } else {
  10726. c.ServeSuccessJSON(map[string]interface{}{
  10727. "code": -10,
  10728. "msg": res2.ErrMsg,
  10729. })
  10730. }
  10731. } else {
  10732. c.ServeSuccessJSON(map[string]interface{}{
  10733. "code": -10,
  10734. "msg": res.ErrMsg,
  10735. })
  10736. }
  10737. }
  10738. }
  10739. func (c *HisApiController) RefundNumber() {
  10740. record_time := c.GetString("record_time")
  10741. //patient_id, _ := c.GetInt64("patient_id")
  10742. admin_user_id, _ := c.GetInt64("admin_user_id")
  10743. his_patient_id, _ := c.GetInt64("id")
  10744. timeLayout := "2006-01-02"
  10745. loc, _ := time.LoadLocation("Local")
  10746. adminUser := c.GetAdminUserInfo()
  10747. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10748. fmt.Println(err)
  10749. if err != nil {
  10750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10751. return
  10752. }
  10753. recordDateTime := theTime.Unix()
  10754. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10755. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10756. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10757. //order, _ := service.GetHisOrderByID(order_id)
  10758. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10759. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10760. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10761. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10762. if count > 0 {
  10763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10764. return
  10765. }
  10766. if config.IsOpen == 1 { //对接了医保,走医保流程
  10767. var res2 ResultSix
  10768. var resSix10265 ResultSix10265
  10769. if miConfig.MdtrtareaAdmvs == "421300" {
  10770. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10771. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10772. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10773. resp3, requestErr3 := http.Get(api3)
  10774. if requestErr3 != nil {
  10775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. return
  10777. }
  10778. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10779. if ioErr3 != nil {
  10780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. var respJSON3 map[string]interface{}
  10785. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10791. userJSONBytes3, _ := json.Marshal(respJSON3)
  10792. fmt.Println("log")
  10793. fmt.Println(string(userJSONBytes3))
  10794. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10795. utils.ErrorLog("解析失败:%v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return
  10798. }
  10799. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10800. var api3 string
  10801. if miConfig.MdtrtareaAdmvs == "320921" {
  10802. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10803. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10804. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10805. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10806. } else {
  10807. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10808. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10809. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10811. }
  10812. resp3, requestErr3 := http.Get(api3)
  10813. if requestErr3 != nil {
  10814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10815. return
  10816. }
  10817. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10818. if ioErr3 != nil {
  10819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10821. return
  10822. }
  10823. var respJSON3 map[string]interface{}
  10824. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10827. return
  10828. }
  10829. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10830. userJSONBytes3, _ := json.Marshal(respJSON3)
  10831. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10832. utils.ErrorLog("解析失败:%v", err)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return
  10835. }
  10836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10837. res2.Output = resSix10265.Output
  10838. res2.ErrMsg = resSix10265.ErrMsg
  10839. res2.Cainfo = resSix10265.Cainfo
  10840. res2.WarnMsg = resSix10265.WarnMsg
  10841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10842. res2.Infcode = infocode
  10843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10844. 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)
  10845. var dat map[string]interface{}
  10846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10847. fmt.Println(dat)
  10848. } else {
  10849. fmt.Println(err)
  10850. }
  10851. saveLog(result, request, "2202", "退号")
  10852. userJSONBytes, _ := json.Marshal(dat)
  10853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10854. utils.ErrorLog("解析失败:%v", err)
  10855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10856. return
  10857. }
  10858. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10859. 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, "")
  10860. var dat map[string]interface{}
  10861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10862. fmt.Println(dat)
  10863. } else {
  10864. fmt.Println(err)
  10865. }
  10866. saveLog(result, request, "2202", "退号")
  10867. userJSONBytes, _ := json.Marshal(dat)
  10868. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10869. utils.ErrorLog("解析失败:%v", err)
  10870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10871. return
  10872. }
  10873. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10874. 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, "")
  10875. var dat map[string]interface{}
  10876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10877. fmt.Println(dat)
  10878. } else {
  10879. fmt.Println(err)
  10880. }
  10881. saveLog(result, request, "2202", "退号")
  10882. userJSONBytes, _ := json.Marshal(dat)
  10883. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10884. utils.ErrorLog("解析失败:%v", err)
  10885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10886. return
  10887. }
  10888. } else {
  10889. var api3 string
  10890. if miConfig.Code == "H15049901371" {
  10891. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10892. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10894. } else {
  10895. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10896. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10898. }
  10899. resp3, requestErr3 := http.Get(api3)
  10900. if requestErr3 != nil {
  10901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10902. return
  10903. }
  10904. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10905. if ioErr3 != nil {
  10906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10908. return
  10909. }
  10910. var respJSON3 map[string]interface{}
  10911. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10914. return
  10915. }
  10916. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10917. userJSONBytes3, _ := json.Marshal(respJSON3)
  10918. if miConfig.Code == "H15049901371" {
  10919. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10920. utils.ErrorLog("解析失败:%v", err)
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. return
  10923. }
  10924. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10925. res2.Output = resSix10265.Output
  10926. res2.ErrMsg = resSix10265.ErrMsg
  10927. res2.Cainfo = resSix10265.Cainfo
  10928. res2.WarnMsg = resSix10265.WarnMsg
  10929. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10930. res2.Infcode = infocode
  10931. } else {
  10932. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10933. utils.ErrorLog("解析失败:%v", err)
  10934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10935. return
  10936. }
  10937. }
  10938. }
  10939. if res2.Infcode == 0 {
  10940. if err == nil {
  10941. c.ServeSuccessJSON(map[string]interface{}{
  10942. "msg": "退号成功",
  10943. })
  10944. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10945. } else {
  10946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10947. return
  10948. }
  10949. } else {
  10950. c.ServeSuccessJSON(map[string]interface{}{
  10951. "code": -10,
  10952. "msg": res2.ErrMsg,
  10953. })
  10954. }
  10955. } else {
  10956. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10957. //if err == nil {
  10958. // c.ServeSuccessJSON(map[string]interface{}{
  10959. // "msg": "退费成功",
  10960. // })
  10961. //} else {
  10962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10963. // return
  10964. //}
  10965. }
  10966. }
  10967. func (c *HisApiController) RefundDetail() {
  10968. order_id, _ := c.GetInt64("order_id")
  10969. admin_user_id, _ := c.GetInt64("admin_user_id")
  10970. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10971. number := c.GetString("number")
  10972. record_time := c.GetString("record_time")
  10973. patient_id, _ := c.GetInt64("patient_id")
  10974. //med_type, _ := c.GetInt64("med_type")
  10975. timeLayout := "2006-01-02"
  10976. loc, _ := time.LoadLocation("Local")
  10977. adminUser := c.GetAdminUserInfo()
  10978. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10979. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10980. fmt.Println(err)
  10981. if err != nil {
  10982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10983. return
  10984. }
  10985. recordDateTime := theTime.Unix()
  10986. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10987. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10990. var order models.HisOrder
  10991. order, _ = service.GetHisOrderByID(order_id)
  10992. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10993. if config.IsOpen == 1 { //对接了医保,走医保流程
  10994. var res2 ResultSix
  10995. if miConfig.MdtrtareaAdmvs == "421300" {
  10996. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10997. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10999. resp3, requestErr3 := http.Get(api3)
  11000. if requestErr3 != nil {
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11005. if ioErr3 != nil {
  11006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11008. return
  11009. }
  11010. var respJSON3 map[string]interface{}
  11011. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11014. return
  11015. }
  11016. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11017. userJSONBytes3, _ := json.Marshal(respJSON3)
  11018. fmt.Println("log")
  11019. fmt.Println(string(userJSONBytes3))
  11020. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11021. utils.ErrorLog("解析失败:%v", err)
  11022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11023. return
  11024. }
  11025. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11026. if err == nil {
  11027. c.ServeSuccessJSON(map[string]interface{}{
  11028. "msg": "撤销明细成功",
  11029. })
  11030. return
  11031. } else {
  11032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11033. return
  11034. }
  11035. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11036. var resSix10265 ResultSix10265
  11037. var api3 string
  11038. if miConfig.MdtrtareaAdmvs == "320921" {
  11039. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11040. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11041. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11042. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11043. } else {
  11044. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11045. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11046. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11048. }
  11049. resp3, requestErr3 := http.Get(api3)
  11050. if requestErr3 != nil {
  11051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11052. return
  11053. }
  11054. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11055. if ioErr3 != nil {
  11056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11058. return
  11059. }
  11060. var respJSON3 map[string]interface{}
  11061. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11064. return
  11065. }
  11066. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11067. userJSONBytes3, _ := json.Marshal(respJSON3)
  11068. fmt.Println("log")
  11069. fmt.Println(string(userJSONBytes3))
  11070. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11071. utils.ErrorLog("解析失败:%v", err)
  11072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11073. return
  11074. }
  11075. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11076. res2.Output = resSix10265.Output
  11077. res2.ErrMsg = resSix10265.ErrMsg
  11078. res2.Cainfo = resSix10265.Cainfo
  11079. res2.WarnMsg = resSix10265.WarnMsg
  11080. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11081. res2.Infcode = infocode
  11082. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11083. if err == nil {
  11084. c.ServeSuccessJSON(map[string]interface{}{
  11085. "msg": "撤销明细成功",
  11086. })
  11087. return
  11088. } else {
  11089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11090. return
  11091. }
  11092. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11093. 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)
  11094. var dat map[string]interface{}
  11095. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11096. fmt.Println(dat)
  11097. } else {
  11098. fmt.Println(err)
  11099. }
  11100. saveLog(result2, src_request, "2205", "撤销明细")
  11101. userJSONBytes, _ := json.Marshal(dat)
  11102. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11103. utils.ErrorLog("解析失败:%v", err)
  11104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11105. return
  11106. }
  11107. if res2.Infcode == 0 {
  11108. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11109. if err == nil {
  11110. c.ServeSuccessJSON(map[string]interface{}{
  11111. "msg": "撤销明细成功",
  11112. })
  11113. return
  11114. } else {
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. return
  11117. }
  11118. } else {
  11119. c.ServeSuccessJSON(map[string]interface{}{
  11120. "code": -10,
  11121. "msg": res2.ErrMsg,
  11122. })
  11123. }
  11124. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11125. 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, "")
  11126. var dat map[string]interface{}
  11127. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11128. fmt.Println(dat)
  11129. } else {
  11130. fmt.Println(err)
  11131. }
  11132. saveLog(result2, src_request, "2205", "撤销明细")
  11133. userJSONBytes, _ := json.Marshal(dat)
  11134. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11135. utils.ErrorLog("解析失败:%v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. if res2.Infcode == 0 {
  11140. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11141. if err == nil {
  11142. c.ServeSuccessJSON(map[string]interface{}{
  11143. "msg": "撤销明细成功",
  11144. })
  11145. return
  11146. } else {
  11147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11148. return
  11149. }
  11150. } else {
  11151. c.ServeSuccessJSON(map[string]interface{}{
  11152. "code": -10,
  11153. "msg": res2.ErrMsg,
  11154. })
  11155. }
  11156. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11157. 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, "")
  11158. var dat map[string]interface{}
  11159. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11160. fmt.Println(dat)
  11161. } else {
  11162. fmt.Println(err)
  11163. }
  11164. saveLog(result2, src_request, "2205", "撤销明细")
  11165. userJSONBytes, _ := json.Marshal(dat)
  11166. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11167. utils.ErrorLog("解析失败:%v", err)
  11168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11169. return
  11170. }
  11171. if res2.Infcode == 0 {
  11172. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11173. if err == nil {
  11174. c.ServeSuccessJSON(map[string]interface{}{
  11175. "msg": "撤销明细成功",
  11176. })
  11177. return
  11178. } else {
  11179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11180. return
  11181. }
  11182. } else {
  11183. c.ServeSuccessJSON(map[string]interface{}{
  11184. "code": -10,
  11185. "msg": res2.ErrMsg,
  11186. })
  11187. }
  11188. } else {
  11189. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11190. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11192. resp2, requestErr2 := http.Get(api2)
  11193. if requestErr2 != nil {
  11194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11195. return
  11196. }
  11197. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11198. if ioErr2 != nil {
  11199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11201. return
  11202. }
  11203. var respJSON2 map[string]interface{}
  11204. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11207. return
  11208. }
  11209. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11210. if err == nil {
  11211. c.ServeSuccessJSON(map[string]interface{}{
  11212. "msg": "撤销明细成功",
  11213. })
  11214. return
  11215. } else {
  11216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11217. return
  11218. }
  11219. }
  11220. } else {
  11221. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11222. if err == nil {
  11223. c.ServeSuccessJSON(map[string]interface{}{
  11224. "msg": "退费成功",
  11225. })
  11226. } else {
  11227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11228. return
  11229. }
  11230. }
  11231. }
  11232. //对账
  11233. func (c *HisApiController) GetCheckAccount() {
  11234. start_time := c.GetString("start_time")
  11235. end_time := c.GetString("end_time")
  11236. insutype := c.GetString("insutype")
  11237. clr_type := c.GetString("clr_type")
  11238. clr_org := c.GetString("clr_optins")
  11239. admin_user_id, _ := c.GetInt64("admin_user_id")
  11240. adminUser := c.GetAdminUserInfo()
  11241. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11242. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11243. if len(clr_org) == 0 {
  11244. clr_org = miConfig.MdtrtareaAdmvs
  11245. }
  11246. timeLayout := "2006-01-02"
  11247. loc, _ := time.LoadLocation("Local")
  11248. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11249. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11250. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11251. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11252. fixmedins_setl_cnt := int64(len(orders))
  11253. var medfee_sumamt float64
  11254. var acct_pay float64
  11255. var fund_pay_sumamt float64
  11256. for _, item := range orders {
  11257. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11258. acct_pay = acct_pay + item.AcctPay
  11259. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11260. }
  11261. var user_name string
  11262. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11263. if role.ID == 0 {
  11264. user_name = "xxx"
  11265. } else {
  11266. user_name = role.UserName
  11267. }
  11268. var res ResultEight
  11269. var res10188 ResultEightFor10188
  11270. if config.IsOpen == 1 {
  11271. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11272. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11273. "insutype=" + insutype +
  11274. "&clr_type=" + clr_type +
  11275. "&setl_optins=" + clr_org +
  11276. "&stmt_begndate=" + start_time +
  11277. "&stm_enddate=" + end_time +
  11278. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11279. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11280. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11281. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11282. "&fixmedins_code=" + miConfig.Code +
  11283. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11284. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11285. "&secret_key=" + miConfig.SecretKey +
  11286. "&org_name=" + miConfig.OrgName +
  11287. "&doctor=" + user_name +
  11288. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11289. fmt.Println(api)
  11290. resp, requestErr := http.Get(api)
  11291. if requestErr != nil {
  11292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11293. return
  11294. }
  11295. body, ioErr := ioutil.ReadAll(resp.Body)
  11296. fmt.Println(body)
  11297. if ioErr != nil {
  11298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11300. return
  11301. }
  11302. var respJSON map[string]interface{}
  11303. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11306. return
  11307. }
  11308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11309. userJSONBytes, _ := json.Marshal(respJSON)
  11310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11311. utils.ErrorLog("解析失败:%v", err)
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return
  11314. }
  11315. res.InfRefmsgid = res10188.InfRefmsgid
  11316. res.Output = res10188.Output
  11317. res.ErrMsg = res10188.ErrMsg
  11318. res.Cainfo = res10188.Cainfo
  11319. res.WarnMsg = res10188.WarnMsg
  11320. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11321. res.Infcode = infocode
  11322. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11323. if clr_type == "11" {
  11324. fixmedins_setl_cnt = 2
  11325. }
  11326. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11327. "insutype=" + insutype +
  11328. "&clr_type=" + clr_type +
  11329. "&setl_optins=" + clr_org +
  11330. "&stmt_begndate=" + start_time +
  11331. "&stm_enddate=" + end_time +
  11332. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11333. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11334. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11335. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11336. "&fixmedins_code=" + miConfig.Code +
  11337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11338. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11339. "&secret_key=" + miConfig.SecretKey +
  11340. "&org_name=" + miConfig.OrgName +
  11341. "&doctor=" + user_name
  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. if ioErr != nil {
  11349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11351. return
  11352. }
  11353. var respJSON map[string]interface{}
  11354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11357. return
  11358. }
  11359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11360. result, _ := json.Marshal(respJSON)
  11361. fmt.Println("log")
  11362. fmt.Println(string(result))
  11363. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11364. utils.ErrorLog("解析失败:%v", err)
  11365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11366. return
  11367. }
  11368. res.InfRefmsgid = res10188.InfRefmsgid
  11369. res.Output = res10188.Output
  11370. res.ErrMsg = res10188.ErrMsg
  11371. res.Cainfo = res10188.Cainfo
  11372. res.WarnMsg = res10188.WarnMsg
  11373. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11374. res.Infcode = infocode
  11375. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11376. var baseParams models.BaseParams
  11377. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11378. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11379. baseParams.SecretKey = miConfig.SecretKey
  11380. baseParams.OrgName = miConfig.OrgName
  11381. baseParams.FixmedinsCode = miConfig.Code
  11382. baseParams.EncKey = miConfig.EncKey
  11383. baseParams.AppSecret = miConfig.AppSecret
  11384. baseParams.SignKey = miConfig.SignKey
  11385. baseParams.AppID = miConfig.Code
  11386. baseParams.Doctor = role.UserName
  11387. baseParams.RequestUrl = miConfig.Url
  11388. businessParams := models.BusinessParams{
  11389. Insutype: insutype,
  11390. ClrType: clr_type,
  11391. SetlOptins: clr_org,
  11392. StmtBegndate: start_time,
  11393. StmtEnddate: end_time,
  11394. MedfeeSumamt: medfee_sumamt,
  11395. FundPaySumamt: fund_pay_sumamt,
  11396. AcctPay: acct_pay,
  11397. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11398. }
  11399. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11400. fmt.Println(requestLog)
  11401. fmt.Println(result)
  11402. fmt.Println(err_msg)
  11403. var dat map[string]interface{}
  11404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11405. fmt.Println(dat)
  11406. } else {
  11407. fmt.Println(err)
  11408. }
  11409. userJSONBytes, _ := json.Marshal(dat)
  11410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11411. utils.ErrorLog("解析失败:%v", err)
  11412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11413. return
  11414. }
  11415. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11416. var baseParams models.BaseParams
  11417. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11418. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11419. baseParams.SecretKey = miConfig.SecretKey
  11420. baseParams.OrgName = miConfig.OrgName
  11421. baseParams.FixmedinsCode = miConfig.Code
  11422. baseParams.EncKey = miConfig.EncKey
  11423. baseParams.AppSecret = miConfig.AppSecret
  11424. baseParams.SignKey = miConfig.SignKey
  11425. baseParams.AppID = miConfig.Code
  11426. baseParams.Doctor = role.UserName
  11427. baseParams.RequestUrl = miConfig.Url
  11428. baseParams.AccessKey = miConfig.AccessKey
  11429. businessParams := models.BusinessParams{
  11430. Insutype: insutype,
  11431. ClrType: clr_type,
  11432. SetlOptins: "430822",
  11433. StmtBegndate: start_time,
  11434. StmtEnddate: end_time,
  11435. MedfeeSumamt: medfee_sumamt,
  11436. FundPaySumamt: fund_pay_sumamt,
  11437. AcctPay: acct_pay,
  11438. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11439. }
  11440. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  11441. fmt.Println(requestLog)
  11442. fmt.Println(result)
  11443. var dat map[string]interface{}
  11444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11445. fmt.Println(dat)
  11446. } else {
  11447. fmt.Println(err)
  11448. }
  11449. userJSONBytes, _ := json.Marshal(dat)
  11450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11451. utils.ErrorLog("解析失败:%v", err)
  11452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11453. return
  11454. }
  11455. } else if miConfig.MdtrtareaAdmvs == "" {
  11456. var baseParams models.BaseParams
  11457. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11458. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11459. baseParams.SecretKey = miConfig.SecretKey
  11460. baseParams.OrgName = miConfig.OrgName
  11461. baseParams.FixmedinsCode = miConfig.Code
  11462. baseParams.EncKey = miConfig.EncKey
  11463. baseParams.AppSecret = miConfig.AppSecret
  11464. baseParams.SignKey = miConfig.SignKey
  11465. baseParams.AppID = miConfig.Code
  11466. baseParams.Doctor = role.UserName
  11467. baseParams.RequestUrl = miConfig.Url
  11468. businessParams := models.BusinessParams{
  11469. Insutype: insutype,
  11470. ClrType: clr_type,
  11471. SetlOptins: clr_org,
  11472. StmtBegndate: start_time,
  11473. StmtEnddate: end_time,
  11474. MedfeeSumamt: medfee_sumamt,
  11475. FundPaySumamt: fund_pay_sumamt,
  11476. AcctPay: acct_pay,
  11477. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11478. }
  11479. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11480. fmt.Println(requestLog)
  11481. fmt.Println(result)
  11482. fmt.Println(err_msg)
  11483. var dat map[string]interface{}
  11484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11485. fmt.Println(dat)
  11486. } else {
  11487. fmt.Println(err)
  11488. }
  11489. userJSONBytes, _ := json.Marshal(dat)
  11490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11491. utils.ErrorLog("解析失败:%v", err)
  11492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11493. return
  11494. }
  11495. } else {
  11496. if len(clr_type) == 0 {
  11497. clr_type = "11"
  11498. }
  11499. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11500. "insutype=" + insutype +
  11501. "&clr_type=" + clr_type +
  11502. "&setl_optins=" + clr_org +
  11503. "&stmt_begndate=" + start_time +
  11504. "&stm_enddate=" + end_time +
  11505. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11506. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11507. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11508. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11509. "&fixmedins_code=" + miConfig.Code +
  11510. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11511. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11512. "&secret_key=" + miConfig.SecretKey +
  11513. "&org_name=" + miConfig.OrgName +
  11514. "&doctor=" + user_name
  11515. fmt.Println(api)
  11516. resp, requestErr := http.Get(api)
  11517. if requestErr != nil {
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11519. return
  11520. }
  11521. body, ioErr := ioutil.ReadAll(resp.Body)
  11522. fmt.Println(body)
  11523. if ioErr != nil {
  11524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11526. return
  11527. }
  11528. var respJSON map[string]interface{}
  11529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11532. return
  11533. }
  11534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11535. userJSONBytes, _ := json.Marshal(respJSON)
  11536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11537. utils.ErrorLog("解析失败:%v", err)
  11538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11539. return
  11540. }
  11541. }
  11542. if res.Infcode == 0 {
  11543. if res.Output.Stmtinfo.StmtRslt == "0" {
  11544. micc := &models.MedicalInsuranceCostCompare{
  11545. StartTime: startime.Unix(),
  11546. EndTime: endtime.Unix(),
  11547. Insutype: insutype,
  11548. CheckType: 1,
  11549. Num: fixmedins_setl_cnt,
  11550. Mtime: time.Now().Unix(),
  11551. Status: 1,
  11552. UserOrgId: adminUser.CurrentOrgId,
  11553. CostTotal: medfee_sumamt,
  11554. FuncTotal: fund_pay_sumamt,
  11555. PsnPay: acct_pay,
  11556. Creator: admin_user_id,
  11557. Ctime: time.Now().Unix(),
  11558. ClrType: clr_type,
  11559. }
  11560. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11561. if err == nil {
  11562. c.ServeSuccessJSON(map[string]interface{}{
  11563. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11564. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11565. })
  11566. } else {
  11567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11568. }
  11569. } else {
  11570. c.ServeSuccessJSON(map[string]interface{}{
  11571. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11572. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11573. })
  11574. }
  11575. } else {
  11576. c.ServeSuccessJSON(map[string]interface{}{
  11577. "code": -10,
  11578. "msg": res.ErrMsg,
  11579. })
  11580. }
  11581. }
  11582. }
  11583. func (c *HisApiController) Check310() {
  11584. adminUser := c.GetAdminUserInfo()
  11585. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11586. var user_name string
  11587. user_name = "高慧裕"
  11588. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11589. "insutype=" + "310" +
  11590. "&clr_type=" + "" +
  11591. "&setl_optins=" + "441202" +
  11592. "&stmt_begndate=" + "2022-03-01" +
  11593. "&stm_enddate=" + "2022-03-31" +
  11594. "&medfee_sumamt=" + "194930.12" +
  11595. "&fund_pay_sumamt=" + "188741.46" +
  11596. "&acct_pay=" + "0" +
  11597. "&fixmedins_setl_cnt=" + "452" +
  11598. "&fixmedins_code=" + miConfig.Code +
  11599. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11600. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11601. "&secret_key=" + miConfig.SecretKey +
  11602. "&org_name=" + miConfig.OrgName +
  11603. "&doctor=" + user_name
  11604. fmt.Println(api)
  11605. resp, requestErr := http.Get(api)
  11606. if requestErr != nil {
  11607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11608. return
  11609. }
  11610. body, ioErr := ioutil.ReadAll(resp.Body)
  11611. fmt.Println(body)
  11612. if ioErr != nil {
  11613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11615. return
  11616. }
  11617. var respJSON map[string]interface{}
  11618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11621. return
  11622. }
  11623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11624. userJSONBytes, _ := json.Marshal(respJSON)
  11625. var res ResultEight
  11626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11627. utils.ErrorLog("解析失败:%v", err)
  11628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11629. return
  11630. }
  11631. }
  11632. func (c *HisApiController) Check390() {
  11633. adminUser := c.GetAdminUserInfo()
  11634. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11635. var user_name string
  11636. user_name = "高慧裕"
  11637. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11638. "insutype=" + "390" +
  11639. "&clr_type=" + "" +
  11640. "&setl_optins=" + "441202" +
  11641. "&stmt_begndate=" + "2022-03-01" +
  11642. "&stm_enddate=" + "2022-03-31" +
  11643. "&medfee_sumamt=" + "1068448.89" +
  11644. "&fund_pay_sumamt=" + "1014677.62" +
  11645. "&acct_pay=" + "0" +
  11646. "&fixmedins_setl_cnt=" + "1950" +
  11647. "&fixmedins_code=" + miConfig.Code +
  11648. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11649. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11650. "&secret_key=" + miConfig.SecretKey +
  11651. "&org_name=" + miConfig.OrgName +
  11652. "&doctor=" + user_name
  11653. fmt.Println(api)
  11654. resp, requestErr := http.Get(api)
  11655. if requestErr != nil {
  11656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11657. return
  11658. }
  11659. body, ioErr := ioutil.ReadAll(resp.Body)
  11660. fmt.Println(body)
  11661. if ioErr != nil {
  11662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11664. return
  11665. }
  11666. var respJSON map[string]interface{}
  11667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11670. return
  11671. }
  11672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11673. userJSONBytes, _ := json.Marshal(respJSON)
  11674. var res ResultEight
  11675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11676. utils.ErrorLog("解析失败:%v", err)
  11677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11678. return
  11679. }
  11680. }
  11681. //对账明细
  11682. func (c *HisApiController) GetCheckDetailAccount() {
  11683. start_time := c.GetString("start_time")
  11684. end_time := c.GetString("end_time")
  11685. admin_user_id, _ := c.GetInt64("admin_user_id")
  11686. adminUser := c.GetAdminUserInfo()
  11687. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11688. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11689. timeLayout := "2006-01-02"
  11690. loc, _ := time.LoadLocation("Local")
  11691. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11692. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11693. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11694. rand.Seed(time.Now().UnixNano())
  11695. num := rand.Intn(30000)
  11696. Mkdir(miConfig.OrgName)
  11697. file := strconv.FormatInt(int64(num), 10)
  11698. file_name := file + ".txt"
  11699. zip_name := file + ".zip"
  11700. zip_path := miConfig.OrgName + "/" + zip_name
  11701. file_path := miConfig.OrgName + "/" + file_name
  11702. decimal.DivisionPrecision = 2
  11703. var medfee_sumamt float64
  11704. var psn_cash_pay float64
  11705. var fund_pay_sumamt float64
  11706. fixmedins_setl_cnt := int64(len(orders))
  11707. for _, item := range orders {
  11708. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11709. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11710. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11711. }
  11712. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11713. defer f.Close()
  11714. if err != nil {
  11715. fmt.Println(err.Error())
  11716. } else {
  11717. for _, item := range orders {
  11718. var refd_setl_flag string
  11719. if item.OrderStatus == 2 {
  11720. refd_setl_flag = "0"
  11721. var str string
  11722. str = item.SetlId + " " +
  11723. item.MdtrtId + " " +
  11724. item.PsnNo + " " +
  11725. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11726. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11727. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11728. _, err = f.Write([]byte(str))
  11729. }
  11730. if item.OrderStatus == 3 {
  11731. var str string
  11732. str = item.SetlId + " " +
  11733. item.MdtrtId + " " +
  11734. item.PsnNo + " " +
  11735. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11736. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11737. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11738. _, err = f.Write([]byte(str))
  11739. var str2 string
  11740. str2 = item.SetlId + " " +
  11741. item.MdtrtId + " " +
  11742. item.PsnNo + " " +
  11743. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11744. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11745. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11746. _, err = f.Write([]byte(str2))
  11747. }
  11748. }
  11749. }
  11750. Zip(file_path, zip_path)
  11751. fmt.Println(ReadFile(zip_path))
  11752. fmt.Println(string(ReadFile(zip_path)))
  11753. if config.IsOpen == 1 {
  11754. var user_name string
  11755. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11756. if role.ID == 0 {
  11757. user_name = "管理员"
  11758. } else {
  11759. user_name = role.UserName
  11760. }
  11761. baseParams := models.BaseParams{
  11762. SecretKey: miConfig.SecretKey,
  11763. FixmedinsCode: miConfig.Code,
  11764. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11765. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11766. OrgName: miConfig.OrgName,
  11767. Doctor: user_name,
  11768. }
  11769. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11770. var dat map[string]interface{}
  11771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11772. fmt.Println(dat)
  11773. } else {
  11774. fmt.Println(err)
  11775. }
  11776. userJSONBytes, _ := json.Marshal(dat)
  11777. var res ResultNine
  11778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11779. utils.ErrorLog("解析失败:%v", err)
  11780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11781. return
  11782. }
  11783. if res.Infcode == 0 {
  11784. fileNo := res.Output.FileQuryNo
  11785. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11786. "file_qury_no=" + fileNo +
  11787. "&setl_optins=" + "定点医保中心" +
  11788. "&stmt_begndate=" + start_time +
  11789. "&stm_enddate=" + end_time +
  11790. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11791. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11792. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11793. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11794. "&fixmedins_code=" + miConfig.Code +
  11795. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11796. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11797. "&secret_key=" + miConfig.SecretKey +
  11798. "&org_name=" + miConfig.OrgName +
  11799. "&doctor=" + user_name
  11800. resp, requestErr := http.Get(api)
  11801. if requestErr != nil {
  11802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11803. return
  11804. }
  11805. body, ioErr := ioutil.ReadAll(resp.Body)
  11806. if ioErr != nil {
  11807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11809. return
  11810. }
  11811. var respJSON map[string]interface{}
  11812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11815. return
  11816. }
  11817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11818. userJSONBytes, _ := json.Marshal(respJSON)
  11819. var res ResultTen
  11820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11821. utils.ErrorLog("解析失败:%v", err)
  11822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11823. return
  11824. }
  11825. if res.Infcode == 0 {
  11826. service.Gdyb9102(baseParams, zip_name, fileNo)
  11827. micc := &models.MedicalInsuranceCostCompare{
  11828. StartTime: startime.Unix(),
  11829. EndTime: endtime.Unix(),
  11830. Insutype: "0",
  11831. CheckType: 2,
  11832. Num: fixmedins_setl_cnt,
  11833. Mtime: time.Now().Unix(),
  11834. Status: 1,
  11835. UserOrgId: adminUser.CurrentOrgId,
  11836. CostTotal: medfee_sumamt,
  11837. FuncTotal: fund_pay_sumamt,
  11838. PsnPay: psn_cash_pay,
  11839. Creator: admin_user_id,
  11840. Ctime: time.Now().Unix(),
  11841. }
  11842. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11843. c.ServeSuccessJSON(map[string]interface{}{
  11844. "msg": "明细对账成功",
  11845. })
  11846. }
  11847. } else {
  11848. }
  11849. }
  11850. }
  11851. type CustomOrderInfo struct {
  11852. Name string
  11853. Spec string
  11854. Unit string
  11855. Count float64
  11856. Price float64
  11857. Total float64
  11858. }
  11859. func (c *HisApiController) GetSettleAccounts() {
  11860. //id, _ := c.GetInt64("id")
  11861. //record_time := c.GetString("record_time")
  11862. order_id, _ := c.GetInt64("order_id")
  11863. admin_user_id, _ := c.GetInt64("admin_user_id")
  11864. //timeLayout := "2006-01-02"
  11865. //loc, _ := time.LoadLocation("Local")
  11866. //
  11867. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11868. //if err != nil {
  11869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11870. // return
  11871. //}
  11872. //recordDateTime := theTime.Unix()
  11873. adminUser := c.GetAdminUserInfo()
  11874. order, _ := service.GetHisOrderByID(order_id)
  11875. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11876. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11877. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11878. orderInfos = append(orderInfos, orderInfos_two...)
  11879. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11880. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11881. var diagnosis_ids []string
  11882. if his.ID > 0 {
  11883. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11884. } else {
  11885. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11886. }
  11887. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11888. var dia_config []*models.HisXtDiagnoseConfig
  11889. var name string
  11890. for _, item := range diagnosis_ids {
  11891. id, _ := strconv.ParseInt(item, 10, 64)
  11892. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11893. dia_config = append(dia_config, &diagnosisConfig)
  11894. if len(name) == 0 {
  11895. name = diagnosisConfig.ClassName
  11896. } else {
  11897. name = name + "," + diagnosisConfig.ClassName
  11898. }
  11899. }
  11900. var bedCostTotal float64 = 0 //床位总费
  11901. var bedCostSelfTotal float64 = 0 //床位自费
  11902. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11903. var operationCostTotal float64 = 0 //手术费
  11904. var operationCostSelfTotal float64 = 0 //手术费
  11905. var operationCostPartSelfTotal float64 = 0 //手术费
  11906. var otherCostTotal float64 = 0 //其他费用
  11907. var otherCostSelfTotal float64 = 0 //其他费用
  11908. var otherCostPartSelfTotal float64 = 0 //其他费用
  11909. var materialCostTotal float64 = 0 //材料费
  11910. var materialCostSelfTotal float64 = 0 //材料费
  11911. var materialCostPartSelfTotal float64 = 0 //材料费
  11912. var westernMedicineCostTotal float64 = 0 //西药费
  11913. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11914. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11915. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11916. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11917. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11918. var checkCostTotal float64 = 0 //检查费
  11919. var checkCostSelfTotal float64 = 0 //检查费
  11920. var checkCostPartSelfTotal float64 = 0 //检查费
  11921. var laboratoryCostTotal float64 = 0 //化验费
  11922. var laboratoryCostSelfTotal float64 = 0 //化验费
  11923. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11924. var treatCostTotal float64 = 0 //治疗费用
  11925. var treatCostSelfTotal float64 = 0 //治疗费用
  11926. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11927. decimal.DivisionPrecision = 2
  11928. for _, item := range orderInfos {
  11929. if item.MedChrgitmType == "01" { //床位费
  11930. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11931. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11932. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11933. }
  11934. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11935. if item.MedChrgitmType == "03" { //检查费
  11936. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11937. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11938. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11939. }
  11940. } else {
  11941. if item.MedChrgitmType == "03" { //检查费
  11942. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11943. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11944. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11945. }
  11946. }
  11947. if item.MedChrgitmType == "04" { //化验费
  11948. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11949. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11950. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11951. }
  11952. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11953. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11954. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11955. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11956. }
  11957. if item.MedChrgitmType == "06" { //手术费
  11958. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11959. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11960. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11961. }
  11962. if item.MedChrgitmType == "08" { //材料费
  11963. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11964. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11965. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11966. }
  11967. if item.MedChrgitmType == "09" { //西药费
  11968. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11969. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11970. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11971. }
  11972. if item.MedChrgitmType == "11" { //中成费
  11973. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11974. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11975. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11976. }
  11977. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11978. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11979. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11980. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11981. }
  11982. }
  11983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11984. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11985. var user_name string
  11986. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11987. if role.ID == 0 {
  11988. user_name = "管理员"
  11989. } else {
  11990. user_name = role.UserName
  11991. }
  11992. baseParams := models.BaseParams{
  11993. SecretKey: miConfig.SecretKey,
  11994. FixmedinsCode: miConfig.Code,
  11995. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11996. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11997. OrgName: miConfig.OrgName,
  11998. Doctor: user_name,
  11999. RequestUrl: miConfig.Url,
  12000. AccessKey: miConfig.AccessKey,
  12001. }
  12002. businessParams := models.BusinessParams{
  12003. PsnNo: order.PsnNo,
  12004. MdtrtId: order.MdtrtId,
  12005. SetlId: order.SetlId,
  12006. }
  12007. var res ResultEleven
  12008. var resEleven10265 ResultEleven10265
  12009. if config.IsOpen == 1 {
  12010. if miConfig.MdtrtareaAdmvs == "421300" {
  12011. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12012. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12014. resp, requestErr := http.Get(api)
  12015. if requestErr != nil {
  12016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12017. return
  12018. }
  12019. body, ioErr := ioutil.ReadAll(resp.Body)
  12020. if ioErr != nil {
  12021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12023. return
  12024. }
  12025. var respJSON map[string]interface{}
  12026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12029. return
  12030. }
  12031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12032. result, _ := json.Marshal(respJSON)
  12033. fmt.Println("log")
  12034. fmt.Println(string(result))
  12035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12036. utils.ErrorLog("解析失败:%v", err)
  12037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12038. return
  12039. }
  12040. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12041. var api string
  12042. if miConfig.MdtrtareaAdmvs == "320921" {
  12043. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12044. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12045. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12046. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12047. } else {
  12048. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12049. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12050. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12052. }
  12053. resp, requestErr := http.Get(api)
  12054. if requestErr != nil {
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. fmt.Println("log")
  12073. fmt.Println(string(result))
  12074. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12075. utils.ErrorLog("解析失败:%v", err)
  12076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12077. return
  12078. }
  12079. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12080. res.Output = resEleven10265.Output
  12081. res.ErrMsg = resEleven10265.ErrMsg
  12082. res.Cainfo = resEleven10265.Cainfo
  12083. res.WarnMsg = resEleven10265.WarnMsg
  12084. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12085. res.Infcode = infocode
  12086. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12087. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12088. saveLog(result, requestLog, "5203", "结算单")
  12089. var dat map[string]interface{}
  12090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12091. fmt.Println(dat)
  12092. } else {
  12093. fmt.Println(err)
  12094. }
  12095. userJSONBytes, _ := json.Marshal(dat)
  12096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12097. utils.ErrorLog("解析失败:%v", err)
  12098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12099. return
  12100. }
  12101. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12102. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12103. saveLog(result, requestLog, "5203", "结算单")
  12104. var dat map[string]interface{}
  12105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12106. fmt.Println(dat)
  12107. } else {
  12108. fmt.Println(err)
  12109. }
  12110. userJSONBytes, _ := json.Marshal(dat)
  12111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12112. utils.ErrorLog("解析失败:%v", err)
  12113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12114. return
  12115. }
  12116. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12117. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12118. saveLog(result, requestLog, "5203", "结算单")
  12119. var dat map[string]interface{}
  12120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12121. fmt.Println(dat)
  12122. } else {
  12123. fmt.Println(err)
  12124. }
  12125. userJSONBytes, _ := json.Marshal(dat)
  12126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12127. utils.ErrorLog("解析失败:%v", err)
  12128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12129. return
  12130. }
  12131. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12132. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12133. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12134. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12135. resp, requestErr := http.Get(api)
  12136. if requestErr != nil {
  12137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12138. return
  12139. }
  12140. body, ioErr := ioutil.ReadAll(resp.Body)
  12141. if ioErr != nil {
  12142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12144. return
  12145. }
  12146. var respJSON map[string]interface{}
  12147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12150. return
  12151. }
  12152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12153. result, _ := json.Marshal(respJSON)
  12154. fmt.Println("log")
  12155. fmt.Println(string(result))
  12156. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12157. utils.ErrorLog("解析失败:%v", err)
  12158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12159. return
  12160. }
  12161. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12162. res.Output = resEleven10265.Output
  12163. res.ErrMsg = resEleven10265.ErrMsg
  12164. res.Cainfo = resEleven10265.Cainfo
  12165. res.WarnMsg = resEleven10265.WarnMsg
  12166. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12167. res.Infcode = infocode
  12168. } else {
  12169. result := service.Gdyb5203(baseParams, businessParams)
  12170. //service.Gdyb5204(baseParams, businessParams)
  12171. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12172. var dat map[string]interface{}
  12173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12174. fmt.Println(dat)
  12175. } else {
  12176. fmt.Println(err)
  12177. }
  12178. userJSONBytes, _ := json.Marshal(dat)
  12179. if miConfig.Code == "H15049901371" {
  12180. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12181. utils.ErrorLog("解析失败:%v", err)
  12182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12183. return
  12184. }
  12185. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12186. res.Output = resEleven10265.Output
  12187. res.ErrMsg = resEleven10265.ErrMsg
  12188. res.Cainfo = resEleven10265.Cainfo
  12189. res.WarnMsg = resEleven10265.WarnMsg
  12190. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12191. res.Infcode = infocode
  12192. } else {
  12193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12194. utils.ErrorLog("解析失败:%v", err)
  12195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12196. return
  12197. }
  12198. }
  12199. }
  12200. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12201. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12202. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12203. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12204. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12205. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12206. var doctor_name string
  12207. if roles.ID == 0 {
  12208. doctor_name = "管理员"
  12209. } else {
  12210. doctor_name = roles.UserName
  12211. }
  12212. yiliao_leibie := ""
  12213. switch order.MedType {
  12214. case "11":
  12215. yiliao_leibie = "普通门诊"
  12216. break
  12217. case "12":
  12218. yiliao_leibie = "门诊挂号"
  12219. break
  12220. case "13":
  12221. yiliao_leibie = "急诊"
  12222. break
  12223. case "14":
  12224. yiliao_leibie = "门诊特殊病"
  12225. break
  12226. case "15":
  12227. yiliao_leibie = "门诊统筹"
  12228. break
  12229. case "16":
  12230. yiliao_leibie = "门诊慢性病"
  12231. break
  12232. case "21":
  12233. yiliao_leibie = "普通住院"
  12234. break
  12235. }
  12236. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12237. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12238. if res.Infcode == 0 {
  12239. c.ServeSuccessJSON(map[string]interface{}{
  12240. "diagnosis": name,
  12241. "order_infos": orderInfos,
  12242. "number": order.MdtrtId,
  12243. "date": order.SettleAccountsDate,
  12244. "charge_admin": charge_admin,
  12245. "printor_admin": printor_admin,
  12246. "info": res.Output.Setlinfo,
  12247. "order": order,
  12248. "bedCostTotal": bedCostTotal,
  12249. "bedCostSelfTotal": bedCostSelfTotal,
  12250. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12251. "operationCostTotal": operationCostTotal,
  12252. "operationCostSelfTotal": operationCostSelfTotal,
  12253. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12254. "otherCostTotal": otherCostTotal,
  12255. "otherCostSelfTotal": otherCostSelfTotal,
  12256. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12257. "materialCostTotal": materialCostTotal,
  12258. "materialCostSelfTotal": materialCostSelfTotal,
  12259. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12260. "westernMedicineCostTotal": westernMedicineCostTotal,
  12261. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12262. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12263. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12264. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12265. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12266. "checkCostTotal": checkCostTotal,
  12267. "checkCostSelfTotal": checkCostSelfTotal,
  12268. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12269. "laboratoryCostTotal": laboratoryCostTotal,
  12270. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12271. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12272. "treatCostTotal": treatCostTotal,
  12273. "treatCostSelfTotal": treatCostSelfTotal,
  12274. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12275. "doctor_info": doctor_info,
  12276. "doctor_code": adminRole_two.DoctorCode,
  12277. "doctor_name": doctor_name,
  12278. "health_card_no": order.PsnNo,
  12279. "department": departments.Name,
  12280. "yiliao_leibie": yiliao_leibie,
  12281. "after_money": order.AccountPrice,
  12282. "patient": patient,
  12283. "org_name": miConfig.OrgName,
  12284. "org_code": miConfig.Code,
  12285. "order_number": order.Number,
  12286. "his_hospital": his_hospital,
  12287. "his": his,
  12288. "dia_config": dia_config,
  12289. //"check_order_info": cus_slice,
  12290. })
  12291. }
  12292. }
  12293. }
  12294. func (c *HisApiController) CheckTreatment() {
  12295. patient_id, _ := c.GetInt64("patient_id")
  12296. id_card_no := c.GetString("id_card_no")
  12297. insutype := c.GetString("insutype")
  12298. med_type := c.GetString("med_type")
  12299. admin_user_id, _ := c.GetInt64("admin_user_id")
  12300. adminUser := c.GetAdminUserInfo()
  12301. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12304. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12305. if miConfig.MdtrtareaAdmvs == "421300" {
  12306. var res ResultTwo
  12307. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12308. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12309. "&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)
  12310. resp, requestErr := http.Get(api)
  12311. if requestErr != nil {
  12312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12313. return
  12314. }
  12315. body, ioErr := ioutil.ReadAll(resp.Body)
  12316. if ioErr != nil {
  12317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12319. return
  12320. }
  12321. var respJSON map[string]interface{}
  12322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. return
  12326. }
  12327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12328. result, _ := json.Marshal(respJSON)
  12329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. if res.Infcode == 0 {
  12335. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12336. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12338. resp, requestErr := http.Get(api)
  12339. if requestErr != nil {
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. body, ioErr := ioutil.ReadAll(resp.Body)
  12344. if ioErr != nil {
  12345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12347. return
  12348. }
  12349. var respJSON map[string]interface{}
  12350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12353. return
  12354. }
  12355. var res Result2001
  12356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12357. result2, _ := json.Marshal(respJSON)
  12358. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12359. utils.ErrorLog("解析失败:%v", err)
  12360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. return
  12362. }
  12363. if res.Infcode == 0 {
  12364. c.ServeSuccessJSON(map[string]interface{}{
  12365. "msg": res.Output.Trtinfo,
  12366. })
  12367. }
  12368. } else {
  12369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12370. return
  12371. }
  12372. } else {
  12373. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12374. var dat map[string]interface{}
  12375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12376. fmt.Println(dat)
  12377. } else {
  12378. fmt.Println(err)
  12379. }
  12380. userJSONBytes, _ := json.Marshal(dat)
  12381. var res ResultTwo
  12382. var res10265 ResultTwo10265
  12383. if miConfig.Code == "H15049901371" {
  12384. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12385. utils.ErrorLog("解析失败:%v", err)
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. res.ErrMsg = res10265.ErrMsg
  12390. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12391. res.Infcode = infocode
  12392. res.Output = res10265.Output
  12393. res.InfRefmsgid = res10265.InfRefmsgid
  12394. } else {
  12395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12396. utils.ErrorLog("解析失败:%v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return
  12399. }
  12400. }
  12401. var user_name string
  12402. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12403. if role.ID == 0 {
  12404. user_name = "xxx"
  12405. } else {
  12406. user_name = role.UserName
  12407. }
  12408. baseParams := models.BaseParams{
  12409. SecretKey: miConfig.SecretKey,
  12410. FixmedinsCode: miConfig.Code,
  12411. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12412. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12413. OrgName: miConfig.OrgName,
  12414. Doctor: user_name,
  12415. }
  12416. if config.IsOpen == 1 {
  12417. if miConfig.Code == "H15049901371" {
  12418. if med_type == "14" {
  12419. if insutype == "390" {
  12420. med_type = "9933"
  12421. } else if insutype == "310" {
  12422. med_type = "990502"
  12423. }
  12424. } else if med_type == "11" {
  12425. med_type = "11"
  12426. }
  12427. }
  12428. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12429. var dat map[string]interface{}
  12430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12431. fmt.Println(dat)
  12432. } else {
  12433. fmt.Println(err)
  12434. }
  12435. var res Result2001
  12436. var res10265 Result2001Org10265
  12437. if miConfig.Code == "H15049901371" {
  12438. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12439. utils.ErrorLog("解析失败:%v", err)
  12440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12441. return
  12442. }
  12443. res.ErrMsg = res10265.ErrMsg
  12444. res.Output = res10265.Output
  12445. res.InfRefmsgid = res10265.InfRefmsgid
  12446. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12447. res.Infcode = infocode
  12448. } else {
  12449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12450. utils.ErrorLog("解析失败:%v", err)
  12451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12452. return
  12453. }
  12454. }
  12455. if res.Infcode == 0 {
  12456. c.ServeSuccessJSON(map[string]interface{}{
  12457. "msg": res.Output.Trtinfo,
  12458. })
  12459. }
  12460. }
  12461. }
  12462. }
  12463. //func (c *HisApiController) PutRecord() {
  12464. // id, _ := c.GetInt64("id")
  12465. // record_time := c.GetString("record_time")
  12466. // timeLayout := "2006-01-02"
  12467. // loc, _ := time.LoadLocation("Local")
  12468. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12469. // if err != nil {
  12470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12471. // return
  12472. // }
  12473. // recordDateTime := theTime.Unix()
  12474. //
  12475. // adminInfo := c.GetAdminUserInfo()
  12476. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12477. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12478. //
  12479. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12480. //
  12481. // fmt.Println(miConfig.SecretKey)
  12482. //
  12483. // if patient == nil {
  12484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12485. // return
  12486. // }
  12487. // if len(patient.IdCardNo) == 0 {
  12488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12489. // return
  12490. // }
  12491. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12492. // if config.IsOpen == 1 {
  12493. // 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
  12494. // resp, requestErr := http.Get(api)
  12495. // if requestErr != nil {
  12496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12497. // return
  12498. // }
  12499. // defer resp.Body.Close()
  12500. // body, ioErr := ioutil.ReadAll(resp.Body)
  12501. // if ioErr != nil {
  12502. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. // return
  12505. // }
  12506. // var respJSON map[string]interface{}
  12507. //
  12508. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12509. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12511. // return
  12512. // }
  12513. //
  12514. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12515. // userJSONBytes, _ := json.Marshal(userJSON)
  12516. // var res ResultTwo
  12517. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12518. // utils.ErrorLog("解析失败:%v", err)
  12519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12520. // return
  12521. // }
  12522. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12523. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12524. // infoStr := string(Iinfos)
  12525. // idetinfoStr := string(Idetinfos)
  12526. //
  12527. // if res.Infcode == 0 {
  12528. // his := models.VMHisPatient{
  12529. // Status: 1,
  12530. // Ctime: time.Now().Unix(),
  12531. // Mtime: time.Now().Unix(),
  12532. // PsnNo: res.Output.Baseinfo.PsnNo,
  12533. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12534. // Certno: res.Output.Baseinfo.Certno,
  12535. // PsnName: res.Output.Baseinfo.PsnName,
  12536. // Gend: res.Output.Baseinfo.Gend,
  12537. // Naty: res.Output.Baseinfo.Naty,
  12538. // Brdy: res.Output.Baseinfo.Brdy,
  12539. // Age: res.Output.Baseinfo.Age,
  12540. // Iinfo: infoStr,
  12541. // Idetinfo: idetinfoStr,
  12542. // PatientId: patient.ID,
  12543. // RecordDate: theTime.Unix(),
  12544. // UserOrgId: adminInfo.CurrentOrgId,
  12545. // AdminUserId: adminInfo.AdminUser.Id,
  12546. // IsReturn: 1,
  12547. // }
  12548. //
  12549. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12550. // //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")
  12551. // //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")
  12552. //
  12553. // //var dat map[string]interface{}
  12554. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12555. // // fmt.Println(dat)
  12556. // //} else {
  12557. // // fmt.Println(err)
  12558. // //}
  12559. //
  12560. // var dat2 map[string]interface{}
  12561. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12562. // fmt.Println(dat2)
  12563. // } else {
  12564. // fmt.Println(err)
  12565. // }
  12566. //
  12567. // } else {
  12568. // adminUser := c.GetAdminUserInfo()
  12569. // errlog := &models.HisOrderError{
  12570. // UserOrgId: adminUser.CurrentOrgId,
  12571. // Ctime: time.Now().Unix(),
  12572. // Mtime: time.Now().Unix(),
  12573. // ErrMsg: res.ErrMsg,
  12574. // Status: 1,
  12575. // PatientId: id,
  12576. // RecordTime: recordDateTime,
  12577. // Stage: 1,
  12578. // }
  12579. // service.CreateErrMsgLog(errlog)
  12580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12581. // return
  12582. // }
  12583. // }
  12584. //
  12585. //}
  12586. //func (c *HisApiController) GetUploadDiag() {
  12587. // id, _ := c.GetInt64("id")
  12588. // record_time := c.GetString("record_time")
  12589. //
  12590. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12591. // sick_type, _ := c.GetInt64("sick_type")
  12592. // reg_type, _ := c.GetInt64("reg_type")
  12593. //
  12594. // timeLayout := "2006-01-02"
  12595. // loc, _ := time.LoadLocation("Local")
  12596. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12597. // if err != nil {
  12598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12599. // return
  12600. // }
  12601. //
  12602. // var patientPrescription models.HisPrescriptionInfo
  12603. // recordDateTime := theTime.Unix()
  12604. // adminInfo := c.GetAdminUserInfo()
  12605. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12606. //
  12607. // if patientPrescription.ID == 0 {
  12608. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12609. // }
  12610. //
  12611. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12612. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12613. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12614. // sickConfig, _ := service.FindSickById(sick_type)
  12615. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12616. //
  12617. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12618. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12619. // "&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 +
  12620. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12621. // resp2, requestErr2 := http.Get(api2)
  12622. // if requestErr2 != nil {
  12623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12624. // return
  12625. // }
  12626. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12627. // if ioErr2 != nil {
  12628. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12630. // return
  12631. // }
  12632. // var respJSON2 map[string]interface{}
  12633. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12636. // return
  12637. // }
  12638. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12639. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12640. //
  12641. // var res2 ResultSix
  12642. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12643. // utils.ErrorLog("解析失败:%v", err)
  12644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12645. // return
  12646. // }
  12647. // if res2.Infcode != 0 {
  12648. // adminUser := c.GetAdminUserInfo()
  12649. // errlog := &models.HisOrderError{
  12650. // UserOrgId: adminUser.CurrentOrgId,
  12651. // Ctime: time.Now().Unix(),
  12652. // Mtime: time.Now().Unix(),
  12653. // ErrMsg: res2.ErrMsg,
  12654. // Status: 1,
  12655. // PatientId: id,
  12656. // RecordTime: recordDateTime,
  12657. // Stage: 3,
  12658. // }
  12659. // service.CreateErrMsgLog(errlog)
  12660. //
  12661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12662. // return
  12663. // }
  12664. //
  12665. // c.ServeSuccessJSON(map[string]interface{}{
  12666. // "msg": "上传成功",
  12667. // })
  12668. //
  12669. //}
  12670. type QueryResult struct {
  12671. ID int64
  12672. Name string
  12673. Code string
  12674. List_type_code string
  12675. }
  12676. func (c *HisApiController) GetCheckCode() {
  12677. ids_str := c.GetString("ids")
  12678. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12679. ids_arr := strings.Split(ids_str, ",")
  12680. var queryResult []QueryResult
  12681. ids := make([]int64, 0)
  12682. for _, item := range ids_arr {
  12683. id, _ := strconv.ParseInt(item, 10, 64)
  12684. ids = append(ids, id)
  12685. }
  12686. if record_type == 1 {
  12687. drugs, _ := service.GetBatchDrugList(ids)
  12688. for _, item := range drugs {
  12689. result := QueryResult{
  12690. ID: item.ID,
  12691. Name: item.DrugName,
  12692. Code: item.MedicalInsuranceNumber,
  12693. List_type_code: "101",
  12694. }
  12695. queryResult = append(queryResult, result)
  12696. }
  12697. } else if record_type == 2 {
  12698. goods, _ := service.GetBatchGoodInformationList(ids)
  12699. for _, item := range goods {
  12700. result := QueryResult{
  12701. ID: item.ID,
  12702. Name: item.GoodName,
  12703. Code: item.MedicalInsuranceNumber,
  12704. List_type_code: "301",
  12705. }
  12706. queryResult = append(queryResult, result)
  12707. }
  12708. } else if record_type == 3 {
  12709. projects, _ := service.GetBathchMyPorjecgList(ids)
  12710. for _, item := range projects {
  12711. result := QueryResult{
  12712. ID: item.ID,
  12713. Name: item.ProjectName,
  12714. Code: item.MedicalCode,
  12715. List_type_code: "201",
  12716. }
  12717. queryResult = append(queryResult, result)
  12718. }
  12719. }
  12720. admin_user_id, _ := c.GetInt64("admin_user_id")
  12721. adminUser := c.GetAdminUserInfo()
  12722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12723. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12724. var user_name string
  12725. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12726. if role.ID == 0 {
  12727. user_name = "xxx"
  12728. } else {
  12729. user_name = role.UserName
  12730. }
  12731. baseParams := &models.BaseParams{
  12732. SecretKey: miConfig.SecretKey,
  12733. FixmedinsCode: miConfig.Code,
  12734. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12735. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12736. OrgName: miConfig.OrgName,
  12737. Doctor: user_name,
  12738. }
  12739. if config.IsOpen == 1 {
  12740. for _, item := range queryResult {
  12741. var result string
  12742. if record_type == 1 {
  12743. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12744. } else if record_type == 2 {
  12745. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12746. } else if record_type == 3 {
  12747. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12748. }
  12749. var dat map[string]interface{}
  12750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12751. fmt.Println(dat)
  12752. } else {
  12753. fmt.Println(err)
  12754. }
  12755. userJSONBytes, _ := json.Marshal(dat)
  12756. var res ResultSix
  12757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12758. utils.ErrorLog("解析失败:%v", err)
  12759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12760. return
  12761. }
  12762. if res.Infcode == 0 {
  12763. if record_type == 1 {
  12764. service.UpdateBaseDrugById(item.ID)
  12765. } else if record_type == 2 {
  12766. service.UpdateGoodInformaitonByDetail(item.ID)
  12767. } else if record_type == 3 {
  12768. service.UpdateProjectById(item.ID)
  12769. }
  12770. c.ServeSuccessJSON(map[string]interface{}{
  12771. "failed_code": 0,
  12772. "msg": "目录对照成功",
  12773. })
  12774. } else {
  12775. c.ServeSuccessJSON(map[string]interface{}{
  12776. "failed_code": -10,
  12777. "msg": res.ErrMsg,
  12778. })
  12779. }
  12780. }
  12781. }
  12782. }
  12783. func (c *HisApiController) UnCheckCode() {
  12784. ids_str := c.GetString("ids")
  12785. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12786. admin_user_id, _ := c.GetInt64("admin_user_id")
  12787. ids_arr := strings.Split(ids_str, ",")
  12788. var queryResult []QueryResult
  12789. ids := make([]int64, 0)
  12790. for _, item := range ids_arr {
  12791. id, _ := strconv.ParseInt(item, 10, 64)
  12792. ids = append(ids, id)
  12793. }
  12794. if record_type == 1 {
  12795. drugs, _ := service.GetBatchDrugList(ids)
  12796. for _, item := range drugs {
  12797. result := QueryResult{
  12798. ID: item.ID,
  12799. Name: item.DrugName,
  12800. Code: item.MedicalInsuranceNumber,
  12801. List_type_code: "101",
  12802. }
  12803. queryResult = append(queryResult, result)
  12804. }
  12805. } else if record_type == 2 {
  12806. goods, _ := service.GetBatchGoodInformationList(ids)
  12807. for _, item := range goods {
  12808. result := QueryResult{
  12809. ID: item.ID,
  12810. Name: item.GoodName,
  12811. Code: item.MedicalInsuranceNumber,
  12812. List_type_code: "301",
  12813. }
  12814. queryResult = append(queryResult, result)
  12815. }
  12816. } else if record_type == 3 {
  12817. projects, _ := service.GetBathchMyPorjecgList(ids)
  12818. for _, item := range projects {
  12819. result := QueryResult{
  12820. ID: item.ID,
  12821. Name: item.ProjectName,
  12822. Code: item.MedicalCode,
  12823. List_type_code: "201",
  12824. }
  12825. queryResult = append(queryResult, result)
  12826. }
  12827. }
  12828. adminUser := c.GetAdminUserInfo()
  12829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12830. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12831. var user_name string
  12832. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12833. if role.ID == 0 {
  12834. user_name = "xxx"
  12835. } else {
  12836. user_name = role.UserName
  12837. }
  12838. baseParams := &models.BaseParams{
  12839. SecretKey: miConfig.SecretKey,
  12840. FixmedinsCode: miConfig.Code,
  12841. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12842. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12843. OrgName: miConfig.OrgName,
  12844. Doctor: user_name,
  12845. }
  12846. if config.IsOpen == 1 {
  12847. for _, item := range queryResult {
  12848. var result string
  12849. if record_type == 1 {
  12850. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12851. } else if record_type == 2 {
  12852. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12853. } else if record_type == 3 {
  12854. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12855. }
  12856. var dat2 map[string]interface{}
  12857. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12858. fmt.Println(dat2)
  12859. } else {
  12860. fmt.Println(err)
  12861. }
  12862. userJSONBytes, _ := json.Marshal(dat2)
  12863. var res ResultSix
  12864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12865. utils.ErrorLog("解析失败:%v", err)
  12866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12867. return
  12868. }
  12869. if res.Infcode == 0 {
  12870. if record_type == 1 {
  12871. service.UpdateDrugByIdDetail(item.ID)
  12872. } else if record_type == 2 {
  12873. service.UpdateGoodInfoById(item.ID)
  12874. } else if record_type == 3 {
  12875. service.UpdateMyProjectById(item.ID)
  12876. }
  12877. c.ServeSuccessJSON(map[string]interface{}{
  12878. "failed_code": 0,
  12879. "msg": "撤销目录对照成功",
  12880. })
  12881. } else {
  12882. c.ServeSuccessJSON(map[string]interface{}{
  12883. "failed_code": -10,
  12884. "msg": res.ErrMsg,
  12885. })
  12886. }
  12887. }
  12888. }
  12889. }
  12890. func (c *HisApiController) GetPatientInfo() {
  12891. id_card_no := c.GetString("id_card_no")
  12892. admin_user_id, _ := c.GetInt64("admin_user_id")
  12893. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12894. if patient.ID == 0 {
  12895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12896. return
  12897. }
  12898. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12899. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12900. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12901. if config.IsOpen == 1 {
  12902. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12903. var dat map[string]interface{}
  12904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12905. fmt.Println(dat)
  12906. } else {
  12907. fmt.Println(err)
  12908. }
  12909. userJSONBytes, _ := json.Marshal(dat)
  12910. var res ResultTwo
  12911. var res10265 ResultTwo10265
  12912. if miConfig.Code == "H15049901371" {
  12913. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12914. utils.ErrorLog("解析失败:%v", err)
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12916. return
  12917. }
  12918. res.ErrMsg = res10265.ErrMsg
  12919. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12920. res.Infcode = infocode
  12921. res.Output = res10265.Output
  12922. res.InfRefmsgid = res10265.InfRefmsgid
  12923. } else {
  12924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12925. utils.ErrorLog("解析失败:%v", err)
  12926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12927. return
  12928. }
  12929. }
  12930. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12931. // utils.ErrorLog("解析失败:%v", err)
  12932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12933. // return
  12934. //}
  12935. if res.Infcode != 0 {
  12936. c.ServeSuccessJSON(map[string]interface{}{
  12937. "failed_code": -10,
  12938. "msg": res.ErrMsg,
  12939. })
  12940. } else {
  12941. c.ServeSuccessJSON(map[string]interface{}{
  12942. "failed_code": 0,
  12943. "info": res,
  12944. })
  12945. }
  12946. }
  12947. }
  12948. func (c *HisApiController) PsnPutOnRecord() {
  12949. record_type, _ := c.GetInt64("type")
  12950. patient_id, _ := c.GetInt64("patient_id")
  12951. admin_user_id, _ := c.GetInt64("admin_user_id")
  12952. start_time := c.GetString("start_time")
  12953. end_time := c.GetString("end_time")
  12954. adminUser := c.GetAdminUserInfo()
  12955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12956. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12957. var patients []*models.Patients
  12958. if record_type == 1 { //全部备案
  12959. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12960. patients = append(patients, patient...)
  12961. } else { //单个备案
  12962. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12963. patients = append(patients, patient)
  12964. }
  12965. var user_name string
  12966. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12967. if role.ID == 0 {
  12968. user_name = "xxx"
  12969. } else {
  12970. user_name = role.UserName
  12971. }
  12972. if config.IsOpen == 1 {
  12973. for _, item := range patients {
  12974. 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
  12975. resp, requestErr := http.Get(api)
  12976. if requestErr != nil {
  12977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12978. return
  12979. }
  12980. defer resp.Body.Close()
  12981. body, ioErr := ioutil.ReadAll(resp.Body)
  12982. if ioErr != nil {
  12983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12985. return
  12986. }
  12987. var respJSON map[string]interface{}
  12988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12991. return
  12992. }
  12993. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12994. userJSONBytes, _ := json.Marshal(userJSON)
  12995. var res ResultTwo
  12996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12997. utils.ErrorLog("解析失败:%v", err)
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12999. return
  13000. }
  13001. if res.Infcode == 0 {
  13002. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13003. var dat map[string]interface{}
  13004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13005. fmt.Println(dat)
  13006. } else {
  13007. fmt.Println(err)
  13008. }
  13009. userJSONBytes, _ := json.Marshal(dat)
  13010. var res2 ResultThirteen
  13011. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13012. utils.ErrorLog("解析失败:%v", err)
  13013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13014. return
  13015. }
  13016. if res2.Infcode == 0 {
  13017. psnResult := &models.GdybPsnRecord{
  13018. UserOrgId: adminUser.CurrentOrgId,
  13019. PatientId: item.ID,
  13020. PsnNo: res.Output.Baseinfo.PsnNo,
  13021. Ctime: time.Now().Unix(),
  13022. Mtime: time.Now().Unix(),
  13023. Status: 1,
  13024. IsCancel: 1,
  13025. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13026. }
  13027. service.CreatePsnRecord(psnResult)
  13028. } else {
  13029. c.ServeSuccessJSON(map[string]interface{}{
  13030. "failed_code": -10,
  13031. "msg": res2.ErrMsg,
  13032. })
  13033. return
  13034. }
  13035. }
  13036. }
  13037. }
  13038. }
  13039. func (c *HisApiController) PsnUnPutOnRecord() {
  13040. id, _ := c.GetInt64("id")
  13041. //record_type, _ := c.GetInt64("type")
  13042. admin_user_id, _ := c.GetInt64("admin_user_id")
  13043. adminUser := c.GetAdminUserInfo()
  13044. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13045. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13046. var user_name string
  13047. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13048. if role.ID == 0 {
  13049. user_name = "xxx"
  13050. } else {
  13051. user_name = role.UserName
  13052. }
  13053. psn_record, _ := service.GetPsnRecordById(id)
  13054. if psn_record.ID == 0 {
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13056. return
  13057. }
  13058. if config.IsOpen == 1 {
  13059. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13060. var dat map[string]interface{}
  13061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13062. fmt.Println(dat)
  13063. } else {
  13064. fmt.Println(err)
  13065. }
  13066. userJSONBytes, _ := json.Marshal(dat)
  13067. var res ResultFourteen
  13068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13069. utils.ErrorLog("解析失败:%v", err)
  13070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13071. return
  13072. }
  13073. if res.Infcode == 0 {
  13074. psn_record.IsCancel = 2
  13075. service.CreatePsnRecord(&psn_record)
  13076. } else {
  13077. c.ServeSuccessJSON(map[string]interface{}{
  13078. "failed_code": -10,
  13079. "msg": res.ErrMsg,
  13080. })
  13081. return
  13082. }
  13083. }
  13084. }
  13085. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13086. patient_id, _ := c.GetInt64("patient_id")
  13087. insutype_two := c.GetString("insutype")
  13088. psn_no := c.GetString("psn_no")
  13089. doctor_id, _ := c.GetInt64("doctor_id")
  13090. sick_id, _ := c.GetInt64("sick_id")
  13091. department_id, _ := c.GetInt64("department_id")
  13092. start_time := c.GetString("start_time")
  13093. end_time := c.GetString("end_time")
  13094. check_time := c.GetString("check_time")
  13095. hospital_code := c.GetString("hospital_code")
  13096. hospital_name := c.GetString("hospital_name")
  13097. adminUser := c.GetAdminUserInfo()
  13098. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13100. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13101. sick, _ := service.FindSickById(sick_id)
  13102. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13103. if len(hospital_code) == 0 {
  13104. hospital_code = miConfig.Code
  13105. }
  13106. if len(hospital_name) == 0 {
  13107. hospital_name = miConfig.OrgName
  13108. }
  13109. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13110. var res ResultTwo
  13111. var res10265 ResultTwo10265
  13112. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13113. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13114. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13115. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13116. "&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
  13117. resp, requestErr := http.Get(api)
  13118. if requestErr != nil {
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13120. return
  13121. }
  13122. body, ioErr := ioutil.ReadAll(resp.Body)
  13123. if ioErr != nil {
  13124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13126. return
  13127. }
  13128. var respJSON map[string]interface{}
  13129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13132. return
  13133. }
  13134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13135. result, _ := json.Marshal(respJSON)
  13136. fmt.Println("log")
  13137. fmt.Println(string(result))
  13138. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13139. utils.ErrorLog("解析失败:%v", err)
  13140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13141. return
  13142. }
  13143. res.ErrMsg = res10265.ErrMsg
  13144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13145. res.Infcode = infocode
  13146. res.Output = res10265.Output
  13147. res.InfRefmsgid = res10265.InfRefmsgid
  13148. } else {
  13149. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13150. if miConfig.Code == "H15049901371" {
  13151. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13152. utils.ErrorLog("解析失败:%v", err)
  13153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13154. return
  13155. }
  13156. res.ErrMsg = res10265.ErrMsg
  13157. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13158. res.Infcode = infocode
  13159. res.Output = res10265.Output
  13160. res.InfRefmsgid = res10265.InfRefmsgid
  13161. } else {
  13162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13163. utils.ErrorLog("解析失败:%v", err)
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. return
  13166. }
  13167. }
  13168. }
  13169. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13170. infoStr := string(Iinfos)
  13171. var rf []*ResultFive
  13172. json.Unmarshal([]byte(infoStr), &rf)
  13173. var insuplc_admdvs string
  13174. var insutype string
  13175. var is390 int = 0
  13176. var is310 int = 0
  13177. var insutypes []*ResultFive
  13178. for _, item := range rf {
  13179. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13180. insutypes = append(insutypes, item)
  13181. }
  13182. }
  13183. if len(insutypes) == 1 {
  13184. insutype = insutypes[0].Insutype
  13185. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13186. } else {
  13187. for _, i := range insutypes {
  13188. if i.Insutype == "390" {
  13189. is390 = 1
  13190. }
  13191. if i.Insutype == "310" {
  13192. is310 = 1
  13193. }
  13194. }
  13195. }
  13196. if is390 == 1 {
  13197. insutype = "390"
  13198. }
  13199. if is310 == 1 {
  13200. insutype = "310"
  13201. }
  13202. if len(insutypes) == 2 {
  13203. insutype = insutype_two
  13204. }
  13205. if len(insutypes) == 0 {
  13206. insutype = "310"
  13207. }
  13208. insutype = insutype_two
  13209. fmt.Println(insutype)
  13210. for _, item := range rf {
  13211. fmt.Println(item.Insutype)
  13212. fmt.Println(insutype)
  13213. if item.Insutype == insutype {
  13214. fmt.Println(item.Insutype)
  13215. fmt.Println(insutype)
  13216. insuplc_admdvs = item.InsuplcAdmdvs
  13217. }
  13218. }
  13219. fmt.Println(insuplc_admdvs)
  13220. var res2 ResultThirteen
  13221. var res10265_2 ResultThirteen10265
  13222. if config.IsOpen == 1 {
  13223. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13224. } else {
  13225. 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, hospital_code, hospital_name)
  13226. var dat map[string]interface{}
  13227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13228. fmt.Println(dat)
  13229. } else {
  13230. fmt.Println(err)
  13231. }
  13232. userJSONBytes, _ := json.Marshal(dat)
  13233. if miConfig.Code == "H15049901371" {
  13234. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13235. utils.ErrorLog("解析失败:%v", err)
  13236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13237. return
  13238. }
  13239. res2.ErrMsg = res10265_2.ErrMsg
  13240. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13241. res2.Infcode = infocode
  13242. res2.Output = res10265_2.Output
  13243. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13244. } else {
  13245. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13246. utils.ErrorLog("解析失败:%v", err)
  13247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13248. return
  13249. }
  13250. }
  13251. }
  13252. if res2.Infcode == 0 {
  13253. psnResult := &models.GdybPsnNcdsRecord{
  13254. UserOrgId: adminUser.CurrentOrgId,
  13255. PatientId: patient.ID,
  13256. PsnNo: psn_no,
  13257. DoctorId: doctor.AdminUserId,
  13258. DepartmentId: department_id,
  13259. SickType: sick_id,
  13260. Insutype: insutype,
  13261. Ctime: time.Now().Unix(),
  13262. Mtime: time.Now().Unix(),
  13263. Status: 1,
  13264. IsCancel: 1,
  13265. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13266. }
  13267. service.CreatePsnNCDSRecord(psnResult)
  13268. c.ServeSuccessJSON(map[string]interface{}{
  13269. "failed_code": 0,
  13270. "msg": "备案成功",
  13271. "result": psnResult,
  13272. })
  13273. } else {
  13274. c.ServeSuccessJSON(map[string]interface{}{
  13275. "failed_code": -10,
  13276. "msg": res2.ErrMsg,
  13277. })
  13278. return
  13279. }
  13280. }
  13281. }
  13282. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13283. id, _ := c.GetInt64("id")
  13284. admin_user_id, _ := c.GetInt64("admin_user_id")
  13285. adminUser := c.GetAdminUserInfo()
  13286. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13287. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13288. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13289. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13290. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13291. //var user_name string
  13292. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13293. //if role.ID == 0 {
  13294. // user_name = "xxx"
  13295. //} else {
  13296. // user_name = role.UserName
  13297. //}
  13298. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13299. if psn_record.ID == 0 {
  13300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13301. return
  13302. }
  13303. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13304. var res ResultTwo
  13305. var res10265 ResultTwo10265
  13306. if miConfig.Code == "H15049901371" {
  13307. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13308. utils.ErrorLog("解析失败:%v", err)
  13309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13310. return
  13311. }
  13312. res.ErrMsg = res10265.ErrMsg
  13313. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13314. res.Infcode = infocode
  13315. res.Output = res10265.Output
  13316. res.InfRefmsgid = res10265.InfRefmsgid
  13317. } else {
  13318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13319. utils.ErrorLog("解析失败:%v", err)
  13320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13321. return
  13322. }
  13323. }
  13324. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13325. infoStr := string(Iinfos)
  13326. var rf []*ResultFive
  13327. json.Unmarshal([]byte(infoStr), &rf)
  13328. var insuplc_admdvs string
  13329. var insutype string
  13330. var is390 int = 0
  13331. var is310 int = 0
  13332. var insutypes []*ResultFive
  13333. for _, item := range rf {
  13334. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13335. insutypes = append(insutypes, item)
  13336. }
  13337. }
  13338. if len(insutypes) == 1 {
  13339. insutype = insutypes[0].Insutype
  13340. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13341. } else {
  13342. for _, i := range insutypes {
  13343. if i.Insutype == "390" {
  13344. is390 = 1
  13345. }
  13346. if i.Insutype == "310" {
  13347. is310 = 1
  13348. }
  13349. }
  13350. }
  13351. if is390 == 1 {
  13352. insutype = "390"
  13353. }
  13354. if is310 == 1 {
  13355. insutype = "310"
  13356. }
  13357. if len(insutypes) == 0 {
  13358. insutype = "310"
  13359. }
  13360. insutype = psn_record.Insutype
  13361. for _, item := range rf {
  13362. if item.Insutype == insutype {
  13363. insuplc_admdvs = item.InsuplcAdmdvs
  13364. }
  13365. }
  13366. if config.IsOpen == 1 {
  13367. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13368. var dat map[string]interface{}
  13369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13370. fmt.Println(dat)
  13371. } else {
  13372. fmt.Println(err)
  13373. }
  13374. userJSONBytes, _ := json.Marshal(dat)
  13375. var res ResultFourteen
  13376. var res10265 ResultFourteen10265
  13377. if miConfig.Code == "H15049901371" {
  13378. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13379. utils.ErrorLog("解析失败:%v", err)
  13380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13381. return
  13382. }
  13383. res.ErrMsg = res10265.ErrMsg
  13384. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13385. res.Infcode = infocode
  13386. res.Output = res10265.Output
  13387. res.InfRefmsgid = res10265.InfRefmsgid
  13388. } else {
  13389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13390. utils.ErrorLog("解析失败:%v", err)
  13391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13392. return
  13393. }
  13394. }
  13395. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13396. // utils.ErrorLog("解析失败:%v", err)
  13397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13398. // return
  13399. //}
  13400. if res.Infcode == 0 {
  13401. psn_record.IsCancel = 2
  13402. service.CreatePsnNCDSRecord(&psn_record)
  13403. c.ServeSuccessJSON(map[string]interface{}{
  13404. "failed_code": 0,
  13405. "msg": "撤销备案成功",
  13406. })
  13407. } else {
  13408. c.ServeSuccessJSON(map[string]interface{}{
  13409. "failed_code": -10,
  13410. "msg": res.ErrMsg,
  13411. })
  13412. return
  13413. }
  13414. }
  13415. }
  13416. func (c *HisApiController) TestTest() {
  13417. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13418. fmt.Println(patient.Iinfo)
  13419. }
  13420. type CustomData struct {
  13421. MsgId string
  13422. PsnNo string
  13423. Info string
  13424. }
  13425. func (c *HisApiController) ReversalData() {
  13426. var customData []*CustomData
  13427. custom := &CustomData{
  13428. MsgId: "H44022900158202103301714472004",
  13429. PsnNo: "44020000001101329945",
  13430. Info: "2207",
  13431. }
  13432. customData = append(customData, custom)
  13433. custom1 := &CustomData{
  13434. MsgId: "H4402290015820210330172057803",
  13435. PsnNo: "44020000001101161813",
  13436. Info: "2207",
  13437. }
  13438. customData = append(customData, custom1)
  13439. custom2 := &CustomData{
  13440. MsgId: "H44022900158202103301705198813",
  13441. PsnNo: "44190000133097375417",
  13442. Info: "2207",
  13443. }
  13444. customData = append(customData, custom2)
  13445. custom3 := &CustomData{
  13446. MsgId: "H44022900158202103301715524756",
  13447. PsnNo: "44020000001100187221",
  13448. Info: "2207",
  13449. }
  13450. customData = append(customData, custom3)
  13451. custom4 := &CustomData{
  13452. MsgId: "H44022900158202103301730376224",
  13453. PsnNo: "44020000001101959155",
  13454. Info: "2207",
  13455. }
  13456. customData = append(customData, custom4)
  13457. custom5 := &CustomData{
  13458. MsgId: "H44022900158202103301748008725",
  13459. PsnNo: "44020000001104246641",
  13460. Info: "2207",
  13461. }
  13462. customData = append(customData, custom5)
  13463. custom6 := &CustomData{
  13464. MsgId: "H44022900158202103301718096755",
  13465. PsnNo: "44020000001102211860",
  13466. Info: "2207",
  13467. }
  13468. customData = append(customData, custom6)
  13469. custom7 := &CustomData{
  13470. MsgId: "H44022900158202103301736551640",
  13471. PsnNo: "44020000001102687718",
  13472. Info: "2207",
  13473. }
  13474. customData = append(customData, custom7)
  13475. custom8 := &CustomData{
  13476. MsgId: "H44022900158202103301743097676",
  13477. PsnNo: "44020000001102127785",
  13478. Info: "2207",
  13479. }
  13480. customData = append(customData, custom8)
  13481. custom9 := &CustomData{
  13482. MsgId: "H44022900158202103301712304203",
  13483. PsnNo: "44020000001101518097",
  13484. Info: "2207",
  13485. }
  13486. customData = append(customData, custom9)
  13487. custom10 := &CustomData{
  13488. MsgId: "H44022900158202103301738448785",
  13489. PsnNo: "44020000001100500813",
  13490. Info: "2207",
  13491. }
  13492. customData = append(customData, custom10)
  13493. custom11 := &CustomData{
  13494. MsgId: "H44022900158202103301732455843",
  13495. PsnNo: "44020000001102690557",
  13496. Info: "2207",
  13497. }
  13498. customData = append(customData, custom11)
  13499. custom12 := &CustomData{
  13500. MsgId: "H44022900158202103301745421708",
  13501. PsnNo: "44020000001102211928",
  13502. Info: "2207",
  13503. }
  13504. customData = append(customData, custom12)
  13505. custom1212 := &CustomData{
  13506. MsgId: "H440229001582021033017351627",
  13507. PsnNo: "44020000001102481733",
  13508. Info: "2207",
  13509. }
  13510. customData = append(customData, custom1212)
  13511. custom13 := &CustomData{
  13512. MsgId: "H44022900158202103301740327951",
  13513. PsnNo: "44020000001103174866",
  13514. Info: "2207",
  13515. }
  13516. customData = append(customData, custom13)
  13517. custom14 := &CustomData{
  13518. MsgId: "H4402290015820210330174922668",
  13519. PsnNo: "44020000001102927272",
  13520. Info: "2207",
  13521. }
  13522. customData = append(customData, custom14)
  13523. custom15 := &CustomData{
  13524. MsgId: "H44022900158202103301752362273",
  13525. PsnNo: "44020000001102942890",
  13526. Info: "2207",
  13527. }
  13528. customData = append(customData, custom15)
  13529. custom16 := &CustomData{
  13530. MsgId: "H44022900158202103301751082917",
  13531. PsnNo: "44020000001101662162",
  13532. Info: "2207",
  13533. }
  13534. customData = append(customData, custom16)
  13535. custom17 := &CustomData{
  13536. MsgId: "H44022900158202103301754147728",
  13537. PsnNo: "44020000000229014511",
  13538. Info: "2207",
  13539. }
  13540. customData = append(customData, custom17)
  13541. adminUser := c.GetAdminUserInfo()
  13542. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13543. for _, item := range customData {
  13544. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13545. fmt.Println(result)
  13546. }
  13547. }
  13548. //func (c *HisApiController) GetAllopatry() {
  13549. // year := c.GetString("year")
  13550. // month := c.GetString("month")
  13551. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13552. // adminUser := c.GetAdminUserInfo()
  13553. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13554. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13555. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13556. //
  13557. // var dat map[string]interface{}
  13558. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13559. // fmt.Println(dat)
  13560. // } else {
  13561. // fmt.Println(err)
  13562. // }
  13563. // userJSONBytes, _ := json.Marshal(dat)
  13564. // var res models.Result9001
  13565. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13566. // utils.ErrorLog("解析失败:%v", err)
  13567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13568. // return
  13569. // }
  13570. //
  13571. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13572. // var dat2 map[string]interface{}
  13573. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13574. // fmt.Println(dat)
  13575. // } else {
  13576. // fmt.Println(err)
  13577. // }
  13578. // userJSONBytes2, _ := json.Marshal(dat2)
  13579. // var res2 models.Result3260
  13580. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13581. // utils.ErrorLog("解析失败:%v", err)
  13582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13583. // return
  13584. // }
  13585. // if res2.Infcode == 0 {
  13586. // c.ServeSuccessJSON(map[string]interface{}{
  13587. // "list": res2.Output.Data,
  13588. // })
  13589. // return
  13590. // } else {
  13591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13592. // return
  13593. // }
  13594. //
  13595. //}
  13596. //func (c *HisApiController) ComfirmAllopatry() {
  13597. // year := c.GetString("year")
  13598. // month := c.GetString("month")
  13599. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13600. // adminUser := c.GetAdminUserInfo()
  13601. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13602. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13603. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13604. // var dat map[string]interface{}
  13605. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13606. // fmt.Println(dat)
  13607. // } else {
  13608. // fmt.Println(err)
  13609. // }
  13610. // userJSONBytes, _ := json.Marshal(dat)
  13611. // var res models.Result9001
  13612. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13613. // utils.ErrorLog("解析失败:%v", err)
  13614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13615. // return
  13616. // }
  13617. //
  13618. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13619. // var dat2 map[string]interface{}
  13620. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13621. // fmt.Println(dat)
  13622. // } else {
  13623. // fmt.Println(err)
  13624. // }
  13625. // userJSONBytes2, _ := json.Marshal(dat2)
  13626. // var res2 models.Result3260
  13627. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13628. // utils.ErrorLog("解析失败:%v", err)
  13629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13630. // return
  13631. // }
  13632. //
  13633. // if res2.Infcode == 0 {
  13634. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13635. // var dat map[string]interface{}
  13636. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13637. // fmt.Println(dat)
  13638. // } else {
  13639. // fmt.Println(err)
  13640. // }
  13641. // userJSONBytes, _ := json.Marshal(dat)
  13642. // var res3 models.Result3261
  13643. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13644. // utils.ErrorLog("解析失败:%v", err)
  13645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13646. // return
  13647. // }
  13648. //
  13649. // if res3.Infcode == 0 {
  13650. // record := &models.HisYidiClearRecord{
  13651. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13652. // Ctime: time.Now().Unix(),
  13653. // Mtime: time.Now().Unix(),
  13654. // Status: 1,
  13655. // MsgId: msgId,
  13656. // }
  13657. // service.SaveClearRecord(record)
  13658. // c.ServeSuccessJSON(map[string]interface{}{
  13659. // "msg": "提取成功",
  13660. // })
  13661. // }
  13662. // }
  13663. //}
  13664. func (c *HisApiController) RefundAllopatry() {
  13665. year := c.GetString("year")
  13666. month := c.GetString("month")
  13667. id, _ := c.GetInt64("id")
  13668. admin_user_id, _ := c.GetInt64("admin_user_id")
  13669. adminUser := c.GetAdminUserInfo()
  13670. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13671. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13672. record, _ := service.GetClearRecordById(id)
  13673. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13674. var dat map[string]interface{}
  13675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13676. fmt.Println(dat)
  13677. } else {
  13678. fmt.Println(err)
  13679. }
  13680. userJSONBytes, _ := json.Marshal(dat)
  13681. var empty ResultFourteen
  13682. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13683. utils.ErrorLog("解析失败:%v", err)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. if empty.Infcode == 0 {
  13688. c.ServeSuccessJSON(map[string]interface{}{
  13689. "msg": "撤销成功",
  13690. })
  13691. return
  13692. }
  13693. }
  13694. func (c *HisApiController) ReversalOtherData() {
  13695. var customData []*CustomData
  13696. custom := &CustomData{
  13697. MsgId: "H44022900158202103301714472004",
  13698. PsnNo: "44020000001101329945",
  13699. Info: "2208",
  13700. }
  13701. customData = append(customData, custom)
  13702. custom1 := &CustomData{
  13703. MsgId: "H4402290015820210330172057803",
  13704. PsnNo: "44020000001101161813",
  13705. Info: "2208",
  13706. }
  13707. customData = append(customData, custom1)
  13708. custom2 := &CustomData{
  13709. MsgId: "H44022900158202103301705198813",
  13710. PsnNo: "44190000133097375417",
  13711. Info: "2208",
  13712. }
  13713. customData = append(customData, custom2)
  13714. custom3 := &CustomData{
  13715. MsgId: "H44022900158202103301715524756",
  13716. PsnNo: "44020000001100187221",
  13717. Info: "2208",
  13718. }
  13719. customData = append(customData, custom3)
  13720. custom4 := &CustomData{
  13721. MsgId: "H44022900158202103301730376224",
  13722. PsnNo: "44020000001101959155",
  13723. Info: "2208",
  13724. }
  13725. customData = append(customData, custom4)
  13726. custom5 := &CustomData{
  13727. MsgId: "H44022900158202103301748008725",
  13728. PsnNo: "44020000001104246641",
  13729. Info: "2208",
  13730. }
  13731. customData = append(customData, custom5)
  13732. custom6 := &CustomData{
  13733. MsgId: "H44022900158202103301718096755",
  13734. PsnNo: "44020000001102211860",
  13735. Info: "2208",
  13736. }
  13737. customData = append(customData, custom6)
  13738. custom7 := &CustomData{
  13739. MsgId: "H44022900158202103301736551640",
  13740. PsnNo: "44020000001102687718",
  13741. Info: "2208",
  13742. }
  13743. customData = append(customData, custom7)
  13744. custom8 := &CustomData{
  13745. MsgId: "H44022900158202103301743097676",
  13746. PsnNo: "44020000001102127785",
  13747. Info: "2208",
  13748. }
  13749. customData = append(customData, custom8)
  13750. custom9 := &CustomData{
  13751. MsgId: "H44022900158202103301712304203",
  13752. PsnNo: "44020000001101518097",
  13753. Info: "2208",
  13754. }
  13755. customData = append(customData, custom9)
  13756. custom10 := &CustomData{
  13757. MsgId: "H44022900158202103301738448785",
  13758. PsnNo: "44020000001100500813",
  13759. Info: "2208",
  13760. }
  13761. customData = append(customData, custom10)
  13762. custom11 := &CustomData{
  13763. MsgId: "H44022900158202103301732455843",
  13764. PsnNo: "44020000001102690557",
  13765. Info: "2208",
  13766. }
  13767. customData = append(customData, custom11)
  13768. custom12 := &CustomData{
  13769. MsgId: "H44022900158202103301745421708",
  13770. PsnNo: "44020000001102211928",
  13771. Info: "2208",
  13772. }
  13773. customData = append(customData, custom12)
  13774. custom1212 := &CustomData{
  13775. MsgId: "H440229001582021033017351627",
  13776. PsnNo: "44020000001102481733",
  13777. Info: "2208",
  13778. }
  13779. customData = append(customData, custom1212)
  13780. custom13 := &CustomData{
  13781. MsgId: "H44022900158202103301740327951",
  13782. PsnNo: "44020000001103174866",
  13783. Info: "2208",
  13784. }
  13785. customData = append(customData, custom13)
  13786. custom14 := &CustomData{
  13787. MsgId: "H4402290015820210330174922668",
  13788. PsnNo: "44020000001102927272",
  13789. Info: "2208",
  13790. }
  13791. customData = append(customData, custom14)
  13792. custom15 := &CustomData{
  13793. MsgId: "H44022900158202103301752362273",
  13794. PsnNo: "44020000001102942890",
  13795. Info: "2208",
  13796. }
  13797. customData = append(customData, custom15)
  13798. custom16 := &CustomData{
  13799. MsgId: "H44022900158202103301751082917",
  13800. PsnNo: "44020000001101662162",
  13801. Info: "2208",
  13802. }
  13803. customData = append(customData, custom16)
  13804. custom17 := &CustomData{
  13805. MsgId: "H44022900158202103301754147728",
  13806. PsnNo: "44020000000229014511",
  13807. Info: "2208",
  13808. }
  13809. customData = append(customData, custom17)
  13810. adminUser := c.GetAdminUserInfo()
  13811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13812. for _, item := range customData {
  13813. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13814. fmt.Println(result)
  13815. }
  13816. }
  13817. func PathExists(path string) (bool, error) {
  13818. _, err := os.Stat(path)
  13819. if err == nil {
  13820. return true, nil
  13821. }
  13822. if os.IsNotExist(err) {
  13823. return false, nil
  13824. }
  13825. return false, err
  13826. }
  13827. //创建文件夹
  13828. func Mkdir(dir string) {
  13829. // 创建文件夹
  13830. exist, err := PathExists(dir)
  13831. if err != nil {
  13832. fmt.Println(err.Error())
  13833. } else {
  13834. if exist {
  13835. fmt.Println(dir + "文件夹已存在!")
  13836. } else {
  13837. // 文件夹名称,权限
  13838. err := os.Mkdir(dir, os.ModePerm)
  13839. if err != nil {
  13840. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13841. } else {
  13842. fmt.Println(dir + "文件夹创建成功!")
  13843. }
  13844. }
  13845. }
  13846. }
  13847. //压缩文件
  13848. func Zip(srcFile string, destZip string) error {
  13849. zipfile, err := os.Create(destZip)
  13850. if err != nil {
  13851. return err
  13852. }
  13853. defer zipfile.Close()
  13854. archive := zip.NewWriter(zipfile)
  13855. defer archive.Close()
  13856. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13857. if err != nil {
  13858. return err
  13859. }
  13860. header, err := zip.FileInfoHeader(info)
  13861. if err != nil {
  13862. return err
  13863. }
  13864. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13865. // header.Name = path
  13866. if info.IsDir() {
  13867. header.Name += "/"
  13868. } else {
  13869. header.Method = zip.Deflate
  13870. }
  13871. writer, err := archive.CreateHeader(header)
  13872. if err != nil {
  13873. return err
  13874. }
  13875. if !info.IsDir() {
  13876. file, err := os.Open(path)
  13877. if err != nil {
  13878. return err
  13879. }
  13880. defer file.Close()
  13881. _, err = io.Copy(writer, file)
  13882. }
  13883. return err
  13884. })
  13885. return err
  13886. }
  13887. func ReadFile(filePath string) []byte {
  13888. f, err := os.Open(filePath)
  13889. if err != nil {
  13890. fmt.Println("read file fail", err)
  13891. return nil
  13892. }
  13893. defer f.Close()
  13894. fd, err := ioutil.ReadAll(f)
  13895. if err != nil {
  13896. fmt.Println("read to fd fail", err)
  13897. return nil
  13898. }
  13899. return fd
  13900. }
  13901. func saveLog(result string, request string, infno string, desc string) {
  13902. org_id, _ := beego.AppConfig.Int64("org_id")
  13903. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13904. dir := miConfig.OrgName + "日志"
  13905. utils.Mkdir(dir)
  13906. month := time.Unix(1557042972, 0).Format("1")
  13907. year := time.Now().Format("2006")
  13908. month = time.Now().Format("01")
  13909. day := time.Now().Format("02")
  13910. hour := time.Now().Format("15")
  13911. min := time.Now().Format("04")
  13912. sec := time.Now().Format("05")
  13913. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13914. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13915. file_name := file + ".txt"
  13916. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13917. exist, _ := utils.PathExists(file_path)
  13918. if exist { //存在
  13919. fmt.Println("存在")
  13920. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13921. if err != nil {
  13922. fmt.Println("read fail")
  13923. }
  13924. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13925. n, _ := f.Seek(0, 2)
  13926. _, err = f.WriteAt([]byte(content), n)
  13927. } else { //不存在
  13928. fmt.Println("文件不存在,创建文件")
  13929. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13930. defer f.Close()
  13931. if err != nil {
  13932. } else {
  13933. _, err = f.Write([]byte("记录日志"))
  13934. }
  13935. }
  13936. }
  13937. type Charset string
  13938. const (
  13939. UTF8 = Charset("UTF-8")
  13940. GB18030 = Charset("GB18030")
  13941. )
  13942. func ConvertToString(src string, srcCode string, tagCode string) string {
  13943. srcCoder := mahonia.NewDecoder(srcCode)
  13944. srcResult := srcCoder.ConvertString(src)
  13945. tagCoder := mahonia.NewDecoder(tagCode)
  13946. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13947. result := string(cdata)
  13948. return result
  13949. }
  13950. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13951. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13952. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13953. var token string
  13954. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13955. var api string
  13956. if miConfig.MdtrtareaAdmvs == "320921" {
  13957. 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 +
  13958. "&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
  13959. fmt.Println(api)
  13960. } else {
  13961. 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 +
  13962. "&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
  13963. }
  13964. resp, requestErr := http.Get(api)
  13965. if requestErr != nil {
  13966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13967. return ""
  13968. }
  13969. body, ioErr := ioutil.ReadAll(resp.Body)
  13970. if ioErr != nil {
  13971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13973. return ""
  13974. }
  13975. var respJSON map[string]interface{}
  13976. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13979. return ""
  13980. }
  13981. var status string
  13982. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13983. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13984. var res ResultTwo //1101结果
  13985. var res10265 ResultTwo10265 //1101结果
  13986. if status == "0" { //读卡成功
  13987. var card_info string //卡信息
  13988. var busi_card_info string
  13989. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13990. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13991. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13992. fmt.Println(card_info)
  13993. fmt.Println(busi_card_info)
  13994. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13995. result, _ := json.Marshal(respJSON)
  13996. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13997. utils.ErrorLog("解析失败:%v", err)
  13998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13999. return ""
  14000. }
  14001. res.ErrMsg = res10265.ErrMsg
  14002. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14003. res.Infcode = infocode
  14004. res.Output = res10265.Output
  14005. res.InfRefmsgid = res10265.InfRefmsgid
  14006. if res.Infcode == 0 {
  14007. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14008. if err == gorm.ErrRecordNotFound {
  14009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14010. return ""
  14011. } else if err != nil {
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14013. return ""
  14014. } else {
  14015. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14016. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14017. infoStr := string(Iinfos)
  14018. idetinfoStr := string(Idetinfos)
  14019. psn := &models.HisPsn{
  14020. PsnNo: res.Output.Baseinfo.PsnNo,
  14021. Age: res.Output.Baseinfo.Age,
  14022. PatientId: patient.ID,
  14023. Certno: res.Output.Baseinfo.Certno,
  14024. Brdy: res.Output.Baseinfo.Brdy,
  14025. Gend: res.Output.Baseinfo.Gend,
  14026. Naty: res.Output.Baseinfo.Naty,
  14027. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14028. PsnName: res.Output.Baseinfo.PsnName,
  14029. Idetinfo: idetinfoStr,
  14030. Insuinfo: infoStr,
  14031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14032. CardInfo: card_info,
  14033. VerifyNumber: token,
  14034. }
  14035. service.CreateHisPsn(psn)
  14036. return token
  14037. }
  14038. }
  14039. } else {
  14040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14041. return ""
  14042. }
  14043. } else { //读卡失败
  14044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14045. return ""
  14046. }
  14047. return token
  14048. }
  14049. func DeleteExtraSpaceTwo(s string) string {
  14050. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14051. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14052. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14053. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14054. s2 := make([]byte, len(s1)) //定义字符数组切片
  14055. copy(s2, s1) //将字符串复制到切片
  14056. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14057. for len(spc_index) > 0 { //找到适配项
  14058. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14059. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14060. }
  14061. return string(s2)
  14062. }
  14063. func Remove0000(s string) string {
  14064. str := make([]rune, 0, len(s))
  14065. for _, v := range []rune(s) {
  14066. if v == 0 {
  14067. continue
  14068. }
  14069. str = append(str, v)
  14070. }
  14071. return string(str)
  14072. }
  14073. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14074. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14075. readCard := DllDef.MustFindProc("EcQuery")
  14076. pCardInfo := make([]byte, 8192)
  14077. pBusiCardInfo := make([]byte, 8192)
  14078. data := make(map[string]interface{})
  14079. //pData := make(map[string]interface{})
  14080. inputData := make(map[string]interface{})
  14081. inputData["orgId"] = code
  14082. inputData["businessType"] = "01101"
  14083. inputData["operatorId"] = operator_id
  14084. inputData["operatorName"] = operator_name
  14085. inputData["officeId"] = "001"
  14086. inputData["officeName"] = "血透室"
  14087. //
  14088. data["data"] = inputData
  14089. data["transType"] = "ec.query"
  14090. data["orgId"] = code
  14091. bytesData, _ := json.Marshal(data)
  14092. pCardInfo = bytesData
  14093. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14094. fmt.Println(ret2)
  14095. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14096. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14097. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14098. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14099. if ret2 != 0 {
  14100. return "", ""
  14101. }
  14102. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14103. }
  14104. func DeleteExtraSpace(s string) string {
  14105. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14106. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14107. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14108. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14109. s2 := make([]byte, len(s1)) //定义字符数组切片
  14110. copy(s2, s1) //将字符串复制到切片
  14111. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14112. for len(spc_index) > 0 { //找到适配项
  14113. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14114. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14115. }
  14116. return string(s2)
  14117. }
  14118. //对账
  14119. func (c *HisApiController) Post3202() {
  14120. start_time := c.GetString("start_time")
  14121. end_time := c.GetString("end_time")
  14122. //insutype := c.GetString("insutype")
  14123. clr_type := c.GetString("clr_type")
  14124. clr_org := c.GetString("clr_optins")
  14125. admin_user_id, _ := c.GetInt64("admin_user_id")
  14126. adminUser := c.GetAdminUserInfo()
  14127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14129. if len(clr_org) == 0 {
  14130. clr_org = miConfig.MdtrtareaAdmvs
  14131. }
  14132. timeLayout := "2006-01-02"
  14133. loc, _ := time.LoadLocation("Local")
  14134. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14135. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14136. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14137. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14138. //fixmedins_setl_cnt := int64(len(orders))
  14139. var medfee_sumamt float64
  14140. var acct_pay float64
  14141. var fund_pay_sumamt float64
  14142. for _, item := range orders {
  14143. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14144. acct_pay = acct_pay + item.AcctPay
  14145. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14146. }
  14147. //var medfee_sumamt_two float64
  14148. //var acct_pay_two float64
  14149. //var fund_pay_sumamt_two float64
  14150. //for _, item := range orders_two {
  14151. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14152. // acct_pay_two = acct_pay_two + item.AcctPay
  14153. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14154. //}
  14155. //var user_name string
  14156. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14157. //if role.ID == 0 {
  14158. // user_name = "xxx"
  14159. //} else {
  14160. // user_name = role.UserName
  14161. //}
  14162. var res ResultSix
  14163. if config.IsOpen == 1 {
  14164. var bps []*models.BusinessParamsTwo
  14165. var bp models.BusinessParamsTwo
  14166. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14167. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14168. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14169. bp.MedfeeSumamt = medfee_sumamt_str
  14170. bp.AcctPay = acct_pay_str
  14171. bp.FundPaySumamt = fund_pay_sumamt_str
  14172. bp.Insutype = "390"
  14173. bp.StmtBegndate = start_time
  14174. bp.ClrType = clr_type
  14175. bp.SetlOptins = clr_org
  14176. bp.StmtEnddate = end_time
  14177. bps = append(bps, &bp)
  14178. data := make(map[string]interface{})
  14179. data["bps"] = bps
  14180. data["org_name"] = miConfig.OrgName
  14181. data["doctor"] = role.UserName
  14182. data["fixmedins_code"] = miConfig.Code
  14183. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14184. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14185. if miConfig.MdtrtareaAdmvs == "421300" {
  14186. client := &http.Client{}
  14187. bytesData, _ := json.Marshal(data)
  14188. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14189. resp, _ := client.Do(req)
  14190. defer resp.Body.Close()
  14191. body, ioErr := ioutil.ReadAll(resp.Body)
  14192. if ioErr != nil {
  14193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14195. return
  14196. }
  14197. var respJSON map[string]interface{}
  14198. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14201. return
  14202. }
  14203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14204. userJSONBytes, _ := json.Marshal(respJSON)
  14205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14206. utils.ErrorLog("解析失败:%v", err)
  14207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14208. return
  14209. }
  14210. }
  14211. if res.Infcode == 0 {
  14212. c.ServeSuccessJSON(map[string]interface{}{
  14213. "msg": "发起成功",
  14214. })
  14215. } else {
  14216. c.ServeSuccessJSON(map[string]interface{}{
  14217. "code": -10,
  14218. "msg": res.ErrMsg,
  14219. })
  14220. }
  14221. }
  14222. }
  14223. func (c *HisApiController) Post3501() {
  14224. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14225. data := make(map[string]interface{})
  14226. var struct3501s []models.Struct3501
  14227. var struct3501 models.Struct3501
  14228. struct3501.OrgName = miConfig.OrgName
  14229. struct3501.AccessKey = miConfig.AccessKey
  14230. struct3501.RequestUrl = miConfig.Url
  14231. struct3501.SecretKey = miConfig.SecretKey
  14232. struct3501.ManuDate = "2022-08-17"
  14233. struct3501.FixmedinsBchno = ""
  14234. struct3501.ManuLotnum = ""
  14235. struct3501.RxFlag = "0"
  14236. struct3501.ExpyEnd = "2022-08-17"
  14237. struct3501.Invdate = "2022-08-17"
  14238. struct3501.InvCnt = "20.25"
  14239. struct3501.Memo = ""
  14240. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14241. struct3501.FixmedinsHilistId = miConfig.Code
  14242. struct3501.FixmedinsHilistName = miConfig.OrgName
  14243. struct3501s = append(struct3501s, struct3501)
  14244. data["struct_3501s"] = struct3501s
  14245. client := &http.Client{}
  14246. bytesData, _ := json.Marshal(data)
  14247. var req *http.Request
  14248. if miConfig.MdtrtareaAdmvs == "320921" {
  14249. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14250. } else {
  14251. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14252. }
  14253. resp, _ := client.Do(req)
  14254. defer resp.Body.Close()
  14255. body, ioErr := ioutil.ReadAll(resp.Body)
  14256. if ioErr != nil {
  14257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. var respJSON map[string]interface{}
  14262. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14265. return
  14266. }
  14267. var res ResultSix
  14268. var resSix10265 ResultSix10265 //1101结果
  14269. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14270. result, _ := json.Marshal(respJSON)
  14271. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14272. utils.ErrorLog("解析失败:%v", err)
  14273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14274. return
  14275. }
  14276. res.InfRefmsgid = resSix10265.InfRefmsgid
  14277. res.Output = resSix10265.Output
  14278. res.ErrMsg = resSix10265.ErrMsg
  14279. res.Cainfo = resSix10265.Cainfo
  14280. res.WarnMsg = resSix10265.WarnMsg
  14281. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14282. res.Infcode = infocode
  14283. if infocode == 0 {
  14284. c.ServeSuccessJSON(map[string]interface{}{
  14285. "msg": "上传成功",
  14286. })
  14287. return
  14288. } else {
  14289. c.ServeSuccessJSON(map[string]interface{}{
  14290. "failed_code": -10,
  14291. "msg": res.ErrMsg,
  14292. })
  14293. return
  14294. }
  14295. }
  14296. func (c *HisApiController) Post3502() {
  14297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14298. data := make(map[string]interface{})
  14299. var struct3502s []models.Struct3502
  14300. var struct3502 models.Struct3502
  14301. struct3502.OrgName = miConfig.OrgName
  14302. struct3502.AccessKey = miConfig.AccessKey
  14303. struct3502.RequestUrl = miConfig.Url
  14304. struct3502.SecretKey = miConfig.SecretKey
  14305. struct3502.ManuDate = "2022-08-15"
  14306. struct3502.FixmedinsBchno = ""
  14307. struct3502.ManuLotnum = ""
  14308. struct3502.RxFlag = "0"
  14309. struct3502.ExpyEnd = "2022-08-15"
  14310. struct3502.Invdate = "2022-08-15"
  14311. struct3502.InvCnt = "20.25"
  14312. struct3502.Memo = ""
  14313. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14314. struct3502.FixmedinsHilistId = miConfig.Code
  14315. struct3502.FixmedinsHilistName = miConfig.OrgName
  14316. struct3502s = append(struct3502s, struct3502)
  14317. data["struct_3502s"] = struct3502s
  14318. client := &http.Client{}
  14319. bytesData, _ := json.Marshal(data)
  14320. var req *http.Request
  14321. if miConfig.MdtrtareaAdmvs == "320921" {
  14322. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14323. } else {
  14324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14325. }
  14326. resp, _ := client.Do(req)
  14327. defer resp.Body.Close()
  14328. body, ioErr := ioutil.ReadAll(resp.Body)
  14329. if ioErr != nil {
  14330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14332. return
  14333. }
  14334. var respJSON map[string]interface{}
  14335. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14338. return
  14339. }
  14340. var res ResultSix
  14341. var resSix10265 ResultSix10265 //1101结果
  14342. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14343. result, _ := json.Marshal(respJSON)
  14344. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14345. utils.ErrorLog("解析失败:%v", err)
  14346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14347. return
  14348. }
  14349. res.InfRefmsgid = resSix10265.InfRefmsgid
  14350. res.Output = resSix10265.Output
  14351. res.ErrMsg = resSix10265.ErrMsg
  14352. res.Cainfo = resSix10265.Cainfo
  14353. res.WarnMsg = resSix10265.WarnMsg
  14354. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14355. res.Infcode = infocode
  14356. if infocode == 0 {
  14357. c.ServeSuccessJSON(map[string]interface{}{
  14358. "msg": "上传成功",
  14359. })
  14360. return
  14361. } else {
  14362. c.ServeSuccessJSON(map[string]interface{}{
  14363. "failed_code": -10,
  14364. "msg": res.ErrMsg,
  14365. })
  14366. return
  14367. }
  14368. }
  14369. func (c *HisApiController) Post3503() {
  14370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14371. data := make(map[string]interface{})
  14372. var struct3501s []models.Struct3501
  14373. var struct3501 models.Struct3501
  14374. struct3501.OrgName = miConfig.OrgName
  14375. struct3501.AccessKey = miConfig.AccessKey
  14376. struct3501.RequestUrl = miConfig.Url
  14377. struct3501.SecretKey = miConfig.SecretKey
  14378. struct3501.ManuDate = "2022-08-15"
  14379. struct3501.FixmedinsBchno = ""
  14380. struct3501.ManuLotnum = ""
  14381. struct3501.RxFlag = "0"
  14382. struct3501.ExpyEnd = "2022-08-15"
  14383. struct3501.Invdate = "2022-08-15"
  14384. struct3501.InvCnt = "20.25"
  14385. struct3501.Memo = ""
  14386. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14387. struct3501.FixmedinsHilistId = miConfig.Code
  14388. struct3501.FixmedinsHilistName = miConfig.OrgName
  14389. struct3501s = append(struct3501s, struct3501)
  14390. data["struct_3501s"] = struct3501s
  14391. client := &http.Client{}
  14392. bytesData, _ := json.Marshal(data)
  14393. var req *http.Request
  14394. if miConfig.MdtrtareaAdmvs == "320921" {
  14395. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14396. } else {
  14397. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14398. }
  14399. resp, _ := client.Do(req)
  14400. defer resp.Body.Close()
  14401. body, ioErr := ioutil.ReadAll(resp.Body)
  14402. if ioErr != nil {
  14403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14405. return
  14406. }
  14407. var respJSON map[string]interface{}
  14408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14411. return
  14412. }
  14413. var res ResultSix
  14414. var resSix10265 ResultSix10265 //1101结果
  14415. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14416. result, _ := json.Marshal(respJSON)
  14417. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14418. utils.ErrorLog("解析失败:%v", err)
  14419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14420. return
  14421. }
  14422. res.InfRefmsgid = resSix10265.InfRefmsgid
  14423. res.Output = resSix10265.Output
  14424. res.ErrMsg = resSix10265.ErrMsg
  14425. res.Cainfo = resSix10265.Cainfo
  14426. res.WarnMsg = resSix10265.WarnMsg
  14427. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14428. res.Infcode = infocode
  14429. if infocode == 0 {
  14430. c.ServeSuccessJSON(map[string]interface{}{
  14431. "msg": "上传成功",
  14432. })
  14433. return
  14434. } else {
  14435. c.ServeSuccessJSON(map[string]interface{}{
  14436. "failed_code": -10,
  14437. "msg": res.ErrMsg,
  14438. })
  14439. return
  14440. }
  14441. }
  14442. func (c *HisApiController) Post3504() {
  14443. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14444. data := make(map[string]interface{})
  14445. var struct3501s []models.Struct3501
  14446. var struct3501 models.Struct3501
  14447. struct3501.OrgName = miConfig.OrgName
  14448. struct3501.AccessKey = miConfig.AccessKey
  14449. struct3501.RequestUrl = miConfig.Url
  14450. struct3501.SecretKey = miConfig.SecretKey
  14451. struct3501.ManuDate = "2022-08-15"
  14452. struct3501.FixmedinsBchno = ""
  14453. struct3501.ManuLotnum = ""
  14454. struct3501.RxFlag = "0"
  14455. struct3501.ExpyEnd = "2022-08-15"
  14456. struct3501.Invdate = "2022-08-15"
  14457. struct3501.InvCnt = "20.25"
  14458. struct3501.Memo = ""
  14459. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14460. struct3501.FixmedinsHilistId = miConfig.Code
  14461. struct3501.FixmedinsHilistName = miConfig.OrgName
  14462. struct3501s = append(struct3501s, struct3501)
  14463. data["struct_3501s"] = struct3501s
  14464. client := &http.Client{}
  14465. bytesData, _ := json.Marshal(data)
  14466. var req *http.Request
  14467. if miConfig.MdtrtareaAdmvs == "320921" {
  14468. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14469. } else {
  14470. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14471. }
  14472. resp, _ := client.Do(req)
  14473. defer resp.Body.Close()
  14474. body, ioErr := ioutil.ReadAll(resp.Body)
  14475. if ioErr != nil {
  14476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14478. return
  14479. }
  14480. var respJSON map[string]interface{}
  14481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14484. return
  14485. }
  14486. var res ResultSix
  14487. var resSix10265 ResultSix10265 //1101结果
  14488. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14489. result, _ := json.Marshal(respJSON)
  14490. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14491. utils.ErrorLog("解析失败:%v", err)
  14492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14493. return
  14494. }
  14495. res.InfRefmsgid = resSix10265.InfRefmsgid
  14496. res.Output = resSix10265.Output
  14497. res.ErrMsg = resSix10265.ErrMsg
  14498. res.Cainfo = resSix10265.Cainfo
  14499. res.WarnMsg = resSix10265.WarnMsg
  14500. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14501. res.Infcode = infocode
  14502. if infocode == 0 {
  14503. c.ServeSuccessJSON(map[string]interface{}{
  14504. "msg": "上传成功",
  14505. })
  14506. return
  14507. } else {
  14508. c.ServeSuccessJSON(map[string]interface{}{
  14509. "failed_code": -10,
  14510. "msg": res.ErrMsg,
  14511. })
  14512. return
  14513. }
  14514. }
  14515. func (c *HisApiController) Post3505() {
  14516. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14517. data := make(map[string]interface{})
  14518. var struct3501s []models.Struct3501
  14519. var struct3501 models.Struct3501
  14520. struct3501.OrgName = miConfig.OrgName
  14521. struct3501.AccessKey = miConfig.AccessKey
  14522. struct3501.RequestUrl = miConfig.Url
  14523. struct3501.SecretKey = miConfig.SecretKey
  14524. struct3501.ManuDate = "2022-08-15"
  14525. struct3501.FixmedinsBchno = ""
  14526. struct3501.ManuLotnum = ""
  14527. struct3501.RxFlag = "0"
  14528. struct3501.ExpyEnd = "2022-08-15"
  14529. struct3501.Invdate = "2022-08-15"
  14530. struct3501.InvCnt = "20.25"
  14531. struct3501.Memo = ""
  14532. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14533. struct3501.FixmedinsHilistId = miConfig.Code
  14534. struct3501.FixmedinsHilistName = miConfig.OrgName
  14535. struct3501s = append(struct3501s, struct3501)
  14536. data["struct_3501s"] = struct3501s
  14537. client := &http.Client{}
  14538. bytesData, _ := json.Marshal(data)
  14539. var req *http.Request
  14540. if miConfig.MdtrtareaAdmvs == "320921" {
  14541. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14542. } else {
  14543. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14544. }
  14545. resp, _ := client.Do(req)
  14546. defer resp.Body.Close()
  14547. body, ioErr := ioutil.ReadAll(resp.Body)
  14548. if ioErr != nil {
  14549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14551. return
  14552. }
  14553. var respJSON map[string]interface{}
  14554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. var res ResultSix
  14560. var resSix10265 ResultSix10265 //1101结果
  14561. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14562. result, _ := json.Marshal(respJSON)
  14563. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14564. utils.ErrorLog("解析失败:%v", err)
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14566. return
  14567. }
  14568. res.InfRefmsgid = resSix10265.InfRefmsgid
  14569. res.Output = resSix10265.Output
  14570. res.ErrMsg = resSix10265.ErrMsg
  14571. res.Cainfo = resSix10265.Cainfo
  14572. res.WarnMsg = resSix10265.WarnMsg
  14573. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14574. res.Infcode = infocode
  14575. if infocode == 0 {
  14576. c.ServeSuccessJSON(map[string]interface{}{
  14577. "msg": "上传成功",
  14578. })
  14579. return
  14580. } else {
  14581. c.ServeSuccessJSON(map[string]interface{}{
  14582. "failed_code": -10,
  14583. "msg": res.ErrMsg,
  14584. })
  14585. return
  14586. }
  14587. }
  14588. func (c *HisApiController) Post3506() {
  14589. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14590. data := make(map[string]interface{})
  14591. var struct3501s []models.Struct3501
  14592. var struct3501 models.Struct3501
  14593. struct3501.OrgName = miConfig.OrgName
  14594. struct3501.AccessKey = miConfig.AccessKey
  14595. struct3501.RequestUrl = miConfig.Url
  14596. struct3501.SecretKey = miConfig.SecretKey
  14597. struct3501.ManuDate = "2022-08-15"
  14598. struct3501.FixmedinsBchno = ""
  14599. struct3501.ManuLotnum = ""
  14600. struct3501.RxFlag = "0"
  14601. struct3501.ExpyEnd = "2022-08-15"
  14602. struct3501.Invdate = "2022-08-15"
  14603. struct3501.InvCnt = "20.25"
  14604. struct3501.Memo = ""
  14605. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14606. struct3501.FixmedinsHilistId = miConfig.Code
  14607. struct3501.FixmedinsHilistName = miConfig.OrgName
  14608. struct3501s = append(struct3501s, struct3501)
  14609. data["struct_3501s"] = struct3501s
  14610. client := &http.Client{}
  14611. bytesData, _ := json.Marshal(data)
  14612. var req *http.Request
  14613. if miConfig.MdtrtareaAdmvs == "320921" {
  14614. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14615. } else {
  14616. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14617. }
  14618. resp, _ := client.Do(req)
  14619. defer resp.Body.Close()
  14620. body, ioErr := ioutil.ReadAll(resp.Body)
  14621. if ioErr != nil {
  14622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14624. return
  14625. }
  14626. var respJSON map[string]interface{}
  14627. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14630. return
  14631. }
  14632. var res ResultSix
  14633. var resSix10265 ResultSix10265 //1101结果
  14634. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14635. result, _ := json.Marshal(respJSON)
  14636. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14637. utils.ErrorLog("解析失败:%v", err)
  14638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14639. return
  14640. }
  14641. res.InfRefmsgid = resSix10265.InfRefmsgid
  14642. res.Output = resSix10265.Output
  14643. res.ErrMsg = resSix10265.ErrMsg
  14644. res.Cainfo = resSix10265.Cainfo
  14645. res.WarnMsg = resSix10265.WarnMsg
  14646. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14647. res.Infcode = infocode
  14648. if infocode == 0 {
  14649. c.ServeSuccessJSON(map[string]interface{}{
  14650. "msg": "上传成功",
  14651. })
  14652. return
  14653. } else {
  14654. c.ServeSuccessJSON(map[string]interface{}{
  14655. "failed_code": -10,
  14656. "msg": res.ErrMsg,
  14657. })
  14658. return
  14659. }
  14660. }
  14661. func (c *HisApiController) Post3507() {
  14662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14663. data := make(map[string]interface{})
  14664. var struct3501s []models.Struct3501
  14665. var struct3501 models.Struct3501
  14666. struct3501.OrgName = miConfig.OrgName
  14667. struct3501.AccessKey = miConfig.AccessKey
  14668. struct3501.RequestUrl = miConfig.Url
  14669. struct3501.SecretKey = miConfig.SecretKey
  14670. struct3501.ManuDate = "2022-08-15"
  14671. struct3501.FixmedinsBchno = ""
  14672. struct3501.ManuLotnum = ""
  14673. struct3501.RxFlag = "0"
  14674. struct3501.ExpyEnd = "2022-08-15"
  14675. struct3501.Invdate = "2022-08-15"
  14676. struct3501.InvCnt = "20.25"
  14677. struct3501.Memo = ""
  14678. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14679. struct3501.FixmedinsHilistId = miConfig.Code
  14680. struct3501.FixmedinsHilistName = miConfig.OrgName
  14681. struct3501s = append(struct3501s, struct3501)
  14682. data["struct_3501s"] = struct3501s
  14683. client := &http.Client{}
  14684. bytesData, _ := json.Marshal(data)
  14685. var req *http.Request
  14686. if miConfig.MdtrtareaAdmvs == "320921" {
  14687. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14688. } else {
  14689. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14690. }
  14691. resp, _ := client.Do(req)
  14692. defer resp.Body.Close()
  14693. body, ioErr := ioutil.ReadAll(resp.Body)
  14694. if ioErr != nil {
  14695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14697. return
  14698. }
  14699. var respJSON map[string]interface{}
  14700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14703. return
  14704. }
  14705. var res ResultSix
  14706. var resSix10265 ResultSix10265 //1101结果
  14707. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14708. result, _ := json.Marshal(respJSON)
  14709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14710. utils.ErrorLog("解析失败:%v", err)
  14711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14712. return
  14713. }
  14714. res.InfRefmsgid = resSix10265.InfRefmsgid
  14715. res.Output = resSix10265.Output
  14716. res.ErrMsg = resSix10265.ErrMsg
  14717. res.Cainfo = resSix10265.Cainfo
  14718. res.WarnMsg = resSix10265.WarnMsg
  14719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14720. res.Infcode = infocode
  14721. if infocode == 0 {
  14722. c.ServeSuccessJSON(map[string]interface{}{
  14723. "msg": "上传成功",
  14724. })
  14725. return
  14726. } else {
  14727. c.ServeSuccessJSON(map[string]interface{}{
  14728. "failed_code": -10,
  14729. "msg": res.ErrMsg,
  14730. })
  14731. return
  14732. }
  14733. }