his_api_controller.go 629KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337
  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. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  91. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  92. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  93. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  94. }
  95. func (c *HisApiController) Get2505() {
  96. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  97. 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")
  98. }
  99. func (c *HisApiController) Get4201A() {
  100. order_id, _ := c.GetInt64("order_id")
  101. admin_user_id, _ := c.GetInt64("admin_user_id")
  102. order, _ := service.GetHisOrderByIDTwo(order_id)
  103. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  104. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  105. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  106. //order_info = append(order_info, order_info_two...)
  107. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  108. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  109. department, _ := service.GetDepartMentDetail(his.Departments)
  110. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  111. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  112. if order.ID == 0 {
  113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  114. return
  115. }
  116. var struct4201A models.Struct4201A
  117. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  118. for _, items := range order_info {
  119. memo := make(map[string]interface{})
  120. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  121. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  122. fsiOPFLD.MedType = "14"
  123. fsiOPFLD.BkkpSn = items.FeedetlSn
  124. fsiOPFLD.FixmedinsCode = miConfig.Code
  125. fsiOPFLD.FixmedinsName = miConfig.OrgName
  126. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  127. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  128. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  129. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  130. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  131. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  132. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  133. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  134. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  135. fsiOPFLD.BilgDeptName = department.Name
  136. fsiOPFLD.BilgDeptCodg = department.Number
  137. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  138. fsiOPFLD.BilgDrName = doctor.UserName
  139. fsiOPFLD.MedChrgitmType = "09"
  140. memo["hosp_appr_flag"] = "1"
  141. memo["invoice_no"] = order.MdtrtId
  142. memo["memo"] = "自费"
  143. bytesData, _ := json.Marshal(memo)
  144. fsiOPFLD.Memo = string(bytesData)
  145. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  146. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  147. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  148. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  149. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  150. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  151. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  152. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  153. fsiOPFLD.BilgDeptName = department.Name
  154. fsiOPFLD.BilgDeptCodg = department.Number
  155. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  156. fsiOPFLD.BilgDrName = doctor.UserName
  157. switch items.HisPrescriptionProject.HisProject.CostClassify {
  158. case 0:
  159. break
  160. case 1:
  161. fsiOPFLD.MedChrgitmType = "14"
  162. break
  163. case 2:
  164. fsiOPFLD.MedChrgitmType = "05"
  165. break
  166. case 3:
  167. fsiOPFLD.MedChrgitmType = "03"
  168. break
  169. case 4:
  170. fsiOPFLD.MedChrgitmType = "03"
  171. break
  172. case 5:
  173. fsiOPFLD.MedChrgitmType = "08"
  174. break
  175. case 6:
  176. fsiOPFLD.MedChrgitmType = "14"
  177. break
  178. case 7:
  179. fsiOPFLD.MedChrgitmType = "14"
  180. break
  181. case 8:
  182. fsiOPFLD.MedChrgitmType = "03"
  183. break
  184. case 9:
  185. fsiOPFLD.MedChrgitmType = "14"
  186. break
  187. case 10:
  188. fsiOPFLD.MedChrgitmType = "14"
  189. break
  190. case 11:
  191. fsiOPFLD.MedChrgitmType = "06"
  192. break
  193. case 12:
  194. fsiOPFLD.MedChrgitmType = "12"
  195. break
  196. case 13:
  197. fsiOPFLD.MedChrgitmType = "01"
  198. break
  199. case 14:
  200. fsiOPFLD.MedChrgitmType = "04"
  201. break
  202. case 15:
  203. fsiOPFLD.MedChrgitmType = "14"
  204. break
  205. }
  206. memo["hosp_appr_flag"] = "1"
  207. memo["invoice_no"] = order.MdtrtId
  208. memo["memo"] = "自费"
  209. bytesData, _ := json.Marshal(memo)
  210. fsiOPFLD.Memo = string(bytesData)
  211. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  212. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  213. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  214. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  215. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  216. fsiOPFLD.BilgDeptName = department.Name
  217. fsiOPFLD.BilgDeptCodg = department.Number
  218. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  219. fsiOPFLD.BilgDrName = doctor.UserName
  220. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  221. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  222. fsiOPFLD.MedChrgitmType = "08"
  223. memo["hosp_appr_flag"] = "1"
  224. memo["invoice_no"] = order.MdtrtId
  225. memo["memo"] = "自费"
  226. bytesData, _ := json.Marshal(memo)
  227. fsiOPFLD.Memo = string(bytesData)
  228. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  229. }
  230. }
  231. }
  232. for _, items := range order_info_two {
  233. memo := make(map[string]interface{})
  234. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  235. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  236. fsiOPFLD.MedType = "14"
  237. fsiOPFLD.BkkpSn = items.FeedetlSn
  238. fsiOPFLD.FixmedinsCode = miConfig.Code
  239. fsiOPFLD.FixmedinsName = miConfig.OrgName
  240. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  241. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  242. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  243. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  244. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  245. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  246. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  247. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  248. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  249. fsiOPFLD.BilgDeptName = department.Name
  250. fsiOPFLD.BilgDeptCodg = department.Number
  251. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  252. fsiOPFLD.BilgDrName = doctor.UserName
  253. fsiOPFLD.MedChrgitmType = "09"
  254. memo["hosp_appr_flag"] = "1"
  255. memo["invoice_no"] = order.MdtrtId
  256. memo["memo"] = "自费"
  257. bytesData, _ := json.Marshal(memo)
  258. fsiOPFLD.Memo = string(bytesData)
  259. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  260. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  261. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  262. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  263. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  264. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  265. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  266. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  267. fsiOPFLD.BilgDeptName = department.Name
  268. fsiOPFLD.BilgDeptCodg = department.Number
  269. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  270. fsiOPFLD.BilgDrName = doctor.UserName
  271. switch items.HisPrescriptionProject.HisProject.CostClassify {
  272. case 0:
  273. break
  274. case 1:
  275. fsiOPFLD.MedChrgitmType = "14"
  276. break
  277. case 2:
  278. fsiOPFLD.MedChrgitmType = "05"
  279. break
  280. case 3:
  281. fsiOPFLD.MedChrgitmType = "03"
  282. break
  283. case 4:
  284. fsiOPFLD.MedChrgitmType = "03"
  285. break
  286. case 5:
  287. fsiOPFLD.MedChrgitmType = "08"
  288. break
  289. case 6:
  290. fsiOPFLD.MedChrgitmType = "14"
  291. break
  292. case 7:
  293. fsiOPFLD.MedChrgitmType = "14"
  294. break
  295. case 8:
  296. fsiOPFLD.MedChrgitmType = "03"
  297. break
  298. case 9:
  299. fsiOPFLD.MedChrgitmType = "14"
  300. break
  301. case 10:
  302. fsiOPFLD.MedChrgitmType = "14"
  303. break
  304. case 11:
  305. fsiOPFLD.MedChrgitmType = "06"
  306. break
  307. case 12:
  308. fsiOPFLD.MedChrgitmType = "12"
  309. break
  310. case 13:
  311. fsiOPFLD.MedChrgitmType = "01"
  312. break
  313. case 14:
  314. fsiOPFLD.MedChrgitmType = "04"
  315. break
  316. case 15:
  317. fsiOPFLD.MedChrgitmType = "14"
  318. break
  319. }
  320. memo["hosp_appr_flag"] = "1"
  321. memo["invoice_no"] = order.MdtrtId
  322. memo["memo"] = "自费"
  323. bytesData, _ := json.Marshal(memo)
  324. fsiOPFLD.Memo = string(bytesData)
  325. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  326. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  327. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  328. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  329. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  330. fsiOPFLD.BilgDeptName = department.Name
  331. fsiOPFLD.BilgDeptCodg = department.Number
  332. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  333. fsiOPFLD.BilgDrName = doctor.UserName
  334. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  335. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  336. fsiOPFLD.MedChrgitmType = "08"
  337. memo["hosp_appr_flag"] = "1"
  338. memo["invoice_no"] = order.MdtrtId
  339. memo["memo"] = "自费"
  340. bytesData, _ := json.Marshal(memo)
  341. fsiOPFLD.Memo = string(bytesData)
  342. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  343. }
  344. }
  345. }
  346. fmt.Println(fsiOPFLDs)
  347. struct4201A.Fopfd = fsiOPFLDs
  348. fmt.Println(struct4201A.Fopfd)
  349. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  350. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  351. var res2 ResultSix
  352. var respJSON2 map[string]interface{}
  353. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. userJSONBytes2, _ := json.Marshal(respJSON2)
  359. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  360. utils.ErrorLog("解析失败:%v", err)
  361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  362. return
  363. }
  364. if res2.Infcode != 0 {
  365. c.ServeSuccessJSON(map[string]interface{}{
  366. "failed_code": -10,
  367. "msg": res2.ErrMsg,
  368. })
  369. return
  370. } else {
  371. c.ServeSuccessJSON(map[string]interface{}{
  372. "msg": "上传成功",
  373. })
  374. }
  375. }
  376. func (c *HisApiController) Get4202() {
  377. order_id, _ := c.GetInt64("order_id")
  378. admin_user_id, _ := c.GetInt64("admin_user_id")
  379. order, _ := service.GetHisOrderByIDTwo(order_id)
  380. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  381. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  382. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  383. if order.ID == 0 {
  384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  385. return
  386. }
  387. var struct4202 models.Struct4202
  388. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  389. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  390. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  391. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  392. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  393. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  394. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  395. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  396. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  397. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  398. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  399. var config []*models.HisXtDiagnoseConfig
  400. for _, item := range diagnosis_ids {
  401. id, _ := strconv.ParseInt(item, 10, 64)
  402. diagnosisConfig, _ := service.FindDiagnoseById(id)
  403. config = append(config, &diagnosisConfig)
  404. }
  405. var tempDiaginfos []models.OwnPayPatnDiagListD
  406. for index, item := range config {
  407. if index == 0 {
  408. var tempDiaginfo models.OwnPayPatnDiagListD
  409. tempDiaginfo.InoutDiagType = "1"
  410. tempDiaginfo.DiagCode = item.CountryCode
  411. tempDiaginfo.DiagName = item.CountryContentName
  412. tempDiaginfo.DiagType = "1"
  413. tempDiaginfo.DiagSrtNo = "1"
  414. tempDiaginfo.MaindiagFlag = "1"
  415. tempDiaginfo.ValiFlag = "1"
  416. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  417. } else {
  418. var tempDiaginfo models.OwnPayPatnDiagListD
  419. tempDiaginfo.DiagCode = item.CountryCode
  420. tempDiaginfo.DiagName = item.CountryContentName
  421. tempDiaginfo.DiagType = "2"
  422. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  423. tempDiaginfo.MaindiagFlag = "0"
  424. tempDiaginfo.ValiFlag = "1"
  425. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  426. }
  427. }
  428. struct4202.ODiagListD = tempDiaginfos
  429. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  430. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  431. var res2 ResultSix
  432. var respJSON2 map[string]interface{}
  433. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  436. return
  437. }
  438. userJSONBytes2, _ := json.Marshal(respJSON2)
  439. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  440. utils.ErrorLog("解析失败:%v", err)
  441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  442. return
  443. }
  444. if res2.Infcode != 0 {
  445. c.ServeSuccessJSON(map[string]interface{}{
  446. "failed_code": -10,
  447. "msg": res2.ErrMsg,
  448. })
  449. return
  450. } else {
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "msg": "上传成功",
  453. })
  454. }
  455. }
  456. func (c *HisApiController) Get4203() {
  457. admin_user_id, _ := c.GetInt64("admin_user_id")
  458. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  460. order_id, _ := c.GetInt64("order_id")
  461. order, _ := service.GetHisOrderByIDTwo(order_id)
  462. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  463. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  464. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  465. var res2 ResultSix
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res2.Infcode != 0 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res2.ErrMsg,
  482. })
  483. return
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "msg": "上传成功",
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get4205() {
  491. order_id, _ := c.GetInt64("order_id")
  492. admin_user_id, _ := c.GetInt64("admin_user_id")
  493. order, _ := service.GetHisOrderByIDTwo(order_id)
  494. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  497. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  498. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  499. //order_info = append(order_info, order_info_two...)
  500. department, _ := service.GetDepartMentDetail(his.Departments)
  501. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  502. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  503. if order.ID == 0 {
  504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  505. return
  506. }
  507. var struct4201A models.Struct4201A
  508. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  509. for _, items := range order_info {
  510. memo := make(map[string]interface{})
  511. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  512. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  513. fsiOPFLD.MedType = "14"
  514. fsiOPFLD.BkkpSn = items.FeedetlSn
  515. fsiOPFLD.FixmedinsCode = miConfig.Code
  516. fsiOPFLD.FixmedinsName = miConfig.OrgName
  517. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  518. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  519. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  520. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  521. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  522. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  523. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  524. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  525. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  526. fsiOPFLD.BilgDeptName = department.Name
  527. fsiOPFLD.BilgDeptCodg = department.Number
  528. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  529. fsiOPFLD.BilgDrName = doctor.UserName
  530. fsiOPFLD.MedChrgitmType = "09"
  531. memo["hosp_appr_flag"] = "1"
  532. memo["invoice_no"] = order.MdtrtId
  533. memo["memo"] = "自费"
  534. bytesData, _ := json.Marshal(memo)
  535. fsiOPFLD.Memo = string(bytesData)
  536. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  537. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  538. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  539. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  540. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  541. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  542. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  543. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  544. fsiOPFLD.BilgDeptName = department.Name
  545. fsiOPFLD.BilgDeptCodg = department.Number
  546. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  547. fsiOPFLD.BilgDrName = doctor.UserName
  548. switch items.HisPrescriptionProject.HisProject.CostClassify {
  549. case 0:
  550. break
  551. case 1:
  552. fsiOPFLD.MedChrgitmType = "14"
  553. break
  554. case 2:
  555. fsiOPFLD.MedChrgitmType = "05"
  556. break
  557. case 3:
  558. fsiOPFLD.MedChrgitmType = "03"
  559. break
  560. case 4:
  561. fsiOPFLD.MedChrgitmType = "03"
  562. break
  563. case 5:
  564. fsiOPFLD.MedChrgitmType = "08"
  565. break
  566. case 6:
  567. fsiOPFLD.MedChrgitmType = "14"
  568. break
  569. case 7:
  570. fsiOPFLD.MedChrgitmType = "14"
  571. break
  572. case 8:
  573. fsiOPFLD.MedChrgitmType = "03"
  574. break
  575. case 9:
  576. fsiOPFLD.MedChrgitmType = "14"
  577. break
  578. case 10:
  579. fsiOPFLD.MedChrgitmType = "14"
  580. break
  581. case 11:
  582. fsiOPFLD.MedChrgitmType = "06"
  583. break
  584. case 12:
  585. fsiOPFLD.MedChrgitmType = "12"
  586. break
  587. case 13:
  588. fsiOPFLD.MedChrgitmType = "01"
  589. break
  590. case 14:
  591. fsiOPFLD.MedChrgitmType = "04"
  592. break
  593. case 15:
  594. fsiOPFLD.MedChrgitmType = "14"
  595. break
  596. }
  597. memo["hosp_appr_flag"] = "1"
  598. memo["invoice_no"] = order.MdtrtId
  599. memo["memo"] = "自费"
  600. bytesData, _ := json.Marshal(memo)
  601. fsiOPFLD.Memo = string(bytesData)
  602. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  603. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  604. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  605. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  606. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  607. fsiOPFLD.BilgDeptName = department.Name
  608. fsiOPFLD.BilgDeptCodg = department.Number
  609. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  610. fsiOPFLD.BilgDrName = doctor.UserName
  611. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  612. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  613. fsiOPFLD.MedChrgitmType = "08"
  614. memo["hosp_appr_flag"] = "1"
  615. memo["invoice_no"] = order.MdtrtId
  616. memo["memo"] = "自费"
  617. bytesData, _ := json.Marshal(memo)
  618. fsiOPFLD.Memo = string(bytesData)
  619. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  620. }
  621. }
  622. }
  623. for _, items := range order_info_two {
  624. memo := make(map[string]interface{})
  625. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  626. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  627. fsiOPFLD.MedType = "14"
  628. fsiOPFLD.BkkpSn = items.FeedetlSn
  629. fsiOPFLD.FixmedinsCode = miConfig.Code
  630. fsiOPFLD.FixmedinsName = miConfig.OrgName
  631. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  632. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  633. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  634. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  635. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  636. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  637. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  638. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  639. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  640. fsiOPFLD.BilgDeptName = department.Name
  641. fsiOPFLD.BilgDeptCodg = department.Number
  642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  643. fsiOPFLD.BilgDrName = doctor.UserName
  644. fsiOPFLD.MedChrgitmType = "09"
  645. memo["hosp_appr_flag"] = "1"
  646. memo["invoice_no"] = order.MdtrtId
  647. memo["memo"] = "自费"
  648. bytesData, _ := json.Marshal(memo)
  649. fsiOPFLD.Memo = string(bytesData)
  650. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  651. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  652. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  653. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  654. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  655. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  656. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  657. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  658. fsiOPFLD.BilgDeptName = department.Name
  659. fsiOPFLD.BilgDeptCodg = department.Number
  660. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  661. fsiOPFLD.BilgDrName = doctor.UserName
  662. switch items.HisPrescriptionProject.HisProject.CostClassify {
  663. case 0:
  664. break
  665. case 1:
  666. fsiOPFLD.MedChrgitmType = "14"
  667. break
  668. case 2:
  669. fsiOPFLD.MedChrgitmType = "05"
  670. break
  671. case 3:
  672. fsiOPFLD.MedChrgitmType = "03"
  673. break
  674. case 4:
  675. fsiOPFLD.MedChrgitmType = "03"
  676. break
  677. case 5:
  678. fsiOPFLD.MedChrgitmType = "08"
  679. break
  680. case 6:
  681. fsiOPFLD.MedChrgitmType = "14"
  682. break
  683. case 7:
  684. fsiOPFLD.MedChrgitmType = "14"
  685. break
  686. case 8:
  687. fsiOPFLD.MedChrgitmType = "03"
  688. break
  689. case 9:
  690. fsiOPFLD.MedChrgitmType = "14"
  691. break
  692. case 10:
  693. fsiOPFLD.MedChrgitmType = "14"
  694. break
  695. case 11:
  696. fsiOPFLD.MedChrgitmType = "06"
  697. break
  698. case 12:
  699. fsiOPFLD.MedChrgitmType = "12"
  700. break
  701. case 13:
  702. fsiOPFLD.MedChrgitmType = "01"
  703. break
  704. case 14:
  705. fsiOPFLD.MedChrgitmType = "04"
  706. break
  707. case 15:
  708. fsiOPFLD.MedChrgitmType = "14"
  709. break
  710. }
  711. memo["hosp_appr_flag"] = "1"
  712. memo["invoice_no"] = order.MdtrtId
  713. memo["memo"] = "自费"
  714. bytesData, _ := json.Marshal(memo)
  715. fsiOPFLD.Memo = string(bytesData)
  716. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  717. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  718. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  719. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  720. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  721. fsiOPFLD.BilgDeptName = department.Name
  722. fsiOPFLD.BilgDeptCodg = department.Number
  723. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  724. fsiOPFLD.BilgDrName = doctor.UserName
  725. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  726. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  727. fsiOPFLD.MedChrgitmType = "08"
  728. memo["hosp_appr_flag"] = "1"
  729. memo["invoice_no"] = order.MdtrtId
  730. memo["memo"] = "自费"
  731. bytesData, _ := json.Marshal(memo)
  732. fsiOPFLD.Memo = string(bytesData)
  733. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  734. }
  735. }
  736. }
  737. fmt.Println(fsiOPFLDs)
  738. struct4201A.Fopfd = fsiOPFLDs
  739. fmt.Println(struct4201A.Fopfd)
  740. var struct4202 models.Struct4202
  741. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  742. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  743. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  744. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  745. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  746. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  747. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  748. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  749. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  750. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  751. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  752. var config []*models.HisXtDiagnoseConfig
  753. for _, item := range diagnosis_ids {
  754. id, _ := strconv.ParseInt(item, 10, 64)
  755. diagnosisConfig, _ := service.FindDiagnoseById(id)
  756. config = append(config, &diagnosisConfig)
  757. }
  758. var tempDiaginfos []models.OwnPayPatnDiagListD
  759. for index, item := range config {
  760. if index == 0 {
  761. var tempDiaginfo models.OwnPayPatnDiagListD
  762. tempDiaginfo.InoutDiagType = "1"
  763. tempDiaginfo.DiagCode = item.CountryCode
  764. tempDiaginfo.DiagName = item.CountryContentName
  765. tempDiaginfo.DiagType = "1"
  766. tempDiaginfo.DiagSrtNo = "1"
  767. tempDiaginfo.MaindiagFlag = "1"
  768. tempDiaginfo.ValiFlag = "1"
  769. tempDiaginfo.DiagDrName = doctor.UserName
  770. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  771. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  772. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  773. } else {
  774. var tempDiaginfo models.OwnPayPatnDiagListD
  775. tempDiaginfo.DiagCode = item.CountryCode
  776. tempDiaginfo.DiagName = item.CountryContentName
  777. tempDiaginfo.DiagType = "2"
  778. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  779. tempDiaginfo.MaindiagFlag = "0"
  780. tempDiaginfo.ValiFlag = "1"
  781. tempDiaginfo.DiagDrName = doctor.UserName
  782. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  783. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  784. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  785. }
  786. }
  787. struct4202.ODiagListD = tempDiaginfos
  788. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  789. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  790. var res2 ResultSix
  791. var respJSON2 map[string]interface{}
  792. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. userJSONBytes2, _ := json.Marshal(respJSON2)
  798. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  799. utils.ErrorLog("解析失败:%v", err)
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. if res2.Infcode != 0 {
  804. c.ServeSuccessJSON(map[string]interface{}{
  805. "failed_code": -10,
  806. "msg": res2.ErrMsg,
  807. })
  808. return
  809. } else {
  810. c.ServeSuccessJSON(map[string]interface{}{
  811. "msg": "上传成功",
  812. })
  813. }
  814. }
  815. func (c *HisApiController) Get4207() {
  816. admin_user_id, _ := c.GetInt64("admin_user_id")
  817. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. order_id, _ := c.GetInt64("order_id")
  820. order, _ := service.GetHisOrderByIDTwo(order_id)
  821. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  822. var struct4207 models.Struct4207
  823. struct4207.PageNum = "1"
  824. struct4207.PageSize = "1000"
  825. struct4207.FixmedinsCode = miConfig.Code
  826. struct4207.FixmedinsMdtrtID = order.Number
  827. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  828. saveLog(result, requestLog, "4207", "查询")
  829. var res2 ResultSix
  830. var respJSON2 map[string]interface{}
  831. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  834. return
  835. }
  836. userJSONBytes2, _ := json.Marshal(respJSON2)
  837. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  838. utils.ErrorLog("解析失败:%v", err)
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  840. return
  841. }
  842. if res2.Infcode != 0 {
  843. c.ServeSuccessJSON(map[string]interface{}{
  844. "failed_code": -10,
  845. "msg": res2.ErrMsg,
  846. })
  847. return
  848. } else {
  849. c.ServeSuccessJSON(map[string]interface{}{
  850. "msg": "查询成功",
  851. })
  852. }
  853. }
  854. func (c *HisApiController) Get4208() {
  855. admin_user_id, _ := c.GetInt64("admin_user_id")
  856. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  858. order_id, _ := c.GetInt64("order_id")
  859. order, _ := service.GetHisOrderByIDTwo(order_id)
  860. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  861. var struct4208 models.Struct4208
  862. struct4208.PageNum = "1"
  863. struct4208.PageSize = "1000"
  864. struct4208.PsnCertType = "01"
  865. struct4208.Certno = his.Certno
  866. struct4208.MedType = order.MedType
  867. struct4208.PsnName = his.Name
  868. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  869. saveLog(result, requestLog, "4208", "查询")
  870. var res2 ResultSix
  871. var respJSON2 map[string]interface{}
  872. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  875. return
  876. }
  877. userJSONBytes2, _ := json.Marshal(respJSON2)
  878. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  879. utils.ErrorLog("解析失败:%v", err)
  880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  881. return
  882. }
  883. if res2.Infcode != 0 {
  884. c.ServeSuccessJSON(map[string]interface{}{
  885. "failed_code": -10,
  886. "msg": res2.ErrMsg,
  887. })
  888. return
  889. } else {
  890. c.ServeSuccessJSON(map[string]interface{}{
  891. "msg": "查询成功",
  892. })
  893. }
  894. }
  895. func (c *HisApiController) Get4209() {
  896. admin_user_id, _ := c.GetInt64("admin_user_id")
  897. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  899. order_id, _ := c.GetInt64("order_id")
  900. order, _ := service.GetHisOrderByIDTwo(order_id)
  901. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  902. var struct4209 models.Struct4209
  903. struct4209.FixmedinsMdtrtID = order.Number
  904. struct4209.FixmedinsCode = miConfig.Code
  905. struct4209.PageSize = "1000"
  906. struct4209.PageNum = "1"
  907. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  908. saveLog(result, requestLog, "4209", "查询")
  909. var res2 ResultSix
  910. var respJSON2 map[string]interface{}
  911. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. userJSONBytes2, _ := json.Marshal(respJSON2)
  917. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  918. utils.ErrorLog("解析失败:%v", err)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. if res2.Infcode != 0 {
  923. c.ServeSuccessJSON(map[string]interface{}{
  924. "failed_code": -10,
  925. "msg": res2.ErrMsg,
  926. })
  927. return
  928. } else {
  929. c.ServeSuccessJSON(map[string]interface{}{
  930. "msg": "查询成功",
  931. })
  932. }
  933. }
  934. type Result3101 struct {
  935. Infcode string `json:"infcode"`
  936. InfRefmsgid string `json:"inf_refmsgid"`
  937. RefmsgTime string `json:"refmsg_time"`
  938. RespondTime string `json:"respond_time"`
  939. Enctype string `json:"enctype"`
  940. Signtype string `json:"signtype"`
  941. ErrMsg string `json:"err_msg"`
  942. Output struct {
  943. Result []struct {
  944. JudgeResultDetailDtos []struct {
  945. VolaItemType string `json:"vola_item_type"`
  946. MdtrtID string `json:"mdtrt_id"`
  947. JrdID string `json:"jrd_id"`
  948. PatnID string `json:"patn_id"`
  949. RxID string `json:"rx_id"`
  950. VolaAmt interface{} `json:"vola_amt"`
  951. } `json:"judge_result_detail_dtos"`
  952. RuleID string `json:"rule_id"`
  953. VolaEvid string `json:"vola_evid"`
  954. MdtrtID string `json:"mdtrt_id"`
  955. RuleName string `json:"rule_name"`
  956. VolaAmtStas string `json:"vola_amt_stas"`
  957. JrID string `json:"jr_id"`
  958. PatnID string `json:"patn_id"`
  959. SevDeg string `json:"sev_deg"`
  960. VolaAmt float64 `json:"vola_amt"`
  961. VolaBhvrType string `json:"vola_bhvr_type"`
  962. VolaCont string `json:"vola_cont"`
  963. } `json:"result"`
  964. } `json:"output"`
  965. }
  966. func (c *HisApiController) ReadEleToken() {
  967. admin_user_id, _ := c.GetInt64("admin_user_id")
  968. his_patient_id, _ := c.GetInt64("his_patient_id")
  969. adminUser := c.GetAdminUserInfo()
  970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  972. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  973. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  974. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  975. if len(tokens) > 0 {
  976. c.ServeSuccessJSON(map[string]interface{}{
  977. "msg": "读取成功",
  978. })
  979. } else {
  980. c.ServeSuccessJSON(map[string]interface{}{
  981. "failed_code": -10,
  982. "msg": "读取失败",
  983. })
  984. }
  985. } else if miConfig.MdtrtareaAdmvs == "350500" {
  986. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  987. if len(errMsg) == 0 {
  988. type ELeData struct {
  989. Data struct {
  990. IdNo string `json:"idNo"`
  991. IdType string `json:"idType"`
  992. UserName string `json:"userName"`
  993. EcToken string `json:"ecToken"`
  994. InsuOrg string `json:"insuOrg"`
  995. Gender string `json:"gender"`
  996. Birthday string `json:"birthday"`
  997. Nationality string `json:"nationality"`
  998. Email string `json:"email"`
  999. Extra string `json:"extra"`
  1000. } `json:"data"`
  1001. Code int `json:"code"`
  1002. Message string `json:"message"`
  1003. }
  1004. var ele ELeData
  1005. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1006. if err != nil {
  1007. utils.ErrorLog("解析失败:%v", err)
  1008. }
  1009. token := ele.Data.EcToken
  1010. if len(token) > 0 {
  1011. psn := &models.HisPsn{
  1012. PsnNo: his.PsnNo,
  1013. Age: 0,
  1014. PatientId: his.PatientId,
  1015. Certno: his.Certno,
  1016. Brdy: his.Brdy,
  1017. Gend: his.Gend,
  1018. Naty: his.Naty,
  1019. PsnCertType: his.PsnCertType,
  1020. PsnName: his.PsnName,
  1021. Idetinfo: his.Idetinfo,
  1022. Insuinfo: his.Iinfo,
  1023. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1024. CardInfo: outPutInfo,
  1025. VerifyNumber: token,
  1026. }
  1027. service.CreateHisPsn(psn)
  1028. }
  1029. if len(token) > 0 {
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "msg": "读取成功",
  1032. })
  1033. } else {
  1034. c.ServeSuccessJSON(map[string]interface{}{
  1035. "failed_code": -10,
  1036. "msg": "读取失败",
  1037. })
  1038. }
  1039. }
  1040. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1041. if initFlag == 0 {
  1042. c.TestGetJiangXiBasBaseInit()
  1043. }
  1044. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1045. type ELeData struct {
  1046. Data struct {
  1047. IdNo string `json:"idNo"`
  1048. IdType string `json:"idType"`
  1049. UserName string `json:"userName"`
  1050. EcToken string `json:"ecToken"`
  1051. InsuOrg string `json:"insuOrg"`
  1052. Gender string `json:"gender"`
  1053. Birthday string `json:"birthday"`
  1054. Nationality string `json:"nationality"`
  1055. Email string `json:"email"`
  1056. Extra string `json:"extra"`
  1057. } `json:"data"`
  1058. Code int `json:"code"`
  1059. Message string `json:"message"`
  1060. }
  1061. var ele ELeData
  1062. err := json.Unmarshal([]byte(json_result), &ele)
  1063. if err != nil {
  1064. utils.ErrorLog("解析失败:%v", err)
  1065. }
  1066. token := ele.Data.EcToken
  1067. token = Remove0000(token)
  1068. fmt.Println(ele.Data.UserName)
  1069. 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)
  1070. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1071. var res ResultTwo
  1072. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1073. utils.ErrorLog("解析失败:%v", err)
  1074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1075. return
  1076. }
  1077. if res.Infcode == 0 {
  1078. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1079. if err == gorm.ErrRecordNotFound {
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1081. return
  1082. } else if err != nil {
  1083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1084. return
  1085. } else {
  1086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1088. infoStr := string(Iinfos)
  1089. idetinfoStr := string(Idetinfos)
  1090. psn := &models.HisPsn{
  1091. PsnNo: res.Output.Baseinfo.PsnNo,
  1092. Age: res.Output.Baseinfo.Age,
  1093. PatientId: patient.ID,
  1094. Certno: res.Output.Baseinfo.Certno,
  1095. Brdy: res.Output.Baseinfo.Brdy,
  1096. Gend: res.Output.Baseinfo.Gend,
  1097. Naty: res.Output.Baseinfo.Naty,
  1098. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1099. PsnName: res.Output.Baseinfo.PsnName,
  1100. Idetinfo: idetinfoStr,
  1101. Insuinfo: infoStr,
  1102. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1103. CardInfo: "",
  1104. VerifyNumber: token,
  1105. }
  1106. service.CreateHisPsn(psn)
  1107. c.ServeSuccessJSON(map[string]interface{}{
  1108. "patient": patient,
  1109. "number": token,
  1110. })
  1111. }
  1112. } else {
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1114. return
  1115. }
  1116. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1117. if initFlag == 0 {
  1118. c.TestGetJiangXiBasBaseInit()
  1119. }
  1120. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1121. type ELeData struct {
  1122. Data struct {
  1123. IdNo string `json:"idNo"`
  1124. IdType string `json:"idType"`
  1125. UserName string `json:"userName"`
  1126. EcToken string `json:"ecToken"`
  1127. InsuOrg string `json:"insuOrg"`
  1128. Gender string `json:"gender"`
  1129. Birthday string `json:"birthday"`
  1130. Nationality string `json:"nationality"`
  1131. Email string `json:"email"`
  1132. Extra string `json:"extra"`
  1133. } `json:"data"`
  1134. Code int `json:"code"`
  1135. Message string `json:"message"`
  1136. }
  1137. var ele ELeData
  1138. err := json.Unmarshal([]byte(json_result), &ele)
  1139. if err != nil {
  1140. utils.ErrorLog("解析失败:%v", err)
  1141. }
  1142. token := ele.Data.EcToken
  1143. token = Remove0000(token)
  1144. fmt.Println(ele.Data.UserName)
  1145. 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)
  1146. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1147. var res ResultTwo
  1148. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1149. utils.ErrorLog("解析失败:%v", err)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. return
  1152. }
  1153. if res.Infcode == 0 {
  1154. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1155. if err == gorm.ErrRecordNotFound {
  1156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1157. return
  1158. } else if err != nil {
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1160. return
  1161. } else {
  1162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1163. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1164. infoStr := string(Iinfos)
  1165. idetinfoStr := string(Idetinfos)
  1166. psn := &models.HisPsn{
  1167. PsnNo: res.Output.Baseinfo.PsnNo,
  1168. Age: res.Output.Baseinfo.Age,
  1169. PatientId: patient.ID,
  1170. Certno: res.Output.Baseinfo.Certno,
  1171. Brdy: res.Output.Baseinfo.Brdy,
  1172. Gend: res.Output.Baseinfo.Gend,
  1173. Naty: res.Output.Baseinfo.Naty,
  1174. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1175. PsnName: res.Output.Baseinfo.PsnName,
  1176. Idetinfo: idetinfoStr,
  1177. Insuinfo: infoStr,
  1178. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1179. CardInfo: "",
  1180. VerifyNumber: token,
  1181. }
  1182. service.CreateHisPsn(psn)
  1183. c.ServeSuccessJSON(map[string]interface{}{
  1184. "patient": patient,
  1185. "number": token,
  1186. })
  1187. }
  1188. } else {
  1189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1190. return
  1191. }
  1192. } else {
  1193. if initFlag == 0 {
  1194. c.TestGetBasBaseInit()
  1195. }
  1196. token := c.GetEleBaseInfo()
  1197. token = Remove0000(token)
  1198. if len(token) > 0 {
  1199. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  1200. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1201. var res ResultTwo
  1202. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1203. utils.ErrorLog("解析失败:%v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. if res.Infcode == 0 {
  1208. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1209. if err == gorm.ErrRecordNotFound {
  1210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1211. return
  1212. } else if err != nil {
  1213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1214. return
  1215. } else {
  1216. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1217. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1218. infoStr := string(Iinfos)
  1219. idetinfoStr := string(Idetinfos)
  1220. psn := &models.HisPsn{
  1221. PsnNo: res.Output.Baseinfo.PsnNo,
  1222. Age: res.Output.Baseinfo.Age,
  1223. PatientId: patient.ID,
  1224. Certno: res.Output.Baseinfo.Certno,
  1225. Brdy: res.Output.Baseinfo.Brdy,
  1226. Gend: res.Output.Baseinfo.Gend,
  1227. Naty: res.Output.Baseinfo.Naty,
  1228. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1229. PsnName: res.Output.Baseinfo.PsnName,
  1230. Idetinfo: idetinfoStr,
  1231. Insuinfo: infoStr,
  1232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1233. CardInfo: "",
  1234. VerifyNumber: token,
  1235. }
  1236. service.CreateHisPsn(psn)
  1237. c.ServeSuccessJSON(map[string]interface{}{
  1238. "msg": "读取成功",
  1239. })
  1240. }
  1241. } else {
  1242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1243. return
  1244. }
  1245. } else {
  1246. c.ServeSuccessJSON(map[string]interface{}{
  1247. "failed_code": -10,
  1248. "msg": "读取失败",
  1249. })
  1250. }
  1251. }
  1252. }
  1253. func (c *HisApiController) Get9001() {
  1254. adminUser := c.GetAdminUserInfo()
  1255. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1256. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1257. if miConfig.MdtrtareaAdmvs == "350500" {
  1258. service.GetFjAuthorizationInfo(miConfig.Code)
  1259. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1260. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1261. var dat map[string]interface{}
  1262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1263. fmt.Println(dat)
  1264. } else {
  1265. fmt.Println(err)
  1266. }
  1267. userJSONBytes, _ := json.Marshal(dat)
  1268. var res models.Result9001
  1269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1270. utils.ErrorLog("解析失败:%v", err)
  1271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1272. return
  1273. }
  1274. } else {
  1275. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1276. var dat map[string]interface{}
  1277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1278. fmt.Println(dat)
  1279. } else {
  1280. fmt.Println(err)
  1281. }
  1282. userJSONBytes, _ := json.Marshal(dat)
  1283. var res models.Result9001
  1284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1285. utils.ErrorLog("解析失败:%v", err)
  1286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1287. return
  1288. }
  1289. }
  1290. }
  1291. 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) {
  1292. var res Result3101
  1293. adminUser := c.GetAdminUserInfo()
  1294. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1295. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1297. //record_time := c.GetString("record_time")
  1298. //trig_scen := c.GetString("trig_scen")
  1299. timeLayout := "2006-01-02"
  1300. loc, _ := time.LoadLocation("Local")
  1301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1302. if err != nil {
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1304. return res
  1305. }
  1306. recordDateTime := theTime.Unix()
  1307. var patientPrescription models.HisPrescriptionInfo
  1308. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1309. //if patientPrescription.ID == 0 {
  1310. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1311. //}
  1312. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1313. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1314. //
  1315. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1316. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1317. var pp models.PublicParams
  1318. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1319. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1320. pp.FixmedinsName = miConfig.OrgName
  1321. pp.FixmedinsCode = miConfig.Code
  1322. pp.RequestUrl = miConfig.Url
  1323. pp.Cainfo = miConfig.Cainfo
  1324. pp.SecretKey = miConfig.SecretKey
  1325. pp.AccessKey = miConfig.AccessKey
  1326. pp.OpterName = roles.UserName
  1327. var config []*models.HisXtDiagnoseConfig
  1328. for _, item := range diagnosis_ids {
  1329. id, _ := strconv.ParseInt(item, 10, 64)
  1330. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1331. config = append(config, &diagnosisConfig)
  1332. }
  1333. var pd models.PatientDtos
  1334. pd.PatnID = his.PsnNo
  1335. pd.PatnName = his.Name
  1336. pd.Gend = his.Gend
  1337. pd.Brdy = his.Brdy
  1338. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1339. pd.CurrMdtrtID = his.Number
  1340. var fed models.FsiEncounterDtos
  1341. fed.MdtrtID = his.Number
  1342. fed.MedinsID = miConfig.Code
  1343. fed.MedinsName = miConfig.OrgName
  1344. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1345. fed.MedMdtrtType = "1"
  1346. fed.MedinsType = "1"
  1347. fed.MedinsLv = "11"
  1348. tm := time.Unix(his.RecordDate, 0)
  1349. s_tm := tm.Format("2006-01-02 15:04:05")
  1350. fed.AdmDate = s_tm
  1351. fed.DscgDate = s_tm
  1352. fed.DscgMainDiseCodg = config[0].CountryCode
  1353. fed.DscgMainDiseName = config[0].CountryContentName
  1354. //诊断信息
  1355. var fdds []*models.FsiDiagnoseDtos
  1356. for index, item := range config {
  1357. if index == 0 {
  1358. var fdd models.FsiDiagnoseDtos
  1359. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1360. fdd.InoutDiseType = "1"
  1361. fdd.MaindiseFlag = "1"
  1362. fdd.DiseDate = s_tm
  1363. fdd.DiasSrtNo = "1"
  1364. fdd.DiseName = item.CountryContentName
  1365. fdd.DiseCodg = item.CountryCode
  1366. fdds = append(fdds, &fdd)
  1367. } else {
  1368. var fdd models.FsiDiagnoseDtos
  1369. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1370. fdd.InoutDiseType = "1"
  1371. fdd.MaindiseFlag = "1"
  1372. fdd.DiseDate = s_tm
  1373. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1374. fdd.DiseName = item.CountryContentName
  1375. fdd.DiseCodg = item.CountryCode
  1376. fdds = append(fdds, &fdd)
  1377. }
  1378. }
  1379. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1380. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1381. fed.AdmDeptName = department.Name
  1382. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1383. fed.DscgDeptName = department.Name
  1384. fed.MedMdtrtType = "1"
  1385. fed.MedType = "11"
  1386. //if his.Insutype == "390" {
  1387. // fed.MedType = "1402"
  1388. //} else {
  1389. // fed.MedType = "9933"
  1390. //}
  1391. var orders []*models.FsiOrderDtos
  1392. if trig_scen == "2" {
  1393. //处方医嘱信息
  1394. for _, item := range prescriptions {
  1395. for _, subItem := range item.HisDoctorAdviceInfo {
  1396. var order models.FsiOrderDtos
  1397. order.RxID = strconv.FormatInt(item.ID, 10)
  1398. order.Rxno = strconv.FormatInt(item.ID, 10)
  1399. order.LongDrordFlag = "0"
  1400. order.HilistType = "1"
  1401. order.ChrgType = "1"
  1402. order.DrordBhvr = "-"
  1403. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1404. order.HosplistName = subItem.BaseDrugLib.DrugName
  1405. order.HilistLv = "1"
  1406. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1407. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1408. order.HosplistName = subItem.BaseDrugLib.DrugName
  1409. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1410. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1411. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1412. order.OwnpayAmt = ""
  1413. order.SelfpayAmt = ""
  1414. order.Spec = ""
  1415. order.SpecUnt = ""
  1416. order.DrordBegnDate = s_tm
  1417. order.DrordStopDate = ""
  1418. order.DrordDrCodg = "1"
  1419. order.DrordDeptName = department.Name
  1420. order.DrordDrCodg = "1"
  1421. order.DrordDrName = doctor_info.UserName
  1422. order.DrordDrProfttl = ""
  1423. order.CurrDrordFlag = "1"
  1424. orders = append(orders, &order)
  1425. }
  1426. for _, subItem := range item.HisPrescriptionProject {
  1427. if subItem.Type == 2 {
  1428. var order models.FsiOrderDtos
  1429. order.RxID = strconv.FormatInt(item.ID, 10)
  1430. order.Rxno = strconv.FormatInt(item.ID, 10)
  1431. order.LongDrordFlag = "0"
  1432. order.HilistType = "1"
  1433. order.ChrgType = "1"
  1434. order.DrordBhvr = "-"
  1435. order.HilistCode = subItem.HisProject.MedicalCode
  1436. order.HosplistName = subItem.HisProject.ProjectName
  1437. order.HilistLv = "1"
  1438. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1439. order.HosplistCode = subItem.HisProject.MedicalCode
  1440. order.HosplistName = subItem.HisProject.ProjectName
  1441. order.Cnt = subItem.Count
  1442. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1443. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1444. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1445. order.OwnpayAmt = ""
  1446. order.SelfpayAmt = ""
  1447. order.Spec = ""
  1448. order.SpecUnt = ""
  1449. order.DrordBegnDate = s_tm
  1450. order.DrordStopDate = ""
  1451. order.DrordDrCodg = "1"
  1452. order.DrordDeptName = department.Name
  1453. order.DrordDrCodg = "1"
  1454. order.DrordDrName = doctor_info.UserName
  1455. order.DrordDrProfttl = ""
  1456. order.CurrDrordFlag = "1"
  1457. orders = append(orders, &order)
  1458. }
  1459. if subItem.Type == 3 {
  1460. var order models.FsiOrderDtos
  1461. order.RxID = strconv.FormatInt(item.ID, 10)
  1462. order.Rxno = strconv.FormatInt(item.ID, 10)
  1463. order.LongDrordFlag = "0"
  1464. order.HilistType = "1"
  1465. order.ChrgType = "1"
  1466. order.DrordBhvr = "-"
  1467. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1468. order.HosplistName = subItem.GoodInfo.GoodName
  1469. order.HilistLv = "1"
  1470. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1471. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1472. order.HosplistName = subItem.GoodInfo.GoodName
  1473. order.Cnt = subItem.Count
  1474. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1475. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1476. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1477. order.OwnpayAmt = ""
  1478. order.SelfpayAmt = ""
  1479. order.Spec = ""
  1480. order.SpecUnt = ""
  1481. order.DrordBegnDate = s_tm
  1482. order.DrordStopDate = ""
  1483. order.DrordDrCodg = "1"
  1484. order.DrordDeptName = department.Name
  1485. order.DrordDrCodg = "1"
  1486. order.DrordDrName = doctor_info.UserName
  1487. order.DrordDrProfttl = ""
  1488. order.CurrDrordFlag = "1"
  1489. orders = append(orders, &order)
  1490. }
  1491. }
  1492. }
  1493. //处方医嘱信息
  1494. }
  1495. fed.MatnStas = "0"
  1496. fed.MedfeeSumamt = "0"
  1497. fed.OwnpayAmt = "0"
  1498. fed.SelfpayAmt = "0"
  1499. fed.AcctPayamt = "0"
  1500. fed.MaAmt = "0"
  1501. fed.HifpPayamt = "0"
  1502. fed.SetlTotlnum = "1"
  1503. fed.Insutype = his.Insutype
  1504. fed.ReimFlag = "0"
  1505. fed.OutSetlFlag = "0"
  1506. var fopd []*models.FsiOperationDtosData
  1507. data := make(map[string]interface{})
  1508. data["fed"] = fed
  1509. data["fdd"] = fdds
  1510. data["fod"] = orders
  1511. data["pd"] = pd
  1512. data["pp"] = pp
  1513. data["fopd"] = fopd
  1514. data["trig_scen"] = trig_scen
  1515. fmt.Println(data)
  1516. fmt.Println(fed)
  1517. fmt.Println(fdds)
  1518. fmt.Println(orders)
  1519. fmt.Println(pd)
  1520. fmt.Println(pp)
  1521. fmt.Println(fopd)
  1522. client := &http.Client{}
  1523. bytesData, _ := json.Marshal(data)
  1524. var req *http.Request
  1525. if miConfig.MdtrtareaAdmvs == "320921" {
  1526. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1527. } else {
  1528. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1529. }
  1530. resp, _ := client.Do(req)
  1531. defer resp.Body.Close()
  1532. body, ioErr := ioutil.ReadAll(resp.Body)
  1533. if ioErr != nil {
  1534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. return res
  1537. }
  1538. var respJSON map[string]interface{}
  1539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1542. return res
  1543. }
  1544. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1545. fmt.Println(respJSON)
  1546. result, _ := json.Marshal(respJSON)
  1547. fmt.Println(result)
  1548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1549. utils.ErrorLog("解析失败:%v", err)
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1551. return res
  1552. }
  1553. return res
  1554. }
  1555. 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) {
  1556. adminUser := c.GetAdminUserInfo()
  1557. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1558. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1560. //record_time := c.GetString("record_time")
  1561. //trig_scen := c.GetString("trig_scen")
  1562. timeLayout := "2006-01-02"
  1563. loc, _ := time.LoadLocation("Local")
  1564. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1565. if err != nil {
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1567. return res
  1568. }
  1569. recordDateTime := theTime.Unix()
  1570. var patientPrescription models.HisPrescriptionInfo
  1571. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1572. if patientPrescription.ID == 0 {
  1573. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1574. }
  1575. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1576. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1577. //
  1578. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1579. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1580. var pp models.PublicParams
  1581. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1582. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1583. pp.FixmedinsName = miConfig.OrgName
  1584. pp.FixmedinsCode = miConfig.Code
  1585. pp.RequestUrl = miConfig.Url
  1586. pp.Cainfo = miConfig.Cainfo
  1587. pp.SecretKey = miConfig.SecretKey
  1588. pp.AccessKey = miConfig.AccessKey
  1589. pp.OpterName = roles.UserName
  1590. var config []*models.HisXtDiagnoseConfig
  1591. for _, item := range diagnosis_ids {
  1592. id, _ := strconv.ParseInt(item, 10, 64)
  1593. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1594. config = append(config, &diagnosisConfig)
  1595. }
  1596. var pd models.PatientDtos
  1597. pd.PatnID = his.PsnNo
  1598. pd.PatnName = his.Name
  1599. pd.Gend = his.Gend
  1600. pd.Brdy = his.Brdy
  1601. pd.Poolarea = his.InsuplcAdmdvs
  1602. pd.CurrMdtrtID = his.Number
  1603. var fed models.FsiEncounterDtos
  1604. fed.MdtrtID = his.Number
  1605. fed.MedinsID = miConfig.Code
  1606. fed.MedinsName = miConfig.OrgName
  1607. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1608. fed.MedMdtrtType = "1"
  1609. fed.MedinsType = "1"
  1610. fed.MedinsLv = "11"
  1611. tm := time.Unix(his.RecordDate, 0)
  1612. s_tm := tm.Format("2006-01-02 15:04:05")
  1613. fed.AdmDate = s_tm
  1614. fed.DscgDate = s_tm
  1615. fed.DscgMainDiseCodg = config[0].CountryCode
  1616. fed.DscgMainDiseName = config[0].CountryContentName
  1617. //诊断信息
  1618. var fdds []*models.FsiDiagnoseDtos
  1619. for index, item := range config {
  1620. if index == 0 {
  1621. var fdd models.FsiDiagnoseDtos
  1622. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1623. fdd.InoutDiseType = "1"
  1624. fdd.MaindiseFlag = "1"
  1625. fdd.DiseDate = s_tm
  1626. fdd.DiasSrtNo = "1"
  1627. fdd.DiseName = item.CountryContentName
  1628. fdd.DiseCodg = item.CountryCode
  1629. fdds = append(fdds, &fdd)
  1630. } else {
  1631. var fdd models.FsiDiagnoseDtos
  1632. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1633. fdd.InoutDiseType = "1"
  1634. fdd.MaindiseFlag = "1"
  1635. fdd.DiseDate = s_tm
  1636. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1637. fdd.DiseName = item.CountryContentName
  1638. fdd.DiseCodg = item.CountryCode
  1639. fdds = append(fdds, &fdd)
  1640. }
  1641. }
  1642. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1643. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1644. fed.AdmDeptName = department.Name
  1645. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1646. fed.DscgDeptName = department.Name
  1647. fed.MedMdtrtType = "1"
  1648. fed.MedType = "11"
  1649. //if his.Insutype == "390" {
  1650. // fed.MedType = "1402"
  1651. //} else {
  1652. // fed.MedType = "9933"
  1653. //}
  1654. var orders []*models.FsiOrderDtos
  1655. if trig_scen == "2" {
  1656. //处方医嘱信息
  1657. for _, item := range prescriptions {
  1658. for _, subItem := range item.HisDoctorAdviceInfo {
  1659. var order models.FsiOrderDtos
  1660. order.RxID = strconv.FormatInt(item.ID, 10)
  1661. order.Rxno = strconv.FormatInt(item.ID, 10)
  1662. order.LongDrordFlag = "0"
  1663. order.HilistType = "1"
  1664. order.ChrgType = "1"
  1665. order.DrordBhvr = "-"
  1666. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1667. order.HosplistName = subItem.BaseDrugLib.DrugName
  1668. order.HilistLv = "1"
  1669. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1670. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1671. order.HosplistName = subItem.BaseDrugLib.DrugName
  1672. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1673. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1674. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1675. order.OwnpayAmt = ""
  1676. order.SelfpayAmt = ""
  1677. order.Spec = ""
  1678. order.SpecUnt = ""
  1679. order.DrordBegnDate = s_tm
  1680. order.DrordStopDate = ""
  1681. order.DrordDrCodg = "1"
  1682. order.DrordDeptName = department.Name
  1683. order.DrordDrCodg = "1"
  1684. order.DrordDrName = doctor_info.UserName
  1685. order.DrordDrProfttl = ""
  1686. order.CurrDrordFlag = "1"
  1687. orders = append(orders, &order)
  1688. }
  1689. for _, subItem := range item.HisPrescriptionProject {
  1690. if subItem.Type == 2 {
  1691. var order models.FsiOrderDtos
  1692. order.RxID = strconv.FormatInt(item.ID, 10)
  1693. order.Rxno = strconv.FormatInt(item.ID, 10)
  1694. order.LongDrordFlag = "0"
  1695. order.HilistType = "1"
  1696. order.ChrgType = "1"
  1697. order.DrordBhvr = "-"
  1698. order.HilistCode = subItem.HisProject.MedicalCode
  1699. order.HosplistName = subItem.HisProject.ProjectName
  1700. order.HilistLv = "1"
  1701. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1702. order.HosplistCode = subItem.HisProject.MedicalCode
  1703. order.HosplistName = subItem.HisProject.ProjectName
  1704. order.Cnt = subItem.Count
  1705. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1706. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1707. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1708. order.OwnpayAmt = ""
  1709. order.SelfpayAmt = ""
  1710. order.Spec = ""
  1711. order.SpecUnt = ""
  1712. order.DrordBegnDate = s_tm
  1713. order.DrordStopDate = ""
  1714. order.DrordDrCodg = "1"
  1715. order.DrordDeptName = department.Name
  1716. order.DrordDrCodg = "1"
  1717. order.DrordDrName = doctor_info.UserName
  1718. order.DrordDrProfttl = ""
  1719. order.CurrDrordFlag = "1"
  1720. orders = append(orders, &order)
  1721. }
  1722. if subItem.Type == 3 {
  1723. var order models.FsiOrderDtos
  1724. order.RxID = strconv.FormatInt(item.ID, 10)
  1725. order.Rxno = strconv.FormatInt(item.ID, 10)
  1726. order.LongDrordFlag = "0"
  1727. order.HilistType = "1"
  1728. order.ChrgType = "1"
  1729. order.DrordBhvr = "-"
  1730. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1731. order.HosplistName = subItem.GoodInfo.GoodName
  1732. order.HilistLv = "1"
  1733. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1734. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1735. order.HosplistName = subItem.GoodInfo.GoodName
  1736. order.Cnt = subItem.Count
  1737. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1738. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1739. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1740. order.OwnpayAmt = ""
  1741. order.SelfpayAmt = ""
  1742. order.Spec = ""
  1743. order.SpecUnt = ""
  1744. order.DrordBegnDate = s_tm
  1745. order.DrordStopDate = ""
  1746. order.DrordDrCodg = "1"
  1747. order.DrordDeptName = department.Name
  1748. order.DrordDrCodg = "1"
  1749. order.DrordDrName = doctor_info.UserName
  1750. order.DrordDrProfttl = ""
  1751. order.CurrDrordFlag = "1"
  1752. orders = append(orders, &order)
  1753. }
  1754. }
  1755. }
  1756. //处方医嘱信息
  1757. }
  1758. fed.MatnStas = "0"
  1759. fed.MedfeeSumamt = "0"
  1760. fed.OwnpayAmt = "0"
  1761. fed.SelfpayAmt = "0"
  1762. fed.AcctPayamt = "0"
  1763. fed.MaAmt = "0"
  1764. fed.HifpPayamt = "0"
  1765. fed.SetlTotlnum = "1"
  1766. fed.Insutype = his.Insutype
  1767. fed.ReimFlag = "0"
  1768. fed.OutSetlFlag = "0"
  1769. var fopd []*models.FsiOperationDtosData
  1770. data := make(map[string]interface{})
  1771. data["fed"] = fed
  1772. data["fdd"] = fdds
  1773. data["fod"] = orders
  1774. data["pd"] = pd
  1775. data["pp"] = pp
  1776. data["fopd"] = fopd
  1777. data["trig_scen"] = trig_scen
  1778. fmt.Println(data)
  1779. fmt.Println(fed)
  1780. fmt.Println(fdds)
  1781. fmt.Println(orders)
  1782. fmt.Println(pd)
  1783. fmt.Println(pp)
  1784. fmt.Println(fopd)
  1785. client := &http.Client{}
  1786. bytesData, _ := json.Marshal(data)
  1787. var req *http.Request
  1788. if miConfig.MdtrtareaAdmvs == "320921" {
  1789. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1790. } else {
  1791. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1792. }
  1793. resp, _ := client.Do(req)
  1794. defer resp.Body.Close()
  1795. body, ioErr := ioutil.ReadAll(resp.Body)
  1796. if ioErr != nil {
  1797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1799. return res
  1800. }
  1801. var respJSON map[string]interface{}
  1802. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. return res
  1806. }
  1807. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1808. result, _ := json.Marshal(respJSON)
  1809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1810. utils.ErrorLog("解析失败:%v", err)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. return res
  1813. }
  1814. return res
  1815. }
  1816. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1817. ////patient_id, _ := c.GetInt64("patient_id")
  1818. //order_id, _ := c.GetInt64("order_id")
  1819. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1820. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1821. //trig_scen := c.GetString("trig_scen")
  1822. adminUser := c.GetAdminUserInfo()
  1823. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1824. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1825. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1826. record_time := c.GetString("record_time")
  1827. order, _ := service.GetHisOrderByID(order_id)
  1828. timeLayout := "2006-01-02"
  1829. loc, _ := time.LoadLocation("Local")
  1830. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1831. if err != nil {
  1832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1833. return
  1834. }
  1835. recordDateTime := theTime.Unix()
  1836. var patientPrescription models.HisPrescriptionInfo
  1837. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1838. if patientPrescription.ID == 0 {
  1839. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1840. }
  1841. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1842. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1843. //
  1844. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1845. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1846. var pp models.PublicParams
  1847. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1848. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1849. pp.FixmedinsName = miConfig.OrgName
  1850. pp.FixmedinsCode = miConfig.Code
  1851. pp.RequestUrl = miConfig.Url
  1852. pp.Cainfo = miConfig.Cainfo
  1853. pp.SecretKey = miConfig.SecretKey
  1854. pp.AccessKey = miConfig.AccessKey
  1855. pp.OpterName = roles.UserName
  1856. var config []*models.HisXtDiagnoseConfig
  1857. for _, item := range diagnosis_ids {
  1858. id, _ := strconv.ParseInt(item, 10, 64)
  1859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1860. config = append(config, &diagnosisConfig)
  1861. }
  1862. var pd models.PatientDtos
  1863. pd.PatnID = his.PsnNo
  1864. pd.PatnName = his.Name
  1865. pd.Gend = his.Gend
  1866. pd.Brdy = his.Brdy
  1867. pd.Poolarea = his.InsuplcAdmdvs
  1868. pd.CurrMdtrtID = his.Number
  1869. var fed models.FsiEncounterDtos
  1870. fed.MdtrtID = his.Number
  1871. fed.MedinsID = miConfig.Code
  1872. fed.MedinsName = miConfig.OrgName
  1873. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1874. fed.MedMdtrtType = "1"
  1875. fed.MedinsType = "1"
  1876. fed.MedinsLv = "11"
  1877. tm := time.Unix(his.RecordDate, 0)
  1878. s_tm := tm.Format("2006-01-02 15:04:05")
  1879. fed.AdmDate = s_tm
  1880. fed.DscgDate = s_tm
  1881. fed.DscgMainDiseCodg = config[0].CountryCode
  1882. fed.DscgMainDiseName = config[0].CountryContentName
  1883. //诊断信息
  1884. var fdds []*models.FsiDiagnoseDtos
  1885. for index, item := range config {
  1886. if index == 0 {
  1887. var fdd models.FsiDiagnoseDtos
  1888. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1889. fdd.InoutDiseType = "1"
  1890. fdd.MaindiseFlag = "1"
  1891. fdd.DiseDate = s_tm
  1892. fdd.DiasSrtNo = "1"
  1893. fdd.DiseName = item.CountryContentName
  1894. fdd.DiseCodg = item.CountryCode
  1895. fdds = append(fdds, &fdd)
  1896. } else {
  1897. var fdd models.FsiDiagnoseDtos
  1898. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1899. fdd.InoutDiseType = "1"
  1900. fdd.MaindiseFlag = "1"
  1901. fdd.DiseDate = s_tm
  1902. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1903. fdd.DiseName = item.CountryContentName
  1904. fdd.DiseCodg = item.CountryCode
  1905. fdds = append(fdds, &fdd)
  1906. }
  1907. }
  1908. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1909. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1910. fed.AdmDeptName = department.Name
  1911. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1912. fed.DscgDeptName = department.Name
  1913. fed.MedType = order.MedType
  1914. //处方医嘱信息
  1915. var orders []*models.FsiOrderDtos
  1916. //for _, item := range prescriptions {
  1917. // for _, subItem := range item.HisDoctorAdviceInfo {
  1918. // var order models.FsiOrderDtos
  1919. // order.RxID = strconv.FormatInt(item.ID, 10)
  1920. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1921. // order.LongDrordFlag = "0"
  1922. // order.HilistType = "1"
  1923. // order.ChrgType = "1"
  1924. // order.DrordBhvr = "-"
  1925. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1926. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1927. // order.HilistLv = "1"
  1928. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1929. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1930. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1931. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1932. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1933. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1934. // order.OwnpayAmt = ""
  1935. // order.SelfpayAmt = ""
  1936. // order.Spec = ""
  1937. // order.SpecUnt = ""
  1938. // order.DrordBegnDate = s_tm
  1939. // order.DrordStopDate = ""
  1940. // order.DrordDrCodg = "1"
  1941. // order.DrordDeptName = department.Name
  1942. // order.DrordDrCodg = "1"
  1943. // order.DrordDrName = doctor_info.UserName
  1944. // order.DrordDrProfttl = ""
  1945. // order.CurrDrordFlag = "1"
  1946. // orders = append(orders, &order)
  1947. // }
  1948. // for _, subItem := range item.HisPrescriptionProject {
  1949. // if subItem.Type == 2 {
  1950. // var order models.FsiOrderDtos
  1951. // order.RxID = strconv.FormatInt(item.ID, 10)
  1952. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1953. // order.LongDrordFlag = "0"
  1954. // order.HilistType = "1"
  1955. // order.ChrgType = "1"
  1956. // order.DrordBhvr = "-"
  1957. // order.HilistCode = subItem.HisProject.MedicalCode
  1958. // order.HosplistName = subItem.HisProject.ProjectName
  1959. // order.HilistLv = "1"
  1960. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1961. // order.HosplistCode = subItem.HisProject.MedicalCode
  1962. // order.HosplistName = subItem.HisProject.ProjectName
  1963. // order.Cnt = subItem.Count
  1964. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1965. //
  1966. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1967. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1968. // order.OwnpayAmt = ""
  1969. // order.SelfpayAmt = ""
  1970. // order.Spec = ""
  1971. // order.SpecUnt = ""
  1972. // order.DrordBegnDate = s_tm
  1973. // order.DrordStopDate = ""
  1974. // order.DrordDrCodg = "1"
  1975. // order.DrordDeptName = department.Name
  1976. // order.DrordDrCodg = "1"
  1977. // order.DrordDrName = doctor_info.UserName
  1978. // order.DrordDrProfttl = ""
  1979. // order.CurrDrordFlag = "1"
  1980. // orders = append(orders, &order)
  1981. //
  1982. // }
  1983. // if subItem.Type == 3 {
  1984. //
  1985. // var order models.FsiOrderDtos
  1986. // order.RxID = strconv.FormatInt(item.ID, 10)
  1987. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1988. // order.LongDrordFlag = "0"
  1989. // order.HilistType = "1"
  1990. // order.ChrgType = "1"
  1991. // order.DrordBhvr = "-"
  1992. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1993. // order.HosplistName = subItem.GoodInfo.GoodName
  1994. // order.HilistLv = "1"
  1995. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1996. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1997. // order.HosplistName = subItem.GoodInfo.GoodName
  1998. // order.Cnt = subItem.Count
  1999. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2000. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2001. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2002. // order.OwnpayAmt = ""
  2003. // order.SelfpayAmt = ""
  2004. // order.Spec = ""
  2005. // order.SpecUnt = ""
  2006. // order.DrordBegnDate = s_tm
  2007. // order.DrordStopDate = ""
  2008. // order.DrordDrCodg = "1"
  2009. // order.DrordDeptName = department.Name
  2010. // order.DrordDrCodg = "1"
  2011. // order.DrordDrName = doctor_info.UserName
  2012. // order.DrordDrProfttl = ""
  2013. // order.CurrDrordFlag = "1"
  2014. // orders = append(orders, &order)
  2015. //
  2016. // }
  2017. // }
  2018. //}
  2019. for _, item := range prescriptions {
  2020. for _, subItem := range item.HisDoctorAdviceInfo {
  2021. var order models.FsiOrderDtos
  2022. order.RxID = strconv.FormatInt(item.ID, 10)
  2023. order.Rxno = strconv.FormatInt(item.ID, 10)
  2024. order.LongDrordFlag = "0"
  2025. order.HilistType = "1"
  2026. order.ChrgType = "1"
  2027. order.DrordBhvr = "-"
  2028. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2029. order.HosplistName = subItem.BaseDrugLib.DrugName
  2030. order.HilistLv = "1"
  2031. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2032. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2033. order.HosplistName = subItem.BaseDrugLib.DrugName
  2034. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2035. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2036. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2037. order.OwnpayAmt = ""
  2038. order.SelfpayAmt = ""
  2039. order.Spec = ""
  2040. order.SpecUnt = ""
  2041. order.DrordBegnDate = s_tm
  2042. order.DrordStopDate = ""
  2043. order.DrordDrCodg = "1"
  2044. order.DrordDeptName = department.Name
  2045. order.DrordDrCodg = "1"
  2046. order.DrordDrName = doctor_info.UserName
  2047. order.DrordDrProfttl = ""
  2048. order.CurrDrordFlag = "1"
  2049. orders = append(orders, &order)
  2050. }
  2051. for _, subItem := range item.HisPrescriptionProject {
  2052. if subItem.Type == 2 {
  2053. var order models.FsiOrderDtos
  2054. order.RxID = strconv.FormatInt(item.ID, 10)
  2055. order.Rxno = strconv.FormatInt(item.ID, 10)
  2056. order.LongDrordFlag = "0"
  2057. order.HilistType = "1"
  2058. order.ChrgType = "1"
  2059. order.DrordBhvr = "-"
  2060. order.HilistCode = subItem.HisProject.MedicalCode
  2061. order.HosplistName = subItem.HisProject.ProjectName
  2062. order.HilistLv = "1"
  2063. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2064. order.HosplistCode = subItem.HisProject.MedicalCode
  2065. order.HosplistName = subItem.HisProject.ProjectName
  2066. order.Cnt = subItem.Count
  2067. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2068. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2069. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2070. order.OwnpayAmt = ""
  2071. order.SelfpayAmt = ""
  2072. order.Spec = ""
  2073. order.SpecUnt = ""
  2074. order.DrordBegnDate = s_tm
  2075. order.DrordStopDate = ""
  2076. order.DrordDrCodg = "1"
  2077. order.DrordDeptName = department.Name
  2078. order.DrordDrCodg = "1"
  2079. order.DrordDrName = doctor_info.UserName
  2080. order.DrordDrProfttl = ""
  2081. order.CurrDrordFlag = "1"
  2082. orders = append(orders, &order)
  2083. }
  2084. if subItem.Type == 3 {
  2085. var order models.FsiOrderDtos
  2086. order.RxID = strconv.FormatInt(item.ID, 10)
  2087. order.Rxno = strconv.FormatInt(item.ID, 10)
  2088. order.LongDrordFlag = "0"
  2089. order.HilistType = "1"
  2090. order.ChrgType = "1"
  2091. order.DrordBhvr = "-"
  2092. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2093. order.HosplistName = subItem.GoodInfo.GoodName
  2094. order.HilistLv = "1"
  2095. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2096. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2097. order.HosplistName = subItem.GoodInfo.GoodName
  2098. order.Cnt = subItem.Count
  2099. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2100. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2101. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2102. order.OwnpayAmt = ""
  2103. order.SelfpayAmt = ""
  2104. order.Spec = ""
  2105. order.SpecUnt = ""
  2106. order.DrordBegnDate = s_tm
  2107. order.DrordStopDate = ""
  2108. order.DrordDrCodg = "1"
  2109. order.DrordDeptName = department.Name
  2110. order.DrordDrCodg = "1"
  2111. order.DrordDrName = doctor_info.UserName
  2112. order.DrordDrProfttl = ""
  2113. order.CurrDrordFlag = "1"
  2114. orders = append(orders, &order)
  2115. }
  2116. }
  2117. }
  2118. //处方医嘱信息
  2119. fed.MatnStas = "0"
  2120. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2121. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2122. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2123. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2124. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2125. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2126. fed.SetlTotlnum = "1"
  2127. fed.Insutype = his.Insutype
  2128. fed.ReimFlag = "0"
  2129. fed.OutSetlFlag = "0"
  2130. var fopd []*models.FsiOperationDtosData
  2131. data := make(map[string]interface{})
  2132. data["fed"] = fed
  2133. data["fdd"] = fdds
  2134. data["fod"] = orders
  2135. data["pd"] = pd
  2136. data["pp"] = pp
  2137. data["fopd"] = fopd
  2138. data["trig_scen"] = trig_scen
  2139. client := &http.Client{}
  2140. bytesData, _ := json.Marshal(data)
  2141. var req *http.Request
  2142. if miConfig.MdtrtareaAdmvs == "320921" {
  2143. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2144. } else {
  2145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2146. }
  2147. resp, _ := client.Do(req)
  2148. defer resp.Body.Close()
  2149. body, ioErr := ioutil.ReadAll(resp.Body)
  2150. if ioErr != nil {
  2151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2153. return res
  2154. }
  2155. var respJSON map[string]interface{}
  2156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. return res
  2160. }
  2161. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2162. result, _ := json.Marshal(respJSON)
  2163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2164. utils.ErrorLog("解析失败:%v", err)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2166. return res
  2167. }
  2168. return res
  2169. //手术操作集合
  2170. //手术操作集合
  2171. }
  2172. func (c *HisApiController) Check() {
  2173. psn_no := c.GetString("psn_no")
  2174. in := c.GetString("in")
  2175. mt := c.GetString("mt")
  2176. baseParams := models.BaseParams{
  2177. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2178. FixmedinsCode: "H15049901371",
  2179. InsuplcAdmdvs: "150499",
  2180. MdtrtareaAdmvs: "150499",
  2181. OrgName: "赤峰费森血液透析中心",
  2182. Doctor: "1111",
  2183. }
  2184. service.Gdyb2001(baseParams, psn_no, in, mt)
  2185. }
  2186. func (c *HisApiController) GetPsnNcdsInfo() {
  2187. admin_user_id, _ := c.GetInt64("admin_user_id")
  2188. patient_id, _ := c.GetInt64("patient_id")
  2189. id, _ := c.GetInt64("id")
  2190. adminUser := c.GetAdminUserInfo()
  2191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2192. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2193. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2194. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2195. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2196. //
  2197. //if psn_record.ID == 0 {
  2198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2199. // return
  2200. //}
  2201. var res Result5301
  2202. var res10265 Result5301For10265
  2203. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2204. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2205. var api string
  2206. if miConfig.MdtrtareaAdmvs == "320921" {
  2207. 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 +
  2208. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2209. } else {
  2210. 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 +
  2211. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2212. }
  2213. resp, requestErr := http.Get(api)
  2214. if requestErr != nil {
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2216. return
  2217. }
  2218. body, ioErr := ioutil.ReadAll(resp.Body)
  2219. if ioErr != nil {
  2220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2222. return
  2223. }
  2224. var respJSON map[string]interface{}
  2225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2228. return
  2229. }
  2230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2231. result, _ := json.Marshal(respJSON)
  2232. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2233. utils.ErrorLog("解析失败:%v", err)
  2234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. return
  2236. }
  2237. res.ErrMsg = res10265.ErrMsg
  2238. res.Output = res10265.Output
  2239. res.InfRefmsgid = res10265.InfRefmsgid
  2240. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2241. res.Infcode = infocode
  2242. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2243. p, _ := service.GetHisPatientById(patient_id)
  2244. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2245. var dat map[string]interface{}
  2246. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2247. fmt.Println(dat)
  2248. } else {
  2249. fmt.Println(err)
  2250. }
  2251. userJSONBytes, _ := json.Marshal(dat)
  2252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2253. utils.ErrorLog("解析失败:%v", err)
  2254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2255. return
  2256. }
  2257. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2258. p, _ := service.GetHisPatientById(patient_id)
  2259. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2260. var dat map[string]interface{}
  2261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2262. fmt.Println(dat)
  2263. } else {
  2264. fmt.Println(err)
  2265. }
  2266. userJSONBytes, _ := json.Marshal(dat)
  2267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2268. utils.ErrorLog("解析失败:%v", err)
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2270. return
  2271. }
  2272. } else {
  2273. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2274. var dat map[string]interface{}
  2275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2276. fmt.Println(dat)
  2277. } else {
  2278. fmt.Println(err)
  2279. }
  2280. userJSONBytes, _ := json.Marshal(dat)
  2281. if miConfig.Code == "H15049901371" {
  2282. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2283. utils.ErrorLog("解析失败:%v", err)
  2284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2285. return
  2286. }
  2287. res.InfRefmsgid = res10265.InfRefmsgid
  2288. res.Output = res10265.Output
  2289. res.ErrMsg = res10265.ErrMsg
  2290. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2291. res.Infcode = infocode
  2292. } else {
  2293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2294. utils.ErrorLog("解析失败:%v", err)
  2295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2296. return
  2297. }
  2298. }
  2299. }
  2300. if res.Infcode == 0 {
  2301. c.ServeSuccessJSON(map[string]interface{}{
  2302. "result": res.Output.Result,
  2303. })
  2304. }
  2305. }
  2306. func (c *HisApiController) CheckInsutype() {
  2307. his_patient_id, _ := c.GetInt64("his_patient_id")
  2308. admin_user_id, _ := c.GetInt64("admin_user_id")
  2309. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2310. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2311. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2312. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2313. var dat map[string]interface{}
  2314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2315. fmt.Println(dat)
  2316. } else {
  2317. fmt.Println(err)
  2318. }
  2319. userJSONBytes, _ := json.Marshal(dat)
  2320. var res Result90100
  2321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2322. utils.ErrorLog("解析失败:%v", err)
  2323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2324. return
  2325. }
  2326. if res.Infcode != 0 {
  2327. c.ServeSuccessJSON(map[string]interface{}{
  2328. "failed_code": -10,
  2329. "msg": res.ErrMsg,
  2330. })
  2331. return
  2332. } else {
  2333. fmt.Println(res)
  2334. }
  2335. }
  2336. func (c *HisApiController) CheckCardPWD() {
  2337. card_pwd := c.GetString("card_pwd")
  2338. his_patient_id, _ := c.GetInt64("his_patient_id")
  2339. admin_user_id, _ := c.GetInt64("admin_user_id")
  2340. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2342. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2343. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2344. bas := strings.Split(psn.CardInfo, "|")
  2345. basNumber := bas[2]
  2346. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2347. var dat map[string]interface{}
  2348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2349. fmt.Println(dat)
  2350. } else {
  2351. fmt.Println(err)
  2352. }
  2353. userJSONBytes, _ := json.Marshal(dat)
  2354. var res Result90991
  2355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2356. utils.ErrorLog("解析失败:%v", err)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. if res.Infcode != 0 {
  2361. c.ServeSuccessJSON(map[string]interface{}{
  2362. "failed_code": -10,
  2363. "msg": res.ErrMsg,
  2364. })
  2365. return
  2366. } else {
  2367. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2368. var msg string
  2369. switch res.Output.Result.CardStat {
  2370. case "00":
  2371. msg = "未激活"
  2372. break
  2373. case "10":
  2374. msg = "激活"
  2375. break
  2376. case "20":
  2377. msg = "窗口挂失"
  2378. break
  2379. case "21":
  2380. msg = "电话挂失"
  2381. break
  2382. case "22":
  2383. msg = "单位网上申报挂失"
  2384. break
  2385. case "23":
  2386. msg = "保健办挂失"
  2387. break
  2388. case "24":
  2389. msg = "个人网上挂失"
  2390. break
  2391. case "25":
  2392. msg = "网上服务大厅挂失"
  2393. break
  2394. case "30":
  2395. msg = "注销"
  2396. break
  2397. case "40":
  2398. msg = "回收"
  2399. break
  2400. case "99":
  2401. msg = "制卡中(无效卡)"
  2402. break
  2403. }
  2404. c.ServeSuccessJSON(map[string]interface{}{
  2405. "failed_code": -10,
  2406. "msg": msg,
  2407. })
  2408. return
  2409. } else {
  2410. c.ServeSuccessJSON(map[string]interface{}{
  2411. "msg": "校验成功",
  2412. })
  2413. return
  2414. }
  2415. }
  2416. }
  2417. func (c *HisApiController) CheckCardPWDTwo() {
  2418. //card_pwd := c.GetString("card_pwd")
  2419. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2420. admin_user_id, _ := c.GetInt64("admin_user_id")
  2421. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2422. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2423. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2424. var dat map[string]interface{}
  2425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2426. fmt.Println(dat)
  2427. } else {
  2428. fmt.Println(err)
  2429. }
  2430. userJSONBytes, _ := json.Marshal(dat)
  2431. var res Result90991
  2432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2433. utils.ErrorLog("解析失败:%v", err)
  2434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2435. return
  2436. }
  2437. if res.Infcode != 0 {
  2438. c.ServeSuccessJSON(map[string]interface{}{
  2439. "failed_code": -10,
  2440. "msg": res.ErrMsg,
  2441. })
  2442. return
  2443. } else {
  2444. if res.Output.Result.SscnoCheckStat == "0" {
  2445. var msg string
  2446. switch res.Output.Result.CardStat {
  2447. case "00":
  2448. msg = "未激活"
  2449. break
  2450. case "10":
  2451. msg = "激活"
  2452. break
  2453. case "20":
  2454. msg = "窗口挂失"
  2455. break
  2456. case "21":
  2457. msg = "电话挂失"
  2458. break
  2459. case "22":
  2460. msg = "单位网上申报挂失"
  2461. break
  2462. case "23":
  2463. msg = "保健办挂失"
  2464. break
  2465. case "24":
  2466. msg = "个人网上挂失"
  2467. break
  2468. case "25":
  2469. msg = "网上服务大厅挂失"
  2470. break
  2471. case "30":
  2472. msg = "注销"
  2473. break
  2474. case "40":
  2475. msg = "回收"
  2476. break
  2477. case "99":
  2478. msg = "制卡中(无效卡)"
  2479. break
  2480. }
  2481. c.ServeSuccessJSON(map[string]interface{}{
  2482. "failed_code": -10,
  2483. "msg": msg,
  2484. })
  2485. return
  2486. } else {
  2487. c.ServeSuccessJSON(map[string]interface{}{
  2488. "msg": "校验成功",
  2489. })
  2490. return
  2491. }
  2492. }
  2493. }
  2494. type ELeCertData struct {
  2495. Data struct {
  2496. Extra string `json:"extra"`
  2497. IDNo string `json:"idNo"`
  2498. IDType string `json:"idType"`
  2499. EcToken string `json:"ecToken"`
  2500. InsuOrg string `json:"insuOrg"`
  2501. UserName string `json:"userName"`
  2502. EcIndexNo string `json:"ecIndexNo"`
  2503. Gender string `json:"gender"`
  2504. Birthday string `json:"birthday"`
  2505. Nationality string `json:"nationality"`
  2506. Email string `json:"email"`
  2507. } `json:"OutData"`
  2508. }
  2509. func (c *HisApiController) ReadCard() {
  2510. id_card_type, _ := c.GetInt64("id_card_type")
  2511. admin_user_id, _ := c.GetInt64("admin_user_id")
  2512. certificates, _ := c.GetInt64("certificates")
  2513. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2515. switch id_card_type {
  2516. case 1:
  2517. if miConfig.MdtrtareaAdmvs == "421300" {
  2518. var res ResultTwo
  2519. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2520. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2521. "&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)
  2522. resp, requestErr := http.Get(api)
  2523. if requestErr != nil {
  2524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. return
  2526. }
  2527. body, ioErr := ioutil.ReadAll(resp.Body)
  2528. if ioErr != nil {
  2529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2531. return
  2532. }
  2533. var respJSON map[string]interface{}
  2534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2537. return
  2538. }
  2539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2540. result, _ := json.Marshal(respJSON)
  2541. fmt.Println("log")
  2542. fmt.Println(string(result))
  2543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2544. utils.ErrorLog("解析失败:%v", err)
  2545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2546. return
  2547. }
  2548. if res.Infcode == 0 {
  2549. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2550. if err == gorm.ErrRecordNotFound {
  2551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2552. return
  2553. } else if err != nil {
  2554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2555. return
  2556. } else {
  2557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2559. infoStr := string(Iinfos)
  2560. idetinfoStr := string(Idetinfos)
  2561. psn := &models.HisPsn{
  2562. PsnNo: res.Output.Baseinfo.PsnNo,
  2563. Age: res.Output.Baseinfo.Age,
  2564. PatientId: patient.ID,
  2565. Certno: res.Output.Baseinfo.Certno,
  2566. Brdy: res.Output.Baseinfo.Brdy,
  2567. Gend: res.Output.Baseinfo.Gend,
  2568. Naty: res.Output.Baseinfo.Naty,
  2569. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2570. PsnName: res.Output.Baseinfo.PsnName,
  2571. Idetinfo: idetinfoStr,
  2572. Insuinfo: infoStr,
  2573. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2574. }
  2575. service.CreateHisPsn(psn)
  2576. c.ServeSuccessJSON(map[string]interface{}{
  2577. "patient": patient,
  2578. "number": res.Output.Baseinfo.Certno,
  2579. })
  2580. }
  2581. } else {
  2582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2583. return
  2584. }
  2585. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2586. var api string
  2587. if miConfig.MdtrtareaAdmvs == "320921" {
  2588. 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 +
  2589. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2590. fmt.Println(api)
  2591. } else {
  2592. 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 +
  2593. "&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)
  2594. }
  2595. resp, requestErr := http.Get(api)
  2596. if requestErr != nil {
  2597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2598. return
  2599. }
  2600. body, ioErr := ioutil.ReadAll(resp.Body)
  2601. if ioErr != nil {
  2602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. return
  2605. }
  2606. var respJSON map[string]interface{}
  2607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2610. return
  2611. }
  2612. var status string
  2613. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2614. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2615. //console.log()
  2616. fmt.Println("type===")
  2617. fmt.Println(card_type)
  2618. var token string
  2619. var res ResultTwo //1101结果
  2620. var res10265 ResultTwo10265 //1101结果
  2621. var card_info string //卡信息
  2622. var busi_card_info string
  2623. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2624. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2625. if status == "0" { //读卡成功
  2626. if card_type == "1" {
  2627. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2628. result, _ := json.Marshal(respJSON)
  2629. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2630. utils.ErrorLog("解析失败:%v", err)
  2631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2632. return
  2633. }
  2634. res.ErrMsg = res10265.ErrMsg
  2635. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. res.Output = res10265.Output
  2638. res.InfRefmsgid = res10265.InfRefmsgid
  2639. } else {
  2640. //var card_info string //卡信息
  2641. //var busi_card_info string
  2642. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2643. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2644. //fmt.Println(card_info)
  2645. //fmt.Println(busi_card_info)
  2646. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2647. result, _ := json.Marshal(respJSON)
  2648. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2649. utils.ErrorLog("解析失败:%v", err)
  2650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2651. return
  2652. }
  2653. res.ErrMsg = res10265.ErrMsg
  2654. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2655. res.Infcode = infocode
  2656. res.Output = res10265.Output
  2657. res.InfRefmsgid = res10265.InfRefmsgid
  2658. }
  2659. if res.Infcode == 0 {
  2660. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2661. if err == gorm.ErrRecordNotFound {
  2662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2663. return
  2664. } else if err != nil {
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2666. return
  2667. } else {
  2668. if card_type == "1" {
  2669. bas := strings.Split(card_info, "|")
  2670. basNumber := bas[2]
  2671. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2672. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2673. infoStr := string(Iinfos)
  2674. idetinfoStr := string(Idetinfos)
  2675. psn := &models.HisPsn{
  2676. PsnNo: res.Output.Baseinfo.PsnNo,
  2677. Age: res.Output.Baseinfo.Age,
  2678. PatientId: patient.ID,
  2679. Certno: res.Output.Baseinfo.Certno,
  2680. Brdy: res.Output.Baseinfo.Brdy,
  2681. Gend: res.Output.Baseinfo.Gend,
  2682. Naty: res.Output.Baseinfo.Naty,
  2683. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2684. PsnName: res.Output.Baseinfo.PsnName,
  2685. Idetinfo: idetinfoStr,
  2686. Insuinfo: infoStr,
  2687. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2688. CardInfo: card_info,
  2689. VerifyNumber: busi_card_info,
  2690. }
  2691. service.CreateHisPsn(psn)
  2692. var rf []*ResultFive
  2693. json.Unmarshal([]byte(infoStr), &rf)
  2694. var insutypes []*ResultFive
  2695. var insutype string
  2696. var is390 int = 0
  2697. var is310 int = 0
  2698. for _, item := range rf {
  2699. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2700. insutypes = append(insutypes, item)
  2701. }
  2702. }
  2703. if len(insutypes) == 1 {
  2704. insutype = insutypes[0].Insutype
  2705. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2706. } else {
  2707. for _, i := range insutypes {
  2708. if i.Insutype == "390" {
  2709. is390 = 1
  2710. }
  2711. if i.Insutype == "310" {
  2712. is310 = 1
  2713. }
  2714. }
  2715. }
  2716. if is390 == 1 {
  2717. insutype = "390"
  2718. }
  2719. if is310 == 1 {
  2720. insutype = "310"
  2721. }
  2722. if len(insutypes) == 0 {
  2723. insutype = "310"
  2724. }
  2725. c.ServeSuccessJSON(map[string]interface{}{
  2726. "patient": patient,
  2727. "number": basNumber,
  2728. "insutype": insutype,
  2729. })
  2730. } else {
  2731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2733. infoStr := string(Iinfos)
  2734. idetinfoStr := string(Idetinfos)
  2735. psn := &models.HisPsn{
  2736. PsnNo: res.Output.Baseinfo.PsnNo,
  2737. Age: res.Output.Baseinfo.Age,
  2738. PatientId: patient.ID,
  2739. Certno: res.Output.Baseinfo.Certno,
  2740. Brdy: res.Output.Baseinfo.Brdy,
  2741. Gend: res.Output.Baseinfo.Gend,
  2742. Naty: res.Output.Baseinfo.Naty,
  2743. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2744. PsnName: res.Output.Baseinfo.PsnName,
  2745. Idetinfo: idetinfoStr,
  2746. Insuinfo: infoStr,
  2747. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2748. CardInfo: card_info,
  2749. VerifyNumber: token,
  2750. }
  2751. service.CreateHisPsn(psn)
  2752. c.ServeSuccessJSON(map[string]interface{}{
  2753. "patient": patient,
  2754. "number": token,
  2755. })
  2756. }
  2757. }
  2758. } else {
  2759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2760. return
  2761. }
  2762. } else { //读卡失败
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2764. return
  2765. }
  2766. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2767. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2768. cardnum = DeleteExtraSpaceTwo(cardnum)
  2769. cardCode = DeleteExtraSpaceTwo(cardCode)
  2770. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2771. name = DeleteExtraSpaceTwo(name)
  2772. errmsg = DeleteExtraSpaceTwo(errmsg)
  2773. cardnum = Remove0000(cardnum)
  2774. cardCode = Remove0000(cardCode)
  2775. id_card_no = Remove0000(id_card_no)
  2776. name = Remove0000(name)
  2777. errmsg = Remove0000(errmsg)
  2778. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  2779. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2780. result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2781. fmt.Println(result2)
  2782. fmt.Println(requestLog2)
  2783. fmt.Println(errMsgLog2)
  2784. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2785. saveLog(result, requestLog, "1101", "获取人员信息")
  2786. fmt.Println(errMsgLog)
  2787. if len(errMsgLog) > 0 {
  2788. } else {
  2789. var dat map[string]interface{}
  2790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2791. fmt.Println(dat)
  2792. } else {
  2793. fmt.Println(err)
  2794. }
  2795. userJSONBytes, _ := json.Marshal(dat)
  2796. var res ResultTwo
  2797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2798. utils.ErrorLog("解析失败:%v", err)
  2799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2800. return
  2801. }
  2802. res.ErrMsg = errMsgLog
  2803. if res.Infcode == 0 {
  2804. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2805. if err == gorm.ErrRecordNotFound {
  2806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2807. return
  2808. } else if err != nil {
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2810. return
  2811. } else {
  2812. fmt.Println(res)
  2813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2815. infoStr := string(Iinfos)
  2816. idetinfoStr := string(Idetinfos)
  2817. psn := &models.HisPsn{
  2818. PsnNo: res.Output.Baseinfo.PsnNo,
  2819. Age: res.Output.Baseinfo.Age,
  2820. PatientId: patient.ID,
  2821. Certno: res.Output.Baseinfo.Certno,
  2822. Brdy: res.Output.Baseinfo.Brdy,
  2823. Gend: res.Output.Baseinfo.Gend,
  2824. Naty: res.Output.Baseinfo.Naty,
  2825. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2826. PsnName: res.Output.Baseinfo.PsnName,
  2827. Idetinfo: idetinfoStr,
  2828. Insuinfo: infoStr,
  2829. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2830. CardInfo: basStr,
  2831. VerifyNumber: "",
  2832. }
  2833. service.CreateHisPsn(psn)
  2834. var rf []*ResultFive
  2835. json.Unmarshal([]byte(infoStr), &rf)
  2836. var insutypes []*ResultFive
  2837. var insutype string
  2838. var is390 int = 0
  2839. var is310 int = 0
  2840. for _, item := range rf {
  2841. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2842. insutypes = append(insutypes, item)
  2843. }
  2844. }
  2845. if len(insutypes) == 1 {
  2846. insutype = insutypes[0].Insutype
  2847. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2848. } else {
  2849. for _, i := range insutypes {
  2850. if i.Insutype == "390" {
  2851. is390 = 1
  2852. }
  2853. if i.Insutype == "310" {
  2854. is310 = 1
  2855. }
  2856. }
  2857. }
  2858. if is390 == 1 {
  2859. insutype = "390"
  2860. }
  2861. if is310 == 1 {
  2862. insutype = "310"
  2863. }
  2864. if len(insutypes) == 0 {
  2865. insutype = "390"
  2866. }
  2867. c.ServeSuccessJSON(map[string]interface{}{
  2868. "patient": patient,
  2869. "number": cardnum,
  2870. "insutype": insutype,
  2871. })
  2872. }
  2873. } else {
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2875. return
  2876. }
  2877. }
  2878. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2879. fmt.Println(initFlag)
  2880. fmt.Println("initFlag")
  2881. if initFlag == 0 {
  2882. c.TestGetJiangXiBasBaseInit()
  2883. }
  2884. basStr := c.GetBasBaseInfo()
  2885. if len(basStr) == 0 {
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2887. return
  2888. }
  2889. fmt.Println(basStr)
  2890. bas := strings.Split(basStr, "|")
  2891. basNumber := bas[1]
  2892. fmt.Println(basNumber)
  2893. card_sn := bas[3]
  2894. fmt.Println(card_sn)
  2895. 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, "")
  2896. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2897. var dat map[string]interface{}
  2898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2899. fmt.Println(dat)
  2900. } else {
  2901. fmt.Println(err)
  2902. }
  2903. userJSONBytes, _ := json.Marshal(dat)
  2904. var res ResultTwo
  2905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2906. utils.ErrorLog("解析失败:%v", err)
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2908. return
  2909. }
  2910. if res.Infcode == 0 {
  2911. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2912. if err == gorm.ErrRecordNotFound {
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2914. return
  2915. } else if err != nil {
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2917. return
  2918. } else {
  2919. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2920. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2921. infoStr := string(Iinfos)
  2922. idetinfoStr := string(Idetinfos)
  2923. psn := &models.HisPsn{
  2924. PsnNo: res.Output.Baseinfo.PsnNo,
  2925. Age: res.Output.Baseinfo.Age,
  2926. PatientId: patient.ID,
  2927. Certno: res.Output.Baseinfo.Certno,
  2928. Brdy: res.Output.Baseinfo.Brdy,
  2929. Gend: res.Output.Baseinfo.Gend,
  2930. Naty: res.Output.Baseinfo.Naty,
  2931. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2932. PsnName: res.Output.Baseinfo.PsnName,
  2933. Idetinfo: idetinfoStr,
  2934. Insuinfo: infoStr,
  2935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2936. CardInfo: basStr,
  2937. VerifyNumber: "",
  2938. }
  2939. service.CreateHisPsn(psn)
  2940. var rf []*ResultFive
  2941. json.Unmarshal([]byte(infoStr), &rf)
  2942. var insutypes []*ResultFive
  2943. var insutype string
  2944. var is390 int = 0
  2945. var is310 int = 0
  2946. for _, item := range rf {
  2947. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2948. insutypes = append(insutypes, item)
  2949. }
  2950. }
  2951. if len(insutypes) == 1 {
  2952. insutype = insutypes[0].Insutype
  2953. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2954. } else {
  2955. for _, i := range insutypes {
  2956. if i.Insutype == "390" {
  2957. is390 = 1
  2958. }
  2959. if i.Insutype == "310" {
  2960. is310 = 1
  2961. }
  2962. }
  2963. }
  2964. if is390 == 1 {
  2965. insutype = "390"
  2966. }
  2967. if is310 == 1 {
  2968. insutype = "310"
  2969. }
  2970. if len(insutypes) == 0 {
  2971. insutype = "310"
  2972. }
  2973. c.ServeSuccessJSON(map[string]interface{}{
  2974. "patient": patient,
  2975. "number": basNumber,
  2976. "insutype": insutype,
  2977. })
  2978. }
  2979. } else {
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2981. return
  2982. }
  2983. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2984. fmt.Println(initFlag)
  2985. fmt.Println("initFlag")
  2986. if initFlag == 0 {
  2987. c.TestGetHnBasBaseInit()
  2988. }
  2989. basStr := c.GetBasBaseInfo()
  2990. if len(basStr) == 0 {
  2991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2992. return
  2993. }
  2994. fmt.Println(basStr)
  2995. bas := strings.Split(basStr, "|")
  2996. basNumber := bas[1]
  2997. fmt.Println(basNumber)
  2998. card_sn := bas[3]
  2999. card_no := bas[2]
  3000. fmt.Println(card_sn)
  3001. name := bas[4]
  3002. name = ConvertToString(name, "gbk", "utf-8")
  3003. 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)
  3004. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3005. var dat map[string]interface{}
  3006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3007. fmt.Println(dat)
  3008. } else {
  3009. fmt.Println(err)
  3010. }
  3011. userJSONBytes, _ := json.Marshal(dat)
  3012. var res ResultTwo
  3013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3014. utils.ErrorLog("解析失败:%v", err)
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. return
  3017. }
  3018. if res.Infcode == 0 {
  3019. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3020. if err == gorm.ErrRecordNotFound {
  3021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3022. return
  3023. } else if err != nil {
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3025. return
  3026. } else {
  3027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3029. infoStr := string(Iinfos)
  3030. idetinfoStr := string(Idetinfos)
  3031. psn := &models.HisPsn{
  3032. PsnNo: res.Output.Baseinfo.PsnNo,
  3033. Age: res.Output.Baseinfo.Age,
  3034. PatientId: patient.ID,
  3035. Certno: res.Output.Baseinfo.Certno,
  3036. Brdy: res.Output.Baseinfo.Brdy,
  3037. Gend: res.Output.Baseinfo.Gend,
  3038. Naty: res.Output.Baseinfo.Naty,
  3039. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3040. PsnName: res.Output.Baseinfo.PsnName,
  3041. Idetinfo: idetinfoStr,
  3042. Insuinfo: infoStr,
  3043. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3044. CardInfo: basStr,
  3045. VerifyNumber: "",
  3046. }
  3047. service.CreateHisPsn(psn)
  3048. var rf []*ResultFive
  3049. json.Unmarshal([]byte(infoStr), &rf)
  3050. var insutypes []*ResultFive
  3051. var insutype string
  3052. var is390 int = 0
  3053. var is310 int = 0
  3054. for _, item := range rf {
  3055. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3056. insutypes = append(insutypes, item)
  3057. }
  3058. }
  3059. if len(insutypes) == 1 {
  3060. insutype = insutypes[0].Insutype
  3061. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3062. } else {
  3063. for _, i := range insutypes {
  3064. if i.Insutype == "390" {
  3065. is390 = 1
  3066. }
  3067. if i.Insutype == "310" {
  3068. is310 = 1
  3069. }
  3070. }
  3071. }
  3072. if is390 == 1 {
  3073. insutype = "390"
  3074. }
  3075. if is310 == 1 {
  3076. insutype = "310"
  3077. }
  3078. if len(insutypes) == 0 {
  3079. insutype = "310"
  3080. }
  3081. c.ServeSuccessJSON(map[string]interface{}{
  3082. "patient": patient,
  3083. "number": basNumber,
  3084. "insutype": insutype,
  3085. })
  3086. }
  3087. } else {
  3088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3089. return
  3090. }
  3091. } else {
  3092. if initFlag == 0 {
  3093. c.TestGetBasBaseInit()
  3094. }
  3095. basStr := c.GetBasBaseInfo()
  3096. if len(basStr) == 0 {
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3098. return
  3099. }
  3100. fmt.Println(basStr)
  3101. bas := strings.Split(basStr, "|")
  3102. basNumber := bas[1]
  3103. fmt.Println(basNumber)
  3104. card_sn := bas[3]
  3105. fmt.Println(card_sn)
  3106. cardNumber := bas[2]
  3107. fmt.Println(cardNumber)
  3108. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3109. result := service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3110. var dat map[string]interface{}
  3111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3112. fmt.Println(dat)
  3113. } else {
  3114. fmt.Println(err)
  3115. }
  3116. userJSONBytes, _ := json.Marshal(dat)
  3117. var res ResultTwo
  3118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3119. utils.ErrorLog("解析失败:%v", err)
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3121. return
  3122. }
  3123. if res.Infcode == 0 {
  3124. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3125. if err == gorm.ErrRecordNotFound {
  3126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3127. return
  3128. } else if err != nil {
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3130. return
  3131. } else {
  3132. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3133. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3134. infoStr := string(Iinfos)
  3135. idetinfoStr := string(Idetinfos)
  3136. var rf []*ResultFive
  3137. json.Unmarshal([]byte(infoStr), &rf)
  3138. var insutypes []*ResultFive
  3139. var insutype string
  3140. var is390 int = 0
  3141. var is310 int = 0
  3142. var insuplc_admdvs string
  3143. for _, item := range rf {
  3144. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3145. insutypes = append(insutypes, item)
  3146. }
  3147. }
  3148. if len(insutypes) == 1 {
  3149. insutype = insutypes[0].Insutype
  3150. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3151. } else {
  3152. for _, i := range insutypes {
  3153. if i.Insutype == "390" {
  3154. is390 = 1
  3155. }
  3156. if i.Insutype == "310" {
  3157. is310 = 1
  3158. }
  3159. }
  3160. }
  3161. if is390 == 1 {
  3162. insutype = "390"
  3163. }
  3164. if is310 == 1 {
  3165. insutype = "310"
  3166. }
  3167. if len(insutypes) == 0 {
  3168. insutype = "310"
  3169. }
  3170. for _, item := range rf {
  3171. if item.Insutype == insutype {
  3172. insuplc_admdvs = item.InsuplcAdmdvs
  3173. }
  3174. }
  3175. psn := &models.HisPsn{
  3176. PsnNo: res.Output.Baseinfo.PsnNo,
  3177. Age: res.Output.Baseinfo.Age,
  3178. PatientId: patient.ID,
  3179. Certno: res.Output.Baseinfo.Certno,
  3180. Brdy: res.Output.Baseinfo.Brdy,
  3181. Gend: res.Output.Baseinfo.Gend,
  3182. Naty: res.Output.Baseinfo.Naty,
  3183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3184. PsnName: res.Output.Baseinfo.PsnName,
  3185. Idetinfo: idetinfoStr,
  3186. Insuinfo: infoStr,
  3187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3188. CardInfo: basStr,
  3189. VerifyNumber: "",
  3190. InsuplcAdmdvs: insuplc_admdvs,
  3191. }
  3192. service.CreateHisPsn(psn)
  3193. c.ServeSuccessJSON(map[string]interface{}{
  3194. "patient": patient,
  3195. "number": basNumber,
  3196. })
  3197. }
  3198. } else {
  3199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3200. return
  3201. }
  3202. break
  3203. }
  3204. case 2:
  3205. if miConfig.MdtrtareaAdmvs == "430800" {
  3206. if initFlag == 0 {
  3207. c.TestGetHnBasBaseInit()
  3208. }
  3209. SFZStr := c.GetSFZBaseInfo()
  3210. if len(SFZStr) == 0 {
  3211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3212. return
  3213. }
  3214. fmt.Println(SFZStr)
  3215. id_card_str := strings.Split(SFZStr, "^")
  3216. card_no := id_card_str[0]
  3217. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3218. //name := id_card_str[1]
  3219. //name = ConvertToString(name, "gbk", "utf-8")
  3220. 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)
  3221. var dat map[string]interface{}
  3222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3223. fmt.Println(dat)
  3224. } else {
  3225. fmt.Println(err)
  3226. }
  3227. userJSONBytes, _ := json.Marshal(dat)
  3228. var res ResultTwo
  3229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3230. utils.ErrorLog("解析失败:%v", err)
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3232. return
  3233. }
  3234. if res.Infcode == 0 {
  3235. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3236. if err == gorm.ErrRecordNotFound {
  3237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3238. return
  3239. } else if err != nil {
  3240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3241. return
  3242. } else {
  3243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3245. infoStr := string(Iinfos)
  3246. idetinfoStr := string(Idetinfos)
  3247. psn := &models.HisPsn{
  3248. PsnNo: res.Output.Baseinfo.PsnNo,
  3249. Age: res.Output.Baseinfo.Age,
  3250. PatientId: patient.ID,
  3251. Certno: res.Output.Baseinfo.Certno,
  3252. Brdy: res.Output.Baseinfo.Brdy,
  3253. Gend: res.Output.Baseinfo.Gend,
  3254. Naty: res.Output.Baseinfo.Naty,
  3255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3256. PsnName: res.Output.Baseinfo.PsnName,
  3257. Idetinfo: idetinfoStr,
  3258. Insuinfo: infoStr,
  3259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3260. CardInfo: SFZStr,
  3261. VerifyNumber: "",
  3262. }
  3263. service.CreateHisPsn(psn)
  3264. var rf []*ResultFive
  3265. json.Unmarshal([]byte(infoStr), &rf)
  3266. var insutypes []*ResultFive
  3267. var insutype string
  3268. var is390 int = 0
  3269. var is310 int = 0
  3270. for _, item := range rf {
  3271. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3272. insutypes = append(insutypes, item)
  3273. }
  3274. }
  3275. if len(insutypes) == 1 {
  3276. insutype = insutypes[0].Insutype
  3277. } else {
  3278. for _, i := range insutypes {
  3279. if i.Insutype == "390" {
  3280. is390 = 1
  3281. }
  3282. if i.Insutype == "310" {
  3283. is310 = 1
  3284. }
  3285. }
  3286. }
  3287. if is390 == 1 {
  3288. insutype = "390"
  3289. }
  3290. if is310 == 1 {
  3291. insutype = "310"
  3292. }
  3293. if len(insutypes) == 0 {
  3294. insutype = "310"
  3295. }
  3296. c.ServeSuccessJSON(map[string]interface{}{
  3297. "patient": patient,
  3298. "number": card_no,
  3299. "insutype": insutype,
  3300. })
  3301. }
  3302. } else {
  3303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3304. return
  3305. }
  3306. } else {
  3307. SFZStr := c.GetSFZBaseInfo()
  3308. id_card_str := strings.Split(SFZStr, "^")
  3309. id_card_number := id_card_str[0]
  3310. card_sn := ""
  3311. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3312. var dat map[string]interface{}
  3313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3314. fmt.Println(dat)
  3315. } else {
  3316. fmt.Println(err)
  3317. }
  3318. userJSONBytes, _ := json.Marshal(dat)
  3319. var res ResultTwo
  3320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3321. utils.ErrorLog("解析失败:%v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. if res.Infcode == 0 {
  3326. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3327. if err == gorm.ErrRecordNotFound {
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3329. return
  3330. } else if err != nil {
  3331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3332. return
  3333. } else {
  3334. c.ServeSuccessJSON(map[string]interface{}{
  3335. "patient": patient,
  3336. "number": id_card_number,
  3337. })
  3338. }
  3339. } else {
  3340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3341. return
  3342. }
  3343. }
  3344. break
  3345. case 3:
  3346. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3347. var api string
  3348. if miConfig.MdtrtareaAdmvs == "320921" {
  3349. 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 +
  3350. "&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
  3351. fmt.Println(api)
  3352. } else {
  3353. 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 +
  3354. "&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)
  3355. }
  3356. resp, requestErr := http.Get(api)
  3357. if requestErr != nil {
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. return
  3360. }
  3361. body, ioErr := ioutil.ReadAll(resp.Body)
  3362. if ioErr != nil {
  3363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3365. return
  3366. }
  3367. var respJSON map[string]interface{}
  3368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3371. return
  3372. }
  3373. var status string
  3374. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3375. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3376. var token string
  3377. var res ResultTwo //1101结果
  3378. var res10265 ResultTwo10265 //1101结果
  3379. var card_info string //卡信息
  3380. var busi_card_info string
  3381. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3383. if status == "0" { //读卡成功
  3384. if card_type == "1" {
  3385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3386. result, _ := json.Marshal(respJSON)
  3387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3388. utils.ErrorLog("解析失败:%v", err)
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3390. return
  3391. }
  3392. res.ErrMsg = res10265.ErrMsg
  3393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3394. res.Infcode = infocode
  3395. res.Output = res10265.Output
  3396. res.InfRefmsgid = res10265.InfRefmsgid
  3397. } else {
  3398. //var card_info string //卡信息
  3399. //var busi_card_info string
  3400. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3401. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3402. //fmt.Println(card_info)
  3403. //fmt.Println(busi_card_info)
  3404. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3405. result, _ := json.Marshal(respJSON)
  3406. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3407. utils.ErrorLog("解析失败:%v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. res.ErrMsg = res10265.ErrMsg
  3412. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3413. res.Infcode = infocode
  3414. res.Output = res10265.Output
  3415. res.InfRefmsgid = res10265.InfRefmsgid
  3416. }
  3417. if res.Infcode == 0 {
  3418. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3419. if err == gorm.ErrRecordNotFound {
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3421. return
  3422. } else if err != nil {
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3424. return
  3425. } else {
  3426. if card_type == "1" {
  3427. bas := strings.Split(card_info, "|")
  3428. basNumber := bas[2]
  3429. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3430. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3431. infoStr := string(Iinfos)
  3432. idetinfoStr := string(Idetinfos)
  3433. psn := &models.HisPsn{
  3434. PsnNo: res.Output.Baseinfo.PsnNo,
  3435. Age: res.Output.Baseinfo.Age,
  3436. PatientId: patient.ID,
  3437. Certno: res.Output.Baseinfo.Certno,
  3438. Brdy: res.Output.Baseinfo.Brdy,
  3439. Gend: res.Output.Baseinfo.Gend,
  3440. Naty: res.Output.Baseinfo.Naty,
  3441. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3442. PsnName: res.Output.Baseinfo.PsnName,
  3443. Idetinfo: idetinfoStr,
  3444. Insuinfo: infoStr,
  3445. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3446. CardInfo: card_info,
  3447. VerifyNumber: busi_card_info,
  3448. }
  3449. service.CreateHisPsn(psn)
  3450. c.ServeSuccessJSON(map[string]interface{}{
  3451. "patient": patient,
  3452. "number": basNumber,
  3453. })
  3454. } else {
  3455. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3456. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3457. infoStr := string(Iinfos)
  3458. idetinfoStr := string(Idetinfos)
  3459. psn := &models.HisPsn{
  3460. PsnNo: res.Output.Baseinfo.PsnNo,
  3461. Age: res.Output.Baseinfo.Age,
  3462. PatientId: patient.ID,
  3463. Certno: res.Output.Baseinfo.Certno,
  3464. Brdy: res.Output.Baseinfo.Brdy,
  3465. Gend: res.Output.Baseinfo.Gend,
  3466. Naty: res.Output.Baseinfo.Naty,
  3467. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3468. PsnName: res.Output.Baseinfo.PsnName,
  3469. Idetinfo: idetinfoStr,
  3470. Insuinfo: infoStr,
  3471. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3472. CardInfo: card_info,
  3473. VerifyNumber: token,
  3474. }
  3475. service.CreateHisPsn(psn)
  3476. var rf []*ResultFive
  3477. json.Unmarshal([]byte(infoStr), &rf)
  3478. var insutypes []*ResultFive
  3479. var insutype string
  3480. var is390 int = 0
  3481. var is310 int = 0
  3482. for _, item := range rf {
  3483. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3484. insutypes = append(insutypes, item)
  3485. }
  3486. }
  3487. if len(insutypes) == 1 {
  3488. insutype = insutypes[0].Insutype
  3489. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3490. } else {
  3491. for _, i := range insutypes {
  3492. if i.Insutype == "390" {
  3493. is390 = 1
  3494. }
  3495. if i.Insutype == "310" {
  3496. is310 = 1
  3497. }
  3498. }
  3499. }
  3500. if is390 == 1 {
  3501. insutype = "390"
  3502. }
  3503. if is310 == 1 {
  3504. insutype = "310"
  3505. }
  3506. if len(insutypes) == 0 {
  3507. insutype = "310"
  3508. }
  3509. c.ServeSuccessJSON(map[string]interface{}{
  3510. "patient": patient,
  3511. "number": token,
  3512. "insutype": insutype,
  3513. })
  3514. }
  3515. }
  3516. } else {
  3517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3518. return
  3519. }
  3520. } else { //读卡失败
  3521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3522. return
  3523. }
  3524. }
  3525. break
  3526. case 4:
  3527. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3528. var api string
  3529. if miConfig.MdtrtareaAdmvs == "320921" {
  3530. 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 +
  3531. "&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
  3532. fmt.Println(api)
  3533. } else {
  3534. 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 +
  3535. "&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)
  3536. }
  3537. resp, requestErr := http.Get(api)
  3538. if requestErr != nil {
  3539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3540. return
  3541. }
  3542. body, ioErr := ioutil.ReadAll(resp.Body)
  3543. if ioErr != nil {
  3544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3546. return
  3547. }
  3548. var respJSON map[string]interface{}
  3549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3552. return
  3553. }
  3554. var status string
  3555. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3556. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3557. var token string
  3558. var res ResultTwo //1101结果
  3559. var res10265 ResultTwo10265 //1101结果
  3560. if status == "0" { //读卡成功
  3561. var card_info string //卡信息
  3562. var busi_card_info string
  3563. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3564. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3565. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3566. fmt.Println(card_info)
  3567. fmt.Println(busi_card_info)
  3568. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3569. result, _ := json.Marshal(respJSON)
  3570. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3571. utils.ErrorLog("解析失败:%v", err)
  3572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3573. return
  3574. }
  3575. res.ErrMsg = res10265.ErrMsg
  3576. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3577. res.Infcode = infocode
  3578. res.Output = res10265.Output
  3579. res.InfRefmsgid = res10265.InfRefmsgid
  3580. if res.Infcode == 0 {
  3581. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3582. if err == gorm.ErrRecordNotFound {
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3584. return
  3585. } else if err != nil {
  3586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3587. return
  3588. } else {
  3589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3591. infoStr := string(Iinfos)
  3592. idetinfoStr := string(Idetinfos)
  3593. psn := &models.HisPsn{
  3594. PsnNo: res.Output.Baseinfo.PsnNo,
  3595. Age: res.Output.Baseinfo.Age,
  3596. PatientId: patient.ID,
  3597. Certno: res.Output.Baseinfo.Certno,
  3598. Brdy: res.Output.Baseinfo.Brdy,
  3599. Gend: res.Output.Baseinfo.Gend,
  3600. Naty: res.Output.Baseinfo.Naty,
  3601. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3602. PsnName: res.Output.Baseinfo.PsnName,
  3603. Idetinfo: idetinfoStr,
  3604. Insuinfo: infoStr,
  3605. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3606. CardInfo: card_info,
  3607. VerifyNumber: token,
  3608. }
  3609. var rf []*ResultFive
  3610. json.Unmarshal([]byte(infoStr), &rf)
  3611. var insutypes []*ResultFive
  3612. var insutype string
  3613. var is390 int = 0
  3614. var is310 int = 0
  3615. for _, item := range rf {
  3616. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3617. insutypes = append(insutypes, item)
  3618. }
  3619. }
  3620. if len(insutypes) == 1 {
  3621. insutype = insutypes[0].Insutype
  3622. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3623. } else {
  3624. for _, i := range insutypes {
  3625. if i.Insutype == "390" {
  3626. is390 = 1
  3627. }
  3628. if i.Insutype == "310" {
  3629. is310 = 1
  3630. }
  3631. }
  3632. }
  3633. if is390 == 1 {
  3634. insutype = "390"
  3635. }
  3636. if is310 == 1 {
  3637. insutype = "310"
  3638. }
  3639. if len(insutypes) == 0 {
  3640. insutype = "310"
  3641. }
  3642. service.CreateHisPsn(psn)
  3643. c.ServeSuccessJSON(map[string]interface{}{
  3644. "patient": patient,
  3645. "number": token,
  3646. "insutype": insutype,
  3647. })
  3648. }
  3649. } else {
  3650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3651. return
  3652. }
  3653. } else { //读卡失败
  3654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3655. return
  3656. }
  3657. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3658. if initFlag == 0 {
  3659. c.TestGetBasBaseInit()
  3660. }
  3661. token := c.GetEleBaseInfo()
  3662. token = Remove0000(token)
  3663. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3664. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3665. //
  3666. var res ResultTwo
  3667. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3668. utils.ErrorLog("解析失败:%v", err)
  3669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. return
  3671. }
  3672. if res.Infcode == 0 {
  3673. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3674. if err == gorm.ErrRecordNotFound {
  3675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3676. return
  3677. } else if err != nil {
  3678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3679. return
  3680. } else {
  3681. //month := time.Unix(1557042972, 0).Format("1")
  3682. //year := time.Now().Format("2006")
  3683. //month = time.Now().Format("01")
  3684. //day := time.Now().Format("02")
  3685. //date := year+"-"+month+"-"+day + " "+"00:00:00"
  3686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3688. infoStr := string(Iinfos)
  3689. idetinfoStr := string(Idetinfos)
  3690. psn := &models.HisPsn{
  3691. PsnNo: res.Output.Baseinfo.PsnNo,
  3692. Age: res.Output.Baseinfo.Age,
  3693. PatientId: patient.ID,
  3694. Certno: res.Output.Baseinfo.Certno,
  3695. Brdy: res.Output.Baseinfo.Brdy,
  3696. Gend: res.Output.Baseinfo.Gend,
  3697. Naty: res.Output.Baseinfo.Naty,
  3698. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3699. PsnName: res.Output.Baseinfo.PsnName,
  3700. Idetinfo: idetinfoStr,
  3701. Insuinfo: infoStr,
  3702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3703. CardInfo: "",
  3704. Stage: "1",
  3705. //RecordDate:
  3706. VerifyNumber: token,
  3707. }
  3708. service.CreateHisPsn(psn)
  3709. c.ServeSuccessJSON(map[string]interface{}{
  3710. "patient": patient,
  3711. "number": token,
  3712. })
  3713. }
  3714. } else {
  3715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3716. return
  3717. }
  3718. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3719. //if initFlag == 0 {
  3720. c.TestGetJiangXiBasBaseInit()
  3721. //}
  3722. //if initEleFlag == 0 {
  3723. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3724. //}
  3725. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3726. type ELeData struct {
  3727. Data struct {
  3728. IdNo string `json:"idNo"`
  3729. IdType string `json:"idType"`
  3730. UserName string `json:"userName"`
  3731. EcToken string `json:"ecToken"`
  3732. InsuOrg string `json:"insuOrg"`
  3733. Gender string `json:"gender"`
  3734. Birthday string `json:"birthday"`
  3735. Nationality string `json:"nationality"`
  3736. Email string `json:"email"`
  3737. Extra string `json:"extra"`
  3738. } `json:"data"`
  3739. Code int `json:"code"`
  3740. Message string `json:"message"`
  3741. }
  3742. var ele ELeData
  3743. err := json.Unmarshal([]byte(json_result), &ele)
  3744. if err != nil {
  3745. utils.ErrorLog("解析失败:%v", err)
  3746. }
  3747. token := ele.Data.EcToken
  3748. token = Remove0000(token)
  3749. 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)
  3750. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3751. var res ResultTwo
  3752. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3753. utils.ErrorLog("解析失败:%v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. if res.Infcode == 0 {
  3758. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3759. if err == gorm.ErrRecordNotFound {
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3761. return
  3762. } else if err != nil {
  3763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3764. return
  3765. } else {
  3766. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3767. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3768. infoStr := string(Iinfos)
  3769. idetinfoStr := string(Idetinfos)
  3770. psn := &models.HisPsn{
  3771. PsnNo: res.Output.Baseinfo.PsnNo,
  3772. Age: res.Output.Baseinfo.Age,
  3773. PatientId: patient.ID,
  3774. Certno: res.Output.Baseinfo.Certno,
  3775. Brdy: res.Output.Baseinfo.Brdy,
  3776. Gend: res.Output.Baseinfo.Gend,
  3777. Naty: res.Output.Baseinfo.Naty,
  3778. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3779. PsnName: res.Output.Baseinfo.PsnName,
  3780. Idetinfo: idetinfoStr,
  3781. Insuinfo: infoStr,
  3782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3783. CardInfo: "",
  3784. //RecordDate:
  3785. VerifyNumber: token,
  3786. }
  3787. service.CreateHisPsn(psn)
  3788. var rf []*ResultFive
  3789. json.Unmarshal([]byte(infoStr), &rf)
  3790. var insutypes []*ResultFive
  3791. var insutype string
  3792. var is390 int = 0
  3793. var is310 int = 0
  3794. for _, item := range rf {
  3795. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3796. insutypes = append(insutypes, item)
  3797. }
  3798. }
  3799. if len(insutypes) == 1 {
  3800. insutype = insutypes[0].Insutype
  3801. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3802. } else {
  3803. for _, i := range insutypes {
  3804. if i.Insutype == "390" {
  3805. is390 = 1
  3806. }
  3807. if i.Insutype == "310" {
  3808. is310 = 1
  3809. }
  3810. }
  3811. }
  3812. if is390 == 1 {
  3813. insutype = "390"
  3814. }
  3815. if is310 == 1 {
  3816. insutype = "310"
  3817. }
  3818. if len(insutypes) == 0 {
  3819. insutype = "310"
  3820. }
  3821. c.ServeSuccessJSON(map[string]interface{}{
  3822. "patient": patient,
  3823. "number": token,
  3824. "insutype": insutype,
  3825. })
  3826. }
  3827. } else {
  3828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3829. return
  3830. }
  3831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3832. //if initFlag == 0 {
  3833. c.TestGetJiangXiBasBaseInit()
  3834. //}
  3835. //if initEleFlag == 0 {
  3836. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3837. //}
  3838. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3839. type ELeData struct {
  3840. Data struct {
  3841. IdNo string `json:"idNo"`
  3842. IdType string `json:"idType"`
  3843. UserName string `json:"userName"`
  3844. EcToken string `json:"ecToken"`
  3845. InsuOrg string `json:"insuOrg"`
  3846. Gender string `json:"gender"`
  3847. Birthday string `json:"birthday"`
  3848. Nationality string `json:"nationality"`
  3849. Email string `json:"email"`
  3850. Extra string `json:"extra"`
  3851. } `json:"data"`
  3852. Code int `json:"code"`
  3853. Message string `json:"message"`
  3854. }
  3855. var ele ELeData
  3856. err := json.Unmarshal([]byte(json_result), &ele)
  3857. if err != nil {
  3858. utils.ErrorLog("解析失败:%v", err)
  3859. }
  3860. token := ele.Data.EcToken
  3861. token = Remove0000(token)
  3862. 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)
  3863. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3864. var res ResultTwo
  3865. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3866. utils.ErrorLog("解析失败:%v", err)
  3867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3868. return
  3869. }
  3870. if res.Infcode == 0 {
  3871. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3872. if err == gorm.ErrRecordNotFound {
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3874. return
  3875. } else if err != nil {
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3877. return
  3878. } else {
  3879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3881. infoStr := string(Iinfos)
  3882. idetinfoStr := string(Idetinfos)
  3883. psn := &models.HisPsn{
  3884. PsnNo: res.Output.Baseinfo.PsnNo,
  3885. Age: res.Output.Baseinfo.Age,
  3886. PatientId: patient.ID,
  3887. Certno: res.Output.Baseinfo.Certno,
  3888. Brdy: res.Output.Baseinfo.Brdy,
  3889. Gend: res.Output.Baseinfo.Gend,
  3890. Naty: res.Output.Baseinfo.Naty,
  3891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3892. PsnName: res.Output.Baseinfo.PsnName,
  3893. Idetinfo: idetinfoStr,
  3894. Insuinfo: infoStr,
  3895. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3896. CardInfo: "",
  3897. VerifyNumber: token,
  3898. }
  3899. service.CreateHisPsn(psn)
  3900. var rf []*ResultFive
  3901. json.Unmarshal([]byte(infoStr), &rf)
  3902. var insutypes []*ResultFive
  3903. var insutype string
  3904. var is390 int = 0
  3905. var is310 int = 0
  3906. for _, item := range rf {
  3907. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3908. insutypes = append(insutypes, item)
  3909. }
  3910. }
  3911. if len(insutypes) == 1 {
  3912. insutype = insutypes[0].Insutype
  3913. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3914. } else {
  3915. for _, i := range insutypes {
  3916. if i.Insutype == "390" {
  3917. is390 = 1
  3918. }
  3919. if i.Insutype == "310" {
  3920. is310 = 1
  3921. }
  3922. }
  3923. }
  3924. if is390 == 1 {
  3925. insutype = "390"
  3926. }
  3927. if is310 == 1 {
  3928. insutype = "310"
  3929. }
  3930. if len(insutypes) == 0 {
  3931. insutype = "310"
  3932. }
  3933. c.ServeSuccessJSON(map[string]interface{}{
  3934. "patient": patient,
  3935. "number": token,
  3936. "insutype": insutype,
  3937. })
  3938. }
  3939. } else {
  3940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3941. return
  3942. }
  3943. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3944. type ELeData struct {
  3945. Code string `json:"code"`
  3946. Data struct {
  3947. Aac002 string `json:"aac002"`
  3948. Aaz500 string `json:"aaz500"`
  3949. ActCardNo string `json:"actCardNo"`
  3950. Bab520 string `json:"bab520"`
  3951. Bkz543 string `json:"bkz543"`
  3952. BusinessType string `json:"businessType"`
  3953. CertfCodg string `json:"certfCodg"`
  3954. EcIndexNo string `json:"ecIndexNo"`
  3955. EcToken string `json:"ecToken"`
  3956. ID0000 string `json:"id0000"`
  3957. IDNo string `json:"idNo"`
  3958. IDType string `json:"idType"`
  3959. Idcode string `json:"idcode"`
  3960. IdentityToken string `json:"identity_token"`
  3961. InsuOrg string `json:"insuOrg"`
  3962. OfficeID string `json:"officeId"`
  3963. OfficeName string `json:"officeName"`
  3964. OperatorID string `json:"operatorId"`
  3965. OperatorName string `json:"operatorName"`
  3966. OrgID string `json:"orgId"`
  3967. UserName string `json:"userName"`
  3968. } `json:"data"`
  3969. Infno interface{} `json:"infno"`
  3970. Message string `json:"message"`
  3971. OrgID string `json:"orgId"`
  3972. TransType string `json:"transType"`
  3973. }
  3974. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3975. outPutInfo = Remove0000(outPutInfo)
  3976. if len(outPutInfo) > 0 {
  3977. var ele ELeData
  3978. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3979. if err != nil {
  3980. utils.ErrorLog("解析失败:%v", err)
  3981. }
  3982. token := ele.Data.EcToken
  3983. fmt.Println(inputInfo)
  3984. fmt.Println(outPutInfo)
  3985. 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)
  3986. saveLog(result, requestLog, "1101", "获取人员信息")
  3987. var dat map[string]interface{}
  3988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3989. fmt.Println(dat)
  3990. } else {
  3991. fmt.Println(err)
  3992. }
  3993. userJSONBytes, _ := json.Marshal(dat)
  3994. var res ResultTwo
  3995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3996. utils.ErrorLog("解析失败:%v", err)
  3997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3998. return
  3999. }
  4000. res.ErrMsg = errMsgLog
  4001. if res.Infcode == 0 {
  4002. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4003. if err == gorm.ErrRecordNotFound {
  4004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4005. return
  4006. } else if err != nil {
  4007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4008. return
  4009. } else {
  4010. fmt.Println(res)
  4011. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4012. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4013. infoStr := string(Iinfos)
  4014. idetinfoStr := string(Idetinfos)
  4015. psn := &models.HisPsn{
  4016. PsnNo: res.Output.Baseinfo.PsnNo,
  4017. Age: res.Output.Baseinfo.Age,
  4018. PatientId: patient.ID,
  4019. Certno: res.Output.Baseinfo.Certno,
  4020. Brdy: res.Output.Baseinfo.Brdy,
  4021. Gend: res.Output.Baseinfo.Gend,
  4022. Naty: res.Output.Baseinfo.Naty,
  4023. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4024. PsnName: res.Output.Baseinfo.PsnName,
  4025. Idetinfo: idetinfoStr,
  4026. Insuinfo: infoStr,
  4027. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4028. CardInfo: outPutInfo,
  4029. VerifyNumber: token,
  4030. InsuplcAdmdvs: ele.Data.InsuOrg,
  4031. }
  4032. service.CreateHisPsn(psn)
  4033. var rf []*ResultFive
  4034. json.Unmarshal([]byte(infoStr), &rf)
  4035. var insutypes []*ResultFive
  4036. var insutype string
  4037. var is390 int = 0
  4038. var is310 int = 0
  4039. for _, item := range rf {
  4040. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4041. insutypes = append(insutypes, item)
  4042. }
  4043. }
  4044. if len(insutypes) == 1 {
  4045. insutype = insutypes[0].Insutype
  4046. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4047. } else {
  4048. for _, i := range insutypes {
  4049. if i.Insutype == "390" {
  4050. is390 = 1
  4051. }
  4052. if i.Insutype == "310" {
  4053. is310 = 1
  4054. }
  4055. }
  4056. }
  4057. if is390 == 1 {
  4058. insutype = "390"
  4059. }
  4060. if is310 == 1 {
  4061. insutype = "310"
  4062. }
  4063. if len(insutypes) == 0 {
  4064. insutype = "310"
  4065. }
  4066. c.ServeSuccessJSON(map[string]interface{}{
  4067. "patient": patient,
  4068. "number": token,
  4069. "insutype": insutype,
  4070. })
  4071. }
  4072. } else {
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4074. return
  4075. }
  4076. }
  4077. } else {
  4078. if initFlag == 0 {
  4079. c.TestGetBasBaseInit()
  4080. }
  4081. token := c.GetEleBaseInfo()
  4082. token = Remove0000(token)
  4083. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4084. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4085. //
  4086. var res ResultTwo
  4087. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4088. utils.ErrorLog("解析失败:%v", err)
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4090. return
  4091. }
  4092. if res.Infcode == 0 {
  4093. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4094. if err == gorm.ErrRecordNotFound {
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4096. return
  4097. } else if err != nil {
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4099. return
  4100. } else {
  4101. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4102. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4103. infoStr := string(Iinfos)
  4104. idetinfoStr := string(Idetinfos)
  4105. psn := &models.HisPsn{
  4106. PsnNo: res.Output.Baseinfo.PsnNo,
  4107. Age: res.Output.Baseinfo.Age,
  4108. PatientId: patient.ID,
  4109. Certno: res.Output.Baseinfo.Certno,
  4110. Brdy: res.Output.Baseinfo.Brdy,
  4111. Gend: res.Output.Baseinfo.Gend,
  4112. Naty: res.Output.Baseinfo.Naty,
  4113. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4114. PsnName: res.Output.Baseinfo.PsnName,
  4115. Idetinfo: idetinfoStr,
  4116. Insuinfo: infoStr,
  4117. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4118. CardInfo: "",
  4119. VerifyNumber: token,
  4120. }
  4121. service.CreateHisPsn(psn)
  4122. c.ServeSuccessJSON(map[string]interface{}{
  4123. "patient": patient,
  4124. "number": token,
  4125. })
  4126. }
  4127. } else {
  4128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4129. return
  4130. }
  4131. }
  4132. break
  4133. }
  4134. }
  4135. var initFlag int64 = 0
  4136. var initEleFlag int64 = 0
  4137. func (c *HisApiController) TestGetBasBaseInit() {
  4138. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4139. Iinit := DllDef.MustFindProc("Init")
  4140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4141. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4142. if ret != 0 {
  4143. fmt.Println("SSCard的报错原因:", err)
  4144. fmt.Println("SSCard的运算结果为:", ret)
  4145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4146. return
  4147. }
  4148. result := int(ret)
  4149. fmt.Println("SSCard的运算结果为1:", result)
  4150. initFlag = 1
  4151. return
  4152. }
  4153. func (c *HisApiController) HandleJiangXiReadCard() {
  4154. fmt.Println("~~~~~~")
  4155. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4156. admin_user_id, _ := c.GetInt64("admin_user_id")
  4157. id_card_type, _ := c.GetInt64("id_card_type")
  4158. //certificates, _ := c.GetInt64("certificates")
  4159. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4160. if initFlag == 0 {
  4161. c.TestGetJiangXiBasBaseInit()
  4162. }
  4163. basStr := c.GetBasBaseInfo()
  4164. if len(basStr) == 0 {
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4166. return
  4167. }
  4168. fmt.Println(basStr)
  4169. bas := strings.Split(basStr, "|")
  4170. basNumber := bas[1]
  4171. fmt.Println(basNumber)
  4172. card_sn := bas[3]
  4173. fmt.Println(card_sn)
  4174. 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, "")
  4175. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4176. var dat map[string]interface{}
  4177. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4178. fmt.Println(dat)
  4179. } else {
  4180. fmt.Println(err)
  4181. }
  4182. userJSONBytes, _ := json.Marshal(dat)
  4183. var res ResultTwo
  4184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4185. utils.ErrorLog("解析失败:%v", err)
  4186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4187. return
  4188. }
  4189. if res.Infcode == 0 {
  4190. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4191. if err == gorm.ErrRecordNotFound {
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4193. return
  4194. } else if err != nil {
  4195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4196. return
  4197. } else {
  4198. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4199. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4200. infoStr := string(Iinfos)
  4201. idetinfoStr := string(Idetinfos)
  4202. psn := &models.HisPsn{
  4203. PsnNo: res.Output.Baseinfo.PsnNo,
  4204. Age: res.Output.Baseinfo.Age,
  4205. PatientId: patient.ID,
  4206. Certno: res.Output.Baseinfo.Certno,
  4207. Brdy: res.Output.Baseinfo.Brdy,
  4208. Gend: res.Output.Baseinfo.Gend,
  4209. Naty: res.Output.Baseinfo.Naty,
  4210. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4211. PsnName: res.Output.Baseinfo.PsnName,
  4212. Idetinfo: idetinfoStr,
  4213. Insuinfo: infoStr,
  4214. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4215. CardInfo: basStr,
  4216. VerifyNumber: "",
  4217. }
  4218. service.CreateHisPsn(psn)
  4219. c.ServeSuccessJSON(map[string]interface{}{
  4220. "patient": patient,
  4221. "number": basNumber,
  4222. })
  4223. }
  4224. } else {
  4225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4226. return
  4227. }
  4228. }
  4229. func (c *HisApiController) TestGetHnBasBaseInit() {
  4230. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4231. Iinit := DllDef.MustFindProc("Init")
  4232. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4233. //http://10.77.211.236/CSB/hsa-fsi-1303
  4234. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  4235. if ret != 0 {
  4236. fmt.Println("SSCard的报错原因:", err)
  4237. fmt.Println("SSCard的运算结果为:", ret)
  4238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4239. return
  4240. }
  4241. result := int(ret)
  4242. fmt.Println("SSCard的运算结果为1:", result)
  4243. initFlag = 1
  4244. return
  4245. }
  4246. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  4247. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4248. Iinit := DllDef.MustFindProc("Init")
  4249. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4250. //http://10.77.211.236/CSB/hsa-fsi-1303
  4251. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4252. if ret != 0 {
  4253. fmt.Println("SSCard的报错原因:", err)
  4254. fmt.Println("SSCard的运算结果为:", ret)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4256. return
  4257. }
  4258. result := int(ret)
  4259. fmt.Println("SSCard的运算结果为1:", result)
  4260. initFlag = 1
  4261. return
  4262. }
  4263. func (c *HisApiController) GetSFZBaseInfo() string {
  4264. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4265. readCard := DllDef.MustFindProc("ReadSFZ")
  4266. if readCard == nil {
  4267. fmt.Println("readcard is nil")
  4268. readCard = DllDef.MustFindProc("ReadSFZ")
  4269. }
  4270. str := make([]byte, 8096)
  4271. str1 := make([]byte, 8096)
  4272. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  4273. fmt.Println(r)
  4274. return Remove0000(string(str))
  4275. }
  4276. func (c *HisApiController) GetEleBaseInfo() string {
  4277. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4278. readCard := DllDef.MustFindProc("GetQRBase")
  4279. fmt.Println(readCard)
  4280. if readCard == nil {
  4281. fmt.Println("readcard is nil")
  4282. readCard = DllDef.MustFindProc("GetQRBase")
  4283. }
  4284. str := make([]byte, 1024)
  4285. str1 := make([]byte, 1024)
  4286. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4287. fmt.Println(ret2)
  4288. fmt.Println(string(str1))
  4289. fmt.Println(string(str))
  4290. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4291. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4292. if ret2 != 0 {
  4293. return ""
  4294. }
  4295. return string(str)
  4296. }
  4297. func GetJxEleBaseInfo(org_id int64) string {
  4298. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4299. readCard := DllDef.MustFindProc("NationEcTrans")
  4300. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4301. if readCard == nil {
  4302. fmt.Println("readcard is nil")
  4303. readCard = DllDef.MustFindProc("NationEcTrans")
  4304. }
  4305. str1 := make([]byte, 1024)
  4306. data := make(map[string]interface{})
  4307. inputData := make(map[string]interface{})
  4308. inputData["orgId"] = miConfig.Code
  4309. inputData["businessType"] = "01101"
  4310. inputData["operatorId"] = "test001"
  4311. inputData["operatorName"] = "cn"
  4312. inputData["officeId"] = "32760"
  4313. inputData["officeName"] = "waike"
  4314. inputData["deviceType"] = ""
  4315. data["data"] = inputData
  4316. data["transType"] = "ec.query"
  4317. data["extra "] = ""
  4318. data["orgId"] = miConfig.Code
  4319. bytesData, _ := json.Marshal(data)
  4320. //bytesData, _ := json.Marshal(data)
  4321. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4322. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4323. fmt.Println(ret2)
  4324. fmt.Println(string(str1))
  4325. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4326. if ret2 != 0 {
  4327. return ""
  4328. }
  4329. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4330. }
  4331. func GetJxEleBaseInitInfo(org_id int64) string {
  4332. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4333. readCard := DllDef.MustFindProc("NationEcTrans")
  4334. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4335. if readCard == nil {
  4336. fmt.Println("readcard is nil")
  4337. readCard = DllDef.MustFindProc("NationEcTrans")
  4338. }
  4339. str1 := make([]byte, 2048)
  4340. data := make(map[string]interface{})
  4341. inputData := make(map[string]interface{})
  4342. inputData["orgId"] = miConfig.Code
  4343. inputData["businessType"] = "01101"
  4344. inputData["operatorId"] = "1"
  4345. inputData["operatorName"] = "huangchuang"
  4346. inputData["officeId"] = "101"
  4347. inputData["officeName"] = "xuetou"
  4348. inputData["deviceType"] = ""
  4349. data["data"] = inputData
  4350. data["transType"] = "ec.query"
  4351. data["orgId"] = miConfig.Code
  4352. bytesData, _ := json.Marshal(data)
  4353. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4354. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4355. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  4356. fmt.Println(ret2)
  4357. fmt.Println(string(str1))
  4358. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4359. if ret2 != 0 {
  4360. return ""
  4361. }
  4362. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  4363. initEleFlag = 1
  4364. }
  4365. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4366. }
  4367. func (c *HisApiController) GetBasBaseInfo() string {
  4368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4369. readCard := DllDef.MustFindProc("ReadCardBas")
  4370. if readCard == nil {
  4371. fmt.Println("readcard is nil")
  4372. readCard = DllDef.MustFindProc("ReadCardBas")
  4373. }
  4374. str := make([]byte, 1024)
  4375. str1 := make([]byte, 1024)
  4376. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4377. fmt.Println(string(str1))
  4378. fmt.Println(string(str))
  4379. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4380. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4381. if ret2 != 0 {
  4382. return ""
  4383. }
  4384. return string(str)
  4385. }
  4386. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  4387. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  4388. readCard := DllDef.MustFindProc("read_cardinfo")
  4389. if readCard == nil {
  4390. fmt.Println("readcard is nil")
  4391. readCard = DllDef.MustFindProc("read_cardinfo")
  4392. }
  4393. str := make([]byte, 1024) //卡号
  4394. str1 := make([]byte, 1024) //卡识别码
  4395. str2 := make([]byte, 1024) //身份证号
  4396. str3 := make([]byte, 1024) //姓名
  4397. str4 := make([]byte, 1024) //错误信息
  4398. 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])))
  4399. fmt.Println(string(str1))
  4400. fmt.Println(string(str))
  4401. fmt.Println(string(str2))
  4402. fmt.Println(string(str3))
  4403. fmt.Println(string(str4))
  4404. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4405. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4406. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  4407. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  4408. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  4409. if ret2 != 0 {
  4410. return "", "", "", "", ""
  4411. }
  4412. return string(str), string(str1), string(str2), string(str3), string(str4)
  4413. }
  4414. type CustomFundPay struct {
  4415. FundPayType string `json:"fund_pay_type"`
  4416. FundPayamt float64 `json:"fund_payamt"`
  4417. }
  4418. func (c *HisApiController) GetSettleList() {
  4419. order_id, _ := c.GetInt64("order_id")
  4420. admin_user_id, _ := c.GetInt64("admin_user_id")
  4421. order, _ := service.GetHisOrderByIDTwo(order_id)
  4422. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4423. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4424. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4425. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4426. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4427. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4428. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4429. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4430. if order.ID == 0 {
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4432. return
  4433. }
  4434. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4435. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4436. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4437. //fmt.Println(count)
  4438. //var zero string
  4439. //number := count + 1
  4440. //if number >= 1000 {
  4441. // zero = "0000" + strconv.FormatInt(number, 10)
  4442. //} else if number >= 10000 {
  4443. // zero = "000" + strconv.FormatInt(number, 10)
  4444. //} else if number >= 100000 {
  4445. // zero = "00" + strconv.FormatInt(number, 10)
  4446. //} else if number >= 1000000 {
  4447. // zero = "0" + strconv.FormatInt(number, 10)
  4448. //} else {
  4449. // zero = strconv.FormatInt(number, 10)
  4450. //}
  4451. //fmt.Println(zero)
  4452. struct4101 := service.Struct4101{
  4453. PsnNo: order.PsnNo,
  4454. MdtrtId: order.MdtrtId,
  4455. SetlId: order.SetlId,
  4456. PsnName: order.PsnName,
  4457. Gend: order.Gend,
  4458. Brdy: his.Brdy,
  4459. Age: his.Age,
  4460. Naty: order.Naty,
  4461. PatnCertType: "01",
  4462. Certno: order.Certno,
  4463. Prfs: "90",
  4464. ConerName: roles[0].UserName,
  4465. PatnRlts: "99",
  4466. ConerAddr: miConfig.OrgName,
  4467. ConerTel: admin.Mobile,
  4468. HiType: order.Insutype,
  4469. Insuplc: miConfig.InsuplcAdmdvs,
  4470. MaindiagFlag: "1",
  4471. BillCode: order.SetlId,
  4472. BillNo: order.SetlId,
  4473. BizSn: order.Number,
  4474. PsnSelfPay: order.PsnPartAmt,
  4475. PsnOwnPay: order.PsnPartAmt,
  4476. AcctPay: order.AcctPay,
  4477. PsnCashpay: order.PsnCashPay,
  4478. HiPaymtd: "1",
  4479. Hsorg: miConfig.InsuplcAdmdvs,
  4480. HsorgOpter: miConfig.InsuplcAdmdvs,
  4481. MedinsFillPsn: curRoles.UserName,
  4482. MedinsFillDept: depart.Name,
  4483. IptMedType: "2",
  4484. }
  4485. struct4101.SetlBegnDate = order.SetlTime
  4486. struct4101.SetlEndDate = order.SetlTime
  4487. time_arr := strings.Split(order.SetlTime, " ")
  4488. struct4101.AdmTime = time_arr[0]
  4489. struct4101.AdmEndTime = time_arr[0]
  4490. var rf []CustomFundPay
  4491. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4492. var tempFunPays []service.CustomStruct
  4493. for _, item := range rf {
  4494. var tempFunPay service.CustomStruct
  4495. tempFunPay.FundPayamt = item.FundPayamt
  4496. tempFunPay.FundPayType = item.FundPayType
  4497. tempFunPays = append(tempFunPays, tempFunPay)
  4498. }
  4499. struct4101.CustomStruct = tempFunPays
  4500. var tempDiaginfos []service.DiaginfoStructTwo
  4501. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4502. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4503. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4504. var config []*models.HisXtDiagnoseConfig
  4505. for _, item := range diagnosis_ids {
  4506. id, _ := strconv.ParseInt(item, 10, 64)
  4507. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4508. config = append(config, &diagnosisConfig)
  4509. }
  4510. for index, item := range config {
  4511. if index == 0 {
  4512. var tempDiaginfo service.DiaginfoStructTwo
  4513. tempDiaginfo.DiagCode = item.CountryCode
  4514. tempDiaginfo.DiagName = item.CountryContentName
  4515. tempDiaginfo.DiagType = "1"
  4516. tempDiaginfo.MaindiagFlag = "1"
  4517. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4518. } else {
  4519. var tempDiaginfo service.DiaginfoStructTwo
  4520. tempDiaginfo.DiagCode = item.CountryCode
  4521. tempDiaginfo.DiagName = item.CountryContentName
  4522. tempDiaginfo.DiagType = "2"
  4523. tempDiaginfo.MaindiagFlag = "0"
  4524. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4525. }
  4526. }
  4527. struct4101.Diseinfo = tempDiaginfos
  4528. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4529. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4530. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4531. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4532. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4533. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4534. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4535. var iteminfo service.IteminfoStruct
  4536. var bedCostTotal float64 = 0 //床位总费
  4537. var bedCostSelfTotal float64 = 0 //床位自费
  4538. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4539. var operationCostTotal float64 = 0 //手术费
  4540. var operationCostSelfTotal float64 = 0 //手术费
  4541. var operationCostPartSelfTotal float64 = 0 //手术费
  4542. var otherCostTotal float64 = 0 //其他费用
  4543. var otherCostSelfTotal float64 = 0 //其他费用
  4544. var otherCostPartSelfTotal float64 = 0 //其他费用
  4545. var materialCostTotal float64 = 0 //材料费
  4546. var materialCostSelfTotal float64 = 0 //材料费
  4547. var materialCostPartSelfTotal float64 = 0 //材料费
  4548. var westernMedicineCostTotal float64 = 0 //西药费
  4549. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4550. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4551. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4552. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4553. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4554. var checkCostTotal float64 = 0 //检查费
  4555. var checkCostSelfTotal float64 = 0 //检查费
  4556. var checkCostPartSelfTotal float64 = 0 //检查费
  4557. var laboratoryCostTotal float64 = 0 //化验费
  4558. var laboratoryCostSelfTotal float64 = 0 //化验费
  4559. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4560. var treatCostTotal float64 = 0 //治疗费用
  4561. var treatCostSelfTotal float64 = 0 //治疗费用
  4562. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4563. decimal.DivisionPrecision = 2
  4564. var bed_fulamt_ownpay_amt float64 = 0
  4565. var operation_fulamt_ownpay_amt float64 = 0
  4566. var other_fulamt_ownpay_amt float64 = 0
  4567. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4568. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4569. var check_fulamt_ownpay_amt float64 = 0
  4570. var material_fulamt_ownpay_amt float64 = 0
  4571. var laboratory_fulamt_ownpay_amt float64 = 0
  4572. var treat_fulamt_ownpay_amt float64 = 0
  4573. var bed_claa_sunmfee float64 = 0
  4574. var bed_clab_amt float64 = 0
  4575. var bed_other_amt float64 = 0
  4576. var operation_claa_sunmfee float64 = 0
  4577. var operation_clab_amt float64 = 0
  4578. var operation_other_amt float64 = 0
  4579. var other_claa_sunmfee float64 = 0
  4580. var other_clab_amt float64 = 0
  4581. var other_other_amt float64 = 0
  4582. var westernMedicine_claa_sunmfee float64 = 0
  4583. var westernMedicine_clab_amt float64 = 0
  4584. var westernMedicine_other_amt float64 = 0
  4585. var chineseTraditional_claa_sunmfee float64 = 0
  4586. var chineseTraditional_clab_amt float64 = 0
  4587. var chineseTraditional_other_amt float64 = 0
  4588. var check_claa_sunmfee float64 = 0
  4589. var check_clab_amt float64 = 0
  4590. var check_other_amt float64 = 0
  4591. var material_claa_sunmfee float64 = 0
  4592. var material_clab_amt float64 = 0
  4593. var material_other_amt float64 = 0
  4594. var laboratory_claa_sunmfee float64 = 0
  4595. var laboratory_clab_amt float64 = 0
  4596. var laboratory_other_amt float64 = 0
  4597. var treat_claa_sunmfee float64 = 0
  4598. var treat_clab_amt float64 = 0
  4599. var treat_other_amt float64 = 0
  4600. for _, item := range order.HisOrderInfo {
  4601. if item.MedChrgitmType == "01" { //床位费
  4602. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4603. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4604. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4605. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4606. if item.ChrgitmLv == "1" {
  4607. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4608. }
  4609. if item.ChrgitmLv == "2" {
  4610. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4611. }
  4612. if item.ChrgitmLv == "3" {
  4613. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4614. }
  4615. }
  4616. if item.MedChrgitmType == "03" { //检查费
  4617. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4618. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4619. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4620. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4621. if item.ChrgitmLv == "1" {
  4622. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4623. }
  4624. if item.ChrgitmLv == "2" {
  4625. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4626. }
  4627. if item.ChrgitmLv == "3" {
  4628. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4629. }
  4630. }
  4631. if item.MedChrgitmType == "04" { //化验费
  4632. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4633. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4634. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4635. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4636. if item.ChrgitmLv == "1" {
  4637. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4638. }
  4639. if item.ChrgitmLv == "2" {
  4640. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4641. }
  4642. if item.ChrgitmLv == "3" {
  4643. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4644. }
  4645. }
  4646. if item.MedChrgitmType == "05" { //治疗费
  4647. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4648. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4649. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4650. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4651. if item.ChrgitmLv == "1" {
  4652. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4653. }
  4654. if item.ChrgitmLv == "2" {
  4655. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4656. }
  4657. if item.ChrgitmLv == "3" {
  4658. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4659. }
  4660. }
  4661. if item.MedChrgitmType == "06" { //手术费
  4662. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4663. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4664. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4665. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4666. if item.ChrgitmLv == "1" {
  4667. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4668. }
  4669. if item.ChrgitmLv == "2" {
  4670. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4671. }
  4672. if item.ChrgitmLv == "3" {
  4673. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4674. }
  4675. }
  4676. if item.MedChrgitmType == "08" { //材料费
  4677. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4678. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4679. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4680. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4681. if item.ChrgitmLv == "1" {
  4682. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4683. }
  4684. if item.ChrgitmLv == "2" {
  4685. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4686. }
  4687. if item.ChrgitmLv == "3" {
  4688. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4689. }
  4690. }
  4691. if item.MedChrgitmType == "09" { //西药费
  4692. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4693. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4694. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4695. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4696. if item.ChrgitmLv == "1" {
  4697. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4698. }
  4699. if item.ChrgitmLv == "2" {
  4700. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4701. }
  4702. if item.ChrgitmLv == "3" {
  4703. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4704. }
  4705. }
  4706. if item.MedChrgitmType == "11" { //中成费
  4707. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4708. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4709. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4710. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4711. if item.ChrgitmLv == "1" {
  4712. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4713. }
  4714. if item.ChrgitmLv == "2" {
  4715. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4716. }
  4717. if item.ChrgitmLv == "3" {
  4718. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4719. }
  4720. }
  4721. if item.MedChrgitmType == "14" { //其他费
  4722. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4723. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4724. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4725. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4726. if item.ChrgitmLv == "1" {
  4727. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4728. }
  4729. if item.ChrgitmLv == "2" {
  4730. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4731. }
  4732. if item.ChrgitmLv == "3" {
  4733. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4734. }
  4735. }
  4736. }
  4737. var iteminfoStructs []service.IteminfoStruct
  4738. if bedCostTotal != 0 {
  4739. iteminfo.MedChrgitm = "01"
  4740. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4741. iteminfo.Amt = bedCostTotal
  4742. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4743. iteminfo.ClabAmt = bed_clab_amt
  4744. iteminfo.OthAmt = bed_other_amt
  4745. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4746. }
  4747. if checkCostTotal != 0 {
  4748. iteminfo.MedChrgitm = "03"
  4749. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4750. iteminfo.Amt = checkCostTotal
  4751. iteminfo.ClaaSumfee = check_claa_sunmfee
  4752. iteminfo.ClabAmt = check_clab_amt
  4753. iteminfo.OthAmt = check_other_amt
  4754. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4755. }
  4756. if laboratoryCostTotal != 0 {
  4757. iteminfo.MedChrgitm = "04"
  4758. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4759. iteminfo.Amt = laboratoryCostTotal
  4760. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4761. iteminfo.ClabAmt = laboratory_clab_amt
  4762. iteminfo.OthAmt = laboratory_other_amt
  4763. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4765. }
  4766. if treatCostTotal != 0 {
  4767. iteminfo.MedChrgitm = "05"
  4768. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4769. iteminfo.Amt = treatCostTotal
  4770. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4771. iteminfo.ClabAmt = treat_clab_amt
  4772. iteminfo.OthAmt = treat_other_amt
  4773. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4774. //(struct4101.IteminfoStruct, iteminfo)
  4775. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4776. }
  4777. if operationCostTotal != 0 {
  4778. iteminfo.MedChrgitm = "06"
  4779. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4780. iteminfo.Amt = operationCostTotal
  4781. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4782. iteminfo.ClabAmt = operation_clab_amt
  4783. iteminfo.OthAmt = operation_other_amt
  4784. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4785. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4786. }
  4787. if materialCostTotal != 0 {
  4788. iteminfo.MedChrgitm = "08"
  4789. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4790. iteminfo.Amt = materialCostTotal
  4791. iteminfo.ClaaSumfee = material_claa_sunmfee
  4792. iteminfo.ClabAmt = material_clab_amt
  4793. iteminfo.OthAmt = material_other_amt
  4794. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4796. }
  4797. if westernMedicineCostTotal != 0 {
  4798. iteminfo.MedChrgitm = "09"
  4799. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4800. iteminfo.Amt = westernMedicineCostTotal
  4801. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4802. iteminfo.ClabAmt = westernMedicine_clab_amt
  4803. iteminfo.OthAmt = westernMedicine_other_amt
  4804. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4806. }
  4807. if chineseTraditionalMedicineCostTotal != 0 {
  4808. iteminfo.MedChrgitm = "11"
  4809. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4810. iteminfo.Amt = westernMedicineCostTotal
  4811. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4812. iteminfo.ClabAmt = westernMedicine_clab_amt
  4813. iteminfo.OthAmt = westernMedicine_other_amt
  4814. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4815. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4816. }
  4817. if otherCostTotal != 0 {
  4818. iteminfo.MedChrgitm = "14"
  4819. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4820. iteminfo.Amt = otherCostTotal
  4821. iteminfo.ClaaSumfee = other_claa_sunmfee
  4822. iteminfo.ClabAmt = other_clab_amt
  4823. iteminfo.OthAmt = other_other_amt
  4824. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4826. }
  4827. struct4101.IteminfoStruct = iteminfoStructs
  4828. struct4101.Ntly = "中国"
  4829. struct4101.AdmCaty = "A03.06"
  4830. struct4101.DoctorName = doctor.UserName
  4831. struct4101.DoctorCode = doctor.DoctorNumber
  4832. var res ResultSeventeen
  4833. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4834. struct4101.BillCode = order.Number
  4835. struct4101.BillNo = order.SetlId
  4836. var resOther ResultSeventeenOther
  4837. var pp models.PublicParams
  4838. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4839. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4840. pp.FixmedinsName = miConfig.OrgName
  4841. pp.FixmedinsCode = miConfig.Code
  4842. pp.RequestUrl = miConfig.Url
  4843. pp.Cainfo = miConfig.Cainfo
  4844. pp.SecretKey = miConfig.SecretKey
  4845. pp.AccessKey = miConfig.AccessKey
  4846. pp.OpterName = curRoles.UserName
  4847. client := &http.Client{}
  4848. var req *http.Request
  4849. data := make(map[string]interface{})
  4850. data["struct4101"] = struct4101
  4851. data["pp"] = pp
  4852. bytesData, _ := json.Marshal(data)
  4853. if miConfig.MdtrtareaAdmvs == "320921" {
  4854. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4855. } else {
  4856. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4857. }
  4858. resp, _ := client.Do(req)
  4859. defer resp.Body.Close()
  4860. body, ioErr := ioutil.ReadAll(resp.Body)
  4861. if ioErr != nil {
  4862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4864. return
  4865. }
  4866. var respJSON map[string]interface{}
  4867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. return
  4871. }
  4872. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4873. userJSONBytes, _ := json.Marshal(respJSON)
  4874. fmt.Println("log")
  4875. fmt.Println(string(userJSONBytes))
  4876. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4877. utils.ErrorLog("解析失败:%v", err)
  4878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4879. return
  4880. }
  4881. res.InfRefmsgid = resOther.InfRefmsgid
  4882. res.Output = resOther.Output
  4883. res.ErrMsg = resOther.ErrMsg
  4884. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4885. res.Infcode = infocode
  4886. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4887. var pp models.PublicParams
  4888. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4889. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4890. pp.FixmedinsName = miConfig.OrgName
  4891. pp.FixmedinsCode = miConfig.Code
  4892. pp.RequestUrl = miConfig.Url
  4893. pp.Cainfo = miConfig.Cainfo
  4894. pp.SecretKey = miConfig.SecretKey
  4895. pp.AccessKey = miConfig.AccessKey
  4896. pp.OpterName = curRoles.UserName
  4897. result, _ := service.Jxyb4101(struct4101, pp)
  4898. var dat map[string]interface{}
  4899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4900. fmt.Println(dat)
  4901. } else {
  4902. fmt.Println(err)
  4903. }
  4904. userJSONBytes, _ := json.Marshal(dat)
  4905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4911. var pp models.PublicParams
  4912. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4913. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4914. pp.FixmedinsName = miConfig.OrgName
  4915. pp.FixmedinsCode = miConfig.Code
  4916. pp.RequestUrl = miConfig.Url
  4917. pp.Cainfo = miConfig.Cainfo
  4918. pp.SecretKey = miConfig.SecretKey
  4919. pp.AccessKey = miConfig.AccessKey
  4920. pp.OpterName = curRoles.UserName
  4921. result, _ := service.Hnyb4101(struct4101, pp)
  4922. var dat map[string]interface{}
  4923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4924. fmt.Println(dat)
  4925. } else {
  4926. fmt.Println(err)
  4927. }
  4928. userJSONBytes, _ := json.Marshal(dat)
  4929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4930. utils.ErrorLog("解析失败:%v", err)
  4931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4932. return
  4933. }
  4934. } else {
  4935. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4936. var dat map[string]interface{}
  4937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4938. fmt.Println(dat)
  4939. } else {
  4940. fmt.Println(err)
  4941. }
  4942. userJSONBytes, _ := json.Marshal(dat)
  4943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4944. utils.ErrorLog("解析失败:%v", err)
  4945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4946. return
  4947. }
  4948. }
  4949. if res.Infcode != 0 {
  4950. c.ServeSuccessJSON(map[string]interface{}{
  4951. "failed_code": -10,
  4952. "msg": res.ErrMsg,
  4953. })
  4954. return
  4955. } else {
  4956. //order.FaPiaoNumber = zero
  4957. //order.FaPiaoCode = last_order.FaPiaoCode
  4958. //service.UpdateOrder(order)
  4959. hisFundSettleListResult := &models.HisFundSettleListResult{
  4960. Number: res.Output.SetlListId,
  4961. Status: 1,
  4962. Ctime: time.Now().Unix(),
  4963. Mtime: time.Now().Unix(),
  4964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4965. IsUpload: 1,
  4966. OrderId: order_id,
  4967. }
  4968. service.CreateUploadRecord(hisFundSettleListResult)
  4969. c.ServeSuccessJSON(map[string]interface{}{
  4970. "msg": "上传成功",
  4971. "result": hisFundSettleListResult,
  4972. })
  4973. return
  4974. }
  4975. }
  4976. func (c *HisApiController) GetSettleListHospital() {
  4977. order_id, _ := c.GetInt64("order_id")
  4978. admin_user_id, _ := c.GetInt64("admin_user_id")
  4979. order, _ := service.GetHisOrderByIDTwo(order_id)
  4980. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4981. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4982. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4983. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4984. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4986. if order.ID == 0 {
  4987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4988. return
  4989. }
  4990. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4991. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4992. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4993. fmt.Println(count)
  4994. var zero string
  4995. number := count + 1
  4996. if number >= 1000 {
  4997. zero = "0000" + strconv.FormatInt(number, 10)
  4998. } else if number >= 10000 {
  4999. zero = "000" + strconv.FormatInt(number, 10)
  5000. } else if number >= 100000 {
  5001. zero = "00" + strconv.FormatInt(number, 10)
  5002. } else if number >= 1000000 {
  5003. zero = "0" + strconv.FormatInt(number, 10)
  5004. } else {
  5005. zero = strconv.FormatInt(number, 10)
  5006. }
  5007. fmt.Println(zero)
  5008. struct4101 := service.Struct4101{
  5009. PsnNo: order.PsnNo,
  5010. MdtrtId: order.MdtrtId,
  5011. SetlId: order.SetlId,
  5012. PsnName: order.PsnName,
  5013. Gend: order.Gend,
  5014. Brdy: his.Brdy,
  5015. Age: int64(order.Age),
  5016. Naty: order.Naty,
  5017. PatnCertType: "01",
  5018. Certno: order.Certno,
  5019. Prfs: "90",
  5020. ConerName: roles[0].UserName,
  5021. PatnRlts: "99",
  5022. ConerAddr: miConfig.OrgName,
  5023. ConerTel: admin.Mobile,
  5024. HiType: order.Insutype,
  5025. Insuplc: miConfig.InsuplcAdmdvs,
  5026. MaindiagFlag: "1",
  5027. BillCode: order.SetlId,
  5028. BillNo: order.SetlId,
  5029. BizSn: order.Number,
  5030. PsnSelfPay: order.PsnPartAmt,
  5031. PsnOwnPay: order.PsnPartAmt,
  5032. AcctPay: order.AcctPay,
  5033. PsnCashpay: order.PsnCashPay,
  5034. HiPaymtd: "1",
  5035. Hsorg: miConfig.InsuplcAdmdvs,
  5036. HsorgOpter: miConfig.InsuplcAdmdvs,
  5037. MedinsFillPsn: curRoles.UserName,
  5038. MedinsFillDept: depart.Name,
  5039. IptMedType: "2",
  5040. AdmTime: his.InHosptialTime,
  5041. AdmEndTime: his.OutHosptialTime,
  5042. }
  5043. struct4101.SetlBegnDate = order.SetlTime
  5044. struct4101.SetlEndDate = order.SetlTime
  5045. var rf []CustomFundPay
  5046. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5047. var tempFunPays []service.CustomStruct
  5048. for _, item := range rf {
  5049. var tempFunPay service.CustomStruct
  5050. tempFunPay.FundPayamt = item.FundPayamt
  5051. tempFunPay.FundPayType = item.FundPayType
  5052. tempFunPays = append(tempFunPays, tempFunPay)
  5053. }
  5054. struct4101.CustomStruct = tempFunPays
  5055. var tempDiaginfos []service.DiaginfoStructTwo
  5056. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5057. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5058. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5059. var config []*models.HisXtDiagnoseConfig
  5060. for _, item := range diagnosis_ids {
  5061. id, _ := strconv.ParseInt(item, 10, 64)
  5062. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5063. config = append(config, &diagnosisConfig)
  5064. }
  5065. for index, item := range config {
  5066. if index == 0 {
  5067. var tempDiaginfo service.DiaginfoStructTwo
  5068. tempDiaginfo.DiagCode = item.CountryCode
  5069. tempDiaginfo.DiagName = item.CountryContentName
  5070. tempDiaginfo.DiagType = "1"
  5071. tempDiaginfo.MaindiagFlag = "1"
  5072. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5073. } else {
  5074. var tempDiaginfo service.DiaginfoStructTwo
  5075. tempDiaginfo.DiagCode = item.CountryCode
  5076. tempDiaginfo.DiagName = item.CountryContentName
  5077. tempDiaginfo.DiagType = "2"
  5078. tempDiaginfo.MaindiagFlag = "0"
  5079. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5080. }
  5081. }
  5082. struct4101.Diseinfo = tempDiaginfos
  5083. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5084. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5085. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5086. tempOpspdiseinfo2.OprnOprtCode = ""
  5087. tempOpspdiseinfo2.OprnOprtName = ""
  5088. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5089. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5090. var iteminfo service.IteminfoStruct
  5091. var bedCostTotal float64 = 0 //床位总费
  5092. var bedCostSelfTotal float64 = 0 //床位自费
  5093. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5094. var operationCostTotal float64 = 0 //手术费
  5095. var operationCostSelfTotal float64 = 0 //手术费
  5096. var operationCostPartSelfTotal float64 = 0 //手术费
  5097. var otherCostTotal float64 = 0 //其他费用
  5098. var otherCostSelfTotal float64 = 0 //其他费用
  5099. var otherCostPartSelfTotal float64 = 0 //其他费用
  5100. var materialCostTotal float64 = 0 //材料费
  5101. var materialCostSelfTotal float64 = 0 //材料费
  5102. var materialCostPartSelfTotal float64 = 0 //材料费
  5103. var westernMedicineCostTotal float64 = 0 //西药费
  5104. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5105. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5106. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5107. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5108. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5109. var checkCostTotal float64 = 0 //检查费
  5110. var checkCostSelfTotal float64 = 0 //检查费
  5111. var checkCostPartSelfTotal float64 = 0 //检查费
  5112. var laboratoryCostTotal float64 = 0 //化验费
  5113. var laboratoryCostSelfTotal float64 = 0 //化验费
  5114. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5115. var treatCostTotal float64 = 0 //治疗费用
  5116. var treatCostSelfTotal float64 = 0 //治疗费用
  5117. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5118. decimal.DivisionPrecision = 2
  5119. var bed_fulamt_ownpay_amt float64 = 0
  5120. var operation_fulamt_ownpay_amt float64 = 0
  5121. var other_fulamt_ownpay_amt float64 = 0
  5122. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5123. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5124. var check_fulamt_ownpay_amt float64 = 0
  5125. var material_fulamt_ownpay_amt float64 = 0
  5126. var laboratory_fulamt_ownpay_amt float64 = 0
  5127. var treat_fulamt_ownpay_amt float64 = 0
  5128. var bed_claa_sunmfee float64 = 0
  5129. var bed_clab_amt float64 = 0
  5130. var bed_other_amt float64 = 0
  5131. var operation_claa_sunmfee float64 = 0
  5132. var operation_clab_amt float64 = 0
  5133. var operation_other_amt float64 = 0
  5134. var other_claa_sunmfee float64 = 0
  5135. var other_clab_amt float64 = 0
  5136. var other_other_amt float64 = 0
  5137. var westernMedicine_claa_sunmfee float64 = 0
  5138. var westernMedicine_clab_amt float64 = 0
  5139. var westernMedicine_other_amt float64 = 0
  5140. var chineseTraditional_claa_sunmfee float64 = 0
  5141. var chineseTraditional_clab_amt float64 = 0
  5142. var chineseTraditional_other_amt float64 = 0
  5143. var check_claa_sunmfee float64 = 0
  5144. var check_clab_amt float64 = 0
  5145. var check_other_amt float64 = 0
  5146. var material_claa_sunmfee float64 = 0
  5147. var material_clab_amt float64 = 0
  5148. var material_other_amt float64 = 0
  5149. var laboratory_claa_sunmfee float64 = 0
  5150. var laboratory_clab_amt float64 = 0
  5151. var laboratory_other_amt float64 = 0
  5152. var treat_claa_sunmfee float64 = 0
  5153. var treat_clab_amt float64 = 0
  5154. var treat_other_amt float64 = 0
  5155. for _, item := range order.HisOrderInfo {
  5156. if item.MedChrgitmType == "01" { //床位费
  5157. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5158. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5159. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5160. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5161. if item.ChrgitmLv == "1" {
  5162. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5163. }
  5164. if item.ChrgitmLv == "2" {
  5165. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5166. }
  5167. if item.ChrgitmLv == "3" {
  5168. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5169. }
  5170. }
  5171. if item.MedChrgitmType == "03" { //检查费
  5172. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5173. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5174. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5175. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5176. if item.ChrgitmLv == "1" {
  5177. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5178. }
  5179. if item.ChrgitmLv == "2" {
  5180. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5181. }
  5182. if item.ChrgitmLv == "3" {
  5183. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5184. }
  5185. }
  5186. if item.MedChrgitmType == "04" { //化验费
  5187. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5188. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5189. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5190. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5191. if item.ChrgitmLv == "1" {
  5192. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5193. }
  5194. if item.ChrgitmLv == "2" {
  5195. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5196. }
  5197. if item.ChrgitmLv == "3" {
  5198. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5199. }
  5200. }
  5201. if item.MedChrgitmType == "05" { //治疗费
  5202. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5203. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5204. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5205. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5206. if item.ChrgitmLv == "1" {
  5207. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5208. }
  5209. if item.ChrgitmLv == "2" {
  5210. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5211. }
  5212. if item.ChrgitmLv == "3" {
  5213. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5214. }
  5215. }
  5216. if item.MedChrgitmType == "06" { //手术费
  5217. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5218. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5219. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5220. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5221. if item.ChrgitmLv == "1" {
  5222. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5223. }
  5224. if item.ChrgitmLv == "2" {
  5225. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5226. }
  5227. if item.ChrgitmLv == "3" {
  5228. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5229. }
  5230. }
  5231. if item.MedChrgitmType == "08" { //材料费
  5232. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5233. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5234. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5235. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5236. if item.ChrgitmLv == "1" {
  5237. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5238. }
  5239. if item.ChrgitmLv == "2" {
  5240. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5241. }
  5242. if item.ChrgitmLv == "3" {
  5243. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5244. }
  5245. }
  5246. if item.MedChrgitmType == "09" { //西药费
  5247. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5248. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5249. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5250. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5251. if item.ChrgitmLv == "1" {
  5252. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5253. }
  5254. if item.ChrgitmLv == "2" {
  5255. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5256. }
  5257. if item.ChrgitmLv == "3" {
  5258. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5259. }
  5260. }
  5261. if item.MedChrgitmType == "11" { //中成费
  5262. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5263. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5264. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5265. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5266. if item.ChrgitmLv == "1" {
  5267. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5268. }
  5269. if item.ChrgitmLv == "2" {
  5270. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5271. }
  5272. if item.ChrgitmLv == "3" {
  5273. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5274. }
  5275. }
  5276. if item.MedChrgitmType == "14" { //其他费
  5277. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5278. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5279. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5280. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5281. if item.ChrgitmLv == "1" {
  5282. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5283. }
  5284. if item.ChrgitmLv == "2" {
  5285. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5286. }
  5287. if item.ChrgitmLv == "3" {
  5288. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5289. }
  5290. }
  5291. }
  5292. var iteminfoStructs []service.IteminfoStruct
  5293. if bedCostTotal != 0 {
  5294. iteminfo.MedChrgitm = "01"
  5295. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5296. iteminfo.Amt = bedCostTotal
  5297. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5298. iteminfo.ClabAmt = bed_clab_amt
  5299. iteminfo.OthAmt = bed_other_amt
  5300. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5301. }
  5302. if checkCostTotal != 0 {
  5303. iteminfo.MedChrgitm = "03"
  5304. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5305. iteminfo.Amt = checkCostTotal
  5306. iteminfo.ClaaSumfee = check_claa_sunmfee
  5307. iteminfo.ClabAmt = check_clab_amt
  5308. iteminfo.OthAmt = check_other_amt
  5309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5310. }
  5311. if laboratoryCostTotal != 0 {
  5312. iteminfo.MedChrgitm = "04"
  5313. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5314. iteminfo.Amt = laboratoryCostTotal
  5315. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5316. iteminfo.ClabAmt = laboratory_clab_amt
  5317. iteminfo.OthAmt = laboratory_other_amt
  5318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5320. }
  5321. if treatCostTotal != 0 {
  5322. iteminfo.MedChrgitm = "05"
  5323. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5324. iteminfo.Amt = treatCostTotal
  5325. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5326. iteminfo.ClabAmt = treat_clab_amt
  5327. iteminfo.OthAmt = treat_other_amt
  5328. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5329. //(struct4101.IteminfoStruct, iteminfo)
  5330. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5331. }
  5332. if operationCostTotal != 0 {
  5333. iteminfo.MedChrgitm = "06"
  5334. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5335. iteminfo.Amt = operationCostTotal
  5336. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5337. iteminfo.ClabAmt = operation_clab_amt
  5338. iteminfo.OthAmt = operation_other_amt
  5339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5341. }
  5342. if materialCostTotal != 0 {
  5343. iteminfo.MedChrgitm = "08"
  5344. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5345. iteminfo.Amt = materialCostTotal
  5346. iteminfo.ClaaSumfee = material_claa_sunmfee
  5347. iteminfo.ClabAmt = material_clab_amt
  5348. iteminfo.OthAmt = material_other_amt
  5349. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5351. }
  5352. if westernMedicineCostTotal != 0 {
  5353. iteminfo.MedChrgitm = "09"
  5354. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5355. iteminfo.Amt = westernMedicineCostTotal
  5356. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5357. iteminfo.ClabAmt = westernMedicine_clab_amt
  5358. iteminfo.OthAmt = westernMedicine_other_amt
  5359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5361. }
  5362. if chineseTraditionalMedicineCostTotal != 0 {
  5363. iteminfo.MedChrgitm = "11"
  5364. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5365. iteminfo.Amt = westernMedicineCostTotal
  5366. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5367. iteminfo.ClabAmt = westernMedicine_clab_amt
  5368. iteminfo.OthAmt = westernMedicine_other_amt
  5369. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5371. }
  5372. if otherCostTotal != 0 {
  5373. iteminfo.MedChrgitm = "14"
  5374. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5375. iteminfo.Amt = otherCostTotal
  5376. iteminfo.ClaaSumfee = other_claa_sunmfee
  5377. iteminfo.ClabAmt = other_clab_amt
  5378. iteminfo.OthAmt = other_other_amt
  5379. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5381. }
  5382. struct4101.IteminfoStruct = iteminfoStructs
  5383. struct4101.Ntly = "中国"
  5384. struct4101.AdmCaty = "A03.06"
  5385. var resOther ResultSeventeenOther
  5386. var res ResultSeventeen
  5387. if miConfig.MdtrtareaAdmvs == "150499" {
  5388. var pp models.PublicParams
  5389. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5390. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5391. pp.FixmedinsName = miConfig.OrgName
  5392. pp.FixmedinsCode = miConfig.Code
  5393. pp.RequestUrl = miConfig.Url
  5394. pp.Cainfo = miConfig.Cainfo
  5395. pp.SecretKey = miConfig.SecretKey
  5396. pp.AccessKey = miConfig.AccessKey
  5397. pp.OpterName = curRoles.UserName
  5398. client := &http.Client{}
  5399. var req *http.Request
  5400. data := make(map[string]interface{})
  5401. data["struct4101"] = struct4101
  5402. data["pp"] = pp
  5403. bytesData, _ := json.Marshal(data)
  5404. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  5405. resp, _ := client.Do(req)
  5406. defer resp.Body.Close()
  5407. body, ioErr := ioutil.ReadAll(resp.Body)
  5408. if ioErr != nil {
  5409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5411. return
  5412. }
  5413. var respJSON map[string]interface{}
  5414. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5420. userJSONBytes, _ := json.Marshal(respJSON)
  5421. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5422. utils.ErrorLog("解析失败:%v", err)
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. res.InfRefmsgid = resOther.InfRefmsgid
  5427. res.Output = resOther.Output
  5428. res.ErrMsg = resOther.ErrMsg
  5429. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5430. res.Infcode = infocode
  5431. } else {
  5432. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5433. var dat map[string]interface{}
  5434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5435. fmt.Println(dat)
  5436. } else {
  5437. fmt.Println(err)
  5438. }
  5439. userJSONBytes, _ := json.Marshal(dat)
  5440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5441. utils.ErrorLog("解析失败:%v", err)
  5442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5443. return
  5444. }
  5445. }
  5446. if res.Infcode != 0 {
  5447. c.ServeSuccessJSON(map[string]interface{}{
  5448. "failed_code": -10,
  5449. "msg": res.ErrMsg,
  5450. })
  5451. return
  5452. } else {
  5453. if miConfig.MdtrtareaAdmvs != "150499" {
  5454. order.FaPiaoNumber = zero
  5455. order.FaPiaoCode = last_order.FaPiaoCode
  5456. service.UpdateOrder(order)
  5457. }
  5458. hisFundSettleListResult := &models.HisFundSettleListResult{
  5459. Number: res.Output.SetlListId,
  5460. Status: 1,
  5461. Ctime: time.Now().Unix(),
  5462. Mtime: time.Now().Unix(),
  5463. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5464. IsUpload: 1,
  5465. OrderId: order_id,
  5466. }
  5467. service.CreateUploadRecord(hisFundSettleListResult)
  5468. c.ServeSuccessJSON(map[string]interface{}{
  5469. "msg": "上传成功",
  5470. "result": hisFundSettleListResult,
  5471. })
  5472. return
  5473. }
  5474. }
  5475. func (c *HisApiController) GetBatchSettleList() {
  5476. orders, _ := service.GetAllHisOrder(10106)
  5477. for _, item := range orders {
  5478. order_id := item.ID
  5479. order, _ := service.GetHisOrderByIDTwo(order_id)
  5480. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5481. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5482. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5483. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  5484. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5486. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5487. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5488. if order.ID == 0 {
  5489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5490. return
  5491. }
  5492. if his.BalanceAccountsType == 2 {
  5493. continue
  5494. }
  5495. struct4101 := service.Struct4101{
  5496. PsnNo: order.PsnNo,
  5497. MdtrtId: order.MdtrtId,
  5498. SetlId: order.SetlId,
  5499. PsnName: order.PsnName,
  5500. Gend: order.Gend,
  5501. Brdy: his.Brdy,
  5502. Age: his.Age,
  5503. Naty: order.Naty,
  5504. PatnCertType: "01",
  5505. Certno: order.Certno,
  5506. Prfs: "90",
  5507. ConerName: roles[0].UserName,
  5508. PatnRlts: "99",
  5509. ConerAddr: miConfig.OrgName,
  5510. ConerTel: admin.Mobile,
  5511. HiType: order.Insutype,
  5512. Insuplc: his.InsuplcAdmdvs,
  5513. MaindiagFlag: "1",
  5514. BillCode: order.SetlId,
  5515. BillNo: order.SetlId,
  5516. BizSn: order.Number,
  5517. PsnSelfPay: order.PsnPartAmt,
  5518. PsnOwnPay: order.PsnPartAmt,
  5519. AcctPay: order.AcctPay,
  5520. PsnCashpay: order.PsnCashPay,
  5521. HiPaymtd: "1",
  5522. Hsorg: his.InsuplcAdmdvs,
  5523. HsorgOpter: his.InsuplcAdmdvs,
  5524. MedinsFillPsn: curRoles.UserName,
  5525. MedinsFillDept: depart.Name,
  5526. IptMedType: "2",
  5527. }
  5528. struct4101.SetlBegnDate = order.SetlTime
  5529. struct4101.SetlEndDate = order.SetlTime
  5530. //if order.SettleType == 1 {
  5531. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5532. // dateStr := t.Format("2006-01-02")
  5533. // struct4101.SetlBegnDate = dateStr
  5534. // struct4101.SetlEndDate = dateStr
  5535. //} else {
  5536. // t := time.Unix(int64(order.SettleStartTime), 0)
  5537. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5538. // dateStartStr := t.Format("2006-01-02")
  5539. // dateEndStr := t2.Format("2006-01-02")
  5540. // struct4101.SetlBegnDate = dateStartStr
  5541. // struct4101.SetlEndDate = dateEndStr
  5542. //}
  5543. var rf []CustomFundPay
  5544. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5545. var tempFunPays []service.CustomStruct
  5546. var tempFunPay610100 service.CustomStruct
  5547. for _, item := range rf {
  5548. if item.FundPayType == "610100" {
  5549. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5550. tempFunPay610100.FundPayType = item.FundPayType
  5551. } else {
  5552. var tempFunPay service.CustomStruct
  5553. tempFunPay.FundPayamt = item.FundPayamt
  5554. tempFunPay.FundPayType = item.FundPayType
  5555. tempFunPays = append(tempFunPays, tempFunPay)
  5556. }
  5557. }
  5558. tempFunPays = append(tempFunPays, tempFunPay610100)
  5559. struct4101.CustomStruct = tempFunPays
  5560. var tempDiaginfos []service.DiaginfoStructTwo
  5561. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5562. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5563. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5564. var config []*models.HisXtDiagnoseConfig
  5565. for _, item := range diagnosis_ids {
  5566. id, _ := strconv.ParseInt(item, 10, 64)
  5567. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5568. config = append(config, &diagnosisConfig)
  5569. }
  5570. for index, item := range config {
  5571. if index == 0 {
  5572. var tempDiaginfo service.DiaginfoStructTwo
  5573. tempDiaginfo.DiagCode = item.CountryCode
  5574. tempDiaginfo.DiagName = item.CountryContentName
  5575. tempDiaginfo.DiagType = "1"
  5576. tempDiaginfo.MaindiagFlag = "1"
  5577. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5578. } else {
  5579. var tempDiaginfo service.DiaginfoStructTwo
  5580. tempDiaginfo.DiagCode = item.CountryCode
  5581. tempDiaginfo.DiagName = item.CountryContentName
  5582. tempDiaginfo.DiagType = "2"
  5583. tempDiaginfo.MaindiagFlag = "0"
  5584. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5585. }
  5586. }
  5587. struct4101.Diseinfo = tempDiaginfos
  5588. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5589. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5590. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5591. tempOpspdiseinfo2.OprnOprtCode = ""
  5592. tempOpspdiseinfo2.OprnOprtName = ""
  5593. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5594. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5595. var iteminfo service.IteminfoStruct
  5596. var bedCostTotal float64 = 0 //床位总费
  5597. var bedCostSelfTotal float64 = 0 //床位自费
  5598. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5599. var examineCostTotal float64 = 0 //诊查总费
  5600. var examineCostSelfTotal float64 = 0 //诊查自费
  5601. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5602. var nursingCostTotal float64 = 0 //护理总费
  5603. var nursingCostSelfTotal float64 = 0 //护理自费
  5604. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5605. var chineseMedicineCostTotal float64 = 0 //中成药
  5606. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5607. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5608. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5609. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5610. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5611. var registerCostTotal float64 = 0 //一般诊疗费
  5612. var registerCostSelfTotal float64 = 0 //一般诊疗费
  5613. var registerPartSelfTotal float64 = 0 //一般诊疗费
  5614. var operationCostTotal float64 = 0 //手术费
  5615. var operationCostSelfTotal float64 = 0 //手术费
  5616. var operationCostPartSelfTotal float64 = 0 //手术费
  5617. var otherCostTotal float64 = 0 //其他费用
  5618. var otherCostSelfTotal float64 = 0 //其他费用
  5619. var otherCostPartSelfTotal float64 = 0 //其他费用
  5620. var materialCostTotal float64 = 0 //材料费
  5621. var materialCostSelfTotal float64 = 0 //材料费
  5622. var materialCostPartSelfTotal float64 = 0 //材料费
  5623. var westernMedicineCostTotal float64 = 0 //西药费
  5624. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5625. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5626. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5627. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5628. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5629. var checkCostTotal float64 = 0 //检查费
  5630. var checkCostSelfTotal float64 = 0 //检查费
  5631. var checkCostPartSelfTotal float64 = 0 //检查费
  5632. var laboratoryCostTotal float64 = 0 //化验费
  5633. var laboratoryCostSelfTotal float64 = 0 //化验费
  5634. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5635. var treatCostTotal float64 = 0 //治疗费用
  5636. var treatCostSelfTotal float64 = 0 //治疗费用
  5637. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5638. decimal.DivisionPrecision = 2
  5639. var bed_fulamt_ownpay_amt float64 = 0
  5640. var examine_fulamt_ownpay_amt float64 = 0
  5641. var nursing_fulamt_ownpay_amt float64 = 0
  5642. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  5643. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  5644. var register_fulamt_ownpay_amt float64 = 0
  5645. var operation_fulamt_ownpay_amt float64 = 0
  5646. var other_fulamt_ownpay_amt float64 = 0
  5647. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5648. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5649. var check_fulamt_ownpay_amt float64 = 0
  5650. var material_fulamt_ownpay_amt float64 = 0
  5651. var laboratory_fulamt_ownpay_amt float64 = 0
  5652. var treat_fulamt_ownpay_amt float64 = 0
  5653. var bed_claa_sunmfee float64 = 0
  5654. var bed_clab_amt float64 = 0
  5655. var bed_other_amt float64 = 0
  5656. var examine_claa_sunmfee float64 = 0
  5657. var examine_clab_amt float64 = 0
  5658. var examine_other_amt float64 = 0
  5659. var nursing_claa_sunmfee float64 = 0
  5660. var nursing_clab_amt float64 = 0
  5661. var nursing_other_amt float64 = 0
  5662. var chinese_medicine_claa_sunmfee float64 = 0
  5663. var chinese_medicine_clab_amt float64 = 0
  5664. var chinese_medicine_other_amt float64 = 0
  5665. var commonly_treatment_claa_sunmfee float64 = 0
  5666. var commonly_treatment_clab_amt float64 = 0
  5667. var commonly_treatment_other_amt float64 = 0
  5668. var operation_claa_sunmfee float64 = 0
  5669. var operation_clab_amt float64 = 0
  5670. var operation_other_amt float64 = 0
  5671. var other_claa_sunmfee float64 = 0
  5672. var other_clab_amt float64 = 0
  5673. var other_other_amt float64 = 0
  5674. var westernMedicine_claa_sunmfee float64 = 0
  5675. var westernMedicine_clab_amt float64 = 0
  5676. var westernMedicine_other_amt float64 = 0
  5677. var chineseTraditional_claa_sunmfee float64 = 0
  5678. var chineseTraditional_clab_amt float64 = 0
  5679. var chineseTraditional_other_amt float64 = 0
  5680. var check_claa_sunmfee float64 = 0
  5681. var check_clab_amt float64 = 0
  5682. var check_other_amt float64 = 0
  5683. var material_claa_sunmfee float64 = 0
  5684. var material_clab_amt float64 = 0
  5685. var material_other_amt float64 = 0
  5686. var laboratory_claa_sunmfee float64 = 0
  5687. var laboratory_clab_amt float64 = 0
  5688. var laboratory_other_amt float64 = 0
  5689. var treat_claa_sunmfee float64 = 0
  5690. var treat_clab_amt float64 = 0
  5691. var treat_other_amt float64 = 0
  5692. var register_claa_sunmfee float64 = 0
  5693. var register_clab_amt float64 = 0
  5694. var register_other_amt float64 = 0
  5695. for _, item := range order.HisOrderInfo {
  5696. if item.MedChrgitmType == "01" { //床位费
  5697. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5698. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5699. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5700. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5701. if item.ChrgitmLv == "1" {
  5702. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5703. }
  5704. if item.ChrgitmLv == "2" {
  5705. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5706. }
  5707. if item.ChrgitmLv == "3" {
  5708. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5709. }
  5710. }
  5711. if item.MedChrgitmType == "02" { //诊查
  5712. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5713. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5714. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5715. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5716. if item.ChrgitmLv == "1" {
  5717. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5718. }
  5719. if item.ChrgitmLv == "2" {
  5720. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5721. }
  5722. if item.ChrgitmLv == "3" {
  5723. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5724. }
  5725. }
  5726. if item.MedChrgitmType == "03" { //检查费
  5727. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5728. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5729. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5730. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5731. if item.ChrgitmLv == "1" {
  5732. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5733. }
  5734. if item.ChrgitmLv == "2" {
  5735. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5736. }
  5737. if item.ChrgitmLv == "3" {
  5738. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5739. }
  5740. }
  5741. if item.MedChrgitmType == "04" { //化验费
  5742. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5743. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5744. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5745. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5746. if item.ChrgitmLv == "1" {
  5747. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5748. }
  5749. if item.ChrgitmLv == "2" {
  5750. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5751. }
  5752. if item.ChrgitmLv == "3" {
  5753. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5754. }
  5755. }
  5756. if item.MedChrgitmType == "05" { //治疗费
  5757. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5758. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5759. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5760. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5761. if item.ChrgitmLv == "1" {
  5762. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5763. }
  5764. if item.ChrgitmLv == "2" {
  5765. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5766. }
  5767. if item.ChrgitmLv == "3" {
  5768. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5769. }
  5770. }
  5771. if item.MedChrgitmType == "06" { //手术费
  5772. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5773. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5774. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5775. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5776. if item.ChrgitmLv == "1" {
  5777. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5778. }
  5779. if item.ChrgitmLv == "2" {
  5780. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5781. }
  5782. if item.ChrgitmLv == "3" {
  5783. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5784. }
  5785. }
  5786. if item.MedChrgitmType == "07" { //手术费
  5787. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5788. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5789. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5790. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5791. if item.ChrgitmLv == "1" {
  5792. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5793. }
  5794. if item.ChrgitmLv == "2" {
  5795. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5796. }
  5797. if item.ChrgitmLv == "3" {
  5798. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5799. }
  5800. }
  5801. if item.MedChrgitmType == "08" { //材料费
  5802. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5803. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5804. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5805. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5806. if item.ChrgitmLv == "1" {
  5807. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5808. }
  5809. if item.ChrgitmLv == "2" {
  5810. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5811. }
  5812. if item.ChrgitmLv == "3" {
  5813. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5814. }
  5815. }
  5816. if item.MedChrgitmType == "09" { //西药费
  5817. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5818. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5819. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5820. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5821. if item.ChrgitmLv == "1" {
  5822. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5823. }
  5824. if item.ChrgitmLv == "2" {
  5825. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5826. }
  5827. if item.ChrgitmLv == "3" {
  5828. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5829. }
  5830. }
  5831. if item.MedChrgitmType == "10" { //中药饮片
  5832. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5833. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5834. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5835. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5836. if item.ChrgitmLv == "1" {
  5837. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5838. }
  5839. if item.ChrgitmLv == "2" {
  5840. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5841. }
  5842. if item.ChrgitmLv == "3" {
  5843. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5844. }
  5845. }
  5846. if item.MedChrgitmType == "11" { //中成费
  5847. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5848. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5849. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5850. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5851. if item.ChrgitmLv == "1" {
  5852. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5853. }
  5854. if item.ChrgitmLv == "2" {
  5855. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5856. }
  5857. if item.ChrgitmLv == "3" {
  5858. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5859. }
  5860. }
  5861. if item.MedChrgitmType == "12" { //中成费
  5862. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5863. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5864. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5865. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5866. if item.ChrgitmLv == "1" {
  5867. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5868. }
  5869. if item.ChrgitmLv == "2" {
  5870. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5871. }
  5872. if item.ChrgitmLv == "3" {
  5873. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5874. }
  5875. }
  5876. if item.MedChrgitmType == "13" { //中成费
  5877. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5878. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5879. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5880. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5881. if item.ChrgitmLv == "1" {
  5882. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5883. }
  5884. if item.ChrgitmLv == "2" {
  5885. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5886. }
  5887. if item.ChrgitmLv == "3" {
  5888. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5889. }
  5890. }
  5891. if item.MedChrgitmType == "14" { //其他费
  5892. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5893. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5894. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5895. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5896. if item.ChrgitmLv == "1" {
  5897. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5898. }
  5899. if item.ChrgitmLv == "2" {
  5900. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5901. }
  5902. if item.ChrgitmLv == "3" {
  5903. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5904. }
  5905. }
  5906. }
  5907. var iteminfoStructs []service.IteminfoStruct
  5908. if bedCostTotal != 0 {
  5909. iteminfo.MedChrgitm = "01"
  5910. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5911. iteminfo.Amt = bedCostTotal
  5912. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5913. iteminfo.ClabAmt = bed_clab_amt
  5914. iteminfo.OthAmt = bed_other_amt
  5915. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5916. }
  5917. if examineCostTotal != 0 {
  5918. iteminfo.MedChrgitm = "02"
  5919. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5920. iteminfo.Amt = examineCostTotal
  5921. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5922. iteminfo.ClabAmt = examine_clab_amt
  5923. iteminfo.OthAmt = examine_other_amt
  5924. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5925. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5926. }
  5927. if checkCostTotal != 0 {
  5928. iteminfo.MedChrgitm = "03"
  5929. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5930. iteminfo.Amt = checkCostTotal
  5931. iteminfo.ClaaSumfee = check_claa_sunmfee
  5932. iteminfo.ClabAmt = check_clab_amt
  5933. iteminfo.OthAmt = check_other_amt
  5934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5935. }
  5936. if laboratoryCostTotal != 0 {
  5937. iteminfo.MedChrgitm = "04"
  5938. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5939. iteminfo.Amt = laboratoryCostTotal
  5940. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5941. iteminfo.ClabAmt = laboratory_clab_amt
  5942. iteminfo.OthAmt = laboratory_other_amt
  5943. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5944. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5945. }
  5946. if treatCostTotal != 0 {
  5947. iteminfo.MedChrgitm = "05"
  5948. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5949. iteminfo.Amt = treatCostTotal
  5950. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5951. iteminfo.ClabAmt = treat_clab_amt
  5952. iteminfo.OthAmt = treat_other_amt
  5953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5954. //(struct4101.IteminfoStruct, iteminfo)
  5955. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5956. }
  5957. if operationCostTotal != 0 {
  5958. iteminfo.MedChrgitm = "06"
  5959. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5960. iteminfo.Amt = operationCostTotal
  5961. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5962. iteminfo.ClabAmt = operation_clab_amt
  5963. iteminfo.OthAmt = operation_other_amt
  5964. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5965. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5966. }
  5967. if nursingCostTotal != 0 {
  5968. iteminfo.MedChrgitm = "07"
  5969. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5970. iteminfo.Amt = nursingCostTotal
  5971. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5972. iteminfo.ClabAmt = nursing_clab_amt
  5973. iteminfo.OthAmt = nursing_other_amt
  5974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5975. }
  5976. if materialCostTotal != 0 {
  5977. iteminfo.MedChrgitm = "08"
  5978. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5979. iteminfo.Amt = materialCostTotal
  5980. iteminfo.ClaaSumfee = material_claa_sunmfee
  5981. iteminfo.ClabAmt = material_clab_amt
  5982. iteminfo.OthAmt = material_other_amt
  5983. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5984. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5985. }
  5986. if westernMedicineCostTotal != 0 {
  5987. iteminfo.MedChrgitm = "09"
  5988. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5989. iteminfo.Amt = westernMedicineCostTotal
  5990. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5991. iteminfo.ClabAmt = westernMedicine_clab_amt
  5992. iteminfo.OthAmt = westernMedicine_other_amt
  5993. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5994. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5995. }
  5996. if chineseMedicineCostTotal != 0 {
  5997. iteminfo.MedChrgitm = "10"
  5998. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5999. iteminfo.Amt = chineseMedicineCostTotal
  6000. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6001. iteminfo.ClabAmt = chinese_medicine_clab_amt
  6002. iteminfo.OthAmt = chinese_medicine_other_amt
  6003. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6004. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6005. }
  6006. if chineseTraditionalMedicineCostTotal != 0 {
  6007. iteminfo.MedChrgitm = "11"
  6008. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6009. iteminfo.Amt = westernMedicineCostTotal
  6010. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6011. iteminfo.ClabAmt = westernMedicine_clab_amt
  6012. iteminfo.OthAmt = westernMedicine_other_amt
  6013. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6014. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6015. }
  6016. if commonlyTreatmentCostTotal != 0 {
  6017. iteminfo.MedChrgitm = "12"
  6018. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6019. iteminfo.Amt = commonlyTreatmentCostTotal
  6020. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6021. iteminfo.ClabAmt = commonly_treatment_clab_amt
  6022. iteminfo.OthAmt = commonly_treatment_other_amt
  6023. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6024. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6025. }
  6026. if registerCostTotal != 0 {
  6027. iteminfo.MedChrgitm = "13"
  6028. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  6029. iteminfo.Amt = registerCostTotal
  6030. iteminfo.ClaaSumfee = register_claa_sunmfee
  6031. iteminfo.ClabAmt = register_clab_amt
  6032. iteminfo.OthAmt = register_other_amt
  6033. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6034. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6035. }
  6036. if otherCostTotal != 0 {
  6037. iteminfo.MedChrgitm = "14"
  6038. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6039. iteminfo.Amt = otherCostTotal
  6040. iteminfo.ClaaSumfee = other_claa_sunmfee
  6041. iteminfo.ClabAmt = other_clab_amt
  6042. iteminfo.OthAmt = other_other_amt
  6043. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6044. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6045. }
  6046. struct4101.IteminfoStruct = iteminfoStructs
  6047. time_arr := strings.Split(order.SetlTime, " ")
  6048. struct4101.AdmTime = time_arr[0]
  6049. struct4101.AdmEndTime = time_arr[0]
  6050. struct4101.DoctorName = doctor.UserName
  6051. struct4101.DoctorCode = doctor.DoctorNumber
  6052. struct4101.Ntly = "中国"
  6053. struct4101.AdmCaty = "A03.06"
  6054. var res ResultSeventeen
  6055. if miConfig.MdtrtareaAdmvs == "421300" {
  6056. data := make(map[string]interface{})
  6057. data["struct4101"] = struct4101
  6058. data["secret_key"] = miConfig.SecretKey
  6059. data["org_name"] = miConfig.OrgName
  6060. data["opera"] = curRoles.UserName
  6061. data["code"] = miConfig.Code
  6062. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6063. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6064. client := &http.Client{}
  6065. bytesData, _ := json.Marshal(data)
  6066. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  6067. resp, _ := client.Do(req)
  6068. defer resp.Body.Close()
  6069. body, ioErr := ioutil.ReadAll(resp.Body)
  6070. if ioErr != nil {
  6071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6073. return
  6074. }
  6075. var respJSON map[string]interface{}
  6076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6079. return
  6080. }
  6081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6082. userJSONBytes, _ := json.Marshal(respJSON)
  6083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6084. utils.ErrorLog("解析失败:%v", err)
  6085. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6086. adminUser := c.GetAdminUserInfo()
  6087. errlog := &models.HisOrderError{
  6088. UserOrgId: adminUser.CurrentOrgId,
  6089. Ctime: time.Now().Unix(),
  6090. Mtime: time.Now().Unix(),
  6091. ErrMsg: res.ErrMsg + "解析失败",
  6092. Status: 1,
  6093. PatientId: order_id,
  6094. Stage: 10088,
  6095. }
  6096. service.CreateErrMsgLog(errlog)
  6097. continue
  6098. }
  6099. } else {
  6100. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  6101. fmt.Println(result)
  6102. var dat map[string]interface{}
  6103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6104. fmt.Println(dat)
  6105. } else {
  6106. fmt.Println(err)
  6107. }
  6108. userJSONBytes, _ := json.Marshal(dat)
  6109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6110. utils.ErrorLog("解析失败:%v", err)
  6111. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6112. adminUser := c.GetAdminUserInfo()
  6113. errlog := &models.HisOrderError{
  6114. UserOrgId: adminUser.CurrentOrgId,
  6115. Ctime: time.Now().Unix(),
  6116. Mtime: time.Now().Unix(),
  6117. ErrMsg: res.ErrMsg + "解析失败",
  6118. Status: 1,
  6119. PatientId: order_id,
  6120. Stage: 10106,
  6121. }
  6122. service.CreateErrMsgLog(errlog)
  6123. continue
  6124. }
  6125. }
  6126. if res.Infcode != 0 {
  6127. adminUser := c.GetAdminUserInfo()
  6128. errlog := &models.HisOrderError{
  6129. UserOrgId: adminUser.CurrentOrgId,
  6130. Ctime: time.Now().Unix(),
  6131. Mtime: time.Now().Unix(),
  6132. ErrMsg: res.ErrMsg,
  6133. Status: 1,
  6134. PatientId: order_id,
  6135. Stage: 10106,
  6136. }
  6137. service.CreateErrMsgLog(errlog)
  6138. continue
  6139. } else {
  6140. hisFundSettleListResult := &models.HisFundSettleListResult{
  6141. Number: res.Output.SetlListId,
  6142. Status: 1,
  6143. Ctime: time.Now().Unix(),
  6144. Mtime: time.Now().Unix(),
  6145. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6146. IsUpload: 1,
  6147. OrderId: order_id,
  6148. }
  6149. service.CreateUploadRecord(hisFundSettleListResult)
  6150. continue
  6151. }
  6152. }
  6153. }
  6154. func (c *HisApiController) GetOrgInfo() {
  6155. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  6156. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  6157. }
  6158. func (c *HisApiController) GetHisPatientInfo() {
  6159. medical_insurance_card := c.GetString("medical_insurance_card")
  6160. id_card_type, _ := c.GetInt64("id_card_type")
  6161. id_card := c.GetString("id_card")
  6162. adminInfo := c.GetAdminUserInfo()
  6163. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6164. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6165. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  6166. IdCardNo := ""
  6167. if id_card_type == 1 {
  6168. IdCardNo = medical_insurance_card
  6169. } else if id_card_type == 2 {
  6170. IdCardNo = id_card
  6171. }
  6172. if config.IsOpen == 1 {
  6173. 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
  6174. resp, requestErr := http.Get(api)
  6175. if requestErr != nil {
  6176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6177. return
  6178. }
  6179. defer resp.Body.Close()
  6180. body, ioErr := ioutil.ReadAll(resp.Body)
  6181. if ioErr != nil {
  6182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6184. return
  6185. }
  6186. var respJSON map[string]interface{}
  6187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6190. return
  6191. }
  6192. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6193. userJSONBytes, _ := json.Marshal(userJSON)
  6194. var res ResultTwo
  6195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6196. utils.ErrorLog("解析失败:%v", err)
  6197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6198. return
  6199. }
  6200. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6201. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6202. infoStr := string(Iinfos)
  6203. idetinfoStr := string(Idetinfos)
  6204. if res.Infcode == 0 {
  6205. his := models.VMHisPatient{
  6206. Status: 1,
  6207. Ctime: time.Now().Unix(),
  6208. Mtime: time.Now().Unix(),
  6209. PsnNo: res.Output.Baseinfo.PsnNo,
  6210. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6211. Certno: res.Output.Baseinfo.Certno,
  6212. PsnName: res.Output.Baseinfo.PsnName,
  6213. Gend: res.Output.Baseinfo.Gend,
  6214. Naty: res.Output.Baseinfo.Naty,
  6215. Brdy: res.Output.Baseinfo.Brdy,
  6216. Age: res.Output.Baseinfo.Age,
  6217. Iinfo: infoStr,
  6218. Idetinfo: idetinfoStr,
  6219. UserOrgId: adminInfo.CurrentOrgId,
  6220. IsReturn: 1,
  6221. IdCardType: id_card_type,
  6222. }
  6223. c.ServeSuccessJSON(map[string]interface{}{
  6224. "info": his,
  6225. })
  6226. } else {
  6227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6228. return
  6229. }
  6230. }
  6231. }
  6232. //func GetBasBaseInfo() (jsonStr string, err error) {
  6233. //
  6234. // handle := syscall.NewLazyDLL("SSCard.dll")
  6235. // add := handle.NewProc("ReadCardBas")
  6236. // str := make([]byte, 1024)
  6237. // str1 := make([]byte, 1024)
  6238. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6239. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  6240. //
  6241. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  6242. //
  6243. // fmt.Println("> Add(4,5)的结果为:", ret)
  6244. // handle.Release()
  6245. //
  6246. // return "", nil
  6247. //
  6248. //}
  6249. //func GetQRBaseInfo() (jsonStr string, err error) {
  6250. // handle := syscall.LoadDLL("SSCard.dll")
  6251. // ReadCardBas := handle.FindProc("GetQRBase")
  6252. //
  6253. // str := make([]byte, 256)
  6254. // str1 := make([]byte, 256)
  6255. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6256. //
  6257. // fmt.Println(string(str))
  6258. // fmt.Println(r)
  6259. // return string(str), nil
  6260. //}
  6261. //func CardInit() int {
  6262. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  6263. // add := DllTestDef.MustFindProc("Init")
  6264. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6265. // if err != nil {
  6266. // fmt.Println("SSCard的运算结果为:", ret)
  6267. // }
  6268. // result := int(ret)
  6269. // return result
  6270. //}
  6271. //func CardInit() int {
  6272. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6273. // if err != nil {
  6274. // fmt.Println("SSCard的运算结果为:", ret)
  6275. // }
  6276. // fmt.Println(err)
  6277. // result := int(ret)
  6278. // return result
  6279. //}
  6280. func IntPtr(n int) uintptr {
  6281. return uintptr(n)
  6282. }
  6283. func StrPtr(s string) uintptr {
  6284. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6285. }
  6286. type Result2001 struct {
  6287. Cainfo interface{} `json:"cainfo"`
  6288. ErrMsg string `json:"err_msg"`
  6289. InfRefmsgid string `json:"inf_refmsgid"`
  6290. Infcode int64 `json:"infcode"`
  6291. Output struct {
  6292. Trtinfo struct {
  6293. PsnNo string `json:"psn_no"`
  6294. TrtChkType string `json:"trt_chk_type"`
  6295. FundPayType string `json:"fund_pay_type"`
  6296. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6297. Begndate string `json:"begndate"`
  6298. Enddate string `json:"enddate"`
  6299. TrtChkRslt string `json:"trt_chk_rslt"`
  6300. } `json:"trtinfo"`
  6301. } `json:"output"`
  6302. RefmsgTime string `json:"refmsg_time"`
  6303. RespondTime string `json:"respond_time"`
  6304. Signtype interface{} `json:"signtype"`
  6305. WarnMsg interface{} `json:"warn_msg"`
  6306. }
  6307. type Result2001Org10265 struct {
  6308. Cainfo interface{} `json:"cainfo"`
  6309. ErrMsg string `json:"err_msg"`
  6310. InfRefmsgid string `json:"inf_refmsgid"`
  6311. Infcode string `json:"infcode"`
  6312. Output struct {
  6313. Trtinfo struct {
  6314. PsnNo string `json:"psn_no"`
  6315. TrtChkType string `json:"trt_chk_type"`
  6316. FundPayType string `json:"fund_pay_type"`
  6317. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6318. Begndate string `json:"begndate"`
  6319. Enddate string `json:"enddate"`
  6320. TrtChkRslt string `json:"trt_chk_rslt"`
  6321. } `json:"trtinfo"`
  6322. } `json:"output"`
  6323. RefmsgTime string `json:"refmsg_time"`
  6324. RespondTime string `json:"respond_time"`
  6325. Signtype interface{} `json:"signtype"`
  6326. WarnMsg interface{} `json:"warn_msg"`
  6327. }
  6328. type ResultTwo struct {
  6329. ErrMsg string `json:"err_msg"`
  6330. InfRefmsgid string `json:"inf_refmsgid"`
  6331. Infcode int64 `json:"infcode"`
  6332. Output struct {
  6333. Baseinfo struct {
  6334. Age float64 `json:"age"`
  6335. Brdy string `json:"brdy"`
  6336. Certno string `json:"certno"`
  6337. Gend string `json:"gend"`
  6338. Naty string `json:"naty"`
  6339. PsnCertType string `json:"psn_cert_type"`
  6340. PsnName string `json:"psn_name"`
  6341. PsnNo string `json:"psn_no"`
  6342. } `json:"baseinfo"`
  6343. Idetinfo []interface{} `json:"idetinfo"`
  6344. Iinfo []struct {
  6345. Balc float64 `json:"balc"`
  6346. CvlservFlag string `json:"cvlserv_flag"`
  6347. EmpName string `json:"emp_name"`
  6348. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6349. Insutype string `json:"insutype"`
  6350. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6351. PausInsuDate string `json:"paus_insu_date"`
  6352. PsnInsuDate string `json:"psn_insu_date"`
  6353. PsnInsuStas string `json:"psn_insu_stas"`
  6354. PsnType string `json:"psn_type"`
  6355. } `json:"insuinfo"`
  6356. } `json:"output"`
  6357. RefmsgTime string `json:"refmsg_time"`
  6358. RespondTime string `json:"respond_time"`
  6359. Signtype interface{} `json:"signtype"`
  6360. WarnInfo interface{} `json:"warn_info"`
  6361. }
  6362. type ResultTwo10265 struct {
  6363. ErrMsg string `json:"err_msg"`
  6364. InfRefmsgid string `json:"inf_refmsgid"`
  6365. Infcode string `json:"infcode"`
  6366. Output struct {
  6367. Baseinfo struct {
  6368. Age float64 `json:"age"`
  6369. Brdy string `json:"brdy"`
  6370. Certno string `json:"certno"`
  6371. Gend string `json:"gend"`
  6372. Naty string `json:"naty"`
  6373. PsnCertType string `json:"psn_cert_type"`
  6374. PsnName string `json:"psn_name"`
  6375. PsnNo string `json:"psn_no"`
  6376. } `json:"baseinfo"`
  6377. Idetinfo []interface{} `json:"idetinfo"`
  6378. Iinfo []struct {
  6379. Balc float64 `json:"balc"`
  6380. CvlservFlag string `json:"cvlserv_flag"`
  6381. EmpName string `json:"emp_name"`
  6382. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6383. Insutype string `json:"insutype"`
  6384. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6385. PausInsuDate string `json:"paus_insu_date"`
  6386. PsnInsuDate string `json:"psn_insu_date"`
  6387. PsnInsuStas string `json:"psn_insu_stas"`
  6388. PsnType string `json:"psn_type"`
  6389. } `json:"insuinfo"`
  6390. } `json:"output"`
  6391. RefmsgTime string `json:"refmsg_time"`
  6392. RespondTime string `json:"respond_time"`
  6393. Signtype interface{} `json:"signtype"`
  6394. WarnInfo interface{} `json:"warn_info"`
  6395. }
  6396. type ResultThree struct {
  6397. Cainfo interface{} `json:"cainfo"`
  6398. ErrMsg string `json:"err_msg"`
  6399. InfRefmsgid string `json:"inf_refmsgid"`
  6400. Infcode int64 `json:"infcode"`
  6401. Output struct {
  6402. Data struct {
  6403. IptOtpNo string `json:"ipt_otp_no"`
  6404. MdtrtID string `json:"mdtrt_id"`
  6405. PsnNo string `json:"psn_no"`
  6406. } `json:"data"`
  6407. } `json:"output"`
  6408. RefmsgTime string `json:"refmsg_time"`
  6409. RespondTime string `json:"respond_time"`
  6410. Signtype interface{} `json:"signtype"`
  6411. WarnMsg interface{} `json:"warn_msg"`
  6412. }
  6413. type ResultThree10265 struct {
  6414. Cainfo interface{} `json:"cainfo"`
  6415. ErrMsg string `json:"err_msg"`
  6416. InfRefmsgid string `json:"inf_refmsgid"`
  6417. Infcode string `json:"infcode"`
  6418. Output struct {
  6419. Data struct {
  6420. IptOtpNo string `json:"ipt_otp_no"`
  6421. MdtrtID string `json:"mdtrt_id"`
  6422. PsnNo string `json:"psn_no"`
  6423. } `json:"data"`
  6424. } `json:"output"`
  6425. RefmsgTime string `json:"refmsg_time"`
  6426. RespondTime string `json:"respond_time"`
  6427. Signtype interface{} `json:"signtype"`
  6428. WarnMsg interface{} `json:"warn_msg"`
  6429. }
  6430. type ResultFour struct {
  6431. Cainfo string `json:"cainfo"`
  6432. ErrMsg string `json:"err_msg"`
  6433. InfRefmsgid string `json:"inf_refmsgid"`
  6434. Infcode int64 `json:"infcode"`
  6435. Output struct {
  6436. Result []struct {
  6437. BasMednFlag string `json:"bas_medn_flag"`
  6438. ChldMedcFlag string `json:"chld_medc_flag"`
  6439. ChrgitmLv string `json:"chrgitm_lv"`
  6440. Cnt float64 `json:"cnt"`
  6441. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6442. DrtReimFlag string `json:"drt_reim_flag"`
  6443. FeedetlSn string `json:"feedetl_sn"`
  6444. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6445. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6446. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6447. ListSpItemFlag string `json:"list_sp_item_flag"`
  6448. LmtUsedFlag string `json:"lmt_used_flag"`
  6449. MedChrgitmType string `json:"med_chrgitm_type"`
  6450. Memo string `json:"memo"`
  6451. OverlmtAmt float64 `json:"overlmt_amt"`
  6452. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6453. Pric float64 `json:"pric"`
  6454. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6455. SelfpayProp float64 `json:"selfpay_prop"`
  6456. } `json:"result"`
  6457. } `json:"output"`
  6458. RefmsgTime string `json:"refmsg_time"`
  6459. RespondTime string `json:"respond_time"`
  6460. Signtype string `json:"signtype"`
  6461. WarnMsg string `json:"warn_msg"`
  6462. }
  6463. type ResultFour10265 struct {
  6464. Cainfo string `json:"cainfo"`
  6465. ErrMsg string `json:"err_msg"`
  6466. InfRefmsgid string `json:"inf_refmsgid"`
  6467. Infcode string `json:"infcode"`
  6468. Output struct {
  6469. Result []struct {
  6470. BasMednFlag string `json:"bas_medn_flag"`
  6471. ChldMedcFlag string `json:"chld_medc_flag"`
  6472. ChrgitmLv string `json:"chrgitm_lv"`
  6473. Cnt float64 `json:"cnt"`
  6474. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6475. DrtReimFlag string `json:"drt_reim_flag"`
  6476. FeedetlSn string `json:"feedetl_sn"`
  6477. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6478. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6479. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6480. ListSpItemFlag string `json:"list_sp_item_flag"`
  6481. LmtUsedFlag string `json:"lmt_used_flag"`
  6482. MedChrgitmType string `json:"med_chrgitm_type"`
  6483. Memo string `json:"memo"`
  6484. OverlmtAmt float64 `json:"overlmt_amt"`
  6485. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6486. Pric float64 `json:"pric"`
  6487. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6488. SelfpayProp float64 `json:"selfpay_prop"`
  6489. } `json:"result"`
  6490. } `json:"output"`
  6491. RefmsgTime string `json:"refmsg_time"`
  6492. RespondTime string `json:"respond_time"`
  6493. Signtype string `json:"signtype"`
  6494. WarnMsg string `json:"warn_msg"`
  6495. }
  6496. type ResultMemo struct {
  6497. InsuAdmdvs string `json:"insuAdmdvs"`
  6498. }
  6499. //[{"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}]
  6500. type ResultIDInfo struct {
  6501. Begntime string `json:"begntime"`
  6502. Endtime string `json:"endtime"`
  6503. Memo string `json:"memo"`
  6504. }
  6505. type ResultFive struct {
  6506. Balc float64 `json:"balc"`
  6507. CvlservFlag string `json:"cvlserv_flag"`
  6508. EmpName string `json:"emp_name"`
  6509. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6510. Insutype string `json:"insutype"`
  6511. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6512. PausInsuDate string `json:"paus_insu_date"`
  6513. PsnInsuDate string `json:"psn_insu_date"`
  6514. PsnInsuStas string `json:"psn_insu_stas"`
  6515. PsnType string `json:"psn_type"`
  6516. }
  6517. type ResultSix struct {
  6518. Cainfo interface{} `json:"cainfo"`
  6519. ErrMsg string `json:"err_msg"`
  6520. InfRefmsgid string `json:"inf_refmsgid"`
  6521. Infcode int64 `json:"infcode"`
  6522. Output struct {
  6523. } `json:"output"`
  6524. RefmsgTime string `json:"refmsg_time"`
  6525. RespondTime string `json:"respond_time"`
  6526. Signtype interface{} `json:"signtype"`
  6527. WarnMsg interface{} `json:"warn_msg"`
  6528. }
  6529. type ResultSix10265 struct {
  6530. Cainfo interface{} `json:"cainfo"`
  6531. ErrMsg string `json:"err_msg"`
  6532. InfRefmsgid string `json:"inf_refmsgid"`
  6533. Infcode string `json:"infcode"`
  6534. Output struct {
  6535. } `json:"output"`
  6536. RefmsgTime string `json:"refmsg_time"`
  6537. RespondTime string `json:"respond_time"`
  6538. Signtype interface{} `json:"signtype"`
  6539. WarnMsg interface{} `json:"warn_msg"`
  6540. }
  6541. type ResultSeven struct {
  6542. Cainfo string `json:"cainfo"`
  6543. ErrMsg string `json:"err_msg"`
  6544. InfRefmsgid string `json:"inf_refmsgid"`
  6545. Infcode int64 `json:"infcode"`
  6546. Output struct {
  6547. Setldetail []interface{} `json:"setldetail"`
  6548. Setlinfo struct {
  6549. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6550. AcctPay float64 `json:"acct_pay"`
  6551. ActPayDedc float64 `json:"act_pay_dedc"`
  6552. Age float64 `json:"age"`
  6553. Balc float64 `json:"balc"`
  6554. Brdy string `json:"brdy"`
  6555. Certno string `json:"certno"`
  6556. ClrOptins string `json:"clr_optins"`
  6557. ClrType string `json:"clr_type"`
  6558. ClrWay string `json:"clr_way"`
  6559. CvlservFlag string `json:"cvlserv_flag"`
  6560. CvlservPay float64 `json:"cvlserv_pay"`
  6561. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6562. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6563. Gend string `json:"gend"`
  6564. HifesPay float64 `json:"hifes_pay"`
  6565. HifmiPay float64 `json:"hifmi_pay"`
  6566. HifpPay float64 `json:"hifp_pay"`
  6567. HospPartAmt float64 `json:"hosp_part_amt"`
  6568. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6569. Insutype string `json:"insutype"`
  6570. MafPay float64 `json:"maf_pay"`
  6571. MdtrtCertType string `json:"mdtrt_cert_type"`
  6572. HifobPay float64 `json:"hifob_pay"`
  6573. MdtrtID string `json:"mdtrt_id"`
  6574. MedType string `json:"med_type"`
  6575. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6576. MedinsSetlID string `json:"medins_setl_id"`
  6577. Naty string `json:"naty"`
  6578. OthPay float64 `json:"oth_pay"`
  6579. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6580. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6581. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6582. PsnCashPay float64 `json:"psn_cash_pay"`
  6583. PsnCertType string `json:"psn_cert_type"`
  6584. PsnName string `json:"psn_name"`
  6585. PsnNo string `json:"psn_no"`
  6586. PsnPartAmt float64 `json:"psn_part_amt"`
  6587. PsnType string `json:"psn_type"`
  6588. SetlID string `json:"setl_id"`
  6589. SetlTime string `json:"setl_time"`
  6590. } `json:"setlinfo"`
  6591. } `json:"output"`
  6592. RefmsgTime string `json:"refmsg_time"`
  6593. RespondTime string `json:"respond_time"`
  6594. Signtype interface{} `json:"signtype"`
  6595. WarnMsg interface{} `json:"warn_msg"`
  6596. }
  6597. type ResultSeven10265 struct {
  6598. Cainfo string `json:"cainfo"`
  6599. ErrMsg string `json:"err_msg"`
  6600. InfRefmsgid string `json:"inf_refmsgid"`
  6601. Infcode string `json:"infcode"`
  6602. Output struct {
  6603. Setldetail []interface{} `json:"setldetail"`
  6604. Setlinfo struct {
  6605. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6606. AcctPay float64 `json:"acct_pay"`
  6607. ActPayDedc float64 `json:"act_pay_dedc"`
  6608. Age float64 `json:"age"`
  6609. Balc float64 `json:"balc"`
  6610. Brdy string `json:"brdy"`
  6611. Certno string `json:"certno"`
  6612. ClrOptins string `json:"clr_optins"`
  6613. ClrType string `json:"clr_type"`
  6614. ClrWay string `json:"clr_way"`
  6615. CvlservFlag string `json:"cvlserv_flag"`
  6616. CvlservPay float64 `json:"cvlserv_pay"`
  6617. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6618. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6619. Gend string `json:"gend"`
  6620. HifesPay float64 `json:"hifes_pay"`
  6621. HifmiPay float64 `json:"hifmi_pay"`
  6622. HifpPay float64 `json:"hifp_pay"`
  6623. HospPartAmt float64 `json:"hosp_part_amt"`
  6624. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6625. Insutype string `json:"insutype"`
  6626. MafPay float64 `json:"maf_pay"`
  6627. MdtrtCertType string `json:"mdtrt_cert_type"`
  6628. HifobPay float64 `json:"hifob_pay"`
  6629. MdtrtID string `json:"mdtrt_id"`
  6630. MedType string `json:"med_type"`
  6631. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6632. MedinsSetlID string `json:"medins_setl_id"`
  6633. Naty string `json:"naty"`
  6634. OthPay float64 `json:"oth_pay"`
  6635. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6636. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6637. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6638. PsnCashPay float64 `json:"psn_cash_pay"`
  6639. PsnCertType string `json:"psn_cert_type"`
  6640. PsnName string `json:"psn_name"`
  6641. PsnNo string `json:"psn_no"`
  6642. PsnPartAmt float64 `json:"psn_part_amt"`
  6643. PsnType string `json:"psn_type"`
  6644. SetlID string `json:"setl_id"`
  6645. SetlTime string `json:"setl_time"`
  6646. } `json:"setlinfo"`
  6647. } `json:"output"`
  6648. RefmsgTime string `json:"refmsg_time"`
  6649. RespondTime string `json:"respond_time"`
  6650. Signtype interface{} `json:"signtype"`
  6651. WarnMsg interface{} `json:"warn_msg"`
  6652. }
  6653. type ResultEight struct {
  6654. Cainfo string `json:"cainfo"`
  6655. ErrMsg string `json:"err_msg"`
  6656. InfRefmsgid string `json:"inf_refmsgid"`
  6657. Infcode int64 `json:"infcode"`
  6658. Output struct {
  6659. Stmtinfo struct {
  6660. SetlOptins string `json:"setl_optins"`
  6661. StmtRslt string `json:"stmt_rslt"`
  6662. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6663. } `json:"stmtinfo"`
  6664. } `json:"output"`
  6665. RefmsgTime string `json:"refmsg_time"`
  6666. RespondTime string `json:"respond_time"`
  6667. Signtype interface{} `json:"signtype"`
  6668. WarnMsg interface{} `json:"warn_msg"`
  6669. }
  6670. type ResultEightFor10188 struct {
  6671. Cainfo string `json:"cainfo"`
  6672. ErrMsg string `json:"err_msg"`
  6673. InfRefmsgid string `json:"inf_refmsgid"`
  6674. Infcode string `json:"infcode"`
  6675. Output struct {
  6676. Stmtinfo struct {
  6677. SetlOptins string `json:"setl_optins"`
  6678. StmtRslt string `json:"stmt_rslt"`
  6679. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6680. } `json:"stmtinfo"`
  6681. } `json:"output"`
  6682. RefmsgTime string `json:"refmsg_time"`
  6683. RespondTime string `json:"respond_time"`
  6684. Signtype interface{} `json:"signtype"`
  6685. WarnMsg interface{} `json:"warn_msg"`
  6686. }
  6687. type ResultNine struct {
  6688. Cainfo string `json:"cainfo"`
  6689. ErrMsg string `json:"err_msg"`
  6690. InfRefmsgid string `json:"inf_refmsgid"`
  6691. Infcode int64 `json:"infcode"`
  6692. Output struct {
  6693. FileQuryNo string `json:"file_qury_no"`
  6694. } `json:"output"`
  6695. RefmsgTime string `json:"refmsg_time"`
  6696. RespondTime string `json:"respond_time"`
  6697. Signtype interface{} `json:"signtype"`
  6698. WarnMsg interface{} `json:"warn_msg"`
  6699. }
  6700. type ResultTen struct {
  6701. Cainfo string `json:"cainfo"`
  6702. ErrMsg string `json:"err_msg"`
  6703. InfRefmsgid string `json:"inf_refmsgid"`
  6704. Infcode int64 `json:"infcode"`
  6705. Output struct {
  6706. DldEndtime string `json:"dld_endtime"`
  6707. FileQuryNo string `json:"file_qury_no"`
  6708. Filename string `json:"filename"`
  6709. } `json:"output"`
  6710. RefmsgTime string `json:"refmsg_time"`
  6711. RespondTime string `json:"respond_time"`
  6712. Signtype interface{} `json:"signtype"`
  6713. WarnMsg interface{} `json:"warn_msg"`
  6714. }
  6715. //type Autogenerated struct {
  6716. // Output struct {
  6717. // Setlinfo struct {
  6718. // SetlTime string `json:"setl_time"`
  6719. // CvlservPay float64 `json:"cvlserv_pay"`
  6720. // Year string `json:"year"`
  6721. // MedType string `json:"med_type"`
  6722. // PsnPay float64 `json:"psn_pay"`
  6723. // OpterID string `json:"opter_id"`
  6724. // Begndate string `json:"begndate"`
  6725. // FlxempeFlag string `json:"flxempe_flag"`
  6726. // HifmiPay float64 `json:"hifmi_pay"`
  6727. // PsnNo string `json:"psn_no"`
  6728. // ActPayDedc float64 `json:"act_pay_dedc"`
  6729. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6730. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6731. // ClrWay string `json:"clr_way"`
  6732. // OthPay float64 `json:"oth_pay"`
  6733. // Gend string `json:"gend"`
  6734. // MdtrtID string `json:"mdtrt_id"`
  6735. // AcctPay float64 `json:"acct_pay"`
  6736. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6737. // Insutype string `json:"insutype"`
  6738. // Invono interface{} `json:"invono"`
  6739. // Enddate string `json:"enddate"`
  6740. // CashPayamt float64 `json:"cash_payamt"`
  6741. // PsnType string `json:"psn_type"`
  6742. // FixmedinsName string `json:"fixmedins_name"`
  6743. // HifpPay float64 `json:"hifp_pay"`
  6744. // NewFlag interface{} `json:"new_flag"`
  6745. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6746. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6747. // PayLoc string `json:"pay_loc"`
  6748. // ClrType string `json:"clr_type"`
  6749. // RefdSetlFlag string `json:"refd_setl_flag"`
  6750. // CvlservFlag string `json:"cvlserv_flag"`
  6751. // EmpName string `json:"emp_name"`
  6752. // Brdy string `json:"brdy"`
  6753. // Naty string `json:"naty"`
  6754. // Certno string `json:"certno"`
  6755. // DiseCode string `json:"dise_code"`
  6756. // FixmedinsCode string `json:"fixmedins_code"`
  6757. // DedcHospLv string `json:"dedc_hosp_lv"`
  6758. // OpterName string `json:"opter_name"`
  6759. // Balc float64 `json:"balc"`
  6760. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6761. // PsnCertType string `json:"psn_cert_type"`
  6762. // HifobPay float64 `json:"hifob_pay"`
  6763. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6764. // HifesPay float64 `json:"hifes_pay"`
  6765. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6766. // OptTime string `json:"opt_time"`
  6767. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6768. // SetlID string `json:"setl_id"`
  6769. // MafPay float64 `json:"maf_pay"`
  6770. // PsnName string `json:"psn_name"`
  6771. // InsuOptins interface{} `json:"insu_optins"`
  6772. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6773. // ClrOptins string `json:"clr_optins"`
  6774. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6775. // DiseName string `json:"dise_name"`
  6776. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6777. // Age float64 `json:"age"`
  6778. // DtrtCertType string `json:"dtrt_cert_type"`
  6779. // HospLv string `json:"hosp_lv"`
  6780. // } `json:"setlinfo"`
  6781. // Setldetail []struct {
  6782. // FundPayType string `json:"fund_pay_type"`
  6783. // FundPayamt float64 `json:"fund_payamt"`
  6784. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6785. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6786. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6787. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6788. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6789. // } `json:"setldetail"`
  6790. // } `json:"output"`
  6791. // Infcode int `json:"infcode"`
  6792. // WarnMsg interface{} `json:"warn_msg"`
  6793. // Cainfo interface{} `json:"cainfo"`
  6794. // ErrMsg interface{} `json:"err_msg"`
  6795. // RefmsgTime string `json:"refmsg_time"`
  6796. // Signtype interface{} `json:"signtype"`
  6797. // RespondTime string `json:"respond_time"`
  6798. // InfRefmsgid string `json:"inf_refmsgid"`
  6799. //}
  6800. type ResultEleven struct {
  6801. Cainfo string `json:"cainfo"`
  6802. ErrMsg string `json:"err_msg"`
  6803. InfRefmsgid string `json:"inf_refmsgid"`
  6804. Infcode int64 `json:"infcode"`
  6805. Output struct {
  6806. Setlinfo struct {
  6807. SetlTime string `json:"setl_time"`
  6808. CvlservPay float64 `json:"cvlserv_pay"`
  6809. Year string `json:"year"`
  6810. MedType string `json:"med_type"`
  6811. PsnPay float64 `json:"psn_pay"`
  6812. OpterID string `json:"opter_id"`
  6813. Begndate string `json:"begndate"`
  6814. FlxempeFlag string `json:"flxempe_flag"`
  6815. HifmiPay float64 `json:"hifmi_pay"`
  6816. PsnNo string `json:"psn_no"`
  6817. ActPayDedc float64 `json:"act_pay_dedc"`
  6818. MedinsSetlID interface{} `json:"medins_setl_id"`
  6819. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6820. ClrWay string `json:"clr_way"`
  6821. OthPay float64 `json:"oth_pay"`
  6822. Gend string `json:"gend"`
  6823. MdtrtID string `json:"mdtrt_id"`
  6824. AcctPay float64 `json:"acct_pay"`
  6825. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6826. Insutype string `json:"insutype"`
  6827. Invono interface{} `json:"invono"`
  6828. Enddate string `json:"enddate"`
  6829. CashPayamt float64 `json:"cash_payamt"`
  6830. PsnType string `json:"psn_type"`
  6831. FixmedinsName string `json:"fixmedins_name"`
  6832. HifpPay float64 `json:"hifp_pay"`
  6833. NewFlag interface{} `json:"new_flag"`
  6834. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6835. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6836. PayLoc string `json:"pay_loc"`
  6837. ClrType string `json:"clr_type"`
  6838. RefdSetlFlag string `json:"refd_setl_flag"`
  6839. CvlservFlag string `json:"cvlserv_flag"`
  6840. EmpName string `json:"emp_name"`
  6841. Brdy string `json:"brdy"`
  6842. Naty string `json:"naty"`
  6843. Certno string `json:"certno"`
  6844. DiseCode string `json:"dise_code"`
  6845. FixmedinsCode string `json:"fixmedins_code"`
  6846. DedcHospLv string `json:"dedc_hosp_lv"`
  6847. OpterName string `json:"opter_name"`
  6848. Balc float64 `json:"balc"`
  6849. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6850. PsnCertType string `json:"psn_cert_type"`
  6851. HifobPay float64 `json:"hifob_pay"`
  6852. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6853. HifesPay float64 `json:"hifes_pay"`
  6854. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6855. OptTime string `json:"opt_time"`
  6856. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6857. SetlID string `json:"setl_id"`
  6858. MafPay float64 `json:"maf_pay"`
  6859. PsnName string `json:"psn_name"`
  6860. InsuOptins interface{} `json:"insu_optins"`
  6861. PrefFundPay interface{} `json:"pref_fund_pay"`
  6862. ClrOptins string `json:"clr_optins"`
  6863. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6864. DiseName string `json:"dise_name"`
  6865. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6866. Age float64 `json:"age"`
  6867. DtrtCertType string `json:"dtrt_cert_type"`
  6868. HospLv string `json:"hosp_lv"`
  6869. PsnCashPay float64
  6870. } `json:"setlinfo"`
  6871. } `json:"output"`
  6872. RefmsgTime string `json:"refmsg_time"`
  6873. RespondTime string `json:"respond_time"`
  6874. Signtype interface{} `json:"signtype"`
  6875. WarnMsg interface{} `json:"warn_msg"`
  6876. }
  6877. type ResultEleven10265 struct {
  6878. Cainfo string `json:"cainfo"`
  6879. ErrMsg string `json:"err_msg"`
  6880. InfRefmsgid string `json:"inf_refmsgid"`
  6881. Infcode string `json:"infcode"`
  6882. Output struct {
  6883. Setlinfo struct {
  6884. SetlTime string `json:"setl_time"`
  6885. CvlservPay float64 `json:"cvlserv_pay"`
  6886. Year string `json:"year"`
  6887. MedType string `json:"med_type"`
  6888. PsnPay float64 `json:"psn_pay"`
  6889. OpterID string `json:"opter_id"`
  6890. Begndate string `json:"begndate"`
  6891. FlxempeFlag string `json:"flxempe_flag"`
  6892. HifmiPay float64 `json:"hifmi_pay"`
  6893. PsnNo string `json:"psn_no"`
  6894. ActPayDedc float64 `json:"act_pay_dedc"`
  6895. MedinsSetlID interface{} `json:"medins_setl_id"`
  6896. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6897. ClrWay string `json:"clr_way"`
  6898. OthPay float64 `json:"oth_pay"`
  6899. Gend string `json:"gend"`
  6900. MdtrtID string `json:"mdtrt_id"`
  6901. AcctPay float64 `json:"acct_pay"`
  6902. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6903. Insutype string `json:"insutype"`
  6904. Invono interface{} `json:"invono"`
  6905. Enddate string `json:"enddate"`
  6906. CashPayamt float64 `json:"cash_payamt"`
  6907. PsnType string `json:"psn_type"`
  6908. FixmedinsName string `json:"fixmedins_name"`
  6909. HifpPay float64 `json:"hifp_pay"`
  6910. NewFlag interface{} `json:"new_flag"`
  6911. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6912. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6913. PayLoc string `json:"pay_loc"`
  6914. ClrType string `json:"clr_type"`
  6915. RefdSetlFlag string `json:"refd_setl_flag"`
  6916. CvlservFlag string `json:"cvlserv_flag"`
  6917. EmpName string `json:"emp_name"`
  6918. Brdy string `json:"brdy"`
  6919. Naty string `json:"naty"`
  6920. Certno string `json:"certno"`
  6921. DiseCode string `json:"dise_code"`
  6922. FixmedinsCode string `json:"fixmedins_code"`
  6923. DedcHospLv string `json:"dedc_hosp_lv"`
  6924. OpterName string `json:"opter_name"`
  6925. Balc float64 `json:"balc"`
  6926. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6927. PsnCertType string `json:"psn_cert_type"`
  6928. HifobPay float64 `json:"hifob_pay"`
  6929. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6930. HifesPay float64 `json:"hifes_pay"`
  6931. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6932. OptTime string `json:"opt_time"`
  6933. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6934. SetlID string `json:"setl_id"`
  6935. MafPay float64 `json:"maf_pay"`
  6936. PsnName string `json:"psn_name"`
  6937. InsuOptins interface{} `json:"insu_optins"`
  6938. PrefFundPay interface{} `json:"pref_fund_pay"`
  6939. ClrOptins string `json:"clr_optins"`
  6940. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6941. DiseName string `json:"dise_name"`
  6942. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6943. Age float64 `json:"age"`
  6944. DtrtCertType string `json:"dtrt_cert_type"`
  6945. HospLv string `json:"hosp_lv"`
  6946. PsnCashPay float64
  6947. } `json:"setlinfo"`
  6948. } `json:"output"`
  6949. RefmsgTime string `json:"refmsg_time"`
  6950. RespondTime string `json:"respond_time"`
  6951. Signtype interface{} `json:"signtype"`
  6952. WarnMsg interface{} `json:"warn_msg"`
  6953. }
  6954. type ResultTwelve struct {
  6955. Cainfo string `json:"cainfo"`
  6956. ErrMsg string `json:"err_msg"`
  6957. InfRefmsgid string `json:"inf_refmsgid"`
  6958. Infcode int64 `json:"infcode"`
  6959. Output struct {
  6960. MdtrtId string `json:"mdtrt_id"`
  6961. ChrgBchno string `json:"chrg_bchno"`
  6962. PsnNo string `json:"psn_no"`
  6963. } `json:"output"`
  6964. RefmsgTime string `json:"refmsg_time"`
  6965. RespondTime string `json:"respond_time"`
  6966. Signtype interface{} `json:"signtype"`
  6967. WarnMsg interface{} `json:"warn_msg"`
  6968. }
  6969. type ResultThirteen struct {
  6970. ErrMsg string `json:"err_msg"`
  6971. InfRefmsgid string `json:"inf_refmsgid"`
  6972. Infcode int64 `json:"infcode"`
  6973. Output struct {
  6974. Result struct {
  6975. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6976. } `json:"result"`
  6977. } `json:"output"`
  6978. RefmsgTime string `json:"refmsg_time"`
  6979. RespondTime string `json:"respond_time"`
  6980. Signtype interface{} `json:"signtype"`
  6981. WarnInfo interface{} `json:"warn_info"`
  6982. }
  6983. type ResultThirteen10265 struct {
  6984. ErrMsg string `json:"err_msg"`
  6985. InfRefmsgid string `json:"inf_refmsgid"`
  6986. Infcode string `json:"infcode"`
  6987. Output struct {
  6988. Result struct {
  6989. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6990. } `json:"result"`
  6991. } `json:"output"`
  6992. RefmsgTime string `json:"refmsg_time"`
  6993. RespondTime string `json:"respond_time"`
  6994. Signtype interface{} `json:"signtype"`
  6995. WarnInfo interface{} `json:"warn_info"`
  6996. }
  6997. type ResultFourteen struct {
  6998. ErrMsg string `json:"err_msg"`
  6999. InfRefmsgid string `json:"inf_refmsgid"`
  7000. Infcode int64 `json:"infcode"`
  7001. Output struct {
  7002. } `json:"output"`
  7003. RefmsgTime string `json:"refmsg_time"`
  7004. RespondTime string `json:"respond_time"`
  7005. Signtype interface{} `json:"signtype"`
  7006. WarnInfo interface{} `json:"warn_info"`
  7007. }
  7008. type ResultFourteen10265 struct {
  7009. ErrMsg string `json:"err_msg"`
  7010. InfRefmsgid string `json:"inf_refmsgid"`
  7011. Infcode string `json:"infcode"`
  7012. Output struct {
  7013. } `json:"output"`
  7014. RefmsgTime string `json:"refmsg_time"`
  7015. RespondTime string `json:"respond_time"`
  7016. Signtype interface{} `json:"signtype"`
  7017. WarnInfo interface{} `json:"warn_info"`
  7018. }
  7019. type ResultSixteen struct {
  7020. Cainfo string `json:"cainfo"`
  7021. ErrMsg string `json:"err_msg"`
  7022. InfRefmsgid string `json:"inf_refmsgid"`
  7023. Infcode int64 `json:"infcode"`
  7024. Output struct {
  7025. Setldetail []interface{} `json:"setldetail"`
  7026. Setlinfo struct {
  7027. MdtrtID string `json:"mdtrt_id"`
  7028. SetlID string `json:"setl_id"`
  7029. ClrOptins string `json:"clr_optins"`
  7030. SetlTime string `json:"setl_time"`
  7031. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7032. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7033. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7034. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7035. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7036. ActPayDedc float64 `json:"act_pay_dedc"`
  7037. HifpPay float64 `json:"hifp_pay"`
  7038. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7039. Lfpay float64 `json:"selfpay"`
  7040. CvlservPay float64 `json:"cvlserv_pay"`
  7041. HifesPay float64 `json:"hifes_pay"`
  7042. HifmiPay float64 `json:"hifmi_pay"`
  7043. HifobPay float64 `json:"hifob_pay"`
  7044. MafPay float64 `json:"maf_pay"`
  7045. OthPay float64 `json:"oth_pay"`
  7046. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7047. PsnPartAmt float64 `json:"psn_part_amt"`
  7048. AcctPay float64 `json:"acct_pay"`
  7049. Balc float64 `json:"balc"`
  7050. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7051. HospPartAmt float64 `json:"hosp_part_amt"`
  7052. MedinsSetlID string `json:"medins_setl_id"`
  7053. PdnCashPay string `json:"pdn_cash_pay"`
  7054. } `json:"setlinfo"`
  7055. } `json:"output"`
  7056. RefmsgTime string `json:"refmsg_time"`
  7057. RespondTime string `json:"respond_time"`
  7058. Signtype interface{} `json:"signtype"`
  7059. WarnMsg interface{} `json:"warn_msg"`
  7060. }
  7061. type ResultSixteen10265 struct {
  7062. Cainfo string `json:"cainfo"`
  7063. ErrMsg string `json:"err_msg"`
  7064. InfRefmsgid string `json:"inf_refmsgid"`
  7065. Infcode string `json:"infcode"`
  7066. Output struct {
  7067. Setldetail []interface{} `json:"setldetail"`
  7068. Setlinfo struct {
  7069. MdtrtID string `json:"mdtrt_id"`
  7070. SetlID string `json:"setl_id"`
  7071. ClrOptins string `json:"clr_optins"`
  7072. SetlTime string `json:"setl_time"`
  7073. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7074. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7075. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7076. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7077. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7078. ActPayDedc float64 `json:"act_pay_dedc"`
  7079. HifpPay float64 `json:"hifp_pay"`
  7080. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7081. Lfpay float64 `json:"selfpay"`
  7082. CvlservPay float64 `json:"cvlserv_pay"`
  7083. HifesPay float64 `json:"hifes_pay"`
  7084. HifmiPay float64 `json:"hifmi_pay"`
  7085. HifobPay float64 `json:"hifob_pay"`
  7086. MafPay float64 `json:"maf_pay"`
  7087. OthPay float64 `json:"oth_pay"`
  7088. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7089. PsnPartAmt float64 `json:"psn_part_amt"`
  7090. AcctPay float64 `json:"acct_pay"`
  7091. Balc float64 `json:"balc"`
  7092. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7093. HospPartAmt float64 `json:"hosp_part_amt"`
  7094. MedinsSetlID string `json:"medins_setl_id"`
  7095. PdnCashPay string `json:"pdn_cash_pay"`
  7096. } `json:"setlinfo"`
  7097. } `json:"output"`
  7098. RefmsgTime string `json:"refmsg_time"`
  7099. RespondTime string `json:"respond_time"`
  7100. Signtype interface{} `json:"signtype"`
  7101. WarnMsg interface{} `json:"warn_msg"`
  7102. }
  7103. type ResultSeventeen struct {
  7104. ErrMsg string `json:"err_msg"`
  7105. InfRefmsgid string `json:"inf_refmsgid"`
  7106. Infcode int64 `json:"infcode"`
  7107. Output struct {
  7108. SetlListId string `json:"setl_list_id"`
  7109. } `json:"output"`
  7110. RefmsgTime string `json:"refmsg_time"`
  7111. RespondTime string `json:"respond_time"`
  7112. Signtype string `json:"signtype"`
  7113. WarnInfo string `json:"warn_info"`
  7114. }
  7115. type ResultSeventeenOther struct {
  7116. ErrMsg string `json:"err_msg"`
  7117. InfRefmsgid string `json:"inf_refmsgid"`
  7118. Infcode string `json:"infcode"`
  7119. Output struct {
  7120. SetlListId string `json:"setl_list_id"`
  7121. } `json:"output"`
  7122. RefmsgTime string `json:"refmsg_time"`
  7123. RespondTime string `json:"respond_time"`
  7124. Signtype string `json:"signtype"`
  7125. WarnInfo string `json:"warn_info"`
  7126. }
  7127. type Result90991 struct {
  7128. ErrMsg string `json:"err_msg"`
  7129. InfRefmsgid string `json:"inf_refmsgid"`
  7130. Infcode int64 `json:"infcode"`
  7131. Output struct {
  7132. Result struct {
  7133. PsnNo string `json:"psn_no"`
  7134. CardStat string `json:"card_stat"`
  7135. Certno string `json:"certno"`
  7136. PsnName string `json:"psn_name"`
  7137. CheckStat string `json:"check_stat"`
  7138. SscnoCheckStat string `json:"sscno_check_stat"`
  7139. } `json:"result"`
  7140. } `json:"output"`
  7141. RefmsgTime string `json:"refmsg_time"`
  7142. RespondTime string `json:"respond_time"`
  7143. Signtype interface{} `json:"signtype"`
  7144. WarnInfo interface{} `json:"warn_info"`
  7145. }
  7146. type Result90100 struct {
  7147. ErrMsg string `json:"err_msg"`
  7148. InfRefmsgid string `json:"inf_refmsgid"`
  7149. Infcode int64 `json:"infcode"`
  7150. Output struct {
  7151. PoolareaNo string `json:"poolarea_no"`
  7152. PoolareaNoName string `json:"poolarea_no_name"`
  7153. Insutype string `json:"insutype"`
  7154. InsutypeName string `json:"insutype_name"`
  7155. ClctType string `json:"clct_type"`
  7156. ClctTypeName string `json:"clct_type_name"`
  7157. ClctFlag string `json:"clct_flag"`
  7158. ClctFlagName string `json:"clct_flag_name"`
  7159. AccrymBegn string `json:"accrym_begn"`
  7160. AccrymEnd string `json:"accrym_end"`
  7161. ClctTime string `json:"clct_time"`
  7162. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  7163. } `json:"output"`
  7164. RefmsgTime string `json:"refmsg_time"`
  7165. RespondTime string `json:"respond_time"`
  7166. Signtype interface{} `json:"signtype"`
  7167. WarnInfo interface{} `json:"warn_info"`
  7168. }
  7169. type Custom struct {
  7170. DetItemFeeSumamt string
  7171. Cut string
  7172. FeedetlSn string
  7173. Price string
  7174. MedListCodg string
  7175. Type int64
  7176. AdviceId int64
  7177. ProjectId int64
  7178. ItemId int64
  7179. }
  7180. type Result5301 struct {
  7181. ErrMsg string `json:"err_msg"`
  7182. InfRefmsgid string `json:"inf_refmsgid"`
  7183. Infcode int64 `json:"infcode"`
  7184. Output struct {
  7185. Result []struct {
  7186. OpspDiseCode string `json:"opsp_dise_code"`
  7187. OpspDiseName string `json:"opsp_dise_name"`
  7188. Begndate string `json:"begndate"`
  7189. Enddate string `json:"enddate"`
  7190. } `json:"feedetail"`
  7191. } `json:"output"`
  7192. RefmsgTime string `json:"refmsg_time"`
  7193. RespondTime string `json:"respond_time"`
  7194. Signtype interface{} `json:"signtype"`
  7195. WarnInfo interface{} `json:"warn_info"`
  7196. }
  7197. type Result5301For10265 struct {
  7198. ErrMsg string `json:"err_msg"`
  7199. InfRefmsgid string `json:"inf_refmsgid"`
  7200. Infcode string `json:"infcode"`
  7201. Output struct {
  7202. Result []struct {
  7203. OpspDiseCode string `json:"opsp_dise_code"`
  7204. OpspDiseName string `json:"opsp_dise_name"`
  7205. Begndate string `json:"begndate"`
  7206. Enddate string `json:"enddate"`
  7207. } `json:"feedetail"`
  7208. } `json:"output"`
  7209. RefmsgTime string `json:"refmsg_time"`
  7210. RespondTime string `json:"respond_time"`
  7211. Signtype interface{} `json:"signtype"`
  7212. WarnInfo interface{} `json:"warn_info"`
  7213. }
  7214. //获取个人信息----挂号-----上传就诊信息
  7215. func (c *HisApiController) GetRegisterInfo() {
  7216. id, _ := c.GetInt64("id")
  7217. record_time := c.GetString("record_time")
  7218. settlementValue, _ := c.GetInt64("settlement_value")
  7219. medical_insurance_card := c.GetString("medical_insurance_card")
  7220. name := c.GetString("name")
  7221. id_card_type, _ := c.GetInt64("id_card_type")
  7222. certificates, _ := c.GetInt64("certificates")
  7223. medical_care, _ := c.GetInt64("medical_care")
  7224. birthday := c.GetString("birthday")
  7225. id_card := c.GetString("id_card")
  7226. register_type, _ := c.GetInt64("register")
  7227. doctor, _ := c.GetInt64("doctor")
  7228. department, _ := c.GetInt64("department")
  7229. gender, _ := c.GetInt64("sex")
  7230. registration_fee, _ := c.GetFloat("registration_fee")
  7231. medical_expenses, _ := c.GetFloat("medical_expenses")
  7232. social_type, _ := c.GetInt64("social_type")
  7233. med_type := c.GetString("social_type")
  7234. admin_user_id, _ := c.GetInt64("admin_user_id")
  7235. insuplc_admdvs := c.GetString("insuplc_admdvs")
  7236. mdtrt_type := c.GetString("mdtrt_type")
  7237. timeLayout := "2006-01-02"
  7238. loc, _ := time.LoadLocation("Local")
  7239. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  7240. birthUnix := birthdays.Unix()
  7241. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7242. if err != nil {
  7243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7244. return
  7245. }
  7246. recordDateTime := theTime.Unix()
  7247. adminInfo := c.GetAdminUserInfo()
  7248. var patient service.Patients
  7249. if id == 0 {
  7250. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  7251. } else {
  7252. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  7253. }
  7254. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7255. if patientPrescription.ID == 0 {
  7256. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7257. }
  7258. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7259. if patient.ID == 0 {
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7261. return
  7262. }
  7263. if len(patient.IdCardNo) == 0 {
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7265. return
  7266. }
  7267. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7268. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  7269. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  7270. //就诊结算未完成,不能进行二次挂号
  7271. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  7272. if len(his) >= 1 {
  7273. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  7274. if len(his) >= 1 && order.ID == 0 {
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  7276. return
  7277. }
  7278. }
  7279. //var register_log string
  7280. if config.IsOpen == 1 {
  7281. var res ResultTwo
  7282. var res10265 ResultTwo10265
  7283. var PsnNo string
  7284. var PsnCertType string
  7285. var Certno string
  7286. var PsnName string
  7287. var Gend string
  7288. var Naty string
  7289. var Brdy string
  7290. var Age float64
  7291. var infoStr string
  7292. var idetinfoStr string
  7293. var infocode int64
  7294. var verify_number string
  7295. fmt.Println(verify_number)
  7296. if miConfig.MdtrtareaAdmvs == "421300" {
  7297. psn_info, _ := service.GetPsnByPatientId(id)
  7298. PsnNo = psn_info.PsnNo
  7299. PsnCertType = psn_info.PsnCertType
  7300. Certno = psn_info.Certno
  7301. PsnName = psn_info.PsnName
  7302. Gend = psn_info.Gend
  7303. Naty = psn_info.Naty
  7304. Brdy = psn_info.Brdy
  7305. Age = psn_info.Age
  7306. infoStr = psn_info.Insuinfo
  7307. idetinfoStr = psn_info.Idetinfo
  7308. infocode = 0
  7309. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7310. psn_info, _ := service.GetPsnByPatientId(id)
  7311. PsnNo = psn_info.PsnNo
  7312. PsnCertType = psn_info.PsnCertType
  7313. Certno = psn_info.Certno
  7314. PsnName = psn_info.PsnName
  7315. Gend = psn_info.Gend
  7316. Naty = psn_info.Naty
  7317. Brdy = psn_info.Brdy
  7318. Age = psn_info.Age
  7319. infoStr = psn_info.Insuinfo
  7320. idetinfoStr = psn_info.Idetinfo
  7321. infocode = 0
  7322. verify_number = psn_info.VerifyNumber
  7323. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7324. if id_card_type == 1 {
  7325. psn_info, _ := service.GetPsnByPatientId(id)
  7326. PsnNo = psn_info.PsnNo
  7327. PsnCertType = psn_info.PsnCertType
  7328. Certno = psn_info.Certno
  7329. PsnName = psn_info.PsnName
  7330. Gend = psn_info.Gend
  7331. Naty = psn_info.Naty
  7332. Brdy = psn_info.Brdy
  7333. Age = psn_info.Age
  7334. infoStr = psn_info.Insuinfo
  7335. idetinfoStr = psn_info.Idetinfo
  7336. infocode = 0
  7337. verify_number = psn_info.VerifyNumber
  7338. } else if id_card_type == 2 {
  7339. 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, "")
  7340. fmt.Println(errMsgLog)
  7341. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7342. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7343. utils.ErrorLog("解析失败:%v", err)
  7344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7345. return
  7346. }
  7347. PsnNo = res.Output.Baseinfo.PsnNo
  7348. PsnCertType = res.Output.Baseinfo.PsnCertType
  7349. Certno = res.Output.Baseinfo.Certno
  7350. PsnName = res.Output.Baseinfo.PsnName
  7351. Gend = res.Output.Baseinfo.Gend
  7352. Naty = res.Output.Baseinfo.Naty
  7353. Brdy = res.Output.Baseinfo.Brdy
  7354. Age = res.Output.Baseinfo.Age
  7355. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7356. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7357. infoStr = string(Iinfos)
  7358. idetinfoStr = string(Idetinfos)
  7359. infocode = res.Infcode
  7360. }
  7361. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7362. if id_card_type == 1 {
  7363. psn_info, _ := service.GetPsnByPatientId(id)
  7364. PsnNo = psn_info.PsnNo
  7365. PsnCertType = psn_info.PsnCertType
  7366. Certno = psn_info.Certno
  7367. PsnName = psn_info.PsnName
  7368. Gend = psn_info.Gend
  7369. Naty = psn_info.Naty
  7370. Brdy = psn_info.Brdy
  7371. Age = psn_info.Age
  7372. infoStr = psn_info.Insuinfo
  7373. idetinfoStr = psn_info.Idetinfo
  7374. infocode = 0
  7375. verify_number = psn_info.VerifyNumber
  7376. } else if id_card_type == 2 {
  7377. 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, "")
  7378. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7379. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7380. utils.ErrorLog("解析失败:%v", err)
  7381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7382. return
  7383. }
  7384. PsnNo = res.Output.Baseinfo.PsnNo
  7385. PsnCertType = res.Output.Baseinfo.PsnCertType
  7386. Certno = res.Output.Baseinfo.Certno
  7387. PsnName = res.Output.Baseinfo.PsnName
  7388. Gend = res.Output.Baseinfo.Gend
  7389. Naty = res.Output.Baseinfo.Naty
  7390. Brdy = res.Output.Baseinfo.Brdy
  7391. Age = res.Output.Baseinfo.Age
  7392. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7393. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7394. infoStr = string(Iinfos)
  7395. idetinfoStr = string(Idetinfos)
  7396. infocode = res.Infcode
  7397. }
  7398. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7399. if id_card_type == 1 {
  7400. psn_info, _ := service.GetPsnByPatientId(id)
  7401. PsnNo = psn_info.PsnNo
  7402. PsnCertType = psn_info.PsnCertType
  7403. Certno = psn_info.Certno
  7404. PsnName = psn_info.PsnName
  7405. Gend = psn_info.Gend
  7406. Naty = psn_info.Naty
  7407. Brdy = psn_info.Brdy
  7408. Age = psn_info.Age
  7409. infoStr = psn_info.Insuinfo
  7410. idetinfoStr = psn_info.Idetinfo
  7411. infocode = 0
  7412. verify_number = psn_info.VerifyNumber
  7413. } else if id_card_type == 2 {
  7414. 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)
  7415. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7417. utils.ErrorLog("解析失败:%v", err)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. return
  7420. }
  7421. PsnNo = res.Output.Baseinfo.PsnNo
  7422. PsnCertType = res.Output.Baseinfo.PsnCertType
  7423. Certno = res.Output.Baseinfo.Certno
  7424. PsnName = res.Output.Baseinfo.PsnName
  7425. Gend = res.Output.Baseinfo.Gend
  7426. Naty = res.Output.Baseinfo.Naty
  7427. Brdy = res.Output.Baseinfo.Brdy
  7428. Age = res.Output.Baseinfo.Age
  7429. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7430. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7431. infoStr = string(Iinfos)
  7432. idetinfoStr = string(Idetinfos)
  7433. infocode = res.Infcode
  7434. }
  7435. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7436. var result string
  7437. var requestLog string
  7438. 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), "")
  7439. if id_card_type == 4 {
  7440. psn_info, _ := service.GetPsnByPatientId(id)
  7441. PsnNo = psn_info.PsnNo
  7442. PsnCertType = psn_info.PsnCertType
  7443. Certno = psn_info.Certno
  7444. PsnName = psn_info.PsnName
  7445. Gend = psn_info.Gend
  7446. Naty = psn_info.Naty
  7447. Brdy = psn_info.Brdy
  7448. Age = psn_info.Age
  7449. infoStr = psn_info.Insuinfo
  7450. idetinfoStr = psn_info.Idetinfo
  7451. infocode = 0
  7452. verify_number = psn_info.VerifyNumber
  7453. } else {
  7454. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7455. if miConfig.Code == "H15049901371" {
  7456. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7457. utils.ErrorLog("解析失败:%v", err)
  7458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7459. return
  7460. }
  7461. res.ErrMsg = res10265.ErrMsg
  7462. res.Output = res10265.Output
  7463. res.InfRefmsgid = res10265.InfRefmsgid
  7464. } else {
  7465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7466. utils.ErrorLog("解析失败:%v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. }
  7471. PsnNo = res.Output.Baseinfo.PsnNo
  7472. PsnCertType = res.Output.Baseinfo.PsnCertType
  7473. Certno = res.Output.Baseinfo.Certno
  7474. PsnName = res.Output.Baseinfo.PsnName
  7475. Gend = res.Output.Baseinfo.Gend
  7476. Naty = res.Output.Baseinfo.Naty
  7477. Brdy = res.Output.Baseinfo.Brdy
  7478. Age = res.Output.Baseinfo.Age
  7479. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7480. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7481. infoStr = string(Iinfos)
  7482. idetinfoStr = string(Idetinfos)
  7483. if miConfig.Code == "H15049901371" {
  7484. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7485. } else {
  7486. infocode = res.Infcode
  7487. }
  7488. }
  7489. } else {
  7490. var result string
  7491. var requestLog string
  7492. if miConfig.UserOrgId == 10138 {
  7493. if id_card_type != 4 || id_card_type != 1 {
  7494. var insa string
  7495. if len(patient.InsuplcAdmdvs) > 0 {
  7496. insa = patient.InsuplcAdmdvs
  7497. } else {
  7498. insa = miConfig.InsuplcAdmdvs
  7499. }
  7500. //psn_info, _ := service.GetPsnByPatientId(id)
  7501. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  7502. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  7503. }
  7504. } else {
  7505. var insa string
  7506. if len(patient.InsuplcAdmdvs) > 0 {
  7507. insa = patient.InsuplcAdmdvs
  7508. } else {
  7509. insa = miConfig.InsuplcAdmdvs
  7510. }
  7511. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  7512. }
  7513. if id_card_type == 4 || id_card_type == 1 {
  7514. psn_info, _ := service.GetPsnByPatientId(id)
  7515. PsnNo = psn_info.PsnNo
  7516. PsnCertType = psn_info.PsnCertType
  7517. Certno = psn_info.Certno
  7518. PsnName = psn_info.PsnName
  7519. Gend = psn_info.Gend
  7520. Naty = psn_info.Naty
  7521. Brdy = psn_info.Brdy
  7522. Age = psn_info.Age
  7523. infoStr = psn_info.Insuinfo
  7524. idetinfoStr = psn_info.Idetinfo
  7525. infocode = 0
  7526. verify_number = psn_info.VerifyNumber
  7527. } else {
  7528. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7529. if miConfig.Code == "H15049901371" {
  7530. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7531. utils.ErrorLog("解析失败:%v", err)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. return
  7534. }
  7535. res.ErrMsg = res10265.ErrMsg
  7536. res.Output = res10265.Output
  7537. res.InfRefmsgid = res10265.InfRefmsgid
  7538. } else {
  7539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7540. utils.ErrorLog("解析失败:%v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. }
  7545. PsnNo = res.Output.Baseinfo.PsnNo
  7546. PsnCertType = res.Output.Baseinfo.PsnCertType
  7547. Certno = res.Output.Baseinfo.Certno
  7548. PsnName = res.Output.Baseinfo.PsnName
  7549. Gend = res.Output.Baseinfo.Gend
  7550. Naty = res.Output.Baseinfo.Naty
  7551. Brdy = res.Output.Baseinfo.Brdy
  7552. Age = res.Output.Baseinfo.Age
  7553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7555. infoStr = string(Iinfos)
  7556. idetinfoStr = string(Idetinfos)
  7557. if miConfig.Code == "H15049901371" {
  7558. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7559. } else {
  7560. infocode = res.Infcode
  7561. }
  7562. }
  7563. }
  7564. if infocode == 0 {
  7565. his := models.VMHisPatient{
  7566. Name: name,
  7567. Gender: gender,
  7568. Birthday: birthUnix,
  7569. MedicalTreatmentType: medical_care,
  7570. IdType: certificates,
  7571. IdCardNo: id_card,
  7572. BalanceAccountsType: settlementValue,
  7573. SocialType: social_type,
  7574. MedicalInsuranceNumber: medical_insurance_card,
  7575. RegisterType: register_type,
  7576. RegisterCost: registration_fee,
  7577. TreatmentCost: medical_expenses,
  7578. Status: 1,
  7579. Ctime: time.Now().Unix(),
  7580. Mtime: time.Now().Unix(),
  7581. PsnNo: PsnNo,
  7582. PsnCertType: PsnCertType,
  7583. Certno: Certno,
  7584. PsnName: PsnName,
  7585. Gend: Gend,
  7586. Naty: Naty,
  7587. Brdy: Brdy,
  7588. Age: Age,
  7589. Iinfo: infoStr,
  7590. Idetinfo: idetinfoStr,
  7591. PatientId: patient.ID,
  7592. RecordDate: theTime.Unix(),
  7593. UserOrgId: adminInfo.CurrentOrgId,
  7594. AdminUserId: admin_user_id,
  7595. IsReturn: 1,
  7596. IdCardType: id_card_type,
  7597. Doctor: doctor,
  7598. Departments: department,
  7599. MdtrtGrpType: mdtrt_type,
  7600. }
  7601. timestamp := time.Now().Unix()
  7602. tempTime := time.Unix(timestamp, 0)
  7603. timeFormat := tempTime.Format("20060102150405")
  7604. chrgBchno := rand.Intn(100000) + 10000
  7605. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7606. his.Number = ipt_otp_no
  7607. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  7608. department, _ := service.GetDepartMentDetail(department)
  7609. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  7610. IdCardNo := ""
  7611. if id_card_type == 1 {
  7612. // IdCardNo = medical_insurance_card
  7613. IdCardNo = patient.IdCardNo
  7614. } else {
  7615. IdCardNo = patient.IdCardNo
  7616. }
  7617. var rf []*ResultFive
  7618. json.Unmarshal([]byte(his.Iinfo), &rf)
  7619. var insutypes []*ResultFive
  7620. var insutype string
  7621. var insuplc_admdvs_temp string
  7622. var is390 int = 0
  7623. var is310 int = 0
  7624. for _, item := range rf {
  7625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7626. insutypes = append(insutypes, item)
  7627. }
  7628. }
  7629. if len(insutypes) == 1 {
  7630. insutype = insutypes[0].Insutype
  7631. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7632. } else {
  7633. for _, i := range insutypes {
  7634. if i.Insutype == "390" {
  7635. is390 = 1
  7636. }
  7637. if i.Insutype == "310" {
  7638. is310 = 1
  7639. }
  7640. }
  7641. }
  7642. if is390 == 1 {
  7643. insutype = "390"
  7644. }
  7645. if is310 == 1 {
  7646. insutype = "310"
  7647. }
  7648. if len(insutypes) == 0 {
  7649. insutype = "390"
  7650. }
  7651. if len(insutypes) == 2 {
  7652. insutype = med_type
  7653. }
  7654. if len(med_type) > 0 {
  7655. insutype = med_type
  7656. }
  7657. var infocode int64
  7658. var resThree ResultThree
  7659. var resThree10265 ResultThree10265
  7660. if len(insuplc_admdvs) == 0 {
  7661. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  7662. } else {
  7663. insuplc_admdvs_temp = insuplc_admdvs
  7664. }
  7665. if miConfig.MdtrtareaAdmvs == "350500" {
  7666. var rf []*ResultIDInfo
  7667. json.Unmarshal([]byte(idetinfoStr), &rf)
  7668. if len(rf) > 0 {
  7669. if len(rf[0].Memo) > 0 {
  7670. content := rf[0].Memo[1:len(rf[0].Memo)]
  7671. content2 := content[:len(content)-1]
  7672. fmt.Println(content2)
  7673. //var rf2 ResultMemo
  7674. //json.Unmarshal([]byte(content2), &rf2)
  7675. //fmt.Println(rf2)
  7676. //fmt.Println(rf2.InsuAdmdvs)
  7677. arr := strings.Split(content2, ",")
  7678. var tarstring string
  7679. for _, item := range arr {
  7680. if find := strings.Contains(item, "insuAdmdvs"); find {
  7681. tarstring = item
  7682. }
  7683. }
  7684. fmt.Println(tarstring)
  7685. if len(tarstring) > 0 {
  7686. arr := strings.Split(tarstring, ":")
  7687. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  7688. //insuplc_admdvs_temp = arr[1]
  7689. }
  7690. }
  7691. }
  7692. }
  7693. if miConfig.MdtrtareaAdmvs == "421300" {
  7694. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  7695. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  7696. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7697. "&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
  7698. resp, requestErr := http.Get(api)
  7699. if requestErr != nil {
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. return
  7702. }
  7703. body, ioErr := ioutil.ReadAll(resp.Body)
  7704. if ioErr != nil {
  7705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7707. return
  7708. }
  7709. var respJSON map[string]interface{}
  7710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7716. result, _ := json.Marshal(respJSON)
  7717. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7718. utils.ErrorLog("解析失败:%v", err)
  7719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7720. return
  7721. }
  7722. infocode = resThree.Infcode
  7723. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7724. psn_info, _ := service.GetPsnByPatientId(id)
  7725. his.PsnNo = psn_info.PsnNo
  7726. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7727. var cert_no string
  7728. if id_card_type == 3 {
  7729. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7730. cert_no = IdCardNo
  7731. } else if id_card_type == 4 {
  7732. cert_no = IdCardNo
  7733. psn_info.VerifyNumber = psn_info.VerifyNumber
  7734. } else {
  7735. bas := strings.Split(psn_info.CardInfo, "|")
  7736. cert_no = bas[2]
  7737. }
  7738. var hisPrescription []*models.HisPrescription
  7739. for _, item := range rf {
  7740. if item.Insutype == insutype {
  7741. //insuplc_admdvs = item.InsuplcAdmdvs
  7742. his.InsuplcAdmdvs = insuplc_admdvs
  7743. }
  7744. }
  7745. his.Insutype = insutype
  7746. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7747. fmt.Println(res3101)
  7748. fmt.Println(res3101.Infcode)
  7749. if res3101.Infcode == "0" {
  7750. fmt.Println("33333333")
  7751. if len(res3101.Output.Result) > 0 {
  7752. fmt.Println("222222")
  7753. for _, item := range res3101.Output.Result {
  7754. if len(res3101.ErrMsg) == 0 {
  7755. res3101.ErrMsg = item.VolaCont
  7756. } else {
  7757. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7758. }
  7759. }
  7760. c.ServeSuccessJSON(map[string]interface{}{
  7761. "failed_code": -10,
  7762. "msg": res3101.ErrMsg,
  7763. })
  7764. return
  7765. } else {
  7766. fmt.Println("11111")
  7767. var api string
  7768. if miConfig.MdtrtareaAdmvs == "320921" {
  7769. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7770. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7771. "&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
  7772. } else {
  7773. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7774. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7775. "&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
  7776. }
  7777. resp, requestErr := http.Get(api)
  7778. if requestErr != nil {
  7779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7780. return
  7781. }
  7782. body, ioErr := ioutil.ReadAll(resp.Body)
  7783. if ioErr != nil {
  7784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. var respJSON map[string]interface{}
  7789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7795. result, _ := json.Marshal(respJSON)
  7796. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. resThree.ErrMsg = resThree10265.ErrMsg
  7802. resThree.Output = resThree10265.Output
  7803. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7804. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7805. }
  7806. } else if res3101.Infcode != "0" {
  7807. c.ServeSuccessJSON(map[string]interface{}{
  7808. "failed_code": -10,
  7809. "msg": res3101.ErrMsg,
  7810. })
  7811. return
  7812. }
  7813. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7814. psn_info, _ := service.GetPsnByPatientId(id)
  7815. var cert_no string
  7816. if id_card_type == 1 {
  7817. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7818. } else if id_card_type == 4 {
  7819. cert_no = psn_info.VerifyNumber
  7820. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7821. } else {
  7822. cert_no = psn_info.VerifyNumber
  7823. }
  7824. 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)
  7825. saveLog(result, requestLog, "2201", "挂号")
  7826. if miConfig.Code == "H15049901371" {
  7827. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7828. utils.ErrorLog("解析失败:%v", err)
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. return
  7831. }
  7832. resThree.ErrMsg = resThree10265.ErrMsg
  7833. resThree.Output = resThree10265.Output
  7834. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7835. } else {
  7836. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7837. utils.ErrorLog("解析失败:%v", err)
  7838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7839. return
  7840. }
  7841. }
  7842. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7843. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7844. psn_info, _ := service.GetPsnByPatientId(id)
  7845. var result string
  7846. var requestLog string
  7847. if id_card_type == 1 {
  7848. bas := strings.Split(psn_info.CardInfo, "|")
  7849. basNumber := bas[2]
  7850. card_sn := bas[3]
  7851. 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)
  7852. saveLog(result, requestLog, "2201A", "挂号")
  7853. } else if id_card_type == 2 {
  7854. 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, "", "")
  7855. saveLog(result, requestLog, "2201A", "挂号")
  7856. } else {
  7857. 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, "", "")
  7858. saveLog(result, requestLog, "2201A", "挂号")
  7859. }
  7860. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7861. utils.ErrorLog("解析失败:%v", err)
  7862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. return
  7864. }
  7865. infocode = resThree.Infcode
  7866. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7867. psn_info, _ := service.GetPsnByPatientId(id)
  7868. var result string
  7869. var requestLog string
  7870. if id_card_type == 1 {
  7871. bas := strings.Split(psn_info.CardInfo, "|")
  7872. basNumber := bas[2]
  7873. card_sn := bas[3]
  7874. 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)
  7875. saveLog(result, requestLog, "2201A", "挂号")
  7876. } else if id_card_type == 2 {
  7877. 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, "", "")
  7878. saveLog(result, requestLog, "2201A", "挂号")
  7879. } else {
  7880. 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, "", "")
  7881. saveLog(result, requestLog, "2201A", "挂号")
  7882. }
  7883. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7884. utils.ErrorLog("解析失败:%v", err)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. infocode = resThree.Infcode
  7889. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7890. psn_info, _ := service.GetPsnByPatientId(id)
  7891. 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)
  7892. saveLog(result, requestLog, "2201A", "挂号")
  7893. if miConfig.Code == "H15049901371" {
  7894. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7895. utils.ErrorLog("解析失败:%v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. resThree.ErrMsg = resThree10265.ErrMsg
  7900. resThree.Output = resThree10265.Output
  7901. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7902. } else {
  7903. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7904. utils.ErrorLog("解析失败:%v", err)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. }
  7909. if miConfig.Code == "H15049901371" {
  7910. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7911. } else {
  7912. infocode = resThree.Infcode
  7913. }
  7914. } else {
  7915. psn_info, _ := service.GetPsnByPatientId(id)
  7916. if id_card_type == 4 || id_card_type == 1 {
  7917. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7918. }
  7919. var rf []*ResultFive
  7920. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  7921. var insutypes []*ResultFive
  7922. var insutype string
  7923. var is390 int = 0
  7924. var is310 int = 0
  7925. for _, item := range rf {
  7926. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7927. insutypes = append(insutypes, item)
  7928. }
  7929. }
  7930. if len(insutypes) == 1 {
  7931. insutype = insutypes[0].Insutype
  7932. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7933. } else {
  7934. for _, i := range insutypes {
  7935. if i.Insutype == "390" {
  7936. is390 = 1
  7937. }
  7938. if i.Insutype == "310" {
  7939. is310 = 1
  7940. }
  7941. }
  7942. }
  7943. if is390 == 1 {
  7944. insutype = "390"
  7945. }
  7946. if is310 == 1 {
  7947. insutype = "310"
  7948. }
  7949. if len(insutypes) == 0 {
  7950. insutype = "310"
  7951. }
  7952. 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)
  7953. saveLog(result, requestLog, "2201A", "挂号")
  7954. if miConfig.Code == "H15049901371" {
  7955. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. resThree.ErrMsg = resThree10265.ErrMsg
  7961. resThree.Output = resThree10265.Output
  7962. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7963. } else {
  7964. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7965. utils.ErrorLog("解析失败:%v", err)
  7966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7967. return
  7968. }
  7969. }
  7970. if miConfig.Code == "H15049901371" {
  7971. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7972. } else {
  7973. infocode = resThree.Infcode
  7974. }
  7975. }
  7976. if infocode != 0 {
  7977. adminUser := c.GetAdminUserInfo()
  7978. errlog := &models.HisOrderError{
  7979. UserOrgId: adminUser.CurrentOrgId,
  7980. Ctime: time.Now().Unix(),
  7981. Mtime: time.Now().Unix(),
  7982. ErrMsg: resThree.ErrMsg,
  7983. Status: 1,
  7984. PatientId: id,
  7985. RecordTime: recordDateTime,
  7986. Stage: 2,
  7987. }
  7988. service.CreateErrMsgLog(errlog)
  7989. c.ServeSuccessJSON(map[string]interface{}{
  7990. "failed_code": -10,
  7991. "msg": resThree.ErrMsg,
  7992. })
  7993. return
  7994. }
  7995. his.Number = resThree.Output.Data.MdtrtID
  7996. his.PsnNo = resThree.Output.Data.PsnNo
  7997. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7998. his.IdCardNo = patient.IdCardNo
  7999. his.PhoneNumber = patient.Phone
  8000. his.UserOrgId = adminInfo.CurrentOrgId
  8001. his.Insutype = insutype
  8002. his.Ctime = time.Now().Unix()
  8003. his.Mtime = time.Now().Unix()
  8004. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8005. his.Status = 1
  8006. his.MdtrtGrpType = mdtrt_type
  8007. service.UpdateHisPatientStatus(&his)
  8008. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8009. c.ServeSuccessJSON(map[string]interface{}{
  8010. "his_info": his,
  8011. })
  8012. } else {
  8013. adminUser := c.GetAdminUserInfo()
  8014. errlog := &models.HisOrderError{
  8015. UserOrgId: adminUser.CurrentOrgId,
  8016. Ctime: time.Now().Unix(),
  8017. Mtime: time.Now().Unix(),
  8018. ErrMsg: res.ErrMsg,
  8019. Status: 1,
  8020. PatientId: id,
  8021. RecordTime: recordDateTime,
  8022. Stage: 1,
  8023. }
  8024. service.CreateErrMsgLog(errlog)
  8025. c.ServeSuccessJSON(map[string]interface{}{
  8026. "failed_code": -10,
  8027. "msg": res.ErrMsg,
  8028. })
  8029. return
  8030. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8031. }
  8032. }
  8033. }
  8034. //
  8035. func (c *HisApiController) GetUploadInfo() {
  8036. id, _ := c.GetInt64("id")
  8037. record_time := c.GetString("record_time")
  8038. his_patient_id, _ := c.GetInt64("his_patient_id")
  8039. order_id, _ := c.GetInt64("order_id")
  8040. pay_way, _ := c.GetInt64("pay_way")
  8041. pay_ways := c.GetString("pay_ways")
  8042. oth_desc := c.GetString("oth_desc")
  8043. pay_price, _ := c.GetFloat("pay_price")
  8044. pay_card_no := c.GetString("pay_card_no")
  8045. discount_price, _ := c.GetFloat("discount_price")
  8046. preferential_price, _ := c.GetFloat("preferential_price")
  8047. reality_price, _ := c.GetFloat("reality_price")
  8048. found_price, _ := c.GetFloat("found_price")
  8049. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  8050. private_price, _ := c.GetFloat("private_price")
  8051. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8052. admin_user_id, _ := c.GetInt64("admin_user_id")
  8053. fapiao_code := c.GetString("fapiao_code")
  8054. fapiao_number := c.GetString("fapiao_number")
  8055. diagnosis_id := c.GetString("diagnosis")
  8056. sick_type, _ := c.GetInt64("sick_type")
  8057. reg_type, _ := c.GetInt64("p_type")
  8058. begin_time := c.GetString("begin_time")
  8059. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  8060. cash_pay := c.GetString("cash_pay")
  8061. band_card_pay := c.GetString("band_card_pay")
  8062. wechat_pay := c.GetString("wechat_pay")
  8063. ali_pay := c.GetString("ali_pay")
  8064. jifen_pay := c.GetString("jifen_pay")
  8065. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  8066. fmt.Println(acct_used_flag)
  8067. id_str := c.GetString("ids")
  8068. ids_arr := strings.Split(id_str, ",")
  8069. timeLayout := "2006-01-02"
  8070. loc, _ := time.LoadLocation("Local")
  8071. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8072. if err != nil {
  8073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8074. return
  8075. }
  8076. recordDateTime := theTime.Unix()
  8077. adminUser := c.GetAdminUserInfo()
  8078. var tempOrder models.HisOrder
  8079. tempOrder, _ = service.GetHisOrderByID(order_id)
  8080. var prescriptions []*models.HisPrescription
  8081. var start_time int64
  8082. var end_time int64
  8083. //押金模块
  8084. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  8085. tmp_decimal := c.GetString("tmp_decimal")
  8086. var decimal float64 //本次使用的押金
  8087. var errmsg error
  8088. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  8089. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  8090. return
  8091. }
  8092. if len(tmp_decimal) > 0 {
  8093. if tmp_decimal[0] == 45 {
  8094. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  8095. return
  8096. }
  8097. }
  8098. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  8099. fmt.Println(errs)
  8100. decimal = tt
  8101. //if adminUser.CurrentOrgId == 10106{
  8102. // if len(fapiao_code) == 0{
  8103. // fapiao_code = "144072080589"
  8104. // }
  8105. // if len(fapiao_number) == 0{
  8106. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  8107. // if order.ID == 0{
  8108. // fapiao_number = "00001520"
  8109. // }else{
  8110. // //fapiao_code = "00001520"
  8111. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  8112. // var zero string
  8113. // if fpNumber >= 1000{
  8114. // zero = "0000" + strconv.Itoa(fpNumber)
  8115. // }else if fpNumber >= 10000{
  8116. // zero = "000" + strconv.Itoa(fpNumber)
  8117. // } else if fpNumber >= 100000{
  8118. // zero = "00" + strconv.Itoa(fpNumber)
  8119. // } else if fpNumber >= 1000000{
  8120. // zero = "0" + strconv.Itoa(fpNumber)
  8121. // }else {
  8122. // zero = strconv.Itoa(fpNumber)
  8123. // }
  8124. // fapiao_number = zero
  8125. // }
  8126. // }
  8127. //}
  8128. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8129. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8130. var patientPrescription models.HisPrescriptionInfo
  8131. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8132. if patientPrescription.ID == 0 {
  8133. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8134. }
  8135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8136. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8137. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8138. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8139. var config []*models.HisXtDiagnoseConfig
  8140. for _, item := range diagnosis_ids {
  8141. id, _ := strconv.ParseInt(item, 10, 64)
  8142. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8143. config = append(config, &diagnosisConfig)
  8144. }
  8145. sickConfig, _ := service.FindSickById(sick_type)
  8146. //if tempOrder.ID == 0 {
  8147. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  8148. //}
  8149. if tempOrder.ID == 0 {
  8150. var result string
  8151. var requestLog string
  8152. var res2 ResultSix
  8153. var ressix10265 ResultSix10265
  8154. if miConfig.MdtrtareaAdmvs == "421300" {
  8155. data := make(map[string]interface{})
  8156. client := &http.Client{}
  8157. data["psn_no"] = his.PsnNo
  8158. data["mdtrt_id"] = his.Number
  8159. data["opter"] = roles.UserName
  8160. data["org_name"] = miConfig.OrgName
  8161. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8162. data["doctor_id"] = doctor_info.DoctorNumber
  8163. data["doctor_name"] = doctor_info.UserName
  8164. data["department"] = department.Name
  8165. data["fixmedins_code"] = miConfig.Code
  8166. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8167. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8168. data["secret_key"] = miConfig.SecretKey
  8169. data["sick_code"] = sickConfig.CountryCode
  8170. data["sick_name"] = sickConfig.ClassName
  8171. data["dept"] = strconv.FormatInt(department.ID, 10)
  8172. data["config"] = config
  8173. data["begin_time"] = begin_time
  8174. bytesData, _ := json.Marshal(data)
  8175. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8176. resp, _ := client.Do(req)
  8177. defer resp.Body.Close()
  8178. body, ioErr := ioutil.ReadAll(resp.Body)
  8179. if ioErr != nil {
  8180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. var respJSON map[string]interface{}
  8185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8191. userJSONBytes, _ := json.Marshal(respJSON)
  8192. fmt.Println("log")
  8193. fmt.Println(string(userJSONBytes))
  8194. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8195. utils.ErrorLog("解析失败:%v", err)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8200. data := make(map[string]interface{})
  8201. client := &http.Client{}
  8202. data["psn_no"] = his.PsnNo
  8203. data["mdtrt_id"] = his.Number
  8204. data["doctor"] = roles.UserName
  8205. data["department"] = department.Name
  8206. data["org_name"] = miConfig.OrgName
  8207. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8208. data["doctor_id"] = doctor_info.DoctorNumber
  8209. data["new_doctor_name"] = doctor_info.UserName
  8210. data["fixmedins_code"] = miConfig.Code
  8211. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8212. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8213. data["secret_key"] = miConfig.SecretKey
  8214. data["sick_code"] = sickConfig.CountryCode
  8215. data["sick_name"] = sickConfig.ClassName
  8216. data["url"] = miConfig.Url
  8217. data["ak"] = miConfig.AccessKey
  8218. data["begin_time"] = begin_time
  8219. data["cainfo"] = miConfig.Cainfo
  8220. data["dept"] = strconv.FormatInt(department.ID, 10)
  8221. data["config"] = config
  8222. bytesData, _ := json.Marshal(data)
  8223. var req *http.Request
  8224. if miConfig.MdtrtareaAdmvs == "320921" {
  8225. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8226. //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 +
  8227. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  8228. } else {
  8229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8230. }
  8231. resp, _ := client.Do(req)
  8232. defer resp.Body.Close()
  8233. body, ioErr := ioutil.ReadAll(resp.Body)
  8234. if ioErr != nil {
  8235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8237. return
  8238. }
  8239. var respJSON map[string]interface{}
  8240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8243. return
  8244. }
  8245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8246. userJSONBytes, _ := json.Marshal(respJSON)
  8247. fmt.Println("log")
  8248. fmt.Println(string(userJSONBytes))
  8249. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  8250. utils.ErrorLog("解析失败:%v", err)
  8251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8252. return
  8253. }
  8254. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8255. res2.Output = ressix10265.Output
  8256. res2.ErrMsg = ressix10265.ErrMsg
  8257. res2.Cainfo = ressix10265.Cainfo
  8258. res2.WarnMsg = ressix10265.WarnMsg
  8259. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8260. res2.Infcode = infocode
  8261. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8262. 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)
  8263. saveLog(result, requestLog, "2203", "上传就诊信息")
  8264. var respJSON2 map[string]interface{}
  8265. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. return
  8269. }
  8270. userJSONBytes2, _ := json.Marshal(respJSON2)
  8271. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8272. utils.ErrorLog("解析失败:%v", err)
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8277. fmt.Println(result2)
  8278. fmt.Println(src_request)
  8279. } else {
  8280. if miConfig.MdtrtareaAdmvs == "440781" { //
  8281. 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)
  8282. } else {
  8283. if miConfig.Code == "H15049901371" {
  8284. //赤峰地区国家医保医疗类别
  8285. //职工透析:医疗类别选特殊情况门诊990502
  8286. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8287. var med_type string
  8288. if his.Insutype == "390" {
  8289. if reg_type == 14 {
  8290. med_type = "9933"
  8291. } else if reg_type == 11 {
  8292. med_type = "11"
  8293. }
  8294. } else if his.Insutype == "310" {
  8295. if reg_type == 14 {
  8296. med_type = "990502"
  8297. } else if reg_type == 11 {
  8298. med_type = "11"
  8299. }
  8300. }
  8301. 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)
  8302. } else {
  8303. 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)
  8304. }
  8305. }
  8306. saveLog(result, requestLog, "2203", "上传就诊信息")
  8307. var respJSON2 map[string]interface{}
  8308. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. userJSONBytes2, _ := json.Marshal(respJSON2)
  8314. if miConfig.Code == "H15049901371" {
  8315. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  8316. utils.ErrorLog("解析失败:%v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8321. res2.Output = ressix10265.Output
  8322. res2.ErrMsg = ressix10265.ErrMsg
  8323. res2.Cainfo = ressix10265.Cainfo
  8324. res2.WarnMsg = ressix10265.WarnMsg
  8325. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8326. res2.Infcode = infocode
  8327. } else {
  8328. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8329. utils.ErrorLog("解析失败:%v", err)
  8330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8331. return
  8332. }
  8333. }
  8334. }
  8335. if res2.Infcode != 0 {
  8336. adminUser := c.GetAdminUserInfo()
  8337. errlog := &models.HisOrderError{
  8338. UserOrgId: adminUser.CurrentOrgId,
  8339. Ctime: time.Now().Unix(),
  8340. Mtime: time.Now().Unix(),
  8341. ErrMsg: res2.ErrMsg,
  8342. Status: 1,
  8343. PatientId: id,
  8344. RecordTime: recordDateTime,
  8345. Stage: 3,
  8346. }
  8347. service.CreateErrMsgLog(errlog)
  8348. c.ServeSuccessJSON(map[string]interface{}{
  8349. "failed_code": -10,
  8350. "msg": res2.ErrMsg,
  8351. })
  8352. return
  8353. } else {
  8354. his.Diagnosis = diagnosis_id
  8355. his.SickType = sickConfig.ID
  8356. //var p_type int64
  8357. //if reg_type == 1111 || reg_type == 1112 {
  8358. // p_type = 11
  8359. //
  8360. //}
  8361. his.PType = fmt.Sprintf("%d", reg_type)
  8362. service.UpdateHisPatientThree(&his)
  8363. data := make(map[string]interface{})
  8364. if settle_accounts_type == 1 { //日结
  8365. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  8366. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  8367. } else {
  8368. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  8369. }
  8370. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  8371. data["pre"] = prescriptions
  8372. } else { //月结
  8373. start_time_str := c.GetString("start_time")
  8374. end_time_str := c.GetString("end_time")
  8375. timeLayout := "2006-01-02"
  8376. loc, _ := time.LoadLocation("Local")
  8377. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8378. if err != nil {
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8380. return
  8381. }
  8382. recordStartTime := theStartTime.Unix()
  8383. start_time = recordStartTime
  8384. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8385. if err != nil {
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8387. return
  8388. }
  8389. recordEndTime := theEndTime.Unix()
  8390. end_time = recordEndTime
  8391. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8392. data["pre"] = prescriptions
  8393. }
  8394. timestamp := time.Now().Unix()
  8395. tempTime := time.Unix(timestamp, 0)
  8396. timeFormat := tempTime.Format("20060102150405")
  8397. chrgBchno := rand.Intn(100000) + 10000
  8398. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8399. strconv.FormatInt(his.PatientId, 10)
  8400. client := &http.Client{}
  8401. data["psn_no"] = his.PsnNo
  8402. data["mdtrt_id"] = his.Number
  8403. data["chrg_bchno"] = chrg_bchno
  8404. data["org_name"] = miConfig.OrgName
  8405. data["doctor"] = doctor_info.UserName
  8406. data["doctor_id"] = doctor_info.DoctorNumber
  8407. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8408. data["fixmedins_code"] = miConfig.Code
  8409. data["opter"] = roles.UserName
  8410. data["dept_code"] = department.Number
  8411. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8412. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8413. data["secret_key"] = miConfig.SecretKey
  8414. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8415. data["url"] = miConfig.Url
  8416. data["ak"] = miConfig.AccessKey
  8417. data["new_doctor_name"] = patientPrescription.Doctor
  8418. data["diag_code"] = sickConfig.CountryCode
  8419. data["cainfo"] = miConfig.Cainfo
  8420. data["opter"] = roles.UserName
  8421. var ids []int64
  8422. for _, item := range prescriptions {
  8423. ids = append(ids, item.ID)
  8424. }
  8425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8426. if config.IsOpen == 1 { //对接了医保,走医保流程
  8427. var res ResultFour
  8428. var resFour10265 ResultFour10265
  8429. if miConfig.MdtrtareaAdmvs == "421300" {
  8430. bytesData, _ := json.Marshal(data)
  8431. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8432. resp, _ := client.Do(req)
  8433. defer resp.Body.Close()
  8434. body, ioErr := ioutil.ReadAll(resp.Body)
  8435. if ioErr != nil {
  8436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. var respJSON map[string]interface{}
  8441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8447. userJSONBytes, _ := json.Marshal(respJSON)
  8448. fmt.Println("log")
  8449. fmt.Println(string(userJSONBytes))
  8450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8456. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8457. if result3101.Infcode == "0" {
  8458. if len(result3101.Output.Result) > 0 {
  8459. var errMsgs []string
  8460. for _, item := range result3101.Output.Result {
  8461. errMsgs = append(errMsgs, item.VolaCont)
  8462. }
  8463. c.ServeSuccessJSON(map[string]interface{}{
  8464. "failed_code": -10,
  8465. "msg": errMsgs,
  8466. })
  8467. return
  8468. }
  8469. }
  8470. if miConfig.MdtrtareaAdmvs == "320921" {
  8471. data["doctor_id"] = "D320923012139"
  8472. } else {
  8473. data["doctor_id"] = "D371621008686"
  8474. }
  8475. bytesData, _ := json.Marshal(data)
  8476. var req *http.Request
  8477. if miConfig.MdtrtareaAdmvs == "320921" {
  8478. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8479. } else {
  8480. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8481. }
  8482. resp, _ := client.Do(req)
  8483. defer resp.Body.Close()
  8484. body, ioErr := ioutil.ReadAll(resp.Body)
  8485. if ioErr != nil {
  8486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8488. return
  8489. }
  8490. var respJSON map[string]interface{}
  8491. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8494. return
  8495. }
  8496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8497. userJSONBytes, _ := json.Marshal(respJSON)
  8498. fmt.Println("log")
  8499. fmt.Println(string(userJSONBytes))
  8500. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8501. utils.ErrorLog("解析失败:%v", err)
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. res.InfRefmsgid = resFour10265.InfRefmsgid
  8506. res.Output = resFour10265.Output
  8507. res.ErrMsg = resFour10265.ErrMsg
  8508. res.Cainfo = resFour10265.Cainfo
  8509. res.WarnMsg = resFour10265.WarnMsg
  8510. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8511. res.Infcode = infocode
  8512. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8513. 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)
  8514. var dat map[string]interface{}
  8515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8516. fmt.Println(dat)
  8517. } else {
  8518. fmt.Println(err)
  8519. }
  8520. saveLog(result, request_log, "2204", "上传费用明细")
  8521. userJSONBytes, _ := json.Marshal(dat)
  8522. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8523. utils.ErrorLog("解析失败:%v", err)
  8524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8525. return
  8526. }
  8527. res.InfRefmsgid = resFour10265.InfRefmsgid
  8528. res.Output = resFour10265.Output
  8529. res.ErrMsg = resFour10265.ErrMsg
  8530. res.Cainfo = resFour10265.Cainfo
  8531. res.WarnMsg = resFour10265.WarnMsg
  8532. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8533. res.Infcode = infocode
  8534. } else {
  8535. if miConfig.Code == "H15049901371" {
  8536. 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)
  8537. var dat map[string]interface{}
  8538. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8539. fmt.Println(dat)
  8540. } else {
  8541. fmt.Println(err)
  8542. }
  8543. saveLog(result, request_log, "2204", "上传费用明细")
  8544. userJSONBytes, _ := json.Marshal(dat)
  8545. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. res.InfRefmsgid = resFour10265.InfRefmsgid
  8551. res.Output = resFour10265.Output
  8552. res.ErrMsg = resFour10265.ErrMsg
  8553. res.Cainfo = resFour10265.Cainfo
  8554. res.WarnMsg = resFour10265.WarnMsg
  8555. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8556. res.Infcode = infocode
  8557. } else {
  8558. 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)
  8559. var dat map[string]interface{}
  8560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8561. fmt.Println(dat)
  8562. } else {
  8563. fmt.Println(err)
  8564. }
  8565. saveLog(result, request_log, "2204", "上传费用明细")
  8566. userJSONBytes, _ := json.Marshal(dat)
  8567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8568. utils.ErrorLog("解析失败:%v", err)
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8570. return
  8571. }
  8572. }
  8573. }
  8574. if res.Infcode == 0 {
  8575. order := &models.HisOrder{
  8576. UserOrgId: adminUser.CurrentOrgId,
  8577. HisPatientId: his.ID,
  8578. PatientId: his.PatientId,
  8579. SettleAccountsDate: recordDateTime,
  8580. MdtrtId: his.Number,
  8581. PsnNo: his.PsnNo,
  8582. MedType: strconv.FormatInt(reg_type, 10),
  8583. Ctime: time.Now().Unix(),
  8584. Mtime: time.Now().Unix(),
  8585. Status: 1,
  8586. Number: chrg_bchno,
  8587. Infcode: res.Infcode,
  8588. WarnMsg: res.WarnMsg,
  8589. Cainfo: res.Cainfo,
  8590. ErrMsg: res.ErrMsg,
  8591. RespondTime: res.RefmsgTime,
  8592. InfRefmsgid: res.InfRefmsgid,
  8593. OrderStatus: 1,
  8594. PayWay: pay_way,
  8595. PayWays: pay_ways,
  8596. OthDesc: oth_desc,
  8597. PayPrice: pay_price,
  8598. PayCardNo: pay_card_no,
  8599. DiscountPrice: discount_price,
  8600. PreferentialPrice: preferential_price,
  8601. RealityPrice: reality_price,
  8602. FoundPrice: found_price,
  8603. MedicalInsurancePrice: medical_insurance_price,
  8604. PrivatePrice: private_price,
  8605. IsMedicineInsurance: 1,
  8606. SettleType: settle_accounts_type,
  8607. SettleStartTime: start_time,
  8608. SettleEndTime: end_time,
  8609. Creator: roles.AdminUserId,
  8610. Modify: roles.AdminUserId,
  8611. FaPiaoNumber: fapiao_number,
  8612. FaPiaoCode: fapiao_code,
  8613. PType: 2,
  8614. Diagnosis: diagnosis_id,
  8615. CashPay: cash_pay,
  8616. WechatPay: wechat_pay,
  8617. AliPay: ali_pay,
  8618. JifenPay: jifen_pay,
  8619. BandCardPay: band_card_pay,
  8620. }
  8621. err = service.CreateOrder(order)
  8622. if err != nil {
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8624. return
  8625. }
  8626. for _, item := range res.Output.Result {
  8627. temp := strings.Split(item.FeedetlSn, "-")
  8628. var advice_id int64 = 0
  8629. var project_id int64 = 0
  8630. var types int64 = 0
  8631. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8632. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8633. if temp[1] == "1" {
  8634. advice_id = id
  8635. project_id = 0
  8636. } else if temp[1] == "2" {
  8637. advice_id = 0
  8638. project_id = id
  8639. }
  8640. if item.MedChrgitmType == "9" {
  8641. item.MedChrgitmType = "09"
  8642. }
  8643. info := &models.HisOrderInfo{
  8644. OrderNumber: order.Number,
  8645. FeedetlSn: item.FeedetlSn,
  8646. UploadDate: time.Now().Unix(),
  8647. AdviceId: advice_id,
  8648. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8649. Cnt: item.Cnt,
  8650. Pric: float64(item.Pric),
  8651. PatientId: his.PatientId,
  8652. PricUplmtAmt: item.PricUplmtAmt,
  8653. SelfpayProp: item.SelfpayProp,
  8654. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8655. OverlmtAmt: item.OverlmtAmt,
  8656. PreselfpayAmt: item.PreselfpayAmt,
  8657. BasMednFlag: item.BasMednFlag,
  8658. MedChrgitmType: item.MedChrgitmType,
  8659. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8660. Status: 1,
  8661. Memo: item.Memo,
  8662. Mtime: time.Now().Unix(),
  8663. InscpScpAmt: item.InscpScpAmt,
  8664. DrtReimFlag: item.DrtReimFlag,
  8665. Ctime: time.Now().Unix(),
  8666. ListSpItemFlag: item.ListSpItemFlag,
  8667. ChldMedcFlag: item.ChldMedcFlag,
  8668. LmtUsedFlag: item.LmtUsedFlag,
  8669. ChrgitmLv: item.ChrgitmLv,
  8670. UserOrgId: adminUser.CurrentOrgId,
  8671. HisPatientId: his.ID,
  8672. OrderId: order.ID,
  8673. ProjectId: project_id,
  8674. Type: types,
  8675. }
  8676. service.CreateOrderInfo(info)
  8677. }
  8678. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8679. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8680. var total float64
  8681. for _, item := range prescriptions {
  8682. if item.Type == 1 { //药品
  8683. for _, subItem := range item.HisDoctorAdviceInfo {
  8684. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8685. total_one := price * subItem.PrescribingNumber
  8686. total = total + total_one
  8687. }
  8688. }
  8689. if item.Type == 2 { //项目
  8690. for _, subItem := range item.HisPrescriptionProject {
  8691. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8692. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8693. total_one := price * cnt
  8694. total = total + total_one
  8695. }
  8696. }
  8697. }
  8698. allTotal := fmt.Sprintf("%f", total)
  8699. //if adminUser.CurrentOrgId == 9919 {
  8700. //
  8701. // allTotal = fmt.Sprintf("%.2f", total)
  8702. //
  8703. //} else {
  8704. //
  8705. // allTotal = fmt.Sprintf("%.2f", total)
  8706. //
  8707. //}
  8708. if res.Infcode == 0 {
  8709. var rf []*ResultFive
  8710. json.Unmarshal([]byte(his.Iinfo), &rf)
  8711. chrg_bchno := chrg_bchno
  8712. cert_no := his.Certno
  8713. var insutypes []string
  8714. var insutype string
  8715. var is390 int = 0
  8716. var is310 int = 0
  8717. for _, item := range rf {
  8718. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8719. insutypes = append(insutypes, item.Insutype)
  8720. }
  8721. }
  8722. if len(insutypes) == 1 {
  8723. insutype = insutypes[0]
  8724. } else {
  8725. for _, i := range insutypes {
  8726. if i == "390" {
  8727. is390 = 1
  8728. }
  8729. if i == "310" {
  8730. is310 = 1
  8731. }
  8732. }
  8733. }
  8734. if is390 == 1 {
  8735. insutype = "390"
  8736. }
  8737. if is310 == 1 {
  8738. insutype = "310"
  8739. }
  8740. if len(insutypes) == 0 {
  8741. insutype = "310"
  8742. }
  8743. if len(insutypes) == 2 {
  8744. insutype = strconv.FormatInt(his.SocialType, 10)
  8745. }
  8746. insutype = strconv.FormatInt(his.SocialType, 10)
  8747. //insutype = "390"
  8748. if his.IdCardType == 1 {
  8749. // cert_no = his.MedicalInsuranceNumber
  8750. cert_no = his.Certno
  8751. } else {
  8752. cert_no = his.Certno
  8753. }
  8754. var res ResultSeven
  8755. var resSeven10265 ResultSeven10265
  8756. var src_resquest string
  8757. var result2 string
  8758. if miConfig.MdtrtareaAdmvs == "421300" {
  8759. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8760. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8761. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8762. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8763. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8764. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8765. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8766. resp, requestErr := http.Get(api)
  8767. if requestErr != nil {
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. body, ioErr := ioutil.ReadAll(resp.Body)
  8772. if ioErr != nil {
  8773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8775. return
  8776. }
  8777. var respJSON map[string]interface{}
  8778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8781. return
  8782. }
  8783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8784. result, _ := json.Marshal(respJSON)
  8785. if miConfig.Code == "H15049901371" {
  8786. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8787. utils.ErrorLog("解析失败:%v", err)
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8789. return
  8790. }
  8791. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8792. res.Output = resSeven10265.Output
  8793. res.ErrMsg = resSeven10265.ErrMsg
  8794. res.Cainfo = resSeven10265.Cainfo
  8795. res.WarnMsg = resSeven10265.WarnMsg
  8796. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8797. res.Infcode = infocode
  8798. } else {
  8799. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8800. utils.ErrorLog("解析失败:%v", err)
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8802. return
  8803. }
  8804. }
  8805. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8806. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8807. if result3101.Infcode == "0" {
  8808. if len(result3101.Output.Result) > 0 {
  8809. var errMsgs []string
  8810. for _, item := range result3101.Output.Result {
  8811. errMsgs = append(errMsgs, item.VolaCont)
  8812. }
  8813. c.ServeSuccessJSON(map[string]interface{}{
  8814. "failed_code": -10,
  8815. "msg": errMsgs,
  8816. })
  8817. return
  8818. } else {
  8819. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8820. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8821. bas := strings.Split(psn_info.CardInfo, "|")
  8822. if his.IdCardType == 1 {
  8823. cert_no = bas[2]
  8824. } else if his.IdCardType == 3 {
  8825. cert_no = his.Certno
  8826. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8827. } else if his.IdCardType == 4 {
  8828. cert_no = his.Certno
  8829. psn_info.VerifyNumber = psn_info.VerifyNumber
  8830. }
  8831. var api string
  8832. if miConfig.MdtrtareaAdmvs == "320921" {
  8833. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8834. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8835. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8837. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8838. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8839. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8840. } else {
  8841. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8842. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8843. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8845. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8846. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8847. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8848. }
  8849. resp, requestErr := http.Get(api)
  8850. if requestErr != nil {
  8851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8852. return
  8853. }
  8854. body, ioErr := ioutil.ReadAll(resp.Body)
  8855. if ioErr != nil {
  8856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. var respJSON map[string]interface{}
  8861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. return
  8865. }
  8866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8867. result, _ := json.Marshal(respJSON)
  8868. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8869. utils.ErrorLog("解析失败:%v", err)
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8874. res.Output = resSeven10265.Output
  8875. res.ErrMsg = resSeven10265.ErrMsg
  8876. res.Cainfo = resSeven10265.Cainfo
  8877. res.WarnMsg = resSeven10265.WarnMsg
  8878. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8879. res.Infcode = infocode
  8880. }
  8881. }
  8882. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8883. var cert_no string
  8884. if his.IdCardType == 4 {
  8885. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8886. cert_no = psn_info.VerifyNumber
  8887. 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)
  8888. } else if his.IdCardType == 1 {
  8889. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8890. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8891. 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)
  8892. }
  8893. //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)
  8894. var dat map[string]interface{}
  8895. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8896. fmt.Println(dat)
  8897. } else {
  8898. fmt.Println(err)
  8899. }
  8900. saveLog(result2, src_resquest, "2207", "结算")
  8901. userJSONBytes, _ := json.Marshal(dat)
  8902. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8903. utils.ErrorLog("解析失败:%v", err)
  8904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8905. return
  8906. }
  8907. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8908. res.Output = resSeven10265.Output
  8909. res.ErrMsg = resSeven10265.ErrMsg
  8910. res.Cainfo = resSeven10265.Cainfo
  8911. res.WarnMsg = resSeven10265.WarnMsg
  8912. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8913. res.Infcode = infocode
  8914. } else {
  8915. if miConfig.Code == "H15049901371" {
  8916. //赤峰地区国家医保医疗类别
  8917. //职工透析:医疗类别选特殊情况门诊990502
  8918. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8919. var med_type string
  8920. if his.Insutype == "390" {
  8921. if reg_type == 14 {
  8922. med_type = "9933"
  8923. } else if reg_type == 11 {
  8924. med_type = "11"
  8925. }
  8926. } else if his.Insutype == "310" {
  8927. if reg_type == 14 {
  8928. med_type = "990502"
  8929. } else if reg_type == 11 {
  8930. med_type = "11"
  8931. }
  8932. }
  8933. 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, "")
  8934. } else {
  8935. if his.IdCardType == 4 {
  8936. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8937. var token string
  8938. token = psn_info.VerifyNumber
  8939. 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)
  8940. } else {
  8941. 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, "")
  8942. }
  8943. }
  8944. //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)
  8945. var dat map[string]interface{}
  8946. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8947. fmt.Println(dat)
  8948. } else {
  8949. fmt.Println(err)
  8950. }
  8951. saveLog(result2, src_resquest, "2207", "结算")
  8952. userJSONBytes, _ := json.Marshal(dat)
  8953. if miConfig.Code == "H15049901371" {
  8954. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8955. utils.ErrorLog("解析失败:%v", err)
  8956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8957. return
  8958. }
  8959. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8960. res.Output = resSeven10265.Output
  8961. res.ErrMsg = resSeven10265.ErrMsg
  8962. res.Cainfo = resSeven10265.Cainfo
  8963. res.WarnMsg = resSeven10265.WarnMsg
  8964. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8965. res.Infcode = infocode
  8966. } else {
  8967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8968. utils.ErrorLog("解析失败:%v", err)
  8969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8970. return
  8971. }
  8972. }
  8973. }
  8974. if res.Infcode != 0 {
  8975. errlog := &models.HisOrderError{
  8976. UserOrgId: adminUser.CurrentOrgId,
  8977. Ctime: time.Now().Unix(),
  8978. Mtime: time.Now().Unix(),
  8979. Number: chrg_bchno,
  8980. ErrMsg: res.ErrMsg,
  8981. Status: 1,
  8982. PatientId: id,
  8983. RecordTime: recordDateTime,
  8984. Stage: 6,
  8985. }
  8986. service.CreateErrMsgLog(errlog)
  8987. c.ServeSuccessJSON(map[string]interface{}{
  8988. "failed_code": -10,
  8989. "msg": res.ErrMsg,
  8990. })
  8991. return
  8992. } else {
  8993. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8994. order.OrderStatus = 2
  8995. order.Status = 1
  8996. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8997. order.SetlId = res.Output.Setlinfo.SetlID
  8998. order.PsnNo = res.Output.Setlinfo.PsnNo
  8999. order.PsnName = res.Output.Setlinfo.PsnName
  9000. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9001. order.Certno = res.Output.Setlinfo.Certno
  9002. order.Gend = res.Output.Setlinfo.Gend
  9003. order.Naty = res.Output.Setlinfo.Naty
  9004. order.Age = res.Output.Setlinfo.Age
  9005. order.Insutype = res.Output.Setlinfo.Insutype
  9006. order.PsnType = res.Output.Setlinfo.PsnType
  9007. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9008. order.SetlTime = res.Output.Setlinfo.SetlTime
  9009. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9010. if res.Output.Setlinfo.MedType == "140101" {
  9011. order.MedType = "14"
  9012. } else {
  9013. order.MedType = res.Output.Setlinfo.MedType
  9014. }
  9015. if reg_type == 1112 {
  9016. order.MedType = "1112"
  9017. }
  9018. if reg_type == 1111 {
  9019. order.MedType = "1111"
  9020. }
  9021. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9022. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9023. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9024. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9025. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9026. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9027. order.HifpPay = res.Output.Setlinfo.HifpPay
  9028. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9029. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9030. order.HifesPay = res.Output.Setlinfo.HifesPay
  9031. order.HifobPay = res.Output.Setlinfo.HifobPay
  9032. order.MafPay = res.Output.Setlinfo.MafPay
  9033. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9034. order.OthPay = res.Output.Setlinfo.OthPay
  9035. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9036. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9037. order.AcctPay = res.Output.Setlinfo.AcctPay
  9038. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9039. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9040. order.Balc = res.Output.Setlinfo.Balc
  9041. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9042. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9043. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9044. order.ClrType = res.Output.Setlinfo.ClrType
  9045. order.ClrWay = res.Output.Setlinfo.ClrWay
  9046. order.Creator = order.Creator
  9047. order.Modify = roles.AdminUserId
  9048. order.RequestLog = src_resquest
  9049. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9050. detailStr := string(setlDetail)
  9051. order.SetlDetail = detailStr
  9052. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9053. err = service.UpDateOrder(order)
  9054. if err == nil {
  9055. //判断是否使用了押金
  9056. if dec_way == "true" {
  9057. tmpstring := strconv.FormatInt(order.ID, 10)
  9058. order.Decimal = decimal
  9059. service.UpDateOrder(order)
  9060. //扣押金
  9061. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9062. if errmsg != nil {
  9063. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9064. return
  9065. }
  9066. }
  9067. c.ServeSuccessJSON(map[string]interface{}{
  9068. "msg": "结算成功",
  9069. })
  9070. } else {
  9071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9072. return
  9073. }
  9074. }
  9075. } else {
  9076. adminUser := c.GetAdminUserInfo()
  9077. errlog := &models.HisOrderError{
  9078. UserOrgId: adminUser.CurrentOrgId,
  9079. Ctime: time.Now().Unix(),
  9080. Mtime: time.Now().Unix(),
  9081. ErrMsg: res.ErrMsg,
  9082. Status: 1,
  9083. PatientId: id,
  9084. RecordTime: recordDateTime,
  9085. Stage: 4,
  9086. }
  9087. service.CreateErrMsgLog(errlog)
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9089. return
  9090. }
  9091. } else {
  9092. adminUser := c.GetAdminUserInfo()
  9093. errlog := &models.HisOrderError{
  9094. UserOrgId: adminUser.CurrentOrgId,
  9095. Ctime: time.Now().Unix(),
  9096. Mtime: time.Now().Unix(),
  9097. ErrMsg: res.ErrMsg,
  9098. Status: 1,
  9099. PatientId: id,
  9100. RecordTime: recordDateTime,
  9101. Stage: 4,
  9102. }
  9103. service.CreateErrMsgLog(errlog)
  9104. c.ServeSuccessJSON(map[string]interface{}{
  9105. "failed_code": -10,
  9106. "msg": res.ErrMsg,
  9107. })
  9108. return
  9109. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9110. //return
  9111. }
  9112. }
  9113. }
  9114. } else if tempOrder.ID > 0 {
  9115. if tempOrder.IsPre == 1 {
  9116. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  9117. var rf []*ResultFive
  9118. json.Unmarshal([]byte(his.Iinfo), &rf)
  9119. chrg_bchno := tempOrder.Number
  9120. cert_no := his.Certno
  9121. var insutypes []string
  9122. var insutype string
  9123. var is390 int = 0
  9124. var is310 int = 0
  9125. for _, item := range rf {
  9126. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9127. insutypes = append(insutypes, item.Insutype)
  9128. }
  9129. }
  9130. if len(insutypes) == 1 {
  9131. insutype = insutypes[0]
  9132. } else {
  9133. for _, i := range insutypes {
  9134. if i == "390" {
  9135. is390 = 1
  9136. }
  9137. if i == "310" {
  9138. is310 = 1
  9139. }
  9140. }
  9141. }
  9142. if is390 == 1 {
  9143. insutype = "390"
  9144. }
  9145. if is310 == 1 {
  9146. insutype = "310"
  9147. }
  9148. if len(insutypes) == 0 {
  9149. insutype = "310"
  9150. }
  9151. if len(insutypes) == 2 {
  9152. insutype = strconv.FormatInt(his.SocialType, 10)
  9153. }
  9154. //insutype = "390"
  9155. if his.IdCardType == 1 {
  9156. // cert_no = his.MedicalInsuranceNumber
  9157. cert_no = his.Certno
  9158. } else {
  9159. cert_no = his.Certno
  9160. }
  9161. var res ResultSeven
  9162. var resSeven10265 ResultSeven10265
  9163. var src_resquest string
  9164. var result2 string
  9165. if miConfig.MdtrtareaAdmvs == "421300" {
  9166. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9167. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9168. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9169. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9170. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9171. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9172. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9173. resp, requestErr := http.Get(api)
  9174. if requestErr != nil {
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. body, ioErr := ioutil.ReadAll(resp.Body)
  9179. if ioErr != nil {
  9180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. return
  9183. }
  9184. var respJSON map[string]interface{}
  9185. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9191. result, _ := json.Marshal(respJSON)
  9192. fmt.Println("log")
  9193. fmt.Println(string(result))
  9194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9195. utils.ErrorLog("解析失败:%v", err)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9200. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  9201. if result3101.Infcode == "0" {
  9202. if len(result3101.Output.Result) > 0 {
  9203. var errMsgs []string
  9204. for _, item := range result3101.Output.Result {
  9205. errMsgs = append(errMsgs, item.VolaCont)
  9206. }
  9207. c.ServeSuccessJSON(map[string]interface{}{
  9208. "failed_code": -10,
  9209. "msg": errMsgs,
  9210. })
  9211. return
  9212. } else {
  9213. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9214. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9215. bas := strings.Split(psn_info.CardInfo, "|")
  9216. if his.IdCardType == 1 {
  9217. cert_no = bas[2]
  9218. } else if his.IdCardType == 3 {
  9219. cert_no = his.Certno
  9220. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9221. } else if his.IdCardType == 4 {
  9222. cert_no = his.Certno
  9223. psn_info.VerifyNumber = psn_info.VerifyNumber
  9224. }
  9225. //江苏地区国家医保医疗类别
  9226. //职工透析:医疗类别选特殊情况门诊9933
  9227. //居民血透门慢: 医疗类别选门诊慢病1402
  9228. //var med_type string
  9229. //if his.Insutype == "310" {
  9230. // if reg_type == 14 {
  9231. // med_type = "9933"
  9232. // } else if reg_type == 11 {
  9233. // med_type = "11"
  9234. //
  9235. // }
  9236. //} else if his.Insutype == "390" {
  9237. // if reg_type == 14 {
  9238. // med_type = "1402"
  9239. // } else if reg_type == 11 {
  9240. // med_type = "11"
  9241. // }
  9242. //}
  9243. var api string
  9244. if miConfig.MdtrtareaAdmvs == "320921" {
  9245. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9246. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9247. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9248. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9249. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9250. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9251. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9252. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9253. } else {
  9254. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9255. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9256. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9257. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9259. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9260. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9261. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9262. }
  9263. resp, requestErr := http.Get(api)
  9264. if requestErr != nil {
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. body, ioErr := ioutil.ReadAll(resp.Body)
  9269. if ioErr != nil {
  9270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. var respJSON map[string]interface{}
  9275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9278. return
  9279. }
  9280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9281. result, _ := json.Marshal(respJSON)
  9282. fmt.Println("log")
  9283. fmt.Println(string(result))
  9284. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9285. utils.ErrorLog("解析失败:%v", err)
  9286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9287. return
  9288. }
  9289. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9290. res.Output = resSeven10265.Output
  9291. res.ErrMsg = resSeven10265.ErrMsg
  9292. res.Cainfo = resSeven10265.Cainfo
  9293. res.WarnMsg = resSeven10265.WarnMsg
  9294. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9295. res.Infcode = infocode
  9296. }
  9297. }
  9298. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9299. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9300. var cert_no string
  9301. if his.IdCardType == 1 {
  9302. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9303. } else {
  9304. cert_no = psn_info.VerifyNumber
  9305. }
  9306. 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)
  9307. var dat map[string]interface{}
  9308. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9309. fmt.Println(dat)
  9310. } else {
  9311. fmt.Println(err)
  9312. }
  9313. saveLog(result2, src_resquest, "2207", "结算")
  9314. userJSONBytes, _ := json.Marshal(dat)
  9315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9316. utils.ErrorLog("解析失败:%v", err)
  9317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9318. return
  9319. }
  9320. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9321. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9322. var cert_no string
  9323. if his.IdCardType == 1 {
  9324. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9325. } else if his.IdCardType == 2 {
  9326. cert_no = his.IdCardNo
  9327. } else {
  9328. cert_no = psn_info.VerifyNumber
  9329. }
  9330. 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, "")
  9331. var dat map[string]interface{}
  9332. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9333. fmt.Println(dat)
  9334. } else {
  9335. fmt.Println(err)
  9336. }
  9337. saveLog(result2, src_resquest, "2207", "结算")
  9338. userJSONBytes, _ := json.Marshal(dat)
  9339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9340. utils.ErrorLog("解析失败:%v", err)
  9341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9342. return
  9343. }
  9344. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9345. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9346. var cert_no string
  9347. if his.IdCardType == 1 {
  9348. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9349. } else if his.IdCardType == 2 {
  9350. cert_no = his.IdCardNo
  9351. } else {
  9352. cert_no = psn_info.VerifyNumber
  9353. }
  9354. 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, "")
  9355. var dat map[string]interface{}
  9356. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9357. fmt.Println(dat)
  9358. } else {
  9359. fmt.Println(err)
  9360. }
  9361. saveLog(result2, src_resquest, "2207", "结算")
  9362. userJSONBytes, _ := json.Marshal(dat)
  9363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. } else {
  9369. var src_resquest string
  9370. if miConfig.Code == "H15049901371" {
  9371. //赤峰地区国家医保医疗类别
  9372. //职工透析:医疗类别选特殊情况门诊990502
  9373. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9374. var med_type string
  9375. if his.Insutype == "390" {
  9376. if reg_type == 14 {
  9377. med_type = "9933"
  9378. } else if reg_type == 11 {
  9379. med_type = "11"
  9380. }
  9381. } else if his.Insutype == "310" {
  9382. if reg_type == 14 {
  9383. med_type = "990502"
  9384. } else if reg_type == 11 {
  9385. med_type = "11"
  9386. }
  9387. }
  9388. 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, "")
  9389. } else {
  9390. if his.IdCardType == 4 {
  9391. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9392. token := psn_info.VerifyNumber
  9393. 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)
  9394. } else {
  9395. 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, "")
  9396. }
  9397. }
  9398. var dat map[string]interface{}
  9399. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9400. fmt.Println(dat)
  9401. } else {
  9402. fmt.Println(err)
  9403. }
  9404. saveLog(result2, src_resquest, "2207", "结算")
  9405. userJSONBytes, _ := json.Marshal(dat)
  9406. if miConfig.Code == "H15049901371" {
  9407. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9408. utils.ErrorLog("解析失败:%v", err)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9413. res.Output = resSeven10265.Output
  9414. res.ErrMsg = resSeven10265.ErrMsg
  9415. res.Cainfo = resSeven10265.Cainfo
  9416. res.WarnMsg = resSeven10265.WarnMsg
  9417. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9418. res.Infcode = infocode
  9419. } else {
  9420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9421. utils.ErrorLog("解析失败:%v", err)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. }
  9426. }
  9427. if res.Infcode != 0 {
  9428. errlog := &models.HisOrderError{
  9429. UserOrgId: adminUser.CurrentOrgId,
  9430. Ctime: time.Now().Unix(),
  9431. Mtime: time.Now().Unix(),
  9432. Number: chrg_bchno,
  9433. ErrMsg: res.ErrMsg,
  9434. Status: 1,
  9435. PatientId: id,
  9436. RecordTime: recordDateTime,
  9437. Stage: 6,
  9438. }
  9439. service.CreateErrMsgLog(errlog)
  9440. c.ServeSuccessJSON(map[string]interface{}{
  9441. "failed_code": -10,
  9442. "msg": res.ErrMsg,
  9443. })
  9444. return
  9445. } else {
  9446. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9447. order.OrderStatus = 2
  9448. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9449. order.SetlId = res.Output.Setlinfo.SetlID
  9450. order.PsnNo = res.Output.Setlinfo.PsnNo
  9451. order.PsnName = res.Output.Setlinfo.PsnName
  9452. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9453. order.Certno = res.Output.Setlinfo.Certno
  9454. order.Gend = res.Output.Setlinfo.Gend
  9455. order.Naty = res.Output.Setlinfo.Naty
  9456. order.Age = res.Output.Setlinfo.Age
  9457. order.Insutype = res.Output.Setlinfo.Insutype
  9458. order.PsnType = res.Output.Setlinfo.PsnType
  9459. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9460. order.SetlTime = res.Output.Setlinfo.SetlTime
  9461. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9462. order.PayWays = pay_ways
  9463. order.AcctUsedFlag = acct_used_flag
  9464. order.WechatPay = wechat_pay
  9465. order.AliPay = ali_pay
  9466. order.JifenPay = jifen_pay
  9467. order.BandCardPay = band_card_pay
  9468. order.CashPay = cash_pay
  9469. order.OthDesc = oth_desc
  9470. //order.MedType = res.Output.Setlinfo.MedType
  9471. if reg_type == 1112 {
  9472. order.MedType = "1112"
  9473. }
  9474. if reg_type == 1111 {
  9475. order.MedType = "1111"
  9476. }
  9477. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9478. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9479. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9480. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9481. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9482. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9483. order.HifpPay = res.Output.Setlinfo.HifpPay
  9484. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9485. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9486. order.HifesPay = res.Output.Setlinfo.HifesPay
  9487. order.HifobPay = res.Output.Setlinfo.HifobPay
  9488. order.MafPay = res.Output.Setlinfo.MafPay
  9489. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9490. order.OthPay = res.Output.Setlinfo.OthPay
  9491. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9492. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9493. order.AcctPay = res.Output.Setlinfo.AcctPay
  9494. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9495. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9496. order.Balc = res.Output.Setlinfo.Balc
  9497. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9498. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9499. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9500. order.ClrWay = res.Output.Setlinfo.ClrWay
  9501. order.Creator = order.Creator
  9502. order.Modify = roles.AdminUserId
  9503. order.RequestLog = src_resquest
  9504. order.Diagnosis = diagnosis_id
  9505. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9506. detailStr := string(setlDetail)
  9507. order.SetlDetail = detailStr
  9508. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9509. err = service.UpDateOrder(order)
  9510. if err == nil {
  9511. //判断是否使用了押金
  9512. if dec_way == "true" {
  9513. tmpstring := strconv.FormatInt(order.ID, 10)
  9514. //扣押金
  9515. order.Decimal = decimal
  9516. service.UpDateOrder(order)
  9517. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9518. if errmsg != nil {
  9519. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9520. return
  9521. }
  9522. }
  9523. c.ServeSuccessJSON(map[string]interface{}{
  9524. "msg": "结算成功",
  9525. })
  9526. } else {
  9527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9528. return
  9529. }
  9530. }
  9531. }
  9532. }
  9533. }
  9534. //func (c *HisApiController) GetPreUploadInfo() {
  9535. // id, _ := c.GetInt64("id")
  9536. // record_time := c.GetString("record_time")
  9537. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9538. // admin_user_id, _ := c.GetInt64("admin_user_id")
  9539. //
  9540. // timeLayout := "2006-01-02"
  9541. // loc, _ := time.LoadLocation("Local")
  9542. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9543. // if err != nil {
  9544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9545. // return
  9546. // }
  9547. // recordDateTime := theTime.Unix()
  9548. // adminUser := c.GetAdminUserInfo()
  9549. //
  9550. // var prescriptions []*models.HisPrescription
  9551. //
  9552. // var start_time int64
  9553. // var end_time int64
  9554. //
  9555. // data := make(map[string]interface{})
  9556. // if settle_accounts_type == 1 { //日结
  9557. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  9558. // data["pre"] = prescriptions
  9559. //
  9560. // } else { //月结
  9561. // start_time_str := c.GetString("start_time")
  9562. // end_time_str := c.GetString("end_time")
  9563. // timeLayout := "2006-01-02"
  9564. // loc, _ := time.LoadLocation("Local")
  9565. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9566. // if err != nil {
  9567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9568. // return
  9569. // }
  9570. // recordStartTime := theStartTime.Unix()
  9571. // start_time = recordStartTime
  9572. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9573. // if err != nil {
  9574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9575. // return
  9576. // }
  9577. // recordEndTime := theEndTime.Unix()
  9578. // end_time = recordEndTime
  9579. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  9580. // data["pre"] = prescriptions
  9581. //
  9582. // }
  9583. //
  9584. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9585. //
  9586. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9587. // timestamp := time.Now().Unix()
  9588. // tempTime := time.Unix(timestamp, 0)
  9589. // timeFormat := tempTime.Format("20060102150405")
  9590. // chrgBchno := rand.Intn(100000) + 10000
  9591. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9592. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9593. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9594. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9595. // strconv.FormatInt(his.PatientId, 10)
  9596. // client := &http.Client{}
  9597. // data["psn_no"] = his.PsnNo
  9598. // data["mdtrt_id"] = his.Number
  9599. // data["chrg_bchno"] = chrg_bchno
  9600. // data["org_name"] = miConfig.OrgName
  9601. // data["doctor"] = roles.UserName
  9602. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  9603. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9604. // data["fixmedins_code"] = miConfig.Code
  9605. // data["dept_code"] = department.Number
  9606. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9607. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9608. // data["secret_key"] = miConfig.SecretKey
  9609. // var ids []int64
  9610. //
  9611. // for _, item := range prescriptions {
  9612. // ids = append(ids, item.ID)
  9613. // }
  9614. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9615. // if config.IsOpen == 1 { //对接了医保,走医保流程
  9616. // bytesData, _ := json.Marshal(data)
  9617. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  9618. // resp, _ := client.Do(req)
  9619. // defer resp.Body.Close()
  9620. // body, ioErr := ioutil.ReadAll(resp.Body)
  9621. // if ioErr != nil {
  9622. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9624. // return
  9625. // }
  9626. // var respJSON map[string]interface{}
  9627. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9628. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. // return
  9631. // }
  9632. //
  9633. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9634. // userJSONBytes, _ := json.Marshal(respJSON)
  9635. // var res ResultFour
  9636. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9637. // utils.ErrorLog("解析失败:%v", err)
  9638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9639. // return
  9640. // }
  9641. //
  9642. // if res.Infcode == 0 {
  9643. // order := &models.HisOrder{
  9644. // UserOrgId: adminUser.CurrentOrgId,
  9645. // HisPatientId: his.ID,
  9646. // PatientId: his.PatientId,
  9647. // SettleAccountsDate: recordDateTime,
  9648. // Ctime: time.Now().Unix(),
  9649. // Mtime: time.Now().Unix(),
  9650. // Status: 1,
  9651. // Number: chrg_bchno,
  9652. // Infcode: res.Infcode,
  9653. // WarnMsg: res.WarnMsg,
  9654. // Cainfo: res.Cainfo,
  9655. // ErrMsg: res.ErrMsg,
  9656. // RespondTime: res.RefmsgTime,
  9657. // InfRefmsgid: res.InfRefmsgid,
  9658. // OrderStatus: 1,
  9659. // IsMedicineInsurance: 1,
  9660. // SettleType: settle_accounts_type,
  9661. // SettleStartTime: start_time,
  9662. // SettleEndTime: end_time,
  9663. // Creator: roles.ID,
  9664. // Modify: roles.ID,
  9665. // PType: 2,
  9666. // }
  9667. // err = service.CreateOrder(order)
  9668. // if err != nil {
  9669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9670. // return
  9671. // }
  9672. //
  9673. // for _, item := range res.Output.Result {
  9674. // temp := strings.Split(item.FeedetlSn, "-")
  9675. // var advice_id int64 = 0
  9676. // var project_id int64 = 0
  9677. // var types int64 = 0
  9678. //
  9679. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  9680. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  9681. //
  9682. // if temp[1] == "1" {
  9683. // advice_id = id
  9684. // project_id = 0
  9685. // } else if temp[1] == "2" {
  9686. // advice_id = 0
  9687. // project_id = id
  9688. // }
  9689. //
  9690. // info := &models.HisOrderInfo{
  9691. // OrderNumber: order.Number,
  9692. // FeedetlSn: item.FeedetlSn,
  9693. // UploadDate: time.Now().Unix(),
  9694. // AdviceId: advice_id,
  9695. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  9696. // Cnt: item.Cnt,
  9697. // Pric: float64(item.Pric),
  9698. // PatientId: his.PatientId,
  9699. // PricUplmtAmt: item.PricUplmtAmt,
  9700. // SelfpayProp: item.SelfpayProp,
  9701. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9702. // OverlmtAmt: item.OverlmtAmt,
  9703. // PreselfpayAmt: item.PreselfpayAmt,
  9704. // BasMednFlag: item.BasMednFlag,
  9705. // MedChrgitmType: item.MedChrgitmType,
  9706. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  9707. // Status: 1,
  9708. // Memo: item.Memo,
  9709. // Mtime: time.Now().Unix(),
  9710. // InscpScpAmt: item.InscpScpAmt,
  9711. // DrtReimFlag: item.DrtReimFlag,
  9712. // Ctime: time.Now().Unix(),
  9713. // ListSpItemFlag: item.ListSpItemFlag,
  9714. // ChldMedcFlag: item.ChldMedcFlag,
  9715. // LmtUsedFlag: item.LmtUsedFlag,
  9716. // ChrgitmLv: item.ChrgitmLv,
  9717. // UserOrgId: adminUser.CurrentOrgId,
  9718. // HisPatientId: his.ID,
  9719. // OrderId: order.ID,
  9720. // ProjectId: project_id,
  9721. // Type: types,
  9722. // }
  9723. // service.CreateOrderInfo(info)
  9724. //
  9725. // }
  9726. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9727. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  9728. //
  9729. // var total float64
  9730. // for _, item := range prescriptions {
  9731. // if item.Type == 1 { //药品
  9732. // for _, subItem := range item.HisDoctorAdviceInfo {
  9733. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9734. // }
  9735. // }
  9736. // if item.Type == 2 { //项目
  9737. // for _, subItem := range item.HisPrescriptionProject {
  9738. // total = total + (subItem.Price * float64(subItem.Count))
  9739. // }
  9740. // }
  9741. // }
  9742. //
  9743. // for _, item := range prescriptions {
  9744. // for _, subItem := range item.HisAdditionalCharge {
  9745. // total = total + (subItem.Price * float64(subItem.Count))
  9746. // }
  9747. // }
  9748. //
  9749. // allTotal := fmt.Sprintf("%.2f", total)
  9750. // if res.Infcode == 0 {
  9751. // var rf []*ResultFive
  9752. // json.Unmarshal([]byte(his.Iinfo), &rf)
  9753. // psn_no := his.PsnNo
  9754. // mdtrt_id := his.Number
  9755. // chrg_bchno := chrg_bchno
  9756. // cert_no := his.Certno
  9757. // insutype := rf[0].Insutype
  9758. //
  9759. // if his.IdCardType == 1 {
  9760. // cert_no = his.MedicalInsuranceNumber
  9761. //
  9762. // } else {
  9763. //
  9764. // cert_no = his.Certno
  9765. //
  9766. // }
  9767. //
  9768. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  9769. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  9770. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9771. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9772. // resp, requestErr := http.Get(api)
  9773. // if requestErr != nil {
  9774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9775. // return
  9776. // }
  9777. // defer resp.Body.Close()
  9778. // body, ioErr := ioutil.ReadAll(resp.Body)
  9779. // if ioErr != nil {
  9780. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9782. // return
  9783. // }
  9784. // var respJSON map[string]interface{}
  9785. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9786. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9788. // return
  9789. // }
  9790. // fmt.Println(respJSON)
  9791. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9792. // userJSONBytes, _ := json.Marshal(respJSON)
  9793. // var res ResultSeven
  9794. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9795. // utils.ErrorLog("解析失败:%v", err)
  9796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. // return
  9798. // }
  9799. // if res.Infcode != 0 {
  9800. // errlog := &models.HisOrderError{
  9801. // UserOrgId: adminUser.CurrentOrgId,
  9802. // Ctime: time.Now().Unix(),
  9803. // Mtime: time.Now().Unix(),
  9804. // Number: chrg_bchno,
  9805. // ErrMsg: res.ErrMsg,
  9806. // Status: 1,
  9807. // PatientId: id,
  9808. // RecordTime: recordDateTime,
  9809. // Stage: 7,
  9810. // }
  9811. // service.CreateErrMsgLog(errlog)
  9812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9813. // return
  9814. // } else {
  9815. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9816. // order.OrderStatus = 1
  9817. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9818. // order.SetlId = res.Output.Setlinfo.SetlID
  9819. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9820. // order.PsnName = res.Output.Setlinfo.PsnName
  9821. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9822. // order.Certno = res.Output.Setlinfo.Certno
  9823. // order.Gend = res.Output.Setlinfo.Gend
  9824. // order.Naty = res.Output.Setlinfo.Naty
  9825. // order.Age = res.Output.Setlinfo.Age
  9826. // order.Insutype = res.Output.Setlinfo.Insutype
  9827. // order.PsnType = res.Output.Setlinfo.PsnType
  9828. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9829. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9830. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9831. // order.MedType = res.Output.Setlinfo.MedType
  9832. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9833. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9834. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9835. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9836. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9837. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9838. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9839. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9840. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9841. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9842. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9843. // order.MafPay = res.Output.Setlinfo.MafPay
  9844. // order.OthPay = res.Output.Setlinfo.OthPay
  9845. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9846. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9847. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9848. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9849. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9850. // order.Balc = res.Output.Setlinfo.Balc
  9851. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9852. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9853. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9854. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9855. // order.Creator = order.Creator
  9856. // order.Modify = roles.ID
  9857. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9858. // detailStr := string(setlDetail)
  9859. // order.SetlDetail = detailStr
  9860. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9861. // err = service.UpDateOrder(order)
  9862. // if err == nil {
  9863. // c.ServeSuccessJSON(map[string]interface{}{
  9864. // "msg": "预结算成功",
  9865. // })
  9866. // } else {
  9867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9868. // return
  9869. // }
  9870. // }
  9871. // } else {
  9872. // adminUser := c.GetAdminUserInfo()
  9873. // errlog := &models.HisOrderError{
  9874. // UserOrgId: adminUser.CurrentOrgId,
  9875. // Ctime: time.Now().Unix(),
  9876. // Mtime: time.Now().Unix(),
  9877. // ErrMsg: res.ErrMsg,
  9878. // Status: 1,
  9879. // PatientId: id,
  9880. // RecordTime: recordDateTime,
  9881. // Stage: 4,
  9882. // }
  9883. // service.CreateErrMsgLog(errlog)
  9884. //
  9885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9886. // return
  9887. // }
  9888. // } else {
  9889. // adminUser := c.GetAdminUserInfo()
  9890. // errlog := &models.HisOrderError{
  9891. // UserOrgId: adminUser.CurrentOrgId,
  9892. // Ctime: time.Now().Unix(),
  9893. // Mtime: time.Now().Unix(),
  9894. // ErrMsg: res.ErrMsg,
  9895. // Status: 1,
  9896. // PatientId: id,
  9897. // RecordTime: recordDateTime,
  9898. // Stage: 4,
  9899. // }
  9900. // service.CreateErrMsgLog(errlog)
  9901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9902. // return
  9903. // }
  9904. //
  9905. // } else {
  9906. // var total float64
  9907. // for _, item := range prescriptions {
  9908. // if item.Type == 1 { //药品
  9909. // for _, subItem := range item.HisDoctorAdviceInfo {
  9910. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9911. // }
  9912. // }
  9913. // if item.Type == 2 { //项目
  9914. // for _, subItem := range item.HisPrescriptionProject {
  9915. // total = total + (subItem.Price * float64(subItem.Count))
  9916. // }
  9917. // }
  9918. //
  9919. // for _, subItem := range item.HisAdditionalCharge {
  9920. // total = total + (subItem.Price * float64(subItem.Count))
  9921. // }
  9922. // }
  9923. //
  9924. // allTotal := fmt.Sprintf("%.2f", total)
  9925. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9926. // order := &models.HisOrder{
  9927. // UserOrgId: adminUser.CurrentOrgId,
  9928. // HisPatientId: his.ID,
  9929. // PatientId: id,
  9930. // SettleAccountsDate: recordDateTime,
  9931. // Ctime: time.Now().Unix(),
  9932. // Mtime: time.Now().Unix(),
  9933. // Status: 1,
  9934. // OrderStatus: 2,
  9935. // Number: chrg_bchno,
  9936. // MedfeeSumamt: totals,
  9937. // }
  9938. // err = service.CreateOrder(order)
  9939. // if err != nil {
  9940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9941. // return
  9942. // }
  9943. //
  9944. // var customs []*Custom
  9945. // for _, item := range prescriptions {
  9946. //
  9947. // if item.Type == 1 { //药品
  9948. // for _, subItem := range item.HisDoctorAdviceInfo {
  9949. // cus := &Custom{
  9950. // AdviceId: subItem.ID,
  9951. // ProjectId: 0,
  9952. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9953. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9954. // FeedetlSn: subItem.FeedetlSn,
  9955. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9956. // MedListCodg: subItem.MedListCodg,
  9957. // Type: 1,
  9958. // }
  9959. // customs = append(customs, cus)
  9960. // }
  9961. // }
  9962. //
  9963. // if item.Type == 2 { //项目
  9964. // for _, subItem := range item.HisPrescriptionProject {
  9965. //
  9966. // cus := &Custom{
  9967. // AdviceId: 0,
  9968. // ProjectId: subItem.ID,
  9969. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9970. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9971. // FeedetlSn: subItem.FeedetlSn,
  9972. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9973. // MedListCodg: subItem.MedListCodg,
  9974. // Type: 2,
  9975. // }
  9976. //
  9977. // customs = append(customs, cus)
  9978. // }
  9979. // }
  9980. //
  9981. // for _, item := range item.HisAdditionalCharge {
  9982. // cus := &Custom{
  9983. // ItemId: item.ID,
  9984. // AdviceId: 0,
  9985. // ProjectId: 0,
  9986. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9987. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9988. // FeedetlSn: item.FeedetlSn,
  9989. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9990. // MedListCodg: item.XtHisAddtionConfig.Code,
  9991. // Type: 3,
  9992. // }
  9993. //
  9994. // customs = append(customs, cus)
  9995. // }
  9996. //
  9997. // }
  9998. //
  9999. // for _, item := range customs {
  10000. // var advice_id int64 = 0
  10001. // var project_id int64 = 0
  10002. // var item_id int64 = 0
  10003. //
  10004. // var types int64 = 0
  10005. //
  10006. // if item.Type == 1 {
  10007. // advice_id = item.AdviceId
  10008. // project_id = 0
  10009. // item_id = 0
  10010. // } else if item.Type == 2 {
  10011. // advice_id = 0
  10012. // item_id = 0
  10013. //
  10014. // project_id = item.ProjectId
  10015. // } else if item.Type == 3 {
  10016. // advice_id = 0
  10017. // item_id = item.ItemId
  10018. // project_id = 0
  10019. // }
  10020. //
  10021. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  10022. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  10023. // pric, _ := strconv.ParseFloat(item.Price, 32)
  10024. //
  10025. // info := &models.HisOrderInfo{
  10026. // OrderNumber: order.Number,
  10027. // UploadDate: time.Now().Unix(),
  10028. // AdviceId: advice_id,
  10029. // DetItemFeeSumamt: detItemFeeSumamt,
  10030. // Cnt: cut,
  10031. // Pric: pric,
  10032. // PatientId: id,
  10033. // Status: 1,
  10034. // Mtime: time.Now().Unix(),
  10035. // Ctime: time.Now().Unix(),
  10036. // UserOrgId: adminUser.CurrentOrgId,
  10037. // HisPatientId: his.ID,
  10038. // OrderId: order.ID,
  10039. // ProjectId: project_id,
  10040. // Type: types,
  10041. // ItemId: item_id,
  10042. // }
  10043. // service.CreateOrderInfo(info)
  10044. // }
  10045. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10046. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10047. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  10048. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10049. // if err == nil {
  10050. // c.ServeSuccessJSON(map[string]interface{}{
  10051. // "msg": "结算成功",
  10052. // })
  10053. // } else {
  10054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10055. // return
  10056. // }
  10057. // }
  10058. //}
  10059. //上传明细-预结算-
  10060. func (c *HisApiController) GetPreUploadInfo() {
  10061. id, _ := c.GetInt64("id")
  10062. record_time := c.GetString("record_time")
  10063. his_patient_id, _ := c.GetInt64("his_patient_id")
  10064. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10065. admin_user_id, _ := c.GetInt64("admin_user_id")
  10066. diagnosis_id := c.GetString("diagnosis")
  10067. sick_type, _ := c.GetInt64("sick_type")
  10068. reg_type, _ := c.GetInt64("p_type")
  10069. begin_time := c.GetString("begin_time")
  10070. acct_used_flag := c.GetString("acct_used_flag")
  10071. id_str := c.GetString("ids")
  10072. ids_arr := strings.Split(id_str, ",")
  10073. timeLayout := "2006-01-02"
  10074. loc, _ := time.LoadLocation("Local")
  10075. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10076. if err != nil {
  10077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10078. return
  10079. }
  10080. recordDateTime := theTime.Unix()
  10081. adminUser := c.GetAdminUserInfo()
  10082. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10083. var config []*models.HisXtDiagnoseConfig
  10084. for _, item := range diagnosis_ids {
  10085. id, _ := strconv.ParseInt(item, 10, 64)
  10086. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10087. config = append(config, &diagnosisConfig)
  10088. }
  10089. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10090. sickConfig, _ := service.FindSickById(sick_type)
  10091. var prescriptions []*models.HisPrescription
  10092. var start_time int64
  10093. var end_time int64
  10094. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10095. fmt.Println(his_patient_id)
  10096. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10097. timestamp := time.Now().Unix()
  10098. tempTime := time.Unix(timestamp, 0)
  10099. timeFormat := tempTime.Format("20060102150405")
  10100. chrgBchno := rand.Intn(100000) + 10000
  10101. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10103. var patientPrescription models.HisPrescriptionInfo
  10104. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10105. if patientPrescription.ID == 0 {
  10106. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10107. }
  10108. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10109. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10110. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10111. strconv.FormatInt(his.PatientId, 10)
  10112. var res2 ResultSix
  10113. var resSix10265 ResultSix10265
  10114. //var time_stamp string
  10115. if miConfig.MdtrtareaAdmvs == "421300" {
  10116. data := make(map[string]interface{})
  10117. client := &http.Client{}
  10118. data["psn_no"] = his.PsnNo
  10119. data["mdtrt_id"] = his.Number
  10120. data["department"] = department.Name
  10121. data["org_name"] = miConfig.OrgName
  10122. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10123. data["doctor_id"] = doctor_info.DoctorNumber
  10124. data["doctor_name"] = roles.UserName
  10125. data["fixmedins_code"] = miConfig.Code
  10126. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10128. data["secret_key"] = miConfig.SecretKey
  10129. data["sick_code"] = sickConfig.CountryCode
  10130. data["sick_name"] = sickConfig.ClassName
  10131. data["begin_time"] = begin_time
  10132. data["dept"] = strconv.FormatInt(department.ID, 10)
  10133. data["config"] = config
  10134. data["opter"] = roles.UserName
  10135. fmt.Println(data)
  10136. bytesData, _ := json.Marshal(data)
  10137. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10138. resp, _ := client.Do(req)
  10139. defer resp.Body.Close()
  10140. body, ioErr := ioutil.ReadAll(resp.Body)
  10141. if ioErr != nil {
  10142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. var respJSON map[string]interface{}
  10147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10150. return
  10151. }
  10152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10153. userJSONBytes, _ := json.Marshal(respJSON)
  10154. fmt.Println("log")
  10155. fmt.Println(string(userJSONBytes))
  10156. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10157. utils.ErrorLog("解析失败:%v", err)
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10159. return
  10160. }
  10161. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10162. data := make(map[string]interface{})
  10163. client := &http.Client{}
  10164. data["psn_no"] = his.PsnNo
  10165. data["mdtrt_id"] = his.Number
  10166. data["doctor"] = roles.UserName
  10167. data["department"] = department.Name
  10168. data["org_name"] = miConfig.OrgName
  10169. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10170. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  10171. data["fixmedins_code"] = miConfig.Code
  10172. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10174. data["secret_key"] = miConfig.SecretKey
  10175. data["sick_code"] = sickConfig.CountryCode
  10176. data["sick_name"] = sickConfig.ClassName
  10177. data["begin_time"] = begin_time
  10178. data["dept"] = strconv.FormatInt(department.ID, 10)
  10179. data["config"] = config
  10180. data["url"] = miConfig.Url
  10181. data["ak"] = miConfig.AccessKey
  10182. data["cainfo"] = miConfig.Cainfo
  10183. bytesData, _ := json.Marshal(data)
  10184. var req *http.Request
  10185. if miConfig.MdtrtareaAdmvs == "320921" {
  10186. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10187. } else {
  10188. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10189. }
  10190. resp, _ := client.Do(req)
  10191. defer resp.Body.Close()
  10192. body, ioErr := ioutil.ReadAll(resp.Body)
  10193. if ioErr != nil {
  10194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10196. return
  10197. }
  10198. var respJSON map[string]interface{}
  10199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10202. return
  10203. }
  10204. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  10205. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  10206. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  10207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10208. userJSONBytes, _ := json.Marshal(respJSON)
  10209. fmt.Println("log")
  10210. fmt.Println(string(userJSONBytes))
  10211. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10212. utils.ErrorLog("解析失败:%v", err)
  10213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10214. return
  10215. }
  10216. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10217. res2.Output = resSix10265.Output
  10218. res2.ErrMsg = resSix10265.ErrMsg
  10219. res2.Cainfo = resSix10265.Cainfo
  10220. res2.WarnMsg = resSix10265.WarnMsg
  10221. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10222. res2.Infcode = infocode
  10223. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10224. 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)
  10225. saveLog(result, requestLog, "2203", "上传就诊信息")
  10226. var respJSON2 map[string]interface{}
  10227. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. return
  10231. }
  10232. userJSONBytes2, _ := json.Marshal(respJSON2)
  10233. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10234. utils.ErrorLog("解析失败:%v", err)
  10235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10236. return
  10237. }
  10238. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10239. var result string
  10240. var requestLog string
  10241. 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, "")
  10242. saveLog(result, requestLog, "2203", "上传就诊信息")
  10243. var respJSON2 map[string]interface{}
  10244. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. userJSONBytes2, _ := json.Marshal(respJSON2)
  10250. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10251. utils.ErrorLog("解析失败:%v", err)
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10253. return
  10254. }
  10255. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10256. var result string
  10257. var requestLog string
  10258. 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, "")
  10259. saveLog(result, requestLog, "2203", "上传就诊信息")
  10260. var respJSON2 map[string]interface{}
  10261. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10264. return
  10265. }
  10266. userJSONBytes2, _ := json.Marshal(respJSON2)
  10267. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. } else {
  10273. var result string
  10274. var requestLog string
  10275. if miConfig.MdtrtareaAdmvs == "440781" { //
  10276. 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)
  10277. } else {
  10278. if miConfig.Code == "H15049901371" {
  10279. //赤峰地区国家医保医疗类别
  10280. //职工透析:医疗类别选特殊情况门诊990502
  10281. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10282. var med_type string
  10283. if his.Insutype == "390" {
  10284. if reg_type == 14 {
  10285. med_type = "9933"
  10286. } else if reg_type == 11 {
  10287. med_type = "11"
  10288. }
  10289. } else if his.Insutype == "310" {
  10290. if reg_type == 14 {
  10291. med_type = "990502"
  10292. } else if reg_type == 11 {
  10293. med_type = "11"
  10294. }
  10295. }
  10296. 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)
  10297. } else {
  10298. 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)
  10299. }
  10300. saveLog(result, requestLog, "2203", "上传就诊信息")
  10301. var respJSON2 map[string]interface{}
  10302. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10305. return
  10306. }
  10307. userJSONBytes2, _ := json.Marshal(respJSON2)
  10308. if miConfig.Code == "H15049901371" {
  10309. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10315. res2.Output = resSix10265.Output
  10316. res2.ErrMsg = resSix10265.ErrMsg
  10317. res2.Cainfo = resSix10265.Cainfo
  10318. res2.WarnMsg = resSix10265.WarnMsg
  10319. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10320. res2.Infcode = infocode
  10321. } else {
  10322. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10323. utils.ErrorLog("解析失败:%v", err)
  10324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10325. return
  10326. }
  10327. }
  10328. }
  10329. }
  10330. if res2.Infcode != 0 {
  10331. adminUser := c.GetAdminUserInfo()
  10332. errlog := &models.HisOrderError{
  10333. UserOrgId: adminUser.CurrentOrgId,
  10334. Ctime: time.Now().Unix(),
  10335. Mtime: time.Now().Unix(),
  10336. ErrMsg: res2.ErrMsg,
  10337. Status: 1,
  10338. PatientId: id,
  10339. RecordTime: recordDateTime,
  10340. Stage: 3,
  10341. }
  10342. service.CreateErrMsgLog(errlog)
  10343. c.ServeSuccessJSON(map[string]interface{}{
  10344. "failed_code": -10,
  10345. "msg": res2.ErrMsg,
  10346. })
  10347. return
  10348. } else {
  10349. his.Diagnosis = diagnosis_id
  10350. his.SickType = sickConfig.ID
  10351. his.PType = fmt.Sprintf("%d", reg_type)
  10352. service.UpdateHisPatientThree(&his)
  10353. data := make(map[string]interface{})
  10354. if settle_accounts_type == 1 { //日结
  10355. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10356. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10357. } else {
  10358. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10359. }
  10360. data["pre"] = prescriptions
  10361. } else { //月结
  10362. start_time_str := c.GetString("start_time")
  10363. end_time_str := c.GetString("end_time")
  10364. timeLayout := "2006-01-02"
  10365. loc, _ := time.LoadLocation("Local")
  10366. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10367. if err != nil {
  10368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10369. return
  10370. }
  10371. recordStartTime := theStartTime.Unix()
  10372. start_time = recordStartTime
  10373. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10374. if err != nil {
  10375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10376. return
  10377. }
  10378. recordEndTime := theEndTime.Unix()
  10379. end_time = recordEndTime
  10380. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10381. data["pre"] = prescriptions
  10382. }
  10383. client := &http.Client{}
  10384. data["psn_no"] = his.PsnNo
  10385. data["mdtrt_id"] = his.Number
  10386. data["chrg_bchno"] = chrg_bchno
  10387. data["org_name"] = miConfig.OrgName
  10388. data["doctor"] = doctor_info.UserName
  10389. data["doctor_id"] = doctor_info.DoctorNumber
  10390. data["dept"] = department.Name
  10391. data["fixmedins_code"] = miConfig.Code
  10392. data["opter"] = roles.UserName
  10393. data["dept_code"] = department.Number
  10394. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10395. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10396. data["secret_key"] = miConfig.SecretKey
  10397. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10398. data["url"] = miConfig.Url
  10399. data["ak"] = miConfig.AccessKey
  10400. data["new_doctor_name"] = patientPrescription.Doctor
  10401. data["diag_code"] = sickConfig.CountryCode
  10402. data["cainfo"] = miConfig.Cainfo
  10403. data["opter"] = roles.UserName
  10404. var ids []int64
  10405. for _, item := range prescriptions {
  10406. ids = append(ids, item.ID)
  10407. }
  10408. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10409. if config.IsOpen == 1 { //对接了医保,走医保流程
  10410. var res ResultFour
  10411. var resFour10265 ResultFour10265
  10412. if miConfig.MdtrtareaAdmvs == "421300" {
  10413. bytesData, _ := json.Marshal(data)
  10414. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10415. resp, _ := client.Do(req)
  10416. defer resp.Body.Close()
  10417. body, ioErr := ioutil.ReadAll(resp.Body)
  10418. if ioErr != nil {
  10419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10421. return
  10422. }
  10423. var respJSON map[string]interface{}
  10424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10427. return
  10428. }
  10429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10430. userJSONBytes, _ := json.Marshal(respJSON)
  10431. fmt.Println("log")
  10432. fmt.Println(string(userJSONBytes))
  10433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10434. utils.ErrorLog("解析失败:%v", err)
  10435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10436. return
  10437. }
  10438. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10439. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10440. if result3101.Infcode == "0" {
  10441. if len(result3101.Output.Result) > 0 {
  10442. var errMsgs []string
  10443. for _, item := range result3101.Output.Result {
  10444. errMsgs = append(errMsgs, item.VolaCont)
  10445. }
  10446. c.ServeSuccessJSON(map[string]interface{}{
  10447. "failed_code": -10,
  10448. "msg": errMsgs,
  10449. })
  10450. return
  10451. } else {
  10452. if miConfig.MdtrtareaAdmvs == "320921" {
  10453. data["doctor_id"] = "D320923012139"
  10454. } else {
  10455. data["doctor_id"] = "D371621008686"
  10456. }
  10457. bytesData, _ := json.Marshal(data)
  10458. var req *http.Request
  10459. if miConfig.MdtrtareaAdmvs == "320921" {
  10460. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10461. } else {
  10462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10463. }
  10464. resp, _ := client.Do(req)
  10465. defer resp.Body.Close()
  10466. body, ioErr := ioutil.ReadAll(resp.Body)
  10467. if ioErr != nil {
  10468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10470. return
  10471. }
  10472. var respJSON map[string]interface{}
  10473. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10476. return
  10477. }
  10478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10479. userJSONBytes, _ := json.Marshal(respJSON)
  10480. fmt.Println("log")
  10481. fmt.Println(string(userJSONBytes))
  10482. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10483. utils.ErrorLog("解析失败:%v", err)
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. return
  10486. }
  10487. res.InfRefmsgid = resFour10265.InfRefmsgid
  10488. res.Output = resFour10265.Output
  10489. res.ErrMsg = resFour10265.ErrMsg
  10490. res.Cainfo = resFour10265.Cainfo
  10491. res.WarnMsg = resFour10265.WarnMsg
  10492. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10493. res.Infcode = infocode
  10494. }
  10495. }
  10496. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10497. 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)
  10498. var dat map[string]interface{}
  10499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10500. fmt.Println(dat)
  10501. } else {
  10502. fmt.Println(err)
  10503. }
  10504. saveLog(result, request_log, "2204", "上传费用明细")
  10505. userJSONBytes, _ := json.Marshal(dat)
  10506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10507. utils.ErrorLog("解析失败:%v", err)
  10508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10509. return
  10510. }
  10511. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10512. 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, "", "")
  10513. var dat map[string]interface{}
  10514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10515. fmt.Println(dat)
  10516. } else {
  10517. fmt.Println(err)
  10518. }
  10519. saveLog(result, request_log, "2204", "上传费用明细")
  10520. userJSONBytes, _ := json.Marshal(dat)
  10521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10522. utils.ErrorLog("解析失败:%v", err)
  10523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10524. return
  10525. }
  10526. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10527. 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, "", "")
  10528. var dat map[string]interface{}
  10529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10530. fmt.Println(dat)
  10531. } else {
  10532. fmt.Println(err)
  10533. }
  10534. saveLog(result, request_log, "2204", "上传费用明细")
  10535. userJSONBytes, _ := json.Marshal(dat)
  10536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. } else {
  10542. if miConfig.Code == "H15049901371" {
  10543. 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)
  10544. var dat map[string]interface{}
  10545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10546. fmt.Println(dat)
  10547. } else {
  10548. fmt.Println(err)
  10549. }
  10550. saveLog(result, request_log, "2204", "上传费用明细")
  10551. userJSONBytes, _ := json.Marshal(dat)
  10552. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10553. utils.ErrorLog("解析失败:%v", err)
  10554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10555. return
  10556. }
  10557. res.InfRefmsgid = resFour10265.InfRefmsgid
  10558. res.Output = resFour10265.Output
  10559. res.ErrMsg = resFour10265.ErrMsg
  10560. res.Cainfo = resFour10265.Cainfo
  10561. res.WarnMsg = resFour10265.WarnMsg
  10562. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10563. res.Infcode = infocode
  10564. } else {
  10565. 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)
  10566. var dat map[string]interface{}
  10567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10568. fmt.Println(dat)
  10569. } else {
  10570. fmt.Println(err)
  10571. }
  10572. saveLog(result, request_log, "2204", "上传费用明细")
  10573. userJSONBytes, _ := json.Marshal(dat)
  10574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10575. utils.ErrorLog("解析失败:%v", err)
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10577. return
  10578. }
  10579. }
  10580. }
  10581. var total_two float64
  10582. if res.Infcode == 0 {
  10583. order := &models.HisOrder{
  10584. UserOrgId: adminUser.CurrentOrgId,
  10585. HisPatientId: his.ID,
  10586. PatientId: his.PatientId,
  10587. SettleAccountsDate: recordDateTime,
  10588. Ctime: time.Now().Unix(),
  10589. Mtime: time.Now().Unix(),
  10590. MdtrtId: his.Number,
  10591. PsnNo: his.PsnNo,
  10592. MedType: strconv.FormatInt(reg_type, 10),
  10593. Status: 1,
  10594. Number: chrg_bchno,
  10595. Infcode: res.Infcode,
  10596. WarnMsg: res.WarnMsg,
  10597. Cainfo: res.Cainfo,
  10598. ErrMsg: res.ErrMsg,
  10599. RespondTime: res.RefmsgTime,
  10600. InfRefmsgid: res.InfRefmsgid,
  10601. OrderStatus: 1,
  10602. IsMedicineInsurance: 1,
  10603. SettleType: settle_accounts_type,
  10604. SettleStartTime: start_time,
  10605. SettleEndTime: end_time,
  10606. Creator: roles.AdminUserId,
  10607. Modify: roles.AdminUserId,
  10608. PType: 2,
  10609. Diagnosis: diagnosis_id,
  10610. }
  10611. err = service.CreateOrder(order)
  10612. if err != nil {
  10613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10614. return
  10615. }
  10616. for _, item := range res.Output.Result {
  10617. temp := strings.Split(item.FeedetlSn, "-")
  10618. var advice_id int64 = 0
  10619. var project_id int64 = 0
  10620. var types int64 = 0
  10621. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10622. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10623. if temp[1] == "1" {
  10624. advice_id = id
  10625. project_id = 0
  10626. } else if temp[1] == "2" {
  10627. advice_id = 0
  10628. project_id = id
  10629. }
  10630. total_two = total_two + item.DetItemFeeSumamt
  10631. info := &models.HisOrderInfo{
  10632. OrderNumber: order.Number,
  10633. FeedetlSn: item.FeedetlSn,
  10634. UploadDate: time.Now().Unix(),
  10635. AdviceId: advice_id,
  10636. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10637. Cnt: item.Cnt,
  10638. Pric: float64(item.Pric),
  10639. PatientId: his.PatientId,
  10640. PricUplmtAmt: item.PricUplmtAmt,
  10641. SelfpayProp: item.SelfpayProp,
  10642. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10643. OverlmtAmt: item.OverlmtAmt,
  10644. PreselfpayAmt: item.PreselfpayAmt,
  10645. BasMednFlag: item.BasMednFlag,
  10646. MedChrgitmType: item.MedChrgitmType,
  10647. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10648. Status: 1,
  10649. Memo: item.Memo,
  10650. Mtime: time.Now().Unix(),
  10651. InscpScpAmt: item.InscpScpAmt,
  10652. DrtReimFlag: item.DrtReimFlag,
  10653. Ctime: time.Now().Unix(),
  10654. ListSpItemFlag: item.ListSpItemFlag,
  10655. ChldMedcFlag: item.ChldMedcFlag,
  10656. LmtUsedFlag: item.LmtUsedFlag,
  10657. ChrgitmLv: item.ChrgitmLv,
  10658. UserOrgId: adminUser.CurrentOrgId,
  10659. HisPatientId: his.ID,
  10660. OrderId: order.ID,
  10661. ProjectId: project_id,
  10662. Type: types,
  10663. }
  10664. service.CreateOrderInfo(info)
  10665. }
  10666. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10667. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10668. var total float64
  10669. for _, item := range prescriptions {
  10670. if item.Type == 1 { //药品
  10671. for _, subItem := range item.HisDoctorAdviceInfo {
  10672. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10673. total_one := price * subItem.PrescribingNumber
  10674. fmt.Println("subItem")
  10675. fmt.Println(subItem.Price)
  10676. fmt.Println("price")
  10677. fmt.Println(price)
  10678. fmt.Println("total_one")
  10679. fmt.Println(total_one)
  10680. total = total + total_one
  10681. fmt.Println(total)
  10682. }
  10683. }
  10684. if item.Type == 2 { //项目
  10685. for _, subItem := range item.HisPrescriptionProject {
  10686. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10687. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10688. total_one := price * cnt
  10689. total = total + total_one
  10690. }
  10691. }
  10692. }
  10693. allTotal := fmt.Sprintf("%2f", total)
  10694. if res.Infcode == 0 {
  10695. var rf []*ResultFive
  10696. json.Unmarshal([]byte(his.Iinfo), &rf)
  10697. chrg_bchno := chrg_bchno
  10698. cert_no := his.Certno
  10699. var insutypes []string
  10700. var insutype string
  10701. var is390 int = 0
  10702. var is310 int = 0
  10703. for _, item := range rf {
  10704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10705. insutypes = append(insutypes, item.Insutype)
  10706. }
  10707. }
  10708. if len(insutypes) == 1 {
  10709. insutype = insutypes[0]
  10710. } else {
  10711. for _, i := range insutypes {
  10712. if i == "390" {
  10713. is390 = 1
  10714. }
  10715. if i == "310" {
  10716. is310 = 1
  10717. }
  10718. }
  10719. }
  10720. if is390 == 1 {
  10721. insutype = "390"
  10722. }
  10723. if is310 == 1 {
  10724. insutype = "310"
  10725. }
  10726. if len(insutypes) == 0 {
  10727. insutype = "390"
  10728. }
  10729. if len(insutypes) == 2 {
  10730. insutype = strconv.FormatInt(his.SocialType, 10)
  10731. }
  10732. //insutype = "390"
  10733. if his.IdCardType == 1 {
  10734. cert_no = his.MedicalInsuranceNumber
  10735. } else {
  10736. cert_no = his.Certno
  10737. }
  10738. var res ResultSeven
  10739. var resSeven10265 ResultSeven10265
  10740. if miConfig.MdtrtareaAdmvs == "421300" {
  10741. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10742. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10743. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10745. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10746. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10747. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  10748. resp, requestErr := http.Get(api)
  10749. if requestErr != nil {
  10750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10751. return
  10752. }
  10753. body, ioErr := ioutil.ReadAll(resp.Body)
  10754. if ioErr != nil {
  10755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10757. return
  10758. }
  10759. var respJSON map[string]interface{}
  10760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10763. return
  10764. }
  10765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10766. result, _ := json.Marshal(respJSON)
  10767. fmt.Println("log")
  10768. fmt.Println(string(result))
  10769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10770. utils.ErrorLog("解析失败:%v", err)
  10771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. return
  10773. }
  10774. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10775. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  10776. if result3101.Infcode == "0" {
  10777. if len(result3101.Output.Result) > 0 {
  10778. var errMsgs []string
  10779. for _, item := range result3101.Output.Result {
  10780. errMsgs = append(errMsgs, item.VolaCont)
  10781. }
  10782. c.ServeSuccessJSON(map[string]interface{}{
  10783. "failed_code": -10,
  10784. "msg": errMsgs,
  10785. })
  10786. return
  10787. } else {
  10788. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10789. if his.IdCardType != 4 {
  10790. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10791. bas := strings.Split(psn_info.CardInfo, "|")
  10792. if his.IdCardType == 1 {
  10793. cert_no = bas[2]
  10794. } else {
  10795. cert_no = bas[1]
  10796. }
  10797. } else {
  10798. cert_no = his.Certno
  10799. }
  10800. //江苏地区国家医保医疗类别
  10801. //职工透析:医疗类别选特殊情况门诊9933
  10802. //居民血透门慢: 医疗类别选门诊慢病1402
  10803. //var med_type string
  10804. //if his.Insutype == "310" {
  10805. // if reg_type == 14 {
  10806. // med_type = "9933"
  10807. // } else if reg_type == 11 {
  10808. // med_type = "11"
  10809. //
  10810. // }
  10811. //} else if his.Insutype == "390" {
  10812. // if reg_type == 14 {
  10813. // med_type = "1402"
  10814. // } else if reg_type == 11 {
  10815. // med_type = "11"
  10816. // }
  10817. //}
  10818. var api string
  10819. if miConfig.MdtrtareaAdmvs == "320921" {
  10820. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10821. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10822. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10824. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10825. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10826. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10827. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10828. } else {
  10829. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10830. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10831. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10832. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10834. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10835. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10836. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10837. }
  10838. resp, requestErr := http.Get(api)
  10839. if requestErr != nil {
  10840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10841. return
  10842. }
  10843. body, ioErr := ioutil.ReadAll(resp.Body)
  10844. if ioErr != nil {
  10845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10847. return
  10848. }
  10849. var respJSON map[string]interface{}
  10850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10853. return
  10854. }
  10855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10856. result, _ := json.Marshal(respJSON)
  10857. fmt.Println("log")
  10858. fmt.Println(string(result))
  10859. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10860. utils.ErrorLog("解析失败:%v", err)
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10862. return
  10863. }
  10864. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10865. res.Output = resSeven10265.Output
  10866. res.ErrMsg = resSeven10265.ErrMsg
  10867. res.Cainfo = resSeven10265.Cainfo
  10868. res.WarnMsg = resSeven10265.WarnMsg
  10869. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10870. res.Infcode = infocode
  10871. }
  10872. }
  10873. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10874. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  10875. var result string
  10876. var request_log string
  10877. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10878. 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)
  10879. } else {
  10880. 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)
  10881. }
  10882. var dat map[string]interface{}
  10883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10884. fmt.Println(dat)
  10885. } else {
  10886. fmt.Println(err)
  10887. }
  10888. saveLog(result, request_log, "2206", "预结算")
  10889. userJSONBytes, _ := json.Marshal(dat)
  10890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10891. utils.ErrorLog("解析失败:%v", err)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10896. var result string
  10897. var request_log string
  10898. if his.IdCardType == 2 {
  10899. 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, "")
  10900. } else if his.IdCardType == 1 {
  10901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10902. bas := strings.Split(psn_info.CardInfo, "|")
  10903. basNumber := bas[2]
  10904. card_sn := bas[3]
  10905. 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)
  10906. } else {
  10907. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10908. 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, "")
  10909. }
  10910. var dat map[string]interface{}
  10911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10912. fmt.Println(dat)
  10913. } else {
  10914. fmt.Println(err)
  10915. }
  10916. saveLog(result, request_log, "2206", "预结算")
  10917. userJSONBytes, _ := json.Marshal(dat)
  10918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10919. utils.ErrorLog("解析失败:%v", err)
  10920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10921. return
  10922. }
  10923. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10924. var result string
  10925. var request_log string
  10926. if his.IdCardType == 2 {
  10927. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", acct_used_flag)
  10928. } else if his.IdCardType == 1 {
  10929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10930. bas := strings.Split(psn_info.CardInfo, "|")
  10931. basNumber := bas[2]
  10932. card_sn := bas[3]
  10933. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, acct_used_flag)
  10934. } else {
  10935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10936. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", acct_used_flag)
  10937. }
  10938. var dat map[string]interface{}
  10939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10940. fmt.Println(dat)
  10941. } else {
  10942. fmt.Println(err)
  10943. }
  10944. saveLog(result, request_log, "2206", "预结算")
  10945. userJSONBytes, _ := json.Marshal(dat)
  10946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10947. utils.ErrorLog("解析失败:%v", err)
  10948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10949. return
  10950. }
  10951. } else {
  10952. var result string
  10953. var request_log string
  10954. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10955. allTotal = fmt.Sprintf("%2f", total_two)
  10956. if his.IdCardType == 4 {
  10957. 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)
  10958. } else {
  10959. 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)
  10960. }
  10961. var dat map[string]interface{}
  10962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10963. fmt.Println(dat)
  10964. } else {
  10965. fmt.Println(err)
  10966. }
  10967. saveLog(result, request_log, "2206", "预结算")
  10968. //userJSONBytes, _ := json.Marshal(dat)
  10969. //
  10970. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10971. // utils.ErrorLog("解析失败:%v", err)
  10972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10973. // return
  10974. //}
  10975. userJSONBytes, _ := json.Marshal(dat)
  10976. if miConfig.Code == "H15049901371" {
  10977. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10978. utils.ErrorLog("解析失败:%v", err)
  10979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10980. return
  10981. }
  10982. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10983. res.Output = resSeven10265.Output
  10984. res.ErrMsg = resSeven10265.ErrMsg
  10985. res.Cainfo = resSeven10265.Cainfo
  10986. res.WarnMsg = resSeven10265.WarnMsg
  10987. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10988. res.Infcode = infocode
  10989. } else {
  10990. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10991. utils.ErrorLog("解析失败:%v", err)
  10992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10993. return
  10994. }
  10995. }
  10996. }
  10997. if res.Infcode != 0 {
  10998. errlog := &models.HisOrderError{
  10999. UserOrgId: adminUser.CurrentOrgId,
  11000. Ctime: time.Now().Unix(),
  11001. Mtime: time.Now().Unix(),
  11002. Number: chrg_bchno,
  11003. ErrMsg: res.ErrMsg,
  11004. Status: 1,
  11005. PatientId: id,
  11006. RecordTime: recordDateTime,
  11007. Stage: 20,
  11008. }
  11009. service.CreateErrMsgLog(errlog)
  11010. c.ServeSuccessJSON(map[string]interface{}{
  11011. "failed_code": -10,
  11012. "msg": res.ErrMsg,
  11013. })
  11014. return
  11015. } else {
  11016. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11017. order.OrderStatus = 1
  11018. order.IsPre = 1
  11019. order.Status = 1
  11020. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11021. order.SetlId = res.Output.Setlinfo.SetlID
  11022. order.PsnNo = res.Output.Setlinfo.PsnNo
  11023. order.PsnName = res.Output.Setlinfo.PsnName
  11024. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11025. order.Certno = res.Output.Setlinfo.Certno
  11026. order.Gend = res.Output.Setlinfo.Gend
  11027. order.Naty = res.Output.Setlinfo.Naty
  11028. order.Age = res.Output.Setlinfo.Age
  11029. order.Insutype = res.Output.Setlinfo.Insutype
  11030. order.PsnType = res.Output.Setlinfo.PsnType
  11031. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11032. order.SetlTime = res.Output.Setlinfo.SetlTime
  11033. order.AcctUsedFlag = acct_used_flag
  11034. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11035. if res.Output.Setlinfo.MedType == "140101" {
  11036. order.MedType = "14"
  11037. } else {
  11038. order.MedType = res.Output.Setlinfo.MedType
  11039. }
  11040. if reg_type == 1112 {
  11041. order.MedType = "1112"
  11042. }
  11043. if reg_type == 1111 {
  11044. order.MedType = "1111"
  11045. }
  11046. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11047. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11048. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11049. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11050. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11051. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11052. order.HifpPay = res.Output.Setlinfo.HifpPay
  11053. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11054. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11055. order.HifesPay = res.Output.Setlinfo.HifesPay
  11056. order.HifobPay = res.Output.Setlinfo.HifobPay
  11057. order.MafPay = res.Output.Setlinfo.MafPay
  11058. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11059. order.OthPay = res.Output.Setlinfo.OthPay
  11060. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11061. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11062. order.AcctPay = res.Output.Setlinfo.AcctPay
  11063. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11064. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11065. order.Balc = res.Output.Setlinfo.Balc
  11066. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11067. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11068. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11069. order.ClrWay = res.Output.Setlinfo.ClrWay
  11070. order.Creator = order.Creator
  11071. order.Modify = roles.AdminUserId
  11072. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11073. detailStr := string(setlDetail)
  11074. order.SetlDetail = detailStr
  11075. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11076. err = service.UpDateOrder(order)
  11077. if err == nil {
  11078. c.ServeSuccessJSON(map[string]interface{}{
  11079. "msg": "预结算成功",
  11080. })
  11081. } else {
  11082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11083. return
  11084. }
  11085. }
  11086. } else {
  11087. adminUser := c.GetAdminUserInfo()
  11088. errlog := &models.HisOrderError{
  11089. UserOrgId: adminUser.CurrentOrgId,
  11090. Ctime: time.Now().Unix(),
  11091. Mtime: time.Now().Unix(),
  11092. ErrMsg: res.ErrMsg,
  11093. Status: 1,
  11094. PatientId: id,
  11095. RecordTime: recordDateTime,
  11096. Stage: 4,
  11097. }
  11098. service.CreateErrMsgLog(errlog)
  11099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11100. return
  11101. }
  11102. } else {
  11103. adminUser := c.GetAdminUserInfo()
  11104. errlog := &models.HisOrderError{
  11105. UserOrgId: adminUser.CurrentOrgId,
  11106. Ctime: time.Now().Unix(),
  11107. Mtime: time.Now().Unix(),
  11108. ErrMsg: res.ErrMsg,
  11109. Status: 1,
  11110. PatientId: id,
  11111. RecordTime: recordDateTime,
  11112. Stage: 4,
  11113. }
  11114. service.CreateErrMsgLog(errlog)
  11115. c.ServeSuccessJSON(map[string]interface{}{
  11116. "failed_code": -10,
  11117. "msg": res.ErrMsg,
  11118. })
  11119. return
  11120. }
  11121. }
  11122. }
  11123. }
  11124. //退款
  11125. func (c *HisApiController) Refund() {
  11126. order_id, _ := c.GetInt64("order_id")
  11127. admin_user_id, _ := c.GetInt64("admin_user_id")
  11128. adminUser := c.GetAdminUserInfo()
  11129. var order models.HisOrder
  11130. order, _ = service.GetHisOrderByID(order_id)
  11131. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11132. if order.ID == 0 {
  11133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11134. return
  11135. }
  11136. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11139. if config.IsOpen == 1 { //对接了医保,走医保流程
  11140. var res ResultSixteen
  11141. var resSixteen10265 ResultSixteen10265
  11142. var src_resquest string
  11143. var result string
  11144. if miConfig.MdtrtareaAdmvs == "421300" {
  11145. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  11146. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11147. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11148. resp3, requestErr3 := http.Get(api3)
  11149. if requestErr3 != nil {
  11150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. return
  11152. }
  11153. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11154. if ioErr3 != nil {
  11155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. return
  11158. }
  11159. var respJSON3 map[string]interface{}
  11160. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11163. return
  11164. }
  11165. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11166. userJSONBytes3, _ := json.Marshal(respJSON3)
  11167. fmt.Println("log")
  11168. fmt.Println(string(userJSONBytes3))
  11169. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  11170. utils.ErrorLog("解析失败:%v", err)
  11171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11172. return
  11173. }
  11174. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11175. var api3 string
  11176. if miConfig.MdtrtareaAdmvs == "320921" {
  11177. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11178. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11179. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11180. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11181. } else {
  11182. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11183. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11184. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11186. }
  11187. resp3, requestErr3 := http.Get(api3)
  11188. if requestErr3 != nil {
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return
  11191. }
  11192. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11193. if ioErr3 != nil {
  11194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return
  11197. }
  11198. var respJSON3 map[string]interface{}
  11199. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11202. return
  11203. }
  11204. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11205. userJSONBytes3, _ := json.Marshal(respJSON3)
  11206. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  11207. utils.ErrorLog("解析失败:%v", err)
  11208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11209. return
  11210. }
  11211. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11212. res.Output = resSixteen10265.Output
  11213. res.ErrMsg = resSixteen10265.ErrMsg
  11214. res.Cainfo = resSixteen10265.Cainfo
  11215. res.WarnMsg = resSixteen10265.WarnMsg
  11216. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11217. res.Infcode = infocode
  11218. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11219. 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)
  11220. var dat map[string]interface{}
  11221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11222. fmt.Println(dat)
  11223. } else {
  11224. fmt.Println(err)
  11225. }
  11226. saveLog(result, src_resquest, "2208", "退费")
  11227. userJSONBytes, _ := json.Marshal(dat)
  11228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11229. utils.ErrorLog("解析失败:%v", err)
  11230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11231. return
  11232. }
  11233. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11234. 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, "")
  11235. var dat map[string]interface{}
  11236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11237. fmt.Println(dat)
  11238. } else {
  11239. fmt.Println(err)
  11240. }
  11241. saveLog(result, src_resquest, "2208", "退费")
  11242. userJSONBytes, _ := json.Marshal(dat)
  11243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11244. utils.ErrorLog("解析失败:%v", err)
  11245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11246. return
  11247. }
  11248. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11249. 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, "")
  11250. var dat map[string]interface{}
  11251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11252. fmt.Println(dat)
  11253. } else {
  11254. fmt.Println(err)
  11255. }
  11256. saveLog(result, src_resquest, "2208", "退费")
  11257. userJSONBytes, _ := json.Marshal(dat)
  11258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11259. utils.ErrorLog("解析失败:%v", err)
  11260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11261. return
  11262. }
  11263. } else {
  11264. if miConfig.Code == "H15049901371" {
  11265. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11266. var dat map[string]interface{}
  11267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11268. fmt.Println(dat)
  11269. } else {
  11270. fmt.Println(err)
  11271. }
  11272. saveLog(result, src_resquest, "2208", "退费")
  11273. userJSONBytes, _ := json.Marshal(dat)
  11274. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  11275. utils.ErrorLog("解析失败:%v", err)
  11276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11277. return
  11278. }
  11279. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11280. res.Output = resSixteen10265.Output
  11281. res.ErrMsg = resSixteen10265.ErrMsg
  11282. res.Cainfo = resSixteen10265.Cainfo
  11283. res.WarnMsg = resSixteen10265.WarnMsg
  11284. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11285. res.Infcode = infocode
  11286. } else {
  11287. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11288. var dat map[string]interface{}
  11289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11290. fmt.Println(dat)
  11291. } else {
  11292. fmt.Println(err)
  11293. }
  11294. saveLog(result, src_resquest, "2208", "退费")
  11295. userJSONBytes, _ := json.Marshal(dat)
  11296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11297. utils.ErrorLog("解析失败:%v", err)
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. return
  11300. }
  11301. }
  11302. }
  11303. if res.Infcode == 0 {
  11304. var res2 ResultSix
  11305. var resSix10265 ResultSix10265
  11306. if miConfig.MdtrtareaAdmvs == "421300" {
  11307. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11308. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11309. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11310. resp3, requestErr3 := http.Get(api3)
  11311. if requestErr3 != nil {
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return
  11314. }
  11315. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11316. if ioErr3 != nil {
  11317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11319. return
  11320. }
  11321. var respJSON3 map[string]interface{}
  11322. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11325. return
  11326. }
  11327. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11328. userJSONBytes3, _ := json.Marshal(respJSON3)
  11329. fmt.Println("log")
  11330. fmt.Println(string(userJSONBytes3))
  11331. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11332. utils.ErrorLog("解析失败:%v", err)
  11333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11334. return
  11335. }
  11336. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11337. var api3 string
  11338. if miConfig.MdtrtareaAdmvs == "320921" {
  11339. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11340. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11342. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11343. } else {
  11344. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11345. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11346. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11348. }
  11349. resp3, requestErr3 := http.Get(api3)
  11350. if requestErr3 != nil {
  11351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11352. return
  11353. }
  11354. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11355. if ioErr3 != nil {
  11356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11358. return
  11359. }
  11360. var respJSON3 map[string]interface{}
  11361. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11364. return
  11365. }
  11366. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11367. userJSONBytes3, _ := json.Marshal(respJSON3)
  11368. fmt.Println("log")
  11369. fmt.Println(string(userJSONBytes3))
  11370. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11371. utils.ErrorLog("解析失败:%v", err)
  11372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11373. return
  11374. }
  11375. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11376. res2.Output = resSix10265.Output
  11377. res2.ErrMsg = resSix10265.ErrMsg
  11378. res2.Cainfo = resSix10265.Cainfo
  11379. res2.WarnMsg = resSix10265.WarnMsg
  11380. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11381. res2.Infcode = infocode
  11382. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11383. 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)
  11384. var dat map[string]interface{}
  11385. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11386. fmt.Println(dat)
  11387. } else {
  11388. fmt.Println(err)
  11389. }
  11390. saveLog(result2, src_request, "2205", "撤销明细")
  11391. userJSONBytes, _ := json.Marshal(dat)
  11392. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11393. utils.ErrorLog("解析失败:%v", err)
  11394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11395. return
  11396. }
  11397. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11398. 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, "")
  11399. var dat map[string]interface{}
  11400. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11401. fmt.Println(dat)
  11402. } else {
  11403. fmt.Println(err)
  11404. }
  11405. saveLog(result2, src_request, "2205", "撤销明细")
  11406. userJSONBytes, _ := json.Marshal(dat)
  11407. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11408. utils.ErrorLog("解析失败:%v", err)
  11409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11410. return
  11411. }
  11412. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11413. 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, "")
  11414. var dat map[string]interface{}
  11415. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11416. fmt.Println(dat)
  11417. } else {
  11418. fmt.Println(err)
  11419. }
  11420. saveLog(result2, src_request, "2205", "撤销明细")
  11421. userJSONBytes, _ := json.Marshal(dat)
  11422. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11423. utils.ErrorLog("解析失败:%v", err)
  11424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11425. return
  11426. }
  11427. } else {
  11428. if miConfig.Code == "H15049901371" {
  11429. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11430. var dat map[string]interface{}
  11431. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11432. fmt.Println(dat)
  11433. } else {
  11434. fmt.Println(err)
  11435. }
  11436. saveLog(result2, src_request, "2205", "撤销明细")
  11437. userJSONBytes, _ := json.Marshal(dat)
  11438. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11439. utils.ErrorLog("解析失败:%v", err)
  11440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11441. return
  11442. }
  11443. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11444. res2.Output = resSix10265.Output
  11445. res2.ErrMsg = resSix10265.ErrMsg
  11446. res2.Cainfo = resSix10265.Cainfo
  11447. res2.WarnMsg = resSix10265.WarnMsg
  11448. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11449. res2.Infcode = infocode
  11450. } else {
  11451. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11452. var dat map[string]interface{}
  11453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11454. fmt.Println(dat)
  11455. } else {
  11456. fmt.Println(err)
  11457. }
  11458. saveLog(result2, src_request, "2205", "撤销明细")
  11459. userJSONBytes, _ := json.Marshal(dat)
  11460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11461. utils.ErrorLog("解析失败:%v", err)
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. }
  11466. }
  11467. if res2.Infcode == 0 {
  11468. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  11469. if err == nil {
  11470. //当押金不为零时产生退费记录
  11471. if order.Decimal != 0 {
  11472. tmp := strconv.FormatInt(order.ID, 10)
  11473. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  11474. if err != nil {
  11475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11476. return
  11477. }
  11478. }
  11479. c.ServeSuccessJSON(map[string]interface{}{
  11480. "msg": "退费成功",
  11481. })
  11482. } else {
  11483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11484. return
  11485. }
  11486. } else {
  11487. c.ServeSuccessJSON(map[string]interface{}{
  11488. "code": -10,
  11489. "msg": res2.ErrMsg,
  11490. })
  11491. }
  11492. } else {
  11493. c.ServeSuccessJSON(map[string]interface{}{
  11494. "code": -10,
  11495. "msg": res.ErrMsg,
  11496. })
  11497. }
  11498. }
  11499. }
  11500. func (c *HisApiController) RefundNumber() {
  11501. record_time := c.GetString("record_time")
  11502. //patient_id, _ := c.GetInt64("patient_id")
  11503. admin_user_id, _ := c.GetInt64("admin_user_id")
  11504. his_patient_id, _ := c.GetInt64("id")
  11505. timeLayout := "2006-01-02"
  11506. loc, _ := time.LoadLocation("Local")
  11507. adminUser := c.GetAdminUserInfo()
  11508. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11509. fmt.Println(err)
  11510. if err != nil {
  11511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11512. return
  11513. }
  11514. recordDateTime := theTime.Unix()
  11515. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11516. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  11517. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11518. //order, _ := service.GetHisOrderByID(order_id)
  11519. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11520. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11521. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11522. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  11523. if count > 0 {
  11524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  11525. return
  11526. }
  11527. if config.IsOpen == 1 { //对接了医保,走医保流程
  11528. var res2 ResultSix
  11529. var resSix10265 ResultSix10265
  11530. if miConfig.MdtrtareaAdmvs == "421300" {
  11531. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  11532. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11533. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11534. resp3, requestErr3 := http.Get(api3)
  11535. if requestErr3 != nil {
  11536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11537. return
  11538. }
  11539. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11540. if ioErr3 != nil {
  11541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11543. return
  11544. }
  11545. var respJSON3 map[string]interface{}
  11546. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11549. return
  11550. }
  11551. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11552. userJSONBytes3, _ := json.Marshal(respJSON3)
  11553. fmt.Println("log")
  11554. fmt.Println(string(userJSONBytes3))
  11555. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11556. utils.ErrorLog("解析失败:%v", err)
  11557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11558. return
  11559. }
  11560. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11561. var api3 string
  11562. if miConfig.MdtrtareaAdmvs == "320921" {
  11563. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11564. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11566. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11567. } else {
  11568. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11569. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11570. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11572. }
  11573. resp3, requestErr3 := http.Get(api3)
  11574. if requestErr3 != nil {
  11575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11576. return
  11577. }
  11578. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11579. if ioErr3 != nil {
  11580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11582. return
  11583. }
  11584. var respJSON3 map[string]interface{}
  11585. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11588. return
  11589. }
  11590. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11591. userJSONBytes3, _ := json.Marshal(respJSON3)
  11592. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11593. utils.ErrorLog("解析失败:%v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return
  11596. }
  11597. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11598. res2.Output = resSix10265.Output
  11599. res2.ErrMsg = resSix10265.ErrMsg
  11600. res2.Cainfo = resSix10265.Cainfo
  11601. res2.WarnMsg = resSix10265.WarnMsg
  11602. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11603. res2.Infcode = infocode
  11604. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11605. 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)
  11606. var dat map[string]interface{}
  11607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11608. fmt.Println(dat)
  11609. } else {
  11610. fmt.Println(err)
  11611. }
  11612. saveLog(result, request, "2202", "退号")
  11613. userJSONBytes, _ := json.Marshal(dat)
  11614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11615. utils.ErrorLog("解析失败:%v", err)
  11616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11617. return
  11618. }
  11619. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11620. 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, "")
  11621. var dat map[string]interface{}
  11622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11623. fmt.Println(dat)
  11624. } else {
  11625. fmt.Println(err)
  11626. }
  11627. saveLog(result, request, "2202", "退号")
  11628. userJSONBytes, _ := json.Marshal(dat)
  11629. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11630. utils.ErrorLog("解析失败:%v", err)
  11631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11632. return
  11633. }
  11634. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11635. 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, "")
  11636. var dat map[string]interface{}
  11637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11638. fmt.Println(dat)
  11639. } else {
  11640. fmt.Println(err)
  11641. }
  11642. saveLog(result, request, "2202", "退号")
  11643. userJSONBytes, _ := json.Marshal(dat)
  11644. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11645. utils.ErrorLog("解析失败:%v", err)
  11646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11647. return
  11648. }
  11649. } else {
  11650. var api3 string
  11651. if miConfig.Code == "H15049901371" {
  11652. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11653. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11654. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11655. } else {
  11656. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11657. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11658. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11659. }
  11660. resp3, requestErr3 := http.Get(api3)
  11661. if requestErr3 != nil {
  11662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11663. return
  11664. }
  11665. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11666. if ioErr3 != nil {
  11667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11669. return
  11670. }
  11671. var respJSON3 map[string]interface{}
  11672. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11675. return
  11676. }
  11677. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11678. userJSONBytes3, _ := json.Marshal(respJSON3)
  11679. if miConfig.Code == "H15049901371" {
  11680. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11681. utils.ErrorLog("解析失败:%v", err)
  11682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11683. return
  11684. }
  11685. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11686. res2.Output = resSix10265.Output
  11687. res2.ErrMsg = resSix10265.ErrMsg
  11688. res2.Cainfo = resSix10265.Cainfo
  11689. res2.WarnMsg = resSix10265.WarnMsg
  11690. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11691. res2.Infcode = infocode
  11692. } else {
  11693. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11694. utils.ErrorLog("解析失败:%v", err)
  11695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11696. return
  11697. }
  11698. }
  11699. }
  11700. if res2.Infcode == 0 {
  11701. if err == nil {
  11702. c.ServeSuccessJSON(map[string]interface{}{
  11703. "msg": "退号成功",
  11704. })
  11705. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  11706. } else {
  11707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11708. return
  11709. }
  11710. } else {
  11711. c.ServeSuccessJSON(map[string]interface{}{
  11712. "code": -10,
  11713. "msg": res2.ErrMsg,
  11714. })
  11715. }
  11716. } else {
  11717. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  11718. //if err == nil {
  11719. // c.ServeSuccessJSON(map[string]interface{}{
  11720. // "msg": "退费成功",
  11721. // })
  11722. //} else {
  11723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11724. // return
  11725. //}
  11726. }
  11727. }
  11728. func (c *HisApiController) RefundDetail() {
  11729. order_id, _ := c.GetInt64("order_id")
  11730. admin_user_id, _ := c.GetInt64("admin_user_id")
  11731. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11732. number := c.GetString("number")
  11733. record_time := c.GetString("record_time")
  11734. patient_id, _ := c.GetInt64("patient_id")
  11735. //med_type, _ := c.GetInt64("med_type")
  11736. timeLayout := "2006-01-02"
  11737. loc, _ := time.LoadLocation("Local")
  11738. adminUser := c.GetAdminUserInfo()
  11739. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11740. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11741. fmt.Println(err)
  11742. if err != nil {
  11743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11744. return
  11745. }
  11746. recordDateTime := theTime.Unix()
  11747. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11748. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11749. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11750. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11751. var order models.HisOrder
  11752. order, _ = service.GetHisOrderByID(order_id)
  11753. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11754. if config.IsOpen == 1 { //对接了医保,走医保流程
  11755. var res2 ResultSix
  11756. if miConfig.MdtrtareaAdmvs == "421300" {
  11757. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11758. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11759. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11760. resp3, requestErr3 := http.Get(api3)
  11761. if requestErr3 != nil {
  11762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11763. return
  11764. }
  11765. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11766. if ioErr3 != nil {
  11767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11769. return
  11770. }
  11771. var respJSON3 map[string]interface{}
  11772. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11775. return
  11776. }
  11777. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11778. userJSONBytes3, _ := json.Marshal(respJSON3)
  11779. fmt.Println("log")
  11780. fmt.Println(string(userJSONBytes3))
  11781. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11782. utils.ErrorLog("解析失败:%v", err)
  11783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11784. return
  11785. }
  11786. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11787. if err == nil {
  11788. c.ServeSuccessJSON(map[string]interface{}{
  11789. "msg": "撤销明细成功",
  11790. })
  11791. return
  11792. } else {
  11793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11794. return
  11795. }
  11796. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11797. var resSix10265 ResultSix10265
  11798. var api3 string
  11799. if miConfig.MdtrtareaAdmvs == "320921" {
  11800. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11801. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11803. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11804. } else {
  11805. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11806. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11807. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11809. }
  11810. resp3, requestErr3 := http.Get(api3)
  11811. if requestErr3 != nil {
  11812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11813. return
  11814. }
  11815. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11816. if ioErr3 != nil {
  11817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11819. return
  11820. }
  11821. var respJSON3 map[string]interface{}
  11822. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11825. return
  11826. }
  11827. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11828. userJSONBytes3, _ := json.Marshal(respJSON3)
  11829. fmt.Println("log")
  11830. fmt.Println(string(userJSONBytes3))
  11831. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11832. utils.ErrorLog("解析失败:%v", err)
  11833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11834. return
  11835. }
  11836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11837. res2.Output = resSix10265.Output
  11838. res2.ErrMsg = resSix10265.ErrMsg
  11839. res2.Cainfo = resSix10265.Cainfo
  11840. res2.WarnMsg = resSix10265.WarnMsg
  11841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11842. res2.Infcode = infocode
  11843. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11844. if err == nil {
  11845. c.ServeSuccessJSON(map[string]interface{}{
  11846. "msg": "撤销明细成功",
  11847. })
  11848. return
  11849. } else {
  11850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11851. return
  11852. }
  11853. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11854. 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)
  11855. var dat map[string]interface{}
  11856. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11857. fmt.Println(dat)
  11858. } else {
  11859. fmt.Println(err)
  11860. }
  11861. saveLog(result2, src_request, "2205", "撤销明细")
  11862. userJSONBytes, _ := json.Marshal(dat)
  11863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11864. utils.ErrorLog("解析失败:%v", err)
  11865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11866. return
  11867. }
  11868. if res2.Infcode == 0 {
  11869. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11870. if err == nil {
  11871. c.ServeSuccessJSON(map[string]interface{}{
  11872. "msg": "撤销明细成功",
  11873. })
  11874. return
  11875. } else {
  11876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11877. return
  11878. }
  11879. } else {
  11880. c.ServeSuccessJSON(map[string]interface{}{
  11881. "code": -10,
  11882. "msg": res2.ErrMsg,
  11883. })
  11884. }
  11885. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11886. 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, "")
  11887. var dat map[string]interface{}
  11888. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11889. fmt.Println(dat)
  11890. } else {
  11891. fmt.Println(err)
  11892. }
  11893. saveLog(result2, src_request, "2205", "撤销明细")
  11894. userJSONBytes, _ := json.Marshal(dat)
  11895. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11896. utils.ErrorLog("解析失败:%v", err)
  11897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11898. return
  11899. }
  11900. if res2.Infcode == 0 {
  11901. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11902. if err == nil {
  11903. c.ServeSuccessJSON(map[string]interface{}{
  11904. "msg": "撤销明细成功",
  11905. })
  11906. return
  11907. } else {
  11908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11909. return
  11910. }
  11911. } else {
  11912. c.ServeSuccessJSON(map[string]interface{}{
  11913. "code": -10,
  11914. "msg": res2.ErrMsg,
  11915. })
  11916. }
  11917. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11918. 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, "")
  11919. var dat map[string]interface{}
  11920. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11921. fmt.Println(dat)
  11922. } else {
  11923. fmt.Println(err)
  11924. }
  11925. saveLog(result2, src_request, "2205", "撤销明细")
  11926. userJSONBytes, _ := json.Marshal(dat)
  11927. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11928. utils.ErrorLog("解析失败:%v", err)
  11929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11930. return
  11931. }
  11932. if res2.Infcode == 0 {
  11933. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11934. if err == nil {
  11935. c.ServeSuccessJSON(map[string]interface{}{
  11936. "msg": "撤销明细成功",
  11937. })
  11938. return
  11939. } else {
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. } else {
  11944. c.ServeSuccessJSON(map[string]interface{}{
  11945. "code": -10,
  11946. "msg": res2.ErrMsg,
  11947. })
  11948. }
  11949. } else {
  11950. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11951. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11953. resp2, requestErr2 := http.Get(api2)
  11954. if requestErr2 != nil {
  11955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11956. return
  11957. }
  11958. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11959. if ioErr2 != nil {
  11960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11962. return
  11963. }
  11964. var respJSON2 map[string]interface{}
  11965. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11968. return
  11969. }
  11970. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11971. if err == nil {
  11972. c.ServeSuccessJSON(map[string]interface{}{
  11973. "msg": "撤销明细成功",
  11974. })
  11975. return
  11976. } else {
  11977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11978. return
  11979. }
  11980. }
  11981. } else {
  11982. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11983. if err == nil {
  11984. c.ServeSuccessJSON(map[string]interface{}{
  11985. "msg": "退费成功",
  11986. })
  11987. } else {
  11988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11989. return
  11990. }
  11991. }
  11992. }
  11993. //对账
  11994. func (c *HisApiController) GetCheckAccount() {
  11995. start_time := c.GetString("start_time")
  11996. end_time := c.GetString("end_time")
  11997. insutype := c.GetString("insutype")
  11998. clr_type := c.GetString("clr_type")
  11999. clr_org := c.GetString("clr_optins")
  12000. admin_user_id, _ := c.GetInt64("admin_user_id")
  12001. adminUser := c.GetAdminUserInfo()
  12002. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12003. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12004. if len(clr_org) == 0 {
  12005. clr_org = miConfig.MdtrtareaAdmvs
  12006. }
  12007. timeLayout := "2006-01-02"
  12008. loc, _ := time.LoadLocation("Local")
  12009. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12010. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12011. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12012. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12013. fixmedins_setl_cnt := int64(len(orders))
  12014. var medfee_sumamt float64
  12015. var acct_pay float64
  12016. var fund_pay_sumamt float64
  12017. for _, item := range orders {
  12018. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12019. acct_pay = acct_pay + item.AcctPay
  12020. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12021. }
  12022. var user_name string
  12023. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12024. if role.ID == 0 {
  12025. user_name = "xxx"
  12026. } else {
  12027. user_name = role.UserName
  12028. }
  12029. var res ResultEight
  12030. var res10188 ResultEightFor10188
  12031. if config.IsOpen == 1 {
  12032. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12033. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  12034. "insutype=" + insutype +
  12035. "&clr_type=" + clr_type +
  12036. "&setl_optins=" + clr_org +
  12037. "&stmt_begndate=" + start_time +
  12038. "&stm_enddate=" + end_time +
  12039. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12040. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12041. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12042. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12043. "&fixmedins_code=" + miConfig.Code +
  12044. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12045. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12046. "&secret_key=" + miConfig.SecretKey +
  12047. "&org_name=" + miConfig.OrgName +
  12048. "&doctor=" + user_name +
  12049. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12050. fmt.Println(api)
  12051. resp, requestErr := http.Get(api)
  12052. if requestErr != nil {
  12053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12054. return
  12055. }
  12056. body, ioErr := ioutil.ReadAll(resp.Body)
  12057. fmt.Println(body)
  12058. if ioErr != nil {
  12059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12061. return
  12062. }
  12063. var respJSON map[string]interface{}
  12064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12070. userJSONBytes, _ := json.Marshal(respJSON)
  12071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12072. utils.ErrorLog("解析失败:%v", err)
  12073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. return
  12075. }
  12076. res.InfRefmsgid = res10188.InfRefmsgid
  12077. res.Output = res10188.Output
  12078. res.ErrMsg = res10188.ErrMsg
  12079. res.Cainfo = res10188.Cainfo
  12080. res.WarnMsg = res10188.WarnMsg
  12081. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12082. res.Infcode = infocode
  12083. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12084. if clr_type == "11" {
  12085. fixmedins_setl_cnt = 2
  12086. }
  12087. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  12088. "insutype=" + insutype +
  12089. "&clr_type=" + clr_type +
  12090. "&setl_optins=" + clr_org +
  12091. "&stmt_begndate=" + start_time +
  12092. "&stm_enddate=" + end_time +
  12093. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12094. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12095. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12096. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12097. "&fixmedins_code=" + miConfig.Code +
  12098. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12099. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12100. "&secret_key=" + miConfig.SecretKey +
  12101. "&org_name=" + miConfig.OrgName +
  12102. "&doctor=" + user_name
  12103. resp, requestErr := http.Get(api)
  12104. if requestErr != nil {
  12105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12106. return
  12107. }
  12108. body, ioErr := ioutil.ReadAll(resp.Body)
  12109. if ioErr != nil {
  12110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12112. return
  12113. }
  12114. var respJSON map[string]interface{}
  12115. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12118. return
  12119. }
  12120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12121. result, _ := json.Marshal(respJSON)
  12122. fmt.Println("log")
  12123. fmt.Println(string(result))
  12124. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  12125. utils.ErrorLog("解析失败:%v", err)
  12126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12127. return
  12128. }
  12129. res.InfRefmsgid = res10188.InfRefmsgid
  12130. res.Output = res10188.Output
  12131. res.ErrMsg = res10188.ErrMsg
  12132. res.Cainfo = res10188.Cainfo
  12133. res.WarnMsg = res10188.WarnMsg
  12134. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12135. res.Infcode = infocode
  12136. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12137. var baseParams models.BaseParams
  12138. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12139. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12140. baseParams.SecretKey = miConfig.SecretKey
  12141. baseParams.OrgName = miConfig.OrgName
  12142. baseParams.FixmedinsCode = miConfig.Code
  12143. baseParams.EncKey = miConfig.EncKey
  12144. baseParams.AppSecret = miConfig.AppSecret
  12145. baseParams.SignKey = miConfig.SignKey
  12146. baseParams.AppID = miConfig.Code
  12147. baseParams.Doctor = role.UserName
  12148. baseParams.RequestUrl = miConfig.Url
  12149. businessParams := models.BusinessParams{
  12150. Insutype: insutype,
  12151. ClrType: clr_type,
  12152. SetlOptins: clr_org,
  12153. StmtBegndate: start_time,
  12154. StmtEnddate: end_time,
  12155. MedfeeSumamt: medfee_sumamt,
  12156. FundPaySumamt: fund_pay_sumamt,
  12157. AcctPay: acct_pay,
  12158. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12159. }
  12160. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12161. fmt.Println(requestLog)
  12162. fmt.Println(result)
  12163. fmt.Println(err_msg)
  12164. var dat map[string]interface{}
  12165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12166. fmt.Println(dat)
  12167. } else {
  12168. fmt.Println(err)
  12169. }
  12170. userJSONBytes, _ := json.Marshal(dat)
  12171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12172. utils.ErrorLog("解析失败:%v", err)
  12173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12174. return
  12175. }
  12176. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12177. var baseParams models.BaseParams
  12178. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12179. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12180. baseParams.SecretKey = miConfig.SecretKey
  12181. baseParams.OrgName = miConfig.OrgName
  12182. baseParams.FixmedinsCode = miConfig.Code
  12183. baseParams.EncKey = miConfig.EncKey
  12184. baseParams.AppSecret = miConfig.AppSecret
  12185. baseParams.SignKey = miConfig.SignKey
  12186. baseParams.AppID = miConfig.Code
  12187. baseParams.Doctor = role.UserName
  12188. baseParams.RequestUrl = miConfig.Url
  12189. baseParams.AccessKey = miConfig.AccessKey
  12190. businessParams := models.BusinessParams{
  12191. Insutype: insutype,
  12192. ClrType: clr_type,
  12193. SetlOptins: "430822",
  12194. StmtBegndate: start_time,
  12195. StmtEnddate: end_time,
  12196. MedfeeSumamt: medfee_sumamt,
  12197. FundPaySumamt: fund_pay_sumamt,
  12198. AcctPay: acct_pay,
  12199. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12200. }
  12201. 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)
  12202. fmt.Println(requestLog)
  12203. fmt.Println(result)
  12204. var dat map[string]interface{}
  12205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12206. fmt.Println(dat)
  12207. } else {
  12208. fmt.Println(err)
  12209. }
  12210. userJSONBytes, _ := json.Marshal(dat)
  12211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12212. utils.ErrorLog("解析失败:%v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. } else if miConfig.MdtrtareaAdmvs == "" {
  12217. var baseParams models.BaseParams
  12218. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12219. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12220. baseParams.SecretKey = miConfig.SecretKey
  12221. baseParams.OrgName = miConfig.OrgName
  12222. baseParams.FixmedinsCode = miConfig.Code
  12223. baseParams.EncKey = miConfig.EncKey
  12224. baseParams.AppSecret = miConfig.AppSecret
  12225. baseParams.SignKey = miConfig.SignKey
  12226. baseParams.AppID = miConfig.Code
  12227. baseParams.Doctor = role.UserName
  12228. baseParams.RequestUrl = miConfig.Url
  12229. businessParams := models.BusinessParams{
  12230. Insutype: insutype,
  12231. ClrType: clr_type,
  12232. SetlOptins: clr_org,
  12233. StmtBegndate: start_time,
  12234. StmtEnddate: end_time,
  12235. MedfeeSumamt: medfee_sumamt,
  12236. FundPaySumamt: fund_pay_sumamt,
  12237. AcctPay: acct_pay,
  12238. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12239. }
  12240. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12241. fmt.Println(requestLog)
  12242. fmt.Println(result)
  12243. fmt.Println(err_msg)
  12244. var dat map[string]interface{}
  12245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12246. fmt.Println(dat)
  12247. } else {
  12248. fmt.Println(err)
  12249. }
  12250. userJSONBytes, _ := json.Marshal(dat)
  12251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12252. utils.ErrorLog("解析失败:%v", err)
  12253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12254. return
  12255. }
  12256. } else {
  12257. if len(clr_type) == 0 {
  12258. clr_type = "11"
  12259. }
  12260. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12261. "insutype=" + insutype +
  12262. "&clr_type=" + clr_type +
  12263. "&setl_optins=" + clr_org +
  12264. "&stmt_begndate=" + start_time +
  12265. "&stm_enddate=" + end_time +
  12266. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12267. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12268. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12269. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12270. "&fixmedins_code=" + miConfig.Code +
  12271. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12272. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12273. "&secret_key=" + miConfig.SecretKey +
  12274. "&org_name=" + miConfig.OrgName +
  12275. "&doctor=" + user_name
  12276. fmt.Println(api)
  12277. resp, requestErr := http.Get(api)
  12278. if requestErr != nil {
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. body, ioErr := ioutil.ReadAll(resp.Body)
  12283. fmt.Println(body)
  12284. if ioErr != nil {
  12285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. var respJSON map[string]interface{}
  12290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. return
  12294. }
  12295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12296. userJSONBytes, _ := json.Marshal(respJSON)
  12297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12298. utils.ErrorLog("解析失败:%v", err)
  12299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12300. return
  12301. }
  12302. }
  12303. if res.Infcode == 0 {
  12304. if res.Output.Stmtinfo.StmtRslt == "0" {
  12305. micc := &models.MedicalInsuranceCostCompare{
  12306. StartTime: startime.Unix(),
  12307. EndTime: endtime.Unix(),
  12308. Insutype: insutype,
  12309. CheckType: 1,
  12310. Num: fixmedins_setl_cnt,
  12311. Mtime: time.Now().Unix(),
  12312. Status: 1,
  12313. UserOrgId: adminUser.CurrentOrgId,
  12314. CostTotal: medfee_sumamt,
  12315. FuncTotal: fund_pay_sumamt,
  12316. PsnPay: acct_pay,
  12317. Creator: admin_user_id,
  12318. Ctime: time.Now().Unix(),
  12319. ClrType: clr_type,
  12320. }
  12321. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  12322. if err == nil {
  12323. c.ServeSuccessJSON(map[string]interface{}{
  12324. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12325. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12326. })
  12327. } else {
  12328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12329. }
  12330. } else {
  12331. c.ServeSuccessJSON(map[string]interface{}{
  12332. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12333. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12334. })
  12335. }
  12336. } else {
  12337. c.ServeSuccessJSON(map[string]interface{}{
  12338. "code": -10,
  12339. "msg": res.ErrMsg,
  12340. })
  12341. }
  12342. }
  12343. }
  12344. func (c *HisApiController) Check310() {
  12345. adminUser := c.GetAdminUserInfo()
  12346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12347. var user_name string
  12348. user_name = "高慧裕"
  12349. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12350. "insutype=" + "310" +
  12351. "&clr_type=" + "" +
  12352. "&setl_optins=" + "441202" +
  12353. "&stmt_begndate=" + "2022-03-01" +
  12354. "&stm_enddate=" + "2022-03-31" +
  12355. "&medfee_sumamt=" + "194930.12" +
  12356. "&fund_pay_sumamt=" + "188741.46" +
  12357. "&acct_pay=" + "0" +
  12358. "&fixmedins_setl_cnt=" + "452" +
  12359. "&fixmedins_code=" + miConfig.Code +
  12360. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12361. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12362. "&secret_key=" + miConfig.SecretKey +
  12363. "&org_name=" + miConfig.OrgName +
  12364. "&doctor=" + user_name
  12365. fmt.Println(api)
  12366. resp, requestErr := http.Get(api)
  12367. if requestErr != nil {
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. body, ioErr := ioutil.ReadAll(resp.Body)
  12372. fmt.Println(body)
  12373. if ioErr != nil {
  12374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. var respJSON map[string]interface{}
  12379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12382. return
  12383. }
  12384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12385. userJSONBytes, _ := json.Marshal(respJSON)
  12386. var res ResultEight
  12387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12388. utils.ErrorLog("解析失败:%v", err)
  12389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. return
  12391. }
  12392. }
  12393. func (c *HisApiController) Check390() {
  12394. adminUser := c.GetAdminUserInfo()
  12395. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12396. var user_name string
  12397. user_name = "高慧裕"
  12398. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12399. "insutype=" + "390" +
  12400. "&clr_type=" + "" +
  12401. "&setl_optins=" + "441202" +
  12402. "&stmt_begndate=" + "2022-03-01" +
  12403. "&stm_enddate=" + "2022-03-31" +
  12404. "&medfee_sumamt=" + "1068448.89" +
  12405. "&fund_pay_sumamt=" + "1014677.62" +
  12406. "&acct_pay=" + "0" +
  12407. "&fixmedins_setl_cnt=" + "1950" +
  12408. "&fixmedins_code=" + miConfig.Code +
  12409. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12410. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12411. "&secret_key=" + miConfig.SecretKey +
  12412. "&org_name=" + miConfig.OrgName +
  12413. "&doctor=" + user_name
  12414. fmt.Println(api)
  12415. resp, requestErr := http.Get(api)
  12416. if requestErr != nil {
  12417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12418. return
  12419. }
  12420. body, ioErr := ioutil.ReadAll(resp.Body)
  12421. fmt.Println(body)
  12422. if ioErr != nil {
  12423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12425. return
  12426. }
  12427. var respJSON map[string]interface{}
  12428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12431. return
  12432. }
  12433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12434. userJSONBytes, _ := json.Marshal(respJSON)
  12435. var res ResultEight
  12436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12437. utils.ErrorLog("解析失败:%v", err)
  12438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12439. return
  12440. }
  12441. }
  12442. //对账明细
  12443. func (c *HisApiController) GetCheckDetailAccount() {
  12444. start_time := c.GetString("start_time")
  12445. end_time := c.GetString("end_time")
  12446. admin_user_id, _ := c.GetInt64("admin_user_id")
  12447. adminUser := c.GetAdminUserInfo()
  12448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12449. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12450. timeLayout := "2006-01-02"
  12451. loc, _ := time.LoadLocation("Local")
  12452. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12453. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12454. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12455. rand.Seed(time.Now().UnixNano())
  12456. num := rand.Intn(30000)
  12457. Mkdir(miConfig.OrgName)
  12458. file := strconv.FormatInt(int64(num), 10)
  12459. file_name := file + ".txt"
  12460. zip_name := file + ".zip"
  12461. zip_path := miConfig.OrgName + "/" + zip_name
  12462. file_path := miConfig.OrgName + "/" + file_name
  12463. decimal.DivisionPrecision = 2
  12464. var medfee_sumamt float64
  12465. var psn_cash_pay float64
  12466. var fund_pay_sumamt float64
  12467. fixmedins_setl_cnt := int64(len(orders))
  12468. for _, item := range orders {
  12469. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12470. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  12471. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12472. }
  12473. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  12474. defer f.Close()
  12475. if err != nil {
  12476. fmt.Println(err.Error())
  12477. } else {
  12478. for _, item := range orders {
  12479. var refd_setl_flag string
  12480. if item.OrderStatus == 2 {
  12481. refd_setl_flag = "0"
  12482. var str string
  12483. str = item.SetlId + " " +
  12484. item.MdtrtId + " " +
  12485. item.PsnNo + " " +
  12486. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12487. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12488. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  12489. _, err = f.Write([]byte(str))
  12490. }
  12491. if item.OrderStatus == 3 {
  12492. var str string
  12493. str = item.SetlId + " " +
  12494. item.MdtrtId + " " +
  12495. item.PsnNo + " " +
  12496. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12497. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12498. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  12499. _, err = f.Write([]byte(str))
  12500. var str2 string
  12501. str2 = item.SetlId + " " +
  12502. item.MdtrtId + " " +
  12503. item.PsnNo + " " +
  12504. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  12505. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  12506. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  12507. _, err = f.Write([]byte(str2))
  12508. }
  12509. }
  12510. }
  12511. Zip(file_path, zip_path)
  12512. fmt.Println(ReadFile(zip_path))
  12513. fmt.Println(string(ReadFile(zip_path)))
  12514. if config.IsOpen == 1 {
  12515. var user_name string
  12516. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12517. if role.ID == 0 {
  12518. user_name = "管理员"
  12519. } else {
  12520. user_name = role.UserName
  12521. }
  12522. baseParams := models.BaseParams{
  12523. SecretKey: miConfig.SecretKey,
  12524. FixmedinsCode: miConfig.Code,
  12525. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12526. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12527. OrgName: miConfig.OrgName,
  12528. Doctor: user_name,
  12529. }
  12530. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  12531. var dat map[string]interface{}
  12532. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12533. fmt.Println(dat)
  12534. } else {
  12535. fmt.Println(err)
  12536. }
  12537. userJSONBytes, _ := json.Marshal(dat)
  12538. var res ResultNine
  12539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12540. utils.ErrorLog("解析失败:%v", err)
  12541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12542. return
  12543. }
  12544. if res.Infcode == 0 {
  12545. fileNo := res.Output.FileQuryNo
  12546. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  12547. "file_qury_no=" + fileNo +
  12548. "&setl_optins=" + "定点医保中心" +
  12549. "&stmt_begndate=" + start_time +
  12550. "&stm_enddate=" + end_time +
  12551. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12552. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12553. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  12554. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12555. "&fixmedins_code=" + miConfig.Code +
  12556. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12557. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12558. "&secret_key=" + miConfig.SecretKey +
  12559. "&org_name=" + miConfig.OrgName +
  12560. "&doctor=" + user_name
  12561. resp, requestErr := http.Get(api)
  12562. if requestErr != nil {
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12564. return
  12565. }
  12566. body, ioErr := ioutil.ReadAll(resp.Body)
  12567. if ioErr != nil {
  12568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12570. return
  12571. }
  12572. var respJSON map[string]interface{}
  12573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12579. userJSONBytes, _ := json.Marshal(respJSON)
  12580. var res ResultTen
  12581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12582. utils.ErrorLog("解析失败:%v", err)
  12583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12584. return
  12585. }
  12586. if res.Infcode == 0 {
  12587. service.Gdyb9102(baseParams, zip_name, fileNo)
  12588. micc := &models.MedicalInsuranceCostCompare{
  12589. StartTime: startime.Unix(),
  12590. EndTime: endtime.Unix(),
  12591. Insutype: "0",
  12592. CheckType: 2,
  12593. Num: fixmedins_setl_cnt,
  12594. Mtime: time.Now().Unix(),
  12595. Status: 1,
  12596. UserOrgId: adminUser.CurrentOrgId,
  12597. CostTotal: medfee_sumamt,
  12598. FuncTotal: fund_pay_sumamt,
  12599. PsnPay: psn_cash_pay,
  12600. Creator: admin_user_id,
  12601. Ctime: time.Now().Unix(),
  12602. }
  12603. service.CreateMedicalInsuranceCostCompareRecord(micc)
  12604. c.ServeSuccessJSON(map[string]interface{}{
  12605. "msg": "明细对账成功",
  12606. })
  12607. }
  12608. } else {
  12609. }
  12610. }
  12611. }
  12612. type CustomOrderInfo struct {
  12613. Name string
  12614. Spec string
  12615. Unit string
  12616. Count float64
  12617. Price float64
  12618. Total float64
  12619. }
  12620. func (c *HisApiController) GetSettleAccounts() {
  12621. //id, _ := c.GetInt64("id")
  12622. //record_time := c.GetString("record_time")
  12623. order_id, _ := c.GetInt64("order_id")
  12624. admin_user_id, _ := c.GetInt64("admin_user_id")
  12625. //timeLayout := "2006-01-02"
  12626. //loc, _ := time.LoadLocation("Local")
  12627. //
  12628. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12629. //if err != nil {
  12630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12631. // return
  12632. //}
  12633. //recordDateTime := theTime.Unix()
  12634. adminUser := c.GetAdminUserInfo()
  12635. order, _ := service.GetHisOrderByID(order_id)
  12636. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12637. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  12638. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  12639. orderInfos = append(orderInfos, orderInfos_two...)
  12640. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12641. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  12642. var diagnosis_ids []string
  12643. if his.ID > 0 {
  12644. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  12645. } else {
  12646. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  12647. }
  12648. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  12649. var dia_config []*models.HisXtDiagnoseConfig
  12650. var name string
  12651. for _, item := range diagnosis_ids {
  12652. id, _ := strconv.ParseInt(item, 10, 64)
  12653. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12654. dia_config = append(dia_config, &diagnosisConfig)
  12655. if len(name) == 0 {
  12656. name = diagnosisConfig.ClassName
  12657. } else {
  12658. name = name + "," + diagnosisConfig.ClassName
  12659. }
  12660. }
  12661. var bedCostTotal float64 = 0 //床位总费
  12662. var bedCostSelfTotal float64 = 0 //床位自费
  12663. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12664. var bedSelfTotal float64 = 0 //床位部分项目自费
  12665. var bedInscpTotal float64 = 0 //床位部分项目自费
  12666. var operationCostTotal float64 = 0 //手术费
  12667. var operationCostSelfTotal float64 = 0 //手术费
  12668. var operationCostPartSelfTotal float64 = 0 //手术费
  12669. var operationSelfTotal float64 = 0 //床位部分项目自费
  12670. var operationInscpTotal float64 = 0 //床位部分项目自费
  12671. var otherCostTotal float64 = 0 //其他费用
  12672. var otherCostSelfTotal float64 = 0 //其他费用
  12673. var otherCostPartSelfTotal float64 = 0 //其他费用
  12674. var otherSelfTotal float64 = 0 //床位部分项目自费
  12675. var otherInscpTotal float64 = 0 //床位部分项目自费
  12676. var materialCostTotal float64 = 0 //材料费
  12677. var materialCostSelfTotal float64 = 0 //材料费
  12678. var materialCostPartSelfTotal float64 = 0 //材料费
  12679. var materialSelfTotal float64 = 0 //床位部分项目自费
  12680. var materialInscpTotal float64 = 0 //床位部分项目自费
  12681. var westernMedicineCostTotal float64 = 0 //西药费
  12682. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12683. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12684. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  12685. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  12686. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12687. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12688. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12689. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  12690. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  12691. var checkCostTotal float64 = 0 //检查费
  12692. var checkCostSelfTotal float64 = 0 //检查费
  12693. var checkCostPartSelfTotal float64 = 0 //检查费
  12694. var checkSelfTotal float64 = 0 //床位部分项目自费
  12695. var checkInscpTotal float64 = 0 //床位部分项目自费
  12696. var laboratoryCostTotal float64 = 0 //化验费
  12697. var laboratoryCostSelfTotal float64 = 0 //化验费
  12698. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12699. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  12700. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  12701. var treatCostTotal float64 = 0 //治疗费用
  12702. var treatCostSelfTotal float64 = 0 //治疗费用
  12703. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12704. var treatSelfTotal float64 = 0 //床位部分项目自费
  12705. var treatInscpTotal float64 = 0 //床位部分项目自费
  12706. decimal.DivisionPrecision = 2
  12707. for _, item := range orderInfos {
  12708. if item.MedChrgitmType == "01" { //床位费
  12709. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12710. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12711. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12712. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12713. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12714. }
  12715. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  12716. if item.MedChrgitmType == "03" { //检查费
  12717. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12718. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12719. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12720. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12721. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12722. }
  12723. } else {
  12724. if item.MedChrgitmType == "03" { //检查费
  12725. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12726. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12727. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12728. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12729. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12730. }
  12731. }
  12732. if item.MedChrgitmType == "04" { //化验费
  12733. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12734. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12735. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12736. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12737. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12738. }
  12739. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  12740. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12741. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12742. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12743. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12744. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12745. }
  12746. if item.MedChrgitmType == "06" { //手术费
  12747. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12748. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12749. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12750. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12751. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12752. }
  12753. if item.MedChrgitmType == "08" { //材料费
  12754. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12755. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12756. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12757. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12758. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12759. }
  12760. if item.MedChrgitmType == "09" { //西药费
  12761. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12762. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12763. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12764. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12765. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12766. }
  12767. if item.MedChrgitmType == "11" { //中成费
  12768. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12769. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12770. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12771. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12772. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12773. }
  12774. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  12775. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12776. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12777. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12778. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12779. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12780. }
  12781. }
  12782. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12783. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12784. var user_name string
  12785. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12786. if role.ID == 0 {
  12787. user_name = "管理员"
  12788. } else {
  12789. user_name = role.UserName
  12790. }
  12791. baseParams := models.BaseParams{
  12792. SecretKey: miConfig.SecretKey,
  12793. FixmedinsCode: miConfig.Code,
  12794. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12795. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12796. OrgName: miConfig.OrgName,
  12797. Doctor: user_name,
  12798. RequestUrl: miConfig.Url,
  12799. AccessKey: miConfig.AccessKey,
  12800. }
  12801. businessParams := models.BusinessParams{
  12802. PsnNo: order.PsnNo,
  12803. MdtrtId: order.MdtrtId,
  12804. SetlId: order.SetlId,
  12805. }
  12806. var res ResultEleven
  12807. var resEleven10265 ResultEleven10265
  12808. if config.IsOpen == 1 {
  12809. if miConfig.MdtrtareaAdmvs == "421300" {
  12810. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12811. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12812. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12813. resp, requestErr := http.Get(api)
  12814. if requestErr != nil {
  12815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12816. return
  12817. }
  12818. body, ioErr := ioutil.ReadAll(resp.Body)
  12819. if ioErr != nil {
  12820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12822. return
  12823. }
  12824. var respJSON map[string]interface{}
  12825. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12828. return
  12829. }
  12830. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12831. result, _ := json.Marshal(respJSON)
  12832. fmt.Println("log")
  12833. fmt.Println(string(result))
  12834. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12835. utils.ErrorLog("解析失败:%v", err)
  12836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12837. return
  12838. }
  12839. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12840. var api string
  12841. if miConfig.MdtrtareaAdmvs == "320921" {
  12842. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12843. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12844. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12845. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12846. } else {
  12847. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12848. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12849. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12851. }
  12852. resp, requestErr := http.Get(api)
  12853. if requestErr != nil {
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return
  12856. }
  12857. body, ioErr := ioutil.ReadAll(resp.Body)
  12858. if ioErr != nil {
  12859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12861. return
  12862. }
  12863. var respJSON map[string]interface{}
  12864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12867. return
  12868. }
  12869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12870. result, _ := json.Marshal(respJSON)
  12871. fmt.Println("log")
  12872. fmt.Println(string(result))
  12873. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12874. utils.ErrorLog("解析失败:%v", err)
  12875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12876. return
  12877. }
  12878. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12879. res.Output = resEleven10265.Output
  12880. res.ErrMsg = resEleven10265.ErrMsg
  12881. res.Cainfo = resEleven10265.Cainfo
  12882. res.WarnMsg = resEleven10265.WarnMsg
  12883. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12884. res.Infcode = infocode
  12885. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12886. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12887. saveLog(result, requestLog, "5203", "结算单")
  12888. var dat map[string]interface{}
  12889. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12890. fmt.Println(dat)
  12891. } else {
  12892. fmt.Println(err)
  12893. }
  12894. userJSONBytes, _ := json.Marshal(dat)
  12895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12896. utils.ErrorLog("解析失败:%v", err)
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return
  12899. }
  12900. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12901. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12902. saveLog(result, requestLog, "5203", "结算单")
  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. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12911. utils.ErrorLog("解析失败:%v", err)
  12912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12913. return
  12914. }
  12915. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12916. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12917. saveLog(result, requestLog, "5203", "结算单")
  12918. var dat map[string]interface{}
  12919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12920. fmt.Println(dat)
  12921. } else {
  12922. fmt.Println(err)
  12923. }
  12924. userJSONBytes, _ := json.Marshal(dat)
  12925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12926. utils.ErrorLog("解析失败:%v", err)
  12927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12928. return
  12929. }
  12930. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12931. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12932. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12933. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12934. resp, requestErr := http.Get(api)
  12935. if requestErr != nil {
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12937. return
  12938. }
  12939. body, ioErr := ioutil.ReadAll(resp.Body)
  12940. if ioErr != nil {
  12941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12943. return
  12944. }
  12945. var respJSON map[string]interface{}
  12946. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12949. return
  12950. }
  12951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12952. result, _ := json.Marshal(respJSON)
  12953. fmt.Println("log")
  12954. fmt.Println(string(result))
  12955. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12956. utils.ErrorLog("解析失败:%v", err)
  12957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12958. return
  12959. }
  12960. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12961. res.Output = resEleven10265.Output
  12962. res.ErrMsg = resEleven10265.ErrMsg
  12963. res.Cainfo = resEleven10265.Cainfo
  12964. res.WarnMsg = resEleven10265.WarnMsg
  12965. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12966. res.Infcode = infocode
  12967. } else {
  12968. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  12969. result := service.Gdyb5203(baseParams, businessParams)
  12970. //service.Gdyb5204(baseParams, businessParams)
  12971. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12972. var dat map[string]interface{}
  12973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12974. fmt.Println(dat)
  12975. } else {
  12976. fmt.Println(err)
  12977. }
  12978. userJSONBytes, _ := json.Marshal(dat)
  12979. if miConfig.Code == "H15049901371" {
  12980. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12981. utils.ErrorLog("解析失败:%v", err)
  12982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12983. return
  12984. }
  12985. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12986. res.Output = resEleven10265.Output
  12987. res.ErrMsg = resEleven10265.ErrMsg
  12988. res.Cainfo = resEleven10265.Cainfo
  12989. res.WarnMsg = resEleven10265.WarnMsg
  12990. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12991. res.Infcode = infocode
  12992. } else {
  12993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12994. utils.ErrorLog("解析失败:%v", err)
  12995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12996. return
  12997. }
  12998. }
  12999. }
  13000. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13001. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13002. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13003. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13004. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13005. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13006. var doctor_name string
  13007. if roles.ID == 0 {
  13008. doctor_name = "管理员"
  13009. } else {
  13010. doctor_name = roles.UserName
  13011. }
  13012. yiliao_leibie := ""
  13013. switch order.MedType {
  13014. case "11":
  13015. yiliao_leibie = "普通门诊"
  13016. break
  13017. case "12":
  13018. yiliao_leibie = "门诊挂号"
  13019. break
  13020. case "13":
  13021. yiliao_leibie = "急诊"
  13022. break
  13023. case "14":
  13024. yiliao_leibie = "门诊特殊病"
  13025. break
  13026. case "15":
  13027. yiliao_leibie = "门诊统筹"
  13028. break
  13029. case "16":
  13030. yiliao_leibie = "门诊慢性病"
  13031. break
  13032. case "21":
  13033. yiliao_leibie = "普通住院"
  13034. break
  13035. }
  13036. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13037. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13038. if res.Infcode == 0 {
  13039. c.ServeSuccessJSON(map[string]interface{}{
  13040. "diagnosis": name,
  13041. "order_infos": orderInfos,
  13042. "number": order.MdtrtId,
  13043. "date": order.SettleAccountsDate,
  13044. "charge_admin": charge_admin,
  13045. "printor_admin": printor_admin,
  13046. "info": res.Output.Setlinfo,
  13047. "order": order,
  13048. "bedCostTotal": bedCostTotal,
  13049. "bedCostSelfTotal": bedCostSelfTotal,
  13050. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13051. "bedSelfTotal": bedSelfTotal,
  13052. "bedInscpTotal": bedInscpTotal,
  13053. "operationCostTotal": operationCostTotal,
  13054. "operationCostSelfTotal": operationCostSelfTotal,
  13055. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13056. "operationSelfTotal": operationSelfTotal,
  13057. "operationInscpTotal": operationInscpTotal,
  13058. "otherCostTotal": otherCostTotal,
  13059. "otherCostSelfTotal": otherCostSelfTotal,
  13060. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13061. "otherSelfTotal": otherSelfTotal,
  13062. "otherInscpTotal": otherInscpTotal,
  13063. "materialCostTotal": materialCostTotal,
  13064. "materialCostSelfTotal": materialCostSelfTotal,
  13065. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13066. "materialSelfTotal": materialSelfTotal,
  13067. "materialInscpTotal": materialInscpTotal,
  13068. "westernMedicineCostTotal": westernMedicineCostTotal,
  13069. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13070. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13071. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13072. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13073. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13074. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13075. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13076. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13077. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13078. "checkCostTotal": checkCostTotal,
  13079. "checkCostSelfTotal": checkCostSelfTotal,
  13080. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13081. "checkSelfTotal": checkSelfTotal,
  13082. "checkInscpTotal": checkInscpTotal,
  13083. "laboratoryCostTotal": laboratoryCostTotal,
  13084. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13085. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13086. "laboratorySelfTotal": laboratorySelfTotal,
  13087. "laboratoryInscpTotal": laboratoryInscpTotal,
  13088. "treatCostTotal": treatCostTotal,
  13089. "treatCostSelfTotal": treatCostSelfTotal,
  13090. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13091. "treatSelfTotal": treatSelfTotal,
  13092. "treatInscpTotal": treatInscpTotal,
  13093. "doctor_info": doctor_info,
  13094. "doctor_code": adminRole_two.DoctorCode,
  13095. "doctor_name": doctor_name,
  13096. "health_card_no": order.PsnNo,
  13097. "department": departments.Name,
  13098. "yiliao_leibie": yiliao_leibie,
  13099. "after_money": order.AccountPrice,
  13100. "patient": patient,
  13101. "org_name": miConfig.OrgName,
  13102. "org_code": miConfig.Code,
  13103. "order_number": order.Number,
  13104. "his_hospital": his_hospital,
  13105. "his": his,
  13106. "dia_config": dia_config,
  13107. //"check_order_info": cus_slice,
  13108. })
  13109. }
  13110. }
  13111. }
  13112. func (c *HisApiController) CheckTreatment() {
  13113. patient_id, _ := c.GetInt64("patient_id")
  13114. id_card_no := c.GetString("id_card_no")
  13115. insutype := c.GetString("insutype")
  13116. med_type := c.GetString("med_type")
  13117. admin_user_id, _ := c.GetInt64("admin_user_id")
  13118. adminUser := c.GetAdminUserInfo()
  13119. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13121. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13122. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13123. if miConfig.MdtrtareaAdmvs == "421300" {
  13124. var res ResultTwo
  13125. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13126. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13127. "&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)
  13128. resp, requestErr := http.Get(api)
  13129. if requestErr != nil {
  13130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13131. return
  13132. }
  13133. body, ioErr := ioutil.ReadAll(resp.Body)
  13134. if ioErr != nil {
  13135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13137. return
  13138. }
  13139. var respJSON map[string]interface{}
  13140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13143. return
  13144. }
  13145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13146. result, _ := json.Marshal(respJSON)
  13147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13148. utils.ErrorLog("解析失败:%v", err)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. if res.Infcode == 0 {
  13153. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  13154. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  13156. resp, requestErr := http.Get(api)
  13157. if requestErr != nil {
  13158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13159. return
  13160. }
  13161. body, ioErr := ioutil.ReadAll(resp.Body)
  13162. if ioErr != nil {
  13163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. return
  13166. }
  13167. var respJSON map[string]interface{}
  13168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13171. return
  13172. }
  13173. var res Result2001
  13174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13175. result2, _ := json.Marshal(respJSON)
  13176. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13177. utils.ErrorLog("解析失败:%v", err)
  13178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13179. return
  13180. }
  13181. if res.Infcode == 0 {
  13182. c.ServeSuccessJSON(map[string]interface{}{
  13183. "msg": res.Output.Trtinfo,
  13184. })
  13185. }
  13186. } else {
  13187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13188. return
  13189. }
  13190. } else {
  13191. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13192. var dat map[string]interface{}
  13193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13194. fmt.Println(dat)
  13195. } else {
  13196. fmt.Println(err)
  13197. }
  13198. userJSONBytes, _ := json.Marshal(dat)
  13199. var res ResultTwo
  13200. var res10265 ResultTwo10265
  13201. if miConfig.Code == "H15049901371" {
  13202. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13203. utils.ErrorLog("解析失败:%v", err)
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. res.ErrMsg = res10265.ErrMsg
  13208. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13209. res.Infcode = infocode
  13210. res.Output = res10265.Output
  13211. res.InfRefmsgid = res10265.InfRefmsgid
  13212. } else {
  13213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13214. utils.ErrorLog("解析失败:%v", err)
  13215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13216. return
  13217. }
  13218. }
  13219. var user_name string
  13220. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  13221. if role.ID == 0 {
  13222. user_name = "xxx"
  13223. } else {
  13224. user_name = role.UserName
  13225. }
  13226. baseParams := models.BaseParams{
  13227. SecretKey: miConfig.SecretKey,
  13228. FixmedinsCode: miConfig.Code,
  13229. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13230. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13231. OrgName: miConfig.OrgName,
  13232. Doctor: user_name,
  13233. }
  13234. if config.IsOpen == 1 {
  13235. if miConfig.Code == "H15049901371" {
  13236. if med_type == "14" {
  13237. if insutype == "390" {
  13238. med_type = "9933"
  13239. } else if insutype == "310" {
  13240. med_type = "990502"
  13241. }
  13242. } else if med_type == "11" {
  13243. med_type = "11"
  13244. }
  13245. }
  13246. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  13247. var dat map[string]interface{}
  13248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13249. fmt.Println(dat)
  13250. } else {
  13251. fmt.Println(err)
  13252. }
  13253. var res Result2001
  13254. var res10265 Result2001Org10265
  13255. if miConfig.Code == "H15049901371" {
  13256. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13257. utils.ErrorLog("解析失败:%v", err)
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. res.ErrMsg = res10265.ErrMsg
  13262. res.Output = res10265.Output
  13263. res.InfRefmsgid = res10265.InfRefmsgid
  13264. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13265. res.Infcode = infocode
  13266. } else {
  13267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13268. utils.ErrorLog("解析失败:%v", err)
  13269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13270. return
  13271. }
  13272. }
  13273. if res.Infcode == 0 {
  13274. c.ServeSuccessJSON(map[string]interface{}{
  13275. "msg": res.Output.Trtinfo,
  13276. })
  13277. }
  13278. }
  13279. }
  13280. }
  13281. //func (c *HisApiController) PutRecord() {
  13282. // id, _ := c.GetInt64("id")
  13283. // record_time := c.GetString("record_time")
  13284. // timeLayout := "2006-01-02"
  13285. // loc, _ := time.LoadLocation("Local")
  13286. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13287. // if err != nil {
  13288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13289. // return
  13290. // }
  13291. // recordDateTime := theTime.Unix()
  13292. //
  13293. // adminInfo := c.GetAdminUserInfo()
  13294. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  13295. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13296. //
  13297. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13298. //
  13299. // fmt.Println(miConfig.SecretKey)
  13300. //
  13301. // if patient == nil {
  13302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13303. // return
  13304. // }
  13305. // if len(patient.IdCardNo) == 0 {
  13306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  13307. // return
  13308. // }
  13309. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  13310. // if config.IsOpen == 1 {
  13311. // 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
  13312. // resp, requestErr := http.Get(api)
  13313. // if requestErr != nil {
  13314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13315. // return
  13316. // }
  13317. // defer resp.Body.Close()
  13318. // body, ioErr := ioutil.ReadAll(resp.Body)
  13319. // if ioErr != nil {
  13320. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13322. // return
  13323. // }
  13324. // var respJSON map[string]interface{}
  13325. //
  13326. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13327. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13329. // return
  13330. // }
  13331. //
  13332. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13333. // userJSONBytes, _ := json.Marshal(userJSON)
  13334. // var res ResultTwo
  13335. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13336. // utils.ErrorLog("解析失败:%v", err)
  13337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13338. // return
  13339. // }
  13340. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13341. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13342. // infoStr := string(Iinfos)
  13343. // idetinfoStr := string(Idetinfos)
  13344. //
  13345. // if res.Infcode == 0 {
  13346. // his := models.VMHisPatient{
  13347. // Status: 1,
  13348. // Ctime: time.Now().Unix(),
  13349. // Mtime: time.Now().Unix(),
  13350. // PsnNo: res.Output.Baseinfo.PsnNo,
  13351. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  13352. // Certno: res.Output.Baseinfo.Certno,
  13353. // PsnName: res.Output.Baseinfo.PsnName,
  13354. // Gend: res.Output.Baseinfo.Gend,
  13355. // Naty: res.Output.Baseinfo.Naty,
  13356. // Brdy: res.Output.Baseinfo.Brdy,
  13357. // Age: res.Output.Baseinfo.Age,
  13358. // Iinfo: infoStr,
  13359. // Idetinfo: idetinfoStr,
  13360. // PatientId: patient.ID,
  13361. // RecordDate: theTime.Unix(),
  13362. // UserOrgId: adminInfo.CurrentOrgId,
  13363. // AdminUserId: adminInfo.AdminUser.Id,
  13364. // IsReturn: 1,
  13365. // }
  13366. //
  13367. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  13368. // //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")
  13369. // //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")
  13370. //
  13371. // //var dat map[string]interface{}
  13372. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13373. // // fmt.Println(dat)
  13374. // //} else {
  13375. // // fmt.Println(err)
  13376. // //}
  13377. //
  13378. // var dat2 map[string]interface{}
  13379. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13380. // fmt.Println(dat2)
  13381. // } else {
  13382. // fmt.Println(err)
  13383. // }
  13384. //
  13385. // } else {
  13386. // adminUser := c.GetAdminUserInfo()
  13387. // errlog := &models.HisOrderError{
  13388. // UserOrgId: adminUser.CurrentOrgId,
  13389. // Ctime: time.Now().Unix(),
  13390. // Mtime: time.Now().Unix(),
  13391. // ErrMsg: res.ErrMsg,
  13392. // Status: 1,
  13393. // PatientId: id,
  13394. // RecordTime: recordDateTime,
  13395. // Stage: 1,
  13396. // }
  13397. // service.CreateErrMsgLog(errlog)
  13398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  13399. // return
  13400. // }
  13401. // }
  13402. //
  13403. //}
  13404. //func (c *HisApiController) GetUploadDiag() {
  13405. // id, _ := c.GetInt64("id")
  13406. // record_time := c.GetString("record_time")
  13407. //
  13408. // diagnosis_id, _ := c.GetInt64("diagnosis")
  13409. // sick_type, _ := c.GetInt64("sick_type")
  13410. // reg_type, _ := c.GetInt64("reg_type")
  13411. //
  13412. // timeLayout := "2006-01-02"
  13413. // loc, _ := time.LoadLocation("Local")
  13414. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13415. // if err != nil {
  13416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13417. // return
  13418. // }
  13419. //
  13420. // var patientPrescription models.HisPrescriptionInfo
  13421. // recordDateTime := theTime.Unix()
  13422. // adminInfo := c.GetAdminUserInfo()
  13423. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13424. //
  13425. // if patientPrescription.ID == 0 {
  13426. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13427. // }
  13428. //
  13429. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13430. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13431. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13432. // sickConfig, _ := service.FindSickById(sick_type)
  13433. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13434. //
  13435. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  13436. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  13437. // "&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 +
  13438. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  13439. // resp2, requestErr2 := http.Get(api2)
  13440. // if requestErr2 != nil {
  13441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13442. // return
  13443. // }
  13444. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13445. // if ioErr2 != nil {
  13446. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13448. // return
  13449. // }
  13450. // var respJSON2 map[string]interface{}
  13451. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13452. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13454. // return
  13455. // }
  13456. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13457. // userJSONBytes2, _ := json.Marshal(respJSON2)
  13458. //
  13459. // var res2 ResultSix
  13460. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13461. // utils.ErrorLog("解析失败:%v", err)
  13462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13463. // return
  13464. // }
  13465. // if res2.Infcode != 0 {
  13466. // adminUser := c.GetAdminUserInfo()
  13467. // errlog := &models.HisOrderError{
  13468. // UserOrgId: adminUser.CurrentOrgId,
  13469. // Ctime: time.Now().Unix(),
  13470. // Mtime: time.Now().Unix(),
  13471. // ErrMsg: res2.ErrMsg,
  13472. // Status: 1,
  13473. // PatientId: id,
  13474. // RecordTime: recordDateTime,
  13475. // Stage: 3,
  13476. // }
  13477. // service.CreateErrMsgLog(errlog)
  13478. //
  13479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  13480. // return
  13481. // }
  13482. //
  13483. // c.ServeSuccessJSON(map[string]interface{}{
  13484. // "msg": "上传成功",
  13485. // })
  13486. //
  13487. //}
  13488. type QueryResult struct {
  13489. ID int64
  13490. Name string
  13491. Code string
  13492. List_type_code string
  13493. }
  13494. func (c *HisApiController) GetCheckCode() {
  13495. ids_str := c.GetString("ids")
  13496. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13497. ids_arr := strings.Split(ids_str, ",")
  13498. var queryResult []QueryResult
  13499. ids := make([]int64, 0)
  13500. for _, item := range ids_arr {
  13501. id, _ := strconv.ParseInt(item, 10, 64)
  13502. ids = append(ids, id)
  13503. }
  13504. if record_type == 1 {
  13505. drugs, _ := service.GetBatchDrugList(ids)
  13506. for _, item := range drugs {
  13507. result := QueryResult{
  13508. ID: item.ID,
  13509. Name: item.DrugName,
  13510. Code: item.MedicalInsuranceNumber,
  13511. List_type_code: "101",
  13512. }
  13513. queryResult = append(queryResult, result)
  13514. }
  13515. } else if record_type == 2 {
  13516. goods, _ := service.GetBatchGoodInformationList(ids)
  13517. for _, item := range goods {
  13518. result := QueryResult{
  13519. ID: item.ID,
  13520. Name: item.GoodName,
  13521. Code: item.MedicalInsuranceNumber,
  13522. List_type_code: "301",
  13523. }
  13524. queryResult = append(queryResult, result)
  13525. }
  13526. } else if record_type == 3 {
  13527. projects, _ := service.GetBathchMyPorjecgList(ids)
  13528. for _, item := range projects {
  13529. result := QueryResult{
  13530. ID: item.ID,
  13531. Name: item.ProjectName,
  13532. Code: item.MedicalCode,
  13533. List_type_code: "201",
  13534. }
  13535. queryResult = append(queryResult, result)
  13536. }
  13537. }
  13538. admin_user_id, _ := c.GetInt64("admin_user_id")
  13539. adminUser := c.GetAdminUserInfo()
  13540. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13541. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13542. var user_name string
  13543. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13544. if role.ID == 0 {
  13545. user_name = "xxx"
  13546. } else {
  13547. user_name = role.UserName
  13548. }
  13549. baseParams := &models.BaseParams{
  13550. SecretKey: miConfig.SecretKey,
  13551. FixmedinsCode: miConfig.Code,
  13552. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13553. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13554. OrgName: miConfig.OrgName,
  13555. Doctor: user_name,
  13556. }
  13557. if config.IsOpen == 1 {
  13558. for _, item := range queryResult {
  13559. var result string
  13560. if record_type == 1 {
  13561. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13562. } else if record_type == 2 {
  13563. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13564. } else if record_type == 3 {
  13565. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13566. }
  13567. var dat map[string]interface{}
  13568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13569. fmt.Println(dat)
  13570. } else {
  13571. fmt.Println(err)
  13572. }
  13573. userJSONBytes, _ := json.Marshal(dat)
  13574. var res ResultSix
  13575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13576. utils.ErrorLog("解析失败:%v", err)
  13577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13578. return
  13579. }
  13580. if res.Infcode == 0 {
  13581. if record_type == 1 {
  13582. service.UpdateBaseDrugById(item.ID)
  13583. } else if record_type == 2 {
  13584. service.UpdateGoodInformaitonByDetail(item.ID)
  13585. } else if record_type == 3 {
  13586. service.UpdateProjectById(item.ID)
  13587. }
  13588. c.ServeSuccessJSON(map[string]interface{}{
  13589. "failed_code": 0,
  13590. "msg": "目录对照成功",
  13591. })
  13592. } else {
  13593. c.ServeSuccessJSON(map[string]interface{}{
  13594. "failed_code": -10,
  13595. "msg": res.ErrMsg,
  13596. })
  13597. }
  13598. }
  13599. }
  13600. }
  13601. func (c *HisApiController) UnCheckCode() {
  13602. ids_str := c.GetString("ids")
  13603. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13604. admin_user_id, _ := c.GetInt64("admin_user_id")
  13605. ids_arr := strings.Split(ids_str, ",")
  13606. var queryResult []QueryResult
  13607. ids := make([]int64, 0)
  13608. for _, item := range ids_arr {
  13609. id, _ := strconv.ParseInt(item, 10, 64)
  13610. ids = append(ids, id)
  13611. }
  13612. if record_type == 1 {
  13613. drugs, _ := service.GetBatchDrugList(ids)
  13614. for _, item := range drugs {
  13615. result := QueryResult{
  13616. ID: item.ID,
  13617. Name: item.DrugName,
  13618. Code: item.MedicalInsuranceNumber,
  13619. List_type_code: "101",
  13620. }
  13621. queryResult = append(queryResult, result)
  13622. }
  13623. } else if record_type == 2 {
  13624. goods, _ := service.GetBatchGoodInformationList(ids)
  13625. for _, item := range goods {
  13626. result := QueryResult{
  13627. ID: item.ID,
  13628. Name: item.GoodName,
  13629. Code: item.MedicalInsuranceNumber,
  13630. List_type_code: "301",
  13631. }
  13632. queryResult = append(queryResult, result)
  13633. }
  13634. } else if record_type == 3 {
  13635. projects, _ := service.GetBathchMyPorjecgList(ids)
  13636. for _, item := range projects {
  13637. result := QueryResult{
  13638. ID: item.ID,
  13639. Name: item.ProjectName,
  13640. Code: item.MedicalCode,
  13641. List_type_code: "201",
  13642. }
  13643. queryResult = append(queryResult, result)
  13644. }
  13645. }
  13646. adminUser := c.GetAdminUserInfo()
  13647. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13648. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13649. var user_name string
  13650. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13651. if role.ID == 0 {
  13652. user_name = "xxx"
  13653. } else {
  13654. user_name = role.UserName
  13655. }
  13656. baseParams := &models.BaseParams{
  13657. SecretKey: miConfig.SecretKey,
  13658. FixmedinsCode: miConfig.Code,
  13659. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13660. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13661. OrgName: miConfig.OrgName,
  13662. Doctor: user_name,
  13663. }
  13664. if config.IsOpen == 1 {
  13665. for _, item := range queryResult {
  13666. var result string
  13667. if record_type == 1 {
  13668. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13669. } else if record_type == 2 {
  13670. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13671. } else if record_type == 3 {
  13672. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13673. }
  13674. var dat2 map[string]interface{}
  13675. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  13676. fmt.Println(dat2)
  13677. } else {
  13678. fmt.Println(err)
  13679. }
  13680. userJSONBytes, _ := json.Marshal(dat2)
  13681. var res ResultSix
  13682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13683. utils.ErrorLog("解析失败:%v", err)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. if res.Infcode == 0 {
  13688. if record_type == 1 {
  13689. service.UpdateDrugByIdDetail(item.ID)
  13690. } else if record_type == 2 {
  13691. service.UpdateGoodInfoById(item.ID)
  13692. } else if record_type == 3 {
  13693. service.UpdateMyProjectById(item.ID)
  13694. }
  13695. c.ServeSuccessJSON(map[string]interface{}{
  13696. "failed_code": 0,
  13697. "msg": "撤销目录对照成功",
  13698. })
  13699. } else {
  13700. c.ServeSuccessJSON(map[string]interface{}{
  13701. "failed_code": -10,
  13702. "msg": res.ErrMsg,
  13703. })
  13704. }
  13705. }
  13706. }
  13707. }
  13708. func (c *HisApiController) GetPatientInfo() {
  13709. id_card_no := c.GetString("id_card_no")
  13710. admin_user_id, _ := c.GetInt64("admin_user_id")
  13711. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13712. if patient.ID == 0 {
  13713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13714. return
  13715. }
  13716. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13717. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13718. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  13719. if config.IsOpen == 1 {
  13720. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13721. var dat map[string]interface{}
  13722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13723. fmt.Println(dat)
  13724. } else {
  13725. fmt.Println(err)
  13726. }
  13727. userJSONBytes, _ := json.Marshal(dat)
  13728. var res ResultTwo
  13729. var res10265 ResultTwo10265
  13730. if miConfig.Code == "H15049901371" {
  13731. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13732. utils.ErrorLog("解析失败:%v", err)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. res.ErrMsg = res10265.ErrMsg
  13737. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13738. res.Infcode = infocode
  13739. res.Output = res10265.Output
  13740. res.InfRefmsgid = res10265.InfRefmsgid
  13741. } else {
  13742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13743. utils.ErrorLog("解析失败:%v", err)
  13744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13745. return
  13746. }
  13747. }
  13748. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13749. // utils.ErrorLog("解析失败:%v", err)
  13750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13751. // return
  13752. //}
  13753. if res.Infcode != 0 {
  13754. c.ServeSuccessJSON(map[string]interface{}{
  13755. "failed_code": -10,
  13756. "msg": res.ErrMsg,
  13757. })
  13758. } else {
  13759. c.ServeSuccessJSON(map[string]interface{}{
  13760. "failed_code": 0,
  13761. "info": res,
  13762. })
  13763. }
  13764. }
  13765. }
  13766. func (c *HisApiController) PsnPutOnRecord() {
  13767. record_type, _ := c.GetInt64("type")
  13768. patient_id, _ := c.GetInt64("patient_id")
  13769. admin_user_id, _ := c.GetInt64("admin_user_id")
  13770. start_time := c.GetString("start_time")
  13771. end_time := c.GetString("end_time")
  13772. adminUser := c.GetAdminUserInfo()
  13773. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13774. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13775. var patients []*models.Patients
  13776. if record_type == 1 { //全部备案
  13777. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  13778. patients = append(patients, patient...)
  13779. } else { //单个备案
  13780. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13781. patients = append(patients, patient)
  13782. }
  13783. var user_name string
  13784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13785. if role.ID == 0 {
  13786. user_name = "xxx"
  13787. } else {
  13788. user_name = role.UserName
  13789. }
  13790. if config.IsOpen == 1 {
  13791. for _, item := range patients {
  13792. 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
  13793. resp, requestErr := http.Get(api)
  13794. if requestErr != nil {
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13796. return
  13797. }
  13798. defer resp.Body.Close()
  13799. body, ioErr := ioutil.ReadAll(resp.Body)
  13800. if ioErr != nil {
  13801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13803. return
  13804. }
  13805. var respJSON map[string]interface{}
  13806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13809. return
  13810. }
  13811. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13812. userJSONBytes, _ := json.Marshal(userJSON)
  13813. var res ResultTwo
  13814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13815. utils.ErrorLog("解析失败:%v", err)
  13816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13817. return
  13818. }
  13819. if res.Infcode == 0 {
  13820. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13821. var dat map[string]interface{}
  13822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13823. fmt.Println(dat)
  13824. } else {
  13825. fmt.Println(err)
  13826. }
  13827. userJSONBytes, _ := json.Marshal(dat)
  13828. var res2 ResultThirteen
  13829. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13830. utils.ErrorLog("解析失败:%v", err)
  13831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13832. return
  13833. }
  13834. if res2.Infcode == 0 {
  13835. psnResult := &models.GdybPsnRecord{
  13836. UserOrgId: adminUser.CurrentOrgId,
  13837. PatientId: item.ID,
  13838. PsnNo: res.Output.Baseinfo.PsnNo,
  13839. Ctime: time.Now().Unix(),
  13840. Mtime: time.Now().Unix(),
  13841. Status: 1,
  13842. IsCancel: 1,
  13843. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13844. }
  13845. service.CreatePsnRecord(psnResult)
  13846. } else {
  13847. c.ServeSuccessJSON(map[string]interface{}{
  13848. "failed_code": -10,
  13849. "msg": res2.ErrMsg,
  13850. })
  13851. return
  13852. }
  13853. }
  13854. }
  13855. }
  13856. }
  13857. func (c *HisApiController) PsnUnPutOnRecord() {
  13858. id, _ := c.GetInt64("id")
  13859. //record_type, _ := c.GetInt64("type")
  13860. admin_user_id, _ := c.GetInt64("admin_user_id")
  13861. adminUser := c.GetAdminUserInfo()
  13862. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13863. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13864. var user_name string
  13865. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13866. if role.ID == 0 {
  13867. user_name = "xxx"
  13868. } else {
  13869. user_name = role.UserName
  13870. }
  13871. psn_record, _ := service.GetPsnRecordById(id)
  13872. if psn_record.ID == 0 {
  13873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13874. return
  13875. }
  13876. if config.IsOpen == 1 {
  13877. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13878. var dat map[string]interface{}
  13879. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13880. fmt.Println(dat)
  13881. } else {
  13882. fmt.Println(err)
  13883. }
  13884. userJSONBytes, _ := json.Marshal(dat)
  13885. var res ResultFourteen
  13886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13887. utils.ErrorLog("解析失败:%v", err)
  13888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13889. return
  13890. }
  13891. if res.Infcode == 0 {
  13892. psn_record.IsCancel = 2
  13893. service.CreatePsnRecord(&psn_record)
  13894. } else {
  13895. c.ServeSuccessJSON(map[string]interface{}{
  13896. "failed_code": -10,
  13897. "msg": res.ErrMsg,
  13898. })
  13899. return
  13900. }
  13901. }
  13902. }
  13903. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13904. patient_id, _ := c.GetInt64("patient_id")
  13905. insutype_two := c.GetString("insutype")
  13906. psn_no := c.GetString("psn_no")
  13907. doctor_id, _ := c.GetInt64("doctor_id")
  13908. sick_id, _ := c.GetInt64("sick_id")
  13909. department_id, _ := c.GetInt64("department_id")
  13910. start_time := c.GetString("start_time")
  13911. end_time := c.GetString("end_time")
  13912. check_time := c.GetString("check_time")
  13913. hospital_code := c.GetString("hospital_code")
  13914. hospital_name := c.GetString("hospital_name")
  13915. adminUser := c.GetAdminUserInfo()
  13916. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13919. sick, _ := service.FindSickById(sick_id)
  13920. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13921. if len(hospital_code) == 0 {
  13922. hospital_code = miConfig.Code
  13923. }
  13924. if len(hospital_name) == 0 {
  13925. hospital_name = miConfig.OrgName
  13926. }
  13927. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13928. var res ResultTwo
  13929. var res10265 ResultTwo10265
  13930. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13931. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13932. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13933. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13934. "&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
  13935. resp, requestErr := http.Get(api)
  13936. if requestErr != nil {
  13937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13938. return
  13939. }
  13940. body, ioErr := ioutil.ReadAll(resp.Body)
  13941. if ioErr != nil {
  13942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13944. return
  13945. }
  13946. var respJSON map[string]interface{}
  13947. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13950. return
  13951. }
  13952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13953. result, _ := json.Marshal(respJSON)
  13954. fmt.Println("log")
  13955. fmt.Println(string(result))
  13956. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13957. utils.ErrorLog("解析失败:%v", err)
  13958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13959. return
  13960. }
  13961. res.ErrMsg = res10265.ErrMsg
  13962. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13963. res.Infcode = infocode
  13964. res.Output = res10265.Output
  13965. res.InfRefmsgid = res10265.InfRefmsgid
  13966. } else {
  13967. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13968. if miConfig.Code == "H15049901371" {
  13969. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13970. utils.ErrorLog("解析失败:%v", err)
  13971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13972. return
  13973. }
  13974. res.ErrMsg = res10265.ErrMsg
  13975. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13976. res.Infcode = infocode
  13977. res.Output = res10265.Output
  13978. res.InfRefmsgid = res10265.InfRefmsgid
  13979. } else {
  13980. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13981. utils.ErrorLog("解析失败:%v", err)
  13982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13983. return
  13984. }
  13985. }
  13986. }
  13987. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13988. infoStr := string(Iinfos)
  13989. var rf []*ResultFive
  13990. json.Unmarshal([]byte(infoStr), &rf)
  13991. var insuplc_admdvs string
  13992. var insutype string
  13993. var is390 int = 0
  13994. var is310 int = 0
  13995. var insutypes []*ResultFive
  13996. for _, item := range rf {
  13997. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13998. insutypes = append(insutypes, item)
  13999. }
  14000. }
  14001. if len(insutypes) == 1 {
  14002. insutype = insutypes[0].Insutype
  14003. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14004. } else {
  14005. for _, i := range insutypes {
  14006. if i.Insutype == "390" {
  14007. is390 = 1
  14008. }
  14009. if i.Insutype == "310" {
  14010. is310 = 1
  14011. }
  14012. }
  14013. }
  14014. if is390 == 1 {
  14015. insutype = "390"
  14016. }
  14017. if is310 == 1 {
  14018. insutype = "310"
  14019. }
  14020. if len(insutypes) == 2 {
  14021. insutype = insutype_two
  14022. }
  14023. if len(insutypes) == 0 {
  14024. insutype = "310"
  14025. }
  14026. insutype = insutype_two
  14027. fmt.Println(insutype)
  14028. for _, item := range rf {
  14029. fmt.Println(item.Insutype)
  14030. fmt.Println(insutype)
  14031. if item.Insutype == insutype {
  14032. fmt.Println(item.Insutype)
  14033. fmt.Println(insutype)
  14034. insuplc_admdvs = item.InsuplcAdmdvs
  14035. }
  14036. }
  14037. fmt.Println(insuplc_admdvs)
  14038. var res2 ResultThirteen
  14039. var res10265_2 ResultThirteen10265
  14040. if config.IsOpen == 1 {
  14041. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14042. } else {
  14043. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  14044. var dat map[string]interface{}
  14045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14046. fmt.Println(dat)
  14047. } else {
  14048. fmt.Println(err)
  14049. }
  14050. userJSONBytes, _ := json.Marshal(dat)
  14051. if miConfig.Code == "H15049901371" {
  14052. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  14053. utils.ErrorLog("解析失败:%v", err)
  14054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14055. return
  14056. }
  14057. res2.ErrMsg = res10265_2.ErrMsg
  14058. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  14059. res2.Infcode = infocode
  14060. res2.Output = res10265_2.Output
  14061. res2.InfRefmsgid = res10265_2.InfRefmsgid
  14062. } else {
  14063. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14064. utils.ErrorLog("解析失败:%v", err)
  14065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14066. return
  14067. }
  14068. }
  14069. }
  14070. if res2.Infcode == 0 {
  14071. psnResult := &models.GdybPsnNcdsRecord{
  14072. UserOrgId: adminUser.CurrentOrgId,
  14073. PatientId: patient.ID,
  14074. PsnNo: psn_no,
  14075. DoctorId: doctor.AdminUserId,
  14076. DepartmentId: department_id,
  14077. SickType: sick_id,
  14078. Insutype: insutype,
  14079. Ctime: time.Now().Unix(),
  14080. Mtime: time.Now().Unix(),
  14081. Status: 1,
  14082. IsCancel: 1,
  14083. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14084. }
  14085. service.CreatePsnNCDSRecord(psnResult)
  14086. c.ServeSuccessJSON(map[string]interface{}{
  14087. "failed_code": 0,
  14088. "msg": "备案成功",
  14089. "result": psnResult,
  14090. })
  14091. } else {
  14092. c.ServeSuccessJSON(map[string]interface{}{
  14093. "failed_code": -10,
  14094. "msg": res2.ErrMsg,
  14095. })
  14096. return
  14097. }
  14098. }
  14099. }
  14100. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  14101. id, _ := c.GetInt64("id")
  14102. admin_user_id, _ := c.GetInt64("admin_user_id")
  14103. adminUser := c.GetAdminUserInfo()
  14104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14105. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14106. //config, _ := service.Ge(adminUser.CurrentOrgId)
  14107. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  14108. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14109. //var user_name string
  14110. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14111. //if role.ID == 0 {
  14112. // user_name = "xxx"
  14113. //} else {
  14114. // user_name = role.UserName
  14115. //}
  14116. psn_record, _ := service.GetPsnNCDSRecordById(id)
  14117. if psn_record.ID == 0 {
  14118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14119. return
  14120. }
  14121. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14122. var res ResultTwo
  14123. var res10265 ResultTwo10265
  14124. if miConfig.Code == "H15049901371" {
  14125. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14126. utils.ErrorLog("解析失败:%v", err)
  14127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14128. return
  14129. }
  14130. res.ErrMsg = res10265.ErrMsg
  14131. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14132. res.Infcode = infocode
  14133. res.Output = res10265.Output
  14134. res.InfRefmsgid = res10265.InfRefmsgid
  14135. } else {
  14136. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14137. utils.ErrorLog("解析失败:%v", err)
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14139. return
  14140. }
  14141. }
  14142. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14143. infoStr := string(Iinfos)
  14144. var rf []*ResultFive
  14145. json.Unmarshal([]byte(infoStr), &rf)
  14146. var insuplc_admdvs string
  14147. var insutype string
  14148. var is390 int = 0
  14149. var is310 int = 0
  14150. var insutypes []*ResultFive
  14151. for _, item := range rf {
  14152. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14153. insutypes = append(insutypes, item)
  14154. }
  14155. }
  14156. if len(insutypes) == 1 {
  14157. insutype = insutypes[0].Insutype
  14158. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14159. } else {
  14160. for _, i := range insutypes {
  14161. if i.Insutype == "390" {
  14162. is390 = 1
  14163. }
  14164. if i.Insutype == "310" {
  14165. is310 = 1
  14166. }
  14167. }
  14168. }
  14169. if is390 == 1 {
  14170. insutype = "390"
  14171. }
  14172. if is310 == 1 {
  14173. insutype = "310"
  14174. }
  14175. if len(insutypes) == 0 {
  14176. insutype = "310"
  14177. }
  14178. insutype = psn_record.Insutype
  14179. for _, item := range rf {
  14180. if item.Insutype == insutype {
  14181. insuplc_admdvs = item.InsuplcAdmdvs
  14182. }
  14183. }
  14184. if config.IsOpen == 1 {
  14185. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14186. var dat map[string]interface{}
  14187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14188. fmt.Println(dat)
  14189. } else {
  14190. fmt.Println(err)
  14191. }
  14192. userJSONBytes, _ := json.Marshal(dat)
  14193. var res ResultFourteen
  14194. var res10265 ResultFourteen10265
  14195. if miConfig.Code == "H15049901371" {
  14196. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14197. utils.ErrorLog("解析失败:%v", err)
  14198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14199. return
  14200. }
  14201. res.ErrMsg = res10265.ErrMsg
  14202. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14203. res.Infcode = infocode
  14204. res.Output = res10265.Output
  14205. res.InfRefmsgid = res10265.InfRefmsgid
  14206. } else {
  14207. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14208. utils.ErrorLog("解析失败:%v", err)
  14209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14210. return
  14211. }
  14212. }
  14213. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14214. // utils.ErrorLog("解析失败:%v", err)
  14215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14216. // return
  14217. //}
  14218. if res.Infcode == 0 {
  14219. psn_record.IsCancel = 2
  14220. service.CreatePsnNCDSRecord(&psn_record)
  14221. c.ServeSuccessJSON(map[string]interface{}{
  14222. "failed_code": 0,
  14223. "msg": "撤销备案成功",
  14224. })
  14225. } else {
  14226. c.ServeSuccessJSON(map[string]interface{}{
  14227. "failed_code": -10,
  14228. "msg": res.ErrMsg,
  14229. })
  14230. return
  14231. }
  14232. }
  14233. }
  14234. func (c *HisApiController) TestTest() {
  14235. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  14236. fmt.Println(patient.Iinfo)
  14237. }
  14238. type CustomData struct {
  14239. MsgId string
  14240. PsnNo string
  14241. Info string
  14242. }
  14243. func (c *HisApiController) ReversalData() {
  14244. var customData []*CustomData
  14245. custom := &CustomData{
  14246. MsgId: "H44022900158202103301714472004",
  14247. PsnNo: "44020000001101329945",
  14248. Info: "2207",
  14249. }
  14250. customData = append(customData, custom)
  14251. custom1 := &CustomData{
  14252. MsgId: "H4402290015820210330172057803",
  14253. PsnNo: "44020000001101161813",
  14254. Info: "2207",
  14255. }
  14256. customData = append(customData, custom1)
  14257. custom2 := &CustomData{
  14258. MsgId: "H44022900158202103301705198813",
  14259. PsnNo: "44190000133097375417",
  14260. Info: "2207",
  14261. }
  14262. customData = append(customData, custom2)
  14263. custom3 := &CustomData{
  14264. MsgId: "H44022900158202103301715524756",
  14265. PsnNo: "44020000001100187221",
  14266. Info: "2207",
  14267. }
  14268. customData = append(customData, custom3)
  14269. custom4 := &CustomData{
  14270. MsgId: "H44022900158202103301730376224",
  14271. PsnNo: "44020000001101959155",
  14272. Info: "2207",
  14273. }
  14274. customData = append(customData, custom4)
  14275. custom5 := &CustomData{
  14276. MsgId: "H44022900158202103301748008725",
  14277. PsnNo: "44020000001104246641",
  14278. Info: "2207",
  14279. }
  14280. customData = append(customData, custom5)
  14281. custom6 := &CustomData{
  14282. MsgId: "H44022900158202103301718096755",
  14283. PsnNo: "44020000001102211860",
  14284. Info: "2207",
  14285. }
  14286. customData = append(customData, custom6)
  14287. custom7 := &CustomData{
  14288. MsgId: "H44022900158202103301736551640",
  14289. PsnNo: "44020000001102687718",
  14290. Info: "2207",
  14291. }
  14292. customData = append(customData, custom7)
  14293. custom8 := &CustomData{
  14294. MsgId: "H44022900158202103301743097676",
  14295. PsnNo: "44020000001102127785",
  14296. Info: "2207",
  14297. }
  14298. customData = append(customData, custom8)
  14299. custom9 := &CustomData{
  14300. MsgId: "H44022900158202103301712304203",
  14301. PsnNo: "44020000001101518097",
  14302. Info: "2207",
  14303. }
  14304. customData = append(customData, custom9)
  14305. custom10 := &CustomData{
  14306. MsgId: "H44022900158202103301738448785",
  14307. PsnNo: "44020000001100500813",
  14308. Info: "2207",
  14309. }
  14310. customData = append(customData, custom10)
  14311. custom11 := &CustomData{
  14312. MsgId: "H44022900158202103301732455843",
  14313. PsnNo: "44020000001102690557",
  14314. Info: "2207",
  14315. }
  14316. customData = append(customData, custom11)
  14317. custom12 := &CustomData{
  14318. MsgId: "H44022900158202103301745421708",
  14319. PsnNo: "44020000001102211928",
  14320. Info: "2207",
  14321. }
  14322. customData = append(customData, custom12)
  14323. custom1212 := &CustomData{
  14324. MsgId: "H440229001582021033017351627",
  14325. PsnNo: "44020000001102481733",
  14326. Info: "2207",
  14327. }
  14328. customData = append(customData, custom1212)
  14329. custom13 := &CustomData{
  14330. MsgId: "H44022900158202103301740327951",
  14331. PsnNo: "44020000001103174866",
  14332. Info: "2207",
  14333. }
  14334. customData = append(customData, custom13)
  14335. custom14 := &CustomData{
  14336. MsgId: "H4402290015820210330174922668",
  14337. PsnNo: "44020000001102927272",
  14338. Info: "2207",
  14339. }
  14340. customData = append(customData, custom14)
  14341. custom15 := &CustomData{
  14342. MsgId: "H44022900158202103301752362273",
  14343. PsnNo: "44020000001102942890",
  14344. Info: "2207",
  14345. }
  14346. customData = append(customData, custom15)
  14347. custom16 := &CustomData{
  14348. MsgId: "H44022900158202103301751082917",
  14349. PsnNo: "44020000001101662162",
  14350. Info: "2207",
  14351. }
  14352. customData = append(customData, custom16)
  14353. custom17 := &CustomData{
  14354. MsgId: "H44022900158202103301754147728",
  14355. PsnNo: "44020000000229014511",
  14356. Info: "2207",
  14357. }
  14358. customData = append(customData, custom17)
  14359. adminUser := c.GetAdminUserInfo()
  14360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14361. for _, item := range customData {
  14362. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14363. fmt.Println(result)
  14364. }
  14365. }
  14366. func (c *HisApiController) GetAllopatry() {
  14367. year := c.GetString("year")
  14368. month := c.GetString("month")
  14369. admin_user_id, _ := c.GetInt64("admin_user_id")
  14370. adminUser := c.GetAdminUserInfo()
  14371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14372. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14373. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14374. var dat map[string]interface{}
  14375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14376. fmt.Println(dat)
  14377. } else {
  14378. fmt.Println(err)
  14379. }
  14380. userJSONBytes, _ := json.Marshal(dat)
  14381. var res models.Result9001
  14382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14383. utils.ErrorLog("解析失败:%v", err)
  14384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14385. return
  14386. }
  14387. fmt.Println(res.Output.Signinoutb)
  14388. fmt.Println(res.Output.Signinoutb.SignNo)
  14389. fmt.Println(string(userJSONBytes))
  14390. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14391. var dat2 map[string]interface{}
  14392. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14393. fmt.Println(dat)
  14394. } else {
  14395. fmt.Println(err)
  14396. }
  14397. userJSONBytes2, _ := json.Marshal(dat2)
  14398. var res2 models.Result3260
  14399. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14400. utils.ErrorLog("解析失败:%v", err)
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14402. return
  14403. }
  14404. if res2.Infcode == 0 {
  14405. result3, _, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14406. var dat2 map[string]interface{}
  14407. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  14408. fmt.Println(dat)
  14409. } else {
  14410. fmt.Println(err)
  14411. }
  14412. c.ServeSuccessJSON(map[string]interface{}{
  14413. "list": res2.Output.Data,
  14414. })
  14415. return
  14416. } else {
  14417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14418. return
  14419. }
  14420. }
  14421. func (c *HisApiController) ComfirmAllopatry() {
  14422. year := c.GetString("year")
  14423. month := c.GetString("month")
  14424. admin_user_id, _ := c.GetInt64("admin_user_id")
  14425. adminUser := c.GetAdminUserInfo()
  14426. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14427. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14428. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14429. var dat map[string]interface{}
  14430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14431. fmt.Println(dat)
  14432. } else {
  14433. fmt.Println(err)
  14434. }
  14435. userJSONBytes, _ := json.Marshal(dat)
  14436. var res models.Result9001
  14437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14438. utils.ErrorLog("解析失败:%v", err)
  14439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14440. return
  14441. }
  14442. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14443. var dat2 map[string]interface{}
  14444. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14445. fmt.Println(dat)
  14446. } else {
  14447. fmt.Println(err)
  14448. }
  14449. userJSONBytes2, _ := json.Marshal(dat2)
  14450. var res2 models.Result3260
  14451. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14452. utils.ErrorLog("解析失败:%v", err)
  14453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14454. return
  14455. }
  14456. if res2.Infcode == 0 {
  14457. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14458. var dat map[string]interface{}
  14459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14460. fmt.Println(dat)
  14461. } else {
  14462. fmt.Println(err)
  14463. }
  14464. userJSONBytes, _ := json.Marshal(dat)
  14465. var res3 models.Result3261
  14466. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  14467. utils.ErrorLog("解析失败:%v", err)
  14468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14469. return
  14470. }
  14471. if res3.Infcode == 0 {
  14472. record := &models.HisYidiClearRecord{
  14473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14474. Ctime: time.Now().Unix(),
  14475. Mtime: time.Now().Unix(),
  14476. Status: 1,
  14477. MsgId: msgId,
  14478. }
  14479. service.SaveClearRecord(record)
  14480. c.ServeSuccessJSON(map[string]interface{}{
  14481. "msg": "提取成功",
  14482. })
  14483. }
  14484. }
  14485. }
  14486. func (c *HisApiController) RefundAllopatry() {
  14487. year := c.GetString("year")
  14488. month := c.GetString("month")
  14489. id, _ := c.GetInt64("id")
  14490. admin_user_id, _ := c.GetInt64("admin_user_id")
  14491. adminUser := c.GetAdminUserInfo()
  14492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14493. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14494. record, _ := service.GetClearRecordById(id)
  14495. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  14496. var dat map[string]interface{}
  14497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14498. fmt.Println(dat)
  14499. } else {
  14500. fmt.Println(err)
  14501. }
  14502. userJSONBytes, _ := json.Marshal(dat)
  14503. var empty ResultFourteen
  14504. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  14505. utils.ErrorLog("解析失败:%v", err)
  14506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14507. return
  14508. }
  14509. if empty.Infcode == 0 {
  14510. c.ServeSuccessJSON(map[string]interface{}{
  14511. "msg": "撤销成功",
  14512. })
  14513. return
  14514. }
  14515. }
  14516. func (c *HisApiController) ReversalOtherData() {
  14517. var customData []*CustomData
  14518. custom := &CustomData{
  14519. MsgId: "H44022900158202103301714472004",
  14520. PsnNo: "44020000001101329945",
  14521. Info: "2208",
  14522. }
  14523. customData = append(customData, custom)
  14524. custom1 := &CustomData{
  14525. MsgId: "H4402290015820210330172057803",
  14526. PsnNo: "44020000001101161813",
  14527. Info: "2208",
  14528. }
  14529. customData = append(customData, custom1)
  14530. custom2 := &CustomData{
  14531. MsgId: "H44022900158202103301705198813",
  14532. PsnNo: "44190000133097375417",
  14533. Info: "2208",
  14534. }
  14535. customData = append(customData, custom2)
  14536. custom3 := &CustomData{
  14537. MsgId: "H44022900158202103301715524756",
  14538. PsnNo: "44020000001100187221",
  14539. Info: "2208",
  14540. }
  14541. customData = append(customData, custom3)
  14542. custom4 := &CustomData{
  14543. MsgId: "H44022900158202103301730376224",
  14544. PsnNo: "44020000001101959155",
  14545. Info: "2208",
  14546. }
  14547. customData = append(customData, custom4)
  14548. custom5 := &CustomData{
  14549. MsgId: "H44022900158202103301748008725",
  14550. PsnNo: "44020000001104246641",
  14551. Info: "2208",
  14552. }
  14553. customData = append(customData, custom5)
  14554. custom6 := &CustomData{
  14555. MsgId: "H44022900158202103301718096755",
  14556. PsnNo: "44020000001102211860",
  14557. Info: "2208",
  14558. }
  14559. customData = append(customData, custom6)
  14560. custom7 := &CustomData{
  14561. MsgId: "H44022900158202103301736551640",
  14562. PsnNo: "44020000001102687718",
  14563. Info: "2208",
  14564. }
  14565. customData = append(customData, custom7)
  14566. custom8 := &CustomData{
  14567. MsgId: "H44022900158202103301743097676",
  14568. PsnNo: "44020000001102127785",
  14569. Info: "2208",
  14570. }
  14571. customData = append(customData, custom8)
  14572. custom9 := &CustomData{
  14573. MsgId: "H44022900158202103301712304203",
  14574. PsnNo: "44020000001101518097",
  14575. Info: "2208",
  14576. }
  14577. customData = append(customData, custom9)
  14578. custom10 := &CustomData{
  14579. MsgId: "H44022900158202103301738448785",
  14580. PsnNo: "44020000001100500813",
  14581. Info: "2208",
  14582. }
  14583. customData = append(customData, custom10)
  14584. custom11 := &CustomData{
  14585. MsgId: "H44022900158202103301732455843",
  14586. PsnNo: "44020000001102690557",
  14587. Info: "2208",
  14588. }
  14589. customData = append(customData, custom11)
  14590. custom12 := &CustomData{
  14591. MsgId: "H44022900158202103301745421708",
  14592. PsnNo: "44020000001102211928",
  14593. Info: "2208",
  14594. }
  14595. customData = append(customData, custom12)
  14596. custom1212 := &CustomData{
  14597. MsgId: "H440229001582021033017351627",
  14598. PsnNo: "44020000001102481733",
  14599. Info: "2208",
  14600. }
  14601. customData = append(customData, custom1212)
  14602. custom13 := &CustomData{
  14603. MsgId: "H44022900158202103301740327951",
  14604. PsnNo: "44020000001103174866",
  14605. Info: "2208",
  14606. }
  14607. customData = append(customData, custom13)
  14608. custom14 := &CustomData{
  14609. MsgId: "H4402290015820210330174922668",
  14610. PsnNo: "44020000001102927272",
  14611. Info: "2208",
  14612. }
  14613. customData = append(customData, custom14)
  14614. custom15 := &CustomData{
  14615. MsgId: "H44022900158202103301752362273",
  14616. PsnNo: "44020000001102942890",
  14617. Info: "2208",
  14618. }
  14619. customData = append(customData, custom15)
  14620. custom16 := &CustomData{
  14621. MsgId: "H44022900158202103301751082917",
  14622. PsnNo: "44020000001101662162",
  14623. Info: "2208",
  14624. }
  14625. customData = append(customData, custom16)
  14626. custom17 := &CustomData{
  14627. MsgId: "H44022900158202103301754147728",
  14628. PsnNo: "44020000000229014511",
  14629. Info: "2208",
  14630. }
  14631. customData = append(customData, custom17)
  14632. adminUser := c.GetAdminUserInfo()
  14633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14634. for _, item := range customData {
  14635. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14636. fmt.Println(result)
  14637. }
  14638. }
  14639. func PathExists(path string) (bool, error) {
  14640. _, err := os.Stat(path)
  14641. if err == nil {
  14642. return true, nil
  14643. }
  14644. if os.IsNotExist(err) {
  14645. return false, nil
  14646. }
  14647. return false, err
  14648. }
  14649. //创建文件夹
  14650. func Mkdir(dir string) {
  14651. // 创建文件夹
  14652. exist, err := PathExists(dir)
  14653. if err != nil {
  14654. fmt.Println(err.Error())
  14655. } else {
  14656. if exist {
  14657. fmt.Println(dir + "文件夹已存在!")
  14658. } else {
  14659. // 文件夹名称,权限
  14660. err := os.Mkdir(dir, os.ModePerm)
  14661. if err != nil {
  14662. fmt.Println(dir+"文件夹创建失败:", err.Error())
  14663. } else {
  14664. fmt.Println(dir + "文件夹创建成功!")
  14665. }
  14666. }
  14667. }
  14668. }
  14669. //压缩文件
  14670. func Zip(srcFile string, destZip string) error {
  14671. zipfile, err := os.Create(destZip)
  14672. if err != nil {
  14673. return err
  14674. }
  14675. defer zipfile.Close()
  14676. archive := zip.NewWriter(zipfile)
  14677. defer archive.Close()
  14678. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  14679. if err != nil {
  14680. return err
  14681. }
  14682. header, err := zip.FileInfoHeader(info)
  14683. if err != nil {
  14684. return err
  14685. }
  14686. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  14687. // header.Name = path
  14688. if info.IsDir() {
  14689. header.Name += "/"
  14690. } else {
  14691. header.Method = zip.Deflate
  14692. }
  14693. writer, err := archive.CreateHeader(header)
  14694. if err != nil {
  14695. return err
  14696. }
  14697. if !info.IsDir() {
  14698. file, err := os.Open(path)
  14699. if err != nil {
  14700. return err
  14701. }
  14702. defer file.Close()
  14703. _, err = io.Copy(writer, file)
  14704. }
  14705. return err
  14706. })
  14707. return err
  14708. }
  14709. func ReadFile(filePath string) []byte {
  14710. f, err := os.Open(filePath)
  14711. if err != nil {
  14712. fmt.Println("read file fail", err)
  14713. return nil
  14714. }
  14715. defer f.Close()
  14716. fd, err := ioutil.ReadAll(f)
  14717. if err != nil {
  14718. fmt.Println("read to fd fail", err)
  14719. return nil
  14720. }
  14721. return fd
  14722. }
  14723. func saveLog(result string, request string, infno string, desc string) {
  14724. org_id, _ := beego.AppConfig.Int64("org_id")
  14725. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14726. dir := miConfig.OrgName + "日志"
  14727. utils.Mkdir(dir)
  14728. month := time.Unix(1557042972, 0).Format("1")
  14729. year := time.Now().Format("2006")
  14730. month = time.Now().Format("01")
  14731. day := time.Now().Format("02")
  14732. hour := time.Now().Format("15")
  14733. min := time.Now().Format("04")
  14734. sec := time.Now().Format("05")
  14735. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  14736. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  14737. file_name := file + ".txt"
  14738. file_path := miConfig.OrgName + "日志" + "/" + file_name
  14739. exist, _ := utils.PathExists(file_path)
  14740. if exist { //存在
  14741. fmt.Println("存在")
  14742. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  14743. if err != nil {
  14744. fmt.Println("read fail")
  14745. }
  14746. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  14747. n, _ := f.Seek(0, 2)
  14748. _, err = f.WriteAt([]byte(content), n)
  14749. } else { //不存在
  14750. fmt.Println("文件不存在,创建文件")
  14751. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  14752. defer f.Close()
  14753. if err != nil {
  14754. } else {
  14755. _, err = f.Write([]byte("记录日志"))
  14756. }
  14757. }
  14758. }
  14759. type Charset string
  14760. const (
  14761. UTF8 = Charset("UTF-8")
  14762. GB18030 = Charset("GB18030")
  14763. )
  14764. func ConvertToString(src string, srcCode string, tagCode string) string {
  14765. srcCoder := mahonia.NewDecoder(srcCode)
  14766. srcResult := srcCoder.ConvertString(src)
  14767. tagCoder := mahonia.NewDecoder(tagCode)
  14768. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  14769. result := string(cdata)
  14770. return result
  14771. }
  14772. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  14773. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  14774. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14775. var token string
  14776. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14777. var api string
  14778. if miConfig.MdtrtareaAdmvs == "320921" {
  14779. 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 +
  14780. "&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
  14781. fmt.Println(api)
  14782. } else {
  14783. 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 +
  14784. "&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
  14785. }
  14786. resp, requestErr := http.Get(api)
  14787. if requestErr != nil {
  14788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14789. return ""
  14790. }
  14791. body, ioErr := ioutil.ReadAll(resp.Body)
  14792. if ioErr != nil {
  14793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14795. return ""
  14796. }
  14797. var respJSON map[string]interface{}
  14798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14801. return ""
  14802. }
  14803. var status string
  14804. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14805. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14806. var res ResultTwo //1101结果
  14807. var res10265 ResultTwo10265 //1101结果
  14808. if status == "0" { //读卡成功
  14809. var card_info string //卡信息
  14810. var busi_card_info string
  14811. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14812. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14813. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14814. fmt.Println(card_info)
  14815. fmt.Println(busi_card_info)
  14816. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14817. result, _ := json.Marshal(respJSON)
  14818. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14819. utils.ErrorLog("解析失败:%v", err)
  14820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14821. return ""
  14822. }
  14823. res.ErrMsg = res10265.ErrMsg
  14824. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14825. res.Infcode = infocode
  14826. res.Output = res10265.Output
  14827. res.InfRefmsgid = res10265.InfRefmsgid
  14828. if res.Infcode == 0 {
  14829. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14830. if err == gorm.ErrRecordNotFound {
  14831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14832. return ""
  14833. } else if err != nil {
  14834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14835. return ""
  14836. } else {
  14837. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14838. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14839. infoStr := string(Iinfos)
  14840. idetinfoStr := string(Idetinfos)
  14841. psn := &models.HisPsn{
  14842. PsnNo: res.Output.Baseinfo.PsnNo,
  14843. Age: res.Output.Baseinfo.Age,
  14844. PatientId: patient.ID,
  14845. Certno: res.Output.Baseinfo.Certno,
  14846. Brdy: res.Output.Baseinfo.Brdy,
  14847. Gend: res.Output.Baseinfo.Gend,
  14848. Naty: res.Output.Baseinfo.Naty,
  14849. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14850. PsnName: res.Output.Baseinfo.PsnName,
  14851. Idetinfo: idetinfoStr,
  14852. Insuinfo: infoStr,
  14853. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14854. CardInfo: card_info,
  14855. VerifyNumber: token,
  14856. }
  14857. service.CreateHisPsn(psn)
  14858. return token
  14859. }
  14860. }
  14861. } else {
  14862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14863. return ""
  14864. }
  14865. } else { //读卡失败
  14866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14867. return ""
  14868. }
  14869. return token
  14870. }
  14871. func DeleteExtraSpaceTwo(s string) string {
  14872. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14873. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14874. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14875. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14876. s2 := make([]byte, len(s1)) //定义字符数组切片
  14877. copy(s2, s1) //将字符串复制到切片
  14878. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14879. for len(spc_index) > 0 { //找到适配项
  14880. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14881. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14882. }
  14883. return string(s2)
  14884. }
  14885. func Remove0000(s string) string {
  14886. str := make([]rune, 0, len(s))
  14887. for _, v := range []rune(s) {
  14888. if v == 0 {
  14889. continue
  14890. }
  14891. str = append(str, v)
  14892. }
  14893. return string(str)
  14894. }
  14895. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14896. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14897. readCard := DllDef.MustFindProc("EcQuery")
  14898. pCardInfo := make([]byte, 8192)
  14899. pBusiCardInfo := make([]byte, 8192)
  14900. data := make(map[string]interface{})
  14901. //pData := make(map[string]interface{})
  14902. inputData := make(map[string]interface{})
  14903. inputData["orgId"] = code
  14904. inputData["businessType"] = "01101"
  14905. inputData["operatorId"] = operator_id
  14906. inputData["operatorName"] = operator_name
  14907. inputData["officeId"] = "001"
  14908. inputData["officeName"] = "血透室"
  14909. //
  14910. data["data"] = inputData
  14911. data["transType"] = "ec.query"
  14912. data["orgId"] = code
  14913. bytesData, _ := json.Marshal(data)
  14914. pCardInfo = bytesData
  14915. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14916. fmt.Println(ret2)
  14917. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14918. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14919. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14920. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14921. if ret2 != 0 {
  14922. return "", ""
  14923. }
  14924. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14925. }
  14926. func DeleteExtraSpace(s string) string {
  14927. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14928. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14929. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14930. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14931. s2 := make([]byte, len(s1)) //定义字符数组切片
  14932. copy(s2, s1) //将字符串复制到切片
  14933. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14934. for len(spc_index) > 0 { //找到适配项
  14935. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14936. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14937. }
  14938. return string(s2)
  14939. }
  14940. //对账
  14941. func (c *HisApiController) Post3202() {
  14942. start_time := c.GetString("start_time")
  14943. end_time := c.GetString("end_time")
  14944. //insutype := c.GetString("insutype")
  14945. clr_type := c.GetString("clr_type")
  14946. clr_org := c.GetString("clr_optins")
  14947. admin_user_id, _ := c.GetInt64("admin_user_id")
  14948. adminUser := c.GetAdminUserInfo()
  14949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14951. if len(clr_org) == 0 {
  14952. clr_org = miConfig.MdtrtareaAdmvs
  14953. }
  14954. timeLayout := "2006-01-02"
  14955. loc, _ := time.LoadLocation("Local")
  14956. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14957. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14958. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14959. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14960. //fixmedins_setl_cnt := int64(len(orders))
  14961. var medfee_sumamt float64
  14962. var acct_pay float64
  14963. var fund_pay_sumamt float64
  14964. for _, item := range orders {
  14965. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14966. acct_pay = acct_pay + item.AcctPay
  14967. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14968. }
  14969. //var medfee_sumamt_two float64
  14970. //var acct_pay_two float64
  14971. //var fund_pay_sumamt_two float64
  14972. //for _, item := range orders_two {
  14973. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14974. // acct_pay_two = acct_pay_two + item.AcctPay
  14975. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14976. //}
  14977. //var user_name string
  14978. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14979. //if role.ID == 0 {
  14980. // user_name = "xxx"
  14981. //} else {
  14982. // user_name = role.UserName
  14983. //}
  14984. var res ResultSix
  14985. if config.IsOpen == 1 {
  14986. var bps []*models.BusinessParamsTwo
  14987. var bp models.BusinessParamsTwo
  14988. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14989. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14990. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14991. bp.MedfeeSumamt = medfee_sumamt_str
  14992. bp.AcctPay = acct_pay_str
  14993. bp.FundPaySumamt = fund_pay_sumamt_str
  14994. bp.Insutype = "390"
  14995. bp.StmtBegndate = start_time
  14996. bp.ClrType = clr_type
  14997. bp.SetlOptins = clr_org
  14998. bp.StmtEnddate = end_time
  14999. bps = append(bps, &bp)
  15000. data := make(map[string]interface{})
  15001. data["bps"] = bps
  15002. data["org_name"] = miConfig.OrgName
  15003. data["doctor"] = role.UserName
  15004. data["fixmedins_code"] = miConfig.Code
  15005. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15006. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15007. if miConfig.MdtrtareaAdmvs == "421300" {
  15008. client := &http.Client{}
  15009. bytesData, _ := json.Marshal(data)
  15010. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  15011. resp, _ := client.Do(req)
  15012. defer resp.Body.Close()
  15013. body, ioErr := ioutil.ReadAll(resp.Body)
  15014. if ioErr != nil {
  15015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15017. return
  15018. }
  15019. var respJSON map[string]interface{}
  15020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15023. return
  15024. }
  15025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15026. userJSONBytes, _ := json.Marshal(respJSON)
  15027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15028. utils.ErrorLog("解析失败:%v", err)
  15029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15030. return
  15031. }
  15032. }
  15033. if res.Infcode == 0 {
  15034. c.ServeSuccessJSON(map[string]interface{}{
  15035. "msg": "发起成功",
  15036. })
  15037. } else {
  15038. c.ServeSuccessJSON(map[string]interface{}{
  15039. "code": -10,
  15040. "msg": res.ErrMsg,
  15041. })
  15042. }
  15043. }
  15044. }
  15045. func (c *HisApiController) Post3501() {
  15046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15047. data := make(map[string]interface{})
  15048. var struct3501s []models.Struct3501
  15049. var struct3501 models.Struct3501
  15050. struct3501.OrgName = miConfig.OrgName
  15051. struct3501.AccessKey = miConfig.AccessKey
  15052. struct3501.RequestUrl = miConfig.Url
  15053. struct3501.SecretKey = miConfig.SecretKey
  15054. struct3501.ManuDate = "2022-08-17"
  15055. struct3501.FixmedinsBchno = ""
  15056. struct3501.ManuLotnum = ""
  15057. struct3501.RxFlag = "0"
  15058. struct3501.ExpyEnd = "2022-08-17"
  15059. struct3501.Invdate = "2022-08-17"
  15060. struct3501.InvCnt = "20.25"
  15061. struct3501.Memo = ""
  15062. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15063. struct3501.FixmedinsHilistId = miConfig.Code
  15064. struct3501.FixmedinsHilistName = miConfig.OrgName
  15065. struct3501s = append(struct3501s, struct3501)
  15066. data["struct_3501s"] = struct3501s
  15067. client := &http.Client{}
  15068. bytesData, _ := json.Marshal(data)
  15069. var req *http.Request
  15070. if miConfig.MdtrtareaAdmvs == "320921" {
  15071. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15072. } else {
  15073. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15074. }
  15075. resp, _ := client.Do(req)
  15076. defer resp.Body.Close()
  15077. body, ioErr := ioutil.ReadAll(resp.Body)
  15078. if ioErr != nil {
  15079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15081. return
  15082. }
  15083. var respJSON map[string]interface{}
  15084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15087. return
  15088. }
  15089. var res ResultSix
  15090. var resSix10265 ResultSix10265 //1101结果
  15091. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15092. result, _ := json.Marshal(respJSON)
  15093. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15094. utils.ErrorLog("解析失败:%v", err)
  15095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15096. return
  15097. }
  15098. res.InfRefmsgid = resSix10265.InfRefmsgid
  15099. res.Output = resSix10265.Output
  15100. res.ErrMsg = resSix10265.ErrMsg
  15101. res.Cainfo = resSix10265.Cainfo
  15102. res.WarnMsg = resSix10265.WarnMsg
  15103. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15104. res.Infcode = infocode
  15105. if infocode == 0 {
  15106. c.ServeSuccessJSON(map[string]interface{}{
  15107. "msg": "上传成功",
  15108. })
  15109. return
  15110. } else {
  15111. c.ServeSuccessJSON(map[string]interface{}{
  15112. "failed_code": -10,
  15113. "msg": res.ErrMsg,
  15114. })
  15115. return
  15116. }
  15117. }
  15118. func (c *HisApiController) Post3502() {
  15119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15120. data := make(map[string]interface{})
  15121. var struct3502s []models.Struct3502
  15122. var struct3502 models.Struct3502
  15123. struct3502.OrgName = miConfig.OrgName
  15124. struct3502.AccessKey = miConfig.AccessKey
  15125. struct3502.RequestUrl = miConfig.Url
  15126. struct3502.SecretKey = miConfig.SecretKey
  15127. struct3502.ManuDate = "2022-08-15"
  15128. struct3502.FixmedinsBchno = ""
  15129. struct3502.ManuLotnum = ""
  15130. struct3502.RxFlag = "0"
  15131. struct3502.ExpyEnd = "2022-08-15"
  15132. struct3502.Invdate = "2022-08-15"
  15133. struct3502.InvCnt = "20.25"
  15134. struct3502.Memo = ""
  15135. struct3502.MedListCodg = "XB01ABD056B002020200517"
  15136. struct3502.FixmedinsHilistId = miConfig.Code
  15137. struct3502.FixmedinsHilistName = miConfig.OrgName
  15138. struct3502s = append(struct3502s, struct3502)
  15139. data["struct_3502s"] = struct3502s
  15140. client := &http.Client{}
  15141. bytesData, _ := json.Marshal(data)
  15142. var req *http.Request
  15143. if miConfig.MdtrtareaAdmvs == "320921" {
  15144. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15145. } else {
  15146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15147. }
  15148. resp, _ := client.Do(req)
  15149. defer resp.Body.Close()
  15150. body, ioErr := ioutil.ReadAll(resp.Body)
  15151. if ioErr != nil {
  15152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15154. return
  15155. }
  15156. var respJSON map[string]interface{}
  15157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15160. return
  15161. }
  15162. var res ResultSix
  15163. var resSix10265 ResultSix10265 //1101结果
  15164. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15165. result, _ := json.Marshal(respJSON)
  15166. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15167. utils.ErrorLog("解析失败:%v", err)
  15168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15169. return
  15170. }
  15171. res.InfRefmsgid = resSix10265.InfRefmsgid
  15172. res.Output = resSix10265.Output
  15173. res.ErrMsg = resSix10265.ErrMsg
  15174. res.Cainfo = resSix10265.Cainfo
  15175. res.WarnMsg = resSix10265.WarnMsg
  15176. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15177. res.Infcode = infocode
  15178. if infocode == 0 {
  15179. c.ServeSuccessJSON(map[string]interface{}{
  15180. "msg": "上传成功",
  15181. })
  15182. return
  15183. } else {
  15184. c.ServeSuccessJSON(map[string]interface{}{
  15185. "failed_code": -10,
  15186. "msg": res.ErrMsg,
  15187. })
  15188. return
  15189. }
  15190. }
  15191. func (c *HisApiController) Post3503() {
  15192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15193. data := make(map[string]interface{})
  15194. var struct3501s []models.Struct3501
  15195. var struct3501 models.Struct3501
  15196. struct3501.OrgName = miConfig.OrgName
  15197. struct3501.AccessKey = miConfig.AccessKey
  15198. struct3501.RequestUrl = miConfig.Url
  15199. struct3501.SecretKey = miConfig.SecretKey
  15200. struct3501.ManuDate = "2022-08-15"
  15201. struct3501.FixmedinsBchno = ""
  15202. struct3501.ManuLotnum = ""
  15203. struct3501.RxFlag = "0"
  15204. struct3501.ExpyEnd = "2022-08-15"
  15205. struct3501.Invdate = "2022-08-15"
  15206. struct3501.InvCnt = "20.25"
  15207. struct3501.Memo = ""
  15208. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15209. struct3501.FixmedinsHilistId = miConfig.Code
  15210. struct3501.FixmedinsHilistName = miConfig.OrgName
  15211. struct3501s = append(struct3501s, struct3501)
  15212. data["struct_3501s"] = struct3501s
  15213. client := &http.Client{}
  15214. bytesData, _ := json.Marshal(data)
  15215. var req *http.Request
  15216. if miConfig.MdtrtareaAdmvs == "320921" {
  15217. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15218. } else {
  15219. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15220. }
  15221. resp, _ := client.Do(req)
  15222. defer resp.Body.Close()
  15223. body, ioErr := ioutil.ReadAll(resp.Body)
  15224. if ioErr != nil {
  15225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15227. return
  15228. }
  15229. var respJSON map[string]interface{}
  15230. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15233. return
  15234. }
  15235. var res ResultSix
  15236. var resSix10265 ResultSix10265 //1101结果
  15237. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15238. result, _ := json.Marshal(respJSON)
  15239. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15240. utils.ErrorLog("解析失败:%v", err)
  15241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15242. return
  15243. }
  15244. res.InfRefmsgid = resSix10265.InfRefmsgid
  15245. res.Output = resSix10265.Output
  15246. res.ErrMsg = resSix10265.ErrMsg
  15247. res.Cainfo = resSix10265.Cainfo
  15248. res.WarnMsg = resSix10265.WarnMsg
  15249. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15250. res.Infcode = infocode
  15251. if infocode == 0 {
  15252. c.ServeSuccessJSON(map[string]interface{}{
  15253. "msg": "上传成功",
  15254. })
  15255. return
  15256. } else {
  15257. c.ServeSuccessJSON(map[string]interface{}{
  15258. "failed_code": -10,
  15259. "msg": res.ErrMsg,
  15260. })
  15261. return
  15262. }
  15263. }
  15264. func (c *HisApiController) Post3504() {
  15265. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15266. data := make(map[string]interface{})
  15267. var struct3501s []models.Struct3501
  15268. var struct3501 models.Struct3501
  15269. struct3501.OrgName = miConfig.OrgName
  15270. struct3501.AccessKey = miConfig.AccessKey
  15271. struct3501.RequestUrl = miConfig.Url
  15272. struct3501.SecretKey = miConfig.SecretKey
  15273. struct3501.ManuDate = "2022-08-15"
  15274. struct3501.FixmedinsBchno = ""
  15275. struct3501.ManuLotnum = ""
  15276. struct3501.RxFlag = "0"
  15277. struct3501.ExpyEnd = "2022-08-15"
  15278. struct3501.Invdate = "2022-08-15"
  15279. struct3501.InvCnt = "20.25"
  15280. struct3501.Memo = ""
  15281. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15282. struct3501.FixmedinsHilistId = miConfig.Code
  15283. struct3501.FixmedinsHilistName = miConfig.OrgName
  15284. struct3501s = append(struct3501s, struct3501)
  15285. data["struct_3501s"] = struct3501s
  15286. client := &http.Client{}
  15287. bytesData, _ := json.Marshal(data)
  15288. var req *http.Request
  15289. if miConfig.MdtrtareaAdmvs == "320921" {
  15290. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15291. } else {
  15292. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15293. }
  15294. resp, _ := client.Do(req)
  15295. defer resp.Body.Close()
  15296. body, ioErr := ioutil.ReadAll(resp.Body)
  15297. if ioErr != nil {
  15298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15300. return
  15301. }
  15302. var respJSON map[string]interface{}
  15303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15306. return
  15307. }
  15308. var res ResultSix
  15309. var resSix10265 ResultSix10265 //1101结果
  15310. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15311. result, _ := json.Marshal(respJSON)
  15312. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15313. utils.ErrorLog("解析失败:%v", err)
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15315. return
  15316. }
  15317. res.InfRefmsgid = resSix10265.InfRefmsgid
  15318. res.Output = resSix10265.Output
  15319. res.ErrMsg = resSix10265.ErrMsg
  15320. res.Cainfo = resSix10265.Cainfo
  15321. res.WarnMsg = resSix10265.WarnMsg
  15322. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15323. res.Infcode = infocode
  15324. if infocode == 0 {
  15325. c.ServeSuccessJSON(map[string]interface{}{
  15326. "msg": "上传成功",
  15327. })
  15328. return
  15329. } else {
  15330. c.ServeSuccessJSON(map[string]interface{}{
  15331. "failed_code": -10,
  15332. "msg": res.ErrMsg,
  15333. })
  15334. return
  15335. }
  15336. }
  15337. func (c *HisApiController) Post3505() {
  15338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15339. data := make(map[string]interface{})
  15340. var struct3501s []models.Struct3501
  15341. var struct3501 models.Struct3501
  15342. struct3501.OrgName = miConfig.OrgName
  15343. struct3501.AccessKey = miConfig.AccessKey
  15344. struct3501.RequestUrl = miConfig.Url
  15345. struct3501.SecretKey = miConfig.SecretKey
  15346. struct3501.ManuDate = "2022-08-15"
  15347. struct3501.FixmedinsBchno = ""
  15348. struct3501.ManuLotnum = ""
  15349. struct3501.RxFlag = "0"
  15350. struct3501.ExpyEnd = "2022-08-15"
  15351. struct3501.Invdate = "2022-08-15"
  15352. struct3501.InvCnt = "20.25"
  15353. struct3501.Memo = ""
  15354. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15355. struct3501.FixmedinsHilistId = miConfig.Code
  15356. struct3501.FixmedinsHilistName = miConfig.OrgName
  15357. struct3501s = append(struct3501s, struct3501)
  15358. data["struct_3501s"] = struct3501s
  15359. client := &http.Client{}
  15360. bytesData, _ := json.Marshal(data)
  15361. var req *http.Request
  15362. if miConfig.MdtrtareaAdmvs == "320921" {
  15363. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15364. } else {
  15365. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15366. }
  15367. resp, _ := client.Do(req)
  15368. defer resp.Body.Close()
  15369. body, ioErr := ioutil.ReadAll(resp.Body)
  15370. if ioErr != nil {
  15371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15373. return
  15374. }
  15375. var respJSON map[string]interface{}
  15376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15379. return
  15380. }
  15381. var res ResultSix
  15382. var resSix10265 ResultSix10265 //1101结果
  15383. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15384. result, _ := json.Marshal(respJSON)
  15385. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15386. utils.ErrorLog("解析失败:%v", err)
  15387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15388. return
  15389. }
  15390. res.InfRefmsgid = resSix10265.InfRefmsgid
  15391. res.Output = resSix10265.Output
  15392. res.ErrMsg = resSix10265.ErrMsg
  15393. res.Cainfo = resSix10265.Cainfo
  15394. res.WarnMsg = resSix10265.WarnMsg
  15395. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15396. res.Infcode = infocode
  15397. if infocode == 0 {
  15398. c.ServeSuccessJSON(map[string]interface{}{
  15399. "msg": "上传成功",
  15400. })
  15401. return
  15402. } else {
  15403. c.ServeSuccessJSON(map[string]interface{}{
  15404. "failed_code": -10,
  15405. "msg": res.ErrMsg,
  15406. })
  15407. return
  15408. }
  15409. }
  15410. func (c *HisApiController) Post3506() {
  15411. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15412. data := make(map[string]interface{})
  15413. var struct3501s []models.Struct3501
  15414. var struct3501 models.Struct3501
  15415. struct3501.OrgName = miConfig.OrgName
  15416. struct3501.AccessKey = miConfig.AccessKey
  15417. struct3501.RequestUrl = miConfig.Url
  15418. struct3501.SecretKey = miConfig.SecretKey
  15419. struct3501.ManuDate = "2022-08-15"
  15420. struct3501.FixmedinsBchno = ""
  15421. struct3501.ManuLotnum = ""
  15422. struct3501.RxFlag = "0"
  15423. struct3501.ExpyEnd = "2022-08-15"
  15424. struct3501.Invdate = "2022-08-15"
  15425. struct3501.InvCnt = "20.25"
  15426. struct3501.Memo = ""
  15427. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15428. struct3501.FixmedinsHilistId = miConfig.Code
  15429. struct3501.FixmedinsHilistName = miConfig.OrgName
  15430. struct3501s = append(struct3501s, struct3501)
  15431. data["struct_3501s"] = struct3501s
  15432. client := &http.Client{}
  15433. bytesData, _ := json.Marshal(data)
  15434. var req *http.Request
  15435. if miConfig.MdtrtareaAdmvs == "320921" {
  15436. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15437. } else {
  15438. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15439. }
  15440. resp, _ := client.Do(req)
  15441. defer resp.Body.Close()
  15442. body, ioErr := ioutil.ReadAll(resp.Body)
  15443. if ioErr != nil {
  15444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15446. return
  15447. }
  15448. var respJSON map[string]interface{}
  15449. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15452. return
  15453. }
  15454. var res ResultSix
  15455. var resSix10265 ResultSix10265 //1101结果
  15456. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15457. result, _ := json.Marshal(respJSON)
  15458. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15459. utils.ErrorLog("解析失败:%v", err)
  15460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15461. return
  15462. }
  15463. res.InfRefmsgid = resSix10265.InfRefmsgid
  15464. res.Output = resSix10265.Output
  15465. res.ErrMsg = resSix10265.ErrMsg
  15466. res.Cainfo = resSix10265.Cainfo
  15467. res.WarnMsg = resSix10265.WarnMsg
  15468. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15469. res.Infcode = infocode
  15470. if infocode == 0 {
  15471. c.ServeSuccessJSON(map[string]interface{}{
  15472. "msg": "上传成功",
  15473. })
  15474. return
  15475. } else {
  15476. c.ServeSuccessJSON(map[string]interface{}{
  15477. "failed_code": -10,
  15478. "msg": res.ErrMsg,
  15479. })
  15480. return
  15481. }
  15482. }
  15483. func (c *HisApiController) Post3507() {
  15484. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15485. data := make(map[string]interface{})
  15486. var struct3501s []models.Struct3501
  15487. var struct3501 models.Struct3501
  15488. struct3501.OrgName = miConfig.OrgName
  15489. struct3501.AccessKey = miConfig.AccessKey
  15490. struct3501.RequestUrl = miConfig.Url
  15491. struct3501.SecretKey = miConfig.SecretKey
  15492. struct3501.ManuDate = "2022-08-15"
  15493. struct3501.FixmedinsBchno = ""
  15494. struct3501.ManuLotnum = ""
  15495. struct3501.RxFlag = "0"
  15496. struct3501.ExpyEnd = "2022-08-15"
  15497. struct3501.Invdate = "2022-08-15"
  15498. struct3501.InvCnt = "20.25"
  15499. struct3501.Memo = ""
  15500. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15501. struct3501.FixmedinsHilistId = miConfig.Code
  15502. struct3501.FixmedinsHilistName = miConfig.OrgName
  15503. struct3501s = append(struct3501s, struct3501)
  15504. data["struct_3501s"] = struct3501s
  15505. client := &http.Client{}
  15506. bytesData, _ := json.Marshal(data)
  15507. var req *http.Request
  15508. if miConfig.MdtrtareaAdmvs == "320921" {
  15509. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15510. } else {
  15511. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15512. }
  15513. resp, _ := client.Do(req)
  15514. defer resp.Body.Close()
  15515. body, ioErr := ioutil.ReadAll(resp.Body)
  15516. if ioErr != nil {
  15517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15519. return
  15520. }
  15521. var respJSON map[string]interface{}
  15522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15525. return
  15526. }
  15527. var res ResultSix
  15528. var resSix10265 ResultSix10265 //1101结果
  15529. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15530. result, _ := json.Marshal(respJSON)
  15531. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15532. utils.ErrorLog("解析失败:%v", err)
  15533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15534. return
  15535. }
  15536. res.InfRefmsgid = resSix10265.InfRefmsgid
  15537. res.Output = resSix10265.Output
  15538. res.ErrMsg = resSix10265.ErrMsg
  15539. res.Cainfo = resSix10265.Cainfo
  15540. res.WarnMsg = resSix10265.WarnMsg
  15541. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15542. res.Infcode = infocode
  15543. if infocode == 0 {
  15544. c.ServeSuccessJSON(map[string]interface{}{
  15545. "msg": "上传成功",
  15546. })
  15547. return
  15548. } else {
  15549. c.ServeSuccessJSON(map[string]interface{}{
  15550. "failed_code": -10,
  15551. "msg": res.ErrMsg,
  15552. })
  15553. return
  15554. }
  15555. }