his_api_controller.go 688KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818
  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/gorilla/websocket"
  15. "github.com/jinzhu/gorm"
  16. "github.com/shopspring/decimal"
  17. "io"
  18. "io/ioutil"
  19. "math"
  20. "math/rand"
  21. "net/http"
  22. "net/url"
  23. "os"
  24. "path/filepath"
  25. "regexp"
  26. "strconv"
  27. "strings"
  28. "syscall"
  29. "time"
  30. "unsafe"
  31. )
  32. type HisApiController struct {
  33. controllers.BaseAuthAPIController
  34. }
  35. func HisManagerApiRegistRouters() {
  36. //挂号
  37. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  38. //上传就诊信息-上传明细-结算
  39. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  40. //查询
  41. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  42. //对总账
  43. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  44. //对明细
  45. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  46. //退费,退明细
  47. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  48. //退号
  49. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  50. //退明细
  51. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  52. //上传就诊信息-上传明细-预结算
  53. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  54. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  55. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  56. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  57. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  58. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  59. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  60. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  61. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  62. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  63. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  64. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  65. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  66. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  67. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  68. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  69. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  70. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  71. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  72. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  73. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  74. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  75. beego.Router("/api/check", &HisApiController{}, "get:Check")
  76. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  77. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  78. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  79. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  80. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  81. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  82. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  83. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  84. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  85. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  86. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  87. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  88. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  89. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  90. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  91. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  92. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  93. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  94. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  95. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  96. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  97. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  98. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  99. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  100. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  101. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  102. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  103. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  104. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  105. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  106. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  107. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  108. }
  109. func (c *HisApiController) GetCFYLJG001() {
  110. admin_user_id, _ := c.GetInt64("admin_user_id")
  111. patient_id, _ := c.GetInt64("patient_id")
  112. his_patient_id, _ := c.GetInt64("his_patient_id")
  113. record_time := c.GetString("record_time")
  114. admin_user_id = 3626
  115. patient_id = 19424
  116. his_patient_id = 238932
  117. record_time = "2023-07-03"
  118. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  119. psn, _ := service.GetPsnByPatientId(patient_id)
  120. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  122. var cFYLJG001 models.CFYLJG001
  123. timeLayout := "2006-01-02"
  124. loc, _ := time.LoadLocation("Local")
  125. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  126. if err != nil {
  127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  128. return
  129. }
  130. recordDateTime := theTime.Unix()
  131. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  132. for _, item := range prescriptions {
  133. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  134. if his.IdCardType == 1 {
  135. bas := strings.Split(psn.CardInfo, "|")
  136. basNumber := bas[1]
  137. fmt.Println(basNumber)
  138. card_sn := bas[3]
  139. card_no := bas[2]
  140. cFYLJG001.MdtrtCertType = "03"
  141. cFYLJG001.CardSn = card_sn
  142. cFYLJG001.MdtrtCertNo = card_no
  143. cFYLJG001.EcToken = ""
  144. cFYLJG001.AuthNo = ""
  145. } else if his.IdCardType == 2 {
  146. cFYLJG001.MdtrtCertType = "02"
  147. cFYLJG001.CardSn = ""
  148. cFYLJG001.MdtrtCertNo = his.IdCardNo
  149. cFYLJG001.EcToken = ""
  150. cFYLJG001.AuthNo = ""
  151. } else if his.IdCardType == 4 {
  152. cFYLJG001.MdtrtCertType = "01"
  153. cFYLJG001.CardSn = ""
  154. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  155. cFYLJG001.EcToken = psn.VerifyNumber
  156. cFYLJG001.AuthNo = ""
  157. }
  158. cFYLJG001.BizTypeCode = "01"
  159. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  160. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  161. cFYLJG001.RxTypeCode = "1"
  162. tempTime := time.Unix(item.PreTime, 0)
  163. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  164. cFYLJG001.PrscTime = timeFormatOne
  165. var count float64
  166. if item.Type == 1 {
  167. for _, sumItem := range item.HisDoctorAdviceInfo {
  168. count = count + sumItem.PrescribingNumber
  169. }
  170. }
  171. cFYLJG001.RxDrugCnt = count
  172. cFYLJG001.ValiDays = "5"
  173. ts := time.Unix(item.PreTime, 0)
  174. record_time = ts.AddDate(0, 0, int(5)).Unix()
  175. tempTime3 := time.Unix(record_time, 0)
  176. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  177. cFYLJG001.ValiEndTime = timeFormat3
  178. cFYLJG001.RxCotnFlag = "0"
  179. for _, subItem := range item.HisDoctorAdviceInfo {
  180. var drug models.RxDrug
  181. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  182. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  183. drug.RxItemTypeCode = "11"
  184. drug.DrugDosform = "" //TODO
  185. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  186. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  187. }
  188. drug.MedcWayDscr = subItem.DeliveryWay
  189. tempTime2 := time.Unix(subItem.StartTime, 0)
  190. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  191. drug.MedcBegntime = timeFormatTwo
  192. if subItem.Day > 0 {
  193. ts := time.Unix(subItem.StartTime, 0)
  194. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  195. tempTime3 := time.Unix(record_time, 0)
  196. timeFormat3 := tempTime3.Format("2006-01-02") + " 23:59:00"
  197. drug.MedcEndtime = timeFormat3
  198. } else {
  199. tempTime2 := time.Unix(subItem.StartTime, 0)
  200. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  201. drug.MedcEndtime = timeFormatTwo
  202. }
  203. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  204. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  205. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  206. drug.DrugCnt = subItem.PrescribingNumber
  207. drug.DrugDosunt = subItem.PrescribingNumberUnit
  208. drug.SinDoscnt = subItem.SingleDose
  209. drug.SinDosunt = subItem.SingleDoseUnit
  210. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  211. drug.UsedFrquName = subItem.ExecutionFrequency
  212. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  213. drug.DrugTotlcntEmp = fmt.Sprintf("%.2f", subItem.PrescribingNumberUnit)
  214. drug.HospApprFlag = "1"
  215. cFYLJG001.List = append(cFYLJG001.List, drug)
  216. }
  217. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  218. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  219. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  220. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  221. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  222. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  223. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  224. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  225. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  226. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  227. cFYLJG001.Mdtrtinfo.PatnHgt = ""
  228. cFYLJG001.Mdtrtinfo.PatnWt = ""
  229. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  230. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  231. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  232. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  233. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  234. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  235. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  236. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  237. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  238. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  239. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  240. tempTime2 := time.Now().Unix()
  241. tempTime3 := time.Unix(tempTime2, 0)
  242. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  243. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  244. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  245. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  246. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  247. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  248. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  249. var config []*models.HisXtDiagnoseConfig
  250. for _, item := range diagnosis_ids {
  251. id, _ := strconv.ParseInt(item, 10, 64)
  252. diagnosisConfig, _ := service.FindDiagnoseById(id)
  253. config = append(config, &diagnosisConfig)
  254. }
  255. for index, item := range config {
  256. if index == 0 {
  257. var dia models.DiseInfo
  258. dia.DiagType = "1"
  259. dia.MaindiagFlag = "1"
  260. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  261. dia.DiagCode = item.CountryCode
  262. dia.DiagName = item.ClassName
  263. dia.DiagDept = "肾内科"
  264. dia.DiagDrNo = doctor.DoctorNumber
  265. dia.DiagDrName = doctor.UserName
  266. tempTime3 := time.Unix(item.Ctime, 0)
  267. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  268. dia.DiagTime = timeFormatTwo
  269. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  270. } else {
  271. var dia models.DiseInfo
  272. dia.DiagType = "1"
  273. dia.MaindiagFlag = "0"
  274. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  275. dia.DiagCode = item.CountryCode
  276. dia.DiagName = item.ClassName
  277. dia.DiagDept = "肾内科"
  278. dia.DiagDrNo = doctor.DoctorNumber
  279. dia.DiagDrName = doctor.UserName
  280. tempTime3 := time.Unix(item.Ctime, 0)
  281. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  282. dia.DiagTime = timeFormatTwo
  283. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  284. }
  285. }
  286. fmt.Println(cFYLJG001)
  287. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  288. }
  289. }
  290. func (c *HisApiController) GetCFYLJG002() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  293. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  294. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  295. }
  296. func (c *HisApiController) GetCFYLJG003() {
  297. admin_user_id, _ := c.GetInt64("admin_user_id")
  298. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  300. var cFYLJG003 models.CFYLJG003
  301. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  302. }
  303. func (c *HisApiController) GetCFYLJG004() {
  304. admin_user_id, _ := c.GetInt64("admin_user_id")
  305. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  306. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  307. var cFYLJG004 models.CFYLJG004
  308. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  309. }
  310. func (c *HisApiController) GetCFYLJG005() {
  311. admin_user_id, _ := c.GetInt64("admin_user_id")
  312. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  313. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  314. var cFYLJG005 models.CFYLJG005
  315. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  316. }
  317. func (c *HisApiController) GetCFYLJG006() {
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  320. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  321. var cFYLJG006 models.CFYLJG006
  322. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  323. }
  324. func (c *HisApiController) GetCFYLJG007() {
  325. admin_user_id, _ := c.GetInt64("admin_user_id")
  326. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. var cFYLJG007 models.CFYLJG007
  329. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  330. }
  331. func (c *HisApiController) GetBL4201A() {
  332. order_id, _ := c.GetInt64("order_id")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. order, _ := service.GetHisOrderByIDTwo(order_id)
  335. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  336. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  337. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  338. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  339. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  340. department, _ := service.GetDepartMentDetail(his.Departments)
  341. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  342. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  343. if order.ID == 0 {
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  345. return
  346. }
  347. var struct4201A models.Struct4201A
  348. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  349. for _, items := range order_info {
  350. memo := make(map[string]interface{})
  351. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  352. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  353. fsiOPFLD.MedType = "14"
  354. fsiOPFLD.BkkpSn = items.FeedetlSn
  355. fsiOPFLD.FixmedinsCode = miConfig.Code
  356. fsiOPFLD.FixmedinsName = miConfig.OrgName
  357. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  358. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  359. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  360. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  361. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  362. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  363. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  364. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  365. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  366. fsiOPFLD.BilgDeptName = department.Name
  367. fsiOPFLD.BilgDeptCodg = department.Number
  368. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  369. fsiOPFLD.BilgDrName = doctor.UserName
  370. fsiOPFLD.MedChrgitmType = "09"
  371. memo["hosp_appr_flag"] = "1"
  372. memo["invoice_no"] = order.MdtrtId
  373. memo["memo"] = "自费"
  374. bytesData, _ := json.Marshal(memo)
  375. fsiOPFLD.Memo = string(bytesData)
  376. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  377. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  378. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  379. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  380. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  381. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  382. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  383. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  384. fsiOPFLD.BilgDeptName = department.Name
  385. fsiOPFLD.BilgDeptCodg = department.Number
  386. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  387. fsiOPFLD.BilgDrName = doctor.UserName
  388. switch items.HisPrescriptionProject.HisProject.CostClassify {
  389. case 0:
  390. break
  391. case 1:
  392. fsiOPFLD.MedChrgitmType = "14"
  393. break
  394. case 2:
  395. fsiOPFLD.MedChrgitmType = "05"
  396. break
  397. case 3:
  398. fsiOPFLD.MedChrgitmType = "03"
  399. break
  400. case 4:
  401. fsiOPFLD.MedChrgitmType = "03"
  402. break
  403. case 5:
  404. fsiOPFLD.MedChrgitmType = "08"
  405. break
  406. case 6:
  407. fsiOPFLD.MedChrgitmType = "14"
  408. break
  409. case 7:
  410. fsiOPFLD.MedChrgitmType = "14"
  411. break
  412. case 8:
  413. fsiOPFLD.MedChrgitmType = "03"
  414. break
  415. case 9:
  416. fsiOPFLD.MedChrgitmType = "14"
  417. break
  418. case 10:
  419. fsiOPFLD.MedChrgitmType = "14"
  420. break
  421. case 11:
  422. fsiOPFLD.MedChrgitmType = "06"
  423. break
  424. case 12:
  425. fsiOPFLD.MedChrgitmType = "12"
  426. break
  427. case 13:
  428. fsiOPFLD.MedChrgitmType = "01"
  429. break
  430. case 14:
  431. fsiOPFLD.MedChrgitmType = "04"
  432. break
  433. case 15:
  434. fsiOPFLD.MedChrgitmType = "14"
  435. break
  436. }
  437. memo["hosp_appr_flag"] = "1"
  438. memo["invoice_no"] = order.MdtrtId
  439. memo["memo"] = "自费"
  440. bytesData, _ := json.Marshal(memo)
  441. fsiOPFLD.Memo = string(bytesData)
  442. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  443. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  444. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  445. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  446. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  447. fsiOPFLD.BilgDeptName = department.Name
  448. fsiOPFLD.BilgDeptCodg = department.Number
  449. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  450. fsiOPFLD.BilgDrName = doctor.UserName
  451. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  452. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  453. fsiOPFLD.MedChrgitmType = "08"
  454. memo["hosp_appr_flag"] = "1"
  455. memo["invoice_no"] = order.MdtrtId
  456. memo["memo"] = "自费"
  457. bytesData, _ := json.Marshal(memo)
  458. fsiOPFLD.Memo = string(bytesData)
  459. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  460. }
  461. }
  462. }
  463. for _, items := range order_info_two {
  464. memo := make(map[string]interface{})
  465. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  466. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  467. fsiOPFLD.MedType = "14"
  468. fsiOPFLD.BkkpSn = items.FeedetlSn
  469. fsiOPFLD.FixmedinsCode = miConfig.Code
  470. fsiOPFLD.FixmedinsName = miConfig.OrgName
  471. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  472. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  473. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  474. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  475. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  476. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  477. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  478. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  479. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  480. fsiOPFLD.BilgDeptName = department.Name
  481. fsiOPFLD.BilgDeptCodg = department.Number
  482. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  483. fsiOPFLD.BilgDrName = doctor.UserName
  484. fsiOPFLD.MedChrgitmType = "09"
  485. memo["hosp_appr_flag"] = "1"
  486. memo["invoice_no"] = order.MdtrtId
  487. memo["memo"] = "自费"
  488. bytesData, _ := json.Marshal(memo)
  489. fsiOPFLD.Memo = string(bytesData)
  490. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  491. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  492. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  493. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  494. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  495. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  496. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  497. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  498. fsiOPFLD.BilgDeptName = department.Name
  499. fsiOPFLD.BilgDeptCodg = department.Number
  500. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  501. fsiOPFLD.BilgDrName = doctor.UserName
  502. switch items.HisPrescriptionProject.HisProject.CostClassify {
  503. case 0:
  504. break
  505. case 1:
  506. fsiOPFLD.MedChrgitmType = "14"
  507. break
  508. case 2:
  509. fsiOPFLD.MedChrgitmType = "05"
  510. break
  511. case 3:
  512. fsiOPFLD.MedChrgitmType = "03"
  513. break
  514. case 4:
  515. fsiOPFLD.MedChrgitmType = "03"
  516. break
  517. case 5:
  518. fsiOPFLD.MedChrgitmType = "08"
  519. break
  520. case 6:
  521. fsiOPFLD.MedChrgitmType = "14"
  522. break
  523. case 7:
  524. fsiOPFLD.MedChrgitmType = "14"
  525. break
  526. case 8:
  527. fsiOPFLD.MedChrgitmType = "03"
  528. break
  529. case 9:
  530. fsiOPFLD.MedChrgitmType = "14"
  531. break
  532. case 10:
  533. fsiOPFLD.MedChrgitmType = "14"
  534. break
  535. case 11:
  536. fsiOPFLD.MedChrgitmType = "06"
  537. break
  538. case 12:
  539. fsiOPFLD.MedChrgitmType = "12"
  540. break
  541. case 13:
  542. fsiOPFLD.MedChrgitmType = "01"
  543. break
  544. case 14:
  545. fsiOPFLD.MedChrgitmType = "04"
  546. break
  547. case 15:
  548. fsiOPFLD.MedChrgitmType = "14"
  549. break
  550. }
  551. memo["hosp_appr_flag"] = "1"
  552. memo["invoice_no"] = order.MdtrtId
  553. memo["memo"] = "自费"
  554. bytesData, _ := json.Marshal(memo)
  555. fsiOPFLD.Memo = string(bytesData)
  556. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  557. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  558. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  559. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  560. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  561. fsiOPFLD.BilgDeptName = department.Name
  562. fsiOPFLD.BilgDeptCodg = department.Number
  563. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  564. fsiOPFLD.BilgDrName = doctor.UserName
  565. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  566. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  567. fsiOPFLD.MedChrgitmType = "08"
  568. memo["hosp_appr_flag"] = "1"
  569. memo["invoice_no"] = order.MdtrtId
  570. memo["memo"] = "自费"
  571. bytesData, _ := json.Marshal(memo)
  572. fsiOPFLD.Memo = string(bytesData)
  573. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  574. }
  575. }
  576. }
  577. fmt.Println(fsiOPFLDs)
  578. struct4201A.Fopfd = fsiOPFLDs
  579. fmt.Println(struct4201A.Fopfd)
  580. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  581. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  582. var res2 ResultSix
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res2.Infcode != 0 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res2.ErrMsg,
  599. })
  600. return
  601. } else {
  602. order.IsUploadOrderInfo = 1
  603. service.UpdateOrder(order)
  604. c.ServeSuccessJSON(map[string]interface{}{
  605. "msg": "上传成功",
  606. })
  607. }
  608. }
  609. func (c *HisApiController) Get2505() {
  610. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  611. 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")
  612. }
  613. func (c *HisApiController) Get4201A() {
  614. order_id, _ := c.GetInt64("order_id")
  615. admin_user_id, _ := c.GetInt64("admin_user_id")
  616. order, _ := service.GetHisOrderByIDTwo(order_id)
  617. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  618. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  619. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  620. //order_info = append(order_info, order_info_two...)
  621. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  622. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  623. department, _ := service.GetDepartMentDetail(his.Departments)
  624. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  625. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  626. if order.ID == 0 {
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  628. return
  629. }
  630. var struct4201A models.Struct4201A
  631. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  632. for _, items := range order_info {
  633. memo := make(map[string]interface{})
  634. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  635. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  636. fsiOPFLD.MedType = "14"
  637. fsiOPFLD.BkkpSn = items.FeedetlSn
  638. fsiOPFLD.FixmedinsCode = miConfig.Code
  639. fsiOPFLD.FixmedinsName = miConfig.OrgName
  640. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  641. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  642. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  643. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  644. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  645. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  646. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  647. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  648. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  649. fsiOPFLD.BilgDeptName = department.Name
  650. fsiOPFLD.BilgDeptCodg = department.Number
  651. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  652. fsiOPFLD.BilgDrName = doctor.UserName
  653. fsiOPFLD.MedChrgitmType = "09"
  654. memo["hosp_appr_flag"] = "1"
  655. memo["invoice_no"] = order.MdtrtId
  656. memo["memo"] = "自费"
  657. bytesData, _ := json.Marshal(memo)
  658. fsiOPFLD.Memo = string(bytesData)
  659. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  660. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  661. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  662. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  663. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  664. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  665. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  666. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  667. fsiOPFLD.BilgDeptName = department.Name
  668. fsiOPFLD.BilgDeptCodg = department.Number
  669. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  670. fsiOPFLD.BilgDrName = doctor.UserName
  671. switch items.HisPrescriptionProject.HisProject.CostClassify {
  672. case 0:
  673. break
  674. case 1:
  675. fsiOPFLD.MedChrgitmType = "14"
  676. break
  677. case 2:
  678. fsiOPFLD.MedChrgitmType = "05"
  679. break
  680. case 3:
  681. fsiOPFLD.MedChrgitmType = "03"
  682. break
  683. case 4:
  684. fsiOPFLD.MedChrgitmType = "03"
  685. break
  686. case 5:
  687. fsiOPFLD.MedChrgitmType = "08"
  688. break
  689. case 6:
  690. fsiOPFLD.MedChrgitmType = "14"
  691. break
  692. case 7:
  693. fsiOPFLD.MedChrgitmType = "14"
  694. break
  695. case 8:
  696. fsiOPFLD.MedChrgitmType = "03"
  697. break
  698. case 9:
  699. fsiOPFLD.MedChrgitmType = "14"
  700. break
  701. case 10:
  702. fsiOPFLD.MedChrgitmType = "14"
  703. break
  704. case 11:
  705. fsiOPFLD.MedChrgitmType = "06"
  706. break
  707. case 12:
  708. fsiOPFLD.MedChrgitmType = "12"
  709. break
  710. case 13:
  711. fsiOPFLD.MedChrgitmType = "01"
  712. break
  713. case 14:
  714. fsiOPFLD.MedChrgitmType = "04"
  715. break
  716. case 15:
  717. fsiOPFLD.MedChrgitmType = "14"
  718. break
  719. }
  720. memo["hosp_appr_flag"] = "1"
  721. memo["invoice_no"] = order.MdtrtId
  722. memo["memo"] = "自费"
  723. bytesData, _ := json.Marshal(memo)
  724. fsiOPFLD.Memo = string(bytesData)
  725. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  726. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  727. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  728. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  729. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  730. fsiOPFLD.BilgDeptName = department.Name
  731. fsiOPFLD.BilgDeptCodg = department.Number
  732. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  733. fsiOPFLD.BilgDrName = doctor.UserName
  734. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  735. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  736. fsiOPFLD.MedChrgitmType = "08"
  737. memo["hosp_appr_flag"] = "1"
  738. memo["invoice_no"] = order.MdtrtId
  739. memo["memo"] = "自费"
  740. bytesData, _ := json.Marshal(memo)
  741. fsiOPFLD.Memo = string(bytesData)
  742. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  743. }
  744. }
  745. }
  746. for _, items := range order_info_two {
  747. memo := make(map[string]interface{})
  748. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  749. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  750. fsiOPFLD.MedType = "14"
  751. fsiOPFLD.BkkpSn = items.FeedetlSn
  752. fsiOPFLD.FixmedinsCode = miConfig.Code
  753. fsiOPFLD.FixmedinsName = miConfig.OrgName
  754. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  755. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  756. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  757. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  758. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  759. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  760. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  761. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  762. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  763. fsiOPFLD.BilgDeptName = department.Name
  764. fsiOPFLD.BilgDeptCodg = department.Number
  765. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  766. fsiOPFLD.BilgDrName = doctor.UserName
  767. fsiOPFLD.MedChrgitmType = "09"
  768. memo["hosp_appr_flag"] = "1"
  769. memo["invoice_no"] = order.MdtrtId
  770. memo["memo"] = "自费"
  771. bytesData, _ := json.Marshal(memo)
  772. fsiOPFLD.Memo = string(bytesData)
  773. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  774. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  775. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  776. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  777. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  778. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  779. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  780. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  781. fsiOPFLD.BilgDeptName = department.Name
  782. fsiOPFLD.BilgDeptCodg = department.Number
  783. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  784. fsiOPFLD.BilgDrName = doctor.UserName
  785. switch items.HisPrescriptionProject.HisProject.CostClassify {
  786. case 0:
  787. break
  788. case 1:
  789. fsiOPFLD.MedChrgitmType = "14"
  790. break
  791. case 2:
  792. fsiOPFLD.MedChrgitmType = "05"
  793. break
  794. case 3:
  795. fsiOPFLD.MedChrgitmType = "03"
  796. break
  797. case 4:
  798. fsiOPFLD.MedChrgitmType = "03"
  799. break
  800. case 5:
  801. fsiOPFLD.MedChrgitmType = "08"
  802. break
  803. case 6:
  804. fsiOPFLD.MedChrgitmType = "14"
  805. break
  806. case 7:
  807. fsiOPFLD.MedChrgitmType = "14"
  808. break
  809. case 8:
  810. fsiOPFLD.MedChrgitmType = "03"
  811. break
  812. case 9:
  813. fsiOPFLD.MedChrgitmType = "14"
  814. break
  815. case 10:
  816. fsiOPFLD.MedChrgitmType = "14"
  817. break
  818. case 11:
  819. fsiOPFLD.MedChrgitmType = "06"
  820. break
  821. case 12:
  822. fsiOPFLD.MedChrgitmType = "12"
  823. break
  824. case 13:
  825. fsiOPFLD.MedChrgitmType = "01"
  826. break
  827. case 14:
  828. fsiOPFLD.MedChrgitmType = "04"
  829. break
  830. case 15:
  831. fsiOPFLD.MedChrgitmType = "14"
  832. break
  833. }
  834. memo["hosp_appr_flag"] = "1"
  835. memo["invoice_no"] = order.MdtrtId
  836. memo["memo"] = "自费"
  837. bytesData, _ := json.Marshal(memo)
  838. fsiOPFLD.Memo = string(bytesData)
  839. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  840. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  841. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  842. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  843. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  844. fsiOPFLD.BilgDeptName = department.Name
  845. fsiOPFLD.BilgDeptCodg = department.Number
  846. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  847. fsiOPFLD.BilgDrName = doctor.UserName
  848. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  849. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  850. fsiOPFLD.MedChrgitmType = "08"
  851. memo["hosp_appr_flag"] = "1"
  852. memo["invoice_no"] = order.MdtrtId
  853. memo["memo"] = "自费"
  854. bytesData, _ := json.Marshal(memo)
  855. fsiOPFLD.Memo = string(bytesData)
  856. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  857. }
  858. }
  859. }
  860. fmt.Println(fsiOPFLDs)
  861. struct4201A.Fopfd = fsiOPFLDs
  862. fmt.Println(struct4201A.Fopfd)
  863. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  864. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  865. var res2 ResultSix
  866. var respJSON2 map[string]interface{}
  867. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  870. return
  871. }
  872. userJSONBytes2, _ := json.Marshal(respJSON2)
  873. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  874. utils.ErrorLog("解析失败:%v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. if res2.Infcode != 0 {
  879. c.ServeSuccessJSON(map[string]interface{}{
  880. "failed_code": -10,
  881. "msg": res2.ErrMsg,
  882. })
  883. return
  884. } else {
  885. order.IsUploadOrderInfo = 1
  886. service.UpdateOrder(order)
  887. c.ServeSuccessJSON(map[string]interface{}{
  888. "msg": "上传成功",
  889. })
  890. }
  891. }
  892. func (c *HisApiController) Get4202() {
  893. order_id, _ := c.GetInt64("order_id")
  894. admin_user_id, _ := c.GetInt64("admin_user_id")
  895. order, _ := service.GetHisOrderByIDTwo(order_id)
  896. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  897. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  899. if order.ID == 0 {
  900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  901. return
  902. }
  903. var struct4202 models.Struct4202
  904. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  905. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  906. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  907. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  908. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  909. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  910. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  911. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  912. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  913. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  914. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  915. var config []*models.HisXtDiagnoseConfig
  916. for _, item := range diagnosis_ids {
  917. id, _ := strconv.ParseInt(item, 10, 64)
  918. diagnosisConfig, _ := service.FindDiagnoseById(id)
  919. config = append(config, &diagnosisConfig)
  920. }
  921. var tempDiaginfos []models.OwnPayPatnDiagListD
  922. for index, item := range config {
  923. if index == 0 {
  924. var tempDiaginfo models.OwnPayPatnDiagListD
  925. tempDiaginfo.InoutDiagType = "1"
  926. tempDiaginfo.DiagCode = item.CountryCode
  927. tempDiaginfo.DiagName = item.CountryContentName
  928. tempDiaginfo.DiagType = "1"
  929. tempDiaginfo.DiagSrtNo = "1"
  930. tempDiaginfo.MaindiagFlag = "1"
  931. tempDiaginfo.ValiFlag = "1"
  932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  933. } else {
  934. var tempDiaginfo models.OwnPayPatnDiagListD
  935. tempDiaginfo.DiagCode = item.CountryCode
  936. tempDiaginfo.DiagName = item.CountryContentName
  937. tempDiaginfo.DiagType = "2"
  938. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  939. tempDiaginfo.MaindiagFlag = "0"
  940. tempDiaginfo.ValiFlag = "1"
  941. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  942. }
  943. }
  944. struct4202.ODiagListD = tempDiaginfos
  945. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  946. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  947. var res2 ResultSix
  948. var respJSON2 map[string]interface{}
  949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  952. return
  953. }
  954. userJSONBytes2, _ := json.Marshal(respJSON2)
  955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  956. utils.ErrorLog("解析失败:%v", err)
  957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  958. return
  959. }
  960. if res2.Infcode != 0 {
  961. c.ServeSuccessJSON(map[string]interface{}{
  962. "failed_code": -10,
  963. "msg": res2.ErrMsg,
  964. })
  965. return
  966. } else {
  967. order.IsUploadDiagnose = 1
  968. service.UpdateOrder(order)
  969. c.ServeSuccessJSON(map[string]interface{}{
  970. "msg": "上传成功",
  971. })
  972. }
  973. }
  974. func (c *HisApiController) Get4203() {
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  978. order_id, _ := c.GetInt64("order_id")
  979. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  980. number := ""
  981. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  982. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  983. if his.ID == 0 {
  984. number = hospital.Number
  985. } else {
  986. number = his.Number
  987. }
  988. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  989. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  990. var res2 ResultSix
  991. var respJSON2 map[string]interface{}
  992. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. userJSONBytes2, _ := json.Marshal(respJSON2)
  998. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  999. utils.ErrorLog("解析失败:%v", err)
  1000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1001. return
  1002. }
  1003. if res2.Infcode != 0 {
  1004. c.ServeSuccessJSON(map[string]interface{}{
  1005. "failed_code": -10,
  1006. "msg": res2.ErrMsg,
  1007. })
  1008. return
  1009. } else {
  1010. order.IsUploadSuccess = 1
  1011. service.UpdateOrderTwo(order)
  1012. c.ServeSuccessJSON(map[string]interface{}{
  1013. "msg": "上传成功",
  1014. })
  1015. }
  1016. }
  1017. func (c *HisApiController) Get4205() {
  1018. order_id, _ := c.GetInt64("order_id")
  1019. admin_user_id, _ := c.GetInt64("admin_user_id")
  1020. fapiao_code := c.GetString("fapiao_code")
  1021. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1022. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1023. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1025. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  1026. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  1027. //order_info = append(order_info, order_info_two...)
  1028. department, _ := service.GetDepartMentDetail(his.Departments)
  1029. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1030. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1031. if order.ID == 0 {
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1033. return
  1034. }
  1035. var struct4201A models.Struct4201A
  1036. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1037. for _, items := range order_info {
  1038. memo := make(map[string]interface{})
  1039. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1040. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1041. fsiOPFLD.MedType = pre.MedType
  1042. fsiOPFLD.FixmedinsCode = miConfig.Code
  1043. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1044. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1045. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1046. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1047. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1048. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1049. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1050. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  1051. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1052. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1053. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1054. fsiOPFLD.BilgDeptName = department.Name
  1055. fsiOPFLD.BilgDeptCodg = department.Number
  1056. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1057. fsiOPFLD.BilgDrName = doctor.UserName
  1058. fsiOPFLD.MedChrgitmType = "09"
  1059. memo["hosp_appr_flag"] = "1"
  1060. memo["invoice_no"] = fapiao_code
  1061. memo["memo"] = "自费"
  1062. bytesData, _ := json.Marshal(memo)
  1063. fsiOPFLD.Memo = string(bytesData)
  1064. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1065. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1066. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1067. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1068. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1069. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1070. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1071. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1072. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1073. fsiOPFLD.BilgDeptName = department.Name
  1074. fsiOPFLD.BilgDeptCodg = department.Number
  1075. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1076. fsiOPFLD.BilgDrName = doctor.UserName
  1077. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1078. case 0:
  1079. break
  1080. case 1:
  1081. fsiOPFLD.MedChrgitmType = "14"
  1082. break
  1083. case 2:
  1084. fsiOPFLD.MedChrgitmType = "05"
  1085. break
  1086. case 3:
  1087. fsiOPFLD.MedChrgitmType = "03"
  1088. break
  1089. case 4:
  1090. fsiOPFLD.MedChrgitmType = "03"
  1091. break
  1092. case 5:
  1093. fsiOPFLD.MedChrgitmType = "08"
  1094. break
  1095. case 6:
  1096. fsiOPFLD.MedChrgitmType = "14"
  1097. break
  1098. case 7:
  1099. fsiOPFLD.MedChrgitmType = "14"
  1100. break
  1101. case 8:
  1102. fsiOPFLD.MedChrgitmType = "03"
  1103. break
  1104. case 9:
  1105. fsiOPFLD.MedChrgitmType = "14"
  1106. break
  1107. case 10:
  1108. fsiOPFLD.MedChrgitmType = "14"
  1109. break
  1110. case 11:
  1111. fsiOPFLD.MedChrgitmType = "06"
  1112. break
  1113. case 12:
  1114. fsiOPFLD.MedChrgitmType = "12"
  1115. break
  1116. case 13:
  1117. fsiOPFLD.MedChrgitmType = "01"
  1118. break
  1119. case 14:
  1120. fsiOPFLD.MedChrgitmType = "04"
  1121. break
  1122. case 15:
  1123. fsiOPFLD.MedChrgitmType = "14"
  1124. break
  1125. }
  1126. memo["hosp_appr_flag"] = "1"
  1127. memo["invoice_no"] = fapiao_code
  1128. memo["memo"] = "自费"
  1129. bytesData, _ := json.Marshal(memo)
  1130. fsiOPFLD.Memo = string(bytesData)
  1131. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1132. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1133. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1134. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1135. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1136. fsiOPFLD.BilgDeptName = department.Name
  1137. fsiOPFLD.BilgDeptCodg = department.Number
  1138. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1139. fsiOPFLD.BilgDrName = doctor.UserName
  1140. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1141. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1142. fsiOPFLD.MedChrgitmType = "08"
  1143. memo["hosp_appr_flag"] = "1"
  1144. memo["invoice_no"] = fapiao_code
  1145. memo["memo"] = "自费"
  1146. bytesData, _ := json.Marshal(memo)
  1147. fsiOPFLD.Memo = string(bytesData)
  1148. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1149. }
  1150. }
  1151. }
  1152. for _, items := range order_info_two {
  1153. memo := make(map[string]interface{})
  1154. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1155. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1156. fsiOPFLD.MedType = pre.MedType
  1157. fsiOPFLD.BkkpSn = items.FeedetlSn
  1158. fsiOPFLD.FixmedinsCode = miConfig.Code
  1159. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1160. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1161. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1162. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1163. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1164. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1165. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1166. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1167. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1168. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1169. fsiOPFLD.BilgDeptName = department.Name
  1170. fsiOPFLD.BilgDeptCodg = department.Number
  1171. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1172. fsiOPFLD.BilgDrName = doctor.UserName
  1173. fsiOPFLD.MedChrgitmType = "09"
  1174. memo["hosp_appr_flag"] = "1"
  1175. memo["invoice_no"] = fapiao_code
  1176. memo["memo"] = "自费"
  1177. bytesData, _ := json.Marshal(memo)
  1178. fsiOPFLD.Memo = string(bytesData)
  1179. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1180. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1181. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1182. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1183. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1184. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1185. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1186. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1187. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1188. fsiOPFLD.BilgDeptName = department.Name
  1189. fsiOPFLD.BilgDeptCodg = department.Number
  1190. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1191. fsiOPFLD.BilgDrName = doctor.UserName
  1192. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1193. case 0:
  1194. break
  1195. case 1:
  1196. fsiOPFLD.MedChrgitmType = "14"
  1197. break
  1198. case 2:
  1199. fsiOPFLD.MedChrgitmType = "05"
  1200. break
  1201. case 3:
  1202. fsiOPFLD.MedChrgitmType = "03"
  1203. break
  1204. case 4:
  1205. fsiOPFLD.MedChrgitmType = "03"
  1206. break
  1207. case 5:
  1208. fsiOPFLD.MedChrgitmType = "08"
  1209. break
  1210. case 6:
  1211. fsiOPFLD.MedChrgitmType = "14"
  1212. break
  1213. case 7:
  1214. fsiOPFLD.MedChrgitmType = "14"
  1215. break
  1216. case 8:
  1217. fsiOPFLD.MedChrgitmType = "03"
  1218. break
  1219. case 9:
  1220. fsiOPFLD.MedChrgitmType = "14"
  1221. break
  1222. case 10:
  1223. fsiOPFLD.MedChrgitmType = "14"
  1224. break
  1225. case 11:
  1226. fsiOPFLD.MedChrgitmType = "06"
  1227. break
  1228. case 12:
  1229. fsiOPFLD.MedChrgitmType = "12"
  1230. break
  1231. case 13:
  1232. fsiOPFLD.MedChrgitmType = "01"
  1233. break
  1234. case 14:
  1235. fsiOPFLD.MedChrgitmType = "04"
  1236. break
  1237. case 15:
  1238. fsiOPFLD.MedChrgitmType = "14"
  1239. break
  1240. }
  1241. memo["hosp_appr_flag"] = "1"
  1242. memo["invoice_no"] = fapiao_code
  1243. memo["memo"] = "自费"
  1244. bytesData, _ := json.Marshal(memo)
  1245. fsiOPFLD.Memo = string(bytesData)
  1246. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1247. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1248. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1249. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1250. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1251. fsiOPFLD.BilgDeptName = department.Name
  1252. fsiOPFLD.BilgDeptCodg = department.Number
  1253. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1254. fsiOPFLD.BilgDrName = doctor.UserName
  1255. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1256. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1257. fsiOPFLD.MedChrgitmType = "08"
  1258. memo["hosp_appr_flag"] = "1"
  1259. memo["invoice_no"] = fapiao_code
  1260. memo["memo"] = "自费"
  1261. bytesData, _ := json.Marshal(memo)
  1262. fsiOPFLD.Memo = string(bytesData)
  1263. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1264. }
  1265. }
  1266. }
  1267. fmt.Println(fsiOPFLDs)
  1268. struct4201A.Fopfd = fsiOPFLDs
  1269. fmt.Println(struct4201A.Fopfd)
  1270. var struct4202 models.Struct4202
  1271. timeLayout := "2006-01-02 15:04:05"
  1272. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  1273. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1274. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1275. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1276. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1277. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1278. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1279. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  1280. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  1281. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1282. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1283. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1284. var config []*models.HisXtDiagnoseConfig
  1285. for _, item := range diagnosis_ids {
  1286. id, _ := strconv.ParseInt(item, 10, 64)
  1287. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1288. config = append(config, &diagnosisConfig)
  1289. }
  1290. var tempDiaginfos []models.OwnPayPatnDiagListD
  1291. for index, item := range config {
  1292. if index == 0 {
  1293. var tempDiaginfo models.OwnPayPatnDiagListD
  1294. tempDiaginfo.InoutDiagType = "1"
  1295. tempDiaginfo.DiagCode = item.CountryCode
  1296. tempDiaginfo.DiagName = item.CountryContentName
  1297. tempDiaginfo.DiagType = "1"
  1298. tempDiaginfo.DiagSrtNo = "1"
  1299. tempDiaginfo.MaindiagFlag = "1"
  1300. tempDiaginfo.ValiFlag = "1"
  1301. tempDiaginfo.DiagDrName = doctor.UserName
  1302. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1303. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1304. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1305. } else {
  1306. var tempDiaginfo models.OwnPayPatnDiagListD
  1307. tempDiaginfo.DiagCode = item.CountryCode
  1308. tempDiaginfo.DiagName = item.CountryContentName
  1309. tempDiaginfo.DiagType = "2"
  1310. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1311. tempDiaginfo.MaindiagFlag = "0"
  1312. tempDiaginfo.ValiFlag = "1"
  1313. tempDiaginfo.DiagDrName = doctor.UserName
  1314. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1315. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1316. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1317. }
  1318. }
  1319. struct4202.ODiagListD = tempDiaginfos
  1320. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  1321. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  1322. var res2 ResultSix
  1323. var respJSON2 map[string]interface{}
  1324. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1327. return
  1328. }
  1329. userJSONBytes2, _ := json.Marshal(respJSON2)
  1330. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1331. utils.ErrorLog("解析失败:%v", err)
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1333. return
  1334. }
  1335. if res2.Infcode != 0 {
  1336. c.ServeSuccessJSON(map[string]interface{}{
  1337. "failed_code": -10,
  1338. "msg": res2.ErrMsg,
  1339. })
  1340. return
  1341. } else {
  1342. order.IsUploadDiagnose = 1
  1343. order.IsUploadOrderInfo = 1
  1344. service.UpdateOrderTwo(order)
  1345. c.ServeSuccessJSON(map[string]interface{}{
  1346. "msg": "上传成功",
  1347. })
  1348. }
  1349. }
  1350. func (c *HisApiController) Get4207() {
  1351. admin_user_id, _ := c.GetInt64("admin_user_id")
  1352. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1353. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1354. order_id, _ := c.GetInt64("order_id")
  1355. order, _ := service.GetHisOrderByIDTwo(order_id)
  1356. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1357. var struct4207 models.Struct4207
  1358. struct4207.PageNum = "1"
  1359. struct4207.PageSize = "1000"
  1360. struct4207.FixmedinsCode = miConfig.Code
  1361. struct4207.FixmedinsMdtrtID = order.Number
  1362. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  1363. saveLog(result, requestLog, "4207", "查询")
  1364. var res2 ResultSix
  1365. var respJSON2 map[string]interface{}
  1366. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. return
  1370. }
  1371. userJSONBytes2, _ := json.Marshal(respJSON2)
  1372. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1373. utils.ErrorLog("解析失败:%v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. if res2.Infcode != 0 {
  1378. c.ServeSuccessJSON(map[string]interface{}{
  1379. "failed_code": -10,
  1380. "msg": res2.ErrMsg,
  1381. })
  1382. return
  1383. } else {
  1384. c.ServeSuccessJSON(map[string]interface{}{
  1385. "msg": "查询成功",
  1386. })
  1387. }
  1388. }
  1389. func (c *HisApiController) Get4208() {
  1390. admin_user_id, _ := c.GetInt64("admin_user_id")
  1391. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1392. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1393. order_id, _ := c.GetInt64("order_id")
  1394. order, _ := service.GetHisOrderByIDTwo(order_id)
  1395. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1396. var struct4208 models.Struct4208
  1397. struct4208.PageNum = "1"
  1398. struct4208.PageSize = "1000"
  1399. struct4208.PsnCertType = "01"
  1400. struct4208.Certno = his.Certno
  1401. struct4208.MedType = order.MedType
  1402. struct4208.PsnName = his.Name
  1403. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  1404. saveLog(result, requestLog, "4208", "查询")
  1405. var res2 ResultSix
  1406. var respJSON2 map[string]interface{}
  1407. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1410. return
  1411. }
  1412. userJSONBytes2, _ := json.Marshal(respJSON2)
  1413. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1414. utils.ErrorLog("解析失败:%v", err)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. return
  1417. }
  1418. if res2.Infcode != 0 {
  1419. c.ServeSuccessJSON(map[string]interface{}{
  1420. "failed_code": -10,
  1421. "msg": res2.ErrMsg,
  1422. })
  1423. return
  1424. } else {
  1425. c.ServeSuccessJSON(map[string]interface{}{
  1426. "msg": "查询成功",
  1427. })
  1428. }
  1429. }
  1430. func (c *HisApiController) Get4209() {
  1431. admin_user_id, _ := c.GetInt64("admin_user_id")
  1432. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1433. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1434. order_id, _ := c.GetInt64("order_id")
  1435. order, _ := service.GetHisOrderByIDTwo(order_id)
  1436. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1437. var struct4209 models.Struct4209
  1438. struct4209.FixmedinsMdtrtID = order.Number
  1439. struct4209.FixmedinsCode = miConfig.Code
  1440. struct4209.PageSize = "1000"
  1441. struct4209.PageNum = "1"
  1442. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  1443. saveLog(result, requestLog, "4209", "查询")
  1444. var res2 ResultSix
  1445. var respJSON2 map[string]interface{}
  1446. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. return
  1450. }
  1451. userJSONBytes2, _ := json.Marshal(respJSON2)
  1452. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1453. utils.ErrorLog("解析失败:%v", err)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. return
  1456. }
  1457. if res2.Infcode != 0 {
  1458. c.ServeSuccessJSON(map[string]interface{}{
  1459. "failed_code": -10,
  1460. "msg": res2.ErrMsg,
  1461. })
  1462. return
  1463. } else {
  1464. c.ServeSuccessJSON(map[string]interface{}{
  1465. "msg": "查询成功",
  1466. })
  1467. }
  1468. }
  1469. type Result3101 struct {
  1470. Infcode string `json:"infcode"`
  1471. InfRefmsgid string `json:"inf_refmsgid"`
  1472. RefmsgTime string `json:"refmsg_time"`
  1473. RespondTime string `json:"respond_time"`
  1474. Enctype string `json:"enctype"`
  1475. Signtype string `json:"signtype"`
  1476. ErrMsg string `json:"err_msg"`
  1477. Output struct {
  1478. Result []struct {
  1479. JudgeResultDetailDtos []struct {
  1480. VolaItemType string `json:"vola_item_type"`
  1481. MdtrtID string `json:"mdtrt_id"`
  1482. JrdID string `json:"jrd_id"`
  1483. PatnID string `json:"patn_id"`
  1484. RxID string `json:"rx_id"`
  1485. VolaAmt interface{} `json:"vola_amt"`
  1486. } `json:"judge_result_detail_dtos"`
  1487. RuleID string `json:"rule_id"`
  1488. VolaEvid string `json:"vola_evid"`
  1489. MdtrtID string `json:"mdtrt_id"`
  1490. RuleName string `json:"rule_name"`
  1491. VolaAmtStas string `json:"vola_amt_stas"`
  1492. JrID string `json:"jr_id"`
  1493. PatnID string `json:"patn_id"`
  1494. SevDeg string `json:"sev_deg"`
  1495. VolaAmt float64 `json:"vola_amt"`
  1496. VolaBhvrType string `json:"vola_bhvr_type"`
  1497. VolaCont string `json:"vola_cont"`
  1498. } `json:"result"`
  1499. } `json:"output"`
  1500. }
  1501. func (c *HisApiController) ReadEleToken() {
  1502. admin_user_id, _ := c.GetInt64("admin_user_id")
  1503. his_patient_id, _ := c.GetInt64("his_patient_id")
  1504. adminUser := c.GetAdminUserInfo()
  1505. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1506. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1507. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1508. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1509. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  1510. if len(tokens) > 0 {
  1511. c.ServeSuccessJSON(map[string]interface{}{
  1512. "msg": "读取成功",
  1513. })
  1514. } else {
  1515. c.ServeSuccessJSON(map[string]interface{}{
  1516. "failed_code": -10,
  1517. "msg": "读取失败",
  1518. })
  1519. }
  1520. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1521. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1522. if len(errMsg) == 0 {
  1523. type ELeData struct {
  1524. Data struct {
  1525. IdNo string `json:"idNo"`
  1526. IdType string `json:"idType"`
  1527. UserName string `json:"userName"`
  1528. EcToken string `json:"ecToken"`
  1529. InsuOrg string `json:"insuOrg"`
  1530. Gender string `json:"gender"`
  1531. Birthday string `json:"birthday"`
  1532. Nationality string `json:"nationality"`
  1533. Email string `json:"email"`
  1534. Extra string `json:"extra"`
  1535. } `json:"data"`
  1536. Code int `json:"code"`
  1537. Message string `json:"message"`
  1538. }
  1539. var ele ELeData
  1540. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1541. if err != nil {
  1542. utils.ErrorLog("解析失败:%v", err)
  1543. }
  1544. token := ele.Data.EcToken
  1545. if len(token) > 0 {
  1546. psn := &models.HisPsn{
  1547. PsnNo: his.PsnNo,
  1548. Age: 0,
  1549. PatientId: his.PatientId,
  1550. Certno: his.Certno,
  1551. Brdy: his.Brdy,
  1552. Gend: his.Gend,
  1553. Naty: his.Naty,
  1554. PsnCertType: his.PsnCertType,
  1555. PsnName: his.PsnName,
  1556. Idetinfo: his.Idetinfo,
  1557. Insuinfo: his.Iinfo,
  1558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1559. CardInfo: outPutInfo,
  1560. VerifyNumber: token,
  1561. }
  1562. service.CreateHisPsn(psn)
  1563. }
  1564. if len(token) > 0 {
  1565. c.ServeSuccessJSON(map[string]interface{}{
  1566. "msg": "读取成功",
  1567. })
  1568. } else {
  1569. c.ServeSuccessJSON(map[string]interface{}{
  1570. "failed_code": -10,
  1571. "msg": "读取失败",
  1572. })
  1573. }
  1574. }
  1575. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1576. if initFlag == 0 {
  1577. c.TestGetJiangXiBasBaseInit()
  1578. }
  1579. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1580. type ELeData struct {
  1581. Data struct {
  1582. IdNo string `json:"idNo"`
  1583. IdType string `json:"idType"`
  1584. UserName string `json:"userName"`
  1585. EcToken string `json:"ecToken"`
  1586. InsuOrg string `json:"insuOrg"`
  1587. Gender string `json:"gender"`
  1588. Birthday string `json:"birthday"`
  1589. Nationality string `json:"nationality"`
  1590. Email string `json:"email"`
  1591. Extra string `json:"extra"`
  1592. } `json:"data"`
  1593. Code int `json:"code"`
  1594. Message string `json:"message"`
  1595. }
  1596. var ele ELeData
  1597. err := json.Unmarshal([]byte(json_result), &ele)
  1598. if err != nil {
  1599. utils.ErrorLog("解析失败:%v", err)
  1600. }
  1601. token := ele.Data.EcToken
  1602. token = Remove0000(token)
  1603. fmt.Println(ele.Data.UserName)
  1604. 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)
  1605. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1606. var res ResultTwo
  1607. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1608. utils.ErrorLog("解析失败:%v", err)
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1610. return
  1611. }
  1612. if res.Infcode == 0 {
  1613. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1614. if err == gorm.ErrRecordNotFound {
  1615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1616. return
  1617. } else if err != nil {
  1618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1619. return
  1620. } else {
  1621. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1622. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1623. infoStr := string(Iinfos)
  1624. idetinfoStr := string(Idetinfos)
  1625. psn := &models.HisPsn{
  1626. PsnNo: res.Output.Baseinfo.PsnNo,
  1627. Age: res.Output.Baseinfo.Age,
  1628. PatientId: patient.ID,
  1629. Certno: res.Output.Baseinfo.Certno,
  1630. Brdy: res.Output.Baseinfo.Brdy,
  1631. Gend: res.Output.Baseinfo.Gend,
  1632. Naty: res.Output.Baseinfo.Naty,
  1633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1634. PsnName: res.Output.Baseinfo.PsnName,
  1635. Idetinfo: idetinfoStr,
  1636. Insuinfo: infoStr,
  1637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1638. CardInfo: "",
  1639. VerifyNumber: token,
  1640. }
  1641. service.CreateHisPsn(psn)
  1642. c.ServeSuccessJSON(map[string]interface{}{
  1643. "patient": patient,
  1644. "number": token,
  1645. })
  1646. }
  1647. } else {
  1648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1649. return
  1650. }
  1651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1652. idNo := c.GetString("idNo")
  1653. userName := c.GetString("userName")
  1654. ecToken := c.GetString("ecToken")
  1655. insuOrg := c.GetString("insuOrg")
  1656. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  1657. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1658. var res ResultTwo
  1659. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1660. utils.ErrorLog("解析失败:%v", err)
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1662. return
  1663. }
  1664. if res.Infcode == 0 {
  1665. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1666. if err == gorm.ErrRecordNotFound {
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1668. return
  1669. } else if err != nil {
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1671. return
  1672. } else {
  1673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1675. infoStr := string(Iinfos)
  1676. idetinfoStr := string(Idetinfos)
  1677. psn := &models.HisPsn{
  1678. PsnNo: res.Output.Baseinfo.PsnNo,
  1679. Age: res.Output.Baseinfo.Age,
  1680. PatientId: patient.ID,
  1681. Certno: res.Output.Baseinfo.Certno,
  1682. Brdy: res.Output.Baseinfo.Brdy,
  1683. Gend: res.Output.Baseinfo.Gend,
  1684. Naty: res.Output.Baseinfo.Naty,
  1685. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1686. PsnName: res.Output.Baseinfo.PsnName,
  1687. Idetinfo: idetinfoStr,
  1688. Insuinfo: infoStr,
  1689. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1690. CardInfo: "",
  1691. VerifyNumber: ecToken,
  1692. InsuplcAdmdvs: insuOrg,
  1693. }
  1694. service.CreateHisPsn(psn)
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "patient": patient,
  1697. "number": ecToken,
  1698. })
  1699. }
  1700. } else {
  1701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1702. return
  1703. }
  1704. } else {
  1705. //if initFlag == 0 {
  1706. // c.TestGetBasBaseInit()
  1707. //}
  1708. //token := c.GetEleBaseInfo()
  1709. //token = Remove0000(token)
  1710. type ELeData struct {
  1711. Code string `json:"code"`
  1712. Data struct {
  1713. Aac002 string `json:"aac002"`
  1714. Aaz500 string `json:"aaz500"`
  1715. ActCardNo string `json:"actCardNo"`
  1716. Bab520 string `json:"bab520"`
  1717. Bkz543 string `json:"bkz543"`
  1718. BusinessType string `json:"businessType"`
  1719. CertfCodg string `json:"certfCodg"`
  1720. EcIndexNo string `json:"ecIndexNo"`
  1721. EcToken string `json:"ecToken"`
  1722. ID0000 string `json:"id0000"`
  1723. IDNo string `json:"idNo"`
  1724. IDType string `json:"idType"`
  1725. Idcode string `json:"idcode"`
  1726. IdentityToken string `json:"identity_token"`
  1727. InsuOrg string `json:"insuOrg"`
  1728. OfficeID string `json:"officeId"`
  1729. OfficeName string `json:"officeName"`
  1730. OperatorID string `json:"operatorId"`
  1731. OperatorName string `json:"operatorName"`
  1732. OrgID string `json:"orgId"`
  1733. UserName string `json:"userName"`
  1734. } `json:"data"`
  1735. Infno interface{} `json:"infno"`
  1736. Message string `json:"message"`
  1737. OrgID string `json:"orgId"`
  1738. TransType string `json:"transType"`
  1739. }
  1740. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  1741. fmt.Println(result)
  1742. outPutInfo := Remove0000(result)
  1743. fmt.Println(outPutInfo)
  1744. var ele ELeData
  1745. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1746. if err != nil {
  1747. utils.ErrorLog("解析失败:%v", err)
  1748. }
  1749. token := ele.Data.EcToken
  1750. if len(token) > 0 {
  1751. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  1752. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1753. var res ResultTwo
  1754. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1755. utils.ErrorLog("解析失败:%v", err)
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1757. return
  1758. }
  1759. if res.Infcode == 0 {
  1760. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1761. if err == gorm.ErrRecordNotFound {
  1762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1763. return
  1764. } else if err != nil {
  1765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1766. return
  1767. } else {
  1768. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1769. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1770. infoStr := string(Iinfos)
  1771. idetinfoStr := string(Idetinfos)
  1772. psn := &models.HisPsn{
  1773. PsnNo: res.Output.Baseinfo.PsnNo,
  1774. Age: res.Output.Baseinfo.Age,
  1775. PatientId: patient.ID,
  1776. Certno: res.Output.Baseinfo.Certno,
  1777. Brdy: res.Output.Baseinfo.Brdy,
  1778. Gend: res.Output.Baseinfo.Gend,
  1779. Naty: res.Output.Baseinfo.Naty,
  1780. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1781. PsnName: res.Output.Baseinfo.PsnName,
  1782. Idetinfo: idetinfoStr,
  1783. Insuinfo: infoStr,
  1784. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1785. CardInfo: "",
  1786. VerifyNumber: token,
  1787. }
  1788. service.CreateHisPsn(psn)
  1789. c.ServeSuccessJSON(map[string]interface{}{
  1790. "msg": "读取成功",
  1791. })
  1792. }
  1793. } else {
  1794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1795. return
  1796. }
  1797. } else {
  1798. c.ServeSuccessJSON(map[string]interface{}{
  1799. "failed_code": -10,
  1800. "msg": "读取失败",
  1801. })
  1802. }
  1803. }
  1804. }
  1805. func (c *HisApiController) Get9001() {
  1806. adminUser := c.GetAdminUserInfo()
  1807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1808. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1809. if miConfig.MdtrtareaAdmvs == "350500" {
  1810. service.GetFjAuthorizationInfo(miConfig.Code)
  1811. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1812. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1813. var dat map[string]interface{}
  1814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1815. fmt.Println(dat)
  1816. } else {
  1817. fmt.Println(err)
  1818. }
  1819. userJSONBytes, _ := json.Marshal(dat)
  1820. var res models.Result9001
  1821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1822. utils.ErrorLog("解析失败:%v", err)
  1823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. return
  1825. }
  1826. } else {
  1827. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1828. var dat map[string]interface{}
  1829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1830. fmt.Println(dat)
  1831. } else {
  1832. fmt.Println(err)
  1833. }
  1834. userJSONBytes, _ := json.Marshal(dat)
  1835. var res models.Result9001
  1836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1837. utils.ErrorLog("解析失败:%v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. return
  1840. }
  1841. }
  1842. }
  1843. 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) {
  1844. var res Result3101
  1845. adminUser := c.GetAdminUserInfo()
  1846. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1847. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1849. //record_time := c.GetString("record_time")
  1850. //trig_scen := c.GetString("trig_scen")
  1851. timeLayout := "2006-01-02"
  1852. loc, _ := time.LoadLocation("Local")
  1853. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1854. if err != nil {
  1855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1856. return res
  1857. }
  1858. recordDateTime := theTime.Unix()
  1859. var patientPrescription models.HisPrescriptionInfo
  1860. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1861. //if patientPrescription.ID == 0 {
  1862. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1863. //}
  1864. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1865. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1866. //
  1867. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1868. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1869. var pp models.PublicParams
  1870. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1871. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1872. pp.FixmedinsName = miConfig.OrgName
  1873. pp.FixmedinsCode = miConfig.Code
  1874. pp.RequestUrl = miConfig.Url
  1875. pp.Cainfo = miConfig.Cainfo
  1876. pp.SecretKey = miConfig.SecretKey
  1877. pp.AccessKey = miConfig.AccessKey
  1878. pp.OpterName = roles.UserName
  1879. var config []*models.HisXtDiagnoseConfig
  1880. for _, item := range diagnosis_ids {
  1881. id, _ := strconv.ParseInt(item, 10, 64)
  1882. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1883. config = append(config, &diagnosisConfig)
  1884. }
  1885. var pd models.PatientDtos
  1886. pd.PatnID = his.PsnNo
  1887. pd.PatnName = his.Name
  1888. pd.Gend = his.Gend
  1889. pd.Brdy = his.Brdy
  1890. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1891. pd.CurrMdtrtID = his.Number
  1892. var fed models.FsiEncounterDtos
  1893. fed.MdtrtID = his.Number
  1894. fed.MedinsID = miConfig.Code
  1895. fed.MedinsName = miConfig.OrgName
  1896. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1897. fed.MedMdtrtType = "1"
  1898. fed.MedinsType = "1"
  1899. fed.MedinsLv = "11"
  1900. tm := time.Unix(his.RecordDate, 0)
  1901. s_tm := tm.Format("2006-01-02 15:04:05")
  1902. fed.AdmDate = s_tm
  1903. fed.DscgDate = s_tm
  1904. fed.DscgMainDiseCodg = config[0].CountryCode
  1905. fed.DscgMainDiseName = config[0].CountryContentName
  1906. //诊断信息
  1907. var fdds []*models.FsiDiagnoseDtos
  1908. for index, item := range config {
  1909. if index == 0 {
  1910. var fdd models.FsiDiagnoseDtos
  1911. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1912. fdd.InoutDiseType = "1"
  1913. fdd.MaindiseFlag = "1"
  1914. fdd.DiseDate = s_tm
  1915. fdd.DiasSrtNo = "1"
  1916. fdd.DiseName = item.CountryContentName
  1917. fdd.DiseCodg = item.CountryCode
  1918. fdds = append(fdds, &fdd)
  1919. } else {
  1920. var fdd models.FsiDiagnoseDtos
  1921. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1922. fdd.InoutDiseType = "1"
  1923. fdd.MaindiseFlag = "1"
  1924. fdd.DiseDate = s_tm
  1925. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1926. fdd.DiseName = item.CountryContentName
  1927. fdd.DiseCodg = item.CountryCode
  1928. fdds = append(fdds, &fdd)
  1929. }
  1930. }
  1931. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1932. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1933. fed.AdmDeptName = department.Name
  1934. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1935. fed.DscgDeptName = department.Name
  1936. fed.MedMdtrtType = "1"
  1937. fed.MedType = "11"
  1938. //if his.Insutype == "390" {
  1939. // fed.MedType = "1402"
  1940. //} else {
  1941. // fed.MedType = "9933"
  1942. //}
  1943. var orders []*models.FsiOrderDtos
  1944. if trig_scen == "2" {
  1945. //处方医嘱信息
  1946. for _, item := range prescriptions {
  1947. for _, subItem := range item.HisDoctorAdviceInfo {
  1948. var order models.FsiOrderDtos
  1949. order.RxID = strconv.FormatInt(item.ID, 10)
  1950. order.Rxno = strconv.FormatInt(item.ID, 10)
  1951. order.LongDrordFlag = "0"
  1952. order.HilistType = "1"
  1953. order.ChrgType = "1"
  1954. order.DrordBhvr = "-"
  1955. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1956. order.HosplistName = subItem.BaseDrugLib.DrugName
  1957. order.HilistLv = "1"
  1958. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1959. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1960. order.HosplistName = subItem.BaseDrugLib.DrugName
  1961. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1962. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1963. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1964. order.OwnpayAmt = ""
  1965. order.SelfpayAmt = ""
  1966. order.Spec = ""
  1967. order.SpecUnt = ""
  1968. order.DrordBegnDate = s_tm
  1969. order.DrordStopDate = ""
  1970. order.DrordDrCodg = "1"
  1971. order.DrordDeptName = department.Name
  1972. order.DrordDrCodg = "1"
  1973. order.DrordDrName = doctor_info.UserName
  1974. order.DrordDrProfttl = ""
  1975. order.CurrDrordFlag = "1"
  1976. orders = append(orders, &order)
  1977. }
  1978. for _, subItem := range item.HisPrescriptionProject {
  1979. if subItem.Type == 2 {
  1980. var order models.FsiOrderDtos
  1981. order.RxID = strconv.FormatInt(item.ID, 10)
  1982. order.Rxno = strconv.FormatInt(item.ID, 10)
  1983. order.LongDrordFlag = "0"
  1984. order.HilistType = "1"
  1985. order.ChrgType = "1"
  1986. order.DrordBhvr = "-"
  1987. order.HilistCode = subItem.HisProject.MedicalCode
  1988. order.HosplistName = subItem.HisProject.ProjectName
  1989. order.HilistLv = "1"
  1990. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1991. order.HosplistCode = subItem.HisProject.MedicalCode
  1992. order.HosplistName = subItem.HisProject.ProjectName
  1993. order.Cnt = subItem.Count
  1994. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1995. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1996. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1997. order.OwnpayAmt = ""
  1998. order.SelfpayAmt = ""
  1999. order.Spec = ""
  2000. order.SpecUnt = ""
  2001. order.DrordBegnDate = s_tm
  2002. order.DrordStopDate = ""
  2003. order.DrordDrCodg = "1"
  2004. order.DrordDeptName = department.Name
  2005. order.DrordDrCodg = "1"
  2006. order.DrordDrName = doctor_info.UserName
  2007. order.DrordDrProfttl = ""
  2008. order.CurrDrordFlag = "1"
  2009. orders = append(orders, &order)
  2010. }
  2011. if subItem.Type == 3 {
  2012. var order models.FsiOrderDtos
  2013. order.RxID = strconv.FormatInt(item.ID, 10)
  2014. order.Rxno = strconv.FormatInt(item.ID, 10)
  2015. order.LongDrordFlag = "0"
  2016. order.HilistType = "1"
  2017. order.ChrgType = "1"
  2018. order.DrordBhvr = "-"
  2019. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2020. order.HosplistName = subItem.GoodInfo.GoodName
  2021. order.HilistLv = "1"
  2022. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2023. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2024. order.HosplistName = subItem.GoodInfo.GoodName
  2025. order.Cnt = subItem.Count
  2026. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2027. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2028. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2029. order.OwnpayAmt = ""
  2030. order.SelfpayAmt = ""
  2031. order.Spec = ""
  2032. order.SpecUnt = ""
  2033. order.DrordBegnDate = s_tm
  2034. order.DrordStopDate = ""
  2035. order.DrordDrCodg = "1"
  2036. order.DrordDeptName = department.Name
  2037. order.DrordDrCodg = "1"
  2038. order.DrordDrName = doctor_info.UserName
  2039. order.DrordDrProfttl = ""
  2040. order.CurrDrordFlag = "1"
  2041. orders = append(orders, &order)
  2042. }
  2043. }
  2044. }
  2045. //处方医嘱信息
  2046. }
  2047. fed.MatnStas = "0"
  2048. fed.MedfeeSumamt = "0"
  2049. fed.OwnpayAmt = "0"
  2050. fed.SelfpayAmt = "0"
  2051. fed.AcctPayamt = "0"
  2052. fed.MaAmt = "0"
  2053. fed.HifpPayamt = "0"
  2054. fed.SetlTotlnum = "1"
  2055. fed.Insutype = his.Insutype
  2056. fed.ReimFlag = "0"
  2057. fed.OutSetlFlag = "0"
  2058. var fopd []*models.FsiOperationDtosData
  2059. data := make(map[string]interface{})
  2060. data["fed"] = fed
  2061. data["fdd"] = fdds
  2062. data["fod"] = orders
  2063. data["pd"] = pd
  2064. data["pp"] = pp
  2065. data["fopd"] = fopd
  2066. data["trig_scen"] = trig_scen
  2067. fmt.Println(data)
  2068. fmt.Println(fed)
  2069. fmt.Println(fdds)
  2070. fmt.Println(orders)
  2071. fmt.Println(pd)
  2072. fmt.Println(pp)
  2073. fmt.Println(fopd)
  2074. client := &http.Client{}
  2075. bytesData, _ := json.Marshal(data)
  2076. var req *http.Request
  2077. if miConfig.MdtrtareaAdmvs == "320921" {
  2078. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2079. } else {
  2080. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2081. }
  2082. resp, _ := client.Do(req)
  2083. defer resp.Body.Close()
  2084. body, ioErr := ioutil.ReadAll(resp.Body)
  2085. if ioErr != nil {
  2086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. return res
  2089. }
  2090. var respJSON map[string]interface{}
  2091. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2094. return res
  2095. }
  2096. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2097. fmt.Println(respJSON)
  2098. result, _ := json.Marshal(respJSON)
  2099. fmt.Println(result)
  2100. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2101. utils.ErrorLog("解析失败:%v", err)
  2102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2103. return res
  2104. }
  2105. return res
  2106. }
  2107. 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) {
  2108. adminUser := c.GetAdminUserInfo()
  2109. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2110. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2112. //record_time := c.GetString("record_time")
  2113. //trig_scen := c.GetString("trig_scen")
  2114. timeLayout := "2006-01-02"
  2115. loc, _ := time.LoadLocation("Local")
  2116. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2117. if err != nil {
  2118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2119. return res
  2120. }
  2121. recordDateTime := theTime.Unix()
  2122. var patientPrescription models.HisPrescriptionInfo
  2123. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2124. if patientPrescription.ID == 0 {
  2125. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2126. }
  2127. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2128. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2129. //
  2130. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2131. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2132. var pp models.PublicParams
  2133. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2134. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2135. pp.FixmedinsName = miConfig.OrgName
  2136. pp.FixmedinsCode = miConfig.Code
  2137. pp.RequestUrl = miConfig.Url
  2138. pp.Cainfo = miConfig.Cainfo
  2139. pp.SecretKey = miConfig.SecretKey
  2140. pp.AccessKey = miConfig.AccessKey
  2141. pp.OpterName = roles.UserName
  2142. var config []*models.HisXtDiagnoseConfig
  2143. for _, item := range diagnosis_ids {
  2144. id, _ := strconv.ParseInt(item, 10, 64)
  2145. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2146. config = append(config, &diagnosisConfig)
  2147. }
  2148. var pd models.PatientDtos
  2149. pd.PatnID = his.PsnNo
  2150. pd.PatnName = his.Name
  2151. pd.Gend = his.Gend
  2152. pd.Brdy = his.Brdy
  2153. pd.Poolarea = his.InsuplcAdmdvs
  2154. pd.CurrMdtrtID = his.Number
  2155. var fed models.FsiEncounterDtos
  2156. fed.MdtrtID = his.Number
  2157. fed.MedinsID = miConfig.Code
  2158. fed.MedinsName = miConfig.OrgName
  2159. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2160. fed.MedMdtrtType = "1"
  2161. fed.MedinsType = "1"
  2162. fed.MedinsLv = "11"
  2163. tm := time.Unix(his.RecordDate, 0)
  2164. s_tm := tm.Format("2006-01-02 15:04:05")
  2165. fed.AdmDate = s_tm
  2166. fed.DscgDate = s_tm
  2167. fed.DscgMainDiseCodg = config[0].CountryCode
  2168. fed.DscgMainDiseName = config[0].CountryContentName
  2169. //诊断信息
  2170. var fdds []*models.FsiDiagnoseDtos
  2171. for index, item := range config {
  2172. if index == 0 {
  2173. var fdd models.FsiDiagnoseDtos
  2174. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2175. fdd.InoutDiseType = "1"
  2176. fdd.MaindiseFlag = "1"
  2177. fdd.DiseDate = s_tm
  2178. fdd.DiasSrtNo = "1"
  2179. fdd.DiseName = item.CountryContentName
  2180. fdd.DiseCodg = item.CountryCode
  2181. fdds = append(fdds, &fdd)
  2182. } else {
  2183. var fdd models.FsiDiagnoseDtos
  2184. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2185. fdd.InoutDiseType = "1"
  2186. fdd.MaindiseFlag = "1"
  2187. fdd.DiseDate = s_tm
  2188. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2189. fdd.DiseName = item.CountryContentName
  2190. fdd.DiseCodg = item.CountryCode
  2191. fdds = append(fdds, &fdd)
  2192. }
  2193. }
  2194. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2195. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2196. fed.AdmDeptName = department.Name
  2197. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2198. fed.DscgDeptName = department.Name
  2199. fed.MedMdtrtType = "1"
  2200. fed.MedType = "11"
  2201. //if his.Insutype == "390" {
  2202. // fed.MedType = "1402"
  2203. //} else {
  2204. // fed.MedType = "9933"
  2205. //}
  2206. var orders []*models.FsiOrderDtos
  2207. if trig_scen == "2" {
  2208. //处方医嘱信息
  2209. for _, item := range prescriptions {
  2210. for _, subItem := range item.HisDoctorAdviceInfo {
  2211. var order models.FsiOrderDtos
  2212. order.RxID = strconv.FormatInt(item.ID, 10)
  2213. order.Rxno = strconv.FormatInt(item.ID, 10)
  2214. order.LongDrordFlag = "0"
  2215. order.HilistType = "1"
  2216. order.ChrgType = "1"
  2217. order.DrordBhvr = "-"
  2218. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2219. order.HosplistName = subItem.BaseDrugLib.DrugName
  2220. order.HilistLv = "1"
  2221. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2222. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2223. order.HosplistName = subItem.BaseDrugLib.DrugName
  2224. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2225. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2226. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2227. order.OwnpayAmt = ""
  2228. order.SelfpayAmt = ""
  2229. order.Spec = ""
  2230. order.SpecUnt = ""
  2231. order.DrordBegnDate = s_tm
  2232. order.DrordStopDate = ""
  2233. order.DrordDrCodg = "1"
  2234. order.DrordDeptName = department.Name
  2235. order.DrordDrCodg = "1"
  2236. order.DrordDrName = doctor_info.UserName
  2237. order.DrordDrProfttl = ""
  2238. order.CurrDrordFlag = "1"
  2239. orders = append(orders, &order)
  2240. }
  2241. for _, subItem := range item.HisPrescriptionProject {
  2242. if subItem.Type == 2 {
  2243. var order models.FsiOrderDtos
  2244. order.RxID = strconv.FormatInt(item.ID, 10)
  2245. order.Rxno = strconv.FormatInt(item.ID, 10)
  2246. order.LongDrordFlag = "0"
  2247. order.HilistType = "1"
  2248. order.ChrgType = "1"
  2249. order.DrordBhvr = "-"
  2250. order.HilistCode = subItem.HisProject.MedicalCode
  2251. order.HosplistName = subItem.HisProject.ProjectName
  2252. order.HilistLv = "1"
  2253. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2254. order.HosplistCode = subItem.HisProject.MedicalCode
  2255. order.HosplistName = subItem.HisProject.ProjectName
  2256. order.Cnt = subItem.Count
  2257. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2258. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2259. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2260. order.OwnpayAmt = ""
  2261. order.SelfpayAmt = ""
  2262. order.Spec = ""
  2263. order.SpecUnt = ""
  2264. order.DrordBegnDate = s_tm
  2265. order.DrordStopDate = ""
  2266. order.DrordDrCodg = "1"
  2267. order.DrordDeptName = department.Name
  2268. order.DrordDrCodg = "1"
  2269. order.DrordDrName = doctor_info.UserName
  2270. order.DrordDrProfttl = ""
  2271. order.CurrDrordFlag = "1"
  2272. orders = append(orders, &order)
  2273. }
  2274. if subItem.Type == 3 {
  2275. var order models.FsiOrderDtos
  2276. order.RxID = strconv.FormatInt(item.ID, 10)
  2277. order.Rxno = strconv.FormatInt(item.ID, 10)
  2278. order.LongDrordFlag = "0"
  2279. order.HilistType = "1"
  2280. order.ChrgType = "1"
  2281. order.DrordBhvr = "-"
  2282. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2283. order.HosplistName = subItem.GoodInfo.GoodName
  2284. order.HilistLv = "1"
  2285. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2286. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2287. order.HosplistName = subItem.GoodInfo.GoodName
  2288. order.Cnt = subItem.Count
  2289. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2290. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2291. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2292. order.OwnpayAmt = ""
  2293. order.SelfpayAmt = ""
  2294. order.Spec = ""
  2295. order.SpecUnt = ""
  2296. order.DrordBegnDate = s_tm
  2297. order.DrordStopDate = ""
  2298. order.DrordDrCodg = "1"
  2299. order.DrordDeptName = department.Name
  2300. order.DrordDrCodg = "1"
  2301. order.DrordDrName = doctor_info.UserName
  2302. order.DrordDrProfttl = ""
  2303. order.CurrDrordFlag = "1"
  2304. orders = append(orders, &order)
  2305. }
  2306. }
  2307. }
  2308. //处方医嘱信息
  2309. }
  2310. fed.MatnStas = "0"
  2311. fed.MedfeeSumamt = "0"
  2312. fed.OwnpayAmt = "0"
  2313. fed.SelfpayAmt = "0"
  2314. fed.AcctPayamt = "0"
  2315. fed.MaAmt = "0"
  2316. fed.HifpPayamt = "0"
  2317. fed.SetlTotlnum = "1"
  2318. fed.Insutype = his.Insutype
  2319. fed.ReimFlag = "0"
  2320. fed.OutSetlFlag = "0"
  2321. var fopd []*models.FsiOperationDtosData
  2322. data := make(map[string]interface{})
  2323. data["fed"] = fed
  2324. data["fdd"] = fdds
  2325. data["fod"] = orders
  2326. data["pd"] = pd
  2327. data["pp"] = pp
  2328. data["fopd"] = fopd
  2329. data["trig_scen"] = trig_scen
  2330. fmt.Println(data)
  2331. fmt.Println(fed)
  2332. fmt.Println(fdds)
  2333. fmt.Println(orders)
  2334. fmt.Println(pd)
  2335. fmt.Println(pp)
  2336. fmt.Println(fopd)
  2337. client := &http.Client{}
  2338. bytesData, _ := json.Marshal(data)
  2339. var req *http.Request
  2340. if miConfig.MdtrtareaAdmvs == "320921" {
  2341. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2342. } else {
  2343. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2344. }
  2345. resp, _ := client.Do(req)
  2346. defer resp.Body.Close()
  2347. body, ioErr := ioutil.ReadAll(resp.Body)
  2348. if ioErr != nil {
  2349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2351. return res
  2352. }
  2353. var respJSON map[string]interface{}
  2354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2357. return res
  2358. }
  2359. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2360. result, _ := json.Marshal(respJSON)
  2361. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2362. utils.ErrorLog("解析失败:%v", err)
  2363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2364. return res
  2365. }
  2366. return res
  2367. }
  2368. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  2369. ////patient_id, _ := c.GetInt64("patient_id")
  2370. //order_id, _ := c.GetInt64("order_id")
  2371. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  2372. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  2373. //trig_scen := c.GetString("trig_scen")
  2374. adminUser := c.GetAdminUserInfo()
  2375. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2376. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2378. record_time := c.GetString("record_time")
  2379. order, _ := service.GetHisOrderByID(order_id)
  2380. timeLayout := "2006-01-02"
  2381. loc, _ := time.LoadLocation("Local")
  2382. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2383. if err != nil {
  2384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2385. return
  2386. }
  2387. recordDateTime := theTime.Unix()
  2388. var patientPrescription models.HisPrescriptionInfo
  2389. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2390. if patientPrescription.ID == 0 {
  2391. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2392. }
  2393. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2394. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2395. //
  2396. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2397. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2398. var pp models.PublicParams
  2399. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2400. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2401. pp.FixmedinsName = miConfig.OrgName
  2402. pp.FixmedinsCode = miConfig.Code
  2403. pp.RequestUrl = miConfig.Url
  2404. pp.Cainfo = miConfig.Cainfo
  2405. pp.SecretKey = miConfig.SecretKey
  2406. pp.AccessKey = miConfig.AccessKey
  2407. pp.OpterName = roles.UserName
  2408. var config []*models.HisXtDiagnoseConfig
  2409. for _, item := range diagnosis_ids {
  2410. id, _ := strconv.ParseInt(item, 10, 64)
  2411. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2412. config = append(config, &diagnosisConfig)
  2413. }
  2414. var pd models.PatientDtos
  2415. pd.PatnID = his.PsnNo
  2416. pd.PatnName = his.Name
  2417. pd.Gend = his.Gend
  2418. pd.Brdy = his.Brdy
  2419. pd.Poolarea = his.InsuplcAdmdvs
  2420. pd.CurrMdtrtID = his.Number
  2421. var fed models.FsiEncounterDtos
  2422. fed.MdtrtID = his.Number
  2423. fed.MedinsID = miConfig.Code
  2424. fed.MedinsName = miConfig.OrgName
  2425. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2426. fed.MedMdtrtType = "1"
  2427. fed.MedinsType = "1"
  2428. fed.MedinsLv = "11"
  2429. tm := time.Unix(his.RecordDate, 0)
  2430. s_tm := tm.Format("2006-01-02 15:04:05")
  2431. fed.AdmDate = s_tm
  2432. fed.DscgDate = s_tm
  2433. fed.DscgMainDiseCodg = config[0].CountryCode
  2434. fed.DscgMainDiseName = config[0].CountryContentName
  2435. //诊断信息
  2436. var fdds []*models.FsiDiagnoseDtos
  2437. for index, item := range config {
  2438. if index == 0 {
  2439. var fdd models.FsiDiagnoseDtos
  2440. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2441. fdd.InoutDiseType = "1"
  2442. fdd.MaindiseFlag = "1"
  2443. fdd.DiseDate = s_tm
  2444. fdd.DiasSrtNo = "1"
  2445. fdd.DiseName = item.CountryContentName
  2446. fdd.DiseCodg = item.CountryCode
  2447. fdds = append(fdds, &fdd)
  2448. } else {
  2449. var fdd models.FsiDiagnoseDtos
  2450. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2451. fdd.InoutDiseType = "1"
  2452. fdd.MaindiseFlag = "1"
  2453. fdd.DiseDate = s_tm
  2454. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2455. fdd.DiseName = item.CountryContentName
  2456. fdd.DiseCodg = item.CountryCode
  2457. fdds = append(fdds, &fdd)
  2458. }
  2459. }
  2460. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2461. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2462. fed.AdmDeptName = department.Name
  2463. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2464. fed.DscgDeptName = department.Name
  2465. fed.MedType = order.MedType
  2466. //处方医嘱信息
  2467. var orders []*models.FsiOrderDtos
  2468. //for _, item := range prescriptions {
  2469. // for _, subItem := range item.HisDoctorAdviceInfo {
  2470. // var order models.FsiOrderDtos
  2471. // order.RxID = strconv.FormatInt(item.ID, 10)
  2472. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2473. // order.LongDrordFlag = "0"
  2474. // order.HilistType = "1"
  2475. // order.ChrgType = "1"
  2476. // order.DrordBhvr = "-"
  2477. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2478. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2479. // order.HilistLv = "1"
  2480. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2481. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2482. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2483. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  2484. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2485. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  2486. // order.OwnpayAmt = ""
  2487. // order.SelfpayAmt = ""
  2488. // order.Spec = ""
  2489. // order.SpecUnt = ""
  2490. // order.DrordBegnDate = s_tm
  2491. // order.DrordStopDate = ""
  2492. // order.DrordDrCodg = "1"
  2493. // order.DrordDeptName = department.Name
  2494. // order.DrordDrCodg = "1"
  2495. // order.DrordDrName = doctor_info.UserName
  2496. // order.DrordDrProfttl = ""
  2497. // order.CurrDrordFlag = "1"
  2498. // orders = append(orders, &order)
  2499. // }
  2500. // for _, subItem := range item.HisPrescriptionProject {
  2501. // if subItem.Type == 2 {
  2502. // var order models.FsiOrderDtos
  2503. // order.RxID = strconv.FormatInt(item.ID, 10)
  2504. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2505. // order.LongDrordFlag = "0"
  2506. // order.HilistType = "1"
  2507. // order.ChrgType = "1"
  2508. // order.DrordBhvr = "-"
  2509. // order.HilistCode = subItem.HisProject.MedicalCode
  2510. // order.HosplistName = subItem.HisProject.ProjectName
  2511. // order.HilistLv = "1"
  2512. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2513. // order.HosplistCode = subItem.HisProject.MedicalCode
  2514. // order.HosplistName = subItem.HisProject.ProjectName
  2515. // order.Cnt = subItem.Count
  2516. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2517. //
  2518. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2519. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2520. // order.OwnpayAmt = ""
  2521. // order.SelfpayAmt = ""
  2522. // order.Spec = ""
  2523. // order.SpecUnt = ""
  2524. // order.DrordBegnDate = s_tm
  2525. // order.DrordStopDate = ""
  2526. // order.DrordDrCodg = "1"
  2527. // order.DrordDeptName = department.Name
  2528. // order.DrordDrCodg = "1"
  2529. // order.DrordDrName = doctor_info.UserName
  2530. // order.DrordDrProfttl = ""
  2531. // order.CurrDrordFlag = "1"
  2532. // orders = append(orders, &order)
  2533. //
  2534. // }
  2535. // if subItem.Type == 3 {
  2536. //
  2537. // var order models.FsiOrderDtos
  2538. // order.RxID = strconv.FormatInt(item.ID, 10)
  2539. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2540. // order.LongDrordFlag = "0"
  2541. // order.HilistType = "1"
  2542. // order.ChrgType = "1"
  2543. // order.DrordBhvr = "-"
  2544. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2545. // order.HosplistName = subItem.GoodInfo.GoodName
  2546. // order.HilistLv = "1"
  2547. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2548. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2549. // order.HosplistName = subItem.GoodInfo.GoodName
  2550. // order.Cnt = subItem.Count
  2551. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2552. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2553. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2554. // order.OwnpayAmt = ""
  2555. // order.SelfpayAmt = ""
  2556. // order.Spec = ""
  2557. // order.SpecUnt = ""
  2558. // order.DrordBegnDate = s_tm
  2559. // order.DrordStopDate = ""
  2560. // order.DrordDrCodg = "1"
  2561. // order.DrordDeptName = department.Name
  2562. // order.DrordDrCodg = "1"
  2563. // order.DrordDrName = doctor_info.UserName
  2564. // order.DrordDrProfttl = ""
  2565. // order.CurrDrordFlag = "1"
  2566. // orders = append(orders, &order)
  2567. //
  2568. // }
  2569. // }
  2570. //}
  2571. for _, item := range prescriptions {
  2572. for _, subItem := range item.HisDoctorAdviceInfo {
  2573. var order models.FsiOrderDtos
  2574. order.RxID = strconv.FormatInt(item.ID, 10)
  2575. order.Rxno = strconv.FormatInt(item.ID, 10)
  2576. order.LongDrordFlag = "0"
  2577. order.HilistType = "1"
  2578. order.ChrgType = "1"
  2579. order.DrordBhvr = "-"
  2580. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2581. order.HosplistName = subItem.BaseDrugLib.DrugName
  2582. order.HilistLv = "1"
  2583. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2584. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2585. order.HosplistName = subItem.BaseDrugLib.DrugName
  2586. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2587. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2588. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2589. order.OwnpayAmt = ""
  2590. order.SelfpayAmt = ""
  2591. order.Spec = ""
  2592. order.SpecUnt = ""
  2593. order.DrordBegnDate = s_tm
  2594. order.DrordStopDate = ""
  2595. order.DrordDrCodg = "1"
  2596. order.DrordDeptName = department.Name
  2597. order.DrordDrCodg = "1"
  2598. order.DrordDrName = doctor_info.UserName
  2599. order.DrordDrProfttl = ""
  2600. order.CurrDrordFlag = "1"
  2601. orders = append(orders, &order)
  2602. }
  2603. for _, subItem := range item.HisPrescriptionProject {
  2604. if subItem.Type == 2 {
  2605. var order models.FsiOrderDtos
  2606. order.RxID = strconv.FormatInt(item.ID, 10)
  2607. order.Rxno = strconv.FormatInt(item.ID, 10)
  2608. order.LongDrordFlag = "0"
  2609. order.HilistType = "1"
  2610. order.ChrgType = "1"
  2611. order.DrordBhvr = "-"
  2612. order.HilistCode = subItem.HisProject.MedicalCode
  2613. order.HosplistName = subItem.HisProject.ProjectName
  2614. order.HilistLv = "1"
  2615. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2616. order.HosplistCode = subItem.HisProject.MedicalCode
  2617. order.HosplistName = subItem.HisProject.ProjectName
  2618. order.Cnt = subItem.Count
  2619. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2620. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2621. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2622. order.OwnpayAmt = ""
  2623. order.SelfpayAmt = ""
  2624. order.Spec = ""
  2625. order.SpecUnt = ""
  2626. order.DrordBegnDate = s_tm
  2627. order.DrordStopDate = ""
  2628. order.DrordDrCodg = "1"
  2629. order.DrordDeptName = department.Name
  2630. order.DrordDrCodg = "1"
  2631. order.DrordDrName = doctor_info.UserName
  2632. order.DrordDrProfttl = ""
  2633. order.CurrDrordFlag = "1"
  2634. orders = append(orders, &order)
  2635. }
  2636. if subItem.Type == 3 {
  2637. var order models.FsiOrderDtos
  2638. order.RxID = strconv.FormatInt(item.ID, 10)
  2639. order.Rxno = strconv.FormatInt(item.ID, 10)
  2640. order.LongDrordFlag = "0"
  2641. order.HilistType = "1"
  2642. order.ChrgType = "1"
  2643. order.DrordBhvr = "-"
  2644. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2645. order.HosplistName = subItem.GoodInfo.GoodName
  2646. order.HilistLv = "1"
  2647. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2648. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2649. order.HosplistName = subItem.GoodInfo.GoodName
  2650. order.Cnt = subItem.Count
  2651. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2652. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2653. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2654. order.OwnpayAmt = ""
  2655. order.SelfpayAmt = ""
  2656. order.Spec = ""
  2657. order.SpecUnt = ""
  2658. order.DrordBegnDate = s_tm
  2659. order.DrordStopDate = ""
  2660. order.DrordDrCodg = "1"
  2661. order.DrordDeptName = department.Name
  2662. order.DrordDrCodg = "1"
  2663. order.DrordDrName = doctor_info.UserName
  2664. order.DrordDrProfttl = ""
  2665. order.CurrDrordFlag = "1"
  2666. orders = append(orders, &order)
  2667. }
  2668. }
  2669. }
  2670. //处方医嘱信息
  2671. fed.MatnStas = "0"
  2672. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2673. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2674. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2675. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2676. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2677. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2678. fed.SetlTotlnum = "1"
  2679. fed.Insutype = his.Insutype
  2680. fed.ReimFlag = "0"
  2681. fed.OutSetlFlag = "0"
  2682. var fopd []*models.FsiOperationDtosData
  2683. data := make(map[string]interface{})
  2684. data["fed"] = fed
  2685. data["fdd"] = fdds
  2686. data["fod"] = orders
  2687. data["pd"] = pd
  2688. data["pp"] = pp
  2689. data["fopd"] = fopd
  2690. data["trig_scen"] = trig_scen
  2691. client := &http.Client{}
  2692. bytesData, _ := json.Marshal(data)
  2693. var req *http.Request
  2694. if miConfig.MdtrtareaAdmvs == "320921" {
  2695. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2696. } else {
  2697. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2698. }
  2699. resp, _ := client.Do(req)
  2700. defer resp.Body.Close()
  2701. body, ioErr := ioutil.ReadAll(resp.Body)
  2702. if ioErr != nil {
  2703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2705. return res
  2706. }
  2707. var respJSON map[string]interface{}
  2708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2711. return res
  2712. }
  2713. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2714. result, _ := json.Marshal(respJSON)
  2715. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2716. utils.ErrorLog("解析失败:%v", err)
  2717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. return res
  2719. }
  2720. return res
  2721. //手术操作集合
  2722. //手术操作集合
  2723. }
  2724. func (c *HisApiController) Check() {
  2725. psn_no := c.GetString("psn_no")
  2726. in := c.GetString("in")
  2727. mt := c.GetString("mt")
  2728. baseParams := models.BaseParams{
  2729. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2730. FixmedinsCode: "H15049901371",
  2731. InsuplcAdmdvs: "150499",
  2732. MdtrtareaAdmvs: "150499",
  2733. OrgName: "赤峰费森血液透析中心",
  2734. Doctor: "1111",
  2735. }
  2736. service.Gdyb2001(baseParams, psn_no, in, mt)
  2737. }
  2738. func (c *HisApiController) GetPsnNcdsInfo() {
  2739. admin_user_id, _ := c.GetInt64("admin_user_id")
  2740. patient_id, _ := c.GetInt64("patient_id")
  2741. id, _ := c.GetInt64("id")
  2742. adminUser := c.GetAdminUserInfo()
  2743. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2744. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2745. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2746. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2747. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2748. //
  2749. //if psn_record.ID == 0 {
  2750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2751. // return
  2752. //}
  2753. var res Result5301
  2754. var res10265 Result5301For10265
  2755. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2756. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2757. var api string
  2758. if miConfig.MdtrtareaAdmvs == "320921" {
  2759. api = "http://192.168.2.3:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2760. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2761. } else {
  2762. 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 +
  2763. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2764. }
  2765. resp, requestErr := http.Get(api)
  2766. if requestErr != nil {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2768. return
  2769. }
  2770. body, ioErr := ioutil.ReadAll(resp.Body)
  2771. if ioErr != nil {
  2772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2774. return
  2775. }
  2776. var respJSON map[string]interface{}
  2777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2780. return
  2781. }
  2782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2783. result, _ := json.Marshal(respJSON)
  2784. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2785. utils.ErrorLog("解析失败:%v", err)
  2786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2787. return
  2788. }
  2789. res.ErrMsg = res10265.ErrMsg
  2790. res.Output = res10265.Output
  2791. res.InfRefmsgid = res10265.InfRefmsgid
  2792. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2793. res.Infcode = infocode
  2794. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2795. p, _ := service.GetHisPatientById(patient_id)
  2796. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2797. var dat map[string]interface{}
  2798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2799. fmt.Println(dat)
  2800. } else {
  2801. fmt.Println(err)
  2802. }
  2803. userJSONBytes, _ := json.Marshal(dat)
  2804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2805. utils.ErrorLog("解析失败:%v", err)
  2806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. return
  2808. }
  2809. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2810. p, _ := service.GetHisPatientById(patient_id)
  2811. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2812. var dat map[string]interface{}
  2813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2814. fmt.Println(dat)
  2815. } else {
  2816. fmt.Println(err)
  2817. }
  2818. userJSONBytes, _ := json.Marshal(dat)
  2819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. } else {
  2825. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2826. var dat map[string]interface{}
  2827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2828. fmt.Println(dat)
  2829. } else {
  2830. fmt.Println(err)
  2831. }
  2832. userJSONBytes, _ := json.Marshal(dat)
  2833. if miConfig.Code == "H15049901371" {
  2834. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2835. utils.ErrorLog("解析失败:%v", err)
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2837. return
  2838. }
  2839. res.InfRefmsgid = res10265.InfRefmsgid
  2840. res.Output = res10265.Output
  2841. res.ErrMsg = res10265.ErrMsg
  2842. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2843. res.Infcode = infocode
  2844. } else {
  2845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2846. utils.ErrorLog("解析失败:%v", err)
  2847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2848. return
  2849. }
  2850. }
  2851. }
  2852. if res.Infcode == 0 {
  2853. c.ServeSuccessJSON(map[string]interface{}{
  2854. "result": res.Output.Result,
  2855. })
  2856. }
  2857. }
  2858. func (c *HisApiController) CheckInsutype() {
  2859. his_patient_id, _ := c.GetInt64("his_patient_id")
  2860. admin_user_id, _ := c.GetInt64("admin_user_id")
  2861. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2862. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2863. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2864. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2865. var dat map[string]interface{}
  2866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2867. fmt.Println(dat)
  2868. } else {
  2869. fmt.Println(err)
  2870. }
  2871. userJSONBytes, _ := json.Marshal(dat)
  2872. var res Result90100
  2873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2874. utils.ErrorLog("解析失败:%v", err)
  2875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2876. return
  2877. }
  2878. if res.Infcode != 0 {
  2879. c.ServeSuccessJSON(map[string]interface{}{
  2880. "failed_code": -10,
  2881. "msg": res.ErrMsg,
  2882. })
  2883. return
  2884. } else {
  2885. fmt.Println(res)
  2886. }
  2887. }
  2888. func (c *HisApiController) CheckCardPWD() {
  2889. card_pwd := c.GetString("card_pwd")
  2890. his_patient_id, _ := c.GetInt64("his_patient_id")
  2891. admin_user_id, _ := c.GetInt64("admin_user_id")
  2892. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2893. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2894. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2895. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2896. bas := strings.Split(psn.CardInfo, "|")
  2897. basNumber := bas[2]
  2898. if psn.InsuplcAdmdvs[:4] == "4403" {
  2899. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2900. var dat map[string]interface{}
  2901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2902. fmt.Println(dat)
  2903. } else {
  2904. fmt.Println(err)
  2905. }
  2906. userJSONBytes, _ := json.Marshal(dat)
  2907. var res Result90991
  2908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2909. utils.ErrorLog("解析失败:%v", err)
  2910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. return
  2912. }
  2913. if res.Infcode != 0 {
  2914. c.ServeSuccessJSON(map[string]interface{}{
  2915. "failed_code": -10,
  2916. "msg": res.ErrMsg,
  2917. })
  2918. return
  2919. } else {
  2920. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2921. var msg string
  2922. switch res.Output.Result.CardStat {
  2923. case "00":
  2924. msg = "未激活"
  2925. break
  2926. case "10":
  2927. msg = "激活"
  2928. break
  2929. case "20":
  2930. msg = "窗口挂失"
  2931. break
  2932. case "21":
  2933. msg = "电话挂失"
  2934. break
  2935. case "22":
  2936. msg = "单位网上申报挂失"
  2937. break
  2938. case "23":
  2939. msg = "保健办挂失"
  2940. break
  2941. case "24":
  2942. msg = "个人网上挂失"
  2943. break
  2944. case "25":
  2945. msg = "网上服务大厅挂失"
  2946. break
  2947. case "30":
  2948. msg = "注销"
  2949. break
  2950. case "40":
  2951. msg = "回收"
  2952. break
  2953. case "99":
  2954. msg = "制卡中(无效卡)"
  2955. break
  2956. }
  2957. c.ServeSuccessJSON(map[string]interface{}{
  2958. "failed_code": -10,
  2959. "msg": msg,
  2960. })
  2961. return
  2962. } else {
  2963. c.ServeSuccessJSON(map[string]interface{}{
  2964. "msg": "校验成功",
  2965. })
  2966. return
  2967. }
  2968. }
  2969. } else {
  2970. c.ServeSuccessJSON(map[string]interface{}{
  2971. "msg": "校验成功",
  2972. })
  2973. return
  2974. }
  2975. }
  2976. func (c *HisApiController) CheckCardPWDTwo() {
  2977. //card_pwd := c.GetString("card_pwd")
  2978. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2979. admin_user_id, _ := c.GetInt64("admin_user_id")
  2980. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2982. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2983. var dat map[string]interface{}
  2984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2985. fmt.Println(dat)
  2986. } else {
  2987. fmt.Println(err)
  2988. }
  2989. userJSONBytes, _ := json.Marshal(dat)
  2990. var res Result90991
  2991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2992. utils.ErrorLog("解析失败:%v", err)
  2993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2994. return
  2995. }
  2996. if res.Infcode != 0 {
  2997. c.ServeSuccessJSON(map[string]interface{}{
  2998. "failed_code": -10,
  2999. "msg": res.ErrMsg,
  3000. })
  3001. return
  3002. } else {
  3003. if res.Output.Result.SscnoCheckStat == "0" {
  3004. var msg string
  3005. switch res.Output.Result.CardStat {
  3006. case "00":
  3007. msg = "未激活"
  3008. break
  3009. case "10":
  3010. msg = "激活"
  3011. break
  3012. case "20":
  3013. msg = "窗口挂失"
  3014. break
  3015. case "21":
  3016. msg = "电话挂失"
  3017. break
  3018. case "22":
  3019. msg = "单位网上申报挂失"
  3020. break
  3021. case "23":
  3022. msg = "保健办挂失"
  3023. break
  3024. case "24":
  3025. msg = "个人网上挂失"
  3026. break
  3027. case "25":
  3028. msg = "网上服务大厅挂失"
  3029. break
  3030. case "30":
  3031. msg = "注销"
  3032. break
  3033. case "40":
  3034. msg = "回收"
  3035. break
  3036. case "99":
  3037. msg = "制卡中(无效卡)"
  3038. break
  3039. }
  3040. c.ServeSuccessJSON(map[string]interface{}{
  3041. "failed_code": -10,
  3042. "msg": msg,
  3043. })
  3044. return
  3045. } else {
  3046. c.ServeSuccessJSON(map[string]interface{}{
  3047. "msg": "校验成功",
  3048. })
  3049. return
  3050. }
  3051. }
  3052. }
  3053. type ELeCertData struct {
  3054. Data struct {
  3055. Extra string `json:"extra"`
  3056. IDNo string `json:"idNo"`
  3057. IDType string `json:"idType"`
  3058. EcToken string `json:"ecToken"`
  3059. InsuOrg string `json:"insuOrg"`
  3060. UserName string `json:"userName"`
  3061. EcIndexNo string `json:"ecIndexNo"`
  3062. Gender string `json:"gender"`
  3063. Birthday string `json:"birthday"`
  3064. Nationality string `json:"nationality"`
  3065. Email string `json:"email"`
  3066. } `json:"OutData"`
  3067. }
  3068. func (c *HisApiController) ReadCard() {
  3069. id_card_type, _ := c.GetInt64("id_card_type")
  3070. admin_user_id, _ := c.GetInt64("admin_user_id")
  3071. certificates, _ := c.GetInt64("certificates")
  3072. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  3073. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3074. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3075. switch id_card_type {
  3076. case 1:
  3077. if miConfig.MdtrtareaAdmvs == "421300" {
  3078. var res ResultTwo
  3079. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  3080. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3081. "&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)
  3082. resp, requestErr := http.Get(api)
  3083. if requestErr != nil {
  3084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3085. return
  3086. }
  3087. body, ioErr := ioutil.ReadAll(resp.Body)
  3088. if ioErr != nil {
  3089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3091. return
  3092. }
  3093. var respJSON map[string]interface{}
  3094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3100. result, _ := json.Marshal(respJSON)
  3101. fmt.Println("log")
  3102. fmt.Println(string(result))
  3103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. if res.Infcode == 0 {
  3109. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3110. if err == gorm.ErrRecordNotFound {
  3111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3112. return
  3113. } else if err != nil {
  3114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3115. return
  3116. } else {
  3117. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3118. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3119. infoStr := string(Iinfos)
  3120. idetinfoStr := string(Idetinfos)
  3121. psn := &models.HisPsn{
  3122. PsnNo: res.Output.Baseinfo.PsnNo,
  3123. Age: res.Output.Baseinfo.Age,
  3124. PatientId: patient.ID,
  3125. Certno: res.Output.Baseinfo.Certno,
  3126. Brdy: res.Output.Baseinfo.Brdy,
  3127. Gend: res.Output.Baseinfo.Gend,
  3128. Naty: res.Output.Baseinfo.Naty,
  3129. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3130. PsnName: res.Output.Baseinfo.PsnName,
  3131. Idetinfo: idetinfoStr,
  3132. Insuinfo: infoStr,
  3133. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3134. }
  3135. service.CreateHisPsn(psn)
  3136. c.ServeSuccessJSON(map[string]interface{}{
  3137. "patient": patient,
  3138. "number": res.Output.Baseinfo.Certno,
  3139. })
  3140. }
  3141. } else {
  3142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3143. return
  3144. }
  3145. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3146. var api string
  3147. if miConfig.MdtrtareaAdmvs == "320921" {
  3148. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3149. "&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
  3150. fmt.Println(api)
  3151. } else {
  3152. 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 +
  3153. "&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)
  3154. }
  3155. resp, requestErr := http.Get(api)
  3156. if requestErr != nil {
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3158. return
  3159. }
  3160. body, ioErr := ioutil.ReadAll(resp.Body)
  3161. if ioErr != nil {
  3162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. var respJSON map[string]interface{}
  3167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3170. return
  3171. }
  3172. var status string
  3173. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3174. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3175. //console.log()
  3176. fmt.Println("type===")
  3177. fmt.Println(card_type)
  3178. var token string
  3179. var res ResultTwo //1101结果
  3180. var res10265 ResultTwo10265 //1101结果
  3181. var card_info string //卡信息
  3182. var busi_card_info string
  3183. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3184. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3185. if status == "0" { //读卡成功
  3186. if card_type == "1" {
  3187. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3188. result, _ := json.Marshal(respJSON)
  3189. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3190. utils.ErrorLog("解析失败:%v", err)
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. return
  3193. }
  3194. res.ErrMsg = res10265.ErrMsg
  3195. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3196. res.Infcode = infocode
  3197. res.Output = res10265.Output
  3198. res.InfRefmsgid = res10265.InfRefmsgid
  3199. } else {
  3200. //var card_info string //卡信息
  3201. //var busi_card_info string
  3202. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3203. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3204. //fmt.Println(card_info)
  3205. //fmt.Println(busi_card_info)
  3206. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3207. result, _ := json.Marshal(respJSON)
  3208. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3209. utils.ErrorLog("解析失败:%v", err)
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3211. return
  3212. }
  3213. res.ErrMsg = res10265.ErrMsg
  3214. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3215. res.Infcode = infocode
  3216. res.Output = res10265.Output
  3217. res.InfRefmsgid = res10265.InfRefmsgid
  3218. }
  3219. if res.Infcode == 0 {
  3220. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3221. if err == gorm.ErrRecordNotFound {
  3222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3223. return
  3224. } else if err != nil {
  3225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3226. return
  3227. } else {
  3228. if card_type == "1" {
  3229. bas := strings.Split(card_info, "|")
  3230. basNumber := bas[2]
  3231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3233. infoStr := string(Iinfos)
  3234. idetinfoStr := string(Idetinfos)
  3235. psn := &models.HisPsn{
  3236. PsnNo: res.Output.Baseinfo.PsnNo,
  3237. Age: res.Output.Baseinfo.Age,
  3238. PatientId: patient.ID,
  3239. Certno: res.Output.Baseinfo.Certno,
  3240. Brdy: res.Output.Baseinfo.Brdy,
  3241. Gend: res.Output.Baseinfo.Gend,
  3242. Naty: res.Output.Baseinfo.Naty,
  3243. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3244. PsnName: res.Output.Baseinfo.PsnName,
  3245. Idetinfo: idetinfoStr,
  3246. Insuinfo: infoStr,
  3247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3248. CardInfo: card_info,
  3249. VerifyNumber: busi_card_info,
  3250. }
  3251. service.CreateHisPsn(psn)
  3252. var rf []*ResultFive
  3253. json.Unmarshal([]byte(infoStr), &rf)
  3254. var insutypes []*ResultFive
  3255. var insutype string
  3256. var is390 int = 0
  3257. var is310 int = 0
  3258. for _, item := range rf {
  3259. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3260. insutypes = append(insutypes, item)
  3261. }
  3262. }
  3263. if len(insutypes) == 1 {
  3264. insutype = insutypes[0].Insutype
  3265. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3266. } else {
  3267. for _, i := range insutypes {
  3268. if i.Insutype == "390" {
  3269. is390 = 1
  3270. }
  3271. if i.Insutype == "310" {
  3272. is310 = 1
  3273. }
  3274. }
  3275. }
  3276. if is390 == 1 {
  3277. insutype = "390"
  3278. }
  3279. if is310 == 1 {
  3280. insutype = "310"
  3281. }
  3282. if len(insutypes) == 0 {
  3283. insutype = "310"
  3284. }
  3285. c.ServeSuccessJSON(map[string]interface{}{
  3286. "patient": patient,
  3287. "number": basNumber,
  3288. "insutype": insutype,
  3289. })
  3290. } else {
  3291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3293. infoStr := string(Iinfos)
  3294. idetinfoStr := string(Idetinfos)
  3295. psn := &models.HisPsn{
  3296. PsnNo: res.Output.Baseinfo.PsnNo,
  3297. Age: res.Output.Baseinfo.Age,
  3298. PatientId: patient.ID,
  3299. Certno: res.Output.Baseinfo.Certno,
  3300. Brdy: res.Output.Baseinfo.Brdy,
  3301. Gend: res.Output.Baseinfo.Gend,
  3302. Naty: res.Output.Baseinfo.Naty,
  3303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3304. PsnName: res.Output.Baseinfo.PsnName,
  3305. Idetinfo: idetinfoStr,
  3306. Insuinfo: infoStr,
  3307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3308. CardInfo: card_info,
  3309. VerifyNumber: token,
  3310. }
  3311. service.CreateHisPsn(psn)
  3312. c.ServeSuccessJSON(map[string]interface{}{
  3313. "patient": patient,
  3314. "number": token,
  3315. })
  3316. }
  3317. }
  3318. } else {
  3319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3320. return
  3321. }
  3322. } else { //读卡失败
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3324. return
  3325. }
  3326. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3327. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  3328. cardnum = DeleteExtraSpaceTwo(cardnum)
  3329. cardCode = DeleteExtraSpaceTwo(cardCode)
  3330. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  3331. name = DeleteExtraSpaceTwo(name)
  3332. errmsg = DeleteExtraSpaceTwo(errmsg)
  3333. cardnum = Remove0000(cardnum)
  3334. cardCode = Remove0000(cardCode)
  3335. id_card_no = Remove0000(id_card_no)
  3336. name = Remove0000(name)
  3337. errmsg = Remove0000(errmsg)
  3338. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  3339. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  3340. //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)
  3341. //fmt.Println(result2)
  3342. //fmt.Println(requestLog2)
  3343. //fmt.Println(errMsgLog2)
  3344. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  3345. saveLog(result, requestLog, "1101", "获取人员信息")
  3346. fmt.Println(errMsgLog)
  3347. if len(errMsgLog) > 0 {
  3348. } else {
  3349. var dat map[string]interface{}
  3350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3351. fmt.Println(dat)
  3352. } else {
  3353. fmt.Println(err)
  3354. }
  3355. userJSONBytes, _ := json.Marshal(dat)
  3356. var res ResultTwo
  3357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3358. utils.ErrorLog("解析失败:%v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. res.ErrMsg = errMsgLog
  3363. if res.Infcode == 0 {
  3364. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  3365. if err == gorm.ErrRecordNotFound {
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3367. return
  3368. } else if err != nil {
  3369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3370. return
  3371. } else {
  3372. fmt.Println(res)
  3373. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3374. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3375. infoStr := string(Iinfos)
  3376. idetinfoStr := string(Idetinfos)
  3377. var rf []*ResultFive
  3378. json.Unmarshal([]byte(infoStr), &rf)
  3379. var insutypes []*ResultFive
  3380. var insutype string
  3381. var is390 int = 0
  3382. var is310 int = 0
  3383. for _, item := range rf {
  3384. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3385. insutypes = append(insutypes, item)
  3386. }
  3387. }
  3388. if len(insutypes) == 1 {
  3389. insutype = insutypes[0].Insutype
  3390. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3391. } else {
  3392. for _, i := range insutypes {
  3393. if i.Insutype == "390" {
  3394. is390 = 1
  3395. }
  3396. if i.Insutype == "310" {
  3397. is310 = 1
  3398. }
  3399. }
  3400. }
  3401. if is390 == 1 {
  3402. insutype = "390"
  3403. }
  3404. if is310 == 1 {
  3405. insutype = "310"
  3406. }
  3407. if len(insutypes) == 0 {
  3408. insutype = "390"
  3409. }
  3410. var insuplc_admdvs string
  3411. for _, item := range rf {
  3412. if item.Insutype == insutype {
  3413. insuplc_admdvs = item.InsuplcAdmdvs
  3414. }
  3415. }
  3416. psn := &models.HisPsn{
  3417. PsnNo: res.Output.Baseinfo.PsnNo,
  3418. Age: res.Output.Baseinfo.Age,
  3419. PatientId: patient.ID,
  3420. Certno: res.Output.Baseinfo.Certno,
  3421. Brdy: res.Output.Baseinfo.Brdy,
  3422. Gend: res.Output.Baseinfo.Gend,
  3423. Naty: res.Output.Baseinfo.Naty,
  3424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3425. PsnName: res.Output.Baseinfo.PsnName,
  3426. Idetinfo: idetinfoStr,
  3427. Insuinfo: infoStr,
  3428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3429. CardInfo: basStr,
  3430. VerifyNumber: "",
  3431. InsuplcAdmdvs: insuplc_admdvs,
  3432. }
  3433. service.CreateHisPsn(psn)
  3434. c.ServeSuccessJSON(map[string]interface{}{
  3435. "patient": patient,
  3436. "number": cardnum,
  3437. "insutype": insutype,
  3438. })
  3439. }
  3440. } else {
  3441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3442. return
  3443. }
  3444. }
  3445. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3446. fmt.Println(initFlag)
  3447. fmt.Println("initFlag")
  3448. if initFlag == 0 {
  3449. c.TestGetJiangXiBasBaseInit()
  3450. }
  3451. basStr := c.GetBasBaseInfo()
  3452. if len(basStr) == 0 {
  3453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3454. return
  3455. }
  3456. fmt.Println(basStr)
  3457. bas := strings.Split(basStr, "|")
  3458. basNumber := bas[1]
  3459. fmt.Println(basNumber)
  3460. card_sn := bas[3]
  3461. fmt.Println(card_sn)
  3462. 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, "")
  3463. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3464. var dat map[string]interface{}
  3465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3466. fmt.Println(dat)
  3467. } else {
  3468. fmt.Println(err)
  3469. }
  3470. userJSONBytes, _ := json.Marshal(dat)
  3471. var res ResultTwo
  3472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3473. utils.ErrorLog("解析失败:%v", err)
  3474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3475. return
  3476. }
  3477. if res.Infcode == 0 {
  3478. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3479. if err == gorm.ErrRecordNotFound {
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3481. return
  3482. } else if err != nil {
  3483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3484. return
  3485. } else {
  3486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3488. infoStr := string(Iinfos)
  3489. idetinfoStr := string(Idetinfos)
  3490. psn := &models.HisPsn{
  3491. PsnNo: res.Output.Baseinfo.PsnNo,
  3492. Age: res.Output.Baseinfo.Age,
  3493. PatientId: patient.ID,
  3494. Certno: res.Output.Baseinfo.Certno,
  3495. Brdy: res.Output.Baseinfo.Brdy,
  3496. Gend: res.Output.Baseinfo.Gend,
  3497. Naty: res.Output.Baseinfo.Naty,
  3498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3499. PsnName: res.Output.Baseinfo.PsnName,
  3500. Idetinfo: idetinfoStr,
  3501. Insuinfo: infoStr,
  3502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3503. CardInfo: basStr,
  3504. VerifyNumber: "",
  3505. }
  3506. service.CreateHisPsn(psn)
  3507. var rf []*ResultFive
  3508. json.Unmarshal([]byte(infoStr), &rf)
  3509. var insutypes []*ResultFive
  3510. var insutype string
  3511. var is390 int = 0
  3512. var is310 int = 0
  3513. for _, item := range rf {
  3514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3515. insutypes = append(insutypes, item)
  3516. }
  3517. }
  3518. if len(insutypes) == 1 {
  3519. insutype = insutypes[0].Insutype
  3520. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3521. } else {
  3522. for _, i := range insutypes {
  3523. if i.Insutype == "390" {
  3524. is390 = 1
  3525. }
  3526. if i.Insutype == "310" {
  3527. is310 = 1
  3528. }
  3529. }
  3530. }
  3531. if is390 == 1 {
  3532. insutype = "390"
  3533. }
  3534. if is310 == 1 {
  3535. insutype = "310"
  3536. }
  3537. if len(insutypes) == 0 {
  3538. insutype = "310"
  3539. }
  3540. c.ServeSuccessJSON(map[string]interface{}{
  3541. "patient": patient,
  3542. "number": basNumber,
  3543. "insutype": insutype,
  3544. })
  3545. }
  3546. } else {
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3548. return
  3549. }
  3550. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3551. fmt.Println(initFlag)
  3552. fmt.Println("initFlag")
  3553. if initFlag == 0 {
  3554. c.TestGetHnBasBaseInit()
  3555. }
  3556. basStr := c.GetBasBaseInfo()
  3557. if len(basStr) == 0 {
  3558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3559. return
  3560. }
  3561. fmt.Println(basStr)
  3562. bas := strings.Split(basStr, "|")
  3563. basNumber := bas[1]
  3564. fmt.Println(basNumber)
  3565. card_sn := bas[3]
  3566. card_no := bas[2]
  3567. fmt.Println(card_sn)
  3568. name := bas[4]
  3569. name = ConvertToString(name, "gbk", "utf-8")
  3570. 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)
  3571. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3572. var dat map[string]interface{}
  3573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3574. fmt.Println(dat)
  3575. } else {
  3576. fmt.Println(err)
  3577. }
  3578. userJSONBytes, _ := json.Marshal(dat)
  3579. var res ResultTwo
  3580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3581. utils.ErrorLog("解析失败:%v", err)
  3582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3583. return
  3584. }
  3585. if res.Infcode == 0 {
  3586. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3587. if err == gorm.ErrRecordNotFound {
  3588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3589. return
  3590. } else if err != nil {
  3591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3592. return
  3593. } else {
  3594. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3595. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3596. infoStr := string(Iinfos)
  3597. idetinfoStr := string(Idetinfos)
  3598. psn := &models.HisPsn{
  3599. PsnNo: res.Output.Baseinfo.PsnNo,
  3600. Age: res.Output.Baseinfo.Age,
  3601. PatientId: patient.ID,
  3602. Certno: res.Output.Baseinfo.Certno,
  3603. Brdy: res.Output.Baseinfo.Brdy,
  3604. Gend: res.Output.Baseinfo.Gend,
  3605. Naty: res.Output.Baseinfo.Naty,
  3606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3607. PsnName: res.Output.Baseinfo.PsnName,
  3608. Idetinfo: idetinfoStr,
  3609. Insuinfo: infoStr,
  3610. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3611. CardInfo: basStr,
  3612. VerifyNumber: "",
  3613. }
  3614. service.CreateHisPsn(psn)
  3615. var rf []*ResultFive
  3616. json.Unmarshal([]byte(infoStr), &rf)
  3617. var insutypes []*ResultFive
  3618. var insutype string
  3619. var is390 int = 0
  3620. var is310 int = 0
  3621. for _, item := range rf {
  3622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3623. insutypes = append(insutypes, item)
  3624. }
  3625. }
  3626. if len(insutypes) == 1 {
  3627. insutype = insutypes[0].Insutype
  3628. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3629. } else {
  3630. for _, i := range insutypes {
  3631. if i.Insutype == "390" {
  3632. is390 = 1
  3633. }
  3634. if i.Insutype == "310" {
  3635. is310 = 1
  3636. }
  3637. }
  3638. }
  3639. if is390 == 1 {
  3640. insutype = "390"
  3641. }
  3642. if is310 == 1 {
  3643. insutype = "310"
  3644. }
  3645. if len(insutypes) == 0 {
  3646. insutype = "310"
  3647. }
  3648. c.ServeSuccessJSON(map[string]interface{}{
  3649. "patient": patient,
  3650. "number": basNumber,
  3651. "insutype": insutype,
  3652. })
  3653. }
  3654. } else {
  3655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3656. return
  3657. }
  3658. } else {
  3659. if initFlag == 0 {
  3660. c.TestGetBasBaseInit()
  3661. }
  3662. basStr := c.GetBasBaseInfo()
  3663. if len(basStr) == 0 {
  3664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3665. return
  3666. }
  3667. fmt.Println(basStr)
  3668. bas := strings.Split(basStr, "|")
  3669. basNumber := bas[1]
  3670. fmt.Println(basNumber)
  3671. card_sn := bas[3]
  3672. fmt.Println(card_sn)
  3673. cardNumber := bas[2]
  3674. fmt.Println(cardNumber)
  3675. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3676. var result string
  3677. if bas[0][:2] == "44" {
  3678. 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)
  3679. } else {
  3680. result = service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3681. }
  3682. var dat map[string]interface{}
  3683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3684. fmt.Println(dat)
  3685. } else {
  3686. fmt.Println(err)
  3687. }
  3688. userJSONBytes, _ := json.Marshal(dat)
  3689. var res ResultTwo
  3690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3691. utils.ErrorLog("解析失败:%v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. if res.Infcode == 0 {
  3696. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3697. if err == gorm.ErrRecordNotFound {
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3699. return
  3700. } else if err != nil {
  3701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3702. return
  3703. } else {
  3704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3706. infoStr := string(Iinfos)
  3707. idetinfoStr := string(Idetinfos)
  3708. var rf []*ResultFive
  3709. json.Unmarshal([]byte(infoStr), &rf)
  3710. var insutypes []*ResultFive
  3711. var insutype string
  3712. var is390 int = 0
  3713. var is310 int = 0
  3714. var insuplc_admdvs string
  3715. for _, item := range rf {
  3716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3717. insutypes = append(insutypes, item)
  3718. }
  3719. }
  3720. if len(insutypes) == 1 {
  3721. insutype = insutypes[0].Insutype
  3722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3723. } else {
  3724. for _, i := range insutypes {
  3725. if i.Insutype == "390" {
  3726. is390 = 1
  3727. }
  3728. if i.Insutype == "310" {
  3729. is310 = 1
  3730. }
  3731. }
  3732. }
  3733. if is390 == 1 {
  3734. insutype = "390"
  3735. }
  3736. if is310 == 1 {
  3737. insutype = "310"
  3738. }
  3739. if len(insutypes) == 0 {
  3740. insutype = "310"
  3741. }
  3742. for _, item := range rf {
  3743. if item.Insutype == insutype {
  3744. insuplc_admdvs = item.InsuplcAdmdvs
  3745. }
  3746. }
  3747. psn := &models.HisPsn{
  3748. PsnNo: res.Output.Baseinfo.PsnNo,
  3749. Age: res.Output.Baseinfo.Age,
  3750. PatientId: patient.ID,
  3751. Certno: res.Output.Baseinfo.Certno,
  3752. Brdy: res.Output.Baseinfo.Brdy,
  3753. Gend: res.Output.Baseinfo.Gend,
  3754. Naty: res.Output.Baseinfo.Naty,
  3755. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3756. PsnName: res.Output.Baseinfo.PsnName,
  3757. Idetinfo: idetinfoStr,
  3758. Insuinfo: infoStr,
  3759. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3760. CardInfo: basStr,
  3761. VerifyNumber: "",
  3762. InsuplcAdmdvs: insuplc_admdvs,
  3763. }
  3764. service.CreateHisPsn(psn)
  3765. c.ServeSuccessJSON(map[string]interface{}{
  3766. "patient": patient,
  3767. "number": basNumber,
  3768. })
  3769. }
  3770. } else {
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3772. return
  3773. }
  3774. break
  3775. }
  3776. case 2:
  3777. if miConfig.MdtrtareaAdmvs == "430800" {
  3778. if initFlag == 0 {
  3779. c.TestGetHnBasBaseInit()
  3780. }
  3781. SFZStr := c.GetSFZBaseInfo()
  3782. if len(SFZStr) == 0 {
  3783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3784. return
  3785. }
  3786. fmt.Println(SFZStr)
  3787. id_card_str := strings.Split(SFZStr, "^")
  3788. card_no := id_card_str[0]
  3789. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3790. //name := id_card_str[1]
  3791. //name = ConvertToString(name, "gbk", "utf-8")
  3792. 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)
  3793. var dat map[string]interface{}
  3794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3795. fmt.Println(dat)
  3796. } else {
  3797. fmt.Println(err)
  3798. }
  3799. userJSONBytes, _ := json.Marshal(dat)
  3800. var res ResultTwo
  3801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3802. utils.ErrorLog("解析失败:%v", err)
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3804. return
  3805. }
  3806. if res.Infcode == 0 {
  3807. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3808. if err == gorm.ErrRecordNotFound {
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3810. return
  3811. } else if err != nil {
  3812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3813. return
  3814. } else {
  3815. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3816. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3817. infoStr := string(Iinfos)
  3818. idetinfoStr := string(Idetinfos)
  3819. psn := &models.HisPsn{
  3820. PsnNo: res.Output.Baseinfo.PsnNo,
  3821. Age: res.Output.Baseinfo.Age,
  3822. PatientId: patient.ID,
  3823. Certno: res.Output.Baseinfo.Certno,
  3824. Brdy: res.Output.Baseinfo.Brdy,
  3825. Gend: res.Output.Baseinfo.Gend,
  3826. Naty: res.Output.Baseinfo.Naty,
  3827. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3828. PsnName: res.Output.Baseinfo.PsnName,
  3829. Idetinfo: idetinfoStr,
  3830. Insuinfo: infoStr,
  3831. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3832. CardInfo: SFZStr,
  3833. VerifyNumber: "",
  3834. }
  3835. service.CreateHisPsn(psn)
  3836. var rf []*ResultFive
  3837. json.Unmarshal([]byte(infoStr), &rf)
  3838. var insutypes []*ResultFive
  3839. var insutype string
  3840. var is390 int = 0
  3841. var is310 int = 0
  3842. for _, item := range rf {
  3843. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3844. insutypes = append(insutypes, item)
  3845. }
  3846. }
  3847. if len(insutypes) == 1 {
  3848. insutype = insutypes[0].Insutype
  3849. } else {
  3850. for _, i := range insutypes {
  3851. if i.Insutype == "390" {
  3852. is390 = 1
  3853. }
  3854. if i.Insutype == "310" {
  3855. is310 = 1
  3856. }
  3857. }
  3858. }
  3859. if is390 == 1 {
  3860. insutype = "390"
  3861. }
  3862. if is310 == 1 {
  3863. insutype = "310"
  3864. }
  3865. if len(insutypes) == 0 {
  3866. insutype = "310"
  3867. }
  3868. c.ServeSuccessJSON(map[string]interface{}{
  3869. "patient": patient,
  3870. "number": card_no,
  3871. "insutype": insutype,
  3872. })
  3873. }
  3874. } else {
  3875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3876. return
  3877. }
  3878. } else {
  3879. SFZStr := c.GetSFZBaseInfo()
  3880. id_card_str := strings.Split(SFZStr, "^")
  3881. id_card_number := id_card_str[0]
  3882. card_sn := ""
  3883. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3884. var dat map[string]interface{}
  3885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3886. fmt.Println(dat)
  3887. } else {
  3888. fmt.Println(err)
  3889. }
  3890. userJSONBytes, _ := json.Marshal(dat)
  3891. var res ResultTwo
  3892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3893. utils.ErrorLog("解析失败:%v", err)
  3894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3895. return
  3896. }
  3897. if res.Infcode == 0 {
  3898. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3899. if err == gorm.ErrRecordNotFound {
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3901. return
  3902. } else if err != nil {
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3904. return
  3905. } else {
  3906. c.ServeSuccessJSON(map[string]interface{}{
  3907. "patient": patient,
  3908. "number": id_card_number,
  3909. })
  3910. }
  3911. } else {
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3913. return
  3914. }
  3915. }
  3916. break
  3917. case 3:
  3918. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3919. var api string
  3920. if miConfig.MdtrtareaAdmvs == "320921" {
  3921. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3922. "&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
  3923. fmt.Println(api)
  3924. } else {
  3925. 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 +
  3926. "&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)
  3927. }
  3928. resp, requestErr := http.Get(api)
  3929. if requestErr != nil {
  3930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. return
  3932. }
  3933. body, ioErr := ioutil.ReadAll(resp.Body)
  3934. if ioErr != nil {
  3935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. return
  3938. }
  3939. var respJSON map[string]interface{}
  3940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3943. return
  3944. }
  3945. var status string
  3946. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3947. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3948. var token string
  3949. var res ResultTwo //1101结果
  3950. var res10265 ResultTwo10265 //1101结果
  3951. var card_info string //卡信息
  3952. var busi_card_info string
  3953. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3954. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3955. if status == "0" { //读卡成功
  3956. if card_type == "1" {
  3957. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3958. result, _ := json.Marshal(respJSON)
  3959. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3960. utils.ErrorLog("解析失败:%v", err)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. res.ErrMsg = res10265.ErrMsg
  3965. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3966. res.Infcode = infocode
  3967. res.Output = res10265.Output
  3968. res.InfRefmsgid = res10265.InfRefmsgid
  3969. } else {
  3970. //var card_info string //卡信息
  3971. //var busi_card_info string
  3972. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3973. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3974. //fmt.Println(card_info)
  3975. //fmt.Println(busi_card_info)
  3976. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3977. result, _ := json.Marshal(respJSON)
  3978. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3979. utils.ErrorLog("解析失败:%v", err)
  3980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3981. return
  3982. }
  3983. res.ErrMsg = res10265.ErrMsg
  3984. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3985. res.Infcode = infocode
  3986. res.Output = res10265.Output
  3987. res.InfRefmsgid = res10265.InfRefmsgid
  3988. }
  3989. if res.Infcode == 0 {
  3990. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3991. if err == gorm.ErrRecordNotFound {
  3992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3993. return
  3994. } else if err != nil {
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3996. return
  3997. } else {
  3998. if card_type == "1" {
  3999. bas := strings.Split(card_info, "|")
  4000. basNumber := bas[2]
  4001. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4002. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4003. infoStr := string(Iinfos)
  4004. idetinfoStr := string(Idetinfos)
  4005. psn := &models.HisPsn{
  4006. PsnNo: res.Output.Baseinfo.PsnNo,
  4007. Age: res.Output.Baseinfo.Age,
  4008. PatientId: patient.ID,
  4009. Certno: res.Output.Baseinfo.Certno,
  4010. Brdy: res.Output.Baseinfo.Brdy,
  4011. Gend: res.Output.Baseinfo.Gend,
  4012. Naty: res.Output.Baseinfo.Naty,
  4013. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4014. PsnName: res.Output.Baseinfo.PsnName,
  4015. Idetinfo: idetinfoStr,
  4016. Insuinfo: infoStr,
  4017. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4018. CardInfo: card_info,
  4019. VerifyNumber: busi_card_info,
  4020. }
  4021. service.CreateHisPsn(psn)
  4022. c.ServeSuccessJSON(map[string]interface{}{
  4023. "patient": patient,
  4024. "number": basNumber,
  4025. })
  4026. } else {
  4027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4029. infoStr := string(Iinfos)
  4030. idetinfoStr := string(Idetinfos)
  4031. psn := &models.HisPsn{
  4032. PsnNo: res.Output.Baseinfo.PsnNo,
  4033. Age: res.Output.Baseinfo.Age,
  4034. PatientId: patient.ID,
  4035. Certno: res.Output.Baseinfo.Certno,
  4036. Brdy: res.Output.Baseinfo.Brdy,
  4037. Gend: res.Output.Baseinfo.Gend,
  4038. Naty: res.Output.Baseinfo.Naty,
  4039. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4040. PsnName: res.Output.Baseinfo.PsnName,
  4041. Idetinfo: idetinfoStr,
  4042. Insuinfo: infoStr,
  4043. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4044. CardInfo: card_info,
  4045. VerifyNumber: token,
  4046. }
  4047. service.CreateHisPsn(psn)
  4048. var rf []*ResultFive
  4049. json.Unmarshal([]byte(infoStr), &rf)
  4050. var insutypes []*ResultFive
  4051. var insutype string
  4052. var is390 int = 0
  4053. var is310 int = 0
  4054. for _, item := range rf {
  4055. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4056. insutypes = append(insutypes, item)
  4057. }
  4058. }
  4059. if len(insutypes) == 1 {
  4060. insutype = insutypes[0].Insutype
  4061. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4062. } else {
  4063. for _, i := range insutypes {
  4064. if i.Insutype == "390" {
  4065. is390 = 1
  4066. }
  4067. if i.Insutype == "310" {
  4068. is310 = 1
  4069. }
  4070. }
  4071. }
  4072. if is390 == 1 {
  4073. insutype = "390"
  4074. }
  4075. if is310 == 1 {
  4076. insutype = "310"
  4077. }
  4078. if len(insutypes) == 0 {
  4079. insutype = "310"
  4080. }
  4081. c.ServeSuccessJSON(map[string]interface{}{
  4082. "patient": patient,
  4083. "number": token,
  4084. "insutype": insutype,
  4085. })
  4086. }
  4087. }
  4088. } else {
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4090. return
  4091. }
  4092. } else { //读卡失败
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4094. return
  4095. }
  4096. }
  4097. break
  4098. case 4:
  4099. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4100. var api string
  4101. if miConfig.MdtrtareaAdmvs == "320921" {
  4102. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4103. "&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
  4104. fmt.Println(api)
  4105. } else {
  4106. 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 +
  4107. "&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)
  4108. }
  4109. resp, requestErr := http.Get(api)
  4110. if requestErr != nil {
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. body, ioErr := ioutil.ReadAll(resp.Body)
  4115. if ioErr != nil {
  4116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4118. return
  4119. }
  4120. var respJSON map[string]interface{}
  4121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4124. return
  4125. }
  4126. var status string
  4127. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4128. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4129. var token string
  4130. var res ResultTwo //1101结果
  4131. var res10265 ResultTwo10265 //1101结果
  4132. if status == "0" { //读卡成功
  4133. var card_info string //卡信息
  4134. var busi_card_info string
  4135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4136. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4137. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4138. fmt.Println(card_info)
  4139. fmt.Println(busi_card_info)
  4140. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4141. result, _ := json.Marshal(respJSON)
  4142. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4143. utils.ErrorLog("解析失败:%v", err)
  4144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4145. return
  4146. }
  4147. res.ErrMsg = res10265.ErrMsg
  4148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4149. res.Infcode = infocode
  4150. res.Output = res10265.Output
  4151. res.InfRefmsgid = res10265.InfRefmsgid
  4152. if res.Infcode == 0 {
  4153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4154. if err == gorm.ErrRecordNotFound {
  4155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4156. return
  4157. } else if err != nil {
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4159. return
  4160. } else {
  4161. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4162. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4163. infoStr := string(Iinfos)
  4164. idetinfoStr := string(Idetinfos)
  4165. psn := &models.HisPsn{
  4166. PsnNo: res.Output.Baseinfo.PsnNo,
  4167. Age: res.Output.Baseinfo.Age,
  4168. PatientId: patient.ID,
  4169. Certno: res.Output.Baseinfo.Certno,
  4170. Brdy: res.Output.Baseinfo.Brdy,
  4171. Gend: res.Output.Baseinfo.Gend,
  4172. Naty: res.Output.Baseinfo.Naty,
  4173. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4174. PsnName: res.Output.Baseinfo.PsnName,
  4175. Idetinfo: idetinfoStr,
  4176. Insuinfo: infoStr,
  4177. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4178. CardInfo: card_info,
  4179. VerifyNumber: token,
  4180. }
  4181. var rf []*ResultFive
  4182. json.Unmarshal([]byte(infoStr), &rf)
  4183. var insutypes []*ResultFive
  4184. var insutype string
  4185. var is390 int = 0
  4186. var is310 int = 0
  4187. for _, item := range rf {
  4188. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4189. insutypes = append(insutypes, item)
  4190. }
  4191. }
  4192. if len(insutypes) == 1 {
  4193. insutype = insutypes[0].Insutype
  4194. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4195. } else {
  4196. for _, i := range insutypes {
  4197. if i.Insutype == "390" {
  4198. is390 = 1
  4199. }
  4200. if i.Insutype == "310" {
  4201. is310 = 1
  4202. }
  4203. }
  4204. }
  4205. if is390 == 1 {
  4206. insutype = "390"
  4207. }
  4208. if is310 == 1 {
  4209. insutype = "310"
  4210. }
  4211. if len(insutypes) == 0 {
  4212. insutype = "310"
  4213. }
  4214. service.CreateHisPsn(psn)
  4215. c.ServeSuccessJSON(map[string]interface{}{
  4216. "patient": patient,
  4217. "number": token,
  4218. "insutype": insutype,
  4219. })
  4220. }
  4221. } else {
  4222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4223. return
  4224. }
  4225. } else { //读卡失败
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4227. return
  4228. }
  4229. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4230. idNo := c.GetString("idNo")
  4231. userName := c.GetString("userName")
  4232. ecToken := c.GetString("ecToken")
  4233. insuOrg := c.GetString("insuOrg")
  4234. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4235. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4236. var res ResultTwo
  4237. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4238. utils.ErrorLog("解析失败:%v", err)
  4239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4240. return
  4241. }
  4242. if res.Infcode == 0 {
  4243. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4244. if err == gorm.ErrRecordNotFound {
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4246. return
  4247. } else if err != nil {
  4248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4249. return
  4250. } else {
  4251. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4252. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4253. infoStr := string(Iinfos)
  4254. idetinfoStr := string(Idetinfos)
  4255. psn := &models.HisPsn{
  4256. PsnNo: res.Output.Baseinfo.PsnNo,
  4257. Age: res.Output.Baseinfo.Age,
  4258. PatientId: patient.ID,
  4259. Certno: res.Output.Baseinfo.Certno,
  4260. Brdy: res.Output.Baseinfo.Brdy,
  4261. Gend: res.Output.Baseinfo.Gend,
  4262. Naty: res.Output.Baseinfo.Naty,
  4263. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4264. PsnName: res.Output.Baseinfo.PsnName,
  4265. Idetinfo: idetinfoStr,
  4266. Insuinfo: infoStr,
  4267. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4268. CardInfo: "",
  4269. Stage: "1",
  4270. VerifyNumber: ecToken,
  4271. InsuplcAdmdvs: insuOrg,
  4272. }
  4273. service.CreateHisPsn(psn)
  4274. var rf []*ResultFive
  4275. json.Unmarshal([]byte(infoStr), &rf)
  4276. var insutypes []*ResultFive
  4277. var insutype string
  4278. var is390 int = 0
  4279. var is310 int = 0
  4280. for _, item := range rf {
  4281. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4282. insutypes = append(insutypes, item)
  4283. }
  4284. }
  4285. if len(insutypes) == 1 {
  4286. insutype = insutypes[0].Insutype
  4287. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4288. } else {
  4289. for _, i := range insutypes {
  4290. if i.Insutype == "390" {
  4291. is390 = 1
  4292. }
  4293. if i.Insutype == "310" {
  4294. is310 = 1
  4295. }
  4296. }
  4297. }
  4298. if is390 == 1 {
  4299. insutype = "390"
  4300. }
  4301. if is310 == 1 {
  4302. insutype = "310"
  4303. }
  4304. if len(insutypes) == 0 {
  4305. insutype = "310"
  4306. }
  4307. c.ServeSuccessJSON(map[string]interface{}{
  4308. "patient": patient,
  4309. "number": ecToken,
  4310. "insutype": insutype,
  4311. })
  4312. }
  4313. } else {
  4314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4315. return
  4316. }
  4317. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4318. //if initFlag == 0 {
  4319. c.TestGetJiangXiBasBaseInit()
  4320. //}
  4321. //if initEleFlag == 0 {
  4322. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4323. //}
  4324. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4325. type ELeData struct {
  4326. Data struct {
  4327. IdNo string `json:"idNo"`
  4328. IdType string `json:"idType"`
  4329. UserName string `json:"userName"`
  4330. EcToken string `json:"ecToken"`
  4331. InsuOrg string `json:"insuOrg"`
  4332. Gender string `json:"gender"`
  4333. Birthday string `json:"birthday"`
  4334. Nationality string `json:"nationality"`
  4335. Email string `json:"email"`
  4336. Extra string `json:"extra"`
  4337. } `json:"data"`
  4338. Code int `json:"code"`
  4339. Message string `json:"message"`
  4340. }
  4341. var ele ELeData
  4342. err := json.Unmarshal([]byte(json_result), &ele)
  4343. if err != nil {
  4344. utils.ErrorLog("解析失败:%v", err)
  4345. }
  4346. token := ele.Data.EcToken
  4347. token = Remove0000(token)
  4348. 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)
  4349. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4350. var res ResultTwo
  4351. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4352. utils.ErrorLog("解析失败:%v", err)
  4353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. return
  4355. }
  4356. if res.Infcode == 0 {
  4357. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4358. if err == gorm.ErrRecordNotFound {
  4359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4360. return
  4361. } else if err != nil {
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4363. return
  4364. } else {
  4365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4367. infoStr := string(Iinfos)
  4368. idetinfoStr := string(Idetinfos)
  4369. psn := &models.HisPsn{
  4370. PsnNo: res.Output.Baseinfo.PsnNo,
  4371. Age: res.Output.Baseinfo.Age,
  4372. PatientId: patient.ID,
  4373. Certno: res.Output.Baseinfo.Certno,
  4374. Brdy: res.Output.Baseinfo.Brdy,
  4375. Gend: res.Output.Baseinfo.Gend,
  4376. Naty: res.Output.Baseinfo.Naty,
  4377. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4378. PsnName: res.Output.Baseinfo.PsnName,
  4379. Idetinfo: idetinfoStr,
  4380. Insuinfo: infoStr,
  4381. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4382. CardInfo: "",
  4383. //RecordDate:
  4384. VerifyNumber: token,
  4385. }
  4386. service.CreateHisPsn(psn)
  4387. var rf []*ResultFive
  4388. json.Unmarshal([]byte(infoStr), &rf)
  4389. var insutypes []*ResultFive
  4390. var insutype string
  4391. var is390 int = 0
  4392. var is310 int = 0
  4393. for _, item := range rf {
  4394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4395. insutypes = append(insutypes, item)
  4396. }
  4397. }
  4398. if len(insutypes) == 1 {
  4399. insutype = insutypes[0].Insutype
  4400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4401. } else {
  4402. for _, i := range insutypes {
  4403. if i.Insutype == "390" {
  4404. is390 = 1
  4405. }
  4406. if i.Insutype == "310" {
  4407. is310 = 1
  4408. }
  4409. }
  4410. }
  4411. if is390 == 1 {
  4412. insutype = "390"
  4413. }
  4414. if is310 == 1 {
  4415. insutype = "310"
  4416. }
  4417. if len(insutypes) == 0 {
  4418. insutype = "310"
  4419. }
  4420. c.ServeSuccessJSON(map[string]interface{}{
  4421. "patient": patient,
  4422. "number": token,
  4423. "insutype": insutype,
  4424. })
  4425. }
  4426. } else {
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4428. return
  4429. }
  4430. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4431. //if initFlag == 0 {
  4432. c.TestGetJiangXiBasBaseInit()
  4433. //}
  4434. //if initEleFlag == 0 {
  4435. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4436. //}
  4437. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4438. type ELeData struct {
  4439. Data struct {
  4440. IdNo string `json:"idNo"`
  4441. IdType string `json:"idType"`
  4442. UserName string `json:"userName"`
  4443. EcToken string `json:"ecToken"`
  4444. InsuOrg string `json:"insuOrg"`
  4445. Gender string `json:"gender"`
  4446. Birthday string `json:"birthday"`
  4447. Nationality string `json:"nationality"`
  4448. Email string `json:"email"`
  4449. Extra string `json:"extra"`
  4450. } `json:"data"`
  4451. Code int `json:"code"`
  4452. Message string `json:"message"`
  4453. }
  4454. var ele ELeData
  4455. err := json.Unmarshal([]byte(json_result), &ele)
  4456. if err != nil {
  4457. utils.ErrorLog("解析失败:%v", err)
  4458. }
  4459. token := ele.Data.EcToken
  4460. token = Remove0000(token)
  4461. 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)
  4462. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4463. var res ResultTwo
  4464. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4465. utils.ErrorLog("解析失败:%v", err)
  4466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4467. return
  4468. }
  4469. if res.Infcode == 0 {
  4470. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4471. if err == gorm.ErrRecordNotFound {
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4473. return
  4474. } else if err != nil {
  4475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4476. return
  4477. } else {
  4478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4480. infoStr := string(Iinfos)
  4481. idetinfoStr := string(Idetinfos)
  4482. psn := &models.HisPsn{
  4483. PsnNo: res.Output.Baseinfo.PsnNo,
  4484. Age: res.Output.Baseinfo.Age,
  4485. PatientId: patient.ID,
  4486. Certno: res.Output.Baseinfo.Certno,
  4487. Brdy: res.Output.Baseinfo.Brdy,
  4488. Gend: res.Output.Baseinfo.Gend,
  4489. Naty: res.Output.Baseinfo.Naty,
  4490. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4491. PsnName: res.Output.Baseinfo.PsnName,
  4492. Idetinfo: idetinfoStr,
  4493. Insuinfo: infoStr,
  4494. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4495. CardInfo: "",
  4496. VerifyNumber: token,
  4497. }
  4498. service.CreateHisPsn(psn)
  4499. var rf []*ResultFive
  4500. json.Unmarshal([]byte(infoStr), &rf)
  4501. var insutypes []*ResultFive
  4502. var insutype string
  4503. var is390 int = 0
  4504. var is310 int = 0
  4505. for _, item := range rf {
  4506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4507. insutypes = append(insutypes, item)
  4508. }
  4509. }
  4510. if len(insutypes) == 1 {
  4511. insutype = insutypes[0].Insutype
  4512. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4513. } else {
  4514. for _, i := range insutypes {
  4515. if i.Insutype == "390" {
  4516. is390 = 1
  4517. }
  4518. if i.Insutype == "310" {
  4519. is310 = 1
  4520. }
  4521. }
  4522. }
  4523. if is390 == 1 {
  4524. insutype = "390"
  4525. }
  4526. if is310 == 1 {
  4527. insutype = "310"
  4528. }
  4529. if len(insutypes) == 0 {
  4530. insutype = "310"
  4531. }
  4532. c.ServeSuccessJSON(map[string]interface{}{
  4533. "patient": patient,
  4534. "number": token,
  4535. "insutype": insutype,
  4536. })
  4537. }
  4538. } else {
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4540. return
  4541. }
  4542. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4543. type ELeData struct {
  4544. Code string `json:"code"`
  4545. Data struct {
  4546. Aac002 string `json:"aac002"`
  4547. Aaz500 string `json:"aaz500"`
  4548. ActCardNo string `json:"actCardNo"`
  4549. Bab520 string `json:"bab520"`
  4550. Bkz543 string `json:"bkz543"`
  4551. BusinessType string `json:"businessType"`
  4552. CertfCodg string `json:"certfCodg"`
  4553. EcIndexNo string `json:"ecIndexNo"`
  4554. EcToken string `json:"ecToken"`
  4555. ID0000 string `json:"id0000"`
  4556. IDNo string `json:"idNo"`
  4557. IDType string `json:"idType"`
  4558. Idcode string `json:"idcode"`
  4559. IdentityToken string `json:"identity_token"`
  4560. InsuOrg string `json:"insuOrg"`
  4561. OfficeID string `json:"officeId"`
  4562. OfficeName string `json:"officeName"`
  4563. OperatorID string `json:"operatorId"`
  4564. OperatorName string `json:"operatorName"`
  4565. OrgID string `json:"orgId"`
  4566. UserName string `json:"userName"`
  4567. } `json:"data"`
  4568. Infno interface{} `json:"infno"`
  4569. Message string `json:"message"`
  4570. OrgID string `json:"orgId"`
  4571. TransType string `json:"transType"`
  4572. }
  4573. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4574. outPutInfo = Remove0000(outPutInfo)
  4575. if len(outPutInfo) > 0 {
  4576. var ele ELeData
  4577. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4578. if err != nil {
  4579. utils.ErrorLog("解析失败:%v", err)
  4580. }
  4581. token := ele.Data.EcToken
  4582. fmt.Println(inputInfo)
  4583. fmt.Println(outPutInfo)
  4584. 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)
  4585. saveLog(result, requestLog, "1101", "获取人员信息")
  4586. var dat map[string]interface{}
  4587. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4588. fmt.Println(dat)
  4589. } else {
  4590. fmt.Println(err)
  4591. }
  4592. userJSONBytes, _ := json.Marshal(dat)
  4593. var res ResultTwo
  4594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4595. utils.ErrorLog("解析失败:%v", err)
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. res.ErrMsg = errMsgLog
  4600. if res.Infcode == 0 {
  4601. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4602. if err == gorm.ErrRecordNotFound {
  4603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4604. return
  4605. } else if err != nil {
  4606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4607. return
  4608. } else {
  4609. fmt.Println(res)
  4610. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4611. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4612. infoStr := string(Iinfos)
  4613. idetinfoStr := string(Idetinfos)
  4614. psn := &models.HisPsn{
  4615. PsnNo: res.Output.Baseinfo.PsnNo,
  4616. Age: res.Output.Baseinfo.Age,
  4617. PatientId: patient.ID,
  4618. Certno: res.Output.Baseinfo.Certno,
  4619. Brdy: res.Output.Baseinfo.Brdy,
  4620. Gend: res.Output.Baseinfo.Gend,
  4621. Naty: res.Output.Baseinfo.Naty,
  4622. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4623. PsnName: res.Output.Baseinfo.PsnName,
  4624. Idetinfo: idetinfoStr,
  4625. Insuinfo: infoStr,
  4626. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4627. CardInfo: outPutInfo,
  4628. VerifyNumber: token,
  4629. InsuplcAdmdvs: ele.Data.InsuOrg,
  4630. }
  4631. service.CreateHisPsn(psn)
  4632. var rf []*ResultFive
  4633. json.Unmarshal([]byte(infoStr), &rf)
  4634. var insutypes []*ResultFive
  4635. var insutype string
  4636. var is390 int = 0
  4637. var is310 int = 0
  4638. for _, item := range rf {
  4639. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4640. insutypes = append(insutypes, item)
  4641. }
  4642. }
  4643. if len(insutypes) == 1 {
  4644. insutype = insutypes[0].Insutype
  4645. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4646. } else {
  4647. for _, i := range insutypes {
  4648. if i.Insutype == "390" {
  4649. is390 = 1
  4650. }
  4651. if i.Insutype == "310" {
  4652. is310 = 1
  4653. }
  4654. }
  4655. }
  4656. if is390 == 1 {
  4657. insutype = "390"
  4658. }
  4659. if is310 == 1 {
  4660. insutype = "310"
  4661. }
  4662. if len(insutypes) == 0 {
  4663. insutype = "310"
  4664. }
  4665. c.ServeSuccessJSON(map[string]interface{}{
  4666. "patient": patient,
  4667. "number": token,
  4668. "insutype": insutype,
  4669. })
  4670. }
  4671. } else {
  4672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4673. return
  4674. }
  4675. }
  4676. } else {
  4677. type ELeData struct {
  4678. Code string `json:"code"`
  4679. Data struct {
  4680. Aac002 string `json:"aac002"`
  4681. Aaz500 string `json:"aaz500"`
  4682. ActCardNo string `json:"actCardNo"`
  4683. Bab520 string `json:"bab520"`
  4684. Bkz543 string `json:"bkz543"`
  4685. BusinessType string `json:"businessType"`
  4686. CertfCodg string `json:"certfCodg"`
  4687. EcIndexNo string `json:"ecIndexNo"`
  4688. EcToken string `json:"ecToken"`
  4689. ID0000 string `json:"id0000"`
  4690. IDNo string `json:"idNo"`
  4691. IDType string `json:"idType"`
  4692. Idcode string `json:"idcode"`
  4693. IdentityToken string `json:"identity_token"`
  4694. InsuOrg string `json:"insuOrg"`
  4695. OfficeID string `json:"officeId"`
  4696. OfficeName string `json:"officeName"`
  4697. OperatorID string `json:"operatorId"`
  4698. OperatorName string `json:"operatorName"`
  4699. OrgID string `json:"orgId"`
  4700. UserName string `json:"userName"`
  4701. } `json:"data"`
  4702. Infno interface{} `json:"infno"`
  4703. Message string `json:"message"`
  4704. OrgID string `json:"orgId"`
  4705. TransType string `json:"transType"`
  4706. }
  4707. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  4708. fmt.Println(result)
  4709. outPutInfo := Remove0000(result)
  4710. fmt.Println(outPutInfo)
  4711. if len(outPutInfo) > 0 {
  4712. var ele ELeData
  4713. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4714. if err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. }
  4717. token := ele.Data.EcToken
  4718. fmt.Println(outPutInfo)
  4719. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4720. saveLog(result, requestLog, "1101", "获取人员信息")
  4721. var dat map[string]interface{}
  4722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4723. fmt.Println(dat)
  4724. } else {
  4725. fmt.Println(err)
  4726. }
  4727. userJSONBytes, _ := json.Marshal(dat)
  4728. var res ResultTwo
  4729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4730. utils.ErrorLog("解析失败:%v", err)
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4732. return
  4733. }
  4734. if res.Infcode == 0 {
  4735. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4736. if err == gorm.ErrRecordNotFound {
  4737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4738. return
  4739. } else if err != nil {
  4740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4741. return
  4742. } else {
  4743. fmt.Println(res)
  4744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4745. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4746. infoStr := string(Iinfos)
  4747. idetinfoStr := string(Idetinfos)
  4748. psn := &models.HisPsn{
  4749. PsnNo: res.Output.Baseinfo.PsnNo,
  4750. Age: res.Output.Baseinfo.Age,
  4751. PatientId: patient.ID,
  4752. Certno: res.Output.Baseinfo.Certno,
  4753. Brdy: res.Output.Baseinfo.Brdy,
  4754. Gend: res.Output.Baseinfo.Gend,
  4755. Naty: res.Output.Baseinfo.Naty,
  4756. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4757. PsnName: res.Output.Baseinfo.PsnName,
  4758. Idetinfo: idetinfoStr,
  4759. Insuinfo: infoStr,
  4760. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4761. CardInfo: outPutInfo,
  4762. VerifyNumber: token,
  4763. InsuplcAdmdvs: ele.Data.InsuOrg,
  4764. }
  4765. service.CreateHisPsn(psn)
  4766. var rf []*ResultFive
  4767. json.Unmarshal([]byte(infoStr), &rf)
  4768. var insutypes []*ResultFive
  4769. var insutype string
  4770. var is390 int = 0
  4771. var is310 int = 0
  4772. for _, item := range rf {
  4773. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4774. insutypes = append(insutypes, item)
  4775. }
  4776. }
  4777. if len(insutypes) == 1 {
  4778. insutype = insutypes[0].Insutype
  4779. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4780. } else {
  4781. for _, i := range insutypes {
  4782. if i.Insutype == "390" {
  4783. is390 = 1
  4784. }
  4785. if i.Insutype == "310" {
  4786. is310 = 1
  4787. }
  4788. }
  4789. }
  4790. if is390 == 1 {
  4791. insutype = "390"
  4792. }
  4793. if is310 == 1 {
  4794. insutype = "310"
  4795. }
  4796. if len(insutypes) == 0 {
  4797. insutype = "310"
  4798. }
  4799. c.ServeSuccessJSON(map[string]interface{}{
  4800. "patient": patient,
  4801. "number": token,
  4802. "insutype": insutype,
  4803. })
  4804. }
  4805. } else {
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4807. return
  4808. }
  4809. }
  4810. //fmt.Println(result)
  4811. //
  4812. //if initFlag == 0 {
  4813. // c.TestGetBasBaseInit()
  4814. //}
  4815. //token := c.GetEleBaseInfo()
  4816. //
  4817. //token = Remove0000(token)
  4818. //
  4819. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4820. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  4821. ////
  4822. //var res ResultTwo
  4823. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4824. // utils.ErrorLog("解析失败:%v", err)
  4825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4826. // return
  4827. //}
  4828. //
  4829. //if res.Infcode == 0 {
  4830. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4831. // if err == gorm.ErrRecordNotFound {
  4832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4833. // return
  4834. // } else if err != nil {
  4835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4836. // return
  4837. //
  4838. // } else {
  4839. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4840. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4841. // infoStr := string(Iinfos)
  4842. // idetinfoStr := string(Idetinfos)
  4843. //
  4844. //
  4845. //
  4846. //
  4847. // var rf []*ResultFive
  4848. // json.Unmarshal([]byte(infoStr), &rf)
  4849. //
  4850. // var insutypes []*ResultFive
  4851. // var insutype string
  4852. // var is390 int = 0
  4853. // var is310 int = 0
  4854. // var insuplc_admdvs string
  4855. //
  4856. // for _, item := range rf {
  4857. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4858. // insutypes = append(insutypes, item)
  4859. // }
  4860. // }
  4861. //
  4862. // if len(insutypes) == 1 {
  4863. // insutype = insutypes[0].Insutype
  4864. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4865. // } else {
  4866. // for _, i := range insutypes {
  4867. // if i.Insutype == "390" {
  4868. // is390 = 1
  4869. // }
  4870. //
  4871. // if i.Insutype == "310" {
  4872. // is310 = 1
  4873. // }
  4874. // }
  4875. // }
  4876. // if is390 == 1 {
  4877. // insutype = "390"
  4878. // }
  4879. //
  4880. // if is310 == 1 {
  4881. // insutype = "310"
  4882. // }
  4883. // if len(insutypes) == 0 {
  4884. // insutype = "310"
  4885. // }
  4886. // for _, item := range rf {
  4887. // if item.Insutype == insutype {
  4888. // insuplc_admdvs = item.InsuplcAdmdvs
  4889. // }
  4890. // }
  4891. // psn := &models.HisPsn{
  4892. // PsnNo: res.Output.Baseinfo.PsnNo,
  4893. // Age: res.Output.Baseinfo.Age,
  4894. // PatientId: patient.ID,
  4895. // Certno: res.Output.Baseinfo.Certno,
  4896. // Brdy: res.Output.Baseinfo.Brdy,
  4897. // Gend: res.Output.Baseinfo.Gend,
  4898. // Naty: res.Output.Baseinfo.Naty,
  4899. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  4900. // PsnName: res.Output.Baseinfo.PsnName,
  4901. // Idetinfo: idetinfoStr,
  4902. // Insuinfo: infoStr,
  4903. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4904. // CardInfo: "",
  4905. // VerifyNumber: token,
  4906. // InsuplcAdmdvs: insuplc_admdvs,
  4907. // }
  4908. // service.CreateHisPsn(psn)
  4909. //
  4910. // c.ServeSuccessJSON(map[string]interface{}{
  4911. // "patient": patient,
  4912. // "number": token,
  4913. // })
  4914. // }
  4915. //} else {
  4916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4917. // return
  4918. //}
  4919. }
  4920. break
  4921. }
  4922. }
  4923. var initFlag int64 = 0
  4924. var initEleFlag int64 = 0
  4925. func (c *HisApiController) TestGetBasBaseInit() {
  4926. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4927. Iinit := DllDef.MustFindProc("Init")
  4928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4929. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4930. if ret != 0 {
  4931. fmt.Println("SSCard的报错原因:", err)
  4932. fmt.Println("SSCard的运算结果为:", ret)
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4934. return
  4935. }
  4936. result := int(ret)
  4937. fmt.Println("SSCard的运算结果为1:", result)
  4938. initFlag = 1
  4939. return
  4940. }
  4941. func (c *HisApiController) HandleJiangXiReadCard() {
  4942. fmt.Println("~~~~~~")
  4943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4944. admin_user_id, _ := c.GetInt64("admin_user_id")
  4945. id_card_type, _ := c.GetInt64("id_card_type")
  4946. //certificates, _ := c.GetInt64("certificates")
  4947. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4948. if initFlag == 0 {
  4949. c.TestGetJiangXiBasBaseInit()
  4950. }
  4951. basStr := c.GetBasBaseInfo()
  4952. if len(basStr) == 0 {
  4953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4954. return
  4955. }
  4956. fmt.Println(basStr)
  4957. bas := strings.Split(basStr, "|")
  4958. basNumber := bas[1]
  4959. fmt.Println(basNumber)
  4960. card_sn := bas[3]
  4961. fmt.Println(card_sn)
  4962. 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, "")
  4963. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4964. var dat map[string]interface{}
  4965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4966. fmt.Println(dat)
  4967. } else {
  4968. fmt.Println(err)
  4969. }
  4970. userJSONBytes, _ := json.Marshal(dat)
  4971. var res ResultTwo
  4972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4973. utils.ErrorLog("解析失败:%v", err)
  4974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4975. return
  4976. }
  4977. if res.Infcode == 0 {
  4978. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4979. if err == gorm.ErrRecordNotFound {
  4980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4981. return
  4982. } else if err != nil {
  4983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4984. return
  4985. } else {
  4986. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4987. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4988. infoStr := string(Iinfos)
  4989. idetinfoStr := string(Idetinfos)
  4990. psn := &models.HisPsn{
  4991. PsnNo: res.Output.Baseinfo.PsnNo,
  4992. Age: res.Output.Baseinfo.Age,
  4993. PatientId: patient.ID,
  4994. Certno: res.Output.Baseinfo.Certno,
  4995. Brdy: res.Output.Baseinfo.Brdy,
  4996. Gend: res.Output.Baseinfo.Gend,
  4997. Naty: res.Output.Baseinfo.Naty,
  4998. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4999. PsnName: res.Output.Baseinfo.PsnName,
  5000. Idetinfo: idetinfoStr,
  5001. Insuinfo: infoStr,
  5002. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5003. CardInfo: basStr,
  5004. VerifyNumber: "",
  5005. }
  5006. service.CreateHisPsn(psn)
  5007. c.ServeSuccessJSON(map[string]interface{}{
  5008. "patient": patient,
  5009. "number": basNumber,
  5010. })
  5011. }
  5012. } else {
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5014. return
  5015. }
  5016. }
  5017. func (c *HisApiController) TestGetHnBasBaseInit() {
  5018. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5019. Iinit := DllDef.MustFindProc("Init")
  5020. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5021. //http://10.77.211.236/CSB/hsa-fsi-1303
  5022. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  5023. if ret != 0 {
  5024. fmt.Println("SSCard的报错原因:", err)
  5025. fmt.Println("SSCard的运算结果为:", ret)
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5027. return
  5028. }
  5029. result := int(ret)
  5030. fmt.Println("SSCard的运算结果为1:", result)
  5031. initFlag = 1
  5032. return
  5033. }
  5034. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  5035. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5036. Iinit := DllDef.MustFindProc("Init")
  5037. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5038. //http://10.77.211.236/CSB/hsa-fsi-1303
  5039. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  5040. if ret != 0 {
  5041. fmt.Println("SSCard的报错原因:", err)
  5042. fmt.Println("SSCard的运算结果为:", ret)
  5043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5044. return
  5045. }
  5046. result := int(ret)
  5047. fmt.Println("SSCard的运算结果为1:", result)
  5048. initFlag = 1
  5049. return
  5050. }
  5051. func (c *HisApiController) GetSFZBaseInfo() string {
  5052. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5053. readCard := DllDef.MustFindProc("ReadSFZ")
  5054. if readCard == nil {
  5055. fmt.Println("readcard is nil")
  5056. readCard = DllDef.MustFindProc("ReadSFZ")
  5057. }
  5058. str := make([]byte, 8096)
  5059. str1 := make([]byte, 8096)
  5060. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  5061. fmt.Println(r)
  5062. return Remove0000(string(str))
  5063. }
  5064. func (c *HisApiController) GetEleBaseInfo() string {
  5065. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5066. readCard := DllDef.MustFindProc("GetQRBase")
  5067. fmt.Println(readCard)
  5068. if readCard == nil {
  5069. fmt.Println("readcard is nil")
  5070. readCard = DllDef.MustFindProc("GetQRBase")
  5071. }
  5072. str := make([]byte, 1024)
  5073. str1 := make([]byte, 1024)
  5074. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5075. fmt.Println(ret2)
  5076. fmt.Println(string(str1))
  5077. fmt.Println(string(str))
  5078. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5079. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5080. if ret2 != 0 {
  5081. return ""
  5082. }
  5083. return string(str)
  5084. }
  5085. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5086. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5087. readCard := DllDef.MustFindProc("NationEcTrans")
  5088. fmt.Println(readCard)
  5089. fmt.Println("!!!!!")
  5090. pBusiCardInfo := make([]byte, 2048)
  5091. input := make(map[string]interface{})
  5092. inputData := make(map[string]interface{})
  5093. inputData["orgId"] = code
  5094. inputData["businessType"] = "01101"
  5095. inputData["operatorId"] = "1"
  5096. inputData["operatorName"] = "admin"
  5097. inputData["officeId"] = "001"
  5098. inputData["officeName"] = "血透室"
  5099. inputData["deviceType"] = ""
  5100. input["data"] = inputData
  5101. input["orgId"] = code
  5102. input["transType"] = "ec.query"
  5103. bytesData, _ := json.Marshal(input)
  5104. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5105. fmt.Println(ret2)
  5106. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5107. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5108. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  5109. }
  5110. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5111. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5112. readCard := DllDef.MustFindProc("NationEcTrans")
  5113. fmt.Println(readCard)
  5114. fmt.Println("!!!!!")
  5115. pBusiCardInfo := make([]byte, 2048)
  5116. input := make(map[string]interface{})
  5117. inputData := make(map[string]interface{})
  5118. inputData["orgId"] = code
  5119. inputData["businessType"] = "01101"
  5120. inputData["operatorId"] = "9"
  5121. inputData["operatorName"] = "admin"
  5122. inputData["officeId"] = "001"
  5123. inputData["officeName"] = "血透室"
  5124. inputData["deviceType"] = ""
  5125. input["data"] = inputData
  5126. input["orgId"] = code
  5127. input["transType"] = "ec.query"
  5128. bytesData, _ := json.Marshal(input)
  5129. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5130. fmt.Println(ret2)
  5131. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5132. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5133. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5134. }
  5135. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  5136. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5137. readCard := DllDef.MustFindProc("NationEcTrans")
  5138. fmt.Println(readCard)
  5139. fmt.Println("!!!!!")
  5140. pBusiCardInfo := make([]byte, 2048)
  5141. input := make(map[string]interface{})
  5142. inputData := make(map[string]interface{})
  5143. inputData["orgId"] = code
  5144. inputData["businessType"] = "01301"
  5145. inputData["operatorId"] = "9"
  5146. inputData["operatorName"] = "admin"
  5147. inputData["officeId"] = "001"
  5148. inputData["officeName"] = "血透室"
  5149. inputData["deviceType"] = ""
  5150. input["data"] = inputData
  5151. input["orgId"] = code
  5152. input["transType"] = "ec.query"
  5153. bytesData, _ := json.Marshal(input)
  5154. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5155. fmt.Println(ret2)
  5156. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5157. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5158. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5159. }
  5160. func GetJxEleBaseInfo(org_id int64) string {
  5161. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5162. readCard := DllDef.MustFindProc("NationEcTrans")
  5163. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5164. if readCard == nil {
  5165. fmt.Println("readcard is nil")
  5166. readCard = DllDef.MustFindProc("NationEcTrans")
  5167. }
  5168. str1 := make([]byte, 1024)
  5169. data := make(map[string]interface{})
  5170. inputData := make(map[string]interface{})
  5171. inputData["orgId"] = miConfig.Code
  5172. inputData["businessType"] = "01101"
  5173. inputData["operatorId"] = "test001"
  5174. inputData["operatorName"] = "cn"
  5175. inputData["officeId"] = "32760"
  5176. inputData["officeName"] = "waike"
  5177. inputData["deviceType"] = ""
  5178. data["data"] = inputData
  5179. data["transType"] = "ec.query"
  5180. data["extra "] = ""
  5181. data["orgId"] = miConfig.Code
  5182. bytesData, _ := json.Marshal(data)
  5183. //bytesData, _ := json.Marshal(data)
  5184. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5185. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5186. fmt.Println(ret2)
  5187. fmt.Println(string(str1))
  5188. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5189. if ret2 != 0 {
  5190. return ""
  5191. }
  5192. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5193. }
  5194. func GetJxEleBaseInitInfo(org_id int64) string {
  5195. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5196. readCard := DllDef.MustFindProc("NationEcTrans")
  5197. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5198. if readCard == nil {
  5199. fmt.Println("readcard is nil")
  5200. readCard = DllDef.MustFindProc("NationEcTrans")
  5201. }
  5202. str1 := make([]byte, 2048)
  5203. data := make(map[string]interface{})
  5204. inputData := make(map[string]interface{})
  5205. inputData["orgId"] = miConfig.Code
  5206. inputData["businessType"] = "01101"
  5207. inputData["operatorId"] = "1"
  5208. inputData["operatorName"] = "huangchuang"
  5209. inputData["officeId"] = "101"
  5210. inputData["officeName"] = "xuetou"
  5211. inputData["deviceType"] = ""
  5212. data["data"] = inputData
  5213. data["transType"] = "ec.query"
  5214. data["orgId"] = miConfig.Code
  5215. bytesData, _ := json.Marshal(data)
  5216. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5217. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5218. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  5219. fmt.Println(ret2)
  5220. fmt.Println(string(str1))
  5221. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5222. if ret2 != 0 {
  5223. return ""
  5224. }
  5225. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  5226. initEleFlag = 1
  5227. }
  5228. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5229. }
  5230. func (c *HisApiController) GetBasBaseInfo() string {
  5231. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5232. readCard := DllDef.MustFindProc("ReadCardBas")
  5233. if readCard == nil {
  5234. fmt.Println("readcard is nil")
  5235. readCard = DllDef.MustFindProc("ReadCardBas")
  5236. }
  5237. str := make([]byte, 1024)
  5238. str1 := make([]byte, 1024)
  5239. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5240. fmt.Println(string(str1))
  5241. fmt.Println(string(str))
  5242. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5243. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5244. if ret2 != 0 {
  5245. return ""
  5246. }
  5247. return string(str)
  5248. }
  5249. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  5250. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  5251. readCard := DllDef.MustFindProc("read_cardinfo")
  5252. if readCard == nil {
  5253. fmt.Println("readcard is nil")
  5254. readCard = DllDef.MustFindProc("read_cardinfo")
  5255. }
  5256. str := make([]byte, 1024) //卡号
  5257. str1 := make([]byte, 1024) //卡识别码
  5258. str2 := make([]byte, 1024) //身份证号
  5259. str3 := make([]byte, 1024) //姓名
  5260. str4 := make([]byte, 1024) //错误信息
  5261. 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])))
  5262. fmt.Println(string(str1))
  5263. fmt.Println(string(str))
  5264. fmt.Println(string(str2))
  5265. fmt.Println(string(str3))
  5266. fmt.Println(string(str4))
  5267. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5268. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5269. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  5270. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  5271. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  5272. if ret2 != 0 {
  5273. return "", "", "", "", ""
  5274. }
  5275. return string(str), string(str1), string(str2), string(str3), string(str4)
  5276. }
  5277. type CustomFundPay struct {
  5278. FundPayType string `json:"fund_pay_type"`
  5279. FundPayamt float64 `json:"fund_payamt"`
  5280. }
  5281. func (c *HisApiController) GetSettleList() {
  5282. order_id, _ := c.GetInt64("order_id")
  5283. admin_user_id, _ := c.GetInt64("admin_user_id")
  5284. order, _ := service.GetHisOrderByIDTwo(order_id)
  5285. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5286. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5287. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5288. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5289. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5290. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5291. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5292. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5293. if order.ID == 0 {
  5294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5295. return
  5296. }
  5297. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5298. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5299. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5300. //fmt.Println(count)
  5301. //var zero string
  5302. //number := count + 1
  5303. //if number >= 1000 {
  5304. // zero = "0000" + strconv.FormatInt(number, 10)
  5305. //} else if number >= 10000 {
  5306. // zero = "000" + strconv.FormatInt(number, 10)
  5307. //} else if number >= 100000 {
  5308. // zero = "00" + strconv.FormatInt(number, 10)
  5309. //} else if number >= 1000000 {
  5310. // zero = "0" + strconv.FormatInt(number, 10)
  5311. //} else {
  5312. // zero = strconv.FormatInt(number, 10)
  5313. //}
  5314. //fmt.Println(zero)
  5315. struct4101 := service.Struct4101{
  5316. PsnNo: order.PsnNo,
  5317. MdtrtId: order.MdtrtId,
  5318. SetlId: order.SetlId,
  5319. PsnName: order.PsnName,
  5320. Gend: order.Gend,
  5321. Brdy: his.Brdy,
  5322. Age: his.Age,
  5323. Naty: order.Naty,
  5324. PatnCertType: "01",
  5325. Certno: order.Certno,
  5326. Prfs: "90",
  5327. ConerName: roles[0].UserName,
  5328. PatnRlts: "99",
  5329. ConerAddr: miConfig.OrgName,
  5330. ConerTel: admin.Mobile,
  5331. HiType: order.Insutype,
  5332. Insuplc: miConfig.InsuplcAdmdvs,
  5333. MaindiagFlag: "1",
  5334. BillCode: order.SetlId,
  5335. BillNo: order.SetlId,
  5336. BizSn: order.Number,
  5337. PsnSelfPay: order.PsnPartAmt,
  5338. PsnOwnPay: order.PsnPartAmt,
  5339. AcctPay: order.AcctPay,
  5340. PsnCashpay: order.PsnCashPay,
  5341. HiPaymtd: "1",
  5342. Hsorg: miConfig.InsuplcAdmdvs,
  5343. HsorgOpter: miConfig.InsuplcAdmdvs,
  5344. MedinsFillPsn: curRoles.UserName,
  5345. MedinsFillDept: depart.Name,
  5346. IptMedType: "2",
  5347. }
  5348. struct4101.SetlBegnDate = order.SetlTime
  5349. struct4101.SetlEndDate = order.SetlTime
  5350. time_arr := strings.Split(order.SetlTime, " ")
  5351. struct4101.AdmTime = time_arr[0]
  5352. struct4101.AdmEndTime = time_arr[0]
  5353. var rf []CustomFundPay
  5354. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5355. var tempFunPays []service.CustomStruct
  5356. for _, item := range rf {
  5357. var tempFunPay service.CustomStruct
  5358. tempFunPay.FundPayamt = item.FundPayamt
  5359. tempFunPay.FundPayType = item.FundPayType
  5360. tempFunPays = append(tempFunPays, tempFunPay)
  5361. }
  5362. struct4101.CustomStruct = tempFunPays
  5363. var tempDiaginfos []service.DiaginfoStructTwo
  5364. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5365. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5366. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5367. var config []*models.HisXtDiagnoseConfig
  5368. for _, item := range diagnosis_ids {
  5369. id, _ := strconv.ParseInt(item, 10, 64)
  5370. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5371. config = append(config, &diagnosisConfig)
  5372. }
  5373. for index, item := range config {
  5374. if index == 0 {
  5375. var tempDiaginfo service.DiaginfoStructTwo
  5376. tempDiaginfo.DiagCode = item.CountryCode
  5377. tempDiaginfo.DiagName = item.CountryContentName
  5378. tempDiaginfo.DiagType = "1"
  5379. tempDiaginfo.MaindiagFlag = "1"
  5380. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5381. } else {
  5382. var tempDiaginfo service.DiaginfoStructTwo
  5383. tempDiaginfo.DiagCode = item.CountryCode
  5384. tempDiaginfo.DiagName = item.CountryContentName
  5385. tempDiaginfo.DiagType = "2"
  5386. tempDiaginfo.MaindiagFlag = "0"
  5387. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5388. }
  5389. }
  5390. struct4101.Diseinfo = tempDiaginfos
  5391. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5392. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5393. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5394. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  5395. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  5396. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5397. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5398. var iteminfo service.IteminfoStruct
  5399. var bedCostTotal float64 = 0 //床位总费
  5400. var bedCostSelfTotal float64 = 0 //床位自费
  5401. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5402. var operationCostTotal float64 = 0 //手术费
  5403. var operationCostSelfTotal float64 = 0 //手术费
  5404. var operationCostPartSelfTotal float64 = 0 //手术费
  5405. var otherCostTotal float64 = 0 //其他费用
  5406. var otherCostSelfTotal float64 = 0 //其他费用
  5407. var otherCostPartSelfTotal float64 = 0 //其他费用
  5408. var materialCostTotal float64 = 0 //材料费
  5409. var materialCostSelfTotal float64 = 0 //材料费
  5410. var materialCostPartSelfTotal float64 = 0 //材料费
  5411. var westernMedicineCostTotal float64 = 0 //西药费
  5412. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5413. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5414. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5415. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5416. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5417. var checkCostTotal float64 = 0 //检查费
  5418. var checkCostSelfTotal float64 = 0 //检查费
  5419. var checkCostPartSelfTotal float64 = 0 //检查费
  5420. var laboratoryCostTotal float64 = 0 //化验费
  5421. var laboratoryCostSelfTotal float64 = 0 //化验费
  5422. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5423. var treatCostTotal float64 = 0 //治疗费用
  5424. var treatCostSelfTotal float64 = 0 //治疗费用
  5425. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5426. decimal.DivisionPrecision = 2
  5427. var bed_fulamt_ownpay_amt float64 = 0
  5428. var operation_fulamt_ownpay_amt float64 = 0
  5429. var other_fulamt_ownpay_amt float64 = 0
  5430. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5431. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5432. var check_fulamt_ownpay_amt float64 = 0
  5433. var material_fulamt_ownpay_amt float64 = 0
  5434. var laboratory_fulamt_ownpay_amt float64 = 0
  5435. var treat_fulamt_ownpay_amt float64 = 0
  5436. var bed_claa_sunmfee float64 = 0
  5437. var bed_clab_amt float64 = 0
  5438. var bed_other_amt float64 = 0
  5439. var operation_claa_sunmfee float64 = 0
  5440. var operation_clab_amt float64 = 0
  5441. var operation_other_amt float64 = 0
  5442. var other_claa_sunmfee float64 = 0
  5443. var other_clab_amt float64 = 0
  5444. var other_other_amt float64 = 0
  5445. var westernMedicine_claa_sunmfee float64 = 0
  5446. var westernMedicine_clab_amt float64 = 0
  5447. var westernMedicine_other_amt float64 = 0
  5448. var chineseTraditional_claa_sunmfee float64 = 0
  5449. var chineseTraditional_clab_amt float64 = 0
  5450. var chineseTraditional_other_amt float64 = 0
  5451. var check_claa_sunmfee float64 = 0
  5452. var check_clab_amt float64 = 0
  5453. var check_other_amt float64 = 0
  5454. var material_claa_sunmfee float64 = 0
  5455. var material_clab_amt float64 = 0
  5456. var material_other_amt float64 = 0
  5457. var laboratory_claa_sunmfee float64 = 0
  5458. var laboratory_clab_amt float64 = 0
  5459. var laboratory_other_amt float64 = 0
  5460. var treat_claa_sunmfee float64 = 0
  5461. var treat_clab_amt float64 = 0
  5462. var treat_other_amt float64 = 0
  5463. for _, item := range order.HisOrderInfo {
  5464. if item.MedChrgitmType == "01" { //床位费
  5465. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5466. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5467. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5468. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5469. if item.ChrgitmLv == "1" {
  5470. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5471. }
  5472. if item.ChrgitmLv == "2" {
  5473. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5474. }
  5475. if item.ChrgitmLv == "3" {
  5476. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5477. }
  5478. }
  5479. if item.MedChrgitmType == "03" { //检查费
  5480. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5481. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5482. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5483. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5484. if item.ChrgitmLv == "1" {
  5485. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5486. }
  5487. if item.ChrgitmLv == "2" {
  5488. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5489. }
  5490. if item.ChrgitmLv == "3" {
  5491. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5492. }
  5493. }
  5494. if item.MedChrgitmType == "04" { //化验费
  5495. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5496. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5497. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5498. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5499. if item.ChrgitmLv == "1" {
  5500. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5501. }
  5502. if item.ChrgitmLv == "2" {
  5503. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5504. }
  5505. if item.ChrgitmLv == "3" {
  5506. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5507. }
  5508. }
  5509. if item.MedChrgitmType == "05" { //治疗费
  5510. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5511. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5512. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5513. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5514. if item.ChrgitmLv == "1" {
  5515. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5516. }
  5517. if item.ChrgitmLv == "2" {
  5518. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5519. }
  5520. if item.ChrgitmLv == "3" {
  5521. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5522. }
  5523. }
  5524. if item.MedChrgitmType == "06" { //手术费
  5525. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5526. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5527. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5528. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5529. if item.ChrgitmLv == "1" {
  5530. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5531. }
  5532. if item.ChrgitmLv == "2" {
  5533. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5534. }
  5535. if item.ChrgitmLv == "3" {
  5536. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5537. }
  5538. }
  5539. if item.MedChrgitmType == "08" { //材料费
  5540. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5541. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5542. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5543. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5544. if item.ChrgitmLv == "1" {
  5545. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5546. }
  5547. if item.ChrgitmLv == "2" {
  5548. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5549. }
  5550. if item.ChrgitmLv == "3" {
  5551. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5552. }
  5553. }
  5554. if item.MedChrgitmType == "09" { //西药费
  5555. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5556. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5557. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5558. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5559. if item.ChrgitmLv == "1" {
  5560. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5561. }
  5562. if item.ChrgitmLv == "2" {
  5563. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5564. }
  5565. if item.ChrgitmLv == "3" {
  5566. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5567. }
  5568. }
  5569. if item.MedChrgitmType == "11" { //中成费
  5570. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5571. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5572. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5573. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5574. if item.ChrgitmLv == "1" {
  5575. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5576. }
  5577. if item.ChrgitmLv == "2" {
  5578. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5579. }
  5580. if item.ChrgitmLv == "3" {
  5581. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5582. }
  5583. }
  5584. if item.MedChrgitmType == "14" { //其他费
  5585. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5586. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5587. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5588. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5589. if item.ChrgitmLv == "1" {
  5590. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5591. }
  5592. if item.ChrgitmLv == "2" {
  5593. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5594. }
  5595. if item.ChrgitmLv == "3" {
  5596. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5597. }
  5598. }
  5599. }
  5600. var iteminfoStructs []service.IteminfoStruct
  5601. if bedCostTotal != 0 {
  5602. iteminfo.MedChrgitm = "01"
  5603. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5604. iteminfo.Amt = bedCostTotal
  5605. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5606. iteminfo.ClabAmt = bed_clab_amt
  5607. iteminfo.OthAmt = bed_other_amt
  5608. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5609. }
  5610. if checkCostTotal != 0 {
  5611. iteminfo.MedChrgitm = "03"
  5612. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5613. iteminfo.Amt = checkCostTotal
  5614. iteminfo.ClaaSumfee = check_claa_sunmfee
  5615. iteminfo.ClabAmt = check_clab_amt
  5616. iteminfo.OthAmt = check_other_amt
  5617. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5618. }
  5619. if laboratoryCostTotal != 0 {
  5620. iteminfo.MedChrgitm = "04"
  5621. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5622. iteminfo.Amt = laboratoryCostTotal
  5623. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5624. iteminfo.ClabAmt = laboratory_clab_amt
  5625. iteminfo.OthAmt = laboratory_other_amt
  5626. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5627. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5628. }
  5629. if treatCostTotal != 0 {
  5630. iteminfo.MedChrgitm = "05"
  5631. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5632. iteminfo.Amt = treatCostTotal
  5633. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5634. iteminfo.ClabAmt = treat_clab_amt
  5635. iteminfo.OthAmt = treat_other_amt
  5636. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5637. //(struct4101.IteminfoStruct, iteminfo)
  5638. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5639. }
  5640. if operationCostTotal != 0 {
  5641. iteminfo.MedChrgitm = "06"
  5642. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5643. iteminfo.Amt = operationCostTotal
  5644. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5645. iteminfo.ClabAmt = operation_clab_amt
  5646. iteminfo.OthAmt = operation_other_amt
  5647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5648. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5649. }
  5650. if materialCostTotal != 0 {
  5651. iteminfo.MedChrgitm = "08"
  5652. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5653. iteminfo.Amt = materialCostTotal
  5654. iteminfo.ClaaSumfee = material_claa_sunmfee
  5655. iteminfo.ClabAmt = material_clab_amt
  5656. iteminfo.OthAmt = material_other_amt
  5657. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5658. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5659. }
  5660. if westernMedicineCostTotal != 0 {
  5661. iteminfo.MedChrgitm = "09"
  5662. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5663. iteminfo.Amt = westernMedicineCostTotal
  5664. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5665. iteminfo.ClabAmt = westernMedicine_clab_amt
  5666. iteminfo.OthAmt = westernMedicine_other_amt
  5667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5669. }
  5670. if chineseTraditionalMedicineCostTotal != 0 {
  5671. iteminfo.MedChrgitm = "11"
  5672. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5673. iteminfo.Amt = westernMedicineCostTotal
  5674. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5675. iteminfo.ClabAmt = westernMedicine_clab_amt
  5676. iteminfo.OthAmt = westernMedicine_other_amt
  5677. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5678. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5679. }
  5680. if otherCostTotal != 0 {
  5681. iteminfo.MedChrgitm = "14"
  5682. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5683. iteminfo.Amt = otherCostTotal
  5684. iteminfo.ClaaSumfee = other_claa_sunmfee
  5685. iteminfo.ClabAmt = other_clab_amt
  5686. iteminfo.OthAmt = other_other_amt
  5687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5688. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5689. }
  5690. struct4101.IteminfoStruct = iteminfoStructs
  5691. struct4101.Ntly = "中国"
  5692. struct4101.AdmCaty = "A03.06"
  5693. struct4101.DoctorName = doctor.UserName
  5694. struct4101.DoctorCode = doctor.DoctorNumber
  5695. var res ResultSeventeen
  5696. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5697. struct4101.BillCode = order.Number
  5698. struct4101.BillNo = order.SetlId
  5699. var resOther ResultSeventeenOther
  5700. var pp models.PublicParams
  5701. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5702. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5703. pp.FixmedinsName = miConfig.OrgName
  5704. pp.FixmedinsCode = miConfig.Code
  5705. pp.RequestUrl = miConfig.Url
  5706. pp.Cainfo = miConfig.Cainfo
  5707. pp.SecretKey = miConfig.SecretKey
  5708. pp.AccessKey = miConfig.AccessKey
  5709. pp.OpterName = curRoles.UserName
  5710. client := &http.Client{}
  5711. var req *http.Request
  5712. data := make(map[string]interface{})
  5713. data["struct4101"] = struct4101
  5714. data["pp"] = pp
  5715. bytesData, _ := json.Marshal(data)
  5716. if miConfig.MdtrtareaAdmvs == "320921" {
  5717. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5718. } else {
  5719. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5720. }
  5721. resp, _ := client.Do(req)
  5722. defer resp.Body.Close()
  5723. body, ioErr := ioutil.ReadAll(resp.Body)
  5724. if ioErr != nil {
  5725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. var respJSON map[string]interface{}
  5730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5733. return
  5734. }
  5735. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5736. userJSONBytes, _ := json.Marshal(respJSON)
  5737. fmt.Println("log")
  5738. fmt.Println(string(userJSONBytes))
  5739. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5740. utils.ErrorLog("解析失败:%v", err)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. return
  5743. }
  5744. res.InfRefmsgid = resOther.InfRefmsgid
  5745. res.Output = resOther.Output
  5746. res.ErrMsg = resOther.ErrMsg
  5747. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5748. res.Infcode = infocode
  5749. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5750. var pp models.PublicParams
  5751. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5752. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5753. pp.FixmedinsName = miConfig.OrgName
  5754. pp.FixmedinsCode = miConfig.Code
  5755. pp.RequestUrl = miConfig.Url
  5756. pp.Cainfo = miConfig.Cainfo
  5757. pp.SecretKey = miConfig.SecretKey
  5758. pp.AccessKey = miConfig.AccessKey
  5759. pp.OpterName = curRoles.UserName
  5760. result, _ := service.Jxyb4101(struct4101, pp)
  5761. var dat map[string]interface{}
  5762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5763. fmt.Println(dat)
  5764. } else {
  5765. fmt.Println(err)
  5766. }
  5767. userJSONBytes, _ := json.Marshal(dat)
  5768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5769. utils.ErrorLog("解析失败:%v", err)
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5774. var pp models.PublicParams
  5775. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5776. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5777. pp.FixmedinsName = miConfig.OrgName
  5778. pp.FixmedinsCode = miConfig.Code
  5779. pp.RequestUrl = miConfig.Url
  5780. pp.Cainfo = miConfig.Cainfo
  5781. pp.SecretKey = miConfig.SecretKey
  5782. pp.AccessKey = miConfig.AccessKey
  5783. pp.OpterName = curRoles.UserName
  5784. result, _ := service.Hnyb4101(struct4101, pp)
  5785. var dat map[string]interface{}
  5786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5787. fmt.Println(dat)
  5788. } else {
  5789. fmt.Println(err)
  5790. }
  5791. userJSONBytes, _ := json.Marshal(dat)
  5792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5793. utils.ErrorLog("解析失败:%v", err)
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5795. return
  5796. }
  5797. } else {
  5798. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5799. var dat map[string]interface{}
  5800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5801. fmt.Println(dat)
  5802. } else {
  5803. fmt.Println(err)
  5804. }
  5805. userJSONBytes, _ := json.Marshal(dat)
  5806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5807. utils.ErrorLog("解析失败:%v", err)
  5808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5809. return
  5810. }
  5811. }
  5812. if res.Infcode != 0 {
  5813. c.ServeSuccessJSON(map[string]interface{}{
  5814. "failed_code": -10,
  5815. "msg": res.ErrMsg,
  5816. })
  5817. return
  5818. } else {
  5819. //order.FaPiaoNumber = zero
  5820. //order.FaPiaoCode = last_order.FaPiaoCode
  5821. //service.UpdateOrder(order)
  5822. hisFundSettleListResult := &models.HisFundSettleListResult{
  5823. Number: res.Output.SetlListId,
  5824. Status: 1,
  5825. Ctime: time.Now().Unix(),
  5826. Mtime: time.Now().Unix(),
  5827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5828. IsUpload: 1,
  5829. OrderId: order_id,
  5830. }
  5831. service.CreateUploadRecord(hisFundSettleListResult)
  5832. c.ServeSuccessJSON(map[string]interface{}{
  5833. "msg": "上传成功",
  5834. "result": hisFundSettleListResult,
  5835. })
  5836. return
  5837. }
  5838. }
  5839. func (c *HisApiController) GetSettleListHospital() {
  5840. order_id, _ := c.GetInt64("order_id")
  5841. admin_user_id, _ := c.GetInt64("admin_user_id")
  5842. order, _ := service.GetHisOrderByIDTwo(order_id)
  5843. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5844. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5845. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5846. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5847. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5849. if order.ID == 0 {
  5850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5851. return
  5852. }
  5853. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5854. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5855. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5856. fmt.Println(count)
  5857. var zero string
  5858. number := count + 1
  5859. if number >= 1000 {
  5860. zero = "0000" + strconv.FormatInt(number, 10)
  5861. } else if number >= 10000 {
  5862. zero = "000" + strconv.FormatInt(number, 10)
  5863. } else if number >= 100000 {
  5864. zero = "00" + strconv.FormatInt(number, 10)
  5865. } else if number >= 1000000 {
  5866. zero = "0" + strconv.FormatInt(number, 10)
  5867. } else {
  5868. zero = strconv.FormatInt(number, 10)
  5869. }
  5870. fmt.Println(zero)
  5871. struct4101 := service.Struct4101{
  5872. PsnNo: order.PsnNo,
  5873. MdtrtId: order.MdtrtId,
  5874. SetlId: order.SetlId,
  5875. PsnName: order.PsnName,
  5876. Gend: order.Gend,
  5877. Brdy: his.Brdy,
  5878. Age: int64(order.Age),
  5879. Naty: order.Naty,
  5880. PatnCertType: "01",
  5881. Certno: order.Certno,
  5882. Prfs: "90",
  5883. ConerName: roles[0].UserName,
  5884. PatnRlts: "99",
  5885. ConerAddr: miConfig.OrgName,
  5886. ConerTel: admin.Mobile,
  5887. HiType: order.Insutype,
  5888. Insuplc: miConfig.InsuplcAdmdvs,
  5889. MaindiagFlag: "1",
  5890. BillCode: order.SetlId,
  5891. BillNo: order.SetlId,
  5892. BizSn: order.Number,
  5893. PsnSelfPay: order.PsnPartAmt,
  5894. PsnOwnPay: order.PsnPartAmt,
  5895. AcctPay: order.AcctPay,
  5896. PsnCashpay: order.PsnCashPay,
  5897. HiPaymtd: "1",
  5898. Hsorg: miConfig.InsuplcAdmdvs,
  5899. HsorgOpter: miConfig.InsuplcAdmdvs,
  5900. MedinsFillPsn: curRoles.UserName,
  5901. MedinsFillDept: depart.Name,
  5902. IptMedType: "2",
  5903. AdmTime: his.InHosptialTime,
  5904. AdmEndTime: his.OutHosptialTime,
  5905. }
  5906. struct4101.SetlBegnDate = order.SetlTime
  5907. struct4101.SetlEndDate = order.SetlTime
  5908. var rf []CustomFundPay
  5909. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5910. var tempFunPays []service.CustomStruct
  5911. for _, item := range rf {
  5912. var tempFunPay service.CustomStruct
  5913. tempFunPay.FundPayamt = item.FundPayamt
  5914. tempFunPay.FundPayType = item.FundPayType
  5915. tempFunPays = append(tempFunPays, tempFunPay)
  5916. }
  5917. struct4101.CustomStruct = tempFunPays
  5918. var tempDiaginfos []service.DiaginfoStructTwo
  5919. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5920. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5921. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5922. var config []*models.HisXtDiagnoseConfig
  5923. for _, item := range diagnosis_ids {
  5924. id, _ := strconv.ParseInt(item, 10, 64)
  5925. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5926. config = append(config, &diagnosisConfig)
  5927. }
  5928. for index, item := range config {
  5929. if index == 0 {
  5930. var tempDiaginfo service.DiaginfoStructTwo
  5931. tempDiaginfo.DiagCode = item.CountryCode
  5932. tempDiaginfo.DiagName = item.CountryContentName
  5933. tempDiaginfo.DiagType = "1"
  5934. tempDiaginfo.MaindiagFlag = "1"
  5935. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5936. } else {
  5937. var tempDiaginfo service.DiaginfoStructTwo
  5938. tempDiaginfo.DiagCode = item.CountryCode
  5939. tempDiaginfo.DiagName = item.CountryContentName
  5940. tempDiaginfo.DiagType = "2"
  5941. tempDiaginfo.MaindiagFlag = "0"
  5942. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5943. }
  5944. }
  5945. struct4101.Diseinfo = tempDiaginfos
  5946. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5947. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5948. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5949. tempOpspdiseinfo2.OprnOprtCode = ""
  5950. tempOpspdiseinfo2.OprnOprtName = ""
  5951. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5952. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5953. var iteminfo service.IteminfoStruct
  5954. var bedCostTotal float64 = 0 //床位总费
  5955. var bedCostSelfTotal float64 = 0 //床位自费
  5956. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5957. var operationCostTotal float64 = 0 //手术费
  5958. var operationCostSelfTotal float64 = 0 //手术费
  5959. var operationCostPartSelfTotal float64 = 0 //手术费
  5960. var otherCostTotal float64 = 0 //其他费用
  5961. var otherCostSelfTotal float64 = 0 //其他费用
  5962. var otherCostPartSelfTotal float64 = 0 //其他费用
  5963. var materialCostTotal float64 = 0 //材料费
  5964. var materialCostSelfTotal float64 = 0 //材料费
  5965. var materialCostPartSelfTotal float64 = 0 //材料费
  5966. var westernMedicineCostTotal float64 = 0 //西药费
  5967. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5968. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5969. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5970. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5971. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5972. var checkCostTotal float64 = 0 //检查费
  5973. var checkCostSelfTotal float64 = 0 //检查费
  5974. var checkCostPartSelfTotal float64 = 0 //检查费
  5975. var laboratoryCostTotal float64 = 0 //化验费
  5976. var laboratoryCostSelfTotal float64 = 0 //化验费
  5977. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5978. var treatCostTotal float64 = 0 //治疗费用
  5979. var treatCostSelfTotal float64 = 0 //治疗费用
  5980. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5981. decimal.DivisionPrecision = 2
  5982. var bed_fulamt_ownpay_amt float64 = 0
  5983. var operation_fulamt_ownpay_amt float64 = 0
  5984. var other_fulamt_ownpay_amt float64 = 0
  5985. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5986. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5987. var check_fulamt_ownpay_amt float64 = 0
  5988. var material_fulamt_ownpay_amt float64 = 0
  5989. var laboratory_fulamt_ownpay_amt float64 = 0
  5990. var treat_fulamt_ownpay_amt float64 = 0
  5991. var bed_claa_sunmfee float64 = 0
  5992. var bed_clab_amt float64 = 0
  5993. var bed_other_amt float64 = 0
  5994. var operation_claa_sunmfee float64 = 0
  5995. var operation_clab_amt float64 = 0
  5996. var operation_other_amt float64 = 0
  5997. var other_claa_sunmfee float64 = 0
  5998. var other_clab_amt float64 = 0
  5999. var other_other_amt float64 = 0
  6000. var westernMedicine_claa_sunmfee float64 = 0
  6001. var westernMedicine_clab_amt float64 = 0
  6002. var westernMedicine_other_amt float64 = 0
  6003. var chineseTraditional_claa_sunmfee float64 = 0
  6004. var chineseTraditional_clab_amt float64 = 0
  6005. var chineseTraditional_other_amt float64 = 0
  6006. var check_claa_sunmfee float64 = 0
  6007. var check_clab_amt float64 = 0
  6008. var check_other_amt float64 = 0
  6009. var material_claa_sunmfee float64 = 0
  6010. var material_clab_amt float64 = 0
  6011. var material_other_amt float64 = 0
  6012. var laboratory_claa_sunmfee float64 = 0
  6013. var laboratory_clab_amt float64 = 0
  6014. var laboratory_other_amt float64 = 0
  6015. var treat_claa_sunmfee float64 = 0
  6016. var treat_clab_amt float64 = 0
  6017. var treat_other_amt float64 = 0
  6018. for _, item := range order.HisOrderInfo {
  6019. if item.MedChrgitmType == "01" { //床位费
  6020. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6021. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6022. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6023. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6024. if item.ChrgitmLv == "1" {
  6025. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6026. }
  6027. if item.ChrgitmLv == "2" {
  6028. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6029. }
  6030. if item.ChrgitmLv == "3" {
  6031. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6032. }
  6033. }
  6034. if item.MedChrgitmType == "03" { //检查费
  6035. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6036. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6037. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6038. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6039. if item.ChrgitmLv == "1" {
  6040. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6041. }
  6042. if item.ChrgitmLv == "2" {
  6043. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6044. }
  6045. if item.ChrgitmLv == "3" {
  6046. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6047. }
  6048. }
  6049. if item.MedChrgitmType == "04" { //化验费
  6050. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6051. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6052. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6053. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6054. if item.ChrgitmLv == "1" {
  6055. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6056. }
  6057. if item.ChrgitmLv == "2" {
  6058. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6059. }
  6060. if item.ChrgitmLv == "3" {
  6061. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6062. }
  6063. }
  6064. if item.MedChrgitmType == "05" { //治疗费
  6065. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6066. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6067. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6068. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6069. if item.ChrgitmLv == "1" {
  6070. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6071. }
  6072. if item.ChrgitmLv == "2" {
  6073. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6074. }
  6075. if item.ChrgitmLv == "3" {
  6076. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6077. }
  6078. }
  6079. if item.MedChrgitmType == "06" { //手术费
  6080. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6081. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6082. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6083. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6084. if item.ChrgitmLv == "1" {
  6085. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6086. }
  6087. if item.ChrgitmLv == "2" {
  6088. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6089. }
  6090. if item.ChrgitmLv == "3" {
  6091. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6092. }
  6093. }
  6094. if item.MedChrgitmType == "08" { //材料费
  6095. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6096. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6097. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6098. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6099. if item.ChrgitmLv == "1" {
  6100. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6101. }
  6102. if item.ChrgitmLv == "2" {
  6103. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6104. }
  6105. if item.ChrgitmLv == "3" {
  6106. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6107. }
  6108. }
  6109. if item.MedChrgitmType == "09" { //西药费
  6110. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6111. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6112. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6113. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6114. if item.ChrgitmLv == "1" {
  6115. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6116. }
  6117. if item.ChrgitmLv == "2" {
  6118. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6119. }
  6120. if item.ChrgitmLv == "3" {
  6121. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6122. }
  6123. }
  6124. if item.MedChrgitmType == "11" { //中成费
  6125. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6126. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6127. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6128. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6129. if item.ChrgitmLv == "1" {
  6130. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6131. }
  6132. if item.ChrgitmLv == "2" {
  6133. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6134. }
  6135. if item.ChrgitmLv == "3" {
  6136. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6137. }
  6138. }
  6139. if item.MedChrgitmType == "14" { //其他费
  6140. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6141. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6142. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6143. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6144. if item.ChrgitmLv == "1" {
  6145. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6146. }
  6147. if item.ChrgitmLv == "2" {
  6148. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6149. }
  6150. if item.ChrgitmLv == "3" {
  6151. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6152. }
  6153. }
  6154. }
  6155. var iteminfoStructs []service.IteminfoStruct
  6156. if bedCostTotal != 0 {
  6157. iteminfo.MedChrgitm = "01"
  6158. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6159. iteminfo.Amt = bedCostTotal
  6160. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6161. iteminfo.ClabAmt = bed_clab_amt
  6162. iteminfo.OthAmt = bed_other_amt
  6163. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6164. }
  6165. if checkCostTotal != 0 {
  6166. iteminfo.MedChrgitm = "03"
  6167. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6168. iteminfo.Amt = checkCostTotal
  6169. iteminfo.ClaaSumfee = check_claa_sunmfee
  6170. iteminfo.ClabAmt = check_clab_amt
  6171. iteminfo.OthAmt = check_other_amt
  6172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6173. }
  6174. if laboratoryCostTotal != 0 {
  6175. iteminfo.MedChrgitm = "04"
  6176. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6177. iteminfo.Amt = laboratoryCostTotal
  6178. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6179. iteminfo.ClabAmt = laboratory_clab_amt
  6180. iteminfo.OthAmt = laboratory_other_amt
  6181. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6182. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6183. }
  6184. if treatCostTotal != 0 {
  6185. iteminfo.MedChrgitm = "05"
  6186. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6187. iteminfo.Amt = treatCostTotal
  6188. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6189. iteminfo.ClabAmt = treat_clab_amt
  6190. iteminfo.OthAmt = treat_other_amt
  6191. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6192. //(struct4101.IteminfoStruct, iteminfo)
  6193. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6194. }
  6195. if operationCostTotal != 0 {
  6196. iteminfo.MedChrgitm = "06"
  6197. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6198. iteminfo.Amt = operationCostTotal
  6199. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6200. iteminfo.ClabAmt = operation_clab_amt
  6201. iteminfo.OthAmt = operation_other_amt
  6202. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6203. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6204. }
  6205. if materialCostTotal != 0 {
  6206. iteminfo.MedChrgitm = "08"
  6207. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6208. iteminfo.Amt = materialCostTotal
  6209. iteminfo.ClaaSumfee = material_claa_sunmfee
  6210. iteminfo.ClabAmt = material_clab_amt
  6211. iteminfo.OthAmt = material_other_amt
  6212. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6214. }
  6215. if westernMedicineCostTotal != 0 {
  6216. iteminfo.MedChrgitm = "09"
  6217. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6218. iteminfo.Amt = westernMedicineCostTotal
  6219. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6220. iteminfo.ClabAmt = westernMedicine_clab_amt
  6221. iteminfo.OthAmt = westernMedicine_other_amt
  6222. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6224. }
  6225. if chineseTraditionalMedicineCostTotal != 0 {
  6226. iteminfo.MedChrgitm = "11"
  6227. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6228. iteminfo.Amt = westernMedicineCostTotal
  6229. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6230. iteminfo.ClabAmt = westernMedicine_clab_amt
  6231. iteminfo.OthAmt = westernMedicine_other_amt
  6232. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6233. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6234. }
  6235. if otherCostTotal != 0 {
  6236. iteminfo.MedChrgitm = "14"
  6237. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6238. iteminfo.Amt = otherCostTotal
  6239. iteminfo.ClaaSumfee = other_claa_sunmfee
  6240. iteminfo.ClabAmt = other_clab_amt
  6241. iteminfo.OthAmt = other_other_amt
  6242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6243. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6244. }
  6245. struct4101.IteminfoStruct = iteminfoStructs
  6246. struct4101.Ntly = "中国"
  6247. struct4101.AdmCaty = "A03.06"
  6248. var resOther ResultSeventeenOther
  6249. var res ResultSeventeen
  6250. if miConfig.MdtrtareaAdmvs == "150499" {
  6251. var pp models.PublicParams
  6252. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6253. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6254. pp.FixmedinsName = miConfig.OrgName
  6255. pp.FixmedinsCode = miConfig.Code
  6256. pp.RequestUrl = miConfig.Url
  6257. pp.Cainfo = miConfig.Cainfo
  6258. pp.SecretKey = miConfig.SecretKey
  6259. pp.AccessKey = miConfig.AccessKey
  6260. pp.OpterName = curRoles.UserName
  6261. client := &http.Client{}
  6262. var req *http.Request
  6263. data := make(map[string]interface{})
  6264. data["struct4101"] = struct4101
  6265. data["pp"] = pp
  6266. bytesData, _ := json.Marshal(data)
  6267. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  6268. resp, _ := client.Do(req)
  6269. defer resp.Body.Close()
  6270. body, ioErr := ioutil.ReadAll(resp.Body)
  6271. if ioErr != nil {
  6272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6274. return
  6275. }
  6276. var respJSON map[string]interface{}
  6277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6280. return
  6281. }
  6282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6283. userJSONBytes, _ := json.Marshal(respJSON)
  6284. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. res.InfRefmsgid = resOther.InfRefmsgid
  6290. res.Output = resOther.Output
  6291. res.ErrMsg = resOther.ErrMsg
  6292. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6293. res.Infcode = infocode
  6294. } else {
  6295. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6296. var dat map[string]interface{}
  6297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6298. fmt.Println(dat)
  6299. } else {
  6300. fmt.Println(err)
  6301. }
  6302. userJSONBytes, _ := json.Marshal(dat)
  6303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6304. utils.ErrorLog("解析失败:%v", err)
  6305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. return
  6307. }
  6308. }
  6309. if res.Infcode != 0 {
  6310. c.ServeSuccessJSON(map[string]interface{}{
  6311. "failed_code": -10,
  6312. "msg": res.ErrMsg,
  6313. })
  6314. return
  6315. } else {
  6316. if miConfig.MdtrtareaAdmvs != "150499" {
  6317. order.FaPiaoNumber = zero
  6318. order.FaPiaoCode = last_order.FaPiaoCode
  6319. service.UpdateOrder(order)
  6320. }
  6321. hisFundSettleListResult := &models.HisFundSettleListResult{
  6322. Number: res.Output.SetlListId,
  6323. Status: 1,
  6324. Ctime: time.Now().Unix(),
  6325. Mtime: time.Now().Unix(),
  6326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6327. IsUpload: 1,
  6328. OrderId: order_id,
  6329. }
  6330. service.CreateUploadRecord(hisFundSettleListResult)
  6331. c.ServeSuccessJSON(map[string]interface{}{
  6332. "msg": "上传成功",
  6333. "result": hisFundSettleListResult,
  6334. })
  6335. return
  6336. }
  6337. }
  6338. //func (c *HisApiController) GetBatchSettleList() {
  6339. // orders, _ := service.GetAllHisOrder(10106)
  6340. // for _, item := range orders {
  6341. // order_id := item.ID
  6342. // order, _ := service.GetHisOrderByIDTwo(order_id)
  6343. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6344. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6345. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6346. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  6347. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6348. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6349. //
  6350. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6351. //
  6352. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6353. //
  6354. // if order.ID == 0 {
  6355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6356. // return
  6357. // }
  6358. // if his.BalanceAccountsType == 2 {
  6359. // continue
  6360. // }
  6361. // struct4101 := service.Struct4101{
  6362. // PsnNo: order.PsnNo,
  6363. // MdtrtId: order.MdtrtId,
  6364. // SetlId: order.SetlId,
  6365. // PsnName: order.PsnName,
  6366. // Gend: order.Gend,
  6367. // Brdy: his.Brdy,
  6368. // Age: his.Age,
  6369. // Naty: order.Naty,
  6370. // PatnCertType: "01",
  6371. // Certno: order.Certno,
  6372. // Prfs: "90",
  6373. // ConerName: roles[0].UserName,
  6374. // PatnRlts: "99",
  6375. // ConerAddr: miConfig.OrgName,
  6376. // ConerTel: admin.Mobile,
  6377. // HiType: order.Insutype,
  6378. // Insuplc: his.InsuplcAdmdvs,
  6379. // MaindiagFlag: "1",
  6380. // BillCode: order.SetlId,
  6381. // BillNo: order.SetlId,
  6382. // BizSn: order.Number,
  6383. // PsnSelfPay: order.PsnPartAmt,
  6384. // PsnOwnPay: order.PsnPartAmt,
  6385. // AcctPay: order.AcctPay,
  6386. // PsnCashpay: order.PsnCashPay,
  6387. // HiPaymtd: "1",
  6388. // Hsorg: his.InsuplcAdmdvs,
  6389. // HsorgOpter: his.InsuplcAdmdvs,
  6390. // MedinsFillPsn: curRoles.UserName,
  6391. // MedinsFillDept: depart.Name,
  6392. // IptMedType: "2",
  6393. // }
  6394. // struct4101.SetlBegnDate = order.SetlTime
  6395. // struct4101.SetlEndDate = order.SetlTime
  6396. // //if order.SettleType == 1 {
  6397. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  6398. // // dateStr := t.Format("2006-01-02")
  6399. // // struct4101.SetlBegnDate = dateStr
  6400. // // struct4101.SetlEndDate = dateStr
  6401. // //} else {
  6402. // // t := time.Unix(int64(order.SettleStartTime), 0)
  6403. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  6404. // // dateStartStr := t.Format("2006-01-02")
  6405. // // dateEndStr := t2.Format("2006-01-02")
  6406. // // struct4101.SetlBegnDate = dateStartStr
  6407. // // struct4101.SetlEndDate = dateEndStr
  6408. // //}
  6409. //
  6410. // var rf []CustomFundPay
  6411. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  6412. //
  6413. // var tempFunPays []service.CustomStruct
  6414. // var tempFunPay610100 service.CustomStruct
  6415. //
  6416. // for _, item := range rf {
  6417. // if item.FundPayType == "610100" {
  6418. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  6419. // tempFunPay610100.FundPayType = item.FundPayType
  6420. // } else {
  6421. // var tempFunPay service.CustomStruct
  6422. // tempFunPay.FundPayamt = item.FundPayamt
  6423. // tempFunPay.FundPayType = item.FundPayType
  6424. // tempFunPays = append(tempFunPays, tempFunPay)
  6425. // }
  6426. // }
  6427. // tempFunPays = append(tempFunPays, tempFunPay610100)
  6428. // struct4101.CustomStruct = tempFunPays
  6429. //
  6430. // var tempDiaginfos []service.DiaginfoStructTwo
  6431. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6432. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6433. //
  6434. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6435. // var config []*models.HisXtDiagnoseConfig
  6436. // for _, item := range diagnosis_ids {
  6437. // id, _ := strconv.ParseInt(item, 10, 64)
  6438. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6439. // config = append(config, &diagnosisConfig)
  6440. // }
  6441. //
  6442. // for index, item := range config {
  6443. // if index == 0 {
  6444. // var tempDiaginfo service.DiaginfoStructTwo
  6445. // tempDiaginfo.DiagCode = item.CountryCode
  6446. // tempDiaginfo.DiagName = item.CountryContentName
  6447. // tempDiaginfo.DiagType = "1"
  6448. // tempDiaginfo.MaindiagFlag = "1"
  6449. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6450. // } else {
  6451. //
  6452. // var tempDiaginfo service.DiaginfoStructTwo
  6453. // tempDiaginfo.DiagCode = item.CountryCode
  6454. // tempDiaginfo.DiagName = item.CountryContentName
  6455. // tempDiaginfo.DiagType = "2"
  6456. // tempDiaginfo.MaindiagFlag = "0"
  6457. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6458. // }
  6459. // }
  6460. // struct4101.Diseinfo = tempDiaginfos
  6461. //
  6462. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  6463. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6464. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6465. // tempOpspdiseinfo2.OprnOprtCode = ""
  6466. // tempOpspdiseinfo2.OprnOprtName = ""
  6467. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6468. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6469. //
  6470. // var iteminfo service.IteminfoStruct
  6471. //
  6472. // var bedCostTotal float64 = 0 //床位总费
  6473. // var bedCostSelfTotal float64 = 0 //床位自费
  6474. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6475. //
  6476. // var examineCostTotal float64 = 0 //诊查总费
  6477. // var examineCostSelfTotal float64 = 0 //诊查自费
  6478. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  6479. //
  6480. // var nursingCostTotal float64 = 0 //护理总费
  6481. // var nursingCostSelfTotal float64 = 0 //护理自费
  6482. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  6483. //
  6484. // var chineseMedicineCostTotal float64 = 0 //中成药
  6485. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  6486. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  6487. //
  6488. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  6489. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  6490. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  6491. //
  6492. // var registerCostTotal float64 = 0 //一般诊疗费
  6493. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  6494. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  6495. //
  6496. // var operationCostTotal float64 = 0 //手术费
  6497. // var operationCostSelfTotal float64 = 0 //手术费
  6498. // var operationCostPartSelfTotal float64 = 0 //手术费
  6499. //
  6500. // var otherCostTotal float64 = 0 //其他费用
  6501. // var otherCostSelfTotal float64 = 0 //其他费用
  6502. // var otherCostPartSelfTotal float64 = 0 //其他费用
  6503. //
  6504. // var materialCostTotal float64 = 0 //材料费
  6505. // var materialCostSelfTotal float64 = 0 //材料费
  6506. // var materialCostPartSelfTotal float64 = 0 //材料费
  6507. //
  6508. // var westernMedicineCostTotal float64 = 0 //西药费
  6509. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  6510. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6511. //
  6512. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6513. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6514. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6515. //
  6516. // var checkCostTotal float64 = 0 //检查费
  6517. // var checkCostSelfTotal float64 = 0 //检查费
  6518. // var checkCostPartSelfTotal float64 = 0 //检查费
  6519. //
  6520. // var laboratoryCostTotal float64 = 0 //化验费
  6521. // var laboratoryCostSelfTotal float64 = 0 //化验费
  6522. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6523. //
  6524. // var treatCostTotal float64 = 0 //治疗费用
  6525. // var treatCostSelfTotal float64 = 0 //治疗费用
  6526. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6527. //
  6528. // decimal.DivisionPrecision = 2
  6529. //
  6530. // var bed_fulamt_ownpay_amt float64 = 0
  6531. //
  6532. // var examine_fulamt_ownpay_amt float64 = 0
  6533. //
  6534. // var nursing_fulamt_ownpay_amt float64 = 0
  6535. //
  6536. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6537. //
  6538. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6539. //
  6540. // var register_fulamt_ownpay_amt float64 = 0
  6541. //
  6542. // var operation_fulamt_ownpay_amt float64 = 0
  6543. // var other_fulamt_ownpay_amt float64 = 0
  6544. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6545. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6546. // var check_fulamt_ownpay_amt float64 = 0
  6547. // var material_fulamt_ownpay_amt float64 = 0
  6548. // var laboratory_fulamt_ownpay_amt float64 = 0
  6549. // var treat_fulamt_ownpay_amt float64 = 0
  6550. //
  6551. // var bed_claa_sunmfee float64 = 0
  6552. // var bed_clab_amt float64 = 0
  6553. // var bed_other_amt float64 = 0
  6554. //
  6555. // var examine_claa_sunmfee float64 = 0
  6556. // var examine_clab_amt float64 = 0
  6557. // var examine_other_amt float64 = 0
  6558. //
  6559. // var nursing_claa_sunmfee float64 = 0
  6560. // var nursing_clab_amt float64 = 0
  6561. // var nursing_other_amt float64 = 0
  6562. //
  6563. // var chinese_medicine_claa_sunmfee float64 = 0
  6564. // var chinese_medicine_clab_amt float64 = 0
  6565. // var chinese_medicine_other_amt float64 = 0
  6566. //
  6567. // var commonly_treatment_claa_sunmfee float64 = 0
  6568. // var commonly_treatment_clab_amt float64 = 0
  6569. // var commonly_treatment_other_amt float64 = 0
  6570. //
  6571. // var operation_claa_sunmfee float64 = 0
  6572. // var operation_clab_amt float64 = 0
  6573. // var operation_other_amt float64 = 0
  6574. //
  6575. // var other_claa_sunmfee float64 = 0
  6576. // var other_clab_amt float64 = 0
  6577. // var other_other_amt float64 = 0
  6578. //
  6579. // var westernMedicine_claa_sunmfee float64 = 0
  6580. // var westernMedicine_clab_amt float64 = 0
  6581. // var westernMedicine_other_amt float64 = 0
  6582. //
  6583. // var chineseTraditional_claa_sunmfee float64 = 0
  6584. // var chineseTraditional_clab_amt float64 = 0
  6585. // var chineseTraditional_other_amt float64 = 0
  6586. //
  6587. // var check_claa_sunmfee float64 = 0
  6588. // var check_clab_amt float64 = 0
  6589. // var check_other_amt float64 = 0
  6590. //
  6591. // var material_claa_sunmfee float64 = 0
  6592. // var material_clab_amt float64 = 0
  6593. // var material_other_amt float64 = 0
  6594. //
  6595. // var laboratory_claa_sunmfee float64 = 0
  6596. // var laboratory_clab_amt float64 = 0
  6597. // var laboratory_other_amt float64 = 0
  6598. //
  6599. // var treat_claa_sunmfee float64 = 0
  6600. // var treat_clab_amt float64 = 0
  6601. // var treat_other_amt float64 = 0
  6602. //
  6603. // var register_claa_sunmfee float64 = 0
  6604. // var register_clab_amt float64 = 0
  6605. // var register_other_amt float64 = 0
  6606. //
  6607. // for _, item := range order.HisOrderInfo {
  6608. // if item.MedChrgitmType == "01" { //床位费
  6609. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6610. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6611. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6612. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6613. // if item.ChrgitmLv == "1" {
  6614. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6615. // }
  6616. // if item.ChrgitmLv == "2" {
  6617. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6618. //
  6619. // }
  6620. // if item.ChrgitmLv == "3" {
  6621. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6622. // }
  6623. //
  6624. // }
  6625. //
  6626. // if item.MedChrgitmType == "02" { //诊查
  6627. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6628. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6629. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6630. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6631. // if item.ChrgitmLv == "1" {
  6632. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6633. // }
  6634. // if item.ChrgitmLv == "2" {
  6635. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6636. //
  6637. // }
  6638. // if item.ChrgitmLv == "3" {
  6639. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6640. // }
  6641. //
  6642. // }
  6643. //
  6644. // if item.MedChrgitmType == "03" { //检查费
  6645. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6646. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6647. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6648. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6649. // if item.ChrgitmLv == "1" {
  6650. //
  6651. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6652. //
  6653. // }
  6654. // if item.ChrgitmLv == "2" {
  6655. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6656. //
  6657. // }
  6658. // if item.ChrgitmLv == "3" {
  6659. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6660. // }
  6661. // }
  6662. //
  6663. // if item.MedChrgitmType == "04" { //化验费
  6664. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6665. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6666. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6667. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6668. // if item.ChrgitmLv == "1" {
  6669. //
  6670. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6671. //
  6672. // }
  6673. // if item.ChrgitmLv == "2" {
  6674. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6675. //
  6676. // }
  6677. // if item.ChrgitmLv == "3" {
  6678. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6679. // }
  6680. // }
  6681. //
  6682. // if item.MedChrgitmType == "05" { //治疗费
  6683. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6684. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6685. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6686. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6687. // if item.ChrgitmLv == "1" {
  6688. //
  6689. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6690. //
  6691. // }
  6692. // if item.ChrgitmLv == "2" {
  6693. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6694. //
  6695. // }
  6696. // if item.ChrgitmLv == "3" {
  6697. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6698. // }
  6699. // }
  6700. //
  6701. // if item.MedChrgitmType == "06" { //手术费
  6702. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6703. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6704. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6705. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6706. //
  6707. // if item.ChrgitmLv == "1" {
  6708. //
  6709. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6710. //
  6711. // }
  6712. // if item.ChrgitmLv == "2" {
  6713. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6714. //
  6715. // }
  6716. // if item.ChrgitmLv == "3" {
  6717. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6718. // }
  6719. // }
  6720. //
  6721. // if item.MedChrgitmType == "07" { //手术费
  6722. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6723. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6724. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6725. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6726. //
  6727. // if item.ChrgitmLv == "1" {
  6728. //
  6729. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6730. //
  6731. // }
  6732. // if item.ChrgitmLv == "2" {
  6733. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6734. //
  6735. // }
  6736. // if item.ChrgitmLv == "3" {
  6737. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6738. // }
  6739. // }
  6740. //
  6741. // if item.MedChrgitmType == "08" { //材料费
  6742. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6743. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6744. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6745. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6746. // if item.ChrgitmLv == "1" {
  6747. //
  6748. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6749. //
  6750. // }
  6751. // if item.ChrgitmLv == "2" {
  6752. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6753. //
  6754. // }
  6755. // if item.ChrgitmLv == "3" {
  6756. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6757. // }
  6758. // }
  6759. // if item.MedChrgitmType == "09" { //西药费
  6760. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6761. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6762. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6763. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6764. // if item.ChrgitmLv == "1" {
  6765. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6766. // }
  6767. // if item.ChrgitmLv == "2" {
  6768. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6769. // }
  6770. // if item.ChrgitmLv == "3" {
  6771. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6772. // }
  6773. // }
  6774. // if item.MedChrgitmType == "10" { //中药饮片
  6775. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6776. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6777. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6778. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6779. // if item.ChrgitmLv == "1" {
  6780. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6781. // }
  6782. // if item.ChrgitmLv == "2" {
  6783. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6784. // }
  6785. // if item.ChrgitmLv == "3" {
  6786. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6787. // }
  6788. // }
  6789. //
  6790. // if item.MedChrgitmType == "11" { //中成费
  6791. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6792. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6793. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6794. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6795. // if item.ChrgitmLv == "1" {
  6796. //
  6797. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6798. //
  6799. // }
  6800. // if item.ChrgitmLv == "2" {
  6801. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6802. //
  6803. // }
  6804. // if item.ChrgitmLv == "3" {
  6805. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6806. // }
  6807. // }
  6808. //
  6809. // if item.MedChrgitmType == "12" { //中成费
  6810. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6811. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6812. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6813. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6814. // if item.ChrgitmLv == "1" {
  6815. //
  6816. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6817. //
  6818. // }
  6819. // if item.ChrgitmLv == "2" {
  6820. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6821. //
  6822. // }
  6823. // if item.ChrgitmLv == "3" {
  6824. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6825. // }
  6826. // }
  6827. //
  6828. // if item.MedChrgitmType == "13" { //中成费
  6829. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6830. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6831. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6832. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6833. // if item.ChrgitmLv == "1" {
  6834. //
  6835. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6836. //
  6837. // }
  6838. // if item.ChrgitmLv == "2" {
  6839. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6840. //
  6841. // }
  6842. // if item.ChrgitmLv == "3" {
  6843. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6844. // }
  6845. // }
  6846. //
  6847. // if item.MedChrgitmType == "14" { //其他费
  6848. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6849. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6850. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6851. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6852. // if item.ChrgitmLv == "1" {
  6853. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6854. //
  6855. // }
  6856. // if item.ChrgitmLv == "2" {
  6857. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6858. //
  6859. // }
  6860. // if item.ChrgitmLv == "3" {
  6861. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6862. // }
  6863. // }
  6864. //
  6865. // }
  6866. //
  6867. // var iteminfoStructs []service.IteminfoStruct
  6868. //
  6869. // if bedCostTotal != 0 {
  6870. // iteminfo.MedChrgitm = "01"
  6871. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6872. // iteminfo.Amt = bedCostTotal
  6873. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  6874. // iteminfo.ClabAmt = bed_clab_amt
  6875. // iteminfo.OthAmt = bed_other_amt
  6876. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6877. // }
  6878. //
  6879. // if examineCostTotal != 0 {
  6880. // iteminfo.MedChrgitm = "02"
  6881. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  6882. // iteminfo.Amt = examineCostTotal
  6883. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  6884. // iteminfo.ClabAmt = examine_clab_amt
  6885. // iteminfo.OthAmt = examine_other_amt
  6886. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6887. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6888. // }
  6889. //
  6890. // if checkCostTotal != 0 {
  6891. // iteminfo.MedChrgitm = "03"
  6892. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6893. // iteminfo.Amt = checkCostTotal
  6894. // iteminfo.ClaaSumfee = check_claa_sunmfee
  6895. // iteminfo.ClabAmt = check_clab_amt
  6896. // iteminfo.OthAmt = check_other_amt
  6897. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6898. //
  6899. // }
  6900. //
  6901. // if laboratoryCostTotal != 0 {
  6902. // iteminfo.MedChrgitm = "04"
  6903. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6904. // iteminfo.Amt = laboratoryCostTotal
  6905. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6906. // iteminfo.ClabAmt = laboratory_clab_amt
  6907. // iteminfo.OthAmt = laboratory_other_amt
  6908. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6909. //
  6910. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6911. //
  6912. // }
  6913. //
  6914. // if treatCostTotal != 0 {
  6915. // iteminfo.MedChrgitm = "05"
  6916. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6917. // iteminfo.Amt = treatCostTotal
  6918. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  6919. // iteminfo.ClabAmt = treat_clab_amt
  6920. // iteminfo.OthAmt = treat_other_amt
  6921. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6922. // //(struct4101.IteminfoStruct, iteminfo)
  6923. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6924. // }
  6925. //
  6926. // if operationCostTotal != 0 {
  6927. // iteminfo.MedChrgitm = "06"
  6928. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6929. // iteminfo.Amt = operationCostTotal
  6930. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  6931. // iteminfo.ClabAmt = operation_clab_amt
  6932. // iteminfo.OthAmt = operation_other_amt
  6933. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6934. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6935. // }
  6936. //
  6937. // if nursingCostTotal != 0 {
  6938. // iteminfo.MedChrgitm = "07"
  6939. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  6940. // iteminfo.Amt = nursingCostTotal
  6941. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  6942. // iteminfo.ClabAmt = nursing_clab_amt
  6943. // iteminfo.OthAmt = nursing_other_amt
  6944. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6945. // }
  6946. //
  6947. // if materialCostTotal != 0 {
  6948. // iteminfo.MedChrgitm = "08"
  6949. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6950. // iteminfo.Amt = materialCostTotal
  6951. // iteminfo.ClaaSumfee = material_claa_sunmfee
  6952. // iteminfo.ClabAmt = material_clab_amt
  6953. // iteminfo.OthAmt = material_other_amt
  6954. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6955. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6956. // }
  6957. //
  6958. // if westernMedicineCostTotal != 0 {
  6959. // iteminfo.MedChrgitm = "09"
  6960. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6961. // iteminfo.Amt = westernMedicineCostTotal
  6962. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6963. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6964. // iteminfo.OthAmt = westernMedicine_other_amt
  6965. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6966. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6967. //
  6968. // }
  6969. //
  6970. // if chineseMedicineCostTotal != 0 {
  6971. // iteminfo.MedChrgitm = "10"
  6972. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6973. // iteminfo.Amt = chineseMedicineCostTotal
  6974. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6975. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  6976. // iteminfo.OthAmt = chinese_medicine_other_amt
  6977. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6978. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6979. //
  6980. // }
  6981. //
  6982. // if chineseTraditionalMedicineCostTotal != 0 {
  6983. // iteminfo.MedChrgitm = "11"
  6984. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6985. // iteminfo.Amt = westernMedicineCostTotal
  6986. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6987. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6988. // iteminfo.OthAmt = westernMedicine_other_amt
  6989. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6990. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6991. //
  6992. // }
  6993. //
  6994. // if commonlyTreatmentCostTotal != 0 {
  6995. // iteminfo.MedChrgitm = "12"
  6996. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6997. // iteminfo.Amt = commonlyTreatmentCostTotal
  6998. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6999. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  7000. // iteminfo.OthAmt = commonly_treatment_other_amt
  7001. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7002. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7003. //
  7004. // }
  7005. //
  7006. // if registerCostTotal != 0 {
  7007. // iteminfo.MedChrgitm = "13"
  7008. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  7009. // iteminfo.Amt = registerCostTotal
  7010. // iteminfo.ClaaSumfee = register_claa_sunmfee
  7011. // iteminfo.ClabAmt = register_clab_amt
  7012. // iteminfo.OthAmt = register_other_amt
  7013. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7014. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7015. //
  7016. // }
  7017. //
  7018. // if otherCostTotal != 0 {
  7019. // iteminfo.MedChrgitm = "14"
  7020. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7021. // iteminfo.Amt = otherCostTotal
  7022. // iteminfo.ClaaSumfee = other_claa_sunmfee
  7023. // iteminfo.ClabAmt = other_clab_amt
  7024. // iteminfo.OthAmt = other_other_amt
  7025. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7026. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7027. //
  7028. // }
  7029. // struct4101.IteminfoStruct = iteminfoStructs
  7030. // time_arr := strings.Split(order.SetlTime, " ")
  7031. // struct4101.AdmTime = time_arr[0]
  7032. // struct4101.AdmEndTime = time_arr[0]
  7033. //
  7034. // struct4101.DoctorName = doctor.UserName
  7035. // struct4101.DoctorCode = doctor.DoctorNumber
  7036. //
  7037. // struct4101.Ntly = "中国"
  7038. // struct4101.AdmCaty = "A03.06"
  7039. // var res ResultSeventeen
  7040. // if miConfig.MdtrtareaAdmvs == "421300" {
  7041. // data := make(map[string]interface{})
  7042. // data["struct4101"] = struct4101
  7043. // data["secret_key"] = miConfig.SecretKey
  7044. // data["org_name"] = miConfig.OrgName
  7045. // data["opera"] = curRoles.UserName
  7046. // data["code"] = miConfig.Code
  7047. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7048. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7049. //
  7050. // client := &http.Client{}
  7051. // bytesData, _ := json.Marshal(data)
  7052. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  7053. // resp, _ := client.Do(req)
  7054. // defer resp.Body.Close()
  7055. // body, ioErr := ioutil.ReadAll(resp.Body)
  7056. // if ioErr != nil {
  7057. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. // return
  7060. // }
  7061. // var respJSON map[string]interface{}
  7062. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7063. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7065. // return
  7066. // }
  7067. //
  7068. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7069. // userJSONBytes, _ := json.Marshal(respJSON)
  7070. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7071. // utils.ErrorLog("解析失败:%v", err)
  7072. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. // adminUser := c.GetAdminUserInfo()
  7074. // errlog := &models.HisOrderError{
  7075. // UserOrgId: adminUser.CurrentOrgId,
  7076. // Ctime: time.Now().Unix(),
  7077. // Mtime: time.Now().Unix(),
  7078. // ErrMsg: res.ErrMsg + "解析失败",
  7079. // Status: 1,
  7080. // PatientId: order_id,
  7081. // Stage: 10088,
  7082. // }
  7083. // service.CreateErrMsgLog(errlog)
  7084. // continue
  7085. // }
  7086. //
  7087. // } else {
  7088. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  7089. // fmt.Println(result)
  7090. //
  7091. // var dat map[string]interface{}
  7092. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7093. // fmt.Println(dat)
  7094. // } else {
  7095. // fmt.Println(err)
  7096. // }
  7097. // userJSONBytes, _ := json.Marshal(dat)
  7098. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7099. // utils.ErrorLog("解析失败:%v", err)
  7100. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7101. // adminUser := c.GetAdminUserInfo()
  7102. // errlog := &models.HisOrderError{
  7103. // UserOrgId: adminUser.CurrentOrgId,
  7104. // Ctime: time.Now().Unix(),
  7105. // Mtime: time.Now().Unix(),
  7106. // ErrMsg: res.ErrMsg + "解析失败",
  7107. // Status: 1,
  7108. // PatientId: order_id,
  7109. // Stage: 10106,
  7110. // }
  7111. // service.CreateErrMsgLog(errlog)
  7112. // continue
  7113. // }
  7114. // }
  7115. //
  7116. // if res.Infcode != 0 {
  7117. // adminUser := c.GetAdminUserInfo()
  7118. // errlog := &models.HisOrderError{
  7119. // UserOrgId: adminUser.CurrentOrgId,
  7120. // Ctime: time.Now().Unix(),
  7121. // Mtime: time.Now().Unix(),
  7122. // ErrMsg: res.ErrMsg,
  7123. // Status: 1,
  7124. // PatientId: order_id,
  7125. // Stage: 10106,
  7126. // }
  7127. // service.CreateErrMsgLog(errlog)
  7128. // continue
  7129. // } else {
  7130. // hisFundSettleListResult := &models.HisFundSettleListResult{
  7131. // Number: res.Output.SetlListId,
  7132. // Status: 1,
  7133. // Ctime: time.Now().Unix(),
  7134. // Mtime: time.Now().Unix(),
  7135. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7136. // IsUpload: 1,
  7137. // OrderId: order_id,
  7138. // }
  7139. // service.CreateUploadRecord(hisFundSettleListResult)
  7140. // continue
  7141. // }
  7142. // }
  7143. //}
  7144. func (c *HisApiController) GetOrgInfo() {
  7145. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  7146. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  7147. }
  7148. func (c *HisApiController) GetHisPatientInfo() {
  7149. medical_insurance_card := c.GetString("medical_insurance_card")
  7150. id_card_type, _ := c.GetInt64("id_card_type")
  7151. id_card := c.GetString("id_card")
  7152. adminInfo := c.GetAdminUserInfo()
  7153. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7154. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7155. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  7156. IdCardNo := ""
  7157. if id_card_type == 1 {
  7158. IdCardNo = medical_insurance_card
  7159. } else if id_card_type == 2 {
  7160. IdCardNo = id_card
  7161. }
  7162. if config.IsOpen == 1 {
  7163. 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
  7164. resp, requestErr := http.Get(api)
  7165. if requestErr != nil {
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. defer resp.Body.Close()
  7170. body, ioErr := ioutil.ReadAll(resp.Body)
  7171. if ioErr != nil {
  7172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. var respJSON map[string]interface{}
  7177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7180. return
  7181. }
  7182. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7183. userJSONBytes, _ := json.Marshal(userJSON)
  7184. var res ResultTwo
  7185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7186. utils.ErrorLog("解析失败:%v", err)
  7187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7188. return
  7189. }
  7190. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7191. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7192. infoStr := string(Iinfos)
  7193. idetinfoStr := string(Idetinfos)
  7194. if res.Infcode == 0 {
  7195. his := models.VMHisPatient{
  7196. Status: 1,
  7197. Ctime: time.Now().Unix(),
  7198. Mtime: time.Now().Unix(),
  7199. PsnNo: res.Output.Baseinfo.PsnNo,
  7200. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7201. Certno: res.Output.Baseinfo.Certno,
  7202. PsnName: res.Output.Baseinfo.PsnName,
  7203. Gend: res.Output.Baseinfo.Gend,
  7204. Naty: res.Output.Baseinfo.Naty,
  7205. Brdy: res.Output.Baseinfo.Brdy,
  7206. Age: res.Output.Baseinfo.Age,
  7207. Iinfo: infoStr,
  7208. Idetinfo: idetinfoStr,
  7209. UserOrgId: adminInfo.CurrentOrgId,
  7210. IsReturn: 1,
  7211. IdCardType: id_card_type,
  7212. }
  7213. c.ServeSuccessJSON(map[string]interface{}{
  7214. "info": his,
  7215. })
  7216. } else {
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7218. return
  7219. }
  7220. }
  7221. }
  7222. //func GetBasBaseInfo() (jsonStr string, err error) {
  7223. //
  7224. // handle := syscall.NewLazyDLL("SSCard.dll")
  7225. // add := handle.NewProc("ReadCardBas")
  7226. // str := make([]byte, 1024)
  7227. // str1 := make([]byte, 1024)
  7228. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7229. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  7230. //
  7231. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  7232. //
  7233. // fmt.Println("> Add(4,5)的结果为:", ret)
  7234. // handle.Release()
  7235. //
  7236. // return "", nil
  7237. //
  7238. //}
  7239. //func GetQRBaseInfo() (jsonStr string, err error) {
  7240. // handle := syscall.LoadDLL("SSCard.dll")
  7241. // ReadCardBas := handle.FindProc("GetQRBase")
  7242. //
  7243. // str := make([]byte, 256)
  7244. // str1 := make([]byte, 256)
  7245. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7246. //
  7247. // fmt.Println(string(str))
  7248. // fmt.Println(r)
  7249. // return string(str), nil
  7250. //}
  7251. //func CardInit() int {
  7252. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  7253. // add := DllTestDef.MustFindProc("Init")
  7254. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7255. // if err != nil {
  7256. // fmt.Println("SSCard的运算结果为:", ret)
  7257. // }
  7258. // result := int(ret)
  7259. // return result
  7260. //}
  7261. //func CardInit() int {
  7262. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7263. // if err != nil {
  7264. // fmt.Println("SSCard的运算结果为:", ret)
  7265. // }
  7266. // fmt.Println(err)
  7267. // result := int(ret)
  7268. // return result
  7269. //}
  7270. func IntPtr(n int) uintptr {
  7271. return uintptr(n)
  7272. }
  7273. func StrPtr(s string) uintptr {
  7274. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  7275. }
  7276. type Result2001 struct {
  7277. Cainfo interface{} `json:"cainfo"`
  7278. ErrMsg string `json:"err_msg"`
  7279. InfRefmsgid string `json:"inf_refmsgid"`
  7280. Infcode int64 `json:"infcode"`
  7281. Output struct {
  7282. Trtinfo struct {
  7283. PsnNo string `json:"psn_no"`
  7284. TrtChkType string `json:"trt_chk_type"`
  7285. FundPayType string `json:"fund_pay_type"`
  7286. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7287. Begndate string `json:"begndate"`
  7288. Enddate string `json:"enddate"`
  7289. TrtChkRslt string `json:"trt_chk_rslt"`
  7290. } `json:"trtinfo"`
  7291. } `json:"output"`
  7292. RefmsgTime string `json:"refmsg_time"`
  7293. RespondTime string `json:"respond_time"`
  7294. Signtype interface{} `json:"signtype"`
  7295. WarnMsg interface{} `json:"warn_msg"`
  7296. }
  7297. type Result2001Org10265 struct {
  7298. Cainfo interface{} `json:"cainfo"`
  7299. ErrMsg string `json:"err_msg"`
  7300. InfRefmsgid string `json:"inf_refmsgid"`
  7301. Infcode string `json:"infcode"`
  7302. Output struct {
  7303. Trtinfo struct {
  7304. PsnNo string `json:"psn_no"`
  7305. TrtChkType string `json:"trt_chk_type"`
  7306. FundPayType string `json:"fund_pay_type"`
  7307. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7308. Begndate string `json:"begndate"`
  7309. Enddate string `json:"enddate"`
  7310. TrtChkRslt string `json:"trt_chk_rslt"`
  7311. } `json:"trtinfo"`
  7312. } `json:"output"`
  7313. RefmsgTime string `json:"refmsg_time"`
  7314. RespondTime string `json:"respond_time"`
  7315. Signtype interface{} `json:"signtype"`
  7316. WarnMsg interface{} `json:"warn_msg"`
  7317. }
  7318. type ResultTwo struct {
  7319. ErrMsg string `json:"err_msg"`
  7320. InfRefmsgid string `json:"inf_refmsgid"`
  7321. Infcode int64 `json:"infcode"`
  7322. Output struct {
  7323. Baseinfo struct {
  7324. Age float64 `json:"age"`
  7325. Brdy string `json:"brdy"`
  7326. Certno string `json:"certno"`
  7327. Gend string `json:"gend"`
  7328. Naty string `json:"naty"`
  7329. PsnCertType string `json:"psn_cert_type"`
  7330. PsnName string `json:"psn_name"`
  7331. PsnNo string `json:"psn_no"`
  7332. } `json:"baseinfo"`
  7333. Idetinfo []interface{} `json:"idetinfo"`
  7334. Iinfo []struct {
  7335. Balc float64 `json:"balc"`
  7336. CvlservFlag string `json:"cvlserv_flag"`
  7337. EmpName string `json:"emp_name"`
  7338. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7339. Insutype string `json:"insutype"`
  7340. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7341. PausInsuDate string `json:"paus_insu_date"`
  7342. PsnInsuDate string `json:"psn_insu_date"`
  7343. PsnInsuStas string `json:"psn_insu_stas"`
  7344. PsnType string `json:"psn_type"`
  7345. } `json:"insuinfo"`
  7346. } `json:"output"`
  7347. RefmsgTime string `json:"refmsg_time"`
  7348. RespondTime string `json:"respond_time"`
  7349. Signtype interface{} `json:"signtype"`
  7350. WarnInfo interface{} `json:"warn_info"`
  7351. }
  7352. type ResultTwo10265 struct {
  7353. ErrMsg string `json:"err_msg"`
  7354. InfRefmsgid string `json:"inf_refmsgid"`
  7355. Infcode string `json:"infcode"`
  7356. Output struct {
  7357. Baseinfo struct {
  7358. Age float64 `json:"age"`
  7359. Brdy string `json:"brdy"`
  7360. Certno string `json:"certno"`
  7361. Gend string `json:"gend"`
  7362. Naty string `json:"naty"`
  7363. PsnCertType string `json:"psn_cert_type"`
  7364. PsnName string `json:"psn_name"`
  7365. PsnNo string `json:"psn_no"`
  7366. } `json:"baseinfo"`
  7367. Idetinfo []interface{} `json:"idetinfo"`
  7368. Iinfo []struct {
  7369. Balc float64 `json:"balc"`
  7370. CvlservFlag string `json:"cvlserv_flag"`
  7371. EmpName string `json:"emp_name"`
  7372. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7373. Insutype string `json:"insutype"`
  7374. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7375. PausInsuDate string `json:"paus_insu_date"`
  7376. PsnInsuDate string `json:"psn_insu_date"`
  7377. PsnInsuStas string `json:"psn_insu_stas"`
  7378. PsnType string `json:"psn_type"`
  7379. } `json:"insuinfo"`
  7380. } `json:"output"`
  7381. RefmsgTime string `json:"refmsg_time"`
  7382. RespondTime string `json:"respond_time"`
  7383. Signtype interface{} `json:"signtype"`
  7384. WarnInfo interface{} `json:"warn_info"`
  7385. }
  7386. type ResultThree struct {
  7387. Cainfo interface{} `json:"cainfo"`
  7388. ErrMsg string `json:"err_msg"`
  7389. InfRefmsgid string `json:"inf_refmsgid"`
  7390. Infcode int64 `json:"infcode"`
  7391. Output struct {
  7392. Data struct {
  7393. IptOtpNo string `json:"ipt_otp_no"`
  7394. MdtrtID string `json:"mdtrt_id"`
  7395. PsnNo string `json:"psn_no"`
  7396. } `json:"data"`
  7397. } `json:"output"`
  7398. RefmsgTime string `json:"refmsg_time"`
  7399. RespondTime string `json:"respond_time"`
  7400. Signtype interface{} `json:"signtype"`
  7401. WarnMsg interface{} `json:"warn_msg"`
  7402. }
  7403. type ResultThree10265 struct {
  7404. Cainfo interface{} `json:"cainfo"`
  7405. ErrMsg string `json:"err_msg"`
  7406. InfRefmsgid string `json:"inf_refmsgid"`
  7407. Infcode string `json:"infcode"`
  7408. Output struct {
  7409. Data struct {
  7410. IptOtpNo string `json:"ipt_otp_no"`
  7411. MdtrtID string `json:"mdtrt_id"`
  7412. PsnNo string `json:"psn_no"`
  7413. } `json:"data"`
  7414. } `json:"output"`
  7415. RefmsgTime string `json:"refmsg_time"`
  7416. RespondTime string `json:"respond_time"`
  7417. Signtype interface{} `json:"signtype"`
  7418. WarnMsg interface{} `json:"warn_msg"`
  7419. }
  7420. type ResultFour struct {
  7421. Cainfo string `json:"cainfo"`
  7422. ErrMsg string `json:"err_msg"`
  7423. InfRefmsgid string `json:"inf_refmsgid"`
  7424. Infcode int64 `json:"infcode"`
  7425. Output struct {
  7426. Result []struct {
  7427. BasMednFlag string `json:"bas_medn_flag"`
  7428. ChldMedcFlag string `json:"chld_medc_flag"`
  7429. ChrgitmLv string `json:"chrgitm_lv"`
  7430. Cnt float64 `json:"cnt"`
  7431. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7432. DrtReimFlag string `json:"drt_reim_flag"`
  7433. FeedetlSn string `json:"feedetl_sn"`
  7434. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7435. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7436. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7437. ListSpItemFlag string `json:"list_sp_item_flag"`
  7438. LmtUsedFlag string `json:"lmt_used_flag"`
  7439. MedChrgitmType string `json:"med_chrgitm_type"`
  7440. Memo string `json:"memo"`
  7441. OverlmtAmt float64 `json:"overlmt_amt"`
  7442. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7443. Pric float64 `json:"pric"`
  7444. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7445. SelfpayProp float64 `json:"selfpay_prop"`
  7446. } `json:"result"`
  7447. } `json:"output"`
  7448. RefmsgTime string `json:"refmsg_time"`
  7449. RespondTime string `json:"respond_time"`
  7450. Signtype string `json:"signtype"`
  7451. WarnMsg string `json:"warn_msg"`
  7452. }
  7453. type ResultFour10265 struct {
  7454. Cainfo string `json:"cainfo"`
  7455. ErrMsg string `json:"err_msg"`
  7456. InfRefmsgid string `json:"inf_refmsgid"`
  7457. Infcode string `json:"infcode"`
  7458. Output struct {
  7459. Result []struct {
  7460. BasMednFlag string `json:"bas_medn_flag"`
  7461. ChldMedcFlag string `json:"chld_medc_flag"`
  7462. ChrgitmLv string `json:"chrgitm_lv"`
  7463. Cnt float64 `json:"cnt"`
  7464. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7465. DrtReimFlag string `json:"drt_reim_flag"`
  7466. FeedetlSn string `json:"feedetl_sn"`
  7467. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7468. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7469. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7470. ListSpItemFlag string `json:"list_sp_item_flag"`
  7471. LmtUsedFlag string `json:"lmt_used_flag"`
  7472. MedChrgitmType string `json:"med_chrgitm_type"`
  7473. Memo string `json:"memo"`
  7474. OverlmtAmt float64 `json:"overlmt_amt"`
  7475. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7476. Pric float64 `json:"pric"`
  7477. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7478. SelfpayProp float64 `json:"selfpay_prop"`
  7479. } `json:"result"`
  7480. } `json:"output"`
  7481. RefmsgTime string `json:"refmsg_time"`
  7482. RespondTime string `json:"respond_time"`
  7483. Signtype string `json:"signtype"`
  7484. WarnMsg string `json:"warn_msg"`
  7485. }
  7486. type ResultMemo struct {
  7487. InsuAdmdvs string `json:"insuAdmdvs"`
  7488. }
  7489. // [{"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}]
  7490. type ResultIDInfo struct {
  7491. Begntime string `json:"begntime"`
  7492. Endtime string `json:"endtime"`
  7493. Memo string `json:"memo"`
  7494. }
  7495. type ResultFive struct {
  7496. Balc float64 `json:"balc"`
  7497. CvlservFlag string `json:"cvlserv_flag"`
  7498. EmpName string `json:"emp_name"`
  7499. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7500. Insutype string `json:"insutype"`
  7501. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7502. PausInsuDate string `json:"paus_insu_date"`
  7503. PsnInsuDate string `json:"psn_insu_date"`
  7504. PsnInsuStas string `json:"psn_insu_stas"`
  7505. PsnType string `json:"psn_type"`
  7506. }
  7507. type ResultSix struct {
  7508. Cainfo interface{} `json:"cainfo"`
  7509. ErrMsg string `json:"err_msg"`
  7510. InfRefmsgid string `json:"inf_refmsgid"`
  7511. Infcode int64 `json:"infcode"`
  7512. Output struct {
  7513. } `json:"output"`
  7514. RefmsgTime string `json:"refmsg_time"`
  7515. RespondTime string `json:"respond_time"`
  7516. Signtype interface{} `json:"signtype"`
  7517. WarnMsg interface{} `json:"warn_msg"`
  7518. }
  7519. type ResultSix10265 struct {
  7520. Cainfo interface{} `json:"cainfo"`
  7521. ErrMsg string `json:"err_msg"`
  7522. InfRefmsgid string `json:"inf_refmsgid"`
  7523. Infcode string `json:"infcode"`
  7524. Output struct {
  7525. } `json:"output"`
  7526. RefmsgTime string `json:"refmsg_time"`
  7527. RespondTime string `json:"respond_time"`
  7528. Signtype interface{} `json:"signtype"`
  7529. WarnMsg interface{} `json:"warn_msg"`
  7530. }
  7531. type ResultSeven struct {
  7532. Cainfo string `json:"cainfo"`
  7533. ErrMsg string `json:"err_msg"`
  7534. InfRefmsgid string `json:"inf_refmsgid"`
  7535. Infcode int64 `json:"infcode"`
  7536. Output struct {
  7537. Setldetail []interface{} `json:"setldetail"`
  7538. Setlinfo struct {
  7539. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7540. AcctPay float64 `json:"acct_pay"`
  7541. ActPayDedc float64 `json:"act_pay_dedc"`
  7542. Age float64 `json:"age"`
  7543. Balc float64 `json:"balc"`
  7544. Brdy string `json:"brdy"`
  7545. Certno string `json:"certno"`
  7546. ClrOptins string `json:"clr_optins"`
  7547. ClrType string `json:"clr_type"`
  7548. ClrWay string `json:"clr_way"`
  7549. CvlservFlag string `json:"cvlserv_flag"`
  7550. CvlservPay float64 `json:"cvlserv_pay"`
  7551. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7552. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7553. Gend string `json:"gend"`
  7554. HifesPay float64 `json:"hifes_pay"`
  7555. HifmiPay float64 `json:"hifmi_pay"`
  7556. HifpPay float64 `json:"hifp_pay"`
  7557. HospPartAmt float64 `json:"hosp_part_amt"`
  7558. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7559. Insutype string `json:"insutype"`
  7560. MafPay float64 `json:"maf_pay"`
  7561. MdtrtCertType string `json:"mdtrt_cert_type"`
  7562. HifobPay float64 `json:"hifob_pay"`
  7563. MdtrtID string `json:"mdtrt_id"`
  7564. MedType string `json:"med_type"`
  7565. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7566. MedinsSetlID string `json:"medins_setl_id"`
  7567. Naty string `json:"naty"`
  7568. OthPay float64 `json:"oth_pay"`
  7569. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7570. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7571. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7572. PsnCashPay float64 `json:"psn_cash_pay"`
  7573. PsnCertType string `json:"psn_cert_type"`
  7574. PsnName string `json:"psn_name"`
  7575. PsnNo string `json:"psn_no"`
  7576. PsnPartAmt float64 `json:"psn_part_amt"`
  7577. PsnType string `json:"psn_type"`
  7578. SetlID string `json:"setl_id"`
  7579. SetlTime string `json:"setl_time"`
  7580. } `json:"setlinfo"`
  7581. } `json:"output"`
  7582. RefmsgTime string `json:"refmsg_time"`
  7583. RespondTime string `json:"respond_time"`
  7584. Signtype interface{} `json:"signtype"`
  7585. WarnMsg interface{} `json:"warn_msg"`
  7586. }
  7587. type ResultSeven10265 struct {
  7588. Cainfo string `json:"cainfo"`
  7589. ErrMsg string `json:"err_msg"`
  7590. InfRefmsgid string `json:"inf_refmsgid"`
  7591. Infcode string `json:"infcode"`
  7592. Output struct {
  7593. Setldetail []interface{} `json:"setldetail"`
  7594. Setlinfo struct {
  7595. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7596. AcctPay float64 `json:"acct_pay"`
  7597. ActPayDedc float64 `json:"act_pay_dedc"`
  7598. Age float64 `json:"age"`
  7599. Balc float64 `json:"balc"`
  7600. Brdy string `json:"brdy"`
  7601. Certno string `json:"certno"`
  7602. ClrOptins string `json:"clr_optins"`
  7603. ClrType string `json:"clr_type"`
  7604. ClrWay string `json:"clr_way"`
  7605. CvlservFlag string `json:"cvlserv_flag"`
  7606. CvlservPay float64 `json:"cvlserv_pay"`
  7607. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7608. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7609. Gend string `json:"gend"`
  7610. HifesPay float64 `json:"hifes_pay"`
  7611. HifmiPay float64 `json:"hifmi_pay"`
  7612. HifpPay float64 `json:"hifp_pay"`
  7613. HospPartAmt float64 `json:"hosp_part_amt"`
  7614. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7615. Insutype string `json:"insutype"`
  7616. MafPay float64 `json:"maf_pay"`
  7617. MdtrtCertType string `json:"mdtrt_cert_type"`
  7618. HifobPay float64 `json:"hifob_pay"`
  7619. MdtrtID string `json:"mdtrt_id"`
  7620. MedType string `json:"med_type"`
  7621. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7622. MedinsSetlID string `json:"medins_setl_id"`
  7623. Naty string `json:"naty"`
  7624. OthPay float64 `json:"oth_pay"`
  7625. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7626. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7627. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7628. PsnCashPay float64 `json:"psn_cash_pay"`
  7629. PsnCertType string `json:"psn_cert_type"`
  7630. PsnName string `json:"psn_name"`
  7631. PsnNo string `json:"psn_no"`
  7632. PsnPartAmt float64 `json:"psn_part_amt"`
  7633. PsnType string `json:"psn_type"`
  7634. SetlID string `json:"setl_id"`
  7635. SetlTime string `json:"setl_time"`
  7636. } `json:"setlinfo"`
  7637. } `json:"output"`
  7638. RefmsgTime string `json:"refmsg_time"`
  7639. RespondTime string `json:"respond_time"`
  7640. Signtype interface{} `json:"signtype"`
  7641. WarnMsg interface{} `json:"warn_msg"`
  7642. }
  7643. type ResultEight struct {
  7644. Cainfo string `json:"cainfo"`
  7645. ErrMsg string `json:"err_msg"`
  7646. InfRefmsgid string `json:"inf_refmsgid"`
  7647. Infcode int64 `json:"infcode"`
  7648. Output struct {
  7649. Stmtinfo struct {
  7650. SetlOptins string `json:"setl_optins"`
  7651. StmtRslt string `json:"stmt_rslt"`
  7652. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7653. } `json:"stmtinfo"`
  7654. } `json:"output"`
  7655. RefmsgTime string `json:"refmsg_time"`
  7656. RespondTime string `json:"respond_time"`
  7657. Signtype interface{} `json:"signtype"`
  7658. WarnMsg interface{} `json:"warn_msg"`
  7659. }
  7660. type ResultEightFor10188 struct {
  7661. Cainfo string `json:"cainfo"`
  7662. ErrMsg string `json:"err_msg"`
  7663. InfRefmsgid string `json:"inf_refmsgid"`
  7664. Infcode string `json:"infcode"`
  7665. Output struct {
  7666. Stmtinfo struct {
  7667. SetlOptins string `json:"setl_optins"`
  7668. StmtRslt string `json:"stmt_rslt"`
  7669. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7670. } `json:"stmtinfo"`
  7671. } `json:"output"`
  7672. RefmsgTime string `json:"refmsg_time"`
  7673. RespondTime string `json:"respond_time"`
  7674. Signtype interface{} `json:"signtype"`
  7675. WarnMsg interface{} `json:"warn_msg"`
  7676. }
  7677. type ResultNine struct {
  7678. Cainfo string `json:"cainfo"`
  7679. ErrMsg string `json:"err_msg"`
  7680. InfRefmsgid string `json:"inf_refmsgid"`
  7681. Infcode int64 `json:"infcode"`
  7682. Output struct {
  7683. FileQuryNo string `json:"file_qury_no"`
  7684. } `json:"output"`
  7685. RefmsgTime string `json:"refmsg_time"`
  7686. RespondTime string `json:"respond_time"`
  7687. Signtype interface{} `json:"signtype"`
  7688. WarnMsg interface{} `json:"warn_msg"`
  7689. }
  7690. type ResultTen struct {
  7691. Cainfo string `json:"cainfo"`
  7692. ErrMsg string `json:"err_msg"`
  7693. InfRefmsgid string `json:"inf_refmsgid"`
  7694. Infcode int64 `json:"infcode"`
  7695. Output struct {
  7696. DldEndtime string `json:"dld_endtime"`
  7697. FileQuryNo string `json:"file_qury_no"`
  7698. Filename string `json:"filename"`
  7699. } `json:"output"`
  7700. RefmsgTime string `json:"refmsg_time"`
  7701. RespondTime string `json:"respond_time"`
  7702. Signtype interface{} `json:"signtype"`
  7703. WarnMsg interface{} `json:"warn_msg"`
  7704. }
  7705. //type Autogenerated struct {
  7706. // Output struct {
  7707. // Setlinfo struct {
  7708. // SetlTime string `json:"setl_time"`
  7709. // CvlservPay float64 `json:"cvlserv_pay"`
  7710. // Year string `json:"year"`
  7711. // MedType string `json:"med_type"`
  7712. // PsnPay float64 `json:"psn_pay"`
  7713. // OpterID string `json:"opter_id"`
  7714. // Begndate string `json:"begndate"`
  7715. // FlxempeFlag string `json:"flxempe_flag"`
  7716. // HifmiPay float64 `json:"hifmi_pay"`
  7717. // PsnNo string `json:"psn_no"`
  7718. // ActPayDedc float64 `json:"act_pay_dedc"`
  7719. // MedinsSetlID interface{} `json:"medins_setl_id"`
  7720. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7721. // ClrWay string `json:"clr_way"`
  7722. // OthPay float64 `json:"oth_pay"`
  7723. // Gend string `json:"gend"`
  7724. // MdtrtID string `json:"mdtrt_id"`
  7725. // AcctPay float64 `json:"acct_pay"`
  7726. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  7727. // Insutype string `json:"insutype"`
  7728. // Invono interface{} `json:"invono"`
  7729. // Enddate string `json:"enddate"`
  7730. // CashPayamt float64 `json:"cash_payamt"`
  7731. // PsnType string `json:"psn_type"`
  7732. // FixmedinsName string `json:"fixmedins_name"`
  7733. // HifpPay float64 `json:"hifp_pay"`
  7734. // NewFlag interface{} `json:"new_flag"`
  7735. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7736. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  7737. // PayLoc string `json:"pay_loc"`
  7738. // ClrType string `json:"clr_type"`
  7739. // RefdSetlFlag string `json:"refd_setl_flag"`
  7740. // CvlservFlag string `json:"cvlserv_flag"`
  7741. // EmpName string `json:"emp_name"`
  7742. // Brdy string `json:"brdy"`
  7743. // Naty string `json:"naty"`
  7744. // Certno string `json:"certno"`
  7745. // DiseCode string `json:"dise_code"`
  7746. // FixmedinsCode string `json:"fixmedins_code"`
  7747. // DedcHospLv string `json:"dedc_hosp_lv"`
  7748. // OpterName string `json:"opter_name"`
  7749. // Balc float64 `json:"balc"`
  7750. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7751. // PsnCertType string `json:"psn_cert_type"`
  7752. // HifobPay float64 `json:"hifob_pay"`
  7753. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  7754. // HifesPay float64 `json:"hifes_pay"`
  7755. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7756. // OptTime string `json:"opt_time"`
  7757. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7758. // SetlID string `json:"setl_id"`
  7759. // MafPay float64 `json:"maf_pay"`
  7760. // PsnName string `json:"psn_name"`
  7761. // InsuOptins interface{} `json:"insu_optins"`
  7762. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7763. // ClrOptins string `json:"clr_optins"`
  7764. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7765. // DiseName string `json:"dise_name"`
  7766. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7767. // Age float64 `json:"age"`
  7768. // DtrtCertType string `json:"dtrt_cert_type"`
  7769. // HospLv string `json:"hosp_lv"`
  7770. // } `json:"setlinfo"`
  7771. // Setldetail []struct {
  7772. // FundPayType string `json:"fund_pay_type"`
  7773. // FundPayamt float64 `json:"fund_payamt"`
  7774. // SetlProcInfo interface{} `json:"setl_proc_info"`
  7775. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  7776. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  7777. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  7778. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7779. // } `json:"setldetail"`
  7780. // } `json:"output"`
  7781. // Infcode int `json:"infcode"`
  7782. // WarnMsg interface{} `json:"warn_msg"`
  7783. // Cainfo interface{} `json:"cainfo"`
  7784. // ErrMsg interface{} `json:"err_msg"`
  7785. // RefmsgTime string `json:"refmsg_time"`
  7786. // Signtype interface{} `json:"signtype"`
  7787. // RespondTime string `json:"respond_time"`
  7788. // InfRefmsgid string `json:"inf_refmsgid"`
  7789. //}
  7790. type ResultEleven struct {
  7791. Cainfo string `json:"cainfo"`
  7792. ErrMsg string `json:"err_msg"`
  7793. InfRefmsgid string `json:"inf_refmsgid"`
  7794. Infcode int64 `json:"infcode"`
  7795. Output struct {
  7796. Setlinfo struct {
  7797. SetlTime string `json:"setl_time"`
  7798. CvlservPay float64 `json:"cvlserv_pay"`
  7799. Year string `json:"year"`
  7800. MedType string `json:"med_type"`
  7801. PsnPay float64 `json:"psn_pay"`
  7802. OpterID string `json:"opter_id"`
  7803. Begndate string `json:"begndate"`
  7804. FlxempeFlag string `json:"flxempe_flag"`
  7805. HifmiPay float64 `json:"hifmi_pay"`
  7806. PsnNo string `json:"psn_no"`
  7807. ActPayDedc float64 `json:"act_pay_dedc"`
  7808. MedinsSetlID interface{} `json:"medins_setl_id"`
  7809. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7810. ClrWay string `json:"clr_way"`
  7811. OthPay float64 `json:"oth_pay"`
  7812. Gend string `json:"gend"`
  7813. MdtrtID string `json:"mdtrt_id"`
  7814. AcctPay float64 `json:"acct_pay"`
  7815. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7816. Insutype string `json:"insutype"`
  7817. Invono interface{} `json:"invono"`
  7818. Enddate string `json:"enddate"`
  7819. CashPayamt float64 `json:"cash_payamt"`
  7820. PsnType string `json:"psn_type"`
  7821. FixmedinsName string `json:"fixmedins_name"`
  7822. HifpPay float64 `json:"hifp_pay"`
  7823. NewFlag interface{} `json:"new_flag"`
  7824. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7825. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7826. PayLoc string `json:"pay_loc"`
  7827. ClrType string `json:"clr_type"`
  7828. RefdSetlFlag string `json:"refd_setl_flag"`
  7829. CvlservFlag string `json:"cvlserv_flag"`
  7830. EmpName string `json:"emp_name"`
  7831. Brdy string `json:"brdy"`
  7832. Naty string `json:"naty"`
  7833. Certno string `json:"certno"`
  7834. DiseCode string `json:"dise_code"`
  7835. FixmedinsCode string `json:"fixmedins_code"`
  7836. DedcHospLv string `json:"dedc_hosp_lv"`
  7837. OpterName string `json:"opter_name"`
  7838. Balc float64 `json:"balc"`
  7839. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7840. PsnCertType string `json:"psn_cert_type"`
  7841. HifobPay float64 `json:"hifob_pay"`
  7842. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7843. HifesPay float64 `json:"hifes_pay"`
  7844. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7845. OptTime string `json:"opt_time"`
  7846. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7847. SetlID string `json:"setl_id"`
  7848. MafPay float64 `json:"maf_pay"`
  7849. PsnName string `json:"psn_name"`
  7850. InsuOptins interface{} `json:"insu_optins"`
  7851. PrefFundPay interface{} `json:"pref_fund_pay"`
  7852. ClrOptins string `json:"clr_optins"`
  7853. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7854. DiseName string `json:"dise_name"`
  7855. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7856. Age float64 `json:"age"`
  7857. DtrtCertType string `json:"dtrt_cert_type"`
  7858. HospLv string `json:"hosp_lv"`
  7859. PsnCashPay float64
  7860. } `json:"setlinfo"`
  7861. } `json:"output"`
  7862. RefmsgTime string `json:"refmsg_time"`
  7863. RespondTime string `json:"respond_time"`
  7864. Signtype interface{} `json:"signtype"`
  7865. WarnMsg interface{} `json:"warn_msg"`
  7866. }
  7867. type ResultEleven10265 struct {
  7868. Cainfo string `json:"cainfo"`
  7869. ErrMsg string `json:"err_msg"`
  7870. InfRefmsgid string `json:"inf_refmsgid"`
  7871. Infcode string `json:"infcode"`
  7872. Output struct {
  7873. Setlinfo struct {
  7874. SetlTime string `json:"setl_time"`
  7875. CvlservPay float64 `json:"cvlserv_pay"`
  7876. Year string `json:"year"`
  7877. MedType string `json:"med_type"`
  7878. PsnPay float64 `json:"psn_pay"`
  7879. OpterID string `json:"opter_id"`
  7880. Begndate string `json:"begndate"`
  7881. FlxempeFlag string `json:"flxempe_flag"`
  7882. HifmiPay float64 `json:"hifmi_pay"`
  7883. PsnNo string `json:"psn_no"`
  7884. ActPayDedc float64 `json:"act_pay_dedc"`
  7885. MedinsSetlID interface{} `json:"medins_setl_id"`
  7886. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7887. ClrWay string `json:"clr_way"`
  7888. OthPay float64 `json:"oth_pay"`
  7889. Gend string `json:"gend"`
  7890. MdtrtID string `json:"mdtrt_id"`
  7891. AcctPay float64 `json:"acct_pay"`
  7892. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7893. Insutype string `json:"insutype"`
  7894. Invono interface{} `json:"invono"`
  7895. Enddate string `json:"enddate"`
  7896. CashPayamt float64 `json:"cash_payamt"`
  7897. PsnType string `json:"psn_type"`
  7898. FixmedinsName string `json:"fixmedins_name"`
  7899. HifpPay float64 `json:"hifp_pay"`
  7900. NewFlag interface{} `json:"new_flag"`
  7901. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7902. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7903. PayLoc string `json:"pay_loc"`
  7904. ClrType string `json:"clr_type"`
  7905. RefdSetlFlag string `json:"refd_setl_flag"`
  7906. CvlservFlag string `json:"cvlserv_flag"`
  7907. EmpName string `json:"emp_name"`
  7908. Brdy string `json:"brdy"`
  7909. Naty string `json:"naty"`
  7910. Certno string `json:"certno"`
  7911. DiseCode string `json:"dise_code"`
  7912. FixmedinsCode string `json:"fixmedins_code"`
  7913. DedcHospLv string `json:"dedc_hosp_lv"`
  7914. OpterName string `json:"opter_name"`
  7915. Balc float64 `json:"balc"`
  7916. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7917. PsnCertType string `json:"psn_cert_type"`
  7918. HifobPay float64 `json:"hifob_pay"`
  7919. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7920. HifesPay float64 `json:"hifes_pay"`
  7921. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7922. OptTime string `json:"opt_time"`
  7923. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7924. SetlID string `json:"setl_id"`
  7925. MafPay float64 `json:"maf_pay"`
  7926. PsnName string `json:"psn_name"`
  7927. InsuOptins interface{} `json:"insu_optins"`
  7928. PrefFundPay interface{} `json:"pref_fund_pay"`
  7929. ClrOptins string `json:"clr_optins"`
  7930. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7931. DiseName string `json:"dise_name"`
  7932. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7933. Age float64 `json:"age"`
  7934. DtrtCertType string `json:"dtrt_cert_type"`
  7935. HospLv string `json:"hosp_lv"`
  7936. PsnCashPay float64
  7937. } `json:"setlinfo"`
  7938. } `json:"output"`
  7939. RefmsgTime string `json:"refmsg_time"`
  7940. RespondTime string `json:"respond_time"`
  7941. Signtype interface{} `json:"signtype"`
  7942. WarnMsg interface{} `json:"warn_msg"`
  7943. }
  7944. type ResultTwelve struct {
  7945. Cainfo string `json:"cainfo"`
  7946. ErrMsg string `json:"err_msg"`
  7947. InfRefmsgid string `json:"inf_refmsgid"`
  7948. Infcode int64 `json:"infcode"`
  7949. Output struct {
  7950. MdtrtId string `json:"mdtrt_id"`
  7951. ChrgBchno string `json:"chrg_bchno"`
  7952. PsnNo string `json:"psn_no"`
  7953. } `json:"output"`
  7954. RefmsgTime string `json:"refmsg_time"`
  7955. RespondTime string `json:"respond_time"`
  7956. Signtype interface{} `json:"signtype"`
  7957. WarnMsg interface{} `json:"warn_msg"`
  7958. }
  7959. type ResultThirteen struct {
  7960. ErrMsg string `json:"err_msg"`
  7961. InfRefmsgid string `json:"inf_refmsgid"`
  7962. Infcode int64 `json:"infcode"`
  7963. Output struct {
  7964. Result struct {
  7965. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7966. } `json:"result"`
  7967. } `json:"output"`
  7968. RefmsgTime string `json:"refmsg_time"`
  7969. RespondTime string `json:"respond_time"`
  7970. Signtype interface{} `json:"signtype"`
  7971. WarnInfo interface{} `json:"warn_info"`
  7972. }
  7973. type ResultThirteen10265 struct {
  7974. ErrMsg string `json:"err_msg"`
  7975. InfRefmsgid string `json:"inf_refmsgid"`
  7976. Infcode string `json:"infcode"`
  7977. Output struct {
  7978. Result struct {
  7979. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7980. } `json:"result"`
  7981. } `json:"output"`
  7982. RefmsgTime string `json:"refmsg_time"`
  7983. RespondTime string `json:"respond_time"`
  7984. Signtype interface{} `json:"signtype"`
  7985. WarnInfo interface{} `json:"warn_info"`
  7986. }
  7987. type ResultFourteen struct {
  7988. ErrMsg string `json:"err_msg"`
  7989. InfRefmsgid string `json:"inf_refmsgid"`
  7990. Infcode int64 `json:"infcode"`
  7991. Output struct {
  7992. } `json:"output"`
  7993. RefmsgTime string `json:"refmsg_time"`
  7994. RespondTime string `json:"respond_time"`
  7995. Signtype interface{} `json:"signtype"`
  7996. WarnInfo interface{} `json:"warn_info"`
  7997. }
  7998. type ResultFourteen10265 struct {
  7999. ErrMsg string `json:"err_msg"`
  8000. InfRefmsgid string `json:"inf_refmsgid"`
  8001. Infcode string `json:"infcode"`
  8002. Output struct {
  8003. } `json:"output"`
  8004. RefmsgTime string `json:"refmsg_time"`
  8005. RespondTime string `json:"respond_time"`
  8006. Signtype interface{} `json:"signtype"`
  8007. WarnInfo interface{} `json:"warn_info"`
  8008. }
  8009. type ResultSixteen struct {
  8010. Cainfo string `json:"cainfo"`
  8011. ErrMsg string `json:"err_msg"`
  8012. InfRefmsgid string `json:"inf_refmsgid"`
  8013. Infcode int64 `json:"infcode"`
  8014. Output struct {
  8015. Setldetail []interface{} `json:"setldetail"`
  8016. Setlinfo struct {
  8017. MdtrtID string `json:"mdtrt_id"`
  8018. SetlID string `json:"setl_id"`
  8019. ClrOptins string `json:"clr_optins"`
  8020. SetlTime string `json:"setl_time"`
  8021. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8022. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8023. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8024. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8025. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8026. ActPayDedc float64 `json:"act_pay_dedc"`
  8027. HifpPay float64 `json:"hifp_pay"`
  8028. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8029. Lfpay float64 `json:"selfpay"`
  8030. CvlservPay float64 `json:"cvlserv_pay"`
  8031. HifesPay float64 `json:"hifes_pay"`
  8032. HifmiPay float64 `json:"hifmi_pay"`
  8033. HifobPay float64 `json:"hifob_pay"`
  8034. MafPay float64 `json:"maf_pay"`
  8035. OthPay float64 `json:"oth_pay"`
  8036. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8037. PsnPartAmt float64 `json:"psn_part_amt"`
  8038. AcctPay float64 `json:"acct_pay"`
  8039. Balc float64 `json:"balc"`
  8040. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8041. HospPartAmt float64 `json:"hosp_part_amt"`
  8042. MedinsSetlID string `json:"medins_setl_id"`
  8043. PdnCashPay string `json:"pdn_cash_pay"`
  8044. } `json:"setlinfo"`
  8045. } `json:"output"`
  8046. RefmsgTime string `json:"refmsg_time"`
  8047. RespondTime string `json:"respond_time"`
  8048. Signtype interface{} `json:"signtype"`
  8049. WarnMsg interface{} `json:"warn_msg"`
  8050. }
  8051. type ResultSixteen10265 struct {
  8052. Cainfo string `json:"cainfo"`
  8053. ErrMsg string `json:"err_msg"`
  8054. InfRefmsgid string `json:"inf_refmsgid"`
  8055. Infcode string `json:"infcode"`
  8056. Output struct {
  8057. Setldetail []interface{} `json:"setldetail"`
  8058. Setlinfo struct {
  8059. MdtrtID string `json:"mdtrt_id"`
  8060. SetlID string `json:"setl_id"`
  8061. ClrOptins string `json:"clr_optins"`
  8062. SetlTime string `json:"setl_time"`
  8063. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8064. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8065. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8066. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8067. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8068. ActPayDedc float64 `json:"act_pay_dedc"`
  8069. HifpPay float64 `json:"hifp_pay"`
  8070. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8071. Lfpay float64 `json:"selfpay"`
  8072. CvlservPay float64 `json:"cvlserv_pay"`
  8073. HifesPay float64 `json:"hifes_pay"`
  8074. HifmiPay float64 `json:"hifmi_pay"`
  8075. HifobPay float64 `json:"hifob_pay"`
  8076. MafPay float64 `json:"maf_pay"`
  8077. OthPay float64 `json:"oth_pay"`
  8078. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8079. PsnPartAmt float64 `json:"psn_part_amt"`
  8080. AcctPay float64 `json:"acct_pay"`
  8081. Balc float64 `json:"balc"`
  8082. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8083. HospPartAmt float64 `json:"hosp_part_amt"`
  8084. MedinsSetlID string `json:"medins_setl_id"`
  8085. PdnCashPay string `json:"pdn_cash_pay"`
  8086. } `json:"setlinfo"`
  8087. } `json:"output"`
  8088. RefmsgTime string `json:"refmsg_time"`
  8089. RespondTime string `json:"respond_time"`
  8090. Signtype interface{} `json:"signtype"`
  8091. WarnMsg interface{} `json:"warn_msg"`
  8092. }
  8093. type ResultSeventeen struct {
  8094. ErrMsg string `json:"err_msg"`
  8095. InfRefmsgid string `json:"inf_refmsgid"`
  8096. Infcode int64 `json:"infcode"`
  8097. Output struct {
  8098. SetlListId string `json:"setl_list_id"`
  8099. } `json:"output"`
  8100. RefmsgTime string `json:"refmsg_time"`
  8101. RespondTime string `json:"respond_time"`
  8102. Signtype string `json:"signtype"`
  8103. WarnInfo string `json:"warn_info"`
  8104. }
  8105. type ResultSeventeenOther struct {
  8106. ErrMsg string `json:"err_msg"`
  8107. InfRefmsgid string `json:"inf_refmsgid"`
  8108. Infcode string `json:"infcode"`
  8109. Output struct {
  8110. SetlListId string `json:"setl_list_id"`
  8111. } `json:"output"`
  8112. RefmsgTime string `json:"refmsg_time"`
  8113. RespondTime string `json:"respond_time"`
  8114. Signtype string `json:"signtype"`
  8115. WarnInfo string `json:"warn_info"`
  8116. }
  8117. type Result90991 struct {
  8118. ErrMsg string `json:"err_msg"`
  8119. InfRefmsgid string `json:"inf_refmsgid"`
  8120. Infcode int64 `json:"infcode"`
  8121. Output struct {
  8122. Result struct {
  8123. PsnNo string `json:"psn_no"`
  8124. CardStat string `json:"card_stat"`
  8125. Certno string `json:"certno"`
  8126. PsnName string `json:"psn_name"`
  8127. CheckStat string `json:"check_stat"`
  8128. SscnoCheckStat string `json:"sscno_check_stat"`
  8129. } `json:"result"`
  8130. } `json:"output"`
  8131. RefmsgTime string `json:"refmsg_time"`
  8132. RespondTime string `json:"respond_time"`
  8133. Signtype interface{} `json:"signtype"`
  8134. WarnInfo interface{} `json:"warn_info"`
  8135. }
  8136. type Result90100 struct {
  8137. ErrMsg string `json:"err_msg"`
  8138. InfRefmsgid string `json:"inf_refmsgid"`
  8139. Infcode int64 `json:"infcode"`
  8140. Output struct {
  8141. PoolareaNo string `json:"poolarea_no"`
  8142. PoolareaNoName string `json:"poolarea_no_name"`
  8143. Insutype string `json:"insutype"`
  8144. InsutypeName string `json:"insutype_name"`
  8145. ClctType string `json:"clct_type"`
  8146. ClctTypeName string `json:"clct_type_name"`
  8147. ClctFlag string `json:"clct_flag"`
  8148. ClctFlagName string `json:"clct_flag_name"`
  8149. AccrymBegn string `json:"accrym_begn"`
  8150. AccrymEnd string `json:"accrym_end"`
  8151. ClctTime string `json:"clct_time"`
  8152. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  8153. } `json:"output"`
  8154. RefmsgTime string `json:"refmsg_time"`
  8155. RespondTime string `json:"respond_time"`
  8156. Signtype interface{} `json:"signtype"`
  8157. WarnInfo interface{} `json:"warn_info"`
  8158. }
  8159. type Custom struct {
  8160. DetItemFeeSumamt string
  8161. Cut string
  8162. FeedetlSn string
  8163. Price string
  8164. MedListCodg string
  8165. Type int64
  8166. AdviceId int64
  8167. ProjectId int64
  8168. ItemId int64
  8169. }
  8170. type Result5301 struct {
  8171. ErrMsg string `json:"err_msg"`
  8172. InfRefmsgid string `json:"inf_refmsgid"`
  8173. Infcode int64 `json:"infcode"`
  8174. Output struct {
  8175. Result []struct {
  8176. OpspDiseCode string `json:"opsp_dise_code"`
  8177. OpspDiseName string `json:"opsp_dise_name"`
  8178. Begndate string `json:"begndate"`
  8179. Enddate string `json:"enddate"`
  8180. } `json:"feedetail"`
  8181. } `json:"output"`
  8182. RefmsgTime string `json:"refmsg_time"`
  8183. RespondTime string `json:"respond_time"`
  8184. Signtype interface{} `json:"signtype"`
  8185. WarnInfo interface{} `json:"warn_info"`
  8186. }
  8187. type Result5301For10265 struct {
  8188. ErrMsg string `json:"err_msg"`
  8189. InfRefmsgid string `json:"inf_refmsgid"`
  8190. Infcode string `json:"infcode"`
  8191. Output struct {
  8192. Result []struct {
  8193. OpspDiseCode string `json:"opsp_dise_code"`
  8194. OpspDiseName string `json:"opsp_dise_name"`
  8195. Begndate string `json:"begndate"`
  8196. Enddate string `json:"enddate"`
  8197. } `json:"feedetail"`
  8198. } `json:"output"`
  8199. RefmsgTime string `json:"refmsg_time"`
  8200. RespondTime string `json:"respond_time"`
  8201. Signtype interface{} `json:"signtype"`
  8202. WarnInfo interface{} `json:"warn_info"`
  8203. }
  8204. //获取个人信息----挂号-----上传就诊信息
  8205. func (c *HisApiController) GetRegisterInfo() {
  8206. id, _ := c.GetInt64("id")
  8207. record_time := c.GetString("record_time")
  8208. settlementValue, _ := c.GetInt64("settlement_value")
  8209. medical_insurance_card := c.GetString("medical_insurance_card")
  8210. name := c.GetString("name")
  8211. id_card_type, _ := c.GetInt64("id_card_type")
  8212. certificates, _ := c.GetInt64("certificates")
  8213. medical_care, _ := c.GetInt64("medical_care")
  8214. birthday := c.GetString("birthday")
  8215. id_card := c.GetString("id_card")
  8216. register_type, _ := c.GetInt64("register")
  8217. doctor, _ := c.GetInt64("doctor")
  8218. department, _ := c.GetInt64("department")
  8219. gender, _ := c.GetInt64("sex")
  8220. registration_fee, _ := c.GetFloat("registration_fee")
  8221. medical_expenses, _ := c.GetFloat("medical_expenses")
  8222. social_type, _ := c.GetInt64("social_type")
  8223. admin_user_id, _ := c.GetInt64("admin_user_id")
  8224. insuplc_admdvs := c.GetString("insuplc_admdvs")
  8225. mdtrt_type := c.GetString("mdtrt_type")
  8226. timeLayout := "2006-01-02"
  8227. loc, _ := time.LoadLocation("Local")
  8228. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  8229. birthUnix := birthdays.Unix()
  8230. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8231. if err != nil {
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8233. return
  8234. }
  8235. recordDateTime := theTime.Unix()
  8236. adminInfo := c.GetAdminUserInfo()
  8237. var patient service.Patients
  8238. if id == 0 {
  8239. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  8240. } else {
  8241. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  8242. }
  8243. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8244. if patientPrescription.ID == 0 {
  8245. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8246. }
  8247. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8248. if patient.ID == 0 {
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8250. return
  8251. }
  8252. if len(patient.IdCardNo) == 0 {
  8253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8254. return
  8255. }
  8256. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8257. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  8258. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  8259. //就诊结算未完成,不能进行二次挂号
  8260. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  8261. if len(his) >= 1 {
  8262. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  8263. if len(his) >= 1 && order.ID == 0 {
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  8265. return
  8266. }
  8267. }
  8268. //var register_log string
  8269. if config.IsOpen == 1 {
  8270. var res ResultTwo
  8271. var res10265 ResultTwo10265
  8272. var PsnNo string
  8273. var PsnCertType string
  8274. var Certno string
  8275. var PsnName string
  8276. var Gend string
  8277. var Naty string
  8278. var Brdy string
  8279. var Age float64
  8280. var infoStr string
  8281. var idetinfoStr string
  8282. var infocode int64
  8283. var verify_number string
  8284. fmt.Println(verify_number)
  8285. if miConfig.MdtrtareaAdmvs == "421300" {
  8286. psn_info, _ := service.GetPsnByPatientId(id)
  8287. PsnNo = psn_info.PsnNo
  8288. PsnCertType = psn_info.PsnCertType
  8289. Certno = psn_info.Certno
  8290. PsnName = psn_info.PsnName
  8291. Gend = psn_info.Gend
  8292. Naty = psn_info.Naty
  8293. Brdy = psn_info.Brdy
  8294. Age = psn_info.Age
  8295. infoStr = psn_info.Insuinfo
  8296. idetinfoStr = psn_info.Idetinfo
  8297. infocode = 0
  8298. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8299. psn_info, _ := service.GetPsnByPatientId(id)
  8300. PsnNo = psn_info.PsnNo
  8301. PsnCertType = psn_info.PsnCertType
  8302. Certno = psn_info.Certno
  8303. PsnName = psn_info.PsnName
  8304. Gend = psn_info.Gend
  8305. Naty = psn_info.Naty
  8306. Brdy = psn_info.Brdy
  8307. Age = psn_info.Age
  8308. infoStr = psn_info.Insuinfo
  8309. idetinfoStr = psn_info.Idetinfo
  8310. infocode = 0
  8311. verify_number = psn_info.VerifyNumber
  8312. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8313. if id_card_type == 1 {
  8314. psn_info, _ := service.GetPsnByPatientId(id)
  8315. PsnNo = psn_info.PsnNo
  8316. PsnCertType = psn_info.PsnCertType
  8317. Certno = psn_info.Certno
  8318. PsnName = psn_info.PsnName
  8319. Gend = psn_info.Gend
  8320. Naty = psn_info.Naty
  8321. Brdy = psn_info.Brdy
  8322. Age = psn_info.Age
  8323. infoStr = psn_info.Insuinfo
  8324. idetinfoStr = psn_info.Idetinfo
  8325. infocode = 0
  8326. verify_number = psn_info.VerifyNumber
  8327. } else if id_card_type == 2 {
  8328. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  8329. fmt.Println(errMsgLog)
  8330. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. PsnNo = res.Output.Baseinfo.PsnNo
  8337. PsnCertType = res.Output.Baseinfo.PsnCertType
  8338. Certno = res.Output.Baseinfo.Certno
  8339. PsnName = res.Output.Baseinfo.PsnName
  8340. Gend = res.Output.Baseinfo.Gend
  8341. Naty = res.Output.Baseinfo.Naty
  8342. Brdy = res.Output.Baseinfo.Brdy
  8343. Age = res.Output.Baseinfo.Age
  8344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8346. infoStr = string(Iinfos)
  8347. idetinfoStr = string(Idetinfos)
  8348. infocode = res.Infcode
  8349. }
  8350. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8351. if id_card_type == 1 {
  8352. psn_info, _ := service.GetPsnByPatientId(id)
  8353. PsnNo = psn_info.PsnNo
  8354. PsnCertType = psn_info.PsnCertType
  8355. Certno = psn_info.Certno
  8356. PsnName = psn_info.PsnName
  8357. Gend = psn_info.Gend
  8358. Naty = psn_info.Naty
  8359. Brdy = psn_info.Brdy
  8360. Age = psn_info.Age
  8361. infoStr = psn_info.Insuinfo
  8362. idetinfoStr = psn_info.Idetinfo
  8363. infocode = 0
  8364. verify_number = psn_info.VerifyNumber
  8365. } else if id_card_type == 2 {
  8366. 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, "")
  8367. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8368. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8369. utils.ErrorLog("解析失败:%v", err)
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. return
  8372. }
  8373. PsnNo = res.Output.Baseinfo.PsnNo
  8374. PsnCertType = res.Output.Baseinfo.PsnCertType
  8375. Certno = res.Output.Baseinfo.Certno
  8376. PsnName = res.Output.Baseinfo.PsnName
  8377. Gend = res.Output.Baseinfo.Gend
  8378. Naty = res.Output.Baseinfo.Naty
  8379. Brdy = res.Output.Baseinfo.Brdy
  8380. Age = res.Output.Baseinfo.Age
  8381. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8382. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8383. infoStr = string(Iinfos)
  8384. idetinfoStr = string(Idetinfos)
  8385. infocode = res.Infcode
  8386. }
  8387. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8388. if id_card_type == 1 {
  8389. psn_info, _ := service.GetPsnByPatientId(id)
  8390. PsnNo = psn_info.PsnNo
  8391. PsnCertType = psn_info.PsnCertType
  8392. Certno = psn_info.Certno
  8393. PsnName = psn_info.PsnName
  8394. Gend = psn_info.Gend
  8395. Naty = psn_info.Naty
  8396. Brdy = psn_info.Brdy
  8397. Age = psn_info.Age
  8398. infoStr = psn_info.Insuinfo
  8399. idetinfoStr = psn_info.Idetinfo
  8400. infocode = 0
  8401. verify_number = psn_info.VerifyNumber
  8402. } else if id_card_type == 2 {
  8403. 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)
  8404. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8406. utils.ErrorLog("解析失败:%v", err)
  8407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8408. return
  8409. }
  8410. PsnNo = res.Output.Baseinfo.PsnNo
  8411. PsnCertType = res.Output.Baseinfo.PsnCertType
  8412. Certno = res.Output.Baseinfo.Certno
  8413. PsnName = res.Output.Baseinfo.PsnName
  8414. Gend = res.Output.Baseinfo.Gend
  8415. Naty = res.Output.Baseinfo.Naty
  8416. Brdy = res.Output.Baseinfo.Brdy
  8417. Age = res.Output.Baseinfo.Age
  8418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8420. infoStr = string(Iinfos)
  8421. idetinfoStr = string(Idetinfos)
  8422. infocode = res.Infcode
  8423. } else if id_card_type == 4 {
  8424. psn_info, _ := service.GetPsnByPatientId(id)
  8425. PsnNo = psn_info.PsnNo
  8426. PsnCertType = psn_info.PsnCertType
  8427. Certno = psn_info.Certno
  8428. PsnName = psn_info.PsnName
  8429. Gend = psn_info.Gend
  8430. Naty = psn_info.Naty
  8431. Brdy = psn_info.Brdy
  8432. Age = psn_info.Age
  8433. infoStr = psn_info.Insuinfo
  8434. idetinfoStr = psn_info.Idetinfo
  8435. infocode = 0
  8436. verify_number = psn_info.VerifyNumber
  8437. }
  8438. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8439. var result string
  8440. var requestLog string
  8441. 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), "")
  8442. if id_card_type == 4 {
  8443. psn_info, _ := service.GetPsnByPatientId(id)
  8444. PsnNo = psn_info.PsnNo
  8445. PsnCertType = psn_info.PsnCertType
  8446. Certno = psn_info.Certno
  8447. PsnName = psn_info.PsnName
  8448. Gend = psn_info.Gend
  8449. Naty = psn_info.Naty
  8450. Brdy = psn_info.Brdy
  8451. Age = psn_info.Age
  8452. infoStr = psn_info.Insuinfo
  8453. idetinfoStr = psn_info.Idetinfo
  8454. infocode = 0
  8455. verify_number = psn_info.VerifyNumber
  8456. } else {
  8457. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8458. if miConfig.Code == "H15049901371" {
  8459. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8460. utils.ErrorLog("解析失败:%v", err)
  8461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8462. return
  8463. }
  8464. res.ErrMsg = res10265.ErrMsg
  8465. res.Output = res10265.Output
  8466. res.InfRefmsgid = res10265.InfRefmsgid
  8467. } else {
  8468. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8469. utils.ErrorLog("解析失败:%v", err)
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. return
  8472. }
  8473. }
  8474. PsnNo = res.Output.Baseinfo.PsnNo
  8475. PsnCertType = res.Output.Baseinfo.PsnCertType
  8476. Certno = res.Output.Baseinfo.Certno
  8477. PsnName = res.Output.Baseinfo.PsnName
  8478. Gend = res.Output.Baseinfo.Gend
  8479. Naty = res.Output.Baseinfo.Naty
  8480. Brdy = res.Output.Baseinfo.Brdy
  8481. Age = res.Output.Baseinfo.Age
  8482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8484. infoStr = string(Iinfos)
  8485. idetinfoStr = string(Idetinfos)
  8486. if miConfig.Code == "H15049901371" {
  8487. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8488. } else {
  8489. infocode = res.Infcode
  8490. }
  8491. }
  8492. } else {
  8493. var result string
  8494. var requestLog string
  8495. //if miConfig.UserOrgId == 10138 {
  8496. if id_card_type != 4 || id_card_type != 1 {
  8497. var insa string
  8498. if len(patient.InsuplcAdmdvs) > 0 {
  8499. insa = patient.InsuplcAdmdvs
  8500. } else {
  8501. insa = miConfig.InsuplcAdmdvs
  8502. }
  8503. //psn_info, _ := service.GetPsnByPatientId(id)
  8504. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  8505. 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)
  8506. }
  8507. //}
  8508. //else {
  8509. // var insa string
  8510. // if len(patient.InsuplcAdmdvs) > 0 {
  8511. // insa = patient.InsuplcAdmdvs
  8512. // } else {
  8513. // insa = miConfig.InsuplcAdmdvs
  8514. // }
  8515. // 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)
  8516. //}
  8517. if id_card_type == 4 || id_card_type == 1 {
  8518. psn_info, _ := service.GetPsnByPatientId(id)
  8519. PsnNo = psn_info.PsnNo
  8520. PsnCertType = psn_info.PsnCertType
  8521. Certno = psn_info.Certno
  8522. PsnName = psn_info.PsnName
  8523. Gend = psn_info.Gend
  8524. Naty = psn_info.Naty
  8525. Brdy = psn_info.Brdy
  8526. Age = psn_info.Age
  8527. infoStr = psn_info.Insuinfo
  8528. idetinfoStr = psn_info.Idetinfo
  8529. infocode = 0
  8530. verify_number = psn_info.VerifyNumber
  8531. } else {
  8532. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8533. if miConfig.Code == "H15049901371" {
  8534. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. res.ErrMsg = res10265.ErrMsg
  8540. res.Output = res10265.Output
  8541. res.InfRefmsgid = res10265.InfRefmsgid
  8542. } else {
  8543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8544. utils.ErrorLog("解析失败:%v", err)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. }
  8549. PsnNo = res.Output.Baseinfo.PsnNo
  8550. PsnCertType = res.Output.Baseinfo.PsnCertType
  8551. Certno = res.Output.Baseinfo.Certno
  8552. PsnName = res.Output.Baseinfo.PsnName
  8553. Gend = res.Output.Baseinfo.Gend
  8554. Naty = res.Output.Baseinfo.Naty
  8555. Brdy = res.Output.Baseinfo.Brdy
  8556. Age = res.Output.Baseinfo.Age
  8557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8559. infoStr = string(Iinfos)
  8560. idetinfoStr = string(Idetinfos)
  8561. if miConfig.Code == "H15049901371" {
  8562. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8563. } else {
  8564. infocode = res.Infcode
  8565. }
  8566. }
  8567. }
  8568. if infocode == 0 {
  8569. his := models.VMHisPatient{
  8570. Name: name,
  8571. Gender: gender,
  8572. Birthday: birthUnix,
  8573. MedicalTreatmentType: medical_care,
  8574. IdType: certificates,
  8575. IdCardNo: id_card,
  8576. BalanceAccountsType: settlementValue,
  8577. SocialType: social_type,
  8578. MedicalInsuranceNumber: medical_insurance_card,
  8579. RegisterType: register_type,
  8580. RegisterCost: registration_fee,
  8581. TreatmentCost: medical_expenses,
  8582. Status: 1,
  8583. Ctime: time.Now().Unix(),
  8584. Mtime: time.Now().Unix(),
  8585. PsnNo: PsnNo,
  8586. PsnCertType: PsnCertType,
  8587. Certno: Certno,
  8588. PsnName: PsnName,
  8589. Gend: Gend,
  8590. Naty: Naty,
  8591. Brdy: Brdy,
  8592. Age: Age,
  8593. Iinfo: infoStr,
  8594. Idetinfo: idetinfoStr,
  8595. PatientId: patient.ID,
  8596. RecordDate: theTime.Unix(),
  8597. UserOrgId: adminInfo.CurrentOrgId,
  8598. AdminUserId: admin_user_id,
  8599. IsReturn: 1,
  8600. IdCardType: id_card_type,
  8601. Doctor: doctor,
  8602. Departments: department,
  8603. MdtrtGrpType: mdtrt_type,
  8604. }
  8605. timestamp := time.Now().Unix()
  8606. tempTime := time.Unix(timestamp, 0)
  8607. timeFormat := tempTime.Format("20060102150405")
  8608. chrgBchno := rand.Intn(100000) + 10000
  8609. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8610. his.Number = ipt_otp_no
  8611. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8612. department, _ := service.GetDepartMentDetail(department)
  8613. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8614. IdCardNo := ""
  8615. if id_card_type == 1 {
  8616. // IdCardNo = medical_insurance_card
  8617. IdCardNo = patient.IdCardNo
  8618. } else {
  8619. IdCardNo = patient.IdCardNo
  8620. }
  8621. var rf []*ResultFive
  8622. json.Unmarshal([]byte(his.Iinfo), &rf)
  8623. var insutypes []*ResultFive
  8624. var insutype string
  8625. var insuplc_admdvs_temp string
  8626. var is390 int = 0
  8627. var is310 int = 0
  8628. for _, item := range rf {
  8629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8630. insutypes = append(insutypes, item)
  8631. }
  8632. }
  8633. if len(insutypes) == 1 {
  8634. insutype = insutypes[0].Insutype
  8635. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8636. } else {
  8637. for _, i := range insutypes {
  8638. if i.Insutype == "390" {
  8639. is390 = 1
  8640. }
  8641. if i.Insutype == "310" {
  8642. is310 = 1
  8643. }
  8644. }
  8645. }
  8646. if is390 == 1 {
  8647. insutype = "390"
  8648. }
  8649. if is310 == 1 {
  8650. insutype = "310"
  8651. }
  8652. fmt.Println(social_type)
  8653. if social_type > 0 {
  8654. insutype = strconv.FormatInt(social_type, 10)
  8655. }
  8656. var infocode int64
  8657. var resThree ResultThree
  8658. var resThree10265 ResultThree10265
  8659. if len(insuplc_admdvs) == 0 {
  8660. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  8661. } else {
  8662. insuplc_admdvs_temp = insuplc_admdvs
  8663. }
  8664. if miConfig.MdtrtareaAdmvs == "421300" {
  8665. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  8666. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  8667. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8668. "&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
  8669. resp, requestErr := http.Get(api)
  8670. if requestErr != nil {
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. body, ioErr := ioutil.ReadAll(resp.Body)
  8675. if ioErr != nil {
  8676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8678. return
  8679. }
  8680. var respJSON map[string]interface{}
  8681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8687. result, _ := json.Marshal(respJSON)
  8688. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8689. utils.ErrorLog("解析失败:%v", err)
  8690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8691. return
  8692. }
  8693. infocode = resThree.Infcode
  8694. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8695. psn_info, _ := service.GetPsnByPatientId(id)
  8696. his.PsnNo = psn_info.PsnNo
  8697. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8698. var cert_no string
  8699. if id_card_type == 3 {
  8700. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  8701. cert_no = IdCardNo
  8702. } else if id_card_type == 4 {
  8703. cert_no = IdCardNo
  8704. psn_info.VerifyNumber = psn_info.VerifyNumber
  8705. } else {
  8706. bas := strings.Split(psn_info.CardInfo, "|")
  8707. cert_no = bas[2]
  8708. }
  8709. var hisPrescription []*models.HisPrescription
  8710. for _, item := range rf {
  8711. if item.Insutype == insutype {
  8712. //insuplc_admdvs = item.InsuplcAdmdvs
  8713. his.InsuplcAdmdvs = insuplc_admdvs
  8714. }
  8715. }
  8716. his.Insutype = insutype
  8717. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  8718. fmt.Println(res3101)
  8719. fmt.Println(res3101.Infcode)
  8720. if res3101.Infcode == "0" {
  8721. fmt.Println("33333333")
  8722. if len(res3101.Output.Result) > 0 {
  8723. fmt.Println("222222")
  8724. for _, item := range res3101.Output.Result {
  8725. if len(res3101.ErrMsg) == 0 {
  8726. res3101.ErrMsg = item.VolaCont
  8727. } else {
  8728. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  8729. }
  8730. }
  8731. c.ServeSuccessJSON(map[string]interface{}{
  8732. "failed_code": -10,
  8733. "msg": res3101.ErrMsg,
  8734. })
  8735. return
  8736. } else {
  8737. fmt.Println("11111")
  8738. var api string
  8739. if miConfig.MdtrtareaAdmvs == "320921" {
  8740. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8741. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8742. "&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
  8743. } else {
  8744. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8745. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8746. "&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
  8747. }
  8748. resp, requestErr := http.Get(api)
  8749. if requestErr != nil {
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. body, ioErr := ioutil.ReadAll(resp.Body)
  8754. if ioErr != nil {
  8755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. var respJSON map[string]interface{}
  8760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8763. return
  8764. }
  8765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8766. result, _ := json.Marshal(respJSON)
  8767. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8768. utils.ErrorLog("解析失败:%v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. resThree.ErrMsg = resThree10265.ErrMsg
  8773. resThree.Output = resThree10265.Output
  8774. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8775. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8776. }
  8777. } else if res3101.Infcode != "0" {
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "failed_code": -10,
  8780. "msg": res3101.ErrMsg,
  8781. })
  8782. return
  8783. }
  8784. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8785. psn_info, _ := service.GetPsnByPatientId(id)
  8786. var cert_no string
  8787. if id_card_type == 1 {
  8788. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8789. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8790. } else if id_card_type == 4 {
  8791. cert_no = psn_info.VerifyNumber
  8792. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8793. } else {
  8794. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8795. cert_no = psn_info.VerifyNumber
  8796. }
  8797. 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)
  8798. saveLog(result, requestLog, "2201", "挂号")
  8799. if miConfig.Code == "H15049901371" {
  8800. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8801. utils.ErrorLog("解析失败:%v", err)
  8802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8803. return
  8804. }
  8805. resThree.ErrMsg = resThree10265.ErrMsg
  8806. resThree.Output = resThree10265.Output
  8807. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8808. } else {
  8809. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8810. utils.ErrorLog("解析失败:%v", err)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. }
  8815. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8816. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  8817. psn_info, _ := service.GetPsnByPatientId(id)
  8818. var result string
  8819. var requestLog string
  8820. if id_card_type == 1 {
  8821. bas := strings.Split(psn_info.CardInfo, "|")
  8822. basNumber := bas[2]
  8823. card_sn := bas[3]
  8824. 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)
  8825. saveLog(result, requestLog, "2201A", "挂号")
  8826. } else if id_card_type == 2 {
  8827. 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, "", "")
  8828. saveLog(result, requestLog, "2201A", "挂号")
  8829. } else {
  8830. 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, "", "")
  8831. saveLog(result, requestLog, "2201A", "挂号")
  8832. }
  8833. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8834. utils.ErrorLog("解析失败:%v", err)
  8835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8836. return
  8837. }
  8838. infocode = resThree.Infcode
  8839. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  8840. psn_info, _ := service.GetPsnByPatientId(id)
  8841. var result string
  8842. var requestLog string
  8843. if id_card_type == 1 {
  8844. bas := strings.Split(psn_info.CardInfo, "|")
  8845. basNumber := bas[2]
  8846. card_sn := bas[3]
  8847. 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)
  8848. saveLog(result, requestLog, "2201A", "挂号")
  8849. } else if id_card_type == 2 {
  8850. 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, "", "")
  8851. saveLog(result, requestLog, "2201A", "挂号")
  8852. } else {
  8853. 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, "", "")
  8854. saveLog(result, requestLog, "2201A", "挂号")
  8855. }
  8856. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8857. utils.ErrorLog("解析失败:%v", err)
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. infocode = resThree.Infcode
  8862. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8863. psn_info, _ := service.GetPsnByPatientId(id)
  8864. 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)
  8865. saveLog(result, requestLog, "2201A", "挂号")
  8866. if miConfig.Code == "H15049901371" {
  8867. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8868. utils.ErrorLog("解析失败:%v", err)
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. resThree.ErrMsg = resThree10265.ErrMsg
  8873. resThree.Output = resThree10265.Output
  8874. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8875. } else {
  8876. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8877. utils.ErrorLog("解析失败:%v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. }
  8882. if miConfig.Code == "H15049901371" {
  8883. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8884. } else {
  8885. infocode = resThree.Infcode
  8886. }
  8887. } else {
  8888. psn_info, _ := service.GetPsnByPatientId(id)
  8889. if id_card_type == 4 || id_card_type == 1 {
  8890. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8891. }
  8892. var rf []*ResultFive
  8893. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  8894. var insutypes []*ResultFive
  8895. var insutype string
  8896. var is390 int = 0
  8897. var is310 int = 0
  8898. for _, item := range rf {
  8899. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8900. insutypes = append(insutypes, item)
  8901. }
  8902. }
  8903. if len(insutypes) == 1 {
  8904. insutype = insutypes[0].Insutype
  8905. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8906. } else {
  8907. for _, i := range insutypes {
  8908. if i.Insutype == "390" {
  8909. is390 = 1
  8910. }
  8911. if i.Insutype == "310" {
  8912. is310 = 1
  8913. }
  8914. }
  8915. }
  8916. if is390 == 1 {
  8917. insutype = "390"
  8918. }
  8919. if is310 == 1 {
  8920. insutype = "310"
  8921. }
  8922. fmt.Println(len(insutypes))
  8923. if len(insutypes) == 0 {
  8924. for index, item := range rf {
  8925. if index == 0 {
  8926. insutype = item.Insutype
  8927. insuplc_admdvs = item.InsuplcAdmdvs
  8928. }
  8929. }
  8930. fmt.Println(insutype)
  8931. fmt.Println(insuplc_admdvs)
  8932. }
  8933. if social_type > 0 {
  8934. insutype = strconv.FormatInt(social_type, 10)
  8935. }
  8936. 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)
  8937. saveLog(result, requestLog, "2201A", "挂号")
  8938. if miConfig.Code == "H15049901371" {
  8939. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8940. utils.ErrorLog("解析失败:%v", err)
  8941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8942. return
  8943. }
  8944. resThree.ErrMsg = resThree10265.ErrMsg
  8945. resThree.Output = resThree10265.Output
  8946. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8947. } else {
  8948. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8949. utils.ErrorLog("解析失败:%v", err)
  8950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8951. return
  8952. }
  8953. }
  8954. if miConfig.Code == "H15049901371" {
  8955. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8956. } else {
  8957. infocode = resThree.Infcode
  8958. }
  8959. }
  8960. if infocode != 0 {
  8961. adminUser := c.GetAdminUserInfo()
  8962. errlog := &models.HisOrderError{
  8963. UserOrgId: adminUser.CurrentOrgId,
  8964. Ctime: time.Now().Unix(),
  8965. Mtime: time.Now().Unix(),
  8966. ErrMsg: resThree.ErrMsg,
  8967. Status: 1,
  8968. PatientId: id,
  8969. RecordTime: recordDateTime,
  8970. Stage: 2,
  8971. }
  8972. service.CreateErrMsgLog(errlog)
  8973. c.ServeSuccessJSON(map[string]interface{}{
  8974. "failed_code": -10,
  8975. "msg": resThree.ErrMsg,
  8976. })
  8977. return
  8978. }
  8979. his.Number = resThree.Output.Data.MdtrtID
  8980. his.PsnNo = resThree.Output.Data.PsnNo
  8981. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8982. his.IdCardNo = patient.IdCardNo
  8983. his.PhoneNumber = patient.Phone
  8984. his.UserOrgId = adminInfo.CurrentOrgId
  8985. his.Insutype = insutype
  8986. his.Ctime = time.Now().Unix()
  8987. his.Mtime = time.Now().Unix()
  8988. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8989. his.Status = 1
  8990. his.MdtrtGrpType = mdtrt_type
  8991. service.UpdateHisPatientStatus(&his)
  8992. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8993. c.ServeSuccessJSON(map[string]interface{}{
  8994. "his_info": his,
  8995. })
  8996. } else {
  8997. adminUser := c.GetAdminUserInfo()
  8998. errlog := &models.HisOrderError{
  8999. UserOrgId: adminUser.CurrentOrgId,
  9000. Ctime: time.Now().Unix(),
  9001. Mtime: time.Now().Unix(),
  9002. ErrMsg: res.ErrMsg,
  9003. Status: 1,
  9004. PatientId: id,
  9005. RecordTime: recordDateTime,
  9006. Stage: 1,
  9007. }
  9008. service.CreateErrMsgLog(errlog)
  9009. c.ServeSuccessJSON(map[string]interface{}{
  9010. "failed_code": -10,
  9011. "msg": res.ErrMsg,
  9012. })
  9013. return
  9014. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9015. }
  9016. }
  9017. }
  9018. func (c *HisApiController) GetUploadInfo() {
  9019. id, _ := c.GetInt64("id")
  9020. record_time := c.GetString("record_time")
  9021. his_patient_id, _ := c.GetInt64("his_patient_id")
  9022. order_id, _ := c.GetInt64("order_id")
  9023. pay_way, _ := c.GetInt64("pay_way")
  9024. pay_ways := c.GetString("pay_ways")
  9025. oth_desc := c.GetString("oth_desc")
  9026. pay_price, _ := c.GetFloat("pay_price")
  9027. pay_card_no := c.GetString("pay_card_no")
  9028. discount_price, _ := c.GetFloat("discount_price")
  9029. preferential_price, _ := c.GetFloat("preferential_price")
  9030. reality_price, _ := c.GetFloat("reality_price")
  9031. found_price, _ := c.GetFloat("found_price")
  9032. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  9033. private_price, _ := c.GetFloat("private_price")
  9034. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9035. admin_user_id, _ := c.GetInt64("admin_user_id")
  9036. fapiao_code := c.GetString("fapiao_code")
  9037. fapiao_number := c.GetString("fapiao_number")
  9038. diagnosis_id := c.GetString("diagnosis")
  9039. sick_type, _ := c.GetInt64("sick_type")
  9040. reg_type, _ := c.GetInt64("p_type")
  9041. begin_time := c.GetString("begin_time")
  9042. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  9043. cash_pay := c.GetString("cash_pay")
  9044. band_card_pay := c.GetString("band_card_pay")
  9045. wechat_pay := c.GetString("wechat_pay")
  9046. ali_pay := c.GetString("ali_pay")
  9047. jifen_pay := c.GetString("jifen_pay")
  9048. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  9049. fmt.Println(acct_used_flag)
  9050. id_str := c.GetString("ids")
  9051. ids_arr := strings.Split(id_str, ",")
  9052. timeLayout := "2006-01-02"
  9053. loc, _ := time.LoadLocation("Local")
  9054. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9055. if err != nil {
  9056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9057. return
  9058. }
  9059. recordDateTime := theTime.Unix()
  9060. adminUser := c.GetAdminUserInfo()
  9061. var tempOrder models.HisOrder
  9062. tempOrder, _ = service.GetHisOrderByID(order_id)
  9063. var prescriptions []*models.HisPrescription
  9064. var start_time int64
  9065. var end_time int64
  9066. //押金模块
  9067. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  9068. tmp_decimal := c.GetString("tmp_decimal")
  9069. var decimal float64 //本次使用的押金
  9070. var errmsg error
  9071. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  9072. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  9073. return
  9074. }
  9075. if len(tmp_decimal) > 0 {
  9076. if tmp_decimal[0] == 45 {
  9077. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  9078. return
  9079. }
  9080. }
  9081. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  9082. fmt.Println(errs)
  9083. decimal = tt
  9084. //if adminUser.CurrentOrgId == 10106{
  9085. // if len(fapiao_code) == 0{
  9086. // fapiao_code = "144072080589"
  9087. // }
  9088. // if len(fapiao_number) == 0{
  9089. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  9090. // if order.ID == 0{
  9091. // fapiao_number = "00001520"
  9092. // }else{
  9093. // //fapiao_code = "00001520"
  9094. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  9095. // var zero string
  9096. // if fpNumber >= 1000{
  9097. // zero = "0000" + strconv.Itoa(fpNumber)
  9098. // }else if fpNumber >= 10000{
  9099. // zero = "000" + strconv.Itoa(fpNumber)
  9100. // } else if fpNumber >= 100000{
  9101. // zero = "00" + strconv.Itoa(fpNumber)
  9102. // } else if fpNumber >= 1000000{
  9103. // zero = "0" + strconv.Itoa(fpNumber)
  9104. // }else {
  9105. // zero = strconv.Itoa(fpNumber)
  9106. // }
  9107. // fapiao_number = zero
  9108. // }
  9109. // }
  9110. //}
  9111. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9112. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9113. var patientPrescription models.HisPrescriptionInfo
  9114. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9115. if patientPrescription.ID == 0 {
  9116. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9117. }
  9118. //if patientPrescription.Do
  9119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9120. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9122. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9123. var config []*models.HisXtDiagnoseConfig
  9124. for _, item := range diagnosis_ids {
  9125. id, _ := strconv.ParseInt(item, 10, 64)
  9126. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9127. config = append(config, &diagnosisConfig)
  9128. }
  9129. sickConfig, _ := service.FindSickById(sick_type)
  9130. //if tempOrder.ID == 0 {
  9131. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  9132. //}
  9133. if tempOrder.ID == 0 {
  9134. var result string
  9135. var requestLog string
  9136. var res2 ResultSix
  9137. var ressix10265 ResultSix10265
  9138. if miConfig.MdtrtareaAdmvs == "421300" {
  9139. data := make(map[string]interface{})
  9140. client := &http.Client{}
  9141. data["psn_no"] = his.PsnNo
  9142. data["mdtrt_id"] = his.Number
  9143. data["opter"] = roles.UserName
  9144. data["org_name"] = miConfig.OrgName
  9145. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9146. data["doctor_id"] = doctor_info.DoctorNumber
  9147. data["doctor_name"] = doctor_info.UserName
  9148. data["department"] = department.Name
  9149. data["fixmedins_code"] = miConfig.Code
  9150. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9151. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9152. data["secret_key"] = miConfig.SecretKey
  9153. data["sick_code"] = sickConfig.CountryCode
  9154. data["sick_name"] = sickConfig.ClassName
  9155. data["dept"] = strconv.FormatInt(department.ID, 10)
  9156. data["config"] = config
  9157. data["begin_time"] = begin_time
  9158. bytesData, _ := json.Marshal(data)
  9159. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9160. resp, _ := client.Do(req)
  9161. defer resp.Body.Close()
  9162. body, ioErr := ioutil.ReadAll(resp.Body)
  9163. if ioErr != nil {
  9164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. var respJSON map[string]interface{}
  9169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9175. userJSONBytes, _ := json.Marshal(respJSON)
  9176. fmt.Println("log")
  9177. fmt.Println(string(userJSONBytes))
  9178. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9179. utils.ErrorLog("解析失败:%v", err)
  9180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9181. return
  9182. }
  9183. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9184. data := make(map[string]interface{})
  9185. client := &http.Client{}
  9186. data["psn_no"] = his.PsnNo
  9187. data["mdtrt_id"] = his.Number
  9188. data["doctor"] = roles.UserName
  9189. data["department"] = department.Name
  9190. data["org_name"] = miConfig.OrgName
  9191. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9192. data["doctor_id"] = doctor_info.DoctorNumber
  9193. data["new_doctor_name"] = doctor_info.UserName
  9194. data["fixmedins_code"] = miConfig.Code
  9195. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9196. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9197. data["secret_key"] = miConfig.SecretKey
  9198. data["sick_code"] = sickConfig.CountryCode
  9199. data["sick_name"] = sickConfig.ClassName
  9200. data["url"] = miConfig.Url
  9201. data["ak"] = miConfig.AccessKey
  9202. data["begin_time"] = begin_time
  9203. data["cainfo"] = miConfig.Cainfo
  9204. data["dept"] = strconv.FormatInt(department.ID, 10)
  9205. data["config"] = config
  9206. bytesData, _ := json.Marshal(data)
  9207. var req *http.Request
  9208. if miConfig.MdtrtareaAdmvs == "320921" {
  9209. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9210. //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 +
  9211. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  9212. } else {
  9213. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9214. }
  9215. resp, _ := client.Do(req)
  9216. defer resp.Body.Close()
  9217. body, ioErr := ioutil.ReadAll(resp.Body)
  9218. if ioErr != nil {
  9219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9221. return
  9222. }
  9223. var respJSON map[string]interface{}
  9224. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9230. userJSONBytes, _ := json.Marshal(respJSON)
  9231. fmt.Println("log")
  9232. fmt.Println(string(userJSONBytes))
  9233. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  9234. utils.ErrorLog("解析失败:%v", err)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9239. res2.Output = ressix10265.Output
  9240. res2.ErrMsg = ressix10265.ErrMsg
  9241. res2.Cainfo = ressix10265.Cainfo
  9242. res2.WarnMsg = ressix10265.WarnMsg
  9243. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9244. res2.Infcode = infocode
  9245. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9246. 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)
  9247. saveLog(result, requestLog, "2203", "上传就诊信息")
  9248. var respJSON2 map[string]interface{}
  9249. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9252. return
  9253. }
  9254. userJSONBytes2, _ := json.Marshal(respJSON2)
  9255. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9256. utils.ErrorLog("解析失败:%v", err)
  9257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9258. return
  9259. }
  9260. 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)
  9261. fmt.Println(result2)
  9262. fmt.Println(src_request)
  9263. } else {
  9264. if miConfig.MdtrtareaAdmvs == "440781" { //
  9265. 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)
  9266. } else {
  9267. if miConfig.Code == "H15049901371" {
  9268. //赤峰地区国家医保医疗类别
  9269. //职工透析:医疗类别选特殊情况门诊990502
  9270. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9271. var med_type string
  9272. if his.Insutype == "390" {
  9273. if reg_type == 14 {
  9274. med_type = "9933"
  9275. } else if reg_type == 11 {
  9276. med_type = "11"
  9277. }
  9278. } else if his.Insutype == "310" {
  9279. if reg_type == 14 {
  9280. med_type = "990502"
  9281. } else if reg_type == 11 {
  9282. med_type = "11"
  9283. }
  9284. }
  9285. 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)
  9286. } else {
  9287. 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)
  9288. }
  9289. }
  9290. saveLog(result, requestLog, "2203", "上传就诊信息")
  9291. var respJSON2 map[string]interface{}
  9292. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9295. return
  9296. }
  9297. userJSONBytes2, _ := json.Marshal(respJSON2)
  9298. if miConfig.Code == "H15049901371" {
  9299. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  9300. utils.ErrorLog("解析失败:%v", err)
  9301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9302. return
  9303. }
  9304. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9305. res2.Output = ressix10265.Output
  9306. res2.ErrMsg = ressix10265.ErrMsg
  9307. res2.Cainfo = ressix10265.Cainfo
  9308. res2.WarnMsg = ressix10265.WarnMsg
  9309. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9310. res2.Infcode = infocode
  9311. } else {
  9312. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9313. utils.ErrorLog("解析失败:%v", err)
  9314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9315. return
  9316. }
  9317. }
  9318. }
  9319. if res2.Infcode != 0 {
  9320. adminUser := c.GetAdminUserInfo()
  9321. errlog := &models.HisOrderError{
  9322. UserOrgId: adminUser.CurrentOrgId,
  9323. Ctime: time.Now().Unix(),
  9324. Mtime: time.Now().Unix(),
  9325. ErrMsg: res2.ErrMsg,
  9326. Status: 1,
  9327. PatientId: id,
  9328. RecordTime: recordDateTime,
  9329. Stage: 3,
  9330. }
  9331. service.CreateErrMsgLog(errlog)
  9332. c.ServeSuccessJSON(map[string]interface{}{
  9333. "failed_code": -10,
  9334. "msg": res2.ErrMsg,
  9335. })
  9336. return
  9337. } else {
  9338. his.Diagnosis = diagnosis_id
  9339. his.SickType = sickConfig.ID
  9340. //var p_type int64
  9341. //if reg_type == 1111 || reg_type == 1112 {
  9342. // p_type = 11
  9343. //
  9344. //}
  9345. his.PType = fmt.Sprintf("%d", reg_type)
  9346. service.UpdateHisPatientThree(&his)
  9347. data := make(map[string]interface{})
  9348. if settle_accounts_type == 1 { //日结
  9349. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9350. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9351. } else {
  9352. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9353. }
  9354. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  9355. data["pre"] = prescriptions
  9356. } else { //月结
  9357. start_time_str := c.GetString("start_time")
  9358. end_time_str := c.GetString("end_time")
  9359. timeLayout := "2006-01-02"
  9360. loc, _ := time.LoadLocation("Local")
  9361. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9362. if err != nil {
  9363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9364. return
  9365. }
  9366. recordStartTime := theStartTime.Unix()
  9367. start_time = recordStartTime
  9368. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9369. if err != nil {
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9371. return
  9372. }
  9373. recordEndTime := theEndTime.Unix()
  9374. end_time = recordEndTime
  9375. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9376. data["pre"] = prescriptions
  9377. }
  9378. timestamp := time.Now().Unix()
  9379. tempTime := time.Unix(timestamp, 0)
  9380. timeFormat := tempTime.Format("20060102150405")
  9381. chrgBchno := rand.Intn(100000) + 10000
  9382. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9383. strconv.FormatInt(his.PatientId, 10)
  9384. client := &http.Client{}
  9385. data["psn_no"] = his.PsnNo
  9386. data["mdtrt_id"] = his.Number
  9387. data["chrg_bchno"] = chrg_bchno
  9388. data["org_name"] = miConfig.OrgName
  9389. data["doctor"] = doctor_info.UserName
  9390. data["doctor_id"] = doctor_info.DoctorNumber
  9391. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9392. data["fixmedins_code"] = miConfig.Code
  9393. data["opter"] = roles.UserName
  9394. data["dept_code"] = department.Number
  9395. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9396. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9397. data["secret_key"] = miConfig.SecretKey
  9398. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9399. data["url"] = miConfig.Url
  9400. data["ak"] = miConfig.AccessKey
  9401. data["new_doctor_name"] = patientPrescription.Doctor
  9402. data["diag_code"] = sickConfig.CountryCode
  9403. data["cainfo"] = miConfig.Cainfo
  9404. data["opter"] = roles.UserName
  9405. var ids []int64
  9406. for _, item := range prescriptions {
  9407. ids = append(ids, item.ID)
  9408. }
  9409. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9410. if config.IsOpen == 1 { //对接了医保,走医保流程
  9411. var res ResultFour
  9412. var resFour10265 ResultFour10265
  9413. if miConfig.MdtrtareaAdmvs == "421300" {
  9414. bytesData, _ := json.Marshal(data)
  9415. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9416. resp, _ := client.Do(req)
  9417. defer resp.Body.Close()
  9418. body, ioErr := ioutil.ReadAll(resp.Body)
  9419. if ioErr != nil {
  9420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9422. return
  9423. }
  9424. var respJSON map[string]interface{}
  9425. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9428. return
  9429. }
  9430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9431. userJSONBytes, _ := json.Marshal(respJSON)
  9432. fmt.Println("log")
  9433. fmt.Println(string(userJSONBytes))
  9434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9435. utils.ErrorLog("解析失败:%v", err)
  9436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9437. return
  9438. }
  9439. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9440. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9441. if result3101.Infcode == "0" {
  9442. if len(result3101.Output.Result) > 0 {
  9443. var errMsgs []string
  9444. for _, item := range result3101.Output.Result {
  9445. errMsgs = append(errMsgs, item.VolaCont)
  9446. }
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "failed_code": -10,
  9449. "msg": errMsgs,
  9450. })
  9451. return
  9452. }
  9453. }
  9454. if miConfig.MdtrtareaAdmvs == "320921" {
  9455. data["doctor_id"] = "D320923012139"
  9456. } else {
  9457. data["doctor_id"] = "D371621008686"
  9458. }
  9459. bytesData, _ := json.Marshal(data)
  9460. var req *http.Request
  9461. if miConfig.MdtrtareaAdmvs == "320921" {
  9462. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9463. } else {
  9464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9465. }
  9466. resp, _ := client.Do(req)
  9467. defer resp.Body.Close()
  9468. body, ioErr := ioutil.ReadAll(resp.Body)
  9469. if ioErr != nil {
  9470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. var respJSON map[string]interface{}
  9475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9481. userJSONBytes, _ := json.Marshal(respJSON)
  9482. fmt.Println("log")
  9483. fmt.Println(string(userJSONBytes))
  9484. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9485. utils.ErrorLog("解析失败:%v", err)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. res.InfRefmsgid = resFour10265.InfRefmsgid
  9490. res.Output = resFour10265.Output
  9491. res.ErrMsg = resFour10265.ErrMsg
  9492. res.Cainfo = resFour10265.Cainfo
  9493. res.WarnMsg = resFour10265.WarnMsg
  9494. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9495. res.Infcode = infocode
  9496. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9497. 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)
  9498. var dat map[string]interface{}
  9499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9500. fmt.Println(dat)
  9501. } else {
  9502. fmt.Println(err)
  9503. }
  9504. saveLog(result, request_log, "2204", "上传费用明细")
  9505. userJSONBytes, _ := json.Marshal(dat)
  9506. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9507. utils.ErrorLog("解析失败:%v", err)
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. res.InfRefmsgid = resFour10265.InfRefmsgid
  9512. res.Output = resFour10265.Output
  9513. res.ErrMsg = resFour10265.ErrMsg
  9514. res.Cainfo = resFour10265.Cainfo
  9515. res.WarnMsg = resFour10265.WarnMsg
  9516. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9517. res.Infcode = infocode
  9518. } else {
  9519. if miConfig.Code == "H15049901371" {
  9520. 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)
  9521. var dat map[string]interface{}
  9522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9523. fmt.Println(dat)
  9524. } else {
  9525. fmt.Println(err)
  9526. }
  9527. saveLog(result, request_log, "2204", "上传费用明细")
  9528. userJSONBytes, _ := json.Marshal(dat)
  9529. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9530. utils.ErrorLog("解析失败:%v", err)
  9531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9532. return
  9533. }
  9534. res.InfRefmsgid = resFour10265.InfRefmsgid
  9535. res.Output = resFour10265.Output
  9536. res.ErrMsg = resFour10265.ErrMsg
  9537. res.Cainfo = resFour10265.Cainfo
  9538. res.WarnMsg = resFour10265.WarnMsg
  9539. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9540. res.Infcode = infocode
  9541. } else {
  9542. 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)
  9543. var dat map[string]interface{}
  9544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9545. fmt.Println(dat)
  9546. } else {
  9547. fmt.Println(err)
  9548. }
  9549. saveLog(result, request_log, "2204", "上传费用明细")
  9550. userJSONBytes, _ := json.Marshal(dat)
  9551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9552. utils.ErrorLog("解析失败:%v", err)
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9554. return
  9555. }
  9556. }
  9557. }
  9558. if res.Infcode == 0 {
  9559. order := &models.HisOrder{
  9560. UserOrgId: adminUser.CurrentOrgId,
  9561. HisPatientId: his.ID,
  9562. PatientId: his.PatientId,
  9563. SettleAccountsDate: recordDateTime,
  9564. MdtrtId: his.Number,
  9565. PsnNo: his.PsnNo,
  9566. MedType: strconv.FormatInt(reg_type, 10),
  9567. Ctime: time.Now().Unix(),
  9568. Mtime: time.Now().Unix(),
  9569. Status: 1,
  9570. Number: chrg_bchno,
  9571. Infcode: res.Infcode,
  9572. WarnMsg: res.WarnMsg,
  9573. Cainfo: res.Cainfo,
  9574. ErrMsg: res.ErrMsg,
  9575. RespondTime: res.RefmsgTime,
  9576. InfRefmsgid: res.InfRefmsgid,
  9577. OrderStatus: 1,
  9578. PayWay: pay_way,
  9579. PayWays: pay_ways,
  9580. OthDesc: oth_desc,
  9581. PayPrice: pay_price,
  9582. PayCardNo: pay_card_no,
  9583. DiscountPrice: discount_price,
  9584. PreferentialPrice: preferential_price,
  9585. RealityPrice: reality_price,
  9586. FoundPrice: found_price,
  9587. MedicalInsurancePrice: medical_insurance_price,
  9588. PrivatePrice: private_price,
  9589. IsMedicineInsurance: 1,
  9590. SettleType: settle_accounts_type,
  9591. SettleStartTime: start_time,
  9592. SettleEndTime: end_time,
  9593. Creator: roles.AdminUserId,
  9594. Modify: roles.AdminUserId,
  9595. FaPiaoNumber: fapiao_number,
  9596. FaPiaoCode: fapiao_code,
  9597. PType: 2,
  9598. Diagnosis: diagnosis_id,
  9599. CashPay: cash_pay,
  9600. WechatPay: wechat_pay,
  9601. AliPay: ali_pay,
  9602. JifenPay: jifen_pay,
  9603. BandCardPay: band_card_pay,
  9604. }
  9605. err = service.CreateOrder(order)
  9606. if err != nil {
  9607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9608. return
  9609. }
  9610. for _, item := range res.Output.Result {
  9611. temp := strings.Split(item.FeedetlSn, "-")
  9612. var advice_id int64 = 0
  9613. var project_id int64 = 0
  9614. var types int64 = 0
  9615. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9616. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9617. if temp[1] == "1" {
  9618. advice_id = id
  9619. project_id = 0
  9620. } else if temp[1] == "2" {
  9621. advice_id = 0
  9622. project_id = id
  9623. }
  9624. if item.MedChrgitmType == "9" {
  9625. item.MedChrgitmType = "09"
  9626. }
  9627. info := &models.HisOrderInfo{
  9628. OrderNumber: order.Number,
  9629. FeedetlSn: item.FeedetlSn,
  9630. UploadDate: time.Now().Unix(),
  9631. AdviceId: advice_id,
  9632. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9633. Cnt: item.Cnt,
  9634. Pric: float64(item.Pric),
  9635. PatientId: his.PatientId,
  9636. PricUplmtAmt: item.PricUplmtAmt,
  9637. SelfpayProp: item.SelfpayProp,
  9638. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9639. OverlmtAmt: item.OverlmtAmt,
  9640. PreselfpayAmt: item.PreselfpayAmt,
  9641. BasMednFlag: item.BasMednFlag,
  9642. MedChrgitmType: item.MedChrgitmType,
  9643. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9644. Status: 1,
  9645. Memo: item.Memo,
  9646. Mtime: time.Now().Unix(),
  9647. InscpScpAmt: item.InscpScpAmt,
  9648. DrtReimFlag: item.DrtReimFlag,
  9649. Ctime: time.Now().Unix(),
  9650. ListSpItemFlag: item.ListSpItemFlag,
  9651. ChldMedcFlag: item.ChldMedcFlag,
  9652. LmtUsedFlag: item.LmtUsedFlag,
  9653. ChrgitmLv: item.ChrgitmLv,
  9654. UserOrgId: adminUser.CurrentOrgId,
  9655. HisPatientId: his.ID,
  9656. OrderId: order.ID,
  9657. ProjectId: project_id,
  9658. Type: types,
  9659. }
  9660. service.CreateOrderInfo(info)
  9661. }
  9662. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9663. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9664. var total float64
  9665. for _, item := range prescriptions {
  9666. if item.Type == 1 { //药品
  9667. for _, subItem := range item.HisDoctorAdviceInfo {
  9668. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9669. total_one := price * subItem.PrescribingNumber
  9670. total = total + total_one
  9671. }
  9672. }
  9673. if item.Type == 2 { //项目
  9674. for _, subItem := range item.HisPrescriptionProject {
  9675. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9676. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9677. total_one := price * cnt
  9678. total = total + total_one
  9679. }
  9680. }
  9681. }
  9682. allTotal := fmt.Sprintf("%f", total)
  9683. //if adminUser.CurrentOrgId == 9919 {
  9684. //
  9685. // allTotal = fmt.Sprintf("%.2f", total)
  9686. //
  9687. //} else {
  9688. //
  9689. // allTotal = fmt.Sprintf("%.2f", total)
  9690. //
  9691. //}
  9692. if res.Infcode == 0 {
  9693. var rf []*ResultFive
  9694. json.Unmarshal([]byte(his.Iinfo), &rf)
  9695. chrg_bchno := chrg_bchno
  9696. cert_no := his.Certno
  9697. var insutypes []string
  9698. var insutype string
  9699. var is390 int = 0
  9700. var is310 int = 0
  9701. for _, item := range rf {
  9702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9703. insutypes = append(insutypes, item.Insutype)
  9704. }
  9705. }
  9706. if len(insutypes) == 1 {
  9707. insutype = insutypes[0]
  9708. } else {
  9709. for _, i := range insutypes {
  9710. if i == "390" {
  9711. is390 = 1
  9712. }
  9713. if i == "310" {
  9714. is310 = 1
  9715. }
  9716. }
  9717. }
  9718. if is390 == 1 {
  9719. insutype = "390"
  9720. }
  9721. if is310 == 1 {
  9722. insutype = "310"
  9723. }
  9724. if len(insutypes) == 0 {
  9725. insutype = "310"
  9726. }
  9727. if len(insutypes) == 2 {
  9728. insutype = strconv.FormatInt(his.SocialType, 10)
  9729. }
  9730. insutype = strconv.FormatInt(his.SocialType, 10)
  9731. //insutype = "390"
  9732. if his.IdCardType == 1 {
  9733. // cert_no = his.MedicalInsuranceNumber
  9734. cert_no = his.Certno
  9735. } else {
  9736. cert_no = his.Certno
  9737. }
  9738. var res ResultSeven
  9739. var resSeven10265 ResultSeven10265
  9740. var src_resquest string
  9741. var result2 string
  9742. if miConfig.MdtrtareaAdmvs == "421300" {
  9743. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9744. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9745. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9747. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9748. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9749. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9750. resp, requestErr := http.Get(api)
  9751. if requestErr != nil {
  9752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9753. return
  9754. }
  9755. body, ioErr := ioutil.ReadAll(resp.Body)
  9756. if ioErr != nil {
  9757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9759. return
  9760. }
  9761. var respJSON map[string]interface{}
  9762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9765. return
  9766. }
  9767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9768. result, _ := json.Marshal(respJSON)
  9769. if miConfig.Code == "H15049901371" {
  9770. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9771. utils.ErrorLog("解析失败:%v", err)
  9772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9773. return
  9774. }
  9775. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9776. res.Output = resSeven10265.Output
  9777. res.ErrMsg = resSeven10265.ErrMsg
  9778. res.Cainfo = resSeven10265.Cainfo
  9779. res.WarnMsg = resSeven10265.WarnMsg
  9780. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9781. res.Infcode = infocode
  9782. } else {
  9783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9784. utils.ErrorLog("解析失败:%v", err)
  9785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9786. return
  9787. }
  9788. }
  9789. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9790. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  9791. if result3101.Infcode == "0" {
  9792. if len(result3101.Output.Result) > 0 {
  9793. var errMsgs []string
  9794. for _, item := range result3101.Output.Result {
  9795. errMsgs = append(errMsgs, item.VolaCont)
  9796. }
  9797. c.ServeSuccessJSON(map[string]interface{}{
  9798. "failed_code": -10,
  9799. "msg": errMsgs,
  9800. })
  9801. return
  9802. } else {
  9803. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9804. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9805. bas := strings.Split(psn_info.CardInfo, "|")
  9806. if his.IdCardType == 1 {
  9807. cert_no = bas[2]
  9808. } else if his.IdCardType == 3 {
  9809. cert_no = his.Certno
  9810. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9811. } else if his.IdCardType == 4 {
  9812. cert_no = his.Certno
  9813. psn_info.VerifyNumber = psn_info.VerifyNumber
  9814. }
  9815. var api string
  9816. if miConfig.MdtrtareaAdmvs == "320921" {
  9817. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9818. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9819. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9820. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9821. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9822. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9823. "&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
  9824. } else {
  9825. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9826. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9827. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9828. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9829. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9830. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9831. "&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
  9832. }
  9833. resp, requestErr := http.Get(api)
  9834. if requestErr != nil {
  9835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9836. return
  9837. }
  9838. body, ioErr := ioutil.ReadAll(resp.Body)
  9839. if ioErr != nil {
  9840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9842. return
  9843. }
  9844. var respJSON map[string]interface{}
  9845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9851. result, _ := json.Marshal(respJSON)
  9852. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9853. utils.ErrorLog("解析失败:%v", err)
  9854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9855. return
  9856. }
  9857. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9858. res.Output = resSeven10265.Output
  9859. res.ErrMsg = resSeven10265.ErrMsg
  9860. res.Cainfo = resSeven10265.Cainfo
  9861. res.WarnMsg = resSeven10265.WarnMsg
  9862. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9863. res.Infcode = infocode
  9864. }
  9865. }
  9866. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9867. var cert_no string
  9868. if his.IdCardType == 4 {
  9869. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9870. cert_no = psn_info.VerifyNumber
  9871. 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)
  9872. } else if his.IdCardType == 1 {
  9873. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9874. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9875. 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)
  9876. }
  9877. //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)
  9878. var dat map[string]interface{}
  9879. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9880. fmt.Println(dat)
  9881. } else {
  9882. fmt.Println(err)
  9883. }
  9884. saveLog(result2, src_resquest, "2207", "结算")
  9885. userJSONBytes, _ := json.Marshal(dat)
  9886. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9887. utils.ErrorLog("解析失败:%v", err)
  9888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9889. return
  9890. }
  9891. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9892. res.Output = resSeven10265.Output
  9893. res.ErrMsg = resSeven10265.ErrMsg
  9894. res.Cainfo = resSeven10265.Cainfo
  9895. res.WarnMsg = resSeven10265.WarnMsg
  9896. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9897. res.Infcode = infocode
  9898. } else {
  9899. if miConfig.Code == "H15049901371" {
  9900. //赤峰地区国家医保医疗类别
  9901. //职工透析:医疗类别选特殊情况门诊990502
  9902. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9903. var med_type string
  9904. if his.Insutype == "390" {
  9905. if reg_type == 14 {
  9906. med_type = "9933"
  9907. } else if reg_type == 11 {
  9908. med_type = "11"
  9909. }
  9910. } else if his.Insutype == "310" {
  9911. if reg_type == 14 {
  9912. med_type = "990502"
  9913. } else if reg_type == 11 {
  9914. med_type = "11"
  9915. }
  9916. }
  9917. 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, "")
  9918. } else {
  9919. if his.IdCardType == 4 {
  9920. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9921. var token string
  9922. token = psn_info.VerifyNumber
  9923. 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)
  9924. } else {
  9925. 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, "")
  9926. }
  9927. }
  9928. //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)
  9929. var dat map[string]interface{}
  9930. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9931. fmt.Println(dat)
  9932. } else {
  9933. fmt.Println(err)
  9934. }
  9935. saveLog(result2, src_resquest, "2207", "结算")
  9936. userJSONBytes, _ := json.Marshal(dat)
  9937. if miConfig.Code == "H15049901371" {
  9938. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9939. utils.ErrorLog("解析失败:%v", err)
  9940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9941. return
  9942. }
  9943. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9944. res.Output = resSeven10265.Output
  9945. res.ErrMsg = resSeven10265.ErrMsg
  9946. res.Cainfo = resSeven10265.Cainfo
  9947. res.WarnMsg = resSeven10265.WarnMsg
  9948. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9949. res.Infcode = infocode
  9950. } else {
  9951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9952. utils.ErrorLog("解析失败:%v", err)
  9953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9954. return
  9955. }
  9956. }
  9957. }
  9958. if res.Infcode != 0 {
  9959. errlog := &models.HisOrderError{
  9960. UserOrgId: adminUser.CurrentOrgId,
  9961. Ctime: time.Now().Unix(),
  9962. Mtime: time.Now().Unix(),
  9963. Number: chrg_bchno,
  9964. ErrMsg: res.ErrMsg,
  9965. Status: 1,
  9966. PatientId: id,
  9967. RecordTime: recordDateTime,
  9968. Stage: 6,
  9969. }
  9970. service.CreateErrMsgLog(errlog)
  9971. c.ServeSuccessJSON(map[string]interface{}{
  9972. "failed_code": -10,
  9973. "msg": res.ErrMsg,
  9974. })
  9975. return
  9976. } else {
  9977. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9978. order.OrderStatus = 2
  9979. order.Status = 1
  9980. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9981. order.SetlId = res.Output.Setlinfo.SetlID
  9982. order.PsnNo = res.Output.Setlinfo.PsnNo
  9983. order.PsnName = res.Output.Setlinfo.PsnName
  9984. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9985. order.Certno = res.Output.Setlinfo.Certno
  9986. order.Gend = res.Output.Setlinfo.Gend
  9987. order.Naty = res.Output.Setlinfo.Naty
  9988. order.Age = res.Output.Setlinfo.Age
  9989. order.Insutype = res.Output.Setlinfo.Insutype
  9990. order.PsnType = res.Output.Setlinfo.PsnType
  9991. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9992. order.SetlTime = res.Output.Setlinfo.SetlTime
  9993. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9994. if res.Output.Setlinfo.MedType == "140101" {
  9995. order.MedType = "14"
  9996. } else {
  9997. order.MedType = res.Output.Setlinfo.MedType
  9998. }
  9999. if reg_type == 1112 {
  10000. order.MedType = "1112"
  10001. }
  10002. if reg_type == 1111 {
  10003. order.MedType = "1111"
  10004. }
  10005. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10006. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10007. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10008. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10009. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10010. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10011. order.HifpPay = res.Output.Setlinfo.HifpPay
  10012. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10013. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10014. order.HifesPay = res.Output.Setlinfo.HifesPay
  10015. order.HifobPay = res.Output.Setlinfo.HifobPay
  10016. order.MafPay = res.Output.Setlinfo.MafPay
  10017. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10018. order.OthPay = res.Output.Setlinfo.OthPay
  10019. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10020. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10021. order.AcctPay = res.Output.Setlinfo.AcctPay
  10022. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10023. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10024. order.Balc = res.Output.Setlinfo.Balc
  10025. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10026. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10027. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10028. order.ClrType = res.Output.Setlinfo.ClrType
  10029. order.ClrWay = res.Output.Setlinfo.ClrWay
  10030. order.Creator = order.Creator
  10031. order.Modify = roles.AdminUserId
  10032. order.RequestLog = src_resquest
  10033. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10034. detailStr := string(setlDetail)
  10035. order.SetlDetail = detailStr
  10036. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10037. err = service.UpDateOrder(order)
  10038. if err == nil {
  10039. //判断是否使用了押金
  10040. if dec_way == "true" {
  10041. tmpstring := strconv.FormatInt(order.ID, 10)
  10042. order.Decimal = decimal
  10043. service.UpDateOrder(order)
  10044. //扣押金
  10045. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10046. if errmsg != nil {
  10047. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10048. return
  10049. }
  10050. }
  10051. c.ServeSuccessJSON(map[string]interface{}{
  10052. "msg": "结算成功",
  10053. })
  10054. } else {
  10055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10056. return
  10057. }
  10058. }
  10059. } else {
  10060. adminUser := c.GetAdminUserInfo()
  10061. errlog := &models.HisOrderError{
  10062. UserOrgId: adminUser.CurrentOrgId,
  10063. Ctime: time.Now().Unix(),
  10064. Mtime: time.Now().Unix(),
  10065. ErrMsg: res.ErrMsg,
  10066. Status: 1,
  10067. PatientId: id,
  10068. RecordTime: recordDateTime,
  10069. Stage: 4,
  10070. }
  10071. service.CreateErrMsgLog(errlog)
  10072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10073. return
  10074. }
  10075. } else {
  10076. adminUser := c.GetAdminUserInfo()
  10077. errlog := &models.HisOrderError{
  10078. UserOrgId: adminUser.CurrentOrgId,
  10079. Ctime: time.Now().Unix(),
  10080. Mtime: time.Now().Unix(),
  10081. ErrMsg: res.ErrMsg,
  10082. Status: 1,
  10083. PatientId: id,
  10084. RecordTime: recordDateTime,
  10085. Stage: 4,
  10086. }
  10087. service.CreateErrMsgLog(errlog)
  10088. c.ServeSuccessJSON(map[string]interface{}{
  10089. "failed_code": -10,
  10090. "msg": res.ErrMsg,
  10091. })
  10092. return
  10093. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10094. //return
  10095. }
  10096. }
  10097. }
  10098. } else if tempOrder.ID > 0 {
  10099. if tempOrder.IsPre == 1 {
  10100. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  10101. var rf []*ResultFive
  10102. json.Unmarshal([]byte(his.Iinfo), &rf)
  10103. chrg_bchno := tempOrder.Number
  10104. cert_no := his.Certno
  10105. var insutypes []string
  10106. var insutype string
  10107. var is390 int = 0
  10108. var is310 int = 0
  10109. for _, item := range rf {
  10110. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10111. insutypes = append(insutypes, item.Insutype)
  10112. }
  10113. }
  10114. if len(insutypes) == 1 {
  10115. insutype = insutypes[0]
  10116. } else {
  10117. for _, i := range insutypes {
  10118. if i == "390" {
  10119. is390 = 1
  10120. }
  10121. if i == "310" {
  10122. is310 = 1
  10123. }
  10124. }
  10125. }
  10126. if is390 == 1 {
  10127. insutype = "390"
  10128. }
  10129. if is310 == 1 {
  10130. insutype = "310"
  10131. }
  10132. if len(insutypes) == 0 {
  10133. insutype = "310"
  10134. }
  10135. if len(insutypes) == 2 {
  10136. insutype = strconv.FormatInt(his.SocialType, 10)
  10137. }
  10138. //insutype = "390"
  10139. if his.IdCardType == 1 {
  10140. // cert_no = his.MedicalInsuranceNumber
  10141. cert_no = his.Certno
  10142. } else {
  10143. cert_no = his.Certno
  10144. }
  10145. var res ResultSeven
  10146. var resSeven10265 ResultSeven10265
  10147. var src_resquest string
  10148. var result2 string
  10149. if miConfig.MdtrtareaAdmvs == "421300" {
  10150. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10151. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10152. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10153. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10154. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10155. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10156. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10157. resp, requestErr := http.Get(api)
  10158. if requestErr != nil {
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. body, ioErr := ioutil.ReadAll(resp.Body)
  10163. if ioErr != nil {
  10164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10166. return
  10167. }
  10168. var respJSON map[string]interface{}
  10169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10172. return
  10173. }
  10174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10175. result, _ := json.Marshal(respJSON)
  10176. fmt.Println("log")
  10177. fmt.Println(string(result))
  10178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10179. utils.ErrorLog("解析失败:%v", err)
  10180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10181. return
  10182. }
  10183. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10184. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  10185. if result3101.Infcode == "0" {
  10186. if len(result3101.Output.Result) > 0 {
  10187. var errMsgs []string
  10188. for _, item := range result3101.Output.Result {
  10189. errMsgs = append(errMsgs, item.VolaCont)
  10190. }
  10191. c.ServeSuccessJSON(map[string]interface{}{
  10192. "failed_code": -10,
  10193. "msg": errMsgs,
  10194. })
  10195. return
  10196. } else {
  10197. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10198. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10199. bas := strings.Split(psn_info.CardInfo, "|")
  10200. if his.IdCardType == 1 {
  10201. cert_no = bas[2]
  10202. } else if his.IdCardType == 3 {
  10203. cert_no = his.Certno
  10204. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10205. } else if his.IdCardType == 4 {
  10206. cert_no = his.Certno
  10207. psn_info.VerifyNumber = psn_info.VerifyNumber
  10208. }
  10209. //江苏地区国家医保医疗类别
  10210. //职工透析:医疗类别选特殊情况门诊9933
  10211. //居民血透门慢: 医疗类别选门诊慢病1402
  10212. //var med_type string
  10213. //if his.Insutype == "310" {
  10214. // if reg_type == 14 {
  10215. // med_type = "9933"
  10216. // } else if reg_type == 11 {
  10217. // med_type = "11"
  10218. //
  10219. // }
  10220. //} else if his.Insutype == "390" {
  10221. // if reg_type == 14 {
  10222. // med_type = "1402"
  10223. // } else if reg_type == 11 {
  10224. // med_type = "11"
  10225. // }
  10226. //}
  10227. var api string
  10228. if miConfig.MdtrtareaAdmvs == "320921" {
  10229. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10230. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10231. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10232. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10233. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10234. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10235. "&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
  10236. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10237. } else {
  10238. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10239. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10240. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10241. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10242. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10243. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10244. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10245. "&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
  10246. }
  10247. resp, requestErr := http.Get(api)
  10248. if requestErr != nil {
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10250. return
  10251. }
  10252. body, ioErr := ioutil.ReadAll(resp.Body)
  10253. if ioErr != nil {
  10254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10256. return
  10257. }
  10258. var respJSON map[string]interface{}
  10259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10262. return
  10263. }
  10264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10265. result, _ := json.Marshal(respJSON)
  10266. fmt.Println("log")
  10267. fmt.Println(string(result))
  10268. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10269. utils.ErrorLog("解析失败:%v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10274. res.Output = resSeven10265.Output
  10275. res.ErrMsg = resSeven10265.ErrMsg
  10276. res.Cainfo = resSeven10265.Cainfo
  10277. res.WarnMsg = resSeven10265.WarnMsg
  10278. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10279. res.Infcode = infocode
  10280. }
  10281. }
  10282. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10283. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10284. var cert_no string
  10285. if his.IdCardType == 1 {
  10286. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10287. } else {
  10288. cert_no = psn_info.VerifyNumber
  10289. }
  10290. 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)
  10291. var dat map[string]interface{}
  10292. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10293. fmt.Println(dat)
  10294. } else {
  10295. fmt.Println(err)
  10296. }
  10297. saveLog(result2, src_resquest, "2207", "结算")
  10298. userJSONBytes, _ := json.Marshal(dat)
  10299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10300. utils.ErrorLog("解析失败:%v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10305. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10306. var cert_no string
  10307. if his.IdCardType == 1 {
  10308. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10309. } else if his.IdCardType == 2 {
  10310. cert_no = his.IdCardNo
  10311. } else {
  10312. cert_no = psn_info.VerifyNumber
  10313. }
  10314. 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, "")
  10315. var dat map[string]interface{}
  10316. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10317. fmt.Println(dat)
  10318. } else {
  10319. fmt.Println(err)
  10320. }
  10321. saveLog(result2, src_resquest, "2207", "结算")
  10322. userJSONBytes, _ := json.Marshal(dat)
  10323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10324. utils.ErrorLog("解析失败:%v", err)
  10325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10326. return
  10327. }
  10328. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10329. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10330. var cert_no string
  10331. if his.IdCardType == 1 {
  10332. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10333. } else if his.IdCardType == 2 {
  10334. cert_no = his.IdCardNo
  10335. } else {
  10336. cert_no = psn_info.VerifyNumber
  10337. }
  10338. 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, "")
  10339. var dat map[string]interface{}
  10340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10341. fmt.Println(dat)
  10342. } else {
  10343. fmt.Println(err)
  10344. }
  10345. saveLog(result2, src_resquest, "2207", "结算")
  10346. userJSONBytes, _ := json.Marshal(dat)
  10347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10348. utils.ErrorLog("解析失败:%v", err)
  10349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10350. return
  10351. }
  10352. } else {
  10353. var src_resquest string
  10354. if miConfig.Code == "H15049901371" {
  10355. //赤峰地区国家医保医疗类别
  10356. //职工透析:医疗类别选特殊情况门诊990502
  10357. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10358. var med_type string
  10359. if his.Insutype == "390" {
  10360. if reg_type == 14 {
  10361. med_type = "9933"
  10362. } else if reg_type == 11 {
  10363. med_type = "11"
  10364. }
  10365. } else if his.Insutype == "310" {
  10366. if reg_type == 14 {
  10367. med_type = "990502"
  10368. } else if reg_type == 11 {
  10369. med_type = "11"
  10370. }
  10371. }
  10372. 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, "")
  10373. } else {
  10374. if his.IdCardType == 4 {
  10375. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10376. token := psn_info.VerifyNumber
  10377. 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)
  10378. } else {
  10379. 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, "")
  10380. }
  10381. }
  10382. var dat map[string]interface{}
  10383. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10384. fmt.Println(dat)
  10385. } else {
  10386. fmt.Println(err)
  10387. }
  10388. saveLog(result2, src_resquest, "2207", "结算")
  10389. userJSONBytes, _ := json.Marshal(dat)
  10390. if miConfig.Code == "H15049901371" {
  10391. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10392. utils.ErrorLog("解析失败:%v", err)
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10394. return
  10395. }
  10396. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10397. res.Output = resSeven10265.Output
  10398. res.ErrMsg = resSeven10265.ErrMsg
  10399. res.Cainfo = resSeven10265.Cainfo
  10400. res.WarnMsg = resSeven10265.WarnMsg
  10401. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10402. res.Infcode = infocode
  10403. } else {
  10404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10405. utils.ErrorLog("解析失败:%v", err)
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10407. return
  10408. }
  10409. }
  10410. }
  10411. if res.Infcode != 0 {
  10412. errlog := &models.HisOrderError{
  10413. UserOrgId: adminUser.CurrentOrgId,
  10414. Ctime: time.Now().Unix(),
  10415. Mtime: time.Now().Unix(),
  10416. Number: chrg_bchno,
  10417. ErrMsg: res.ErrMsg,
  10418. Status: 1,
  10419. PatientId: id,
  10420. RecordTime: recordDateTime,
  10421. Stage: 6,
  10422. }
  10423. service.CreateErrMsgLog(errlog)
  10424. c.ServeSuccessJSON(map[string]interface{}{
  10425. "failed_code": -10,
  10426. "msg": res.ErrMsg,
  10427. })
  10428. return
  10429. } else {
  10430. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10431. order.OrderStatus = 2
  10432. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10433. order.SetlId = res.Output.Setlinfo.SetlID
  10434. order.PsnNo = res.Output.Setlinfo.PsnNo
  10435. order.PsnName = res.Output.Setlinfo.PsnName
  10436. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10437. order.Certno = res.Output.Setlinfo.Certno
  10438. order.Gend = res.Output.Setlinfo.Gend
  10439. order.Naty = res.Output.Setlinfo.Naty
  10440. order.Age = res.Output.Setlinfo.Age
  10441. order.Insutype = res.Output.Setlinfo.Insutype
  10442. order.PsnType = res.Output.Setlinfo.PsnType
  10443. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10444. order.SetlTime = res.Output.Setlinfo.SetlTime
  10445. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10446. order.PayWays = pay_ways
  10447. order.AcctUsedFlag = acct_used_flag
  10448. order.WechatPay = wechat_pay
  10449. order.AliPay = ali_pay
  10450. order.JifenPay = jifen_pay
  10451. order.BandCardPay = band_card_pay
  10452. order.CashPay = cash_pay
  10453. order.OthDesc = oth_desc
  10454. //order.MedType = res.Output.Setlinfo.MedType
  10455. if reg_type == 1112 {
  10456. order.MedType = "1112"
  10457. }
  10458. if reg_type == 1111 {
  10459. order.MedType = "1111"
  10460. }
  10461. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10462. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10463. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10464. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10465. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10466. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10467. order.HifpPay = res.Output.Setlinfo.HifpPay
  10468. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10469. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10470. order.HifesPay = res.Output.Setlinfo.HifesPay
  10471. order.HifobPay = res.Output.Setlinfo.HifobPay
  10472. order.MafPay = res.Output.Setlinfo.MafPay
  10473. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10474. order.OthPay = res.Output.Setlinfo.OthPay
  10475. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10476. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10477. order.AcctPay = res.Output.Setlinfo.AcctPay
  10478. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10479. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10480. order.Balc = res.Output.Setlinfo.Balc
  10481. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10482. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10483. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10484. order.ClrWay = res.Output.Setlinfo.ClrWay
  10485. order.Creator = order.Creator
  10486. order.Modify = roles.AdminUserId
  10487. order.RequestLog = src_resquest
  10488. order.Diagnosis = diagnosis_id
  10489. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10490. detailStr := string(setlDetail)
  10491. order.SetlDetail = detailStr
  10492. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10493. err = service.UpDateOrder(order)
  10494. if err == nil {
  10495. //判断是否使用了押金
  10496. if dec_way == "true" {
  10497. tmpstring := strconv.FormatInt(order.ID, 10)
  10498. //扣押金
  10499. order.Decimal = decimal
  10500. service.UpDateOrder(order)
  10501. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10502. if errmsg != nil {
  10503. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10504. return
  10505. }
  10506. }
  10507. c.ServeSuccessJSON(map[string]interface{}{
  10508. "msg": "结算成功",
  10509. })
  10510. } else {
  10511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10512. return
  10513. }
  10514. }
  10515. }
  10516. }
  10517. }
  10518. //func (c *HisApiController) GetPreUploadInfo() {
  10519. // id, _ := c.GetInt64("id")
  10520. // record_time := c.GetString("record_time")
  10521. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10522. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10523. //
  10524. // timeLayout := "2006-01-02"
  10525. // loc, _ := time.LoadLocation("Local")
  10526. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10527. // if err != nil {
  10528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10529. // return
  10530. // }
  10531. // recordDateTime := theTime.Unix()
  10532. // adminUser := c.GetAdminUserInfo()
  10533. //
  10534. // var prescriptions []*models.HisPrescription
  10535. //
  10536. // var start_time int64
  10537. // var end_time int64
  10538. //
  10539. // data := make(map[string]interface{})
  10540. // if settle_accounts_type == 1 { //日结
  10541. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10542. // data["pre"] = prescriptions
  10543. //
  10544. // } else { //月结
  10545. // start_time_str := c.GetString("start_time")
  10546. // end_time_str := c.GetString("end_time")
  10547. // timeLayout := "2006-01-02"
  10548. // loc, _ := time.LoadLocation("Local")
  10549. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10550. // if err != nil {
  10551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10552. // return
  10553. // }
  10554. // recordStartTime := theStartTime.Unix()
  10555. // start_time = recordStartTime
  10556. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10557. // if err != nil {
  10558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10559. // return
  10560. // }
  10561. // recordEndTime := theEndTime.Unix()
  10562. // end_time = recordEndTime
  10563. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10564. // data["pre"] = prescriptions
  10565. //
  10566. // }
  10567. //
  10568. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10569. //
  10570. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10571. // timestamp := time.Now().Unix()
  10572. // tempTime := time.Unix(timestamp, 0)
  10573. // timeFormat := tempTime.Format("20060102150405")
  10574. // chrgBchno := rand.Intn(100000) + 10000
  10575. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10576. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10577. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10578. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10579. // strconv.FormatInt(his.PatientId, 10)
  10580. // client := &http.Client{}
  10581. // data["psn_no"] = his.PsnNo
  10582. // data["mdtrt_id"] = his.Number
  10583. // data["chrg_bchno"] = chrg_bchno
  10584. // data["org_name"] = miConfig.OrgName
  10585. // data["doctor"] = roles.UserName
  10586. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10587. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10588. // data["fixmedins_code"] = miConfig.Code
  10589. // data["dept_code"] = department.Number
  10590. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10591. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10592. // data["secret_key"] = miConfig.SecretKey
  10593. // var ids []int64
  10594. //
  10595. // for _, item := range prescriptions {
  10596. // ids = append(ids, item.ID)
  10597. // }
  10598. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10599. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10600. // bytesData, _ := json.Marshal(data)
  10601. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10602. // resp, _ := client.Do(req)
  10603. // defer resp.Body.Close()
  10604. // body, ioErr := ioutil.ReadAll(resp.Body)
  10605. // if ioErr != nil {
  10606. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10608. // return
  10609. // }
  10610. // var respJSON map[string]interface{}
  10611. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10612. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10614. // return
  10615. // }
  10616. //
  10617. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10618. // userJSONBytes, _ := json.Marshal(respJSON)
  10619. // var res ResultFour
  10620. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10621. // utils.ErrorLog("解析失败:%v", err)
  10622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10623. // return
  10624. // }
  10625. //
  10626. // if res.Infcode == 0 {
  10627. // order := &models.HisOrder{
  10628. // UserOrgId: adminUser.CurrentOrgId,
  10629. // HisPatientId: his.ID,
  10630. // PatientId: his.PatientId,
  10631. // SettleAccountsDate: recordDateTime,
  10632. // Ctime: time.Now().Unix(),
  10633. // Mtime: time.Now().Unix(),
  10634. // Status: 1,
  10635. // Number: chrg_bchno,
  10636. // Infcode: res.Infcode,
  10637. // WarnMsg: res.WarnMsg,
  10638. // Cainfo: res.Cainfo,
  10639. // ErrMsg: res.ErrMsg,
  10640. // RespondTime: res.RefmsgTime,
  10641. // InfRefmsgid: res.InfRefmsgid,
  10642. // OrderStatus: 1,
  10643. // IsMedicineInsurance: 1,
  10644. // SettleType: settle_accounts_type,
  10645. // SettleStartTime: start_time,
  10646. // SettleEndTime: end_time,
  10647. // Creator: roles.ID,
  10648. // Modify: roles.ID,
  10649. // PType: 2,
  10650. // }
  10651. // err = service.CreateOrder(order)
  10652. // if err != nil {
  10653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10654. // return
  10655. // }
  10656. //
  10657. // for _, item := range res.Output.Result {
  10658. // temp := strings.Split(item.FeedetlSn, "-")
  10659. // var advice_id int64 = 0
  10660. // var project_id int64 = 0
  10661. // var types int64 = 0
  10662. //
  10663. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  10664. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  10665. //
  10666. // if temp[1] == "1" {
  10667. // advice_id = id
  10668. // project_id = 0
  10669. // } else if temp[1] == "2" {
  10670. // advice_id = 0
  10671. // project_id = id
  10672. // }
  10673. //
  10674. // info := &models.HisOrderInfo{
  10675. // OrderNumber: order.Number,
  10676. // FeedetlSn: item.FeedetlSn,
  10677. // UploadDate: time.Now().Unix(),
  10678. // AdviceId: advice_id,
  10679. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  10680. // Cnt: item.Cnt,
  10681. // Pric: float64(item.Pric),
  10682. // PatientId: his.PatientId,
  10683. // PricUplmtAmt: item.PricUplmtAmt,
  10684. // SelfpayProp: item.SelfpayProp,
  10685. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10686. // OverlmtAmt: item.OverlmtAmt,
  10687. // PreselfpayAmt: item.PreselfpayAmt,
  10688. // BasMednFlag: item.BasMednFlag,
  10689. // MedChrgitmType: item.MedChrgitmType,
  10690. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  10691. // Status: 1,
  10692. // Memo: item.Memo,
  10693. // Mtime: time.Now().Unix(),
  10694. // InscpScpAmt: item.InscpScpAmt,
  10695. // DrtReimFlag: item.DrtReimFlag,
  10696. // Ctime: time.Now().Unix(),
  10697. // ListSpItemFlag: item.ListSpItemFlag,
  10698. // ChldMedcFlag: item.ChldMedcFlag,
  10699. // LmtUsedFlag: item.LmtUsedFlag,
  10700. // ChrgitmLv: item.ChrgitmLv,
  10701. // UserOrgId: adminUser.CurrentOrgId,
  10702. // HisPatientId: his.ID,
  10703. // OrderId: order.ID,
  10704. // ProjectId: project_id,
  10705. // Type: types,
  10706. // }
  10707. // service.CreateOrderInfo(info)
  10708. //
  10709. // }
  10710. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10711. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  10712. //
  10713. // var total float64
  10714. // for _, item := range prescriptions {
  10715. // if item.Type == 1 { //药品
  10716. // for _, subItem := range item.HisDoctorAdviceInfo {
  10717. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10718. // }
  10719. // }
  10720. // if item.Type == 2 { //项目
  10721. // for _, subItem := range item.HisPrescriptionProject {
  10722. // total = total + (subItem.Price * float64(subItem.Count))
  10723. // }
  10724. // }
  10725. // }
  10726. //
  10727. // for _, item := range prescriptions {
  10728. // for _, subItem := range item.HisAdditionalCharge {
  10729. // total = total + (subItem.Price * float64(subItem.Count))
  10730. // }
  10731. // }
  10732. //
  10733. // allTotal := fmt.Sprintf("%.2f", total)
  10734. // if res.Infcode == 0 {
  10735. // var rf []*ResultFive
  10736. // json.Unmarshal([]byte(his.Iinfo), &rf)
  10737. // psn_no := his.PsnNo
  10738. // mdtrt_id := his.Number
  10739. // chrg_bchno := chrg_bchno
  10740. // cert_no := his.Certno
  10741. // insutype := rf[0].Insutype
  10742. //
  10743. // if his.IdCardType == 1 {
  10744. // cert_no = his.MedicalInsuranceNumber
  10745. //
  10746. // } else {
  10747. //
  10748. // cert_no = his.Certno
  10749. //
  10750. // }
  10751. //
  10752. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  10753. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  10754. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  10755. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  10756. // resp, requestErr := http.Get(api)
  10757. // if requestErr != nil {
  10758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10759. // return
  10760. // }
  10761. // defer resp.Body.Close()
  10762. // body, ioErr := ioutil.ReadAll(resp.Body)
  10763. // if ioErr != nil {
  10764. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10766. // return
  10767. // }
  10768. // var respJSON map[string]interface{}
  10769. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10770. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. // return
  10773. // }
  10774. // fmt.Println(respJSON)
  10775. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10776. // userJSONBytes, _ := json.Marshal(respJSON)
  10777. // var res ResultSeven
  10778. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10779. // utils.ErrorLog("解析失败:%v", err)
  10780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10781. // return
  10782. // }
  10783. // if res.Infcode != 0 {
  10784. // errlog := &models.HisOrderError{
  10785. // UserOrgId: adminUser.CurrentOrgId,
  10786. // Ctime: time.Now().Unix(),
  10787. // Mtime: time.Now().Unix(),
  10788. // Number: chrg_bchno,
  10789. // ErrMsg: res.ErrMsg,
  10790. // Status: 1,
  10791. // PatientId: id,
  10792. // RecordTime: recordDateTime,
  10793. // Stage: 7,
  10794. // }
  10795. // service.CreateErrMsgLog(errlog)
  10796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10797. // return
  10798. // } else {
  10799. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10800. // order.OrderStatus = 1
  10801. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10802. // order.SetlId = res.Output.Setlinfo.SetlID
  10803. // order.PsnNo = res.Output.Setlinfo.PsnNo
  10804. // order.PsnName = res.Output.Setlinfo.PsnName
  10805. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10806. // order.Certno = res.Output.Setlinfo.Certno
  10807. // order.Gend = res.Output.Setlinfo.Gend
  10808. // order.Naty = res.Output.Setlinfo.Naty
  10809. // order.Age = res.Output.Setlinfo.Age
  10810. // order.Insutype = res.Output.Setlinfo.Insutype
  10811. // order.PsnType = res.Output.Setlinfo.PsnType
  10812. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10813. // order.SetlTime = res.Output.Setlinfo.SetlTime
  10814. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10815. // order.MedType = res.Output.Setlinfo.MedType
  10816. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10817. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10818. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10819. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10820. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10821. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10822. // order.HifpPay = res.Output.Setlinfo.HifpPay
  10823. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10824. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10825. // order.HifesPay = res.Output.Setlinfo.HifesPay
  10826. // order.HifobPay = res.Output.Setlinfo.HifobPay
  10827. // order.MafPay = res.Output.Setlinfo.MafPay
  10828. // order.OthPay = res.Output.Setlinfo.OthPay
  10829. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10830. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10831. // order.AcctPay = res.Output.Setlinfo.AcctPay
  10832. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10833. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10834. // order.Balc = res.Output.Setlinfo.Balc
  10835. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10836. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10837. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10838. // order.ClrWay = res.Output.Setlinfo.ClrWay
  10839. // order.Creator = order.Creator
  10840. // order.Modify = roles.ID
  10841. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10842. // detailStr := string(setlDetail)
  10843. // order.SetlDetail = detailStr
  10844. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10845. // err = service.UpDateOrder(order)
  10846. // if err == nil {
  10847. // c.ServeSuccessJSON(map[string]interface{}{
  10848. // "msg": "预结算成功",
  10849. // })
  10850. // } else {
  10851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10852. // return
  10853. // }
  10854. // }
  10855. // } else {
  10856. // adminUser := c.GetAdminUserInfo()
  10857. // errlog := &models.HisOrderError{
  10858. // UserOrgId: adminUser.CurrentOrgId,
  10859. // Ctime: time.Now().Unix(),
  10860. // Mtime: time.Now().Unix(),
  10861. // ErrMsg: res.ErrMsg,
  10862. // Status: 1,
  10863. // PatientId: id,
  10864. // RecordTime: recordDateTime,
  10865. // Stage: 4,
  10866. // }
  10867. // service.CreateErrMsgLog(errlog)
  10868. //
  10869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10870. // return
  10871. // }
  10872. // } else {
  10873. // adminUser := c.GetAdminUserInfo()
  10874. // errlog := &models.HisOrderError{
  10875. // UserOrgId: adminUser.CurrentOrgId,
  10876. // Ctime: time.Now().Unix(),
  10877. // Mtime: time.Now().Unix(),
  10878. // ErrMsg: res.ErrMsg,
  10879. // Status: 1,
  10880. // PatientId: id,
  10881. // RecordTime: recordDateTime,
  10882. // Stage: 4,
  10883. // }
  10884. // service.CreateErrMsgLog(errlog)
  10885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10886. // return
  10887. // }
  10888. //
  10889. // } else {
  10890. // var total float64
  10891. // for _, item := range prescriptions {
  10892. // if item.Type == 1 { //药品
  10893. // for _, subItem := range item.HisDoctorAdviceInfo {
  10894. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10895. // }
  10896. // }
  10897. // if item.Type == 2 { //项目
  10898. // for _, subItem := range item.HisPrescriptionProject {
  10899. // total = total + (subItem.Price * float64(subItem.Count))
  10900. // }
  10901. // }
  10902. //
  10903. // for _, subItem := range item.HisAdditionalCharge {
  10904. // total = total + (subItem.Price * float64(subItem.Count))
  10905. // }
  10906. // }
  10907. //
  10908. // allTotal := fmt.Sprintf("%.2f", total)
  10909. // totals, _ := strconv.ParseFloat(allTotal, 64)
  10910. // order := &models.HisOrder{
  10911. // UserOrgId: adminUser.CurrentOrgId,
  10912. // HisPatientId: his.ID,
  10913. // PatientId: id,
  10914. // SettleAccountsDate: recordDateTime,
  10915. // Ctime: time.Now().Unix(),
  10916. // Mtime: time.Now().Unix(),
  10917. // Status: 1,
  10918. // OrderStatus: 2,
  10919. // Number: chrg_bchno,
  10920. // MedfeeSumamt: totals,
  10921. // }
  10922. // err = service.CreateOrder(order)
  10923. // if err != nil {
  10924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10925. // return
  10926. // }
  10927. //
  10928. // var customs []*Custom
  10929. // for _, item := range prescriptions {
  10930. //
  10931. // if item.Type == 1 { //药品
  10932. // for _, subItem := range item.HisDoctorAdviceInfo {
  10933. // cus := &Custom{
  10934. // AdviceId: subItem.ID,
  10935. // ProjectId: 0,
  10936. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  10937. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  10938. // FeedetlSn: subItem.FeedetlSn,
  10939. // Price: fmt.Sprintf("%.2f", subItem.Price),
  10940. // MedListCodg: subItem.MedListCodg,
  10941. // Type: 1,
  10942. // }
  10943. // customs = append(customs, cus)
  10944. // }
  10945. // }
  10946. //
  10947. // if item.Type == 2 { //项目
  10948. // for _, subItem := range item.HisPrescriptionProject {
  10949. //
  10950. // cus := &Custom{
  10951. // AdviceId: 0,
  10952. // ProjectId: subItem.ID,
  10953. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  10954. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  10955. // FeedetlSn: subItem.FeedetlSn,
  10956. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  10957. // MedListCodg: subItem.MedListCodg,
  10958. // Type: 2,
  10959. // }
  10960. //
  10961. // customs = append(customs, cus)
  10962. // }
  10963. // }
  10964. //
  10965. // for _, item := range item.HisAdditionalCharge {
  10966. // cus := &Custom{
  10967. // ItemId: item.ID,
  10968. // AdviceId: 0,
  10969. // ProjectId: 0,
  10970. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  10971. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  10972. // FeedetlSn: item.FeedetlSn,
  10973. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  10974. // MedListCodg: item.XtHisAddtionConfig.Code,
  10975. // Type: 3,
  10976. // }
  10977. //
  10978. // customs = append(customs, cus)
  10979. // }
  10980. //
  10981. // }
  10982. //
  10983. // for _, item := range customs {
  10984. // var advice_id int64 = 0
  10985. // var project_id int64 = 0
  10986. // var item_id int64 = 0
  10987. //
  10988. // var types int64 = 0
  10989. //
  10990. // if item.Type == 1 {
  10991. // advice_id = item.AdviceId
  10992. // project_id = 0
  10993. // item_id = 0
  10994. // } else if item.Type == 2 {
  10995. // advice_id = 0
  10996. // item_id = 0
  10997. //
  10998. // project_id = item.ProjectId
  10999. // } else if item.Type == 3 {
  11000. // advice_id = 0
  11001. // item_id = item.ItemId
  11002. // project_id = 0
  11003. // }
  11004. //
  11005. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  11006. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  11007. // pric, _ := strconv.ParseFloat(item.Price, 32)
  11008. //
  11009. // info := &models.HisOrderInfo{
  11010. // OrderNumber: order.Number,
  11011. // UploadDate: time.Now().Unix(),
  11012. // AdviceId: advice_id,
  11013. // DetItemFeeSumamt: detItemFeeSumamt,
  11014. // Cnt: cut,
  11015. // Pric: pric,
  11016. // PatientId: id,
  11017. // Status: 1,
  11018. // Mtime: time.Now().Unix(),
  11019. // Ctime: time.Now().Unix(),
  11020. // UserOrgId: adminUser.CurrentOrgId,
  11021. // HisPatientId: his.ID,
  11022. // OrderId: order.ID,
  11023. // ProjectId: project_id,
  11024. // Type: types,
  11025. // ItemId: item_id,
  11026. // }
  11027. // service.CreateOrderInfo(info)
  11028. // }
  11029. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11030. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11031. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  11032. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11033. // if err == nil {
  11034. // c.ServeSuccessJSON(map[string]interface{}{
  11035. // "msg": "结算成功",
  11036. // })
  11037. // } else {
  11038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11039. // return
  11040. // }
  11041. // }
  11042. //}
  11043. // 上传明细-预结算-
  11044. func (c *HisApiController) GetPreUploadInfo() {
  11045. id, _ := c.GetInt64("id")
  11046. record_time := c.GetString("record_time")
  11047. his_patient_id, _ := c.GetInt64("his_patient_id")
  11048. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11049. admin_user_id, _ := c.GetInt64("admin_user_id")
  11050. diagnosis_id := c.GetString("diagnosis")
  11051. sick_type, _ := c.GetInt64("sick_type")
  11052. reg_type, _ := c.GetInt64("p_type")
  11053. begin_time := c.GetString("begin_time")
  11054. acct_used_flag := c.GetString("acct_used_flag")
  11055. id_str := c.GetString("ids")
  11056. ids_arr := strings.Split(id_str, ",")
  11057. timeLayout := "2006-01-02"
  11058. loc, _ := time.LoadLocation("Local")
  11059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11060. if err != nil {
  11061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11062. return
  11063. }
  11064. recordDateTime := theTime.Unix()
  11065. adminUser := c.GetAdminUserInfo()
  11066. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11067. var config []*models.HisXtDiagnoseConfig
  11068. for _, item := range diagnosis_ids {
  11069. id, _ := strconv.ParseInt(item, 10, 64)
  11070. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11071. config = append(config, &diagnosisConfig)
  11072. }
  11073. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  11074. sickConfig, _ := service.FindSickById(sick_type)
  11075. var prescriptions []*models.HisPrescription
  11076. var start_time int64
  11077. var end_time int64
  11078. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11079. fmt.Println(his_patient_id)
  11080. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11081. timestamp := time.Now().Unix()
  11082. tempTime := time.Unix(timestamp, 0)
  11083. timeFormat := tempTime.Format("20060102150405")
  11084. chrgBchno := rand.Intn(100000) + 10000
  11085. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11086. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11087. var patientPrescription models.HisPrescriptionInfo
  11088. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11089. if patientPrescription.ID == 0 {
  11090. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11091. }
  11092. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11093. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11094. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11095. strconv.FormatInt(his.PatientId, 10)
  11096. var res2 ResultSix
  11097. var resSix10265 ResultSix10265
  11098. //var time_stamp string
  11099. if miConfig.MdtrtareaAdmvs == "421300" {
  11100. data := make(map[string]interface{})
  11101. client := &http.Client{}
  11102. data["psn_no"] = his.PsnNo
  11103. data["mdtrt_id"] = his.Number
  11104. data["department"] = department.Name
  11105. data["org_name"] = miConfig.OrgName
  11106. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11107. data["doctor_id"] = doctor_info.DoctorNumber
  11108. data["doctor_name"] = roles.UserName
  11109. data["fixmedins_code"] = miConfig.Code
  11110. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11111. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11112. data["secret_key"] = miConfig.SecretKey
  11113. data["sick_code"] = sickConfig.CountryCode
  11114. data["sick_name"] = sickConfig.ClassName
  11115. data["begin_time"] = begin_time
  11116. data["dept"] = strconv.FormatInt(department.ID, 10)
  11117. data["config"] = config
  11118. data["opter"] = roles.UserName
  11119. fmt.Println(data)
  11120. bytesData, _ := json.Marshal(data)
  11121. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11122. resp, _ := client.Do(req)
  11123. defer resp.Body.Close()
  11124. body, ioErr := ioutil.ReadAll(resp.Body)
  11125. if ioErr != nil {
  11126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11128. return
  11129. }
  11130. var respJSON map[string]interface{}
  11131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11134. return
  11135. }
  11136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11137. userJSONBytes, _ := json.Marshal(respJSON)
  11138. fmt.Println("log")
  11139. fmt.Println(string(userJSONBytes))
  11140. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11141. utils.ErrorLog("解析失败:%v", err)
  11142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11143. return
  11144. }
  11145. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11146. data := make(map[string]interface{})
  11147. client := &http.Client{}
  11148. data["psn_no"] = his.PsnNo
  11149. data["mdtrt_id"] = his.Number
  11150. data["doctor"] = roles.UserName
  11151. data["department"] = department.Name
  11152. data["org_name"] = miConfig.OrgName
  11153. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11154. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  11155. data["fixmedins_code"] = miConfig.Code
  11156. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11158. data["secret_key"] = miConfig.SecretKey
  11159. data["sick_code"] = sickConfig.CountryCode
  11160. data["sick_name"] = sickConfig.ClassName
  11161. data["begin_time"] = begin_time
  11162. data["dept"] = strconv.FormatInt(department.ID, 10)
  11163. data["config"] = config
  11164. data["url"] = miConfig.Url
  11165. data["ak"] = miConfig.AccessKey
  11166. data["cainfo"] = miConfig.Cainfo
  11167. bytesData, _ := json.Marshal(data)
  11168. var req *http.Request
  11169. if miConfig.MdtrtareaAdmvs == "320921" {
  11170. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11171. } else {
  11172. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11173. }
  11174. resp, _ := client.Do(req)
  11175. defer resp.Body.Close()
  11176. body, ioErr := ioutil.ReadAll(resp.Body)
  11177. if ioErr != nil {
  11178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11180. return
  11181. }
  11182. var respJSON map[string]interface{}
  11183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11186. return
  11187. }
  11188. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  11189. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  11190. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  11191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11192. userJSONBytes, _ := json.Marshal(respJSON)
  11193. fmt.Println("log")
  11194. fmt.Println(string(userJSONBytes))
  11195. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11196. utils.ErrorLog("解析失败:%v", err)
  11197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11198. return
  11199. }
  11200. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11201. res2.Output = resSix10265.Output
  11202. res2.ErrMsg = resSix10265.ErrMsg
  11203. res2.Cainfo = resSix10265.Cainfo
  11204. res2.WarnMsg = resSix10265.WarnMsg
  11205. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11206. res2.Infcode = infocode
  11207. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11208. 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)
  11209. saveLog(result, requestLog, "2203", "上传就诊信息")
  11210. var respJSON2 map[string]interface{}
  11211. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11214. return
  11215. }
  11216. userJSONBytes2, _ := json.Marshal(respJSON2)
  11217. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11218. utils.ErrorLog("解析失败:%v", err)
  11219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11220. return
  11221. }
  11222. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11223. var result string
  11224. var requestLog string
  11225. 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, "")
  11226. saveLog(result, requestLog, "2203", "上传就诊信息")
  11227. var respJSON2 map[string]interface{}
  11228. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11231. return
  11232. }
  11233. userJSONBytes2, _ := json.Marshal(respJSON2)
  11234. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11235. utils.ErrorLog("解析失败:%v", err)
  11236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11237. return
  11238. }
  11239. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11240. var result string
  11241. var requestLog string
  11242. 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, "")
  11243. saveLog(result, requestLog, "2203", "上传就诊信息")
  11244. var respJSON2 map[string]interface{}
  11245. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11248. return
  11249. }
  11250. userJSONBytes2, _ := json.Marshal(respJSON2)
  11251. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11252. utils.ErrorLog("解析失败:%v", err)
  11253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11254. return
  11255. }
  11256. } else {
  11257. var result string
  11258. var requestLog string
  11259. if miConfig.MdtrtareaAdmvs == "440781" { //
  11260. 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)
  11261. } else {
  11262. if miConfig.Code == "H15049901371" {
  11263. //赤峰地区国家医保医疗类别
  11264. //职工透析:医疗类别选特殊情况门诊990502
  11265. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11266. var med_type string
  11267. if his.Insutype == "390" {
  11268. if reg_type == 14 {
  11269. med_type = "9933"
  11270. } else if reg_type == 11 {
  11271. med_type = "11"
  11272. }
  11273. } else if his.Insutype == "310" {
  11274. if reg_type == 14 {
  11275. med_type = "990502"
  11276. } else if reg_type == 11 {
  11277. med_type = "11"
  11278. }
  11279. }
  11280. 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)
  11281. } else {
  11282. 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)
  11283. }
  11284. saveLog(result, requestLog, "2203", "上传就诊信息")
  11285. var respJSON2 map[string]interface{}
  11286. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11289. return
  11290. }
  11291. userJSONBytes2, _ := json.Marshal(respJSON2)
  11292. if miConfig.Code == "H15049901371" {
  11293. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  11294. utils.ErrorLog("解析失败:%v", err)
  11295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11296. return
  11297. }
  11298. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11299. res2.Output = resSix10265.Output
  11300. res2.ErrMsg = resSix10265.ErrMsg
  11301. res2.Cainfo = resSix10265.Cainfo
  11302. res2.WarnMsg = resSix10265.WarnMsg
  11303. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11304. res2.Infcode = infocode
  11305. } else {
  11306. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11307. utils.ErrorLog("解析失败:%v", err)
  11308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11309. return
  11310. }
  11311. }
  11312. }
  11313. }
  11314. if res2.Infcode != 0 {
  11315. adminUser := c.GetAdminUserInfo()
  11316. errlog := &models.HisOrderError{
  11317. UserOrgId: adminUser.CurrentOrgId,
  11318. Ctime: time.Now().Unix(),
  11319. Mtime: time.Now().Unix(),
  11320. ErrMsg: res2.ErrMsg,
  11321. Status: 1,
  11322. PatientId: id,
  11323. RecordTime: recordDateTime,
  11324. Stage: 3,
  11325. }
  11326. service.CreateErrMsgLog(errlog)
  11327. c.ServeSuccessJSON(map[string]interface{}{
  11328. "failed_code": -10,
  11329. "msg": res2.ErrMsg,
  11330. })
  11331. return
  11332. } else {
  11333. his.Diagnosis = diagnosis_id
  11334. his.SickType = sickConfig.ID
  11335. his.PType = fmt.Sprintf("%d", reg_type)
  11336. service.UpdateHisPatientThree(&his)
  11337. data := make(map[string]interface{})
  11338. if settle_accounts_type == 1 { //日结
  11339. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11340. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11341. } else {
  11342. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11343. }
  11344. data["pre"] = prescriptions
  11345. } else { //月结
  11346. start_time_str := c.GetString("start_time")
  11347. end_time_str := c.GetString("end_time")
  11348. timeLayout := "2006-01-02"
  11349. loc, _ := time.LoadLocation("Local")
  11350. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11351. if err != nil {
  11352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11353. return
  11354. }
  11355. recordStartTime := theStartTime.Unix()
  11356. start_time = recordStartTime
  11357. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11358. if err != nil {
  11359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11360. return
  11361. }
  11362. recordEndTime := theEndTime.Unix()
  11363. end_time = recordEndTime
  11364. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11365. data["pre"] = prescriptions
  11366. }
  11367. client := &http.Client{}
  11368. data["psn_no"] = his.PsnNo
  11369. data["mdtrt_id"] = his.Number
  11370. data["chrg_bchno"] = chrg_bchno
  11371. data["org_name"] = miConfig.OrgName
  11372. data["doctor"] = doctor_info.UserName
  11373. data["doctor_id"] = doctor_info.DoctorNumber
  11374. data["dept"] = department.Name
  11375. data["fixmedins_code"] = miConfig.Code
  11376. data["opter"] = roles.UserName
  11377. data["dept_code"] = department.Number
  11378. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11379. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11380. data["secret_key"] = miConfig.SecretKey
  11381. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11382. data["url"] = miConfig.Url
  11383. data["ak"] = miConfig.AccessKey
  11384. data["new_doctor_name"] = patientPrescription.Doctor
  11385. data["diag_code"] = sickConfig.CountryCode
  11386. data["cainfo"] = miConfig.Cainfo
  11387. data["opter"] = roles.UserName
  11388. var ids []int64
  11389. for _, item := range prescriptions {
  11390. ids = append(ids, item.ID)
  11391. }
  11392. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11393. if config.IsOpen == 1 { //对接了医保,走医保流程
  11394. var res ResultFour
  11395. var resFour10265 ResultFour10265
  11396. if miConfig.MdtrtareaAdmvs == "421300" {
  11397. bytesData, _ := json.Marshal(data)
  11398. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11399. resp, _ := client.Do(req)
  11400. defer resp.Body.Close()
  11401. body, ioErr := ioutil.ReadAll(resp.Body)
  11402. if ioErr != nil {
  11403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11405. return
  11406. }
  11407. var respJSON map[string]interface{}
  11408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return
  11412. }
  11413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11414. userJSONBytes, _ := json.Marshal(respJSON)
  11415. fmt.Println("log")
  11416. fmt.Println(string(userJSONBytes))
  11417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11418. utils.ErrorLog("解析失败:%v", err)
  11419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11420. return
  11421. }
  11422. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11423. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11424. if result3101.Infcode == "0" {
  11425. if len(result3101.Output.Result) > 0 {
  11426. var errMsgs []string
  11427. for _, item := range result3101.Output.Result {
  11428. errMsgs = append(errMsgs, item.VolaCont)
  11429. }
  11430. c.ServeSuccessJSON(map[string]interface{}{
  11431. "failed_code": -10,
  11432. "msg": errMsgs,
  11433. })
  11434. return
  11435. } else {
  11436. if miConfig.MdtrtareaAdmvs == "320921" {
  11437. data["doctor_id"] = "D320923012139"
  11438. } else {
  11439. data["doctor_id"] = "D371621008686"
  11440. }
  11441. bytesData, _ := json.Marshal(data)
  11442. var req *http.Request
  11443. if miConfig.MdtrtareaAdmvs == "320921" {
  11444. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11445. } else {
  11446. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11447. }
  11448. resp, _ := client.Do(req)
  11449. defer resp.Body.Close()
  11450. body, ioErr := ioutil.ReadAll(resp.Body)
  11451. if ioErr != nil {
  11452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11454. return
  11455. }
  11456. var respJSON map[string]interface{}
  11457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11460. return
  11461. }
  11462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11463. userJSONBytes, _ := json.Marshal(respJSON)
  11464. fmt.Println("log")
  11465. fmt.Println(string(userJSONBytes))
  11466. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11467. utils.ErrorLog("解析失败:%v", err)
  11468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11469. return
  11470. }
  11471. res.InfRefmsgid = resFour10265.InfRefmsgid
  11472. res.Output = resFour10265.Output
  11473. res.ErrMsg = resFour10265.ErrMsg
  11474. res.Cainfo = resFour10265.Cainfo
  11475. res.WarnMsg = resFour10265.WarnMsg
  11476. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11477. res.Infcode = infocode
  11478. }
  11479. }
  11480. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11481. 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)
  11482. var dat map[string]interface{}
  11483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11484. fmt.Println(dat)
  11485. } else {
  11486. fmt.Println(err)
  11487. }
  11488. saveLog(result, request_log, "2204", "上传费用明细")
  11489. userJSONBytes, _ := json.Marshal(dat)
  11490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11491. utils.ErrorLog("解析失败:%v", err)
  11492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11493. return
  11494. }
  11495. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11496. 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, "", "")
  11497. var dat map[string]interface{}
  11498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11499. fmt.Println(dat)
  11500. } else {
  11501. fmt.Println(err)
  11502. }
  11503. saveLog(result, request_log, "2204", "上传费用明细")
  11504. userJSONBytes, _ := json.Marshal(dat)
  11505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11506. utils.ErrorLog("解析失败:%v", err)
  11507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11508. return
  11509. }
  11510. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11511. 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, "", "")
  11512. var dat map[string]interface{}
  11513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11514. fmt.Println(dat)
  11515. } else {
  11516. fmt.Println(err)
  11517. }
  11518. saveLog(result, request_log, "2204", "上传费用明细")
  11519. userJSONBytes, _ := json.Marshal(dat)
  11520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11521. utils.ErrorLog("解析失败:%v", err)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return
  11524. }
  11525. } else {
  11526. if miConfig.Code == "H15049901371" {
  11527. 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)
  11528. var dat map[string]interface{}
  11529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11530. fmt.Println(dat)
  11531. } else {
  11532. fmt.Println(err)
  11533. }
  11534. saveLog(result, request_log, "2204", "上传费用明细")
  11535. userJSONBytes, _ := json.Marshal(dat)
  11536. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11537. utils.ErrorLog("解析失败:%v", err)
  11538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11539. return
  11540. }
  11541. res.InfRefmsgid = resFour10265.InfRefmsgid
  11542. res.Output = resFour10265.Output
  11543. res.ErrMsg = resFour10265.ErrMsg
  11544. res.Cainfo = resFour10265.Cainfo
  11545. res.WarnMsg = resFour10265.WarnMsg
  11546. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11547. res.Infcode = infocode
  11548. } else {
  11549. 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)
  11550. var dat map[string]interface{}
  11551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11552. fmt.Println(dat)
  11553. } else {
  11554. fmt.Println(err)
  11555. }
  11556. saveLog(result, request_log, "2204", "上传费用明细")
  11557. userJSONBytes, _ := json.Marshal(dat)
  11558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11559. utils.ErrorLog("解析失败:%v", err)
  11560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11561. return
  11562. }
  11563. }
  11564. }
  11565. var total_two float64
  11566. if res.Infcode == 0 {
  11567. order := &models.HisOrder{
  11568. UserOrgId: adminUser.CurrentOrgId,
  11569. HisPatientId: his.ID,
  11570. PatientId: his.PatientId,
  11571. SettleAccountsDate: recordDateTime,
  11572. Ctime: time.Now().Unix(),
  11573. Mtime: time.Now().Unix(),
  11574. MdtrtId: his.Number,
  11575. PsnNo: his.PsnNo,
  11576. MedType: strconv.FormatInt(reg_type, 10),
  11577. Status: 1,
  11578. Number: chrg_bchno,
  11579. Infcode: res.Infcode,
  11580. WarnMsg: res.WarnMsg,
  11581. Cainfo: res.Cainfo,
  11582. ErrMsg: res.ErrMsg,
  11583. RespondTime: res.RefmsgTime,
  11584. InfRefmsgid: res.InfRefmsgid,
  11585. OrderStatus: 1,
  11586. IsMedicineInsurance: 1,
  11587. SettleType: settle_accounts_type,
  11588. SettleStartTime: start_time,
  11589. SettleEndTime: end_time,
  11590. Creator: roles.AdminUserId,
  11591. Modify: roles.AdminUserId,
  11592. PType: 2,
  11593. Diagnosis: diagnosis_id,
  11594. }
  11595. err = service.CreateOrder(order)
  11596. if err != nil {
  11597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11598. return
  11599. }
  11600. for _, item := range res.Output.Result {
  11601. temp := strings.Split(item.FeedetlSn, "-")
  11602. var advice_id int64 = 0
  11603. var project_id int64 = 0
  11604. var types int64 = 0
  11605. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11606. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11607. if temp[1] == "1" {
  11608. advice_id = id
  11609. project_id = 0
  11610. } else if temp[1] == "2" {
  11611. advice_id = 0
  11612. project_id = id
  11613. }
  11614. total_two = total_two + item.DetItemFeeSumamt
  11615. info := &models.HisOrderInfo{
  11616. OrderNumber: order.Number,
  11617. FeedetlSn: item.FeedetlSn,
  11618. UploadDate: time.Now().Unix(),
  11619. AdviceId: advice_id,
  11620. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11621. Cnt: item.Cnt,
  11622. Pric: float64(item.Pric),
  11623. PatientId: his.PatientId,
  11624. PricUplmtAmt: item.PricUplmtAmt,
  11625. SelfpayProp: item.SelfpayProp,
  11626. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11627. OverlmtAmt: item.OverlmtAmt,
  11628. PreselfpayAmt: item.PreselfpayAmt,
  11629. BasMednFlag: item.BasMednFlag,
  11630. MedChrgitmType: item.MedChrgitmType,
  11631. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11632. Status: 1,
  11633. Memo: item.Memo,
  11634. Mtime: time.Now().Unix(),
  11635. InscpScpAmt: item.InscpScpAmt,
  11636. DrtReimFlag: item.DrtReimFlag,
  11637. Ctime: time.Now().Unix(),
  11638. ListSpItemFlag: item.ListSpItemFlag,
  11639. ChldMedcFlag: item.ChldMedcFlag,
  11640. LmtUsedFlag: item.LmtUsedFlag,
  11641. ChrgitmLv: item.ChrgitmLv,
  11642. UserOrgId: adminUser.CurrentOrgId,
  11643. HisPatientId: his.ID,
  11644. OrderId: order.ID,
  11645. ProjectId: project_id,
  11646. Type: types,
  11647. }
  11648. service.CreateOrderInfo(info)
  11649. }
  11650. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11651. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11652. var total float64
  11653. for _, item := range prescriptions {
  11654. if item.Type == 1 { //药品
  11655. for _, subItem := range item.HisDoctorAdviceInfo {
  11656. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11657. total_one := price * subItem.PrescribingNumber
  11658. fmt.Println("subItem")
  11659. fmt.Println(subItem.Price)
  11660. fmt.Println("price")
  11661. fmt.Println(price)
  11662. fmt.Println("total_one")
  11663. fmt.Println(total_one)
  11664. total = total + total_one
  11665. fmt.Println(total)
  11666. }
  11667. }
  11668. if item.Type == 2 { //项目
  11669. for _, subItem := range item.HisPrescriptionProject {
  11670. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11671. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11672. total_one := price * cnt
  11673. total = total + total_one
  11674. }
  11675. }
  11676. }
  11677. allTotal := fmt.Sprintf("%2f", total)
  11678. if res.Infcode == 0 {
  11679. var rf []*ResultFive
  11680. json.Unmarshal([]byte(his.Iinfo), &rf)
  11681. chrg_bchno := chrg_bchno
  11682. cert_no := his.Certno
  11683. var insutypes []string
  11684. var insutype string
  11685. var is390 int = 0
  11686. var is310 int = 0
  11687. for _, item := range rf {
  11688. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11689. insutypes = append(insutypes, item.Insutype)
  11690. }
  11691. }
  11692. if len(insutypes) == 1 {
  11693. insutype = insutypes[0]
  11694. } else {
  11695. for _, i := range insutypes {
  11696. if i == "390" {
  11697. is390 = 1
  11698. }
  11699. if i == "310" {
  11700. is310 = 1
  11701. }
  11702. }
  11703. }
  11704. if is390 == 1 {
  11705. insutype = "390"
  11706. }
  11707. if is310 == 1 {
  11708. insutype = "310"
  11709. }
  11710. if len(insutypes) == 0 {
  11711. insutype = "390"
  11712. }
  11713. if len(insutypes) == 2 {
  11714. insutype = strconv.FormatInt(his.SocialType, 10)
  11715. }
  11716. //insutype = "390"
  11717. if his.IdCardType == 1 {
  11718. cert_no = his.MedicalInsuranceNumber
  11719. } else {
  11720. cert_no = his.Certno
  11721. }
  11722. var res ResultSeven
  11723. var resSeven10265 ResultSeven10265
  11724. if miConfig.MdtrtareaAdmvs == "421300" {
  11725. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11726. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11727. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11729. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11730. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11731. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  11732. resp, requestErr := http.Get(api)
  11733. if requestErr != nil {
  11734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11735. return
  11736. }
  11737. body, ioErr := ioutil.ReadAll(resp.Body)
  11738. if ioErr != nil {
  11739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. var respJSON map[string]interface{}
  11744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11747. return
  11748. }
  11749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11750. result, _ := json.Marshal(respJSON)
  11751. fmt.Println("log")
  11752. fmt.Println(string(result))
  11753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11754. utils.ErrorLog("解析失败:%v", err)
  11755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11756. return
  11757. }
  11758. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11759. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  11760. if result3101.Infcode == "0" {
  11761. if len(result3101.Output.Result) > 0 {
  11762. var errMsgs []string
  11763. for _, item := range result3101.Output.Result {
  11764. errMsgs = append(errMsgs, item.VolaCont)
  11765. }
  11766. c.ServeSuccessJSON(map[string]interface{}{
  11767. "failed_code": -10,
  11768. "msg": errMsgs,
  11769. })
  11770. return
  11771. } else {
  11772. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11773. if his.IdCardType != 4 {
  11774. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11775. bas := strings.Split(psn_info.CardInfo, "|")
  11776. if his.IdCardType == 1 {
  11777. cert_no = bas[2]
  11778. } else {
  11779. cert_no = bas[1]
  11780. }
  11781. } else {
  11782. cert_no = his.Certno
  11783. }
  11784. //江苏地区国家医保医疗类别
  11785. //职工透析:医疗类别选特殊情况门诊9933
  11786. //居民血透门慢: 医疗类别选门诊慢病1402
  11787. //var med_type string
  11788. //if his.Insutype == "310" {
  11789. // if reg_type == 14 {
  11790. // med_type = "9933"
  11791. // } else if reg_type == 11 {
  11792. // med_type = "11"
  11793. //
  11794. // }
  11795. //} else if his.Insutype == "390" {
  11796. // if reg_type == 14 {
  11797. // med_type = "1402"
  11798. // } else if reg_type == 11 {
  11799. // med_type = "11"
  11800. // }
  11801. //}
  11802. var api string
  11803. if miConfig.MdtrtareaAdmvs == "320921" {
  11804. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11805. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11806. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11808. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11809. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11810. "&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
  11811. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11812. } else {
  11813. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11814. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11815. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11816. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11818. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11819. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11820. "&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
  11821. }
  11822. resp, requestErr := http.Get(api)
  11823. if requestErr != nil {
  11824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11825. return
  11826. }
  11827. body, ioErr := ioutil.ReadAll(resp.Body)
  11828. if ioErr != nil {
  11829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11831. return
  11832. }
  11833. var respJSON map[string]interface{}
  11834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11837. return
  11838. }
  11839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11840. result, _ := json.Marshal(respJSON)
  11841. fmt.Println("log")
  11842. fmt.Println(string(result))
  11843. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11844. utils.ErrorLog("解析失败:%v", err)
  11845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11846. return
  11847. }
  11848. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11849. res.Output = resSeven10265.Output
  11850. res.ErrMsg = resSeven10265.ErrMsg
  11851. res.Cainfo = resSeven10265.Cainfo
  11852. res.WarnMsg = resSeven10265.WarnMsg
  11853. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11854. res.Infcode = infocode
  11855. }
  11856. }
  11857. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11858. acct_used_flag := "1"
  11859. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  11860. var result string
  11861. var request_log string
  11862. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  11863. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  11864. } else {
  11865. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  11866. }
  11867. var dat map[string]interface{}
  11868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11869. fmt.Println(dat)
  11870. } else {
  11871. fmt.Println(err)
  11872. }
  11873. saveLog(result, request_log, "2206", "预结算")
  11874. userJSONBytes, _ := json.Marshal(dat)
  11875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11876. utils.ErrorLog("解析失败:%v", err)
  11877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11878. return
  11879. }
  11880. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11881. var result string
  11882. var request_log string
  11883. if his.IdCardType == 2 {
  11884. 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, "")
  11885. } else if his.IdCardType == 1 {
  11886. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11887. bas := strings.Split(psn_info.CardInfo, "|")
  11888. basNumber := bas[2]
  11889. card_sn := bas[3]
  11890. 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)
  11891. } else {
  11892. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11893. 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, "")
  11894. }
  11895. var dat map[string]interface{}
  11896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11897. fmt.Println(dat)
  11898. } else {
  11899. fmt.Println(err)
  11900. }
  11901. saveLog(result, request_log, "2206", "预结算")
  11902. userJSONBytes, _ := json.Marshal(dat)
  11903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11904. utils.ErrorLog("解析失败:%v", err)
  11905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11906. return
  11907. }
  11908. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11909. var result string
  11910. var request_log string
  11911. if his.IdCardType == 2 {
  11912. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", "1")
  11913. } else if his.IdCardType == 1 {
  11914. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11915. bas := strings.Split(psn_info.CardInfo, "|")
  11916. basNumber := bas[2]
  11917. card_sn := bas[3]
  11918. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "1")
  11919. } else {
  11920. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11921. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "1")
  11922. }
  11923. var dat map[string]interface{}
  11924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11925. fmt.Println(dat)
  11926. } else {
  11927. fmt.Println(err)
  11928. }
  11929. saveLog(result, request_log, "2206", "预结算")
  11930. userJSONBytes, _ := json.Marshal(dat)
  11931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11932. utils.ErrorLog("解析失败:%v", err)
  11933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11934. return
  11935. }
  11936. } else {
  11937. var result string
  11938. var request_log string
  11939. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11940. allTotal = fmt.Sprintf("%2f", total_two)
  11941. if his.IdCardType == 4 {
  11942. 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)
  11943. } else {
  11944. 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)
  11945. }
  11946. var dat map[string]interface{}
  11947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11948. fmt.Println(dat)
  11949. } else {
  11950. fmt.Println(err)
  11951. }
  11952. saveLog(result, request_log, "2206", "预结算")
  11953. //userJSONBytes, _ := json.Marshal(dat)
  11954. //
  11955. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11956. // utils.ErrorLog("解析失败:%v", err)
  11957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11958. // return
  11959. //}
  11960. userJSONBytes, _ := json.Marshal(dat)
  11961. if miConfig.Code == "H15049901371" {
  11962. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11963. utils.ErrorLog("解析失败:%v", err)
  11964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11965. return
  11966. }
  11967. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11968. res.Output = resSeven10265.Output
  11969. res.ErrMsg = resSeven10265.ErrMsg
  11970. res.Cainfo = resSeven10265.Cainfo
  11971. res.WarnMsg = resSeven10265.WarnMsg
  11972. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11973. res.Infcode = infocode
  11974. } else {
  11975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11976. utils.ErrorLog("解析失败:%v", err)
  11977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11978. return
  11979. }
  11980. }
  11981. }
  11982. if res.Infcode != 0 {
  11983. errlog := &models.HisOrderError{
  11984. UserOrgId: adminUser.CurrentOrgId,
  11985. Ctime: time.Now().Unix(),
  11986. Mtime: time.Now().Unix(),
  11987. Number: chrg_bchno,
  11988. ErrMsg: res.ErrMsg,
  11989. Status: 1,
  11990. PatientId: id,
  11991. RecordTime: recordDateTime,
  11992. Stage: 20,
  11993. }
  11994. service.CreateErrMsgLog(errlog)
  11995. c.ServeSuccessJSON(map[string]interface{}{
  11996. "failed_code": -10,
  11997. "msg": res.ErrMsg,
  11998. })
  11999. return
  12000. } else {
  12001. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12002. order.OrderStatus = 1
  12003. order.IsPre = 1
  12004. order.Status = 1
  12005. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12006. order.SetlId = res.Output.Setlinfo.SetlID
  12007. order.PsnNo = res.Output.Setlinfo.PsnNo
  12008. order.PsnName = res.Output.Setlinfo.PsnName
  12009. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12010. order.Certno = res.Output.Setlinfo.Certno
  12011. order.Gend = res.Output.Setlinfo.Gend
  12012. order.Naty = res.Output.Setlinfo.Naty
  12013. order.Age = res.Output.Setlinfo.Age
  12014. order.Insutype = res.Output.Setlinfo.Insutype
  12015. order.PsnType = res.Output.Setlinfo.PsnType
  12016. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12017. order.SetlTime = res.Output.Setlinfo.SetlTime
  12018. order.AcctUsedFlag = acct_used_flag
  12019. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12020. if res.Output.Setlinfo.MedType == "140101" {
  12021. order.MedType = "14"
  12022. } else {
  12023. order.MedType = res.Output.Setlinfo.MedType
  12024. }
  12025. if reg_type == 1112 {
  12026. order.MedType = "1112"
  12027. }
  12028. if reg_type == 1111 {
  12029. order.MedType = "1111"
  12030. }
  12031. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12032. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12033. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12034. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12035. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12036. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12037. order.HifpPay = res.Output.Setlinfo.HifpPay
  12038. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12039. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12040. order.HifesPay = res.Output.Setlinfo.HifesPay
  12041. order.HifobPay = res.Output.Setlinfo.HifobPay
  12042. order.MafPay = res.Output.Setlinfo.MafPay
  12043. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12044. order.OthPay = res.Output.Setlinfo.OthPay
  12045. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12046. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12047. order.AcctPay = res.Output.Setlinfo.AcctPay
  12048. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12049. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12050. order.Balc = res.Output.Setlinfo.Balc
  12051. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12052. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12053. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12054. order.ClrWay = res.Output.Setlinfo.ClrWay
  12055. order.Creator = order.Creator
  12056. order.Modify = roles.AdminUserId
  12057. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12058. detailStr := string(setlDetail)
  12059. order.SetlDetail = detailStr
  12060. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12061. err = service.UpDateOrder(order)
  12062. if err == nil {
  12063. c.ServeSuccessJSON(map[string]interface{}{
  12064. "msg": "预结算成功",
  12065. })
  12066. } else {
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12068. return
  12069. }
  12070. }
  12071. } else {
  12072. adminUser := c.GetAdminUserInfo()
  12073. errlog := &models.HisOrderError{
  12074. UserOrgId: adminUser.CurrentOrgId,
  12075. Ctime: time.Now().Unix(),
  12076. Mtime: time.Now().Unix(),
  12077. ErrMsg: res.ErrMsg,
  12078. Status: 1,
  12079. PatientId: id,
  12080. RecordTime: recordDateTime,
  12081. Stage: 4,
  12082. }
  12083. service.CreateErrMsgLog(errlog)
  12084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12085. return
  12086. }
  12087. } else {
  12088. adminUser := c.GetAdminUserInfo()
  12089. errlog := &models.HisOrderError{
  12090. UserOrgId: adminUser.CurrentOrgId,
  12091. Ctime: time.Now().Unix(),
  12092. Mtime: time.Now().Unix(),
  12093. ErrMsg: res.ErrMsg,
  12094. Status: 1,
  12095. PatientId: id,
  12096. RecordTime: recordDateTime,
  12097. Stage: 4,
  12098. }
  12099. service.CreateErrMsgLog(errlog)
  12100. c.ServeSuccessJSON(map[string]interface{}{
  12101. "failed_code": -10,
  12102. "msg": res.ErrMsg,
  12103. })
  12104. return
  12105. }
  12106. }
  12107. }
  12108. }
  12109. // 退款
  12110. func (c *HisApiController) Refund() {
  12111. order_id, _ := c.GetInt64("order_id")
  12112. admin_user_id, _ := c.GetInt64("admin_user_id")
  12113. adminUser := c.GetAdminUserInfo()
  12114. var order models.HisOrder
  12115. order, _ = service.GetHisOrderByID(order_id)
  12116. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12117. if order.ID == 0 {
  12118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12119. return
  12120. }
  12121. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12124. if config.IsOpen == 1 { //对接了医保,走医保流程
  12125. var res ResultSixteen
  12126. var resSixteen10265 ResultSixteen10265
  12127. var src_resquest string
  12128. var result string
  12129. if miConfig.MdtrtareaAdmvs == "421300" {
  12130. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  12131. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12132. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12133. resp3, requestErr3 := http.Get(api3)
  12134. if requestErr3 != nil {
  12135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12136. return
  12137. }
  12138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12139. if ioErr3 != nil {
  12140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12142. return
  12143. }
  12144. var respJSON3 map[string]interface{}
  12145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12148. return
  12149. }
  12150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12151. userJSONBytes3, _ := json.Marshal(respJSON3)
  12152. fmt.Println("log")
  12153. fmt.Println(string(userJSONBytes3))
  12154. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  12155. utils.ErrorLog("解析失败:%v", err)
  12156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12157. return
  12158. }
  12159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12160. var api3 string
  12161. if miConfig.MdtrtareaAdmvs == "320921" {
  12162. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12163. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12164. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12165. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12166. } else {
  12167. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12168. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12169. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12171. }
  12172. resp3, requestErr3 := http.Get(api3)
  12173. if requestErr3 != nil {
  12174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12175. return
  12176. }
  12177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12178. if ioErr3 != nil {
  12179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12181. return
  12182. }
  12183. var respJSON3 map[string]interface{}
  12184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12187. return
  12188. }
  12189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12190. userJSONBytes3, _ := json.Marshal(respJSON3)
  12191. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  12192. utils.ErrorLog("解析失败:%v", err)
  12193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12194. return
  12195. }
  12196. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12197. res.Output = resSixteen10265.Output
  12198. res.ErrMsg = resSixteen10265.ErrMsg
  12199. res.Cainfo = resSixteen10265.Cainfo
  12200. res.WarnMsg = resSixteen10265.WarnMsg
  12201. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12202. res.Infcode = infocode
  12203. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12204. 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)
  12205. var dat map[string]interface{}
  12206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12207. fmt.Println(dat)
  12208. } else {
  12209. fmt.Println(err)
  12210. }
  12211. saveLog(result, src_resquest, "2208", "退费")
  12212. userJSONBytes, _ := json.Marshal(dat)
  12213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12214. utils.ErrorLog("解析失败:%v", err)
  12215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12216. return
  12217. }
  12218. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12219. 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, "")
  12220. var dat map[string]interface{}
  12221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12222. fmt.Println(dat)
  12223. } else {
  12224. fmt.Println(err)
  12225. }
  12226. saveLog(result, src_resquest, "2208", "退费")
  12227. userJSONBytes, _ := json.Marshal(dat)
  12228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12229. utils.ErrorLog("解析失败:%v", err)
  12230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12231. return
  12232. }
  12233. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12234. 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, "")
  12235. var dat map[string]interface{}
  12236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12237. fmt.Println(dat)
  12238. } else {
  12239. fmt.Println(err)
  12240. }
  12241. saveLog(result, src_resquest, "2208", "退费")
  12242. userJSONBytes, _ := json.Marshal(dat)
  12243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12244. utils.ErrorLog("解析失败:%v", err)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return
  12247. }
  12248. } else {
  12249. if miConfig.Code == "H15049901371" {
  12250. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12251. var dat map[string]interface{}
  12252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12253. fmt.Println(dat)
  12254. } else {
  12255. fmt.Println(err)
  12256. }
  12257. saveLog(result, src_resquest, "2208", "退费")
  12258. userJSONBytes, _ := json.Marshal(dat)
  12259. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  12260. utils.ErrorLog("解析失败:%v", err)
  12261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12262. return
  12263. }
  12264. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12265. res.Output = resSixteen10265.Output
  12266. res.ErrMsg = resSixteen10265.ErrMsg
  12267. res.Cainfo = resSixteen10265.Cainfo
  12268. res.WarnMsg = resSixteen10265.WarnMsg
  12269. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12270. res.Infcode = infocode
  12271. } else {
  12272. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12273. var dat map[string]interface{}
  12274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12275. fmt.Println(dat)
  12276. } else {
  12277. fmt.Println(err)
  12278. }
  12279. saveLog(result, src_resquest, "2208", "退费")
  12280. userJSONBytes, _ := json.Marshal(dat)
  12281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12282. utils.ErrorLog("解析失败:%v", err)
  12283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12284. return
  12285. }
  12286. }
  12287. }
  12288. if res.Infcode == 0 {
  12289. var res2 ResultSix
  12290. var resSix10265 ResultSix10265
  12291. if miConfig.MdtrtareaAdmvs == "421300" {
  12292. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12293. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12294. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12295. resp3, requestErr3 := http.Get(api3)
  12296. if requestErr3 != nil {
  12297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12298. return
  12299. }
  12300. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12301. if ioErr3 != nil {
  12302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. var respJSON3 map[string]interface{}
  12307. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12313. userJSONBytes3, _ := json.Marshal(respJSON3)
  12314. fmt.Println("log")
  12315. fmt.Println(string(userJSONBytes3))
  12316. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12317. utils.ErrorLog("解析失败:%v", err)
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12319. return
  12320. }
  12321. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12322. var api3 string
  12323. if miConfig.MdtrtareaAdmvs == "320921" {
  12324. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12325. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12326. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12327. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12328. } else {
  12329. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12330. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12331. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12333. }
  12334. resp3, requestErr3 := http.Get(api3)
  12335. if requestErr3 != nil {
  12336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12337. return
  12338. }
  12339. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12340. if ioErr3 != nil {
  12341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12343. return
  12344. }
  12345. var respJSON3 map[string]interface{}
  12346. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12349. return
  12350. }
  12351. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12352. userJSONBytes3, _ := json.Marshal(respJSON3)
  12353. fmt.Println("log")
  12354. fmt.Println(string(userJSONBytes3))
  12355. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12356. utils.ErrorLog("解析失败:%v", err)
  12357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12358. return
  12359. }
  12360. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12361. res2.Output = resSix10265.Output
  12362. res2.ErrMsg = resSix10265.ErrMsg
  12363. res2.Cainfo = resSix10265.Cainfo
  12364. res2.WarnMsg = resSix10265.WarnMsg
  12365. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12366. res2.Infcode = infocode
  12367. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12368. 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)
  12369. var dat map[string]interface{}
  12370. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12371. fmt.Println(dat)
  12372. } else {
  12373. fmt.Println(err)
  12374. }
  12375. saveLog(result2, src_request, "2205", "撤销明细")
  12376. userJSONBytes, _ := json.Marshal(dat)
  12377. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12378. utils.ErrorLog("解析失败:%v", err)
  12379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12380. return
  12381. }
  12382. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12383. 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, "")
  12384. var dat map[string]interface{}
  12385. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12386. fmt.Println(dat)
  12387. } else {
  12388. fmt.Println(err)
  12389. }
  12390. saveLog(result2, src_request, "2205", "撤销明细")
  12391. userJSONBytes, _ := json.Marshal(dat)
  12392. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12393. utils.ErrorLog("解析失败:%v", err)
  12394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12395. return
  12396. }
  12397. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12398. 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, "")
  12399. var dat map[string]interface{}
  12400. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12401. fmt.Println(dat)
  12402. } else {
  12403. fmt.Println(err)
  12404. }
  12405. saveLog(result2, src_request, "2205", "撤销明细")
  12406. userJSONBytes, _ := json.Marshal(dat)
  12407. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12408. utils.ErrorLog("解析失败:%v", err)
  12409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12410. return
  12411. }
  12412. } else {
  12413. if miConfig.Code == "H15049901371" {
  12414. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12415. var dat map[string]interface{}
  12416. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12417. fmt.Println(dat)
  12418. } else {
  12419. fmt.Println(err)
  12420. }
  12421. saveLog(result2, src_request, "2205", "撤销明细")
  12422. userJSONBytes, _ := json.Marshal(dat)
  12423. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12424. utils.ErrorLog("解析失败:%v", err)
  12425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12426. return
  12427. }
  12428. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12429. res2.Output = resSix10265.Output
  12430. res2.ErrMsg = resSix10265.ErrMsg
  12431. res2.Cainfo = resSix10265.Cainfo
  12432. res2.WarnMsg = resSix10265.WarnMsg
  12433. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12434. res2.Infcode = infocode
  12435. } else {
  12436. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12437. var dat map[string]interface{}
  12438. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12439. fmt.Println(dat)
  12440. } else {
  12441. fmt.Println(err)
  12442. }
  12443. saveLog(result2, src_request, "2205", "撤销明细")
  12444. userJSONBytes, _ := json.Marshal(dat)
  12445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12446. utils.ErrorLog("解析失败:%v", err)
  12447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12448. return
  12449. }
  12450. }
  12451. }
  12452. if res2.Infcode == 0 {
  12453. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  12454. if err == nil {
  12455. //当押金不为零时产生退费记录
  12456. if order.Decimal != 0 {
  12457. tmp := strconv.FormatInt(order.ID, 10)
  12458. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  12459. if err != nil {
  12460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12461. return
  12462. }
  12463. }
  12464. c.ServeSuccessJSON(map[string]interface{}{
  12465. "msg": "退费成功",
  12466. })
  12467. } else {
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. } else {
  12472. c.ServeSuccessJSON(map[string]interface{}{
  12473. "code": -10,
  12474. "msg": res2.ErrMsg,
  12475. })
  12476. }
  12477. } else {
  12478. c.ServeSuccessJSON(map[string]interface{}{
  12479. "code": -10,
  12480. "msg": res.ErrMsg,
  12481. })
  12482. }
  12483. }
  12484. }
  12485. func (c *HisApiController) RefundNumber() {
  12486. record_time := c.GetString("record_time")
  12487. //patient_id, _ := c.GetInt64("patient_id")
  12488. admin_user_id, _ := c.GetInt64("admin_user_id")
  12489. his_patient_id, _ := c.GetInt64("id")
  12490. timeLayout := "2006-01-02"
  12491. loc, _ := time.LoadLocation("Local")
  12492. adminUser := c.GetAdminUserInfo()
  12493. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12494. fmt.Println(err)
  12495. if err != nil {
  12496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12497. return
  12498. }
  12499. recordDateTime := theTime.Unix()
  12500. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12501. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  12502. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12503. //order, _ := service.GetHisOrderByID(order_id)
  12504. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12505. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12506. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12507. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  12508. if count > 0 {
  12509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  12510. return
  12511. }
  12512. if config.IsOpen == 1 { //对接了医保,走医保流程
  12513. var res2 ResultSix
  12514. var resSix10265 ResultSix10265
  12515. if miConfig.MdtrtareaAdmvs == "421300" {
  12516. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  12517. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12519. resp3, requestErr3 := http.Get(api3)
  12520. if requestErr3 != nil {
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return
  12523. }
  12524. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12525. if ioErr3 != nil {
  12526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12528. return
  12529. }
  12530. var respJSON3 map[string]interface{}
  12531. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12534. return
  12535. }
  12536. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12537. userJSONBytes3, _ := json.Marshal(respJSON3)
  12538. fmt.Println("log")
  12539. fmt.Println(string(userJSONBytes3))
  12540. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12541. utils.ErrorLog("解析失败:%v", err)
  12542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12543. return
  12544. }
  12545. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12546. var api3 string
  12547. if miConfig.MdtrtareaAdmvs == "320921" {
  12548. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12549. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12551. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12552. } else {
  12553. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12554. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12555. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12557. }
  12558. resp3, requestErr3 := http.Get(api3)
  12559. if requestErr3 != nil {
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12564. if ioErr3 != nil {
  12565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. var respJSON3 map[string]interface{}
  12570. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12573. return
  12574. }
  12575. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12576. userJSONBytes3, _ := json.Marshal(respJSON3)
  12577. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12578. utils.ErrorLog("解析失败:%v", err)
  12579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12580. return
  12581. }
  12582. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12583. res2.Output = resSix10265.Output
  12584. res2.ErrMsg = resSix10265.ErrMsg
  12585. res2.Cainfo = resSix10265.Cainfo
  12586. res2.WarnMsg = resSix10265.WarnMsg
  12587. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12588. res2.Infcode = infocode
  12589. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12590. 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)
  12591. var dat map[string]interface{}
  12592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12593. fmt.Println(dat)
  12594. } else {
  12595. fmt.Println(err)
  12596. }
  12597. saveLog(result, request, "2202", "退号")
  12598. userJSONBytes, _ := json.Marshal(dat)
  12599. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12600. utils.ErrorLog("解析失败:%v", err)
  12601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12602. return
  12603. }
  12604. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12605. 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, "")
  12606. var dat map[string]interface{}
  12607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12608. fmt.Println(dat)
  12609. } else {
  12610. fmt.Println(err)
  12611. }
  12612. saveLog(result, request, "2202", "退号")
  12613. userJSONBytes, _ := json.Marshal(dat)
  12614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12615. utils.ErrorLog("解析失败:%v", err)
  12616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12617. return
  12618. }
  12619. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12620. 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, "")
  12621. var dat map[string]interface{}
  12622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12623. fmt.Println(dat)
  12624. } else {
  12625. fmt.Println(err)
  12626. }
  12627. saveLog(result, request, "2202", "退号")
  12628. userJSONBytes, _ := json.Marshal(dat)
  12629. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12630. utils.ErrorLog("解析失败:%v", err)
  12631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12632. return
  12633. }
  12634. } else {
  12635. var api3 string
  12636. if miConfig.Code == "H15049901371" {
  12637. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12638. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12639. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12640. } else {
  12641. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12642. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12644. }
  12645. resp3, requestErr3 := http.Get(api3)
  12646. if requestErr3 != nil {
  12647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12648. return
  12649. }
  12650. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12651. if ioErr3 != nil {
  12652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12654. return
  12655. }
  12656. var respJSON3 map[string]interface{}
  12657. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12660. return
  12661. }
  12662. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12663. userJSONBytes3, _ := json.Marshal(respJSON3)
  12664. if miConfig.Code == "H15049901371" {
  12665. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12666. utils.ErrorLog("解析失败:%v", err)
  12667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12668. return
  12669. }
  12670. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12671. res2.Output = resSix10265.Output
  12672. res2.ErrMsg = resSix10265.ErrMsg
  12673. res2.Cainfo = resSix10265.Cainfo
  12674. res2.WarnMsg = resSix10265.WarnMsg
  12675. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12676. res2.Infcode = infocode
  12677. } else {
  12678. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12679. utils.ErrorLog("解析失败:%v", err)
  12680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12681. return
  12682. }
  12683. }
  12684. }
  12685. if res2.Infcode == 0 {
  12686. if err == nil {
  12687. c.ServeSuccessJSON(map[string]interface{}{
  12688. "msg": "退号成功",
  12689. })
  12690. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  12691. } else {
  12692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12693. return
  12694. }
  12695. } else {
  12696. c.ServeSuccessJSON(map[string]interface{}{
  12697. "code": -10,
  12698. "msg": res2.ErrMsg,
  12699. })
  12700. }
  12701. } else {
  12702. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  12703. //if err == nil {
  12704. // c.ServeSuccessJSON(map[string]interface{}{
  12705. // "msg": "退费成功",
  12706. // })
  12707. //} else {
  12708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12709. // return
  12710. //}
  12711. }
  12712. }
  12713. func (c *HisApiController) RefundDetail() {
  12714. order_id, _ := c.GetInt64("order_id")
  12715. admin_user_id, _ := c.GetInt64("admin_user_id")
  12716. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12717. number := c.GetString("number")
  12718. record_time := c.GetString("record_time")
  12719. patient_id, _ := c.GetInt64("patient_id")
  12720. //med_type, _ := c.GetInt64("med_type")
  12721. timeLayout := "2006-01-02"
  12722. loc, _ := time.LoadLocation("Local")
  12723. adminUser := c.GetAdminUserInfo()
  12724. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12725. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12726. fmt.Println(err)
  12727. if err != nil {
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12729. return
  12730. }
  12731. recordDateTime := theTime.Unix()
  12732. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12733. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12734. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12735. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12736. var order models.HisOrder
  12737. order, _ = service.GetHisOrderByID(order_id)
  12738. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12739. if config.IsOpen == 1 { //对接了医保,走医保流程
  12740. var res2 ResultSix
  12741. if miConfig.MdtrtareaAdmvs == "421300" {
  12742. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12743. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12745. resp3, requestErr3 := http.Get(api3)
  12746. if requestErr3 != nil {
  12747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12748. return
  12749. }
  12750. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12751. if ioErr3 != nil {
  12752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12754. return
  12755. }
  12756. var respJSON3 map[string]interface{}
  12757. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12760. return
  12761. }
  12762. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12763. userJSONBytes3, _ := json.Marshal(respJSON3)
  12764. fmt.Println("log")
  12765. fmt.Println(string(userJSONBytes3))
  12766. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12767. utils.ErrorLog("解析失败:%v", err)
  12768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12769. return
  12770. }
  12771. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12772. if err == nil {
  12773. c.ServeSuccessJSON(map[string]interface{}{
  12774. "msg": "撤销明细成功",
  12775. })
  12776. return
  12777. } else {
  12778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12779. return
  12780. }
  12781. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12782. var resSix10265 ResultSix10265
  12783. var api3 string
  12784. if miConfig.MdtrtareaAdmvs == "320921" {
  12785. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12786. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12788. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12789. } else {
  12790. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12791. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12792. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12794. }
  12795. resp3, requestErr3 := http.Get(api3)
  12796. if requestErr3 != nil {
  12797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12798. return
  12799. }
  12800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12801. if ioErr3 != nil {
  12802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12804. return
  12805. }
  12806. var respJSON3 map[string]interface{}
  12807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12810. return
  12811. }
  12812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12813. userJSONBytes3, _ := json.Marshal(respJSON3)
  12814. fmt.Println("log")
  12815. fmt.Println(string(userJSONBytes3))
  12816. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12817. utils.ErrorLog("解析失败:%v", err)
  12818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12819. return
  12820. }
  12821. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12822. res2.Output = resSix10265.Output
  12823. res2.ErrMsg = resSix10265.ErrMsg
  12824. res2.Cainfo = resSix10265.Cainfo
  12825. res2.WarnMsg = resSix10265.WarnMsg
  12826. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12827. res2.Infcode = infocode
  12828. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12829. if err == nil {
  12830. c.ServeSuccessJSON(map[string]interface{}{
  12831. "msg": "撤销明细成功",
  12832. })
  12833. return
  12834. } else {
  12835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12836. return
  12837. }
  12838. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12839. 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)
  12840. var dat map[string]interface{}
  12841. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12842. fmt.Println(dat)
  12843. } else {
  12844. fmt.Println(err)
  12845. }
  12846. saveLog(result2, src_request, "2205", "撤销明细")
  12847. userJSONBytes, _ := json.Marshal(dat)
  12848. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12849. utils.ErrorLog("解析失败:%v", err)
  12850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12851. return
  12852. }
  12853. if res2.Infcode == 0 {
  12854. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12855. if err == nil {
  12856. c.ServeSuccessJSON(map[string]interface{}{
  12857. "msg": "撤销明细成功",
  12858. })
  12859. return
  12860. } else {
  12861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12862. return
  12863. }
  12864. } else {
  12865. c.ServeSuccessJSON(map[string]interface{}{
  12866. "code": -10,
  12867. "msg": res2.ErrMsg,
  12868. })
  12869. }
  12870. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12871. 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, "")
  12872. var dat map[string]interface{}
  12873. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12874. fmt.Println(dat)
  12875. } else {
  12876. fmt.Println(err)
  12877. }
  12878. saveLog(result2, src_request, "2205", "撤销明细")
  12879. userJSONBytes, _ := json.Marshal(dat)
  12880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12881. utils.ErrorLog("解析失败:%v", err)
  12882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12883. return
  12884. }
  12885. if res2.Infcode == 0 {
  12886. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12887. if err == nil {
  12888. c.ServeSuccessJSON(map[string]interface{}{
  12889. "msg": "撤销明细成功",
  12890. })
  12891. return
  12892. } else {
  12893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12894. return
  12895. }
  12896. } else {
  12897. c.ServeSuccessJSON(map[string]interface{}{
  12898. "code": -10,
  12899. "msg": res2.ErrMsg,
  12900. })
  12901. }
  12902. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12903. 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, "")
  12904. var dat map[string]interface{}
  12905. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12906. fmt.Println(dat)
  12907. } else {
  12908. fmt.Println(err)
  12909. }
  12910. saveLog(result2, src_request, "2205", "撤销明细")
  12911. userJSONBytes, _ := json.Marshal(dat)
  12912. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12913. utils.ErrorLog("解析失败:%v", err)
  12914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12915. return
  12916. }
  12917. if res2.Infcode == 0 {
  12918. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12919. if err == nil {
  12920. c.ServeSuccessJSON(map[string]interface{}{
  12921. "msg": "撤销明细成功",
  12922. })
  12923. return
  12924. } else {
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12926. return
  12927. }
  12928. } else {
  12929. c.ServeSuccessJSON(map[string]interface{}{
  12930. "code": -10,
  12931. "msg": res2.ErrMsg,
  12932. })
  12933. }
  12934. } else {
  12935. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  12936. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12938. resp2, requestErr2 := http.Get(api2)
  12939. if requestErr2 != nil {
  12940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12941. return
  12942. }
  12943. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12944. if ioErr2 != nil {
  12945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12947. return
  12948. }
  12949. var respJSON2 map[string]interface{}
  12950. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12953. return
  12954. }
  12955. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12956. if err == nil {
  12957. c.ServeSuccessJSON(map[string]interface{}{
  12958. "msg": "撤销明细成功",
  12959. })
  12960. return
  12961. } else {
  12962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12963. return
  12964. }
  12965. }
  12966. } else {
  12967. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12968. if err == nil {
  12969. c.ServeSuccessJSON(map[string]interface{}{
  12970. "msg": "退费成功",
  12971. })
  12972. } else {
  12973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12974. return
  12975. }
  12976. }
  12977. }
  12978. // 对账
  12979. func (c *HisApiController) GetCheckAccount() {
  12980. start_time := c.GetString("start_time")
  12981. end_time := c.GetString("end_time")
  12982. insutype := c.GetString("insutype")
  12983. clr_type := c.GetString("clr_type")
  12984. clr_org := c.GetString("clr_optins")
  12985. admin_user_id, _ := c.GetInt64("admin_user_id")
  12986. adminUser := c.GetAdminUserInfo()
  12987. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12988. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12989. if len(clr_org) == 0 {
  12990. clr_org = miConfig.MdtrtareaAdmvs
  12991. }
  12992. timeLayout := "2006-01-02"
  12993. loc, _ := time.LoadLocation("Local")
  12994. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12995. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12996. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12997. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12998. fixmedins_setl_cnt := int64(len(orders))
  12999. var medfee_sumamt float64
  13000. var acct_pay float64
  13001. var fund_pay_sumamt float64
  13002. for _, item := range orders {
  13003. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13004. acct_pay = acct_pay + item.AcctPay
  13005. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13006. }
  13007. var user_name string
  13008. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13009. if role.ID == 0 {
  13010. user_name = "xxx"
  13011. } else {
  13012. user_name = role.UserName
  13013. }
  13014. var res ResultEight
  13015. var res10188 ResultEightFor10188
  13016. if config.IsOpen == 1 {
  13017. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13018. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  13019. "insutype=" + insutype +
  13020. "&clr_type=" + clr_type +
  13021. "&setl_optins=" + clr_org +
  13022. "&stmt_begndate=" + start_time +
  13023. "&stm_enddate=" + end_time +
  13024. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13025. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13026. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13027. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13028. "&fixmedins_code=" + miConfig.Code +
  13029. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13030. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13031. "&secret_key=" + miConfig.SecretKey +
  13032. "&org_name=" + miConfig.OrgName +
  13033. "&doctor=" + user_name +
  13034. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13035. fmt.Println(api)
  13036. resp, requestErr := http.Get(api)
  13037. if requestErr != nil {
  13038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13039. return
  13040. }
  13041. body, ioErr := ioutil.ReadAll(resp.Body)
  13042. fmt.Println(body)
  13043. if ioErr != nil {
  13044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13046. return
  13047. }
  13048. var respJSON map[string]interface{}
  13049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13052. return
  13053. }
  13054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13055. userJSONBytes, _ := json.Marshal(respJSON)
  13056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13057. utils.ErrorLog("解析失败:%v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. res.InfRefmsgid = res10188.InfRefmsgid
  13062. res.Output = res10188.Output
  13063. res.ErrMsg = res10188.ErrMsg
  13064. res.Cainfo = res10188.Cainfo
  13065. res.WarnMsg = res10188.WarnMsg
  13066. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13067. res.Infcode = infocode
  13068. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13069. if clr_type == "11" {
  13070. fixmedins_setl_cnt = 2
  13071. }
  13072. //if clr_type == "21" {
  13073. // clr_type = "22"
  13074. //}
  13075. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  13076. "insutype=" + insutype +
  13077. "&clr_type=" + clr_type +
  13078. "&setl_optins=" + clr_org +
  13079. "&stmt_begndate=" + start_time +
  13080. "&stm_enddate=" + end_time +
  13081. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13082. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13083. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13084. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13085. "&fixmedins_code=" + miConfig.Code +
  13086. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13087. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13088. "&secret_key=" + miConfig.SecretKey +
  13089. "&org_name=" + miConfig.OrgName +
  13090. "&doctor=" + user_name
  13091. resp, requestErr := http.Get(api)
  13092. if requestErr != nil {
  13093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13094. return
  13095. }
  13096. body, ioErr := ioutil.ReadAll(resp.Body)
  13097. if ioErr != nil {
  13098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13100. return
  13101. }
  13102. var respJSON map[string]interface{}
  13103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13106. return
  13107. }
  13108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13109. result, _ := json.Marshal(respJSON)
  13110. fmt.Println("log")
  13111. fmt.Println(string(result))
  13112. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  13113. utils.ErrorLog("解析失败:%v", err)
  13114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13115. return
  13116. }
  13117. res.InfRefmsgid = res10188.InfRefmsgid
  13118. res.Output = res10188.Output
  13119. res.ErrMsg = res10188.ErrMsg
  13120. res.Cainfo = res10188.Cainfo
  13121. res.WarnMsg = res10188.WarnMsg
  13122. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13123. res.Infcode = infocode
  13124. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13125. var baseParams models.BaseParams
  13126. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13127. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13128. baseParams.SecretKey = miConfig.SecretKey
  13129. baseParams.OrgName = miConfig.OrgName
  13130. baseParams.FixmedinsCode = miConfig.Code
  13131. baseParams.EncKey = miConfig.EncKey
  13132. baseParams.AppSecret = miConfig.AppSecret
  13133. baseParams.SignKey = miConfig.SignKey
  13134. baseParams.AppID = miConfig.Code
  13135. baseParams.Doctor = role.UserName
  13136. baseParams.RequestUrl = miConfig.Url
  13137. businessParams := models.BusinessParams{
  13138. Insutype: insutype,
  13139. ClrType: clr_type,
  13140. SetlOptins: clr_org,
  13141. StmtBegndate: start_time,
  13142. StmtEnddate: end_time,
  13143. MedfeeSumamt: medfee_sumamt,
  13144. FundPaySumamt: fund_pay_sumamt,
  13145. AcctPay: acct_pay,
  13146. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13147. }
  13148. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13149. fmt.Println(requestLog)
  13150. fmt.Println(result)
  13151. fmt.Println(err_msg)
  13152. var dat map[string]interface{}
  13153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13154. fmt.Println(dat)
  13155. } else {
  13156. fmt.Println(err)
  13157. }
  13158. userJSONBytes, _ := json.Marshal(dat)
  13159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13160. utils.ErrorLog("解析失败:%v", err)
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13162. return
  13163. }
  13164. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13165. var baseParams models.BaseParams
  13166. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13167. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13168. baseParams.SecretKey = miConfig.SecretKey
  13169. baseParams.OrgName = miConfig.OrgName
  13170. baseParams.FixmedinsCode = miConfig.Code
  13171. baseParams.EncKey = miConfig.EncKey
  13172. baseParams.AppSecret = miConfig.AppSecret
  13173. baseParams.SignKey = miConfig.SignKey
  13174. baseParams.AppID = miConfig.Code
  13175. baseParams.Doctor = role.UserName
  13176. baseParams.RequestUrl = miConfig.Url
  13177. baseParams.AccessKey = miConfig.AccessKey
  13178. businessParams := models.BusinessParams{
  13179. Insutype: insutype,
  13180. ClrType: clr_type,
  13181. SetlOptins: "430822",
  13182. StmtBegndate: start_time,
  13183. StmtEnddate: end_time,
  13184. MedfeeSumamt: medfee_sumamt,
  13185. FundPaySumamt: fund_pay_sumamt,
  13186. AcctPay: acct_pay,
  13187. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13188. }
  13189. 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)
  13190. fmt.Println(requestLog)
  13191. fmt.Println(result)
  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. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13200. utils.ErrorLog("解析失败:%v", err)
  13201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13202. return
  13203. }
  13204. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13205. var baseParams models.BaseParams
  13206. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13207. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13208. baseParams.SecretKey = miConfig.SecretKey
  13209. baseParams.OrgName = miConfig.OrgName
  13210. baseParams.FixmedinsCode = miConfig.Code
  13211. baseParams.EncKey = miConfig.EncKey
  13212. baseParams.AppSecret = miConfig.AppSecret
  13213. baseParams.SignKey = miConfig.SignKey
  13214. baseParams.AppID = miConfig.Code
  13215. baseParams.Doctor = role.UserName
  13216. baseParams.RequestUrl = miConfig.Url
  13217. businessParams := models.BusinessParams{
  13218. Insutype: insutype,
  13219. ClrType: clr_type,
  13220. SetlOptins: clr_org,
  13221. StmtBegndate: start_time,
  13222. StmtEnddate: end_time,
  13223. MedfeeSumamt: medfee_sumamt,
  13224. FundPaySumamt: fund_pay_sumamt,
  13225. AcctPay: acct_pay,
  13226. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13227. }
  13228. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13229. fmt.Println(requestLog)
  13230. fmt.Println(result)
  13231. fmt.Println(err_msg)
  13232. var dat map[string]interface{}
  13233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13234. fmt.Println(dat)
  13235. } else {
  13236. fmt.Println(err)
  13237. }
  13238. userJSONBytes, _ := json.Marshal(dat)
  13239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13240. utils.ErrorLog("解析失败:%v", err)
  13241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13242. return
  13243. }
  13244. } else {
  13245. if len(clr_type) == 0 {
  13246. clr_type = "11"
  13247. }
  13248. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13249. "insutype=" + insutype +
  13250. "&clr_type=" + clr_type +
  13251. "&setl_optins=" + clr_org +
  13252. "&stmt_begndate=" + start_time +
  13253. "&stm_enddate=" + end_time +
  13254. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13255. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13256. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13257. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13258. "&fixmedins_code=" + miConfig.Code +
  13259. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13260. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13261. "&secret_key=" + miConfig.SecretKey +
  13262. "&org_name=" + miConfig.OrgName +
  13263. "&doctor=" + user_name
  13264. fmt.Println(api)
  13265. resp, requestErr := http.Get(api)
  13266. if requestErr != nil {
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. body, ioErr := ioutil.ReadAll(resp.Body)
  13271. fmt.Println(body)
  13272. if ioErr != nil {
  13273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13275. return
  13276. }
  13277. var respJSON map[string]interface{}
  13278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13281. return
  13282. }
  13283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13284. userJSONBytes, _ := json.Marshal(respJSON)
  13285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13286. utils.ErrorLog("解析失败:%v", err)
  13287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13288. return
  13289. }
  13290. }
  13291. if res.Infcode == 0 {
  13292. if res.Output.Stmtinfo.StmtRslt == "0" {
  13293. micc := &models.MedicalInsuranceCostCompare{
  13294. StartTime: startime.Unix(),
  13295. EndTime: endtime.Unix(),
  13296. Insutype: insutype,
  13297. CheckType: 1,
  13298. Num: fixmedins_setl_cnt,
  13299. Mtime: time.Now().Unix(),
  13300. Status: 1,
  13301. UserOrgId: adminUser.CurrentOrgId,
  13302. CostTotal: medfee_sumamt,
  13303. FuncTotal: fund_pay_sumamt,
  13304. PsnPay: acct_pay,
  13305. Creator: admin_user_id,
  13306. Ctime: time.Now().Unix(),
  13307. ClrType: clr_type,
  13308. }
  13309. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  13310. if err == nil {
  13311. c.ServeSuccessJSON(map[string]interface{}{
  13312. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13313. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13314. })
  13315. } else {
  13316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13317. }
  13318. } else {
  13319. c.ServeSuccessJSON(map[string]interface{}{
  13320. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13321. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13322. })
  13323. }
  13324. } else {
  13325. c.ServeSuccessJSON(map[string]interface{}{
  13326. "code": -10,
  13327. "msg": res.ErrMsg,
  13328. })
  13329. }
  13330. }
  13331. }
  13332. func (c *HisApiController) Check310() {
  13333. adminUser := c.GetAdminUserInfo()
  13334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13335. var user_name string
  13336. user_name = "高慧裕"
  13337. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13338. "insutype=" + "310" +
  13339. "&clr_type=" + "" +
  13340. "&setl_optins=" + "441202" +
  13341. "&stmt_begndate=" + "2022-03-01" +
  13342. "&stm_enddate=" + "2022-03-31" +
  13343. "&medfee_sumamt=" + "194930.12" +
  13344. "&fund_pay_sumamt=" + "188741.46" +
  13345. "&acct_pay=" + "0" +
  13346. "&fixmedins_setl_cnt=" + "452" +
  13347. "&fixmedins_code=" + miConfig.Code +
  13348. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13349. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13350. "&secret_key=" + miConfig.SecretKey +
  13351. "&org_name=" + miConfig.OrgName +
  13352. "&doctor=" + user_name
  13353. fmt.Println(api)
  13354. resp, requestErr := http.Get(api)
  13355. if requestErr != nil {
  13356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13357. return
  13358. }
  13359. body, ioErr := ioutil.ReadAll(resp.Body)
  13360. fmt.Println(body)
  13361. if ioErr != nil {
  13362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13364. return
  13365. }
  13366. var respJSON map[string]interface{}
  13367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13370. return
  13371. }
  13372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13373. userJSONBytes, _ := json.Marshal(respJSON)
  13374. var res ResultEight
  13375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13376. utils.ErrorLog("解析失败:%v", err)
  13377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13378. return
  13379. }
  13380. }
  13381. func (c *HisApiController) Check390() {
  13382. adminUser := c.GetAdminUserInfo()
  13383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13384. var user_name string
  13385. user_name = "高慧裕"
  13386. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13387. "insutype=" + "390" +
  13388. "&clr_type=" + "" +
  13389. "&setl_optins=" + "441202" +
  13390. "&stmt_begndate=" + "2022-03-01" +
  13391. "&stm_enddate=" + "2022-03-31" +
  13392. "&medfee_sumamt=" + "1068448.89" +
  13393. "&fund_pay_sumamt=" + "1014677.62" +
  13394. "&acct_pay=" + "0" +
  13395. "&fixmedins_setl_cnt=" + "1950" +
  13396. "&fixmedins_code=" + miConfig.Code +
  13397. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13398. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13399. "&secret_key=" + miConfig.SecretKey +
  13400. "&org_name=" + miConfig.OrgName +
  13401. "&doctor=" + user_name
  13402. fmt.Println(api)
  13403. resp, requestErr := http.Get(api)
  13404. if requestErr != nil {
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. body, ioErr := ioutil.ReadAll(resp.Body)
  13409. fmt.Println(body)
  13410. if ioErr != nil {
  13411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13413. return
  13414. }
  13415. var respJSON map[string]interface{}
  13416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13419. return
  13420. }
  13421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13422. userJSONBytes, _ := json.Marshal(respJSON)
  13423. var res ResultEight
  13424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13425. utils.ErrorLog("解析失败:%v", err)
  13426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13427. return
  13428. }
  13429. }
  13430. // 对账明细
  13431. func (c *HisApiController) GetCheckDetailAccount() {
  13432. start_time := c.GetString("start_time")
  13433. end_time := c.GetString("end_time")
  13434. admin_user_id, _ := c.GetInt64("admin_user_id")
  13435. adminUser := c.GetAdminUserInfo()
  13436. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13437. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13438. timeLayout := "2006-01-02"
  13439. loc, _ := time.LoadLocation("Local")
  13440. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13441. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13442. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13443. rand.Seed(time.Now().UnixNano())
  13444. num := rand.Intn(30000)
  13445. Mkdir(miConfig.OrgName)
  13446. file := strconv.FormatInt(int64(num), 10)
  13447. file_name := file + ".txt"
  13448. zip_name := file + ".zip"
  13449. zip_path := miConfig.OrgName + "/" + zip_name
  13450. file_path := miConfig.OrgName + "/" + file_name
  13451. decimal.DivisionPrecision = 2
  13452. var medfee_sumamt float64
  13453. var psn_cash_pay float64
  13454. var fund_pay_sumamt float64
  13455. fixmedins_setl_cnt := int64(len(orders))
  13456. for _, item := range orders {
  13457. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13458. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  13459. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13460. }
  13461. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  13462. defer f.Close()
  13463. if err != nil {
  13464. fmt.Println(err.Error())
  13465. } else {
  13466. for _, item := range orders {
  13467. var refd_setl_flag string
  13468. if item.OrderStatus == 2 {
  13469. refd_setl_flag = "0"
  13470. var str string
  13471. str = item.SetlId + " " +
  13472. item.MdtrtId + " " +
  13473. item.PsnNo + " " +
  13474. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13475. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13476. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  13477. _, err = f.Write([]byte(str))
  13478. }
  13479. if item.OrderStatus == 3 {
  13480. var str string
  13481. str = item.SetlId + " " +
  13482. item.MdtrtId + " " +
  13483. item.PsnNo + " " +
  13484. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13485. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13486. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  13487. _, err = f.Write([]byte(str))
  13488. var str2 string
  13489. str2 = item.SetlId + " " +
  13490. item.MdtrtId + " " +
  13491. item.PsnNo + " " +
  13492. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  13493. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  13494. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  13495. _, err = f.Write([]byte(str2))
  13496. }
  13497. }
  13498. }
  13499. Zip(file_path, zip_path)
  13500. fmt.Println(ReadFile(zip_path))
  13501. fmt.Println(string(ReadFile(zip_path)))
  13502. if config.IsOpen == 1 {
  13503. var user_name string
  13504. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13505. if role.ID == 0 {
  13506. user_name = "管理员"
  13507. } else {
  13508. user_name = role.UserName
  13509. }
  13510. baseParams := models.BaseParams{
  13511. SecretKey: miConfig.SecretKey,
  13512. FixmedinsCode: miConfig.Code,
  13513. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13514. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13515. OrgName: miConfig.OrgName,
  13516. Doctor: user_name,
  13517. }
  13518. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  13519. var dat map[string]interface{}
  13520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13521. fmt.Println(dat)
  13522. } else {
  13523. fmt.Println(err)
  13524. }
  13525. userJSONBytes, _ := json.Marshal(dat)
  13526. var res ResultNine
  13527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13528. utils.ErrorLog("解析失败:%v", err)
  13529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13530. return
  13531. }
  13532. if res.Infcode == 0 {
  13533. fileNo := res.Output.FileQuryNo
  13534. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  13535. "file_qury_no=" + fileNo +
  13536. "&setl_optins=" + "定点医保中心" +
  13537. "&stmt_begndate=" + start_time +
  13538. "&stm_enddate=" + end_time +
  13539. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13540. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13541. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13542. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13543. "&fixmedins_code=" + miConfig.Code +
  13544. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13545. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13546. "&secret_key=" + miConfig.SecretKey +
  13547. "&org_name=" + miConfig.OrgName +
  13548. "&doctor=" + user_name
  13549. resp, requestErr := http.Get(api)
  13550. if requestErr != nil {
  13551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13552. return
  13553. }
  13554. body, ioErr := ioutil.ReadAll(resp.Body)
  13555. if ioErr != nil {
  13556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13558. return
  13559. }
  13560. var respJSON map[string]interface{}
  13561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13564. return
  13565. }
  13566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13567. userJSONBytes, _ := json.Marshal(respJSON)
  13568. var res ResultTen
  13569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13570. utils.ErrorLog("解析失败:%v", err)
  13571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13572. return
  13573. }
  13574. if res.Infcode == 0 {
  13575. service.Gdyb9102(baseParams, zip_name, fileNo)
  13576. micc := &models.MedicalInsuranceCostCompare{
  13577. StartTime: startime.Unix(),
  13578. EndTime: endtime.Unix(),
  13579. Insutype: "0",
  13580. CheckType: 2,
  13581. Num: fixmedins_setl_cnt,
  13582. Mtime: time.Now().Unix(),
  13583. Status: 1,
  13584. UserOrgId: adminUser.CurrentOrgId,
  13585. CostTotal: medfee_sumamt,
  13586. FuncTotal: fund_pay_sumamt,
  13587. PsnPay: psn_cash_pay,
  13588. Creator: admin_user_id,
  13589. Ctime: time.Now().Unix(),
  13590. }
  13591. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13592. c.ServeSuccessJSON(map[string]interface{}{
  13593. "msg": "明细对账成功",
  13594. })
  13595. }
  13596. } else {
  13597. }
  13598. }
  13599. }
  13600. type CustomOrderInfo struct {
  13601. Name string
  13602. Spec string
  13603. Unit string
  13604. Count float64
  13605. Price float64
  13606. Total float64
  13607. }
  13608. func (c *HisApiController) GetBatchSettleAccounts() {
  13609. admin_user_id, _ := c.GetInt64("admin_user_id")
  13610. order_ids := c.GetString("order_ids")
  13611. order_ids_arr := strings.Split(order_ids, ",")
  13612. data3 := []map[string]interface{}{}
  13613. for _, item := range order_ids_arr {
  13614. id, _ := strconv.ParseInt(item, 10, 64)
  13615. order_id := id
  13616. adminUser := c.GetAdminUserInfo()
  13617. order, _ := service.GetHisOrderByID(order_id)
  13618. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13619. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13620. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13621. orderInfos = append(orderInfos, orderInfos_two...)
  13622. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13623. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13624. var diagnosis_ids []string
  13625. if his.ID > 0 {
  13626. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13627. } else {
  13628. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13629. }
  13630. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13631. var dia_config []*models.HisXtDiagnoseConfig
  13632. var name string
  13633. for _, item := range diagnosis_ids {
  13634. id, _ := strconv.ParseInt(item, 10, 64)
  13635. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13636. dia_config = append(dia_config, &diagnosisConfig)
  13637. if len(name) == 0 {
  13638. name = diagnosisConfig.ClassName
  13639. } else {
  13640. name = name + "," + diagnosisConfig.ClassName
  13641. }
  13642. }
  13643. var bedCostTotal float64 = 0 //床位总费
  13644. var bedCostSelfTotal float64 = 0 //床位自费
  13645. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13646. var bedSelfTotal float64 = 0 //床位部分项目自费
  13647. var bedInscpTotal float64 = 0 //床位部分项目自费
  13648. var operationCostTotal float64 = 0 //手术费
  13649. var operationCostSelfTotal float64 = 0 //手术费
  13650. var operationCostPartSelfTotal float64 = 0 //手术费
  13651. var operationSelfTotal float64 = 0 //床位部分项目自费
  13652. var operationInscpTotal float64 = 0 //床位部分项目自费
  13653. var otherCostTotal float64 = 0 //其他费用
  13654. var otherCostSelfTotal float64 = 0 //其他费用
  13655. var otherCostPartSelfTotal float64 = 0 //其他费用
  13656. var otherSelfTotal float64 = 0 //床位部分项目自费
  13657. var otherInscpTotal float64 = 0 //床位部分项目自费
  13658. var materialCostTotal float64 = 0 //材料费
  13659. var materialCostSelfTotal float64 = 0 //材料费
  13660. var materialCostPartSelfTotal float64 = 0 //材料费
  13661. var materialSelfTotal float64 = 0 //床位部分项目自费
  13662. var materialInscpTotal float64 = 0 //床位部分项目自费
  13663. var westernMedicineCostTotal float64 = 0 //西药费
  13664. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13665. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13666. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13667. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13668. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13669. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13670. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13671. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  13672. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  13673. var checkCostTotal float64 = 0 //检查费
  13674. var checkCostSelfTotal float64 = 0 //检查费
  13675. var checkCostPartSelfTotal float64 = 0 //检查费
  13676. var checkSelfTotal float64 = 0 //床位部分项目自费
  13677. var checkInscpTotal float64 = 0 //床位部分项目自费
  13678. var laboratoryCostTotal float64 = 0 //化验费
  13679. var laboratoryCostSelfTotal float64 = 0 //化验费
  13680. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13681. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  13682. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  13683. var treatCostTotal float64 = 0 //治疗费用
  13684. var treatCostSelfTotal float64 = 0 //治疗费用
  13685. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13686. var treatSelfTotal float64 = 0 //床位部分项目自费
  13687. var treatInscpTotal float64 = 0 //床位部分项目自费
  13688. decimal.DivisionPrecision = 2
  13689. for _, item := range orderInfos {
  13690. if item.MedChrgitmType == "01" { //床位费
  13691. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13692. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13693. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13694. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13695. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13696. }
  13697. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  13698. if item.MedChrgitmType == "03" { //检查费
  13699. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13700. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13701. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13702. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13703. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13704. }
  13705. } else {
  13706. if item.MedChrgitmType == "03" { //检查费
  13707. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13708. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13709. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13710. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13711. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13712. }
  13713. }
  13714. if item.MedChrgitmType == "04" { //化验费
  13715. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13716. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13717. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13718. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13719. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13720. }
  13721. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  13722. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13723. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13724. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13725. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13726. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13727. }
  13728. if item.MedChrgitmType == "06" { //手术费
  13729. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13730. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13731. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13732. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13733. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13734. }
  13735. if item.MedChrgitmType == "08" { //材料费
  13736. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13737. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13738. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13739. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13740. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13741. }
  13742. if item.MedChrgitmType == "09" { //西药费
  13743. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13744. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13745. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13746. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13747. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13748. }
  13749. if item.MedChrgitmType == "11" { //中成费
  13750. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13751. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13752. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13753. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13754. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13755. }
  13756. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  13757. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13758. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13759. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13760. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13761. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13762. }
  13763. }
  13764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13765. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13766. var user_name string
  13767. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13768. if role.ID == 0 {
  13769. user_name = "管理员"
  13770. } else {
  13771. user_name = role.UserName
  13772. }
  13773. baseParams := models.BaseParams{
  13774. SecretKey: miConfig.SecretKey,
  13775. FixmedinsCode: miConfig.Code,
  13776. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13777. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13778. OrgName: miConfig.OrgName,
  13779. Doctor: user_name,
  13780. RequestUrl: miConfig.Url,
  13781. AccessKey: miConfig.AccessKey,
  13782. }
  13783. businessParams := models.BusinessParams{
  13784. PsnNo: order.PsnNo,
  13785. MdtrtId: order.MdtrtId,
  13786. SetlId: order.SetlId,
  13787. }
  13788. var res ResultEleven
  13789. var resEleven10265 ResultEleven10265
  13790. if config.IsOpen == 1 {
  13791. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  13792. result := service.Gdyb5203(baseParams, businessParams)
  13793. //service.Gdyb5204(baseParams, businessParams)
  13794. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  13795. var dat map[string]interface{}
  13796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13797. fmt.Println(dat)
  13798. } else {
  13799. fmt.Println(err)
  13800. }
  13801. userJSONBytes, _ := json.Marshal(dat)
  13802. if miConfig.Code == "H15049901371" {
  13803. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  13804. utils.ErrorLog("解析失败:%v", err)
  13805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13806. return
  13807. }
  13808. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13809. res.Output = resEleven10265.Output
  13810. res.ErrMsg = resEleven10265.ErrMsg
  13811. res.Cainfo = resEleven10265.Cainfo
  13812. res.WarnMsg = resEleven10265.WarnMsg
  13813. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13814. res.Infcode = infocode
  13815. } else {
  13816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13817. utils.ErrorLog("解析失败:%v", err)
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13819. return
  13820. }
  13821. }
  13822. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13823. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13824. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13825. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13826. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13827. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13828. var doctor_name string
  13829. if roles.ID == 0 {
  13830. doctor_name = "管理员"
  13831. } else {
  13832. doctor_name = roles.UserName
  13833. }
  13834. yiliao_leibie := ""
  13835. switch order.MedType {
  13836. case "11":
  13837. yiliao_leibie = "普通门诊"
  13838. break
  13839. case "12":
  13840. yiliao_leibie = "门诊挂号"
  13841. break
  13842. case "13":
  13843. yiliao_leibie = "急诊"
  13844. break
  13845. case "14":
  13846. yiliao_leibie = "门诊特殊病"
  13847. break
  13848. case "15":
  13849. yiliao_leibie = "门诊统筹"
  13850. break
  13851. case "16":
  13852. yiliao_leibie = "门诊慢性病"
  13853. break
  13854. case "21":
  13855. yiliao_leibie = "普通住院"
  13856. break
  13857. }
  13858. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13859. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13860. if res.Infcode == 0 {
  13861. data2 := map[string]interface{}{
  13862. "diagnosis": name,
  13863. "order_infos": orderInfos,
  13864. "number": order.MdtrtId,
  13865. "date": order.SettleAccountsDate,
  13866. "charge_admin": charge_admin,
  13867. "printor_admin": printor_admin,
  13868. "info": res.Output.Setlinfo,
  13869. "order": order,
  13870. "bedCostTotal": bedCostTotal,
  13871. "bedCostSelfTotal": bedCostSelfTotal,
  13872. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13873. "bedSelfTotal": bedSelfTotal,
  13874. "bedInscpTotal": bedInscpTotal,
  13875. "operationCostTotal": operationCostTotal,
  13876. "operationCostSelfTotal": operationCostSelfTotal,
  13877. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13878. "operationSelfTotal": operationSelfTotal,
  13879. "operationInscpTotal": operationInscpTotal,
  13880. "otherCostTotal": otherCostTotal,
  13881. "otherCostSelfTotal": otherCostSelfTotal,
  13882. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13883. "otherSelfTotal": otherSelfTotal,
  13884. "otherInscpTotal": otherInscpTotal,
  13885. "materialCostTotal": materialCostTotal,
  13886. "materialCostSelfTotal": materialCostSelfTotal,
  13887. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13888. "materialSelfTotal": materialSelfTotal,
  13889. "materialInscpTotal": materialInscpTotal,
  13890. "westernMedicineCostTotal": westernMedicineCostTotal,
  13891. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13892. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13893. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13894. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13895. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13896. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13897. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13898. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13899. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13900. "checkCostTotal": checkCostTotal,
  13901. "checkCostSelfTotal": checkCostSelfTotal,
  13902. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13903. "checkSelfTotal": checkSelfTotal,
  13904. "checkInscpTotal": checkInscpTotal,
  13905. "laboratoryCostTotal": laboratoryCostTotal,
  13906. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13907. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13908. "laboratorySelfTotal": laboratorySelfTotal,
  13909. "laboratoryInscpTotal": laboratoryInscpTotal,
  13910. "treatCostTotal": treatCostTotal,
  13911. "treatCostSelfTotal": treatCostSelfTotal,
  13912. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13913. "treatSelfTotal": treatSelfTotal,
  13914. "treatInscpTotal": treatInscpTotal,
  13915. "doctor_info": doctor_info,
  13916. "doctor_code": adminRole_two.DoctorCode,
  13917. "doctor_name": doctor_name,
  13918. "health_card_no": order.PsnNo,
  13919. "department": departments.Name,
  13920. "yiliao_leibie": yiliao_leibie,
  13921. "after_money": order.AccountPrice,
  13922. "patient": patient,
  13923. "org_name": miConfig.OrgName,
  13924. "org_code": miConfig.Code,
  13925. "order_number": order.Number,
  13926. "his_hospital": his_hospital,
  13927. "his": his,
  13928. "dia_config": dia_config,
  13929. "psn_cash_pay": order.PsnCashPay,
  13930. //"check_order_info": cus_slice,
  13931. }
  13932. data3 = append(data3, data2)
  13933. }
  13934. }
  13935. }
  13936. c.ServeSuccessJSON(map[string]interface{}{
  13937. "infos": data3,
  13938. })
  13939. }
  13940. func (c *HisApiController) GetSettleAccounts() {
  13941. //id, _ := c.GetInt64("id")
  13942. //record_time := c.GetString("record_time")
  13943. order_id, _ := c.GetInt64("order_id")
  13944. admin_user_id, _ := c.GetInt64("admin_user_id")
  13945. //timeLayout := "2006-01-02"
  13946. //loc, _ := time.LoadLocation("Local")
  13947. //
  13948. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13949. //if err != nil {
  13950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13951. // return
  13952. //}
  13953. //recordDateTime := theTime.Unix()
  13954. adminUser := c.GetAdminUserInfo()
  13955. order, _ := service.GetHisOrderByID(order_id)
  13956. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13957. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13958. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13959. orderInfos = append(orderInfos, orderInfos_two...)
  13960. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13961. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13962. var diagnosis_ids []string
  13963. if his.ID > 0 {
  13964. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13965. } else {
  13966. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13967. }
  13968. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13969. var dia_config []*models.HisXtDiagnoseConfig
  13970. var name string
  13971. for _, item := range diagnosis_ids {
  13972. id, _ := strconv.ParseInt(item, 10, 64)
  13973. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13974. dia_config = append(dia_config, &diagnosisConfig)
  13975. if len(name) == 0 {
  13976. name = diagnosisConfig.ClassName
  13977. } else {
  13978. name = name + "," + diagnosisConfig.ClassName
  13979. }
  13980. }
  13981. var bedCostTotal float64 = 0 //床位总费
  13982. var bedCostSelfTotal float64 = 0 //床位自费
  13983. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13984. var bedSelfTotal float64 = 0 //床位部分项目自费
  13985. var bedInscpTotal float64 = 0 //床位部分项目自费
  13986. var operationCostTotal float64 = 0 //手术费
  13987. var operationCostSelfTotal float64 = 0 //手术费
  13988. var operationCostPartSelfTotal float64 = 0 //手术费
  13989. var operationSelfTotal float64 = 0 //床位部分项目自费
  13990. var operationInscpTotal float64 = 0 //床位部分项目自费
  13991. var otherCostTotal float64 = 0 //其他费用
  13992. var otherCostSelfTotal float64 = 0 //其他费用
  13993. var otherCostPartSelfTotal float64 = 0 //其他费用
  13994. var otherSelfTotal float64 = 0 //床位部分项目自费
  13995. var otherInscpTotal float64 = 0 //床位部分项目自费
  13996. var materialCostTotal float64 = 0 //材料费
  13997. var materialCostSelfTotal float64 = 0 //材料费
  13998. var materialCostPartSelfTotal float64 = 0 //材料费
  13999. var materialSelfTotal float64 = 0 //床位部分项目自费
  14000. var materialInscpTotal float64 = 0 //床位部分项目自费
  14001. var westernMedicineCostTotal float64 = 0 //西药费
  14002. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14003. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14004. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14005. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14006. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14007. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14008. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14009. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14010. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14011. var checkCostTotal float64 = 0 //检查费
  14012. var checkCostSelfTotal float64 = 0 //检查费
  14013. var checkCostPartSelfTotal float64 = 0 //检查费
  14014. var checkSelfTotal float64 = 0 //床位部分项目自费
  14015. var checkInscpTotal float64 = 0 //床位部分项目自费
  14016. var laboratoryCostTotal float64 = 0 //化验费
  14017. var laboratoryCostSelfTotal float64 = 0 //化验费
  14018. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14019. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14020. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14021. var treatCostTotal float64 = 0 //治疗费用
  14022. var treatCostSelfTotal float64 = 0 //治疗费用
  14023. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14024. var treatSelfTotal float64 = 0 //床位部分项目自费
  14025. var treatInscpTotal float64 = 0 //床位部分项目自费
  14026. decimal.DivisionPrecision = 2
  14027. for _, item := range orderInfos {
  14028. if item.MedChrgitmType == "01" { //床位费
  14029. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14030. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14031. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14032. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14033. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14034. }
  14035. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14036. if item.MedChrgitmType == "03" { //检查费
  14037. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14038. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14039. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14040. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14041. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14042. }
  14043. } else {
  14044. if item.MedChrgitmType == "03" { //检查费
  14045. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14046. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14047. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14048. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14049. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14050. }
  14051. }
  14052. if item.MedChrgitmType == "04" { //化验费
  14053. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14054. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14055. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14056. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14057. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14058. }
  14059. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14060. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14061. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14062. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14063. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14064. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14065. }
  14066. if item.MedChrgitmType == "06" { //手术费
  14067. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14068. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14069. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14070. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14071. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14072. }
  14073. if item.MedChrgitmType == "08" { //材料费
  14074. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14075. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14076. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14077. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14078. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14079. }
  14080. if item.MedChrgitmType == "09" { //西药费
  14081. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14082. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14083. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14084. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14085. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14086. }
  14087. if item.MedChrgitmType == "11" { //中成费
  14088. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14089. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14090. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14091. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14092. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14093. }
  14094. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14095. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14096. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14097. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14098. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14099. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14100. }
  14101. }
  14102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14103. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14104. var user_name string
  14105. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14106. if role.ID == 0 {
  14107. user_name = "管理员"
  14108. } else {
  14109. user_name = role.UserName
  14110. }
  14111. baseParams := models.BaseParams{
  14112. SecretKey: miConfig.SecretKey,
  14113. FixmedinsCode: miConfig.Code,
  14114. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14115. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14116. OrgName: miConfig.OrgName,
  14117. Doctor: user_name,
  14118. RequestUrl: miConfig.Url,
  14119. AccessKey: miConfig.AccessKey,
  14120. }
  14121. businessParams := models.BusinessParams{
  14122. PsnNo: order.PsnNo,
  14123. MdtrtId: order.MdtrtId,
  14124. SetlId: order.SetlId,
  14125. }
  14126. var res ResultEleven
  14127. var resEleven10265 ResultEleven10265
  14128. if config.IsOpen == 1 {
  14129. if miConfig.MdtrtareaAdmvs == "421300" {
  14130. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14131. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14132. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14133. resp, requestErr := http.Get(api)
  14134. if requestErr != nil {
  14135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14136. return
  14137. }
  14138. body, ioErr := ioutil.ReadAll(resp.Body)
  14139. if ioErr != nil {
  14140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14142. return
  14143. }
  14144. var respJSON map[string]interface{}
  14145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14148. return
  14149. }
  14150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14151. result, _ := json.Marshal(respJSON)
  14152. fmt.Println("log")
  14153. fmt.Println(string(result))
  14154. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14155. utils.ErrorLog("解析失败:%v", err)
  14156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14157. return
  14158. }
  14159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14160. var api string
  14161. if miConfig.MdtrtareaAdmvs == "320921" {
  14162. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14163. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14164. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14165. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14166. } else {
  14167. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14168. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14169. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14171. }
  14172. resp, requestErr := http.Get(api)
  14173. if requestErr != nil {
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. body, ioErr := ioutil.ReadAll(resp.Body)
  14178. if ioErr != nil {
  14179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14181. return
  14182. }
  14183. var respJSON map[string]interface{}
  14184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14187. return
  14188. }
  14189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14190. result, _ := json.Marshal(respJSON)
  14191. fmt.Println("log")
  14192. fmt.Println(string(result))
  14193. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14194. utils.ErrorLog("解析失败:%v", err)
  14195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14196. return
  14197. }
  14198. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14199. res.Output = resEleven10265.Output
  14200. res.ErrMsg = resEleven10265.ErrMsg
  14201. res.Cainfo = resEleven10265.Cainfo
  14202. res.WarnMsg = resEleven10265.WarnMsg
  14203. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14204. res.Infcode = infocode
  14205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14206. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14207. saveLog(result, requestLog, "5203", "结算单")
  14208. var dat map[string]interface{}
  14209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14210. fmt.Println(dat)
  14211. } else {
  14212. fmt.Println(err)
  14213. }
  14214. userJSONBytes, _ := json.Marshal(dat)
  14215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14216. utils.ErrorLog("解析失败:%v", err)
  14217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14218. return
  14219. }
  14220. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14221. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  14222. saveLog(result, requestLog, "5203", "结算单")
  14223. var dat map[string]interface{}
  14224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14225. fmt.Println(dat)
  14226. } else {
  14227. fmt.Println(err)
  14228. }
  14229. userJSONBytes, _ := json.Marshal(dat)
  14230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14231. utils.ErrorLog("解析失败:%v", err)
  14232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14233. return
  14234. }
  14235. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14236. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  14237. saveLog(result, requestLog, "5203", "结算单")
  14238. var dat map[string]interface{}
  14239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14240. fmt.Println(dat)
  14241. } else {
  14242. fmt.Println(err)
  14243. }
  14244. userJSONBytes, _ := json.Marshal(dat)
  14245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14246. utils.ErrorLog("解析失败:%v", err)
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14248. return
  14249. }
  14250. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14251. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14252. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14254. resp, requestErr := http.Get(api)
  14255. if requestErr != nil {
  14256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14257. return
  14258. }
  14259. body, ioErr := ioutil.ReadAll(resp.Body)
  14260. if ioErr != nil {
  14261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14263. return
  14264. }
  14265. var respJSON map[string]interface{}
  14266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14269. return
  14270. }
  14271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14272. result, _ := json.Marshal(respJSON)
  14273. fmt.Println("log")
  14274. fmt.Println(string(result))
  14275. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14276. utils.ErrorLog("解析失败:%v", err)
  14277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14278. return
  14279. }
  14280. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14281. res.Output = resEleven10265.Output
  14282. res.ErrMsg = resEleven10265.ErrMsg
  14283. res.Cainfo = resEleven10265.Cainfo
  14284. res.WarnMsg = resEleven10265.WarnMsg
  14285. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14286. res.Infcode = infocode
  14287. } else {
  14288. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14289. result := service.Gdyb5203(baseParams, businessParams)
  14290. //service.Gdyb5204(baseParams, businessParams)
  14291. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14292. var dat map[string]interface{}
  14293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14294. fmt.Println(dat)
  14295. } else {
  14296. fmt.Println(err)
  14297. }
  14298. userJSONBytes, _ := json.Marshal(dat)
  14299. if miConfig.Code == "H15049901371" {
  14300. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14301. utils.ErrorLog("解析失败:%v", err)
  14302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14303. return
  14304. }
  14305. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14306. res.Output = resEleven10265.Output
  14307. res.ErrMsg = resEleven10265.ErrMsg
  14308. res.Cainfo = resEleven10265.Cainfo
  14309. res.WarnMsg = resEleven10265.WarnMsg
  14310. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14311. res.Infcode = infocode
  14312. } else {
  14313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14314. utils.ErrorLog("解析失败:%v", err)
  14315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14316. return
  14317. }
  14318. }
  14319. }
  14320. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14321. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14322. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14323. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14324. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14325. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14326. var doctor_name string
  14327. if roles.ID == 0 {
  14328. doctor_name = "管理员"
  14329. } else {
  14330. doctor_name = roles.UserName
  14331. }
  14332. yiliao_leibie := ""
  14333. switch order.MedType {
  14334. case "11":
  14335. yiliao_leibie = "普通门诊"
  14336. break
  14337. case "12":
  14338. yiliao_leibie = "门诊挂号"
  14339. break
  14340. case "13":
  14341. yiliao_leibie = "急诊"
  14342. break
  14343. case "14":
  14344. yiliao_leibie = "门诊特殊病"
  14345. break
  14346. case "15":
  14347. yiliao_leibie = "门诊统筹"
  14348. break
  14349. case "16":
  14350. yiliao_leibie = "门诊慢性病"
  14351. break
  14352. case "21":
  14353. yiliao_leibie = "普通住院"
  14354. break
  14355. }
  14356. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14357. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14358. if res.Infcode == 0 {
  14359. c.ServeSuccessJSON(map[string]interface{}{
  14360. "diagnosis": name,
  14361. "order_infos": orderInfos,
  14362. "number": order.MdtrtId,
  14363. "date": order.SettleAccountsDate,
  14364. "charge_admin": charge_admin,
  14365. "printor_admin": printor_admin,
  14366. "info": res.Output.Setlinfo,
  14367. "order": order,
  14368. "bedCostTotal": bedCostTotal,
  14369. "bedCostSelfTotal": bedCostSelfTotal,
  14370. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14371. "bedSelfTotal": bedSelfTotal,
  14372. "bedInscpTotal": bedInscpTotal,
  14373. "operationCostTotal": operationCostTotal,
  14374. "operationCostSelfTotal": operationCostSelfTotal,
  14375. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14376. "operationSelfTotal": operationSelfTotal,
  14377. "operationInscpTotal": operationInscpTotal,
  14378. "otherCostTotal": otherCostTotal,
  14379. "otherCostSelfTotal": otherCostSelfTotal,
  14380. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14381. "otherSelfTotal": otherSelfTotal,
  14382. "otherInscpTotal": otherInscpTotal,
  14383. "materialCostTotal": materialCostTotal,
  14384. "materialCostSelfTotal": materialCostSelfTotal,
  14385. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14386. "materialSelfTotal": materialSelfTotal,
  14387. "materialInscpTotal": materialInscpTotal,
  14388. "westernMedicineCostTotal": westernMedicineCostTotal,
  14389. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14390. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14391. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14392. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14393. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14394. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14395. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14396. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14397. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14398. "checkCostTotal": checkCostTotal,
  14399. "checkCostSelfTotal": checkCostSelfTotal,
  14400. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14401. "checkSelfTotal": checkSelfTotal,
  14402. "checkInscpTotal": checkInscpTotal,
  14403. "laboratoryCostTotal": laboratoryCostTotal,
  14404. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14405. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14406. "laboratorySelfTotal": laboratorySelfTotal,
  14407. "laboratoryInscpTotal": laboratoryInscpTotal,
  14408. "treatCostTotal": treatCostTotal,
  14409. "treatCostSelfTotal": treatCostSelfTotal,
  14410. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14411. "treatSelfTotal": treatSelfTotal,
  14412. "treatInscpTotal": treatInscpTotal,
  14413. "doctor_info": doctor_info,
  14414. "doctor_code": adminRole_two.DoctorCode,
  14415. "doctor_name": doctor_name,
  14416. "health_card_no": order.PsnNo,
  14417. "department": departments.Name,
  14418. "yiliao_leibie": yiliao_leibie,
  14419. "after_money": order.AccountPrice,
  14420. "patient": patient,
  14421. "org_name": miConfig.OrgName,
  14422. "org_code": miConfig.Code,
  14423. "order_number": order.Number,
  14424. "his_hospital": his_hospital,
  14425. "his": his,
  14426. "dia_config": dia_config,
  14427. "psn_cash_pay": order.PsnCashPay,
  14428. //"check_order_info": cus_slice,
  14429. })
  14430. }
  14431. }
  14432. }
  14433. func (c *HisApiController) CheckTreatment() {
  14434. patient_id, _ := c.GetInt64("patient_id")
  14435. id_card_no := c.GetString("id_card_no")
  14436. insutype := c.GetString("insutype")
  14437. med_type := c.GetString("med_type")
  14438. admin_user_id, _ := c.GetInt64("admin_user_id")
  14439. adminUser := c.GetAdminUserInfo()
  14440. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14441. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14442. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14443. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14444. if miConfig.MdtrtareaAdmvs == "421300" {
  14445. var res ResultTwo
  14446. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  14447. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14448. "&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)
  14449. resp, requestErr := http.Get(api)
  14450. if requestErr != nil {
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. return
  14453. }
  14454. body, ioErr := ioutil.ReadAll(resp.Body)
  14455. if ioErr != nil {
  14456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14458. return
  14459. }
  14460. var respJSON map[string]interface{}
  14461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14464. return
  14465. }
  14466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14467. result, _ := json.Marshal(respJSON)
  14468. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14469. utils.ErrorLog("解析失败:%v", err)
  14470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14471. return
  14472. }
  14473. if res.Infcode == 0 {
  14474. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  14475. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14476. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  14477. resp, requestErr := http.Get(api)
  14478. if requestErr != nil {
  14479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14480. return
  14481. }
  14482. body, ioErr := ioutil.ReadAll(resp.Body)
  14483. if ioErr != nil {
  14484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14486. return
  14487. }
  14488. var respJSON map[string]interface{}
  14489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14492. return
  14493. }
  14494. var res Result2001
  14495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14496. result2, _ := json.Marshal(respJSON)
  14497. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14498. utils.ErrorLog("解析失败:%v", err)
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14500. return
  14501. }
  14502. if res.Infcode == 0 {
  14503. c.ServeSuccessJSON(map[string]interface{}{
  14504. "msg": res.Output.Trtinfo,
  14505. })
  14506. }
  14507. } else {
  14508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14509. return
  14510. }
  14511. } else {
  14512. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14513. var dat map[string]interface{}
  14514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14515. fmt.Println(dat)
  14516. } else {
  14517. fmt.Println(err)
  14518. }
  14519. userJSONBytes, _ := json.Marshal(dat)
  14520. var res ResultTwo
  14521. var res10265 ResultTwo10265
  14522. if miConfig.Code == "H15049901371" {
  14523. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14524. utils.ErrorLog("解析失败:%v", err)
  14525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14526. return
  14527. }
  14528. res.ErrMsg = res10265.ErrMsg
  14529. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14530. res.Infcode = infocode
  14531. res.Output = res10265.Output
  14532. res.InfRefmsgid = res10265.InfRefmsgid
  14533. } else {
  14534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14535. utils.ErrorLog("解析失败:%v", err)
  14536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14537. return
  14538. }
  14539. }
  14540. var user_name string
  14541. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  14542. if role.ID == 0 {
  14543. user_name = "xxx"
  14544. } else {
  14545. user_name = role.UserName
  14546. }
  14547. baseParams := models.BaseParams{
  14548. SecretKey: miConfig.SecretKey,
  14549. FixmedinsCode: miConfig.Code,
  14550. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14551. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14552. OrgName: miConfig.OrgName,
  14553. Doctor: user_name,
  14554. }
  14555. if config.IsOpen == 1 {
  14556. if miConfig.Code == "H15049901371" {
  14557. if med_type == "14" {
  14558. if insutype == "390" {
  14559. med_type = "9933"
  14560. } else if insutype == "310" {
  14561. med_type = "990502"
  14562. }
  14563. } else if med_type == "11" {
  14564. med_type = "11"
  14565. }
  14566. }
  14567. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  14568. var dat map[string]interface{}
  14569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14570. fmt.Println(dat)
  14571. } else {
  14572. fmt.Println(err)
  14573. }
  14574. var res Result2001
  14575. var res10265 Result2001Org10265
  14576. if miConfig.Code == "H15049901371" {
  14577. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14578. utils.ErrorLog("解析失败:%v", err)
  14579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14580. return
  14581. }
  14582. res.ErrMsg = res10265.ErrMsg
  14583. res.Output = res10265.Output
  14584. res.InfRefmsgid = res10265.InfRefmsgid
  14585. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14586. res.Infcode = infocode
  14587. } else {
  14588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14589. utils.ErrorLog("解析失败:%v", err)
  14590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14591. return
  14592. }
  14593. }
  14594. if res.Infcode == 0 {
  14595. c.ServeSuccessJSON(map[string]interface{}{
  14596. "msg": res.Output.Trtinfo,
  14597. })
  14598. }
  14599. }
  14600. }
  14601. }
  14602. //func (c *HisApiController) PutRecord() {
  14603. // id, _ := c.GetInt64("id")
  14604. // record_time := c.GetString("record_time")
  14605. // timeLayout := "2006-01-02"
  14606. // loc, _ := time.LoadLocation("Local")
  14607. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14608. // if err != nil {
  14609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14610. // return
  14611. // }
  14612. // recordDateTime := theTime.Unix()
  14613. //
  14614. // adminInfo := c.GetAdminUserInfo()
  14615. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  14616. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14617. //
  14618. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14619. //
  14620. // fmt.Println(miConfig.SecretKey)
  14621. //
  14622. // if patient == nil {
  14623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14624. // return
  14625. // }
  14626. // if len(patient.IdCardNo) == 0 {
  14627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  14628. // return
  14629. // }
  14630. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14631. // if config.IsOpen == 1 {
  14632. // 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
  14633. // resp, requestErr := http.Get(api)
  14634. // if requestErr != nil {
  14635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14636. // return
  14637. // }
  14638. // defer resp.Body.Close()
  14639. // body, ioErr := ioutil.ReadAll(resp.Body)
  14640. // if ioErr != nil {
  14641. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14643. // return
  14644. // }
  14645. // var respJSON map[string]interface{}
  14646. //
  14647. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14648. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14650. // return
  14651. // }
  14652. //
  14653. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14654. // userJSONBytes, _ := json.Marshal(userJSON)
  14655. // var res ResultTwo
  14656. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14657. // utils.ErrorLog("解析失败:%v", err)
  14658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14659. // return
  14660. // }
  14661. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14662. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14663. // infoStr := string(Iinfos)
  14664. // idetinfoStr := string(Idetinfos)
  14665. //
  14666. // if res.Infcode == 0 {
  14667. // his := models.VMHisPatient{
  14668. // Status: 1,
  14669. // Ctime: time.Now().Unix(),
  14670. // Mtime: time.Now().Unix(),
  14671. // PsnNo: res.Output.Baseinfo.PsnNo,
  14672. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  14673. // Certno: res.Output.Baseinfo.Certno,
  14674. // PsnName: res.Output.Baseinfo.PsnName,
  14675. // Gend: res.Output.Baseinfo.Gend,
  14676. // Naty: res.Output.Baseinfo.Naty,
  14677. // Brdy: res.Output.Baseinfo.Brdy,
  14678. // Age: res.Output.Baseinfo.Age,
  14679. // Iinfo: infoStr,
  14680. // Idetinfo: idetinfoStr,
  14681. // PatientId: patient.ID,
  14682. // RecordDate: theTime.Unix(),
  14683. // UserOrgId: adminInfo.CurrentOrgId,
  14684. // AdminUserId: adminInfo.AdminUser.Id,
  14685. // IsReturn: 1,
  14686. // }
  14687. //
  14688. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  14689. // //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")
  14690. // //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")
  14691. //
  14692. // //var dat map[string]interface{}
  14693. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14694. // // fmt.Println(dat)
  14695. // //} else {
  14696. // // fmt.Println(err)
  14697. // //}
  14698. //
  14699. // var dat2 map[string]interface{}
  14700. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14701. // fmt.Println(dat2)
  14702. // } else {
  14703. // fmt.Println(err)
  14704. // }
  14705. //
  14706. // } else {
  14707. // adminUser := c.GetAdminUserInfo()
  14708. // errlog := &models.HisOrderError{
  14709. // UserOrgId: adminUser.CurrentOrgId,
  14710. // Ctime: time.Now().Unix(),
  14711. // Mtime: time.Now().Unix(),
  14712. // ErrMsg: res.ErrMsg,
  14713. // Status: 1,
  14714. // PatientId: id,
  14715. // RecordTime: recordDateTime,
  14716. // Stage: 1,
  14717. // }
  14718. // service.CreateErrMsgLog(errlog)
  14719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  14720. // return
  14721. // }
  14722. // }
  14723. //
  14724. //}
  14725. //func (c *HisApiController) GetUploadDiag() {
  14726. // id, _ := c.GetInt64("id")
  14727. // record_time := c.GetString("record_time")
  14728. //
  14729. // diagnosis_id, _ := c.GetInt64("diagnosis")
  14730. // sick_type, _ := c.GetInt64("sick_type")
  14731. // reg_type, _ := c.GetInt64("reg_type")
  14732. //
  14733. // timeLayout := "2006-01-02"
  14734. // loc, _ := time.LoadLocation("Local")
  14735. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14736. // if err != nil {
  14737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14738. // return
  14739. // }
  14740. //
  14741. // var patientPrescription models.HisPrescriptionInfo
  14742. // recordDateTime := theTime.Unix()
  14743. // adminInfo := c.GetAdminUserInfo()
  14744. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14745. //
  14746. // if patientPrescription.ID == 0 {
  14747. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14748. // }
  14749. //
  14750. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14751. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  14752. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14753. // sickConfig, _ := service.FindSickById(sick_type)
  14754. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14755. //
  14756. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  14757. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  14758. // "&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 +
  14759. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  14760. // resp2, requestErr2 := http.Get(api2)
  14761. // if requestErr2 != nil {
  14762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14763. // return
  14764. // }
  14765. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  14766. // if ioErr2 != nil {
  14767. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  14768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14769. // return
  14770. // }
  14771. // var respJSON2 map[string]interface{}
  14772. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  14773. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14775. // return
  14776. // }
  14777. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14778. // userJSONBytes2, _ := json.Marshal(respJSON2)
  14779. //
  14780. // var res2 ResultSix
  14781. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14782. // utils.ErrorLog("解析失败:%v", err)
  14783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14784. // return
  14785. // }
  14786. // if res2.Infcode != 0 {
  14787. // adminUser := c.GetAdminUserInfo()
  14788. // errlog := &models.HisOrderError{
  14789. // UserOrgId: adminUser.CurrentOrgId,
  14790. // Ctime: time.Now().Unix(),
  14791. // Mtime: time.Now().Unix(),
  14792. // ErrMsg: res2.ErrMsg,
  14793. // Status: 1,
  14794. // PatientId: id,
  14795. // RecordTime: recordDateTime,
  14796. // Stage: 3,
  14797. // }
  14798. // service.CreateErrMsgLog(errlog)
  14799. //
  14800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  14801. // return
  14802. // }
  14803. //
  14804. // c.ServeSuccessJSON(map[string]interface{}{
  14805. // "msg": "上传成功",
  14806. // })
  14807. //
  14808. //}
  14809. type QueryResult struct {
  14810. ID int64
  14811. Name string
  14812. Code string
  14813. List_type_code string
  14814. }
  14815. func (c *HisApiController) GetCheckCode() {
  14816. ids_str := c.GetString("ids")
  14817. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14818. ids_arr := strings.Split(ids_str, ",")
  14819. var queryResult []QueryResult
  14820. ids := make([]int64, 0)
  14821. for _, item := range ids_arr {
  14822. id, _ := strconv.ParseInt(item, 10, 64)
  14823. ids = append(ids, id)
  14824. }
  14825. if record_type == 1 {
  14826. drugs, _ := service.GetBatchDrugList(ids)
  14827. for _, item := range drugs {
  14828. result := QueryResult{
  14829. ID: item.ID,
  14830. Name: item.DrugName,
  14831. Code: item.MedicalInsuranceNumber,
  14832. List_type_code: "101",
  14833. }
  14834. queryResult = append(queryResult, result)
  14835. }
  14836. } else if record_type == 2 {
  14837. goods, _ := service.GetBatchGoodInformationList(ids)
  14838. for _, item := range goods {
  14839. result := QueryResult{
  14840. ID: item.ID,
  14841. Name: item.GoodName,
  14842. Code: item.MedicalInsuranceNumber,
  14843. List_type_code: "301",
  14844. }
  14845. queryResult = append(queryResult, result)
  14846. }
  14847. } else if record_type == 3 {
  14848. projects, _ := service.GetBathchMyPorjecgList(ids)
  14849. for _, item := range projects {
  14850. result := QueryResult{
  14851. ID: item.ID,
  14852. Name: item.ProjectName,
  14853. Code: item.MedicalCode,
  14854. List_type_code: "201",
  14855. }
  14856. queryResult = append(queryResult, result)
  14857. }
  14858. }
  14859. admin_user_id, _ := c.GetInt64("admin_user_id")
  14860. adminUser := c.GetAdminUserInfo()
  14861. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14862. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14863. var user_name string
  14864. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14865. if role.ID == 0 {
  14866. user_name = "xxx"
  14867. } else {
  14868. user_name = role.UserName
  14869. }
  14870. baseParams := &models.BaseParams{
  14871. SecretKey: miConfig.SecretKey,
  14872. FixmedinsCode: miConfig.Code,
  14873. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14874. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14875. OrgName: miConfig.OrgName,
  14876. Doctor: user_name,
  14877. }
  14878. if config.IsOpen == 1 {
  14879. for _, item := range queryResult {
  14880. var result string
  14881. if record_type == 1 {
  14882. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14883. } else if record_type == 2 {
  14884. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14885. } else if record_type == 3 {
  14886. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14887. }
  14888. var dat map[string]interface{}
  14889. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14890. fmt.Println(dat)
  14891. } else {
  14892. fmt.Println(err)
  14893. }
  14894. userJSONBytes, _ := json.Marshal(dat)
  14895. var res ResultSix
  14896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14897. utils.ErrorLog("解析失败:%v", err)
  14898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14899. return
  14900. }
  14901. if res.Infcode == 0 {
  14902. if record_type == 1 {
  14903. service.UpdateBaseDrugById(item.ID)
  14904. } else if record_type == 2 {
  14905. service.UpdateGoodInformaitonByDetail(item.ID)
  14906. } else if record_type == 3 {
  14907. service.UpdateProjectById(item.ID)
  14908. }
  14909. c.ServeSuccessJSON(map[string]interface{}{
  14910. "failed_code": 0,
  14911. "msg": "目录对照成功",
  14912. })
  14913. } else {
  14914. c.ServeSuccessJSON(map[string]interface{}{
  14915. "failed_code": -10,
  14916. "msg": res.ErrMsg,
  14917. })
  14918. }
  14919. }
  14920. }
  14921. }
  14922. func (c *HisApiController) UnCheckCode() {
  14923. ids_str := c.GetString("ids")
  14924. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14925. admin_user_id, _ := c.GetInt64("admin_user_id")
  14926. ids_arr := strings.Split(ids_str, ",")
  14927. var queryResult []QueryResult
  14928. ids := make([]int64, 0)
  14929. for _, item := range ids_arr {
  14930. id, _ := strconv.ParseInt(item, 10, 64)
  14931. ids = append(ids, id)
  14932. }
  14933. if record_type == 1 {
  14934. drugs, _ := service.GetBatchDrugList(ids)
  14935. for _, item := range drugs {
  14936. result := QueryResult{
  14937. ID: item.ID,
  14938. Name: item.DrugName,
  14939. Code: item.MedicalInsuranceNumber,
  14940. List_type_code: "101",
  14941. }
  14942. queryResult = append(queryResult, result)
  14943. }
  14944. } else if record_type == 2 {
  14945. goods, _ := service.GetBatchGoodInformationList(ids)
  14946. for _, item := range goods {
  14947. result := QueryResult{
  14948. ID: item.ID,
  14949. Name: item.GoodName,
  14950. Code: item.MedicalInsuranceNumber,
  14951. List_type_code: "301",
  14952. }
  14953. queryResult = append(queryResult, result)
  14954. }
  14955. } else if record_type == 3 {
  14956. projects, _ := service.GetBathchMyPorjecgList(ids)
  14957. for _, item := range projects {
  14958. result := QueryResult{
  14959. ID: item.ID,
  14960. Name: item.ProjectName,
  14961. Code: item.MedicalCode,
  14962. List_type_code: "201",
  14963. }
  14964. queryResult = append(queryResult, result)
  14965. }
  14966. }
  14967. adminUser := c.GetAdminUserInfo()
  14968. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14969. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14970. var user_name string
  14971. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14972. if role.ID == 0 {
  14973. user_name = "xxx"
  14974. } else {
  14975. user_name = role.UserName
  14976. }
  14977. baseParams := &models.BaseParams{
  14978. SecretKey: miConfig.SecretKey,
  14979. FixmedinsCode: miConfig.Code,
  14980. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14981. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14982. OrgName: miConfig.OrgName,
  14983. Doctor: user_name,
  14984. }
  14985. if config.IsOpen == 1 {
  14986. for _, item := range queryResult {
  14987. var result string
  14988. if record_type == 1 {
  14989. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14990. } else if record_type == 2 {
  14991. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14992. } else if record_type == 3 {
  14993. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14994. }
  14995. var dat2 map[string]interface{}
  14996. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  14997. fmt.Println(dat2)
  14998. } else {
  14999. fmt.Println(err)
  15000. }
  15001. userJSONBytes, _ := json.Marshal(dat2)
  15002. var res ResultSix
  15003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15004. utils.ErrorLog("解析失败:%v", err)
  15005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15006. return
  15007. }
  15008. if res.Infcode == 0 {
  15009. if record_type == 1 {
  15010. service.UpdateDrugByIdDetail(item.ID)
  15011. } else if record_type == 2 {
  15012. service.UpdateGoodInfoById(item.ID)
  15013. } else if record_type == 3 {
  15014. service.UpdateMyProjectById(item.ID)
  15015. }
  15016. c.ServeSuccessJSON(map[string]interface{}{
  15017. "failed_code": 0,
  15018. "msg": "撤销目录对照成功",
  15019. })
  15020. } else {
  15021. c.ServeSuccessJSON(map[string]interface{}{
  15022. "failed_code": -10,
  15023. "msg": res.ErrMsg,
  15024. })
  15025. }
  15026. }
  15027. }
  15028. }
  15029. func (c *HisApiController) GetPatientInfo() {
  15030. id_card_no := c.GetString("id_card_no")
  15031. admin_user_id, _ := c.GetInt64("admin_user_id")
  15032. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  15033. if patient.ID == 0 {
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15035. return
  15036. }
  15037. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15039. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  15040. if config.IsOpen == 1 {
  15041. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15042. var dat map[string]interface{}
  15043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15044. fmt.Println(dat)
  15045. } else {
  15046. fmt.Println(err)
  15047. }
  15048. userJSONBytes, _ := json.Marshal(dat)
  15049. var res ResultTwo
  15050. var res10265 ResultTwo10265
  15051. if miConfig.Code == "H15049901371" {
  15052. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15053. utils.ErrorLog("解析失败:%v", err)
  15054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15055. return
  15056. }
  15057. res.ErrMsg = res10265.ErrMsg
  15058. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15059. res.Infcode = infocode
  15060. res.Output = res10265.Output
  15061. res.InfRefmsgid = res10265.InfRefmsgid
  15062. } else {
  15063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15064. utils.ErrorLog("解析失败:%v", err)
  15065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15066. return
  15067. }
  15068. }
  15069. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15070. // utils.ErrorLog("解析失败:%v", err)
  15071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15072. // return
  15073. //}
  15074. for index, item := range res.Output.Iinfo {
  15075. if item.PsnInsuStas == "2" {
  15076. fmt.Println("--------")
  15077. res.Output.Iinfo[index].Insutype = "300"
  15078. res.Output.Iinfo[index].PsnInsuStas = "1"
  15079. }
  15080. }
  15081. fmt.Println(res.Output.Iinfo)
  15082. if res.Infcode != 0 {
  15083. c.ServeSuccessJSON(map[string]interface{}{
  15084. "failed_code": -10,
  15085. "msg": res.ErrMsg,
  15086. })
  15087. } else {
  15088. c.ServeSuccessJSON(map[string]interface{}{
  15089. "failed_code": 0,
  15090. "info": res,
  15091. })
  15092. }
  15093. }
  15094. }
  15095. func (c *HisApiController) PsnPutOnRecord() {
  15096. record_type, _ := c.GetInt64("type")
  15097. patient_id, _ := c.GetInt64("patient_id")
  15098. admin_user_id, _ := c.GetInt64("admin_user_id")
  15099. start_time := c.GetString("start_time")
  15100. end_time := c.GetString("end_time")
  15101. adminUser := c.GetAdminUserInfo()
  15102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15103. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15104. var patients []*models.Patients
  15105. if record_type == 1 { //全部备案
  15106. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  15107. patients = append(patients, patient...)
  15108. } else { //单个备案
  15109. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15110. patients = append(patients, patient)
  15111. }
  15112. var user_name string
  15113. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15114. if role.ID == 0 {
  15115. user_name = "xxx"
  15116. } else {
  15117. user_name = role.UserName
  15118. }
  15119. if config.IsOpen == 1 {
  15120. for _, item := range patients {
  15121. 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
  15122. resp, requestErr := http.Get(api)
  15123. if requestErr != nil {
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15125. return
  15126. }
  15127. defer resp.Body.Close()
  15128. body, ioErr := ioutil.ReadAll(resp.Body)
  15129. if ioErr != nil {
  15130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15132. return
  15133. }
  15134. var respJSON map[string]interface{}
  15135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15138. return
  15139. }
  15140. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15141. userJSONBytes, _ := json.Marshal(userJSON)
  15142. var res ResultTwo
  15143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15144. utils.ErrorLog("解析失败:%v", err)
  15145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. return
  15147. }
  15148. if res.Infcode == 0 {
  15149. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  15150. var dat map[string]interface{}
  15151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15152. fmt.Println(dat)
  15153. } else {
  15154. fmt.Println(err)
  15155. }
  15156. userJSONBytes, _ := json.Marshal(dat)
  15157. var res2 ResultThirteen
  15158. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15159. utils.ErrorLog("解析失败:%v", err)
  15160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15161. return
  15162. }
  15163. if res2.Infcode == 0 {
  15164. psnResult := &models.GdybPsnRecord{
  15165. UserOrgId: adminUser.CurrentOrgId,
  15166. PatientId: item.ID,
  15167. PsnNo: res.Output.Baseinfo.PsnNo,
  15168. Ctime: time.Now().Unix(),
  15169. Mtime: time.Now().Unix(),
  15170. Status: 1,
  15171. IsCancel: 1,
  15172. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15173. }
  15174. service.CreatePsnRecord(psnResult)
  15175. } else {
  15176. c.ServeSuccessJSON(map[string]interface{}{
  15177. "failed_code": -10,
  15178. "msg": res2.ErrMsg,
  15179. })
  15180. return
  15181. }
  15182. }
  15183. }
  15184. }
  15185. }
  15186. func (c *HisApiController) PsnUnPutOnRecord() {
  15187. id, _ := c.GetInt64("id")
  15188. //record_type, _ := c.GetInt64("type")
  15189. admin_user_id, _ := c.GetInt64("admin_user_id")
  15190. adminUser := c.GetAdminUserInfo()
  15191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15192. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15193. var user_name string
  15194. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15195. if role.ID == 0 {
  15196. user_name = "xxx"
  15197. } else {
  15198. user_name = role.UserName
  15199. }
  15200. psn_record, _ := service.GetPsnRecordById(id)
  15201. if psn_record.ID == 0 {
  15202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15203. return
  15204. }
  15205. if config.IsOpen == 1 {
  15206. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15207. var dat map[string]interface{}
  15208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15209. fmt.Println(dat)
  15210. } else {
  15211. fmt.Println(err)
  15212. }
  15213. userJSONBytes, _ := json.Marshal(dat)
  15214. var res ResultFourteen
  15215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15216. utils.ErrorLog("解析失败:%v", err)
  15217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15218. return
  15219. }
  15220. if res.Infcode == 0 {
  15221. psn_record.IsCancel = 2
  15222. service.CreatePsnRecord(&psn_record)
  15223. } else {
  15224. c.ServeSuccessJSON(map[string]interface{}{
  15225. "failed_code": -10,
  15226. "msg": res.ErrMsg,
  15227. })
  15228. return
  15229. }
  15230. }
  15231. }
  15232. func (c *HisApiController) PsnPutNCDSOnRecord() {
  15233. patient_id, _ := c.GetInt64("patient_id")
  15234. insutype_two := c.GetString("insutype")
  15235. psn_no := c.GetString("psn_no")
  15236. doctor_id, _ := c.GetInt64("doctor_id")
  15237. sick_id, _ := c.GetInt64("sick_id")
  15238. department_id, _ := c.GetInt64("department_id")
  15239. start_time := c.GetString("start_time")
  15240. end_time := c.GetString("end_time")
  15241. check_time := c.GetString("check_time")
  15242. hospital_code := c.GetString("hospital_code")
  15243. hospital_name := c.GetString("hospital_name")
  15244. adminUser := c.GetAdminUserInfo()
  15245. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15247. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15248. sick, _ := service.FindSickById(sick_id)
  15249. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15250. if len(hospital_code) == 0 {
  15251. hospital_code = miConfig.Code
  15252. }
  15253. if len(hospital_name) == 0 {
  15254. hospital_name = miConfig.OrgName
  15255. }
  15256. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15257. var res ResultTwo
  15258. var res10265 ResultTwo10265
  15259. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15260. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  15261. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  15262. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  15263. "&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
  15264. resp, requestErr := http.Get(api)
  15265. if requestErr != nil {
  15266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15267. return
  15268. }
  15269. body, ioErr := ioutil.ReadAll(resp.Body)
  15270. if ioErr != nil {
  15271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15273. return
  15274. }
  15275. var respJSON map[string]interface{}
  15276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15279. return
  15280. }
  15281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15282. result, _ := json.Marshal(respJSON)
  15283. fmt.Println("log")
  15284. fmt.Println(string(result))
  15285. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15286. utils.ErrorLog("解析失败:%v", err)
  15287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15288. return
  15289. }
  15290. res.ErrMsg = res10265.ErrMsg
  15291. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15292. res.Infcode = infocode
  15293. res.Output = res10265.Output
  15294. res.InfRefmsgid = res10265.InfRefmsgid
  15295. } else {
  15296. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15297. if miConfig.Code == "H15049901371" {
  15298. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15299. utils.ErrorLog("解析失败:%v", err)
  15300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15301. return
  15302. }
  15303. res.ErrMsg = res10265.ErrMsg
  15304. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15305. res.Infcode = infocode
  15306. res.Output = res10265.Output
  15307. res.InfRefmsgid = res10265.InfRefmsgid
  15308. } else {
  15309. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15310. utils.ErrorLog("解析失败:%v", err)
  15311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15312. return
  15313. }
  15314. }
  15315. }
  15316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15317. infoStr := string(Iinfos)
  15318. var rf []*ResultFive
  15319. json.Unmarshal([]byte(infoStr), &rf)
  15320. var insuplc_admdvs string
  15321. var insutype string
  15322. var is390 int = 0
  15323. var is310 int = 0
  15324. var insutypes []*ResultFive
  15325. for _, item := range rf {
  15326. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15327. insutypes = append(insutypes, item)
  15328. }
  15329. }
  15330. if len(insutypes) == 1 {
  15331. insutype = insutypes[0].Insutype
  15332. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15333. } else {
  15334. for _, i := range insutypes {
  15335. if i.Insutype == "390" {
  15336. is390 = 1
  15337. }
  15338. if i.Insutype == "310" {
  15339. is310 = 1
  15340. }
  15341. }
  15342. }
  15343. if is390 == 1 {
  15344. insutype = "390"
  15345. }
  15346. if is310 == 1 {
  15347. insutype = "310"
  15348. }
  15349. if len(insutypes) == 2 {
  15350. insutype = insutype_two
  15351. }
  15352. if len(insutypes) == 0 {
  15353. insutype = "310"
  15354. }
  15355. insutype = insutype_two
  15356. fmt.Println(insutype)
  15357. for _, item := range rf {
  15358. fmt.Println(item.Insutype)
  15359. fmt.Println(insutype)
  15360. if item.Insutype == insutype {
  15361. fmt.Println(item.Insutype)
  15362. fmt.Println(insutype)
  15363. insuplc_admdvs = item.InsuplcAdmdvs
  15364. }
  15365. }
  15366. fmt.Println(insuplc_admdvs)
  15367. var res2 ResultThirteen
  15368. var res10265_2 ResultThirteen10265
  15369. if config.IsOpen == 1 {
  15370. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15371. } else {
  15372. 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)
  15373. var dat map[string]interface{}
  15374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15375. fmt.Println(dat)
  15376. } else {
  15377. fmt.Println(err)
  15378. }
  15379. userJSONBytes, _ := json.Marshal(dat)
  15380. if miConfig.Code == "H15049901371" {
  15381. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  15382. utils.ErrorLog("解析失败:%v", err)
  15383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15384. return
  15385. }
  15386. res2.ErrMsg = res10265_2.ErrMsg
  15387. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  15388. res2.Infcode = infocode
  15389. res2.Output = res10265_2.Output
  15390. res2.InfRefmsgid = res10265_2.InfRefmsgid
  15391. } else {
  15392. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15393. utils.ErrorLog("解析失败:%v", err)
  15394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15395. return
  15396. }
  15397. }
  15398. }
  15399. if res2.Infcode == 0 {
  15400. psnResult := &models.GdybPsnNcdsRecord{
  15401. UserOrgId: adminUser.CurrentOrgId,
  15402. PatientId: patient.ID,
  15403. PsnNo: psn_no,
  15404. DoctorId: doctor.AdminUserId,
  15405. DepartmentId: department_id,
  15406. SickType: sick_id,
  15407. Insutype: insutype,
  15408. Ctime: time.Now().Unix(),
  15409. Mtime: time.Now().Unix(),
  15410. Status: 1,
  15411. IsCancel: 1,
  15412. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15413. }
  15414. service.CreatePsnNCDSRecord(psnResult)
  15415. c.ServeSuccessJSON(map[string]interface{}{
  15416. "failed_code": 0,
  15417. "msg": "备案成功",
  15418. "result": psnResult,
  15419. })
  15420. } else {
  15421. c.ServeSuccessJSON(map[string]interface{}{
  15422. "failed_code": -10,
  15423. "msg": res2.ErrMsg,
  15424. })
  15425. return
  15426. }
  15427. }
  15428. }
  15429. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  15430. id, _ := c.GetInt64("id")
  15431. admin_user_id, _ := c.GetInt64("admin_user_id")
  15432. adminUser := c.GetAdminUserInfo()
  15433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15434. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15435. //config, _ := service.Ge(adminUser.CurrentOrgId)
  15436. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  15437. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15438. //var user_name string
  15439. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15440. //if role.ID == 0 {
  15441. // user_name = "xxx"
  15442. //} else {
  15443. // user_name = role.UserName
  15444. //}
  15445. psn_record, _ := service.GetPsnNCDSRecordById(id)
  15446. if psn_record.ID == 0 {
  15447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15448. return
  15449. }
  15450. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15451. var res ResultTwo
  15452. var res10265 ResultTwo10265
  15453. if miConfig.Code == "H15049901371" {
  15454. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15455. utils.ErrorLog("解析失败:%v", err)
  15456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15457. return
  15458. }
  15459. res.ErrMsg = res10265.ErrMsg
  15460. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15461. res.Infcode = infocode
  15462. res.Output = res10265.Output
  15463. res.InfRefmsgid = res10265.InfRefmsgid
  15464. } else {
  15465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15466. utils.ErrorLog("解析失败:%v", err)
  15467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15468. return
  15469. }
  15470. }
  15471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15472. infoStr := string(Iinfos)
  15473. var rf []*ResultFive
  15474. json.Unmarshal([]byte(infoStr), &rf)
  15475. var insuplc_admdvs string
  15476. var insutype string
  15477. var is390 int = 0
  15478. var is310 int = 0
  15479. var insutypes []*ResultFive
  15480. for _, item := range rf {
  15481. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15482. insutypes = append(insutypes, item)
  15483. }
  15484. }
  15485. if len(insutypes) == 1 {
  15486. insutype = insutypes[0].Insutype
  15487. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15488. } else {
  15489. for _, i := range insutypes {
  15490. if i.Insutype == "390" {
  15491. is390 = 1
  15492. }
  15493. if i.Insutype == "310" {
  15494. is310 = 1
  15495. }
  15496. }
  15497. }
  15498. if is390 == 1 {
  15499. insutype = "390"
  15500. }
  15501. if is310 == 1 {
  15502. insutype = "310"
  15503. }
  15504. if len(insutypes) == 0 {
  15505. insutype = "310"
  15506. }
  15507. insutype = psn_record.Insutype
  15508. for _, item := range rf {
  15509. if item.Insutype == insutype {
  15510. insuplc_admdvs = item.InsuplcAdmdvs
  15511. }
  15512. }
  15513. if config.IsOpen == 1 {
  15514. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15515. var dat map[string]interface{}
  15516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15517. fmt.Println(dat)
  15518. } else {
  15519. fmt.Println(err)
  15520. }
  15521. userJSONBytes, _ := json.Marshal(dat)
  15522. var res ResultFourteen
  15523. var res10265 ResultFourteen10265
  15524. if miConfig.Code == "H15049901371" {
  15525. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15526. utils.ErrorLog("解析失败:%v", err)
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15528. return
  15529. }
  15530. res.ErrMsg = res10265.ErrMsg
  15531. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15532. res.Infcode = infocode
  15533. res.Output = res10265.Output
  15534. res.InfRefmsgid = res10265.InfRefmsgid
  15535. } else {
  15536. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15537. utils.ErrorLog("解析失败:%v", err)
  15538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15539. return
  15540. }
  15541. }
  15542. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15543. // utils.ErrorLog("解析失败:%v", err)
  15544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15545. // return
  15546. //}
  15547. if res.Infcode == 0 {
  15548. psn_record.IsCancel = 2
  15549. service.CreatePsnNCDSRecord(&psn_record)
  15550. c.ServeSuccessJSON(map[string]interface{}{
  15551. "failed_code": 0,
  15552. "msg": "撤销备案成功",
  15553. })
  15554. } else {
  15555. c.ServeSuccessJSON(map[string]interface{}{
  15556. "failed_code": -10,
  15557. "msg": res.ErrMsg,
  15558. })
  15559. return
  15560. }
  15561. }
  15562. }
  15563. func (c *HisApiController) TestTest() {
  15564. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  15565. fmt.Println(patient.Iinfo)
  15566. }
  15567. type CustomData struct {
  15568. MsgId string
  15569. PsnNo string
  15570. Info string
  15571. }
  15572. func (c *HisApiController) ReversalData() {
  15573. var customData []*CustomData
  15574. custom := &CustomData{
  15575. MsgId: "H44022900158202103301714472004",
  15576. PsnNo: "44020000001101329945",
  15577. Info: "2207",
  15578. }
  15579. customData = append(customData, custom)
  15580. custom1 := &CustomData{
  15581. MsgId: "H4402290015820210330172057803",
  15582. PsnNo: "44020000001101161813",
  15583. Info: "2207",
  15584. }
  15585. customData = append(customData, custom1)
  15586. custom2 := &CustomData{
  15587. MsgId: "H44022900158202103301705198813",
  15588. PsnNo: "44190000133097375417",
  15589. Info: "2207",
  15590. }
  15591. customData = append(customData, custom2)
  15592. custom3 := &CustomData{
  15593. MsgId: "H44022900158202103301715524756",
  15594. PsnNo: "44020000001100187221",
  15595. Info: "2207",
  15596. }
  15597. customData = append(customData, custom3)
  15598. custom4 := &CustomData{
  15599. MsgId: "H44022900158202103301730376224",
  15600. PsnNo: "44020000001101959155",
  15601. Info: "2207",
  15602. }
  15603. customData = append(customData, custom4)
  15604. custom5 := &CustomData{
  15605. MsgId: "H44022900158202103301748008725",
  15606. PsnNo: "44020000001104246641",
  15607. Info: "2207",
  15608. }
  15609. customData = append(customData, custom5)
  15610. custom6 := &CustomData{
  15611. MsgId: "H44022900158202103301718096755",
  15612. PsnNo: "44020000001102211860",
  15613. Info: "2207",
  15614. }
  15615. customData = append(customData, custom6)
  15616. custom7 := &CustomData{
  15617. MsgId: "H44022900158202103301736551640",
  15618. PsnNo: "44020000001102687718",
  15619. Info: "2207",
  15620. }
  15621. customData = append(customData, custom7)
  15622. custom8 := &CustomData{
  15623. MsgId: "H44022900158202103301743097676",
  15624. PsnNo: "44020000001102127785",
  15625. Info: "2207",
  15626. }
  15627. customData = append(customData, custom8)
  15628. custom9 := &CustomData{
  15629. MsgId: "H44022900158202103301712304203",
  15630. PsnNo: "44020000001101518097",
  15631. Info: "2207",
  15632. }
  15633. customData = append(customData, custom9)
  15634. custom10 := &CustomData{
  15635. MsgId: "H44022900158202103301738448785",
  15636. PsnNo: "44020000001100500813",
  15637. Info: "2207",
  15638. }
  15639. customData = append(customData, custom10)
  15640. custom11 := &CustomData{
  15641. MsgId: "H44022900158202103301732455843",
  15642. PsnNo: "44020000001102690557",
  15643. Info: "2207",
  15644. }
  15645. customData = append(customData, custom11)
  15646. custom12 := &CustomData{
  15647. MsgId: "H44022900158202103301745421708",
  15648. PsnNo: "44020000001102211928",
  15649. Info: "2207",
  15650. }
  15651. customData = append(customData, custom12)
  15652. custom1212 := &CustomData{
  15653. MsgId: "H440229001582021033017351627",
  15654. PsnNo: "44020000001102481733",
  15655. Info: "2207",
  15656. }
  15657. customData = append(customData, custom1212)
  15658. custom13 := &CustomData{
  15659. MsgId: "H44022900158202103301740327951",
  15660. PsnNo: "44020000001103174866",
  15661. Info: "2207",
  15662. }
  15663. customData = append(customData, custom13)
  15664. custom14 := &CustomData{
  15665. MsgId: "H4402290015820210330174922668",
  15666. PsnNo: "44020000001102927272",
  15667. Info: "2207",
  15668. }
  15669. customData = append(customData, custom14)
  15670. custom15 := &CustomData{
  15671. MsgId: "H44022900158202103301752362273",
  15672. PsnNo: "44020000001102942890",
  15673. Info: "2207",
  15674. }
  15675. customData = append(customData, custom15)
  15676. custom16 := &CustomData{
  15677. MsgId: "H44022900158202103301751082917",
  15678. PsnNo: "44020000001101662162",
  15679. Info: "2207",
  15680. }
  15681. customData = append(customData, custom16)
  15682. custom17 := &CustomData{
  15683. MsgId: "H44022900158202103301754147728",
  15684. PsnNo: "44020000000229014511",
  15685. Info: "2207",
  15686. }
  15687. customData = append(customData, custom17)
  15688. adminUser := c.GetAdminUserInfo()
  15689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15690. for _, item := range customData {
  15691. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  15692. fmt.Println(result)
  15693. }
  15694. }
  15695. func (c *HisApiController) GetAllopatry() {
  15696. year := c.GetString("year")
  15697. month := c.GetString("month")
  15698. admin_user_id, _ := c.GetInt64("admin_user_id")
  15699. adminUser := c.GetAdminUserInfo()
  15700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15701. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15702. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15703. var dat map[string]interface{}
  15704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15705. fmt.Println(dat)
  15706. } else {
  15707. fmt.Println(err)
  15708. }
  15709. userJSONBytes, _ := json.Marshal(dat)
  15710. var res models.Result9001
  15711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15712. utils.ErrorLog("解析失败:%v", err)
  15713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15714. return
  15715. }
  15716. fmt.Println(res.Output.Signinoutb)
  15717. fmt.Println(res.Output.Signinoutb.SignNo)
  15718. fmt.Println(string(userJSONBytes))
  15719. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15720. var dat3 map[string]interface{}
  15721. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  15722. fmt.Println(dat3)
  15723. } else {
  15724. fmt.Println(err)
  15725. }
  15726. userJSONBytes3, _ := json.Marshal(dat3)
  15727. var res3 models.Result3260
  15728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  15729. utils.ErrorLog("解析失败:%v", err)
  15730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15731. return
  15732. }
  15733. var curpage int
  15734. var pagesize int = 100
  15735. var start int = 1
  15736. //var stop int
  15737. //pagecount := 10
  15738. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  15739. for curpage = 1; curpage <= pagecount; curpage++ {
  15740. if curpage == 1 {
  15741. start = 0
  15742. } else {
  15743. start = (curpage-1)*pagesize + 1
  15744. }
  15745. //stop = curpage * pagesize
  15746. //if stop > int(res3.Output.Totalrow) {
  15747. // stop =int(res3.Output.Totalrow)
  15748. //}
  15749. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  15750. var dat2 map[string]interface{}
  15751. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15752. fmt.Println(dat)
  15753. } else {
  15754. fmt.Println(err)
  15755. }
  15756. userJSONBytes2, _ := json.Marshal(dat2)
  15757. var res2 models.Result3260
  15758. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15759. utils.ErrorLog("解析失败:%v", err)
  15760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15761. return
  15762. }
  15763. //if res2.Infcode == 0 {
  15764. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15765. // //var dat2 map[string]interface{}
  15766. // //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  15767. // // fmt.Println(dat)
  15768. // //} else {
  15769. // // fmt.Println(err)
  15770. // //}
  15771. // //c.ServeSuccessJSON(map[string]interface{}{
  15772. // // "list": res2.Output.Data,
  15773. // //})
  15774. // //return
  15775. //}
  15776. }
  15777. }
  15778. func (c *HisApiController) ComfirmAllopatry() {
  15779. year := c.GetString("year")
  15780. month := c.GetString("month")
  15781. admin_user_id, _ := c.GetInt64("admin_user_id")
  15782. adminUser := c.GetAdminUserInfo()
  15783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15784. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15785. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15786. var dat map[string]interface{}
  15787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15788. fmt.Println(dat)
  15789. } else {
  15790. fmt.Println(err)
  15791. }
  15792. userJSONBytes, _ := json.Marshal(dat)
  15793. var res models.Result9001
  15794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15795. utils.ErrorLog("解析失败:%v", err)
  15796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15797. return
  15798. }
  15799. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15800. var dat2 map[string]interface{}
  15801. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15802. fmt.Println(dat)
  15803. } else {
  15804. fmt.Println(err)
  15805. }
  15806. userJSONBytes2, _ := json.Marshal(dat2)
  15807. var res2 models.Result3260
  15808. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15809. utils.ErrorLog("解析失败:%v", err)
  15810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15811. return
  15812. }
  15813. //if res2.Infcode == 0 {
  15814. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15815. // var dat map[string]interface{}
  15816. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15817. // fmt.Println(dat)
  15818. // } else {
  15819. // fmt.Println(err)
  15820. // }
  15821. // userJSONBytes, _ := json.Marshal(dat)
  15822. // var res3 models.Result3261
  15823. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  15824. // utils.ErrorLog("解析失败:%v", err)
  15825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15826. // return
  15827. // }
  15828. //
  15829. // if res3.Infcode == 0 {
  15830. // record := &models.HisYidiClearRecord{
  15831. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15832. // Ctime: time.Now().Unix(),
  15833. // Mtime: time.Now().Unix(),
  15834. // Status: 1,
  15835. // MsgId: msgId,
  15836. // }
  15837. // service.SaveClearRecord(record)
  15838. // c.ServeSuccessJSON(map[string]interface{}{
  15839. // "msg": "提取成功",
  15840. // })
  15841. // }
  15842. //}
  15843. }
  15844. func (c *HisApiController) RefundAllopatry() {
  15845. year := c.GetString("year")
  15846. month := c.GetString("month")
  15847. //id, _ := c.GetInt64("id")
  15848. admin_user_id, _ := c.GetInt64("admin_user_id")
  15849. adminUser := c.GetAdminUserInfo()
  15850. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15851. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15852. //record, _ := service.GetClearRecordById(id)
  15853. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15854. var dat map[string]interface{}
  15855. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15856. fmt.Println(dat)
  15857. } else {
  15858. fmt.Println(err)
  15859. }
  15860. userJSONBytes, _ := json.Marshal(dat)
  15861. var res models.Result9001
  15862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15863. utils.ErrorLog("解析失败:%v", err)
  15864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15865. return
  15866. }
  15867. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  15868. var dat2 map[string]interface{}
  15869. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  15870. fmt.Println(dat)
  15871. } else {
  15872. fmt.Println(err)
  15873. }
  15874. userJSONBytes2, _ := json.Marshal(dat2)
  15875. var empty ResultFourteen
  15876. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  15877. utils.ErrorLog("解析失败:%v", err)
  15878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15879. return
  15880. }
  15881. if empty.Infcode == 0 {
  15882. c.ServeSuccessJSON(map[string]interface{}{
  15883. "msg": "撤销成功",
  15884. })
  15885. return
  15886. }
  15887. }
  15888. func (c *HisApiController) ReversalOtherData() {
  15889. var customData []*CustomData
  15890. custom := &CustomData{
  15891. MsgId: "H44022900158202103301714472004",
  15892. PsnNo: "44020000001101329945",
  15893. Info: "2208",
  15894. }
  15895. customData = append(customData, custom)
  15896. custom1 := &CustomData{
  15897. MsgId: "H4402290015820210330172057803",
  15898. PsnNo: "44020000001101161813",
  15899. Info: "2208",
  15900. }
  15901. customData = append(customData, custom1)
  15902. custom2 := &CustomData{
  15903. MsgId: "H44022900158202103301705198813",
  15904. PsnNo: "44190000133097375417",
  15905. Info: "2208",
  15906. }
  15907. customData = append(customData, custom2)
  15908. custom3 := &CustomData{
  15909. MsgId: "H44022900158202103301715524756",
  15910. PsnNo: "44020000001100187221",
  15911. Info: "2208",
  15912. }
  15913. customData = append(customData, custom3)
  15914. custom4 := &CustomData{
  15915. MsgId: "H44022900158202103301730376224",
  15916. PsnNo: "44020000001101959155",
  15917. Info: "2208",
  15918. }
  15919. customData = append(customData, custom4)
  15920. custom5 := &CustomData{
  15921. MsgId: "H44022900158202103301748008725",
  15922. PsnNo: "44020000001104246641",
  15923. Info: "2208",
  15924. }
  15925. customData = append(customData, custom5)
  15926. custom6 := &CustomData{
  15927. MsgId: "H44022900158202103301718096755",
  15928. PsnNo: "44020000001102211860",
  15929. Info: "2208",
  15930. }
  15931. customData = append(customData, custom6)
  15932. custom7 := &CustomData{
  15933. MsgId: "H44022900158202103301736551640",
  15934. PsnNo: "44020000001102687718",
  15935. Info: "2208",
  15936. }
  15937. customData = append(customData, custom7)
  15938. custom8 := &CustomData{
  15939. MsgId: "H44022900158202103301743097676",
  15940. PsnNo: "44020000001102127785",
  15941. Info: "2208",
  15942. }
  15943. customData = append(customData, custom8)
  15944. custom9 := &CustomData{
  15945. MsgId: "H44022900158202103301712304203",
  15946. PsnNo: "44020000001101518097",
  15947. Info: "2208",
  15948. }
  15949. customData = append(customData, custom9)
  15950. custom10 := &CustomData{
  15951. MsgId: "H44022900158202103301738448785",
  15952. PsnNo: "44020000001100500813",
  15953. Info: "2208",
  15954. }
  15955. customData = append(customData, custom10)
  15956. custom11 := &CustomData{
  15957. MsgId: "H44022900158202103301732455843",
  15958. PsnNo: "44020000001102690557",
  15959. Info: "2208",
  15960. }
  15961. customData = append(customData, custom11)
  15962. custom12 := &CustomData{
  15963. MsgId: "H44022900158202103301745421708",
  15964. PsnNo: "44020000001102211928",
  15965. Info: "2208",
  15966. }
  15967. customData = append(customData, custom12)
  15968. custom1212 := &CustomData{
  15969. MsgId: "H440229001582021033017351627",
  15970. PsnNo: "44020000001102481733",
  15971. Info: "2208",
  15972. }
  15973. customData = append(customData, custom1212)
  15974. custom13 := &CustomData{
  15975. MsgId: "H44022900158202103301740327951",
  15976. PsnNo: "44020000001103174866",
  15977. Info: "2208",
  15978. }
  15979. customData = append(customData, custom13)
  15980. custom14 := &CustomData{
  15981. MsgId: "H4402290015820210330174922668",
  15982. PsnNo: "44020000001102927272",
  15983. Info: "2208",
  15984. }
  15985. customData = append(customData, custom14)
  15986. custom15 := &CustomData{
  15987. MsgId: "H44022900158202103301752362273",
  15988. PsnNo: "44020000001102942890",
  15989. Info: "2208",
  15990. }
  15991. customData = append(customData, custom15)
  15992. custom16 := &CustomData{
  15993. MsgId: "H44022900158202103301751082917",
  15994. PsnNo: "44020000001101662162",
  15995. Info: "2208",
  15996. }
  15997. customData = append(customData, custom16)
  15998. custom17 := &CustomData{
  15999. MsgId: "H44022900158202103301754147728",
  16000. PsnNo: "44020000000229014511",
  16001. Info: "2208",
  16002. }
  16003. customData = append(customData, custom17)
  16004. adminUser := c.GetAdminUserInfo()
  16005. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16006. for _, item := range customData {
  16007. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16008. fmt.Println(result)
  16009. }
  16010. }
  16011. func PathExists(path string) (bool, error) {
  16012. _, err := os.Stat(path)
  16013. if err == nil {
  16014. return true, nil
  16015. }
  16016. if os.IsNotExist(err) {
  16017. return false, nil
  16018. }
  16019. return false, err
  16020. }
  16021. // 创建文件夹
  16022. func Mkdir(dir string) {
  16023. // 创建文件夹
  16024. exist, err := PathExists(dir)
  16025. if err != nil {
  16026. fmt.Println(err.Error())
  16027. } else {
  16028. if exist {
  16029. fmt.Println(dir + "文件夹已存在!")
  16030. } else {
  16031. // 文件夹名称,权限
  16032. err := os.Mkdir(dir, os.ModePerm)
  16033. if err != nil {
  16034. fmt.Println(dir+"文件夹创建失败:", err.Error())
  16035. } else {
  16036. fmt.Println(dir + "文件夹创建成功!")
  16037. }
  16038. }
  16039. }
  16040. }
  16041. // 压缩文件
  16042. func Zip(srcFile string, destZip string) error {
  16043. zipfile, err := os.Create(destZip)
  16044. if err != nil {
  16045. return err
  16046. }
  16047. defer zipfile.Close()
  16048. archive := zip.NewWriter(zipfile)
  16049. defer archive.Close()
  16050. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  16051. if err != nil {
  16052. return err
  16053. }
  16054. header, err := zip.FileInfoHeader(info)
  16055. if err != nil {
  16056. return err
  16057. }
  16058. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  16059. // header.Name = path
  16060. if info.IsDir() {
  16061. header.Name += "/"
  16062. } else {
  16063. header.Method = zip.Deflate
  16064. }
  16065. writer, err := archive.CreateHeader(header)
  16066. if err != nil {
  16067. return err
  16068. }
  16069. if !info.IsDir() {
  16070. file, err := os.Open(path)
  16071. if err != nil {
  16072. return err
  16073. }
  16074. defer file.Close()
  16075. _, err = io.Copy(writer, file)
  16076. }
  16077. return err
  16078. })
  16079. return err
  16080. }
  16081. func ReadFile(filePath string) []byte {
  16082. f, err := os.Open(filePath)
  16083. if err != nil {
  16084. fmt.Println("read file fail", err)
  16085. return nil
  16086. }
  16087. defer f.Close()
  16088. fd, err := ioutil.ReadAll(f)
  16089. if err != nil {
  16090. fmt.Println("read to fd fail", err)
  16091. return nil
  16092. }
  16093. return fd
  16094. }
  16095. func saveLog(result string, request string, infno string, desc string) {
  16096. org_id, _ := beego.AppConfig.Int64("org_id")
  16097. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16098. dir := miConfig.OrgName + "日志"
  16099. utils.Mkdir(dir)
  16100. month := time.Unix(1557042972, 0).Format("1")
  16101. year := time.Now().Format("2006")
  16102. month = time.Now().Format("01")
  16103. day := time.Now().Format("02")
  16104. hour := time.Now().Format("15")
  16105. min := time.Now().Format("04")
  16106. sec := time.Now().Format("05")
  16107. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  16108. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  16109. file_name := file + ".txt"
  16110. file_path := miConfig.OrgName + "日志" + "/" + file_name
  16111. exist, _ := utils.PathExists(file_path)
  16112. if exist { //存在
  16113. fmt.Println("存在")
  16114. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  16115. if err != nil {
  16116. fmt.Println("read fail")
  16117. }
  16118. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  16119. n, _ := f.Seek(0, 2)
  16120. _, err = f.WriteAt([]byte(content), n)
  16121. } else { //不存在
  16122. fmt.Println("文件不存在,创建文件")
  16123. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  16124. defer f.Close()
  16125. if err != nil {
  16126. } else {
  16127. _, err = f.Write([]byte("记录日志"))
  16128. }
  16129. }
  16130. }
  16131. type Charset string
  16132. const (
  16133. UTF8 = Charset("UTF-8")
  16134. GB18030 = Charset("GB18030")
  16135. )
  16136. func ConvertToString(src string, srcCode string, tagCode string) string {
  16137. srcCoder := mahonia.NewDecoder(srcCode)
  16138. srcResult := srcCoder.ConvertString(src)
  16139. tagCoder := mahonia.NewDecoder(tagCode)
  16140. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  16141. result := string(cdata)
  16142. return result
  16143. }
  16144. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  16145. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  16146. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16147. var token string
  16148. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16149. var api string
  16150. if miConfig.MdtrtareaAdmvs == "320921" {
  16151. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16152. "&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
  16153. fmt.Println(api)
  16154. } else {
  16155. 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 +
  16156. "&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
  16157. }
  16158. resp, requestErr := http.Get(api)
  16159. if requestErr != nil {
  16160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16161. return ""
  16162. }
  16163. body, ioErr := ioutil.ReadAll(resp.Body)
  16164. if ioErr != nil {
  16165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16167. return ""
  16168. }
  16169. var respJSON map[string]interface{}
  16170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16173. return ""
  16174. }
  16175. var status string
  16176. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16177. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16178. var res ResultTwo //1101结果
  16179. var res10265 ResultTwo10265 //1101结果
  16180. if status == "0" { //读卡成功
  16181. var card_info string //卡信息
  16182. var busi_card_info string
  16183. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16184. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16185. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16186. fmt.Println(card_info)
  16187. fmt.Println(busi_card_info)
  16188. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16189. result, _ := json.Marshal(respJSON)
  16190. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16191. utils.ErrorLog("解析失败:%v", err)
  16192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16193. return ""
  16194. }
  16195. res.ErrMsg = res10265.ErrMsg
  16196. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16197. res.Infcode = infocode
  16198. res.Output = res10265.Output
  16199. res.InfRefmsgid = res10265.InfRefmsgid
  16200. if res.Infcode == 0 {
  16201. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16202. if err == gorm.ErrRecordNotFound {
  16203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16204. return ""
  16205. } else if err != nil {
  16206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16207. return ""
  16208. } else {
  16209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16211. infoStr := string(Iinfos)
  16212. idetinfoStr := string(Idetinfos)
  16213. psn := &models.HisPsn{
  16214. PsnNo: res.Output.Baseinfo.PsnNo,
  16215. Age: res.Output.Baseinfo.Age,
  16216. PatientId: patient.ID,
  16217. Certno: res.Output.Baseinfo.Certno,
  16218. Brdy: res.Output.Baseinfo.Brdy,
  16219. Gend: res.Output.Baseinfo.Gend,
  16220. Naty: res.Output.Baseinfo.Naty,
  16221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16222. PsnName: res.Output.Baseinfo.PsnName,
  16223. Idetinfo: idetinfoStr,
  16224. Insuinfo: infoStr,
  16225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16226. CardInfo: card_info,
  16227. VerifyNumber: token,
  16228. }
  16229. service.CreateHisPsn(psn)
  16230. return token
  16231. }
  16232. }
  16233. } else {
  16234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16235. return ""
  16236. }
  16237. } else { //读卡失败
  16238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16239. return ""
  16240. }
  16241. return token
  16242. }
  16243. func DeleteExtraSpaceTwo(s string) string {
  16244. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16245. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16246. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16247. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16248. s2 := make([]byte, len(s1)) //定义字符数组切片
  16249. copy(s2, s1) //将字符串复制到切片
  16250. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16251. for len(spc_index) > 0 { //找到适配项
  16252. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16253. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16254. }
  16255. return string(s2)
  16256. }
  16257. func Remove0000(s string) string {
  16258. str := make([]rune, 0, len(s))
  16259. for _, v := range []rune(s) {
  16260. if v == 0 {
  16261. continue
  16262. }
  16263. str = append(str, v)
  16264. }
  16265. return string(str)
  16266. }
  16267. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  16268. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  16269. readCard := DllDef.MustFindProc("EcQuery")
  16270. pCardInfo := make([]byte, 8192)
  16271. pBusiCardInfo := make([]byte, 8192)
  16272. data := make(map[string]interface{})
  16273. //pData := make(map[string]interface{})
  16274. inputData := make(map[string]interface{})
  16275. inputData["orgId"] = code
  16276. inputData["businessType"] = "01101"
  16277. inputData["operatorId"] = operator_id
  16278. inputData["operatorName"] = operator_name
  16279. inputData["officeId"] = "001"
  16280. inputData["officeName"] = "血透室"
  16281. //
  16282. data["data"] = inputData
  16283. data["transType"] = "ec.query"
  16284. data["orgId"] = code
  16285. bytesData, _ := json.Marshal(data)
  16286. pCardInfo = bytesData
  16287. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16288. fmt.Println(ret2)
  16289. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  16290. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16291. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  16292. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16293. if ret2 != 0 {
  16294. return "", ""
  16295. }
  16296. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  16297. }
  16298. func DeleteExtraSpace(s string) string {
  16299. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16300. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16301. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16302. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16303. s2 := make([]byte, len(s1)) //定义字符数组切片
  16304. copy(s2, s1) //将字符串复制到切片
  16305. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16306. for len(spc_index) > 0 { //找到适配项
  16307. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16308. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16309. }
  16310. return string(s2)
  16311. }
  16312. // 对账
  16313. func (c *HisApiController) Post3202() {
  16314. start_time := c.GetString("start_time")
  16315. end_time := c.GetString("end_time")
  16316. //insutype := c.GetString("insutype")
  16317. clr_type := c.GetString("clr_type")
  16318. clr_org := c.GetString("clr_optins")
  16319. admin_user_id, _ := c.GetInt64("admin_user_id")
  16320. adminUser := c.GetAdminUserInfo()
  16321. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16322. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16323. if len(clr_org) == 0 {
  16324. clr_org = miConfig.MdtrtareaAdmvs
  16325. }
  16326. timeLayout := "2006-01-02"
  16327. loc, _ := time.LoadLocation("Local")
  16328. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16329. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16330. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16331. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  16332. //fixmedins_setl_cnt := int64(len(orders))
  16333. var medfee_sumamt float64
  16334. var acct_pay float64
  16335. var fund_pay_sumamt float64
  16336. for _, item := range orders {
  16337. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16338. acct_pay = acct_pay + item.AcctPay
  16339. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16340. }
  16341. //var medfee_sumamt_two float64
  16342. //var acct_pay_two float64
  16343. //var fund_pay_sumamt_two float64
  16344. //for _, item := range orders_two {
  16345. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  16346. // acct_pay_two = acct_pay_two + item.AcctPay
  16347. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  16348. //}
  16349. //var user_name string
  16350. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16351. //if role.ID == 0 {
  16352. // user_name = "xxx"
  16353. //} else {
  16354. // user_name = role.UserName
  16355. //}
  16356. var res ResultSix
  16357. if config.IsOpen == 1 {
  16358. var bps []*models.BusinessParamsTwo
  16359. var bp models.BusinessParamsTwo
  16360. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  16361. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  16362. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  16363. bp.MedfeeSumamt = medfee_sumamt_str
  16364. bp.AcctPay = acct_pay_str
  16365. bp.FundPaySumamt = fund_pay_sumamt_str
  16366. bp.Insutype = "390"
  16367. bp.StmtBegndate = start_time
  16368. bp.ClrType = clr_type
  16369. bp.SetlOptins = clr_org
  16370. bp.StmtEnddate = end_time
  16371. bps = append(bps, &bp)
  16372. data := make(map[string]interface{})
  16373. data["bps"] = bps
  16374. data["org_name"] = miConfig.OrgName
  16375. data["doctor"] = role.UserName
  16376. data["fixmedins_code"] = miConfig.Code
  16377. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16378. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16379. if miConfig.MdtrtareaAdmvs == "421300" {
  16380. client := &http.Client{}
  16381. bytesData, _ := json.Marshal(data)
  16382. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  16383. resp, _ := client.Do(req)
  16384. defer resp.Body.Close()
  16385. body, ioErr := ioutil.ReadAll(resp.Body)
  16386. if ioErr != nil {
  16387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16389. return
  16390. }
  16391. var respJSON map[string]interface{}
  16392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16395. return
  16396. }
  16397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16398. userJSONBytes, _ := json.Marshal(respJSON)
  16399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16400. utils.ErrorLog("解析失败:%v", err)
  16401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16402. return
  16403. }
  16404. }
  16405. if res.Infcode == 0 {
  16406. c.ServeSuccessJSON(map[string]interface{}{
  16407. "msg": "发起成功",
  16408. })
  16409. } else {
  16410. c.ServeSuccessJSON(map[string]interface{}{
  16411. "code": -10,
  16412. "msg": res.ErrMsg,
  16413. })
  16414. }
  16415. }
  16416. }
  16417. func (c *HisApiController) Post3501() {
  16418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16419. data := make(map[string]interface{})
  16420. var struct3501s []models.Struct3501
  16421. var struct3501 models.Struct3501
  16422. struct3501.OrgName = miConfig.OrgName
  16423. struct3501.AccessKey = miConfig.AccessKey
  16424. struct3501.RequestUrl = miConfig.Url
  16425. struct3501.SecretKey = miConfig.SecretKey
  16426. struct3501.ManuDate = "2022-08-17"
  16427. struct3501.FixmedinsBchno = ""
  16428. struct3501.ManuLotnum = ""
  16429. struct3501.RxFlag = "0"
  16430. struct3501.ExpyEnd = "2022-08-17"
  16431. struct3501.Invdate = "2022-08-17"
  16432. struct3501.InvCnt = "20.25"
  16433. struct3501.Memo = ""
  16434. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16435. struct3501.FixmedinsHilistId = miConfig.Code
  16436. struct3501.FixmedinsHilistName = miConfig.OrgName
  16437. struct3501s = append(struct3501s, struct3501)
  16438. data["struct_3501s"] = struct3501s
  16439. client := &http.Client{}
  16440. bytesData, _ := json.Marshal(data)
  16441. var req *http.Request
  16442. if miConfig.MdtrtareaAdmvs == "320921" {
  16443. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16444. } else {
  16445. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16446. }
  16447. resp, _ := client.Do(req)
  16448. defer resp.Body.Close()
  16449. body, ioErr := ioutil.ReadAll(resp.Body)
  16450. if ioErr != nil {
  16451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16453. return
  16454. }
  16455. var respJSON map[string]interface{}
  16456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16459. return
  16460. }
  16461. var res ResultSix
  16462. var resSix10265 ResultSix10265 //1101结果
  16463. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16464. result, _ := json.Marshal(respJSON)
  16465. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16466. utils.ErrorLog("解析失败:%v", err)
  16467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16468. return
  16469. }
  16470. res.InfRefmsgid = resSix10265.InfRefmsgid
  16471. res.Output = resSix10265.Output
  16472. res.ErrMsg = resSix10265.ErrMsg
  16473. res.Cainfo = resSix10265.Cainfo
  16474. res.WarnMsg = resSix10265.WarnMsg
  16475. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16476. res.Infcode = infocode
  16477. if infocode == 0 {
  16478. c.ServeSuccessJSON(map[string]interface{}{
  16479. "msg": "上传成功",
  16480. })
  16481. return
  16482. } else {
  16483. c.ServeSuccessJSON(map[string]interface{}{
  16484. "failed_code": -10,
  16485. "msg": res.ErrMsg,
  16486. })
  16487. return
  16488. }
  16489. }
  16490. func (c *HisApiController) Post3502() {
  16491. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16492. data := make(map[string]interface{})
  16493. var struct3502s []models.Struct3502
  16494. var struct3502 models.Struct3502
  16495. struct3502.OrgName = miConfig.OrgName
  16496. struct3502.AccessKey = miConfig.AccessKey
  16497. struct3502.RequestUrl = miConfig.Url
  16498. struct3502.SecretKey = miConfig.SecretKey
  16499. struct3502.ManuDate = "2022-08-15"
  16500. struct3502.FixmedinsBchno = ""
  16501. struct3502.ManuLotnum = ""
  16502. struct3502.RxFlag = "0"
  16503. struct3502.ExpyEnd = "2022-08-15"
  16504. struct3502.Invdate = "2022-08-15"
  16505. struct3502.InvCnt = "20.25"
  16506. struct3502.Memo = ""
  16507. struct3502.MedListCodg = "XB01ABD056B002020200517"
  16508. struct3502.FixmedinsHilistId = miConfig.Code
  16509. struct3502.FixmedinsHilistName = miConfig.OrgName
  16510. struct3502s = append(struct3502s, struct3502)
  16511. data["struct_3502s"] = struct3502s
  16512. client := &http.Client{}
  16513. bytesData, _ := json.Marshal(data)
  16514. var req *http.Request
  16515. if miConfig.MdtrtareaAdmvs == "320921" {
  16516. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16517. } else {
  16518. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16519. }
  16520. resp, _ := client.Do(req)
  16521. defer resp.Body.Close()
  16522. body, ioErr := ioutil.ReadAll(resp.Body)
  16523. if ioErr != nil {
  16524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16526. return
  16527. }
  16528. var respJSON map[string]interface{}
  16529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16532. return
  16533. }
  16534. var res ResultSix
  16535. var resSix10265 ResultSix10265 //1101结果
  16536. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16537. result, _ := json.Marshal(respJSON)
  16538. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16539. utils.ErrorLog("解析失败:%v", err)
  16540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16541. return
  16542. }
  16543. res.InfRefmsgid = resSix10265.InfRefmsgid
  16544. res.Output = resSix10265.Output
  16545. res.ErrMsg = resSix10265.ErrMsg
  16546. res.Cainfo = resSix10265.Cainfo
  16547. res.WarnMsg = resSix10265.WarnMsg
  16548. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16549. res.Infcode = infocode
  16550. if infocode == 0 {
  16551. c.ServeSuccessJSON(map[string]interface{}{
  16552. "msg": "上传成功",
  16553. })
  16554. return
  16555. } else {
  16556. c.ServeSuccessJSON(map[string]interface{}{
  16557. "failed_code": -10,
  16558. "msg": res.ErrMsg,
  16559. })
  16560. return
  16561. }
  16562. }
  16563. func (c *HisApiController) Post3503() {
  16564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16565. data := make(map[string]interface{})
  16566. var struct3501s []models.Struct3501
  16567. var struct3501 models.Struct3501
  16568. struct3501.OrgName = miConfig.OrgName
  16569. struct3501.AccessKey = miConfig.AccessKey
  16570. struct3501.RequestUrl = miConfig.Url
  16571. struct3501.SecretKey = miConfig.SecretKey
  16572. struct3501.ManuDate = "2022-08-15"
  16573. struct3501.FixmedinsBchno = ""
  16574. struct3501.ManuLotnum = ""
  16575. struct3501.RxFlag = "0"
  16576. struct3501.ExpyEnd = "2022-08-15"
  16577. struct3501.Invdate = "2022-08-15"
  16578. struct3501.InvCnt = "20.25"
  16579. struct3501.Memo = ""
  16580. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16581. struct3501.FixmedinsHilistId = miConfig.Code
  16582. struct3501.FixmedinsHilistName = miConfig.OrgName
  16583. struct3501s = append(struct3501s, struct3501)
  16584. data["struct_3501s"] = struct3501s
  16585. client := &http.Client{}
  16586. bytesData, _ := json.Marshal(data)
  16587. var req *http.Request
  16588. if miConfig.MdtrtareaAdmvs == "320921" {
  16589. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16590. } else {
  16591. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16592. }
  16593. resp, _ := client.Do(req)
  16594. defer resp.Body.Close()
  16595. body, ioErr := ioutil.ReadAll(resp.Body)
  16596. if ioErr != nil {
  16597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16599. return
  16600. }
  16601. var respJSON map[string]interface{}
  16602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16605. return
  16606. }
  16607. var res ResultSix
  16608. var resSix10265 ResultSix10265 //1101结果
  16609. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16610. result, _ := json.Marshal(respJSON)
  16611. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16612. utils.ErrorLog("解析失败:%v", err)
  16613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16614. return
  16615. }
  16616. res.InfRefmsgid = resSix10265.InfRefmsgid
  16617. res.Output = resSix10265.Output
  16618. res.ErrMsg = resSix10265.ErrMsg
  16619. res.Cainfo = resSix10265.Cainfo
  16620. res.WarnMsg = resSix10265.WarnMsg
  16621. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16622. res.Infcode = infocode
  16623. if infocode == 0 {
  16624. c.ServeSuccessJSON(map[string]interface{}{
  16625. "msg": "上传成功",
  16626. })
  16627. return
  16628. } else {
  16629. c.ServeSuccessJSON(map[string]interface{}{
  16630. "failed_code": -10,
  16631. "msg": res.ErrMsg,
  16632. })
  16633. return
  16634. }
  16635. }
  16636. func (c *HisApiController) Post3504() {
  16637. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16638. data := make(map[string]interface{})
  16639. var struct3501s []models.Struct3501
  16640. var struct3501 models.Struct3501
  16641. struct3501.OrgName = miConfig.OrgName
  16642. struct3501.AccessKey = miConfig.AccessKey
  16643. struct3501.RequestUrl = miConfig.Url
  16644. struct3501.SecretKey = miConfig.SecretKey
  16645. struct3501.ManuDate = "2022-08-15"
  16646. struct3501.FixmedinsBchno = ""
  16647. struct3501.ManuLotnum = ""
  16648. struct3501.RxFlag = "0"
  16649. struct3501.ExpyEnd = "2022-08-15"
  16650. struct3501.Invdate = "2022-08-15"
  16651. struct3501.InvCnt = "20.25"
  16652. struct3501.Memo = ""
  16653. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16654. struct3501.FixmedinsHilistId = miConfig.Code
  16655. struct3501.FixmedinsHilistName = miConfig.OrgName
  16656. struct3501s = append(struct3501s, struct3501)
  16657. data["struct_3501s"] = struct3501s
  16658. client := &http.Client{}
  16659. bytesData, _ := json.Marshal(data)
  16660. var req *http.Request
  16661. if miConfig.MdtrtareaAdmvs == "320921" {
  16662. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16663. } else {
  16664. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16665. }
  16666. resp, _ := client.Do(req)
  16667. defer resp.Body.Close()
  16668. body, ioErr := ioutil.ReadAll(resp.Body)
  16669. if ioErr != nil {
  16670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16672. return
  16673. }
  16674. var respJSON map[string]interface{}
  16675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16678. return
  16679. }
  16680. var res ResultSix
  16681. var resSix10265 ResultSix10265 //1101结果
  16682. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16683. result, _ := json.Marshal(respJSON)
  16684. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16685. utils.ErrorLog("解析失败:%v", err)
  16686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16687. return
  16688. }
  16689. res.InfRefmsgid = resSix10265.InfRefmsgid
  16690. res.Output = resSix10265.Output
  16691. res.ErrMsg = resSix10265.ErrMsg
  16692. res.Cainfo = resSix10265.Cainfo
  16693. res.WarnMsg = resSix10265.WarnMsg
  16694. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16695. res.Infcode = infocode
  16696. if infocode == 0 {
  16697. c.ServeSuccessJSON(map[string]interface{}{
  16698. "msg": "上传成功",
  16699. })
  16700. return
  16701. } else {
  16702. c.ServeSuccessJSON(map[string]interface{}{
  16703. "failed_code": -10,
  16704. "msg": res.ErrMsg,
  16705. })
  16706. return
  16707. }
  16708. }
  16709. func (c *HisApiController) Post3505() {
  16710. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16711. data := make(map[string]interface{})
  16712. var struct3501s []models.Struct3501
  16713. var struct3501 models.Struct3501
  16714. struct3501.OrgName = miConfig.OrgName
  16715. struct3501.AccessKey = miConfig.AccessKey
  16716. struct3501.RequestUrl = miConfig.Url
  16717. struct3501.SecretKey = miConfig.SecretKey
  16718. struct3501.ManuDate = "2022-08-15"
  16719. struct3501.FixmedinsBchno = ""
  16720. struct3501.ManuLotnum = ""
  16721. struct3501.RxFlag = "0"
  16722. struct3501.ExpyEnd = "2022-08-15"
  16723. struct3501.Invdate = "2022-08-15"
  16724. struct3501.InvCnt = "20.25"
  16725. struct3501.Memo = ""
  16726. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16727. struct3501.FixmedinsHilistId = miConfig.Code
  16728. struct3501.FixmedinsHilistName = miConfig.OrgName
  16729. struct3501s = append(struct3501s, struct3501)
  16730. data["struct_3501s"] = struct3501s
  16731. client := &http.Client{}
  16732. bytesData, _ := json.Marshal(data)
  16733. var req *http.Request
  16734. if miConfig.MdtrtareaAdmvs == "320921" {
  16735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16736. } else {
  16737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16738. }
  16739. resp, _ := client.Do(req)
  16740. defer resp.Body.Close()
  16741. body, ioErr := ioutil.ReadAll(resp.Body)
  16742. if ioErr != nil {
  16743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16745. return
  16746. }
  16747. var respJSON map[string]interface{}
  16748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16751. return
  16752. }
  16753. var res ResultSix
  16754. var resSix10265 ResultSix10265 //1101结果
  16755. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16756. result, _ := json.Marshal(respJSON)
  16757. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16758. utils.ErrorLog("解析失败:%v", err)
  16759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16760. return
  16761. }
  16762. res.InfRefmsgid = resSix10265.InfRefmsgid
  16763. res.Output = resSix10265.Output
  16764. res.ErrMsg = resSix10265.ErrMsg
  16765. res.Cainfo = resSix10265.Cainfo
  16766. res.WarnMsg = resSix10265.WarnMsg
  16767. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16768. res.Infcode = infocode
  16769. if infocode == 0 {
  16770. c.ServeSuccessJSON(map[string]interface{}{
  16771. "msg": "上传成功",
  16772. })
  16773. return
  16774. } else {
  16775. c.ServeSuccessJSON(map[string]interface{}{
  16776. "failed_code": -10,
  16777. "msg": res.ErrMsg,
  16778. })
  16779. return
  16780. }
  16781. }
  16782. func (c *HisApiController) Post3506() {
  16783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16784. data := make(map[string]interface{})
  16785. var struct3501s []models.Struct3501
  16786. var struct3501 models.Struct3501
  16787. struct3501.OrgName = miConfig.OrgName
  16788. struct3501.AccessKey = miConfig.AccessKey
  16789. struct3501.RequestUrl = miConfig.Url
  16790. struct3501.SecretKey = miConfig.SecretKey
  16791. struct3501.ManuDate = "2022-08-15"
  16792. struct3501.FixmedinsBchno = ""
  16793. struct3501.ManuLotnum = ""
  16794. struct3501.RxFlag = "0"
  16795. struct3501.ExpyEnd = "2022-08-15"
  16796. struct3501.Invdate = "2022-08-15"
  16797. struct3501.InvCnt = "20.25"
  16798. struct3501.Memo = ""
  16799. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16800. struct3501.FixmedinsHilistId = miConfig.Code
  16801. struct3501.FixmedinsHilistName = miConfig.OrgName
  16802. struct3501s = append(struct3501s, struct3501)
  16803. data["struct_3501s"] = struct3501s
  16804. client := &http.Client{}
  16805. bytesData, _ := json.Marshal(data)
  16806. var req *http.Request
  16807. if miConfig.MdtrtareaAdmvs == "320921" {
  16808. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16809. } else {
  16810. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16811. }
  16812. resp, _ := client.Do(req)
  16813. defer resp.Body.Close()
  16814. body, ioErr := ioutil.ReadAll(resp.Body)
  16815. if ioErr != nil {
  16816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16818. return
  16819. }
  16820. var respJSON map[string]interface{}
  16821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16824. return
  16825. }
  16826. var res ResultSix
  16827. var resSix10265 ResultSix10265 //1101结果
  16828. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16829. result, _ := json.Marshal(respJSON)
  16830. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16831. utils.ErrorLog("解析失败:%v", err)
  16832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16833. return
  16834. }
  16835. res.InfRefmsgid = resSix10265.InfRefmsgid
  16836. res.Output = resSix10265.Output
  16837. res.ErrMsg = resSix10265.ErrMsg
  16838. res.Cainfo = resSix10265.Cainfo
  16839. res.WarnMsg = resSix10265.WarnMsg
  16840. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16841. res.Infcode = infocode
  16842. if infocode == 0 {
  16843. c.ServeSuccessJSON(map[string]interface{}{
  16844. "msg": "上传成功",
  16845. })
  16846. return
  16847. } else {
  16848. c.ServeSuccessJSON(map[string]interface{}{
  16849. "failed_code": -10,
  16850. "msg": res.ErrMsg,
  16851. })
  16852. return
  16853. }
  16854. }
  16855. func (c *HisApiController) Post3507() {
  16856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16857. data := make(map[string]interface{})
  16858. var struct3501s []models.Struct3501
  16859. var struct3501 models.Struct3501
  16860. struct3501.OrgName = miConfig.OrgName
  16861. struct3501.AccessKey = miConfig.AccessKey
  16862. struct3501.RequestUrl = miConfig.Url
  16863. struct3501.SecretKey = miConfig.SecretKey
  16864. struct3501.ManuDate = "2022-08-15"
  16865. struct3501.FixmedinsBchno = ""
  16866. struct3501.ManuLotnum = ""
  16867. struct3501.RxFlag = "0"
  16868. struct3501.ExpyEnd = "2022-08-15"
  16869. struct3501.Invdate = "2022-08-15"
  16870. struct3501.InvCnt = "20.25"
  16871. struct3501.Memo = ""
  16872. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16873. struct3501.FixmedinsHilistId = miConfig.Code
  16874. struct3501.FixmedinsHilistName = miConfig.OrgName
  16875. struct3501s = append(struct3501s, struct3501)
  16876. data["struct_3501s"] = struct3501s
  16877. client := &http.Client{}
  16878. bytesData, _ := json.Marshal(data)
  16879. var req *http.Request
  16880. if miConfig.MdtrtareaAdmvs == "320921" {
  16881. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16882. } else {
  16883. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16884. }
  16885. resp, _ := client.Do(req)
  16886. defer resp.Body.Close()
  16887. body, ioErr := ioutil.ReadAll(resp.Body)
  16888. if ioErr != nil {
  16889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16891. return
  16892. }
  16893. var respJSON map[string]interface{}
  16894. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16897. return
  16898. }
  16899. var res ResultSix
  16900. var resSix10265 ResultSix10265 //1101结果
  16901. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16902. result, _ := json.Marshal(respJSON)
  16903. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16904. utils.ErrorLog("解析失败:%v", err)
  16905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16906. return
  16907. }
  16908. res.InfRefmsgid = resSix10265.InfRefmsgid
  16909. res.Output = resSix10265.Output
  16910. res.ErrMsg = resSix10265.ErrMsg
  16911. res.Cainfo = resSix10265.Cainfo
  16912. res.WarnMsg = resSix10265.WarnMsg
  16913. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16914. res.Infcode = infocode
  16915. if infocode == 0 {
  16916. c.ServeSuccessJSON(map[string]interface{}{
  16917. "msg": "上传成功",
  16918. })
  16919. return
  16920. } else {
  16921. c.ServeSuccessJSON(map[string]interface{}{
  16922. "failed_code": -10,
  16923. "msg": res.ErrMsg,
  16924. })
  16925. return
  16926. }
  16927. }
  16928. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  16929. // WebSocket服务器地址
  16930. serverURL := "ws://127.0.0.1:8899"
  16931. // 解析WebSocket服务器地址
  16932. u, err := url.Parse(serverURL)
  16933. if err != nil {
  16934. }
  16935. // 建立WebSocket连接
  16936. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16937. if err != nil {
  16938. }
  16939. defer conn.Close()
  16940. input2 := make(map[string]interface{})
  16941. input := make(map[string]interface{})
  16942. inputData := make(map[string]interface{})
  16943. inputData["orgId"] = code
  16944. inputData["businessType"] = "01101"
  16945. inputData["operatorId"] = operator_id
  16946. inputData["operatorName"] = operator_name
  16947. inputData["officeId"] = "001"
  16948. inputData["officeName"] = "血透室"
  16949. inputData["deviceType"] = ""
  16950. input["data"] = inputData
  16951. input["orgId"] = code
  16952. input["transType"] = "ec.query"
  16953. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16954. input2["indata"] = input
  16955. bytesData, _ := json.Marshal(input2)
  16956. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16957. if err != nil {
  16958. fmt.Println(err)
  16959. }
  16960. // 接收消息
  16961. _, receivedMessage, err := conn.ReadMessage()
  16962. if err != nil {
  16963. fmt.Println(err)
  16964. }
  16965. return "", string(receivedMessage)
  16966. }
  16967. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  16968. // WebSocket服务器地址
  16969. serverURL := "ws://127.0.0.1:8899"
  16970. // 解析WebSocket服务器地址
  16971. u, err := url.Parse(serverURL)
  16972. if err != nil {
  16973. }
  16974. // 建立WebSocket连接
  16975. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16976. if err != nil {
  16977. }
  16978. defer conn.Close()
  16979. input2 := make(map[string]interface{})
  16980. input := make(map[string]interface{})
  16981. inputData := make(map[string]interface{})
  16982. inputData["orgId"] = code
  16983. inputData["businessType"] = "01301"
  16984. inputData["operatorId"] = operator_id
  16985. inputData["operatorName"] = operator_name
  16986. inputData["officeId"] = "001"
  16987. inputData["officeName"] = "血透室"
  16988. inputData["deviceType"] = ""
  16989. input["data"] = inputData
  16990. input["orgId"] = code
  16991. input["transType"] = "ec.query"
  16992. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16993. input2["indata"] = input
  16994. bytesData, _ := json.Marshal(input2)
  16995. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16996. if err != nil {
  16997. fmt.Println(err)
  16998. }
  16999. // 接收消息
  17000. _, receivedMessage, err := conn.ReadMessage()
  17001. if err != nil {
  17002. fmt.Println(err)
  17003. }
  17004. return "", string(receivedMessage)
  17005. }