his_api_controller.go 687KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813
  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. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  115. psn, _ := service.GetPsnByPatientId(patient_id)
  116. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  117. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  118. var cFYLJG001 models.CFYLJG001
  119. timeLayout := "2006-01-02"
  120. loc, _ := time.LoadLocation("Local")
  121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  122. if err != nil {
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  124. return
  125. }
  126. recordDateTime := theTime.Unix()
  127. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  128. for _, item := range prescriptions {
  129. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  130. if his.IdCardType == 1 {
  131. bas := strings.Split(psn.CardInfo, "|")
  132. basNumber := bas[1]
  133. fmt.Println(basNumber)
  134. card_sn := bas[3]
  135. card_no := bas[2]
  136. cFYLJG001.MdtrtCertType = "03"
  137. cFYLJG001.CardSn = card_sn
  138. cFYLJG001.MdtrtCertNo = card_no
  139. cFYLJG001.EcToken = ""
  140. cFYLJG001.AuthNo = ""
  141. } else if his.IdCardType == 2 {
  142. cFYLJG001.MdtrtCertType = "02"
  143. cFYLJG001.CardSn = ""
  144. cFYLJG001.MdtrtCertNo = his.IdCardNo
  145. cFYLJG001.EcToken = ""
  146. cFYLJG001.AuthNo = ""
  147. } else if his.IdCardType == 4 {
  148. cFYLJG001.MdtrtCertType = "01"
  149. cFYLJG001.CardSn = ""
  150. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  151. cFYLJG001.EcToken = psn.VerifyNumber
  152. cFYLJG001.AuthNo = ""
  153. }
  154. cFYLJG001.BizTypeCode = "01"
  155. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  156. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  157. cFYLJG001.RxTypeCode = "1"
  158. tempTime := time.Unix(item.PreTime, 0)
  159. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  160. cFYLJG001.PrscTime = timeFormatOne
  161. var count float64
  162. if item.Type == 1 {
  163. for _, sumItem := range item.HisDoctorAdviceInfo {
  164. count = count + sumItem.PrescribingNumber
  165. }
  166. }
  167. cFYLJG001.RxDrugCnt = count
  168. cFYLJG001.ValiDays = "5"
  169. ts := time.Unix(item.PreTime, 0)
  170. record_time = ts.AddDate(0, 0, int(5)).Unix()
  171. tempTime3 := time.Unix(record_time, 0)
  172. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  173. cFYLJG001.ValiEndTime = timeFormat3
  174. cFYLJG001.RxCotnFlag = "0"
  175. for _, subItem := range item.HisDoctorAdviceInfo {
  176. var drug models.RxDrug
  177. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  178. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  179. drug.RxItemTypeCode = "11"
  180. drug.DrugDosform = "" //TODO
  181. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  182. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  183. }
  184. drug.MedcWayDscr = subItem.DeliveryWay
  185. tempTime2 := time.Unix(subItem.StartTime, 0)
  186. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  187. drug.MedcBegntime = timeFormatTwo
  188. if subItem.Day > 0 {
  189. ts := time.Unix(subItem.StartTime, 0)
  190. record_time = ts.AddDate(0, 0, int(subItem.Day)).Unix()
  191. tempTime3 := time.Unix(record_time, 0)
  192. timeFormat3 := tempTime3.Format("2006-01-02") + " 23:59:00"
  193. drug.MedcEndtime = timeFormat3
  194. } else {
  195. tempTime2 := time.Unix(subItem.StartTime, 0)
  196. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  197. drug.MedcEndtime = timeFormatTwo
  198. }
  199. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  200. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  201. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  202. drug.DrugCnt = subItem.PrescribingNumber
  203. drug.DrugDosunt = subItem.PrescribingNumberUnit
  204. drug.SinDoscnt = subItem.SingleDose
  205. drug.SinDosunt = subItem.SingleDoseUnit
  206. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  207. drug.UsedFrquName = subItem.ExecutionFrequency
  208. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  209. drug.DrugTotlcntEmp = fmt.Sprintf("%.2f", subItem.PrescribingNumberUnit)
  210. drug.HospApprFlag = "1"
  211. cFYLJG001.List = append(cFYLJG001.List, drug)
  212. }
  213. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  214. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  215. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  216. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  217. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  218. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  219. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  220. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  221. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  222. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  223. cFYLJG001.Mdtrtinfo.PatnHgt = ""
  224. cFYLJG001.Mdtrtinfo.PatnWt = ""
  225. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  226. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  227. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  228. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  229. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  230. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  231. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  232. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  233. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  234. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  235. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  236. tempTime2 := time.Now().Unix()
  237. tempTime3 := time.Unix(tempTime2, 0)
  238. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  239. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  240. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  241. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  242. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  243. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  244. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  245. var config []*models.HisXtDiagnoseConfig
  246. for _, item := range diagnosis_ids {
  247. id, _ := strconv.ParseInt(item, 10, 64)
  248. diagnosisConfig, _ := service.FindDiagnoseById(id)
  249. config = append(config, &diagnosisConfig)
  250. }
  251. for index, item := range config {
  252. if index == 0 {
  253. var dia models.DiseInfo
  254. dia.DiagType = "1"
  255. dia.MaindiagFlag = "1"
  256. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  257. dia.DiagCode = item.CountryCode
  258. dia.DiagName = item.ClassName
  259. dia.DiagDept = "肾内科"
  260. dia.DiagDrNo = doctor.DoctorNumber
  261. dia.DiagDrName = doctor.UserName
  262. tempTime3 := time.Unix(item.Ctime, 0)
  263. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  264. dia.DiagTime = timeFormatTwo
  265. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  266. } else {
  267. var dia models.DiseInfo
  268. dia.DiagType = "1"
  269. dia.MaindiagFlag = "0"
  270. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  271. dia.DiagCode = item.CountryCode
  272. dia.DiagName = item.ClassName
  273. dia.DiagDept = "肾内科"
  274. dia.DiagDrNo = doctor.DoctorNumber
  275. dia.DiagDrName = doctor.UserName
  276. tempTime3 := time.Unix(item.Ctime, 0)
  277. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  278. dia.DiagTime = timeFormatTwo
  279. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  280. }
  281. }
  282. fmt.Println(cFYLJG001)
  283. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  284. }
  285. }
  286. func (c *HisApiController) GetCFYLJG002() {
  287. admin_user_id, _ := c.GetInt64("admin_user_id")
  288. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  289. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  290. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  291. }
  292. func (c *HisApiController) GetCFYLJG003() {
  293. admin_user_id, _ := c.GetInt64("admin_user_id")
  294. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  296. var cFYLJG003 models.CFYLJG003
  297. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  298. }
  299. func (c *HisApiController) GetCFYLJG004() {
  300. admin_user_id, _ := c.GetInt64("admin_user_id")
  301. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  302. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  303. var cFYLJG004 models.CFYLJG004
  304. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  305. }
  306. func (c *HisApiController) GetCFYLJG005() {
  307. admin_user_id, _ := c.GetInt64("admin_user_id")
  308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  310. var cFYLJG005 models.CFYLJG005
  311. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  312. }
  313. func (c *HisApiController) GetCFYLJG006() {
  314. admin_user_id, _ := c.GetInt64("admin_user_id")
  315. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  316. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  317. var cFYLJG006 models.CFYLJG006
  318. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  319. }
  320. func (c *HisApiController) GetCFYLJG007() {
  321. admin_user_id, _ := c.GetInt64("admin_user_id")
  322. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  324. var cFYLJG007 models.CFYLJG007
  325. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  326. }
  327. func (c *HisApiController) GetBL4201A() {
  328. order_id, _ := c.GetInt64("order_id")
  329. admin_user_id, _ := c.GetInt64("admin_user_id")
  330. order, _ := service.GetHisOrderByIDTwo(order_id)
  331. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  332. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  333. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  334. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  336. department, _ := service.GetDepartMentDetail(his.Departments)
  337. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  338. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  339. if order.ID == 0 {
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  341. return
  342. }
  343. var struct4201A models.Struct4201A
  344. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  345. for _, items := range order_info {
  346. memo := make(map[string]interface{})
  347. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  348. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  349. fsiOPFLD.MedType = "14"
  350. fsiOPFLD.BkkpSn = items.FeedetlSn
  351. fsiOPFLD.FixmedinsCode = miConfig.Code
  352. fsiOPFLD.FixmedinsName = miConfig.OrgName
  353. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  354. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  355. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  356. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  357. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  358. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  359. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  360. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  361. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  362. fsiOPFLD.BilgDeptName = department.Name
  363. fsiOPFLD.BilgDeptCodg = department.Number
  364. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  365. fsiOPFLD.BilgDrName = doctor.UserName
  366. fsiOPFLD.MedChrgitmType = "09"
  367. memo["hosp_appr_flag"] = "1"
  368. memo["invoice_no"] = order.MdtrtId
  369. memo["memo"] = "自费"
  370. bytesData, _ := json.Marshal(memo)
  371. fsiOPFLD.Memo = string(bytesData)
  372. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  373. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  374. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  375. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  376. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  377. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  378. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  379. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  380. fsiOPFLD.BilgDeptName = department.Name
  381. fsiOPFLD.BilgDeptCodg = department.Number
  382. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  383. fsiOPFLD.BilgDrName = doctor.UserName
  384. switch items.HisPrescriptionProject.HisProject.CostClassify {
  385. case 0:
  386. break
  387. case 1:
  388. fsiOPFLD.MedChrgitmType = "14"
  389. break
  390. case 2:
  391. fsiOPFLD.MedChrgitmType = "05"
  392. break
  393. case 3:
  394. fsiOPFLD.MedChrgitmType = "03"
  395. break
  396. case 4:
  397. fsiOPFLD.MedChrgitmType = "03"
  398. break
  399. case 5:
  400. fsiOPFLD.MedChrgitmType = "08"
  401. break
  402. case 6:
  403. fsiOPFLD.MedChrgitmType = "14"
  404. break
  405. case 7:
  406. fsiOPFLD.MedChrgitmType = "14"
  407. break
  408. case 8:
  409. fsiOPFLD.MedChrgitmType = "03"
  410. break
  411. case 9:
  412. fsiOPFLD.MedChrgitmType = "14"
  413. break
  414. case 10:
  415. fsiOPFLD.MedChrgitmType = "14"
  416. break
  417. case 11:
  418. fsiOPFLD.MedChrgitmType = "06"
  419. break
  420. case 12:
  421. fsiOPFLD.MedChrgitmType = "12"
  422. break
  423. case 13:
  424. fsiOPFLD.MedChrgitmType = "01"
  425. break
  426. case 14:
  427. fsiOPFLD.MedChrgitmType = "04"
  428. break
  429. case 15:
  430. fsiOPFLD.MedChrgitmType = "14"
  431. break
  432. }
  433. memo["hosp_appr_flag"] = "1"
  434. memo["invoice_no"] = order.MdtrtId
  435. memo["memo"] = "自费"
  436. bytesData, _ := json.Marshal(memo)
  437. fsiOPFLD.Memo = string(bytesData)
  438. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  439. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  440. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  441. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  442. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  443. fsiOPFLD.BilgDeptName = department.Name
  444. fsiOPFLD.BilgDeptCodg = department.Number
  445. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  446. fsiOPFLD.BilgDrName = doctor.UserName
  447. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  448. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  449. fsiOPFLD.MedChrgitmType = "08"
  450. memo["hosp_appr_flag"] = "1"
  451. memo["invoice_no"] = order.MdtrtId
  452. memo["memo"] = "自费"
  453. bytesData, _ := json.Marshal(memo)
  454. fsiOPFLD.Memo = string(bytesData)
  455. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  456. }
  457. }
  458. }
  459. for _, items := range order_info_two {
  460. memo := make(map[string]interface{})
  461. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  462. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  463. fsiOPFLD.MedType = "14"
  464. fsiOPFLD.BkkpSn = items.FeedetlSn
  465. fsiOPFLD.FixmedinsCode = miConfig.Code
  466. fsiOPFLD.FixmedinsName = miConfig.OrgName
  467. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  468. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  469. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  470. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  471. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  472. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  473. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  474. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  475. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  476. fsiOPFLD.BilgDeptName = department.Name
  477. fsiOPFLD.BilgDeptCodg = department.Number
  478. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  479. fsiOPFLD.BilgDrName = doctor.UserName
  480. fsiOPFLD.MedChrgitmType = "09"
  481. memo["hosp_appr_flag"] = "1"
  482. memo["invoice_no"] = order.MdtrtId
  483. memo["memo"] = "自费"
  484. bytesData, _ := json.Marshal(memo)
  485. fsiOPFLD.Memo = string(bytesData)
  486. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  487. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  488. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  489. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  490. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  491. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  492. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  493. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  494. fsiOPFLD.BilgDeptName = department.Name
  495. fsiOPFLD.BilgDeptCodg = department.Number
  496. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  497. fsiOPFLD.BilgDrName = doctor.UserName
  498. switch items.HisPrescriptionProject.HisProject.CostClassify {
  499. case 0:
  500. break
  501. case 1:
  502. fsiOPFLD.MedChrgitmType = "14"
  503. break
  504. case 2:
  505. fsiOPFLD.MedChrgitmType = "05"
  506. break
  507. case 3:
  508. fsiOPFLD.MedChrgitmType = "03"
  509. break
  510. case 4:
  511. fsiOPFLD.MedChrgitmType = "03"
  512. break
  513. case 5:
  514. fsiOPFLD.MedChrgitmType = "08"
  515. break
  516. case 6:
  517. fsiOPFLD.MedChrgitmType = "14"
  518. break
  519. case 7:
  520. fsiOPFLD.MedChrgitmType = "14"
  521. break
  522. case 8:
  523. fsiOPFLD.MedChrgitmType = "03"
  524. break
  525. case 9:
  526. fsiOPFLD.MedChrgitmType = "14"
  527. break
  528. case 10:
  529. fsiOPFLD.MedChrgitmType = "14"
  530. break
  531. case 11:
  532. fsiOPFLD.MedChrgitmType = "06"
  533. break
  534. case 12:
  535. fsiOPFLD.MedChrgitmType = "12"
  536. break
  537. case 13:
  538. fsiOPFLD.MedChrgitmType = "01"
  539. break
  540. case 14:
  541. fsiOPFLD.MedChrgitmType = "04"
  542. break
  543. case 15:
  544. fsiOPFLD.MedChrgitmType = "14"
  545. break
  546. }
  547. memo["hosp_appr_flag"] = "1"
  548. memo["invoice_no"] = order.MdtrtId
  549. memo["memo"] = "自费"
  550. bytesData, _ := json.Marshal(memo)
  551. fsiOPFLD.Memo = string(bytesData)
  552. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  553. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  554. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  555. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  556. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  557. fsiOPFLD.BilgDeptName = department.Name
  558. fsiOPFLD.BilgDeptCodg = department.Number
  559. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  560. fsiOPFLD.BilgDrName = doctor.UserName
  561. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  562. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  563. fsiOPFLD.MedChrgitmType = "08"
  564. memo["hosp_appr_flag"] = "1"
  565. memo["invoice_no"] = order.MdtrtId
  566. memo["memo"] = "自费"
  567. bytesData, _ := json.Marshal(memo)
  568. fsiOPFLD.Memo = string(bytesData)
  569. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  570. }
  571. }
  572. }
  573. fmt.Println(fsiOPFLDs)
  574. struct4201A.Fopfd = fsiOPFLDs
  575. fmt.Println(struct4201A.Fopfd)
  576. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  577. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  578. var res2 ResultSix
  579. var respJSON2 map[string]interface{}
  580. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  583. return
  584. }
  585. userJSONBytes2, _ := json.Marshal(respJSON2)
  586. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  587. utils.ErrorLog("解析失败:%v", err)
  588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  589. return
  590. }
  591. if res2.Infcode != 0 {
  592. c.ServeSuccessJSON(map[string]interface{}{
  593. "failed_code": -10,
  594. "msg": res2.ErrMsg,
  595. })
  596. return
  597. } else {
  598. order.IsUploadOrderInfo = 1
  599. service.UpdateOrder(order)
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "msg": "上传成功",
  602. })
  603. }
  604. }
  605. func (c *HisApiController) Get2505() {
  606. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  607. 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")
  608. }
  609. func (c *HisApiController) Get4201A() {
  610. order_id, _ := c.GetInt64("order_id")
  611. admin_user_id, _ := c.GetInt64("admin_user_id")
  612. order, _ := service.GetHisOrderByIDTwo(order_id)
  613. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  614. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  615. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  616. //order_info = append(order_info, order_info_two...)
  617. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  619. department, _ := service.GetDepartMentDetail(his.Departments)
  620. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  621. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  622. if order.ID == 0 {
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  624. return
  625. }
  626. var struct4201A models.Struct4201A
  627. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  628. for _, items := range order_info {
  629. memo := make(map[string]interface{})
  630. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  631. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  632. fsiOPFLD.MedType = "14"
  633. fsiOPFLD.BkkpSn = items.FeedetlSn
  634. fsiOPFLD.FixmedinsCode = miConfig.Code
  635. fsiOPFLD.FixmedinsName = miConfig.OrgName
  636. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  637. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  638. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  639. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  640. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  641. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  642. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  643. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  644. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  645. fsiOPFLD.BilgDeptName = department.Name
  646. fsiOPFLD.BilgDeptCodg = department.Number
  647. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  648. fsiOPFLD.BilgDrName = doctor.UserName
  649. fsiOPFLD.MedChrgitmType = "09"
  650. memo["hosp_appr_flag"] = "1"
  651. memo["invoice_no"] = order.MdtrtId
  652. memo["memo"] = "自费"
  653. bytesData, _ := json.Marshal(memo)
  654. fsiOPFLD.Memo = string(bytesData)
  655. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  656. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  657. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  658. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  659. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  660. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  661. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  662. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  663. fsiOPFLD.BilgDeptName = department.Name
  664. fsiOPFLD.BilgDeptCodg = department.Number
  665. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  666. fsiOPFLD.BilgDrName = doctor.UserName
  667. switch items.HisPrescriptionProject.HisProject.CostClassify {
  668. case 0:
  669. break
  670. case 1:
  671. fsiOPFLD.MedChrgitmType = "14"
  672. break
  673. case 2:
  674. fsiOPFLD.MedChrgitmType = "05"
  675. break
  676. case 3:
  677. fsiOPFLD.MedChrgitmType = "03"
  678. break
  679. case 4:
  680. fsiOPFLD.MedChrgitmType = "03"
  681. break
  682. case 5:
  683. fsiOPFLD.MedChrgitmType = "08"
  684. break
  685. case 6:
  686. fsiOPFLD.MedChrgitmType = "14"
  687. break
  688. case 7:
  689. fsiOPFLD.MedChrgitmType = "14"
  690. break
  691. case 8:
  692. fsiOPFLD.MedChrgitmType = "03"
  693. break
  694. case 9:
  695. fsiOPFLD.MedChrgitmType = "14"
  696. break
  697. case 10:
  698. fsiOPFLD.MedChrgitmType = "14"
  699. break
  700. case 11:
  701. fsiOPFLD.MedChrgitmType = "06"
  702. break
  703. case 12:
  704. fsiOPFLD.MedChrgitmType = "12"
  705. break
  706. case 13:
  707. fsiOPFLD.MedChrgitmType = "01"
  708. break
  709. case 14:
  710. fsiOPFLD.MedChrgitmType = "04"
  711. break
  712. case 15:
  713. fsiOPFLD.MedChrgitmType = "14"
  714. break
  715. }
  716. memo["hosp_appr_flag"] = "1"
  717. memo["invoice_no"] = order.MdtrtId
  718. memo["memo"] = "自费"
  719. bytesData, _ := json.Marshal(memo)
  720. fsiOPFLD.Memo = string(bytesData)
  721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  722. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  723. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  724. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  725. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  726. fsiOPFLD.BilgDeptName = department.Name
  727. fsiOPFLD.BilgDeptCodg = department.Number
  728. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  729. fsiOPFLD.BilgDrName = doctor.UserName
  730. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  731. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  732. fsiOPFLD.MedChrgitmType = "08"
  733. memo["hosp_appr_flag"] = "1"
  734. memo["invoice_no"] = order.MdtrtId
  735. memo["memo"] = "自费"
  736. bytesData, _ := json.Marshal(memo)
  737. fsiOPFLD.Memo = string(bytesData)
  738. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  739. }
  740. }
  741. }
  742. for _, items := range order_info_two {
  743. memo := make(map[string]interface{})
  744. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  745. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  746. fsiOPFLD.MedType = "14"
  747. fsiOPFLD.BkkpSn = items.FeedetlSn
  748. fsiOPFLD.FixmedinsCode = miConfig.Code
  749. fsiOPFLD.FixmedinsName = miConfig.OrgName
  750. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  751. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  752. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  753. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  754. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  755. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  756. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  757. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  758. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  759. fsiOPFLD.BilgDeptName = department.Name
  760. fsiOPFLD.BilgDeptCodg = department.Number
  761. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  762. fsiOPFLD.BilgDrName = doctor.UserName
  763. fsiOPFLD.MedChrgitmType = "09"
  764. memo["hosp_appr_flag"] = "1"
  765. memo["invoice_no"] = order.MdtrtId
  766. memo["memo"] = "自费"
  767. bytesData, _ := json.Marshal(memo)
  768. fsiOPFLD.Memo = string(bytesData)
  769. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  770. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  771. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  772. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  773. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  774. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  775. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  776. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  777. fsiOPFLD.BilgDeptName = department.Name
  778. fsiOPFLD.BilgDeptCodg = department.Number
  779. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  780. fsiOPFLD.BilgDrName = doctor.UserName
  781. switch items.HisPrescriptionProject.HisProject.CostClassify {
  782. case 0:
  783. break
  784. case 1:
  785. fsiOPFLD.MedChrgitmType = "14"
  786. break
  787. case 2:
  788. fsiOPFLD.MedChrgitmType = "05"
  789. break
  790. case 3:
  791. fsiOPFLD.MedChrgitmType = "03"
  792. break
  793. case 4:
  794. fsiOPFLD.MedChrgitmType = "03"
  795. break
  796. case 5:
  797. fsiOPFLD.MedChrgitmType = "08"
  798. break
  799. case 6:
  800. fsiOPFLD.MedChrgitmType = "14"
  801. break
  802. case 7:
  803. fsiOPFLD.MedChrgitmType = "14"
  804. break
  805. case 8:
  806. fsiOPFLD.MedChrgitmType = "03"
  807. break
  808. case 9:
  809. fsiOPFLD.MedChrgitmType = "14"
  810. break
  811. case 10:
  812. fsiOPFLD.MedChrgitmType = "14"
  813. break
  814. case 11:
  815. fsiOPFLD.MedChrgitmType = "06"
  816. break
  817. case 12:
  818. fsiOPFLD.MedChrgitmType = "12"
  819. break
  820. case 13:
  821. fsiOPFLD.MedChrgitmType = "01"
  822. break
  823. case 14:
  824. fsiOPFLD.MedChrgitmType = "04"
  825. break
  826. case 15:
  827. fsiOPFLD.MedChrgitmType = "14"
  828. break
  829. }
  830. memo["hosp_appr_flag"] = "1"
  831. memo["invoice_no"] = order.MdtrtId
  832. memo["memo"] = "自费"
  833. bytesData, _ := json.Marshal(memo)
  834. fsiOPFLD.Memo = string(bytesData)
  835. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  836. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  837. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  838. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  839. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  840. fsiOPFLD.BilgDeptName = department.Name
  841. fsiOPFLD.BilgDeptCodg = department.Number
  842. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  843. fsiOPFLD.BilgDrName = doctor.UserName
  844. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  845. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  846. fsiOPFLD.MedChrgitmType = "08"
  847. memo["hosp_appr_flag"] = "1"
  848. memo["invoice_no"] = order.MdtrtId
  849. memo["memo"] = "自费"
  850. bytesData, _ := json.Marshal(memo)
  851. fsiOPFLD.Memo = string(bytesData)
  852. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  853. }
  854. }
  855. }
  856. fmt.Println(fsiOPFLDs)
  857. struct4201A.Fopfd = fsiOPFLDs
  858. fmt.Println(struct4201A.Fopfd)
  859. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  860. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  861. var res2 ResultSix
  862. var respJSON2 map[string]interface{}
  863. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  866. return
  867. }
  868. userJSONBytes2, _ := json.Marshal(respJSON2)
  869. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  870. utils.ErrorLog("解析失败:%v", err)
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  872. return
  873. }
  874. if res2.Infcode != 0 {
  875. c.ServeSuccessJSON(map[string]interface{}{
  876. "failed_code": -10,
  877. "msg": res2.ErrMsg,
  878. })
  879. return
  880. } else {
  881. order.IsUploadOrderInfo = 1
  882. service.UpdateOrder(order)
  883. c.ServeSuccessJSON(map[string]interface{}{
  884. "msg": "上传成功",
  885. })
  886. }
  887. }
  888. func (c *HisApiController) Get4202() {
  889. order_id, _ := c.GetInt64("order_id")
  890. admin_user_id, _ := c.GetInt64("admin_user_id")
  891. order, _ := service.GetHisOrderByIDTwo(order_id)
  892. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  893. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  895. if order.ID == 0 {
  896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  897. return
  898. }
  899. var struct4202 models.Struct4202
  900. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  901. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  902. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  903. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  904. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  905. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  906. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  907. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  908. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  909. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  910. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  911. var config []*models.HisXtDiagnoseConfig
  912. for _, item := range diagnosis_ids {
  913. id, _ := strconv.ParseInt(item, 10, 64)
  914. diagnosisConfig, _ := service.FindDiagnoseById(id)
  915. config = append(config, &diagnosisConfig)
  916. }
  917. var tempDiaginfos []models.OwnPayPatnDiagListD
  918. for index, item := range config {
  919. if index == 0 {
  920. var tempDiaginfo models.OwnPayPatnDiagListD
  921. tempDiaginfo.InoutDiagType = "1"
  922. tempDiaginfo.DiagCode = item.CountryCode
  923. tempDiaginfo.DiagName = item.CountryContentName
  924. tempDiaginfo.DiagType = "1"
  925. tempDiaginfo.DiagSrtNo = "1"
  926. tempDiaginfo.MaindiagFlag = "1"
  927. tempDiaginfo.ValiFlag = "1"
  928. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  929. } else {
  930. var tempDiaginfo models.OwnPayPatnDiagListD
  931. tempDiaginfo.DiagCode = item.CountryCode
  932. tempDiaginfo.DiagName = item.CountryContentName
  933. tempDiaginfo.DiagType = "2"
  934. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  935. tempDiaginfo.MaindiagFlag = "0"
  936. tempDiaginfo.ValiFlag = "1"
  937. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  938. }
  939. }
  940. struct4202.ODiagListD = tempDiaginfos
  941. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  942. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  943. var res2 ResultSix
  944. var respJSON2 map[string]interface{}
  945. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  948. return
  949. }
  950. userJSONBytes2, _ := json.Marshal(respJSON2)
  951. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  952. utils.ErrorLog("解析失败:%v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. if res2.Infcode != 0 {
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "failed_code": -10,
  959. "msg": res2.ErrMsg,
  960. })
  961. return
  962. } else {
  963. order.IsUploadDiagnose = 1
  964. service.UpdateOrder(order)
  965. c.ServeSuccessJSON(map[string]interface{}{
  966. "msg": "上传成功",
  967. })
  968. }
  969. }
  970. func (c *HisApiController) Get4203() {
  971. admin_user_id, _ := c.GetInt64("admin_user_id")
  972. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  973. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  974. order_id, _ := c.GetInt64("order_id")
  975. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  976. number := ""
  977. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  978. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  979. if his.ID == 0 {
  980. number = hospital.Number
  981. } else {
  982. number = his.Number
  983. }
  984. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  985. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  986. var res2 ResultSix
  987. var respJSON2 map[string]interface{}
  988. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. userJSONBytes2, _ := json.Marshal(respJSON2)
  994. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  995. utils.ErrorLog("解析失败:%v", err)
  996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  997. return
  998. }
  999. if res2.Infcode != 0 {
  1000. c.ServeSuccessJSON(map[string]interface{}{
  1001. "failed_code": -10,
  1002. "msg": res2.ErrMsg,
  1003. })
  1004. return
  1005. } else {
  1006. order.IsUploadSuccess = 1
  1007. service.UpdateOrderTwo(order)
  1008. c.ServeSuccessJSON(map[string]interface{}{
  1009. "msg": "上传成功",
  1010. })
  1011. }
  1012. }
  1013. func (c *HisApiController) Get4205() {
  1014. order_id, _ := c.GetInt64("order_id")
  1015. admin_user_id, _ := c.GetInt64("admin_user_id")
  1016. fapiao_code := c.GetString("fapiao_code")
  1017. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1018. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1019. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1020. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1021. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  1022. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  1023. //order_info = append(order_info, order_info_two...)
  1024. department, _ := service.GetDepartMentDetail(his.Departments)
  1025. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1026. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1027. if order.ID == 0 {
  1028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1029. return
  1030. }
  1031. var struct4201A models.Struct4201A
  1032. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1033. for _, items := range order_info {
  1034. memo := make(map[string]interface{})
  1035. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1036. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1037. fsiOPFLD.MedType = pre.MedType
  1038. fsiOPFLD.FixmedinsCode = miConfig.Code
  1039. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1040. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1041. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1042. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1043. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1044. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1045. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1046. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  1047. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1048. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1049. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1050. fsiOPFLD.BilgDeptName = department.Name
  1051. fsiOPFLD.BilgDeptCodg = department.Number
  1052. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1053. fsiOPFLD.BilgDrName = doctor.UserName
  1054. fsiOPFLD.MedChrgitmType = "09"
  1055. memo["hosp_appr_flag"] = "1"
  1056. memo["invoice_no"] = fapiao_code
  1057. memo["memo"] = "自费"
  1058. bytesData, _ := json.Marshal(memo)
  1059. fsiOPFLD.Memo = string(bytesData)
  1060. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1061. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1062. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1063. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1064. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1065. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1066. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1067. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1068. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1069. fsiOPFLD.BilgDeptName = department.Name
  1070. fsiOPFLD.BilgDeptCodg = department.Number
  1071. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1072. fsiOPFLD.BilgDrName = doctor.UserName
  1073. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1074. case 0:
  1075. break
  1076. case 1:
  1077. fsiOPFLD.MedChrgitmType = "14"
  1078. break
  1079. case 2:
  1080. fsiOPFLD.MedChrgitmType = "05"
  1081. break
  1082. case 3:
  1083. fsiOPFLD.MedChrgitmType = "03"
  1084. break
  1085. case 4:
  1086. fsiOPFLD.MedChrgitmType = "03"
  1087. break
  1088. case 5:
  1089. fsiOPFLD.MedChrgitmType = "08"
  1090. break
  1091. case 6:
  1092. fsiOPFLD.MedChrgitmType = "14"
  1093. break
  1094. case 7:
  1095. fsiOPFLD.MedChrgitmType = "14"
  1096. break
  1097. case 8:
  1098. fsiOPFLD.MedChrgitmType = "03"
  1099. break
  1100. case 9:
  1101. fsiOPFLD.MedChrgitmType = "14"
  1102. break
  1103. case 10:
  1104. fsiOPFLD.MedChrgitmType = "14"
  1105. break
  1106. case 11:
  1107. fsiOPFLD.MedChrgitmType = "06"
  1108. break
  1109. case 12:
  1110. fsiOPFLD.MedChrgitmType = "12"
  1111. break
  1112. case 13:
  1113. fsiOPFLD.MedChrgitmType = "01"
  1114. break
  1115. case 14:
  1116. fsiOPFLD.MedChrgitmType = "04"
  1117. break
  1118. case 15:
  1119. fsiOPFLD.MedChrgitmType = "14"
  1120. break
  1121. }
  1122. memo["hosp_appr_flag"] = "1"
  1123. memo["invoice_no"] = fapiao_code
  1124. memo["memo"] = "自费"
  1125. bytesData, _ := json.Marshal(memo)
  1126. fsiOPFLD.Memo = string(bytesData)
  1127. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1128. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1129. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1130. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1131. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1132. fsiOPFLD.BilgDeptName = department.Name
  1133. fsiOPFLD.BilgDeptCodg = department.Number
  1134. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1135. fsiOPFLD.BilgDrName = doctor.UserName
  1136. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1137. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1138. fsiOPFLD.MedChrgitmType = "08"
  1139. memo["hosp_appr_flag"] = "1"
  1140. memo["invoice_no"] = fapiao_code
  1141. memo["memo"] = "自费"
  1142. bytesData, _ := json.Marshal(memo)
  1143. fsiOPFLD.Memo = string(bytesData)
  1144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1145. }
  1146. }
  1147. }
  1148. for _, items := range order_info_two {
  1149. memo := make(map[string]interface{})
  1150. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1151. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1152. fsiOPFLD.MedType = pre.MedType
  1153. fsiOPFLD.BkkpSn = items.FeedetlSn
  1154. fsiOPFLD.FixmedinsCode = miConfig.Code
  1155. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1156. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1157. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1158. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1159. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1160. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1161. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1162. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1163. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1164. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1165. fsiOPFLD.BilgDeptName = department.Name
  1166. fsiOPFLD.BilgDeptCodg = department.Number
  1167. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1168. fsiOPFLD.BilgDrName = doctor.UserName
  1169. fsiOPFLD.MedChrgitmType = "09"
  1170. memo["hosp_appr_flag"] = "1"
  1171. memo["invoice_no"] = fapiao_code
  1172. memo["memo"] = "自费"
  1173. bytesData, _ := json.Marshal(memo)
  1174. fsiOPFLD.Memo = string(bytesData)
  1175. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1176. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1177. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1178. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1179. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1180. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1181. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1182. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1183. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1184. fsiOPFLD.BilgDeptName = department.Name
  1185. fsiOPFLD.BilgDeptCodg = department.Number
  1186. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1187. fsiOPFLD.BilgDrName = doctor.UserName
  1188. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1189. case 0:
  1190. break
  1191. case 1:
  1192. fsiOPFLD.MedChrgitmType = "14"
  1193. break
  1194. case 2:
  1195. fsiOPFLD.MedChrgitmType = "05"
  1196. break
  1197. case 3:
  1198. fsiOPFLD.MedChrgitmType = "03"
  1199. break
  1200. case 4:
  1201. fsiOPFLD.MedChrgitmType = "03"
  1202. break
  1203. case 5:
  1204. fsiOPFLD.MedChrgitmType = "08"
  1205. break
  1206. case 6:
  1207. fsiOPFLD.MedChrgitmType = "14"
  1208. break
  1209. case 7:
  1210. fsiOPFLD.MedChrgitmType = "14"
  1211. break
  1212. case 8:
  1213. fsiOPFLD.MedChrgitmType = "03"
  1214. break
  1215. case 9:
  1216. fsiOPFLD.MedChrgitmType = "14"
  1217. break
  1218. case 10:
  1219. fsiOPFLD.MedChrgitmType = "14"
  1220. break
  1221. case 11:
  1222. fsiOPFLD.MedChrgitmType = "06"
  1223. break
  1224. case 12:
  1225. fsiOPFLD.MedChrgitmType = "12"
  1226. break
  1227. case 13:
  1228. fsiOPFLD.MedChrgitmType = "01"
  1229. break
  1230. case 14:
  1231. fsiOPFLD.MedChrgitmType = "04"
  1232. break
  1233. case 15:
  1234. fsiOPFLD.MedChrgitmType = "14"
  1235. break
  1236. }
  1237. memo["hosp_appr_flag"] = "1"
  1238. memo["invoice_no"] = fapiao_code
  1239. memo["memo"] = "自费"
  1240. bytesData, _ := json.Marshal(memo)
  1241. fsiOPFLD.Memo = string(bytesData)
  1242. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1243. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1244. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1245. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1246. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1247. fsiOPFLD.BilgDeptName = department.Name
  1248. fsiOPFLD.BilgDeptCodg = department.Number
  1249. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1250. fsiOPFLD.BilgDrName = doctor.UserName
  1251. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1252. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1253. fsiOPFLD.MedChrgitmType = "08"
  1254. memo["hosp_appr_flag"] = "1"
  1255. memo["invoice_no"] = fapiao_code
  1256. memo["memo"] = "自费"
  1257. bytesData, _ := json.Marshal(memo)
  1258. fsiOPFLD.Memo = string(bytesData)
  1259. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1260. }
  1261. }
  1262. }
  1263. fmt.Println(fsiOPFLDs)
  1264. struct4201A.Fopfd = fsiOPFLDs
  1265. fmt.Println(struct4201A.Fopfd)
  1266. var struct4202 models.Struct4202
  1267. timeLayout := "2006-01-02 15:04:05"
  1268. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  1269. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1270. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1271. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1272. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1273. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1274. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1275. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  1276. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  1277. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1278. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1279. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1280. var config []*models.HisXtDiagnoseConfig
  1281. for _, item := range diagnosis_ids {
  1282. id, _ := strconv.ParseInt(item, 10, 64)
  1283. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1284. config = append(config, &diagnosisConfig)
  1285. }
  1286. var tempDiaginfos []models.OwnPayPatnDiagListD
  1287. for index, item := range config {
  1288. if index == 0 {
  1289. var tempDiaginfo models.OwnPayPatnDiagListD
  1290. tempDiaginfo.InoutDiagType = "1"
  1291. tempDiaginfo.DiagCode = item.CountryCode
  1292. tempDiaginfo.DiagName = item.CountryContentName
  1293. tempDiaginfo.DiagType = "1"
  1294. tempDiaginfo.DiagSrtNo = "1"
  1295. tempDiaginfo.MaindiagFlag = "1"
  1296. tempDiaginfo.ValiFlag = "1"
  1297. tempDiaginfo.DiagDrName = doctor.UserName
  1298. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1299. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1300. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1301. } else {
  1302. var tempDiaginfo models.OwnPayPatnDiagListD
  1303. tempDiaginfo.DiagCode = item.CountryCode
  1304. tempDiaginfo.DiagName = item.CountryContentName
  1305. tempDiaginfo.DiagType = "2"
  1306. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1307. tempDiaginfo.MaindiagFlag = "0"
  1308. tempDiaginfo.ValiFlag = "1"
  1309. tempDiaginfo.DiagDrName = doctor.UserName
  1310. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1311. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1313. }
  1314. }
  1315. struct4202.ODiagListD = tempDiaginfos
  1316. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  1317. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  1318. var res2 ResultSix
  1319. var respJSON2 map[string]interface{}
  1320. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1323. return
  1324. }
  1325. userJSONBytes2, _ := json.Marshal(respJSON2)
  1326. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1327. utils.ErrorLog("解析失败:%v", err)
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. return
  1330. }
  1331. if res2.Infcode != 0 {
  1332. c.ServeSuccessJSON(map[string]interface{}{
  1333. "failed_code": -10,
  1334. "msg": res2.ErrMsg,
  1335. })
  1336. return
  1337. } else {
  1338. order.IsUploadDiagnose = 1
  1339. order.IsUploadOrderInfo = 1
  1340. service.UpdateOrderTwo(order)
  1341. c.ServeSuccessJSON(map[string]interface{}{
  1342. "msg": "上传成功",
  1343. })
  1344. }
  1345. }
  1346. func (c *HisApiController) Get4207() {
  1347. admin_user_id, _ := c.GetInt64("admin_user_id")
  1348. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1350. order_id, _ := c.GetInt64("order_id")
  1351. order, _ := service.GetHisOrderByIDTwo(order_id)
  1352. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1353. var struct4207 models.Struct4207
  1354. struct4207.PageNum = "1"
  1355. struct4207.PageSize = "1000"
  1356. struct4207.FixmedinsCode = miConfig.Code
  1357. struct4207.FixmedinsMdtrtID = order.Number
  1358. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  1359. saveLog(result, requestLog, "4207", "查询")
  1360. var res2 ResultSix
  1361. var respJSON2 map[string]interface{}
  1362. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1365. return
  1366. }
  1367. userJSONBytes2, _ := json.Marshal(respJSON2)
  1368. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1369. utils.ErrorLog("解析失败:%v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. if res2.Infcode != 0 {
  1374. c.ServeSuccessJSON(map[string]interface{}{
  1375. "failed_code": -10,
  1376. "msg": res2.ErrMsg,
  1377. })
  1378. return
  1379. } else {
  1380. c.ServeSuccessJSON(map[string]interface{}{
  1381. "msg": "查询成功",
  1382. })
  1383. }
  1384. }
  1385. func (c *HisApiController) Get4208() {
  1386. admin_user_id, _ := c.GetInt64("admin_user_id")
  1387. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1389. order_id, _ := c.GetInt64("order_id")
  1390. order, _ := service.GetHisOrderByIDTwo(order_id)
  1391. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1392. var struct4208 models.Struct4208
  1393. struct4208.PageNum = "1"
  1394. struct4208.PageSize = "1000"
  1395. struct4208.PsnCertType = "01"
  1396. struct4208.Certno = his.Certno
  1397. struct4208.MedType = order.MedType
  1398. struct4208.PsnName = his.Name
  1399. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  1400. saveLog(result, requestLog, "4208", "查询")
  1401. var res2 ResultSix
  1402. var respJSON2 map[string]interface{}
  1403. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. userJSONBytes2, _ := json.Marshal(respJSON2)
  1409. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1410. utils.ErrorLog("解析失败:%v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. if res2.Infcode != 0 {
  1415. c.ServeSuccessJSON(map[string]interface{}{
  1416. "failed_code": -10,
  1417. "msg": res2.ErrMsg,
  1418. })
  1419. return
  1420. } else {
  1421. c.ServeSuccessJSON(map[string]interface{}{
  1422. "msg": "查询成功",
  1423. })
  1424. }
  1425. }
  1426. func (c *HisApiController) Get4209() {
  1427. admin_user_id, _ := c.GetInt64("admin_user_id")
  1428. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1430. order_id, _ := c.GetInt64("order_id")
  1431. order, _ := service.GetHisOrderByIDTwo(order_id)
  1432. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1433. var struct4209 models.Struct4209
  1434. struct4209.FixmedinsMdtrtID = order.Number
  1435. struct4209.FixmedinsCode = miConfig.Code
  1436. struct4209.PageSize = "1000"
  1437. struct4209.PageNum = "1"
  1438. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  1439. saveLog(result, requestLog, "4209", "查询")
  1440. var res2 ResultSix
  1441. var respJSON2 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes2, _ := json.Marshal(respJSON2)
  1448. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. if res2.Infcode != 0 {
  1454. c.ServeSuccessJSON(map[string]interface{}{
  1455. "failed_code": -10,
  1456. "msg": res2.ErrMsg,
  1457. })
  1458. return
  1459. } else {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "msg": "查询成功",
  1462. })
  1463. }
  1464. }
  1465. type Result3101 struct {
  1466. Infcode string `json:"infcode"`
  1467. InfRefmsgid string `json:"inf_refmsgid"`
  1468. RefmsgTime string `json:"refmsg_time"`
  1469. RespondTime string `json:"respond_time"`
  1470. Enctype string `json:"enctype"`
  1471. Signtype string `json:"signtype"`
  1472. ErrMsg string `json:"err_msg"`
  1473. Output struct {
  1474. Result []struct {
  1475. JudgeResultDetailDtos []struct {
  1476. VolaItemType string `json:"vola_item_type"`
  1477. MdtrtID string `json:"mdtrt_id"`
  1478. JrdID string `json:"jrd_id"`
  1479. PatnID string `json:"patn_id"`
  1480. RxID string `json:"rx_id"`
  1481. VolaAmt interface{} `json:"vola_amt"`
  1482. } `json:"judge_result_detail_dtos"`
  1483. RuleID string `json:"rule_id"`
  1484. VolaEvid string `json:"vola_evid"`
  1485. MdtrtID string `json:"mdtrt_id"`
  1486. RuleName string `json:"rule_name"`
  1487. VolaAmtStas string `json:"vola_amt_stas"`
  1488. JrID string `json:"jr_id"`
  1489. PatnID string `json:"patn_id"`
  1490. SevDeg string `json:"sev_deg"`
  1491. VolaAmt float64 `json:"vola_amt"`
  1492. VolaBhvrType string `json:"vola_bhvr_type"`
  1493. VolaCont string `json:"vola_cont"`
  1494. } `json:"result"`
  1495. } `json:"output"`
  1496. }
  1497. func (c *HisApiController) ReadEleToken() {
  1498. admin_user_id, _ := c.GetInt64("admin_user_id")
  1499. his_patient_id, _ := c.GetInt64("his_patient_id")
  1500. adminUser := c.GetAdminUserInfo()
  1501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1503. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1504. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1505. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  1506. if len(tokens) > 0 {
  1507. c.ServeSuccessJSON(map[string]interface{}{
  1508. "msg": "读取成功",
  1509. })
  1510. } else {
  1511. c.ServeSuccessJSON(map[string]interface{}{
  1512. "failed_code": -10,
  1513. "msg": "读取失败",
  1514. })
  1515. }
  1516. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1517. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1518. if len(errMsg) == 0 {
  1519. type ELeData struct {
  1520. Data struct {
  1521. IdNo string `json:"idNo"`
  1522. IdType string `json:"idType"`
  1523. UserName string `json:"userName"`
  1524. EcToken string `json:"ecToken"`
  1525. InsuOrg string `json:"insuOrg"`
  1526. Gender string `json:"gender"`
  1527. Birthday string `json:"birthday"`
  1528. Nationality string `json:"nationality"`
  1529. Email string `json:"email"`
  1530. Extra string `json:"extra"`
  1531. } `json:"data"`
  1532. Code int `json:"code"`
  1533. Message string `json:"message"`
  1534. }
  1535. var ele ELeData
  1536. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1537. if err != nil {
  1538. utils.ErrorLog("解析失败:%v", err)
  1539. }
  1540. token := ele.Data.EcToken
  1541. if len(token) > 0 {
  1542. psn := &models.HisPsn{
  1543. PsnNo: his.PsnNo,
  1544. Age: 0,
  1545. PatientId: his.PatientId,
  1546. Certno: his.Certno,
  1547. Brdy: his.Brdy,
  1548. Gend: his.Gend,
  1549. Naty: his.Naty,
  1550. PsnCertType: his.PsnCertType,
  1551. PsnName: his.PsnName,
  1552. Idetinfo: his.Idetinfo,
  1553. Insuinfo: his.Iinfo,
  1554. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1555. CardInfo: outPutInfo,
  1556. VerifyNumber: token,
  1557. }
  1558. service.CreateHisPsn(psn)
  1559. }
  1560. if len(token) > 0 {
  1561. c.ServeSuccessJSON(map[string]interface{}{
  1562. "msg": "读取成功",
  1563. })
  1564. } else {
  1565. c.ServeSuccessJSON(map[string]interface{}{
  1566. "failed_code": -10,
  1567. "msg": "读取失败",
  1568. })
  1569. }
  1570. }
  1571. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1572. if initFlag == 0 {
  1573. c.TestGetJiangXiBasBaseInit()
  1574. }
  1575. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1576. type ELeData struct {
  1577. Data struct {
  1578. IdNo string `json:"idNo"`
  1579. IdType string `json:"idType"`
  1580. UserName string `json:"userName"`
  1581. EcToken string `json:"ecToken"`
  1582. InsuOrg string `json:"insuOrg"`
  1583. Gender string `json:"gender"`
  1584. Birthday string `json:"birthday"`
  1585. Nationality string `json:"nationality"`
  1586. Email string `json:"email"`
  1587. Extra string `json:"extra"`
  1588. } `json:"data"`
  1589. Code int `json:"code"`
  1590. Message string `json:"message"`
  1591. }
  1592. var ele ELeData
  1593. err := json.Unmarshal([]byte(json_result), &ele)
  1594. if err != nil {
  1595. utils.ErrorLog("解析失败:%v", err)
  1596. }
  1597. token := ele.Data.EcToken
  1598. token = Remove0000(token)
  1599. fmt.Println(ele.Data.UserName)
  1600. 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)
  1601. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1602. var res ResultTwo
  1603. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1604. utils.ErrorLog("解析失败:%v", err)
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1606. return
  1607. }
  1608. if res.Infcode == 0 {
  1609. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1610. if err == gorm.ErrRecordNotFound {
  1611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1612. return
  1613. } else if err != nil {
  1614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1615. return
  1616. } else {
  1617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1619. infoStr := string(Iinfos)
  1620. idetinfoStr := string(Idetinfos)
  1621. psn := &models.HisPsn{
  1622. PsnNo: res.Output.Baseinfo.PsnNo,
  1623. Age: res.Output.Baseinfo.Age,
  1624. PatientId: patient.ID,
  1625. Certno: res.Output.Baseinfo.Certno,
  1626. Brdy: res.Output.Baseinfo.Brdy,
  1627. Gend: res.Output.Baseinfo.Gend,
  1628. Naty: res.Output.Baseinfo.Naty,
  1629. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1630. PsnName: res.Output.Baseinfo.PsnName,
  1631. Idetinfo: idetinfoStr,
  1632. Insuinfo: infoStr,
  1633. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1634. CardInfo: "",
  1635. VerifyNumber: token,
  1636. }
  1637. service.CreateHisPsn(psn)
  1638. c.ServeSuccessJSON(map[string]interface{}{
  1639. "patient": patient,
  1640. "number": token,
  1641. })
  1642. }
  1643. } else {
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1645. return
  1646. }
  1647. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1648. idNo := c.GetString("idNo")
  1649. userName := c.GetString("userName")
  1650. ecToken := c.GetString("ecToken")
  1651. insuOrg := c.GetString("insuOrg")
  1652. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  1653. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1654. var res ResultTwo
  1655. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1656. utils.ErrorLog("解析失败:%v", err)
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. if res.Infcode == 0 {
  1661. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1662. if err == gorm.ErrRecordNotFound {
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1664. return
  1665. } else if err != nil {
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1667. return
  1668. } else {
  1669. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1670. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1671. infoStr := string(Iinfos)
  1672. idetinfoStr := string(Idetinfos)
  1673. psn := &models.HisPsn{
  1674. PsnNo: res.Output.Baseinfo.PsnNo,
  1675. Age: res.Output.Baseinfo.Age,
  1676. PatientId: patient.ID,
  1677. Certno: res.Output.Baseinfo.Certno,
  1678. Brdy: res.Output.Baseinfo.Brdy,
  1679. Gend: res.Output.Baseinfo.Gend,
  1680. Naty: res.Output.Baseinfo.Naty,
  1681. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1682. PsnName: res.Output.Baseinfo.PsnName,
  1683. Idetinfo: idetinfoStr,
  1684. Insuinfo: infoStr,
  1685. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1686. CardInfo: "",
  1687. VerifyNumber: ecToken,
  1688. InsuplcAdmdvs: insuOrg,
  1689. }
  1690. service.CreateHisPsn(psn)
  1691. c.ServeSuccessJSON(map[string]interface{}{
  1692. "patient": patient,
  1693. "number": ecToken,
  1694. })
  1695. }
  1696. } else {
  1697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1698. return
  1699. }
  1700. } else {
  1701. //if initFlag == 0 {
  1702. // c.TestGetBasBaseInit()
  1703. //}
  1704. //token := c.GetEleBaseInfo()
  1705. //token = Remove0000(token)
  1706. type ELeData struct {
  1707. Code string `json:"code"`
  1708. Data struct {
  1709. Aac002 string `json:"aac002"`
  1710. Aaz500 string `json:"aaz500"`
  1711. ActCardNo string `json:"actCardNo"`
  1712. Bab520 string `json:"bab520"`
  1713. Bkz543 string `json:"bkz543"`
  1714. BusinessType string `json:"businessType"`
  1715. CertfCodg string `json:"certfCodg"`
  1716. EcIndexNo string `json:"ecIndexNo"`
  1717. EcToken string `json:"ecToken"`
  1718. ID0000 string `json:"id0000"`
  1719. IDNo string `json:"idNo"`
  1720. IDType string `json:"idType"`
  1721. Idcode string `json:"idcode"`
  1722. IdentityToken string `json:"identity_token"`
  1723. InsuOrg string `json:"insuOrg"`
  1724. OfficeID string `json:"officeId"`
  1725. OfficeName string `json:"officeName"`
  1726. OperatorID string `json:"operatorId"`
  1727. OperatorName string `json:"operatorName"`
  1728. OrgID string `json:"orgId"`
  1729. UserName string `json:"userName"`
  1730. } `json:"data"`
  1731. Infno interface{} `json:"infno"`
  1732. Message string `json:"message"`
  1733. OrgID string `json:"orgId"`
  1734. TransType string `json:"transType"`
  1735. }
  1736. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  1737. fmt.Println(result)
  1738. outPutInfo := Remove0000(result)
  1739. fmt.Println(outPutInfo)
  1740. var ele ELeData
  1741. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1742. if err != nil {
  1743. utils.ErrorLog("解析失败:%v", err)
  1744. }
  1745. token := ele.Data.EcToken
  1746. if len(token) > 0 {
  1747. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  1748. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1749. var res ResultTwo
  1750. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1751. utils.ErrorLog("解析失败:%v", err)
  1752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1753. return
  1754. }
  1755. if res.Infcode == 0 {
  1756. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1757. if err == gorm.ErrRecordNotFound {
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1759. return
  1760. } else if err != nil {
  1761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1762. return
  1763. } else {
  1764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1766. infoStr := string(Iinfos)
  1767. idetinfoStr := string(Idetinfos)
  1768. psn := &models.HisPsn{
  1769. PsnNo: res.Output.Baseinfo.PsnNo,
  1770. Age: res.Output.Baseinfo.Age,
  1771. PatientId: patient.ID,
  1772. Certno: res.Output.Baseinfo.Certno,
  1773. Brdy: res.Output.Baseinfo.Brdy,
  1774. Gend: res.Output.Baseinfo.Gend,
  1775. Naty: res.Output.Baseinfo.Naty,
  1776. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1777. PsnName: res.Output.Baseinfo.PsnName,
  1778. Idetinfo: idetinfoStr,
  1779. Insuinfo: infoStr,
  1780. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1781. CardInfo: "",
  1782. VerifyNumber: token,
  1783. }
  1784. service.CreateHisPsn(psn)
  1785. c.ServeSuccessJSON(map[string]interface{}{
  1786. "msg": "读取成功",
  1787. })
  1788. }
  1789. } else {
  1790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1791. return
  1792. }
  1793. } else {
  1794. c.ServeSuccessJSON(map[string]interface{}{
  1795. "failed_code": -10,
  1796. "msg": "读取失败",
  1797. })
  1798. }
  1799. }
  1800. }
  1801. func (c *HisApiController) Get9001() {
  1802. adminUser := c.GetAdminUserInfo()
  1803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1804. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1805. if miConfig.MdtrtareaAdmvs == "350500" {
  1806. service.GetFjAuthorizationInfo(miConfig.Code)
  1807. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1808. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1809. var dat map[string]interface{}
  1810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1811. fmt.Println(dat)
  1812. } else {
  1813. fmt.Println(err)
  1814. }
  1815. userJSONBytes, _ := json.Marshal(dat)
  1816. var res models.Result9001
  1817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. } else {
  1823. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1824. var dat map[string]interface{}
  1825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1826. fmt.Println(dat)
  1827. } else {
  1828. fmt.Println(err)
  1829. }
  1830. userJSONBytes, _ := json.Marshal(dat)
  1831. var res models.Result9001
  1832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1833. utils.ErrorLog("解析失败:%v", err)
  1834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1835. return
  1836. }
  1837. }
  1838. }
  1839. 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) {
  1840. var res Result3101
  1841. adminUser := c.GetAdminUserInfo()
  1842. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1843. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. //record_time := c.GetString("record_time")
  1846. //trig_scen := c.GetString("trig_scen")
  1847. timeLayout := "2006-01-02"
  1848. loc, _ := time.LoadLocation("Local")
  1849. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1850. if err != nil {
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1852. return res
  1853. }
  1854. recordDateTime := theTime.Unix()
  1855. var patientPrescription models.HisPrescriptionInfo
  1856. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1857. //if patientPrescription.ID == 0 {
  1858. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1859. //}
  1860. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1861. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1862. //
  1863. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1864. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1865. var pp models.PublicParams
  1866. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1867. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1868. pp.FixmedinsName = miConfig.OrgName
  1869. pp.FixmedinsCode = miConfig.Code
  1870. pp.RequestUrl = miConfig.Url
  1871. pp.Cainfo = miConfig.Cainfo
  1872. pp.SecretKey = miConfig.SecretKey
  1873. pp.AccessKey = miConfig.AccessKey
  1874. pp.OpterName = roles.UserName
  1875. var config []*models.HisXtDiagnoseConfig
  1876. for _, item := range diagnosis_ids {
  1877. id, _ := strconv.ParseInt(item, 10, 64)
  1878. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1879. config = append(config, &diagnosisConfig)
  1880. }
  1881. var pd models.PatientDtos
  1882. pd.PatnID = his.PsnNo
  1883. pd.PatnName = his.Name
  1884. pd.Gend = his.Gend
  1885. pd.Brdy = his.Brdy
  1886. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1887. pd.CurrMdtrtID = his.Number
  1888. var fed models.FsiEncounterDtos
  1889. fed.MdtrtID = his.Number
  1890. fed.MedinsID = miConfig.Code
  1891. fed.MedinsName = miConfig.OrgName
  1892. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1893. fed.MedMdtrtType = "1"
  1894. fed.MedinsType = "1"
  1895. fed.MedinsLv = "11"
  1896. tm := time.Unix(his.RecordDate, 0)
  1897. s_tm := tm.Format("2006-01-02 15:04:05")
  1898. fed.AdmDate = s_tm
  1899. fed.DscgDate = s_tm
  1900. fed.DscgMainDiseCodg = config[0].CountryCode
  1901. fed.DscgMainDiseName = config[0].CountryContentName
  1902. //诊断信息
  1903. var fdds []*models.FsiDiagnoseDtos
  1904. for index, item := range config {
  1905. if index == 0 {
  1906. var fdd models.FsiDiagnoseDtos
  1907. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1908. fdd.InoutDiseType = "1"
  1909. fdd.MaindiseFlag = "1"
  1910. fdd.DiseDate = s_tm
  1911. fdd.DiasSrtNo = "1"
  1912. fdd.DiseName = item.CountryContentName
  1913. fdd.DiseCodg = item.CountryCode
  1914. fdds = append(fdds, &fdd)
  1915. } else {
  1916. var fdd models.FsiDiagnoseDtos
  1917. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1918. fdd.InoutDiseType = "1"
  1919. fdd.MaindiseFlag = "1"
  1920. fdd.DiseDate = s_tm
  1921. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1922. fdd.DiseName = item.CountryContentName
  1923. fdd.DiseCodg = item.CountryCode
  1924. fdds = append(fdds, &fdd)
  1925. }
  1926. }
  1927. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1928. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1929. fed.AdmDeptName = department.Name
  1930. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1931. fed.DscgDeptName = department.Name
  1932. fed.MedMdtrtType = "1"
  1933. fed.MedType = "11"
  1934. //if his.Insutype == "390" {
  1935. // fed.MedType = "1402"
  1936. //} else {
  1937. // fed.MedType = "9933"
  1938. //}
  1939. var orders []*models.FsiOrderDtos
  1940. if trig_scen == "2" {
  1941. //处方医嘱信息
  1942. for _, item := range prescriptions {
  1943. for _, subItem := range item.HisDoctorAdviceInfo {
  1944. var order models.FsiOrderDtos
  1945. order.RxID = strconv.FormatInt(item.ID, 10)
  1946. order.Rxno = strconv.FormatInt(item.ID, 10)
  1947. order.LongDrordFlag = "0"
  1948. order.HilistType = "1"
  1949. order.ChrgType = "1"
  1950. order.DrordBhvr = "-"
  1951. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1952. order.HosplistName = subItem.BaseDrugLib.DrugName
  1953. order.HilistLv = "1"
  1954. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1955. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1956. order.HosplistName = subItem.BaseDrugLib.DrugName
  1957. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1958. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1959. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1960. order.OwnpayAmt = ""
  1961. order.SelfpayAmt = ""
  1962. order.Spec = ""
  1963. order.SpecUnt = ""
  1964. order.DrordBegnDate = s_tm
  1965. order.DrordStopDate = ""
  1966. order.DrordDrCodg = "1"
  1967. order.DrordDeptName = department.Name
  1968. order.DrordDrCodg = "1"
  1969. order.DrordDrName = doctor_info.UserName
  1970. order.DrordDrProfttl = ""
  1971. order.CurrDrordFlag = "1"
  1972. orders = append(orders, &order)
  1973. }
  1974. for _, subItem := range item.HisPrescriptionProject {
  1975. if subItem.Type == 2 {
  1976. var order models.FsiOrderDtos
  1977. order.RxID = strconv.FormatInt(item.ID, 10)
  1978. order.Rxno = strconv.FormatInt(item.ID, 10)
  1979. order.LongDrordFlag = "0"
  1980. order.HilistType = "1"
  1981. order.ChrgType = "1"
  1982. order.DrordBhvr = "-"
  1983. order.HilistCode = subItem.HisProject.MedicalCode
  1984. order.HosplistName = subItem.HisProject.ProjectName
  1985. order.HilistLv = "1"
  1986. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1987. order.HosplistCode = subItem.HisProject.MedicalCode
  1988. order.HosplistName = subItem.HisProject.ProjectName
  1989. order.Cnt = subItem.Count
  1990. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1991. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1992. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1993. order.OwnpayAmt = ""
  1994. order.SelfpayAmt = ""
  1995. order.Spec = ""
  1996. order.SpecUnt = ""
  1997. order.DrordBegnDate = s_tm
  1998. order.DrordStopDate = ""
  1999. order.DrordDrCodg = "1"
  2000. order.DrordDeptName = department.Name
  2001. order.DrordDrCodg = "1"
  2002. order.DrordDrName = doctor_info.UserName
  2003. order.DrordDrProfttl = ""
  2004. order.CurrDrordFlag = "1"
  2005. orders = append(orders, &order)
  2006. }
  2007. if subItem.Type == 3 {
  2008. var order models.FsiOrderDtos
  2009. order.RxID = strconv.FormatInt(item.ID, 10)
  2010. order.Rxno = strconv.FormatInt(item.ID, 10)
  2011. order.LongDrordFlag = "0"
  2012. order.HilistType = "1"
  2013. order.ChrgType = "1"
  2014. order.DrordBhvr = "-"
  2015. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2016. order.HosplistName = subItem.GoodInfo.GoodName
  2017. order.HilistLv = "1"
  2018. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2019. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2020. order.HosplistName = subItem.GoodInfo.GoodName
  2021. order.Cnt = subItem.Count
  2022. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2023. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2024. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2025. order.OwnpayAmt = ""
  2026. order.SelfpayAmt = ""
  2027. order.Spec = ""
  2028. order.SpecUnt = ""
  2029. order.DrordBegnDate = s_tm
  2030. order.DrordStopDate = ""
  2031. order.DrordDrCodg = "1"
  2032. order.DrordDeptName = department.Name
  2033. order.DrordDrCodg = "1"
  2034. order.DrordDrName = doctor_info.UserName
  2035. order.DrordDrProfttl = ""
  2036. order.CurrDrordFlag = "1"
  2037. orders = append(orders, &order)
  2038. }
  2039. }
  2040. }
  2041. //处方医嘱信息
  2042. }
  2043. fed.MatnStas = "0"
  2044. fed.MedfeeSumamt = "0"
  2045. fed.OwnpayAmt = "0"
  2046. fed.SelfpayAmt = "0"
  2047. fed.AcctPayamt = "0"
  2048. fed.MaAmt = "0"
  2049. fed.HifpPayamt = "0"
  2050. fed.SetlTotlnum = "1"
  2051. fed.Insutype = his.Insutype
  2052. fed.ReimFlag = "0"
  2053. fed.OutSetlFlag = "0"
  2054. var fopd []*models.FsiOperationDtosData
  2055. data := make(map[string]interface{})
  2056. data["fed"] = fed
  2057. data["fdd"] = fdds
  2058. data["fod"] = orders
  2059. data["pd"] = pd
  2060. data["pp"] = pp
  2061. data["fopd"] = fopd
  2062. data["trig_scen"] = trig_scen
  2063. fmt.Println(data)
  2064. fmt.Println(fed)
  2065. fmt.Println(fdds)
  2066. fmt.Println(orders)
  2067. fmt.Println(pd)
  2068. fmt.Println(pp)
  2069. fmt.Println(fopd)
  2070. client := &http.Client{}
  2071. bytesData, _ := json.Marshal(data)
  2072. var req *http.Request
  2073. if miConfig.MdtrtareaAdmvs == "320921" {
  2074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2075. } else {
  2076. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2077. }
  2078. resp, _ := client.Do(req)
  2079. defer resp.Body.Close()
  2080. body, ioErr := ioutil.ReadAll(resp.Body)
  2081. if ioErr != nil {
  2082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2084. return res
  2085. }
  2086. var respJSON map[string]interface{}
  2087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2090. return res
  2091. }
  2092. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2093. fmt.Println(respJSON)
  2094. result, _ := json.Marshal(respJSON)
  2095. fmt.Println(result)
  2096. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2097. utils.ErrorLog("解析失败:%v", err)
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. return res
  2100. }
  2101. return res
  2102. }
  2103. 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) {
  2104. adminUser := c.GetAdminUserInfo()
  2105. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2106. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2108. //record_time := c.GetString("record_time")
  2109. //trig_scen := c.GetString("trig_scen")
  2110. timeLayout := "2006-01-02"
  2111. loc, _ := time.LoadLocation("Local")
  2112. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2113. if err != nil {
  2114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2115. return res
  2116. }
  2117. recordDateTime := theTime.Unix()
  2118. var patientPrescription models.HisPrescriptionInfo
  2119. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2120. if patientPrescription.ID == 0 {
  2121. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2122. }
  2123. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2124. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2125. //
  2126. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2127. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2128. var pp models.PublicParams
  2129. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2130. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2131. pp.FixmedinsName = miConfig.OrgName
  2132. pp.FixmedinsCode = miConfig.Code
  2133. pp.RequestUrl = miConfig.Url
  2134. pp.Cainfo = miConfig.Cainfo
  2135. pp.SecretKey = miConfig.SecretKey
  2136. pp.AccessKey = miConfig.AccessKey
  2137. pp.OpterName = roles.UserName
  2138. var config []*models.HisXtDiagnoseConfig
  2139. for _, item := range diagnosis_ids {
  2140. id, _ := strconv.ParseInt(item, 10, 64)
  2141. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2142. config = append(config, &diagnosisConfig)
  2143. }
  2144. var pd models.PatientDtos
  2145. pd.PatnID = his.PsnNo
  2146. pd.PatnName = his.Name
  2147. pd.Gend = his.Gend
  2148. pd.Brdy = his.Brdy
  2149. pd.Poolarea = his.InsuplcAdmdvs
  2150. pd.CurrMdtrtID = his.Number
  2151. var fed models.FsiEncounterDtos
  2152. fed.MdtrtID = his.Number
  2153. fed.MedinsID = miConfig.Code
  2154. fed.MedinsName = miConfig.OrgName
  2155. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2156. fed.MedMdtrtType = "1"
  2157. fed.MedinsType = "1"
  2158. fed.MedinsLv = "11"
  2159. tm := time.Unix(his.RecordDate, 0)
  2160. s_tm := tm.Format("2006-01-02 15:04:05")
  2161. fed.AdmDate = s_tm
  2162. fed.DscgDate = s_tm
  2163. fed.DscgMainDiseCodg = config[0].CountryCode
  2164. fed.DscgMainDiseName = config[0].CountryContentName
  2165. //诊断信息
  2166. var fdds []*models.FsiDiagnoseDtos
  2167. for index, item := range config {
  2168. if index == 0 {
  2169. var fdd models.FsiDiagnoseDtos
  2170. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2171. fdd.InoutDiseType = "1"
  2172. fdd.MaindiseFlag = "1"
  2173. fdd.DiseDate = s_tm
  2174. fdd.DiasSrtNo = "1"
  2175. fdd.DiseName = item.CountryContentName
  2176. fdd.DiseCodg = item.CountryCode
  2177. fdds = append(fdds, &fdd)
  2178. } else {
  2179. var fdd models.FsiDiagnoseDtos
  2180. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2181. fdd.InoutDiseType = "1"
  2182. fdd.MaindiseFlag = "1"
  2183. fdd.DiseDate = s_tm
  2184. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2185. fdd.DiseName = item.CountryContentName
  2186. fdd.DiseCodg = item.CountryCode
  2187. fdds = append(fdds, &fdd)
  2188. }
  2189. }
  2190. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2191. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2192. fed.AdmDeptName = department.Name
  2193. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2194. fed.DscgDeptName = department.Name
  2195. fed.MedMdtrtType = "1"
  2196. fed.MedType = "11"
  2197. //if his.Insutype == "390" {
  2198. // fed.MedType = "1402"
  2199. //} else {
  2200. // fed.MedType = "9933"
  2201. //}
  2202. var orders []*models.FsiOrderDtos
  2203. if trig_scen == "2" {
  2204. //处方医嘱信息
  2205. for _, item := range prescriptions {
  2206. for _, subItem := range item.HisDoctorAdviceInfo {
  2207. var order models.FsiOrderDtos
  2208. order.RxID = strconv.FormatInt(item.ID, 10)
  2209. order.Rxno = strconv.FormatInt(item.ID, 10)
  2210. order.LongDrordFlag = "0"
  2211. order.HilistType = "1"
  2212. order.ChrgType = "1"
  2213. order.DrordBhvr = "-"
  2214. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2215. order.HosplistName = subItem.BaseDrugLib.DrugName
  2216. order.HilistLv = "1"
  2217. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2218. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2219. order.HosplistName = subItem.BaseDrugLib.DrugName
  2220. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2221. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2222. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2223. order.OwnpayAmt = ""
  2224. order.SelfpayAmt = ""
  2225. order.Spec = ""
  2226. order.SpecUnt = ""
  2227. order.DrordBegnDate = s_tm
  2228. order.DrordStopDate = ""
  2229. order.DrordDrCodg = "1"
  2230. order.DrordDeptName = department.Name
  2231. order.DrordDrCodg = "1"
  2232. order.DrordDrName = doctor_info.UserName
  2233. order.DrordDrProfttl = ""
  2234. order.CurrDrordFlag = "1"
  2235. orders = append(orders, &order)
  2236. }
  2237. for _, subItem := range item.HisPrescriptionProject {
  2238. if subItem.Type == 2 {
  2239. var order models.FsiOrderDtos
  2240. order.RxID = strconv.FormatInt(item.ID, 10)
  2241. order.Rxno = strconv.FormatInt(item.ID, 10)
  2242. order.LongDrordFlag = "0"
  2243. order.HilistType = "1"
  2244. order.ChrgType = "1"
  2245. order.DrordBhvr = "-"
  2246. order.HilistCode = subItem.HisProject.MedicalCode
  2247. order.HosplistName = subItem.HisProject.ProjectName
  2248. order.HilistLv = "1"
  2249. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2250. order.HosplistCode = subItem.HisProject.MedicalCode
  2251. order.HosplistName = subItem.HisProject.ProjectName
  2252. order.Cnt = subItem.Count
  2253. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2254. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2255. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2256. order.OwnpayAmt = ""
  2257. order.SelfpayAmt = ""
  2258. order.Spec = ""
  2259. order.SpecUnt = ""
  2260. order.DrordBegnDate = s_tm
  2261. order.DrordStopDate = ""
  2262. order.DrordDrCodg = "1"
  2263. order.DrordDeptName = department.Name
  2264. order.DrordDrCodg = "1"
  2265. order.DrordDrName = doctor_info.UserName
  2266. order.DrordDrProfttl = ""
  2267. order.CurrDrordFlag = "1"
  2268. orders = append(orders, &order)
  2269. }
  2270. if subItem.Type == 3 {
  2271. var order models.FsiOrderDtos
  2272. order.RxID = strconv.FormatInt(item.ID, 10)
  2273. order.Rxno = strconv.FormatInt(item.ID, 10)
  2274. order.LongDrordFlag = "0"
  2275. order.HilistType = "1"
  2276. order.ChrgType = "1"
  2277. order.DrordBhvr = "-"
  2278. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2279. order.HosplistName = subItem.GoodInfo.GoodName
  2280. order.HilistLv = "1"
  2281. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2282. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2283. order.HosplistName = subItem.GoodInfo.GoodName
  2284. order.Cnt = subItem.Count
  2285. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2286. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2287. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2288. order.OwnpayAmt = ""
  2289. order.SelfpayAmt = ""
  2290. order.Spec = ""
  2291. order.SpecUnt = ""
  2292. order.DrordBegnDate = s_tm
  2293. order.DrordStopDate = ""
  2294. order.DrordDrCodg = "1"
  2295. order.DrordDeptName = department.Name
  2296. order.DrordDrCodg = "1"
  2297. order.DrordDrName = doctor_info.UserName
  2298. order.DrordDrProfttl = ""
  2299. order.CurrDrordFlag = "1"
  2300. orders = append(orders, &order)
  2301. }
  2302. }
  2303. }
  2304. //处方医嘱信息
  2305. }
  2306. fed.MatnStas = "0"
  2307. fed.MedfeeSumamt = "0"
  2308. fed.OwnpayAmt = "0"
  2309. fed.SelfpayAmt = "0"
  2310. fed.AcctPayamt = "0"
  2311. fed.MaAmt = "0"
  2312. fed.HifpPayamt = "0"
  2313. fed.SetlTotlnum = "1"
  2314. fed.Insutype = his.Insutype
  2315. fed.ReimFlag = "0"
  2316. fed.OutSetlFlag = "0"
  2317. var fopd []*models.FsiOperationDtosData
  2318. data := make(map[string]interface{})
  2319. data["fed"] = fed
  2320. data["fdd"] = fdds
  2321. data["fod"] = orders
  2322. data["pd"] = pd
  2323. data["pp"] = pp
  2324. data["fopd"] = fopd
  2325. data["trig_scen"] = trig_scen
  2326. fmt.Println(data)
  2327. fmt.Println(fed)
  2328. fmt.Println(fdds)
  2329. fmt.Println(orders)
  2330. fmt.Println(pd)
  2331. fmt.Println(pp)
  2332. fmt.Println(fopd)
  2333. client := &http.Client{}
  2334. bytesData, _ := json.Marshal(data)
  2335. var req *http.Request
  2336. if miConfig.MdtrtareaAdmvs == "320921" {
  2337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2338. } else {
  2339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2340. }
  2341. resp, _ := client.Do(req)
  2342. defer resp.Body.Close()
  2343. body, ioErr := ioutil.ReadAll(resp.Body)
  2344. if ioErr != nil {
  2345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. return res
  2348. }
  2349. var respJSON map[string]interface{}
  2350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. return res
  2354. }
  2355. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2356. result, _ := json.Marshal(respJSON)
  2357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2358. utils.ErrorLog("解析失败:%v", err)
  2359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2360. return res
  2361. }
  2362. return res
  2363. }
  2364. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  2365. ////patient_id, _ := c.GetInt64("patient_id")
  2366. //order_id, _ := c.GetInt64("order_id")
  2367. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  2368. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  2369. //trig_scen := c.GetString("trig_scen")
  2370. adminUser := c.GetAdminUserInfo()
  2371. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2372. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2374. record_time := c.GetString("record_time")
  2375. order, _ := service.GetHisOrderByID(order_id)
  2376. timeLayout := "2006-01-02"
  2377. loc, _ := time.LoadLocation("Local")
  2378. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2379. if err != nil {
  2380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2381. return
  2382. }
  2383. recordDateTime := theTime.Unix()
  2384. var patientPrescription models.HisPrescriptionInfo
  2385. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2386. if patientPrescription.ID == 0 {
  2387. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2388. }
  2389. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2390. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2391. //
  2392. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2393. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2394. var pp models.PublicParams
  2395. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2396. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2397. pp.FixmedinsName = miConfig.OrgName
  2398. pp.FixmedinsCode = miConfig.Code
  2399. pp.RequestUrl = miConfig.Url
  2400. pp.Cainfo = miConfig.Cainfo
  2401. pp.SecretKey = miConfig.SecretKey
  2402. pp.AccessKey = miConfig.AccessKey
  2403. pp.OpterName = roles.UserName
  2404. var config []*models.HisXtDiagnoseConfig
  2405. for _, item := range diagnosis_ids {
  2406. id, _ := strconv.ParseInt(item, 10, 64)
  2407. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2408. config = append(config, &diagnosisConfig)
  2409. }
  2410. var pd models.PatientDtos
  2411. pd.PatnID = his.PsnNo
  2412. pd.PatnName = his.Name
  2413. pd.Gend = his.Gend
  2414. pd.Brdy = his.Brdy
  2415. pd.Poolarea = his.InsuplcAdmdvs
  2416. pd.CurrMdtrtID = his.Number
  2417. var fed models.FsiEncounterDtos
  2418. fed.MdtrtID = his.Number
  2419. fed.MedinsID = miConfig.Code
  2420. fed.MedinsName = miConfig.OrgName
  2421. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2422. fed.MedMdtrtType = "1"
  2423. fed.MedinsType = "1"
  2424. fed.MedinsLv = "11"
  2425. tm := time.Unix(his.RecordDate, 0)
  2426. s_tm := tm.Format("2006-01-02 15:04:05")
  2427. fed.AdmDate = s_tm
  2428. fed.DscgDate = s_tm
  2429. fed.DscgMainDiseCodg = config[0].CountryCode
  2430. fed.DscgMainDiseName = config[0].CountryContentName
  2431. //诊断信息
  2432. var fdds []*models.FsiDiagnoseDtos
  2433. for index, item := range config {
  2434. if index == 0 {
  2435. var fdd models.FsiDiagnoseDtos
  2436. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2437. fdd.InoutDiseType = "1"
  2438. fdd.MaindiseFlag = "1"
  2439. fdd.DiseDate = s_tm
  2440. fdd.DiasSrtNo = "1"
  2441. fdd.DiseName = item.CountryContentName
  2442. fdd.DiseCodg = item.CountryCode
  2443. fdds = append(fdds, &fdd)
  2444. } else {
  2445. var fdd models.FsiDiagnoseDtos
  2446. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2447. fdd.InoutDiseType = "1"
  2448. fdd.MaindiseFlag = "1"
  2449. fdd.DiseDate = s_tm
  2450. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2451. fdd.DiseName = item.CountryContentName
  2452. fdd.DiseCodg = item.CountryCode
  2453. fdds = append(fdds, &fdd)
  2454. }
  2455. }
  2456. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2457. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2458. fed.AdmDeptName = department.Name
  2459. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2460. fed.DscgDeptName = department.Name
  2461. fed.MedType = order.MedType
  2462. //处方医嘱信息
  2463. var orders []*models.FsiOrderDtos
  2464. //for _, item := range prescriptions {
  2465. // for _, subItem := range item.HisDoctorAdviceInfo {
  2466. // var order models.FsiOrderDtos
  2467. // order.RxID = strconv.FormatInt(item.ID, 10)
  2468. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2469. // order.LongDrordFlag = "0"
  2470. // order.HilistType = "1"
  2471. // order.ChrgType = "1"
  2472. // order.DrordBhvr = "-"
  2473. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2474. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2475. // order.HilistLv = "1"
  2476. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2477. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2478. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2479. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  2480. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2481. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  2482. // order.OwnpayAmt = ""
  2483. // order.SelfpayAmt = ""
  2484. // order.Spec = ""
  2485. // order.SpecUnt = ""
  2486. // order.DrordBegnDate = s_tm
  2487. // order.DrordStopDate = ""
  2488. // order.DrordDrCodg = "1"
  2489. // order.DrordDeptName = department.Name
  2490. // order.DrordDrCodg = "1"
  2491. // order.DrordDrName = doctor_info.UserName
  2492. // order.DrordDrProfttl = ""
  2493. // order.CurrDrordFlag = "1"
  2494. // orders = append(orders, &order)
  2495. // }
  2496. // for _, subItem := range item.HisPrescriptionProject {
  2497. // if subItem.Type == 2 {
  2498. // var order models.FsiOrderDtos
  2499. // order.RxID = strconv.FormatInt(item.ID, 10)
  2500. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2501. // order.LongDrordFlag = "0"
  2502. // order.HilistType = "1"
  2503. // order.ChrgType = "1"
  2504. // order.DrordBhvr = "-"
  2505. // order.HilistCode = subItem.HisProject.MedicalCode
  2506. // order.HosplistName = subItem.HisProject.ProjectName
  2507. // order.HilistLv = "1"
  2508. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2509. // order.HosplistCode = subItem.HisProject.MedicalCode
  2510. // order.HosplistName = subItem.HisProject.ProjectName
  2511. // order.Cnt = subItem.Count
  2512. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2513. //
  2514. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2515. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2516. // order.OwnpayAmt = ""
  2517. // order.SelfpayAmt = ""
  2518. // order.Spec = ""
  2519. // order.SpecUnt = ""
  2520. // order.DrordBegnDate = s_tm
  2521. // order.DrordStopDate = ""
  2522. // order.DrordDrCodg = "1"
  2523. // order.DrordDeptName = department.Name
  2524. // order.DrordDrCodg = "1"
  2525. // order.DrordDrName = doctor_info.UserName
  2526. // order.DrordDrProfttl = ""
  2527. // order.CurrDrordFlag = "1"
  2528. // orders = append(orders, &order)
  2529. //
  2530. // }
  2531. // if subItem.Type == 3 {
  2532. //
  2533. // var order models.FsiOrderDtos
  2534. // order.RxID = strconv.FormatInt(item.ID, 10)
  2535. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2536. // order.LongDrordFlag = "0"
  2537. // order.HilistType = "1"
  2538. // order.ChrgType = "1"
  2539. // order.DrordBhvr = "-"
  2540. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2541. // order.HosplistName = subItem.GoodInfo.GoodName
  2542. // order.HilistLv = "1"
  2543. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2544. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2545. // order.HosplistName = subItem.GoodInfo.GoodName
  2546. // order.Cnt = subItem.Count
  2547. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2548. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2549. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2550. // order.OwnpayAmt = ""
  2551. // order.SelfpayAmt = ""
  2552. // order.Spec = ""
  2553. // order.SpecUnt = ""
  2554. // order.DrordBegnDate = s_tm
  2555. // order.DrordStopDate = ""
  2556. // order.DrordDrCodg = "1"
  2557. // order.DrordDeptName = department.Name
  2558. // order.DrordDrCodg = "1"
  2559. // order.DrordDrName = doctor_info.UserName
  2560. // order.DrordDrProfttl = ""
  2561. // order.CurrDrordFlag = "1"
  2562. // orders = append(orders, &order)
  2563. //
  2564. // }
  2565. // }
  2566. //}
  2567. for _, item := range prescriptions {
  2568. for _, subItem := range item.HisDoctorAdviceInfo {
  2569. var order models.FsiOrderDtos
  2570. order.RxID = strconv.FormatInt(item.ID, 10)
  2571. order.Rxno = strconv.FormatInt(item.ID, 10)
  2572. order.LongDrordFlag = "0"
  2573. order.HilistType = "1"
  2574. order.ChrgType = "1"
  2575. order.DrordBhvr = "-"
  2576. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2577. order.HosplistName = subItem.BaseDrugLib.DrugName
  2578. order.HilistLv = "1"
  2579. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2580. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2581. order.HosplistName = subItem.BaseDrugLib.DrugName
  2582. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2583. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2584. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2585. order.OwnpayAmt = ""
  2586. order.SelfpayAmt = ""
  2587. order.Spec = ""
  2588. order.SpecUnt = ""
  2589. order.DrordBegnDate = s_tm
  2590. order.DrordStopDate = ""
  2591. order.DrordDrCodg = "1"
  2592. order.DrordDeptName = department.Name
  2593. order.DrordDrCodg = "1"
  2594. order.DrordDrName = doctor_info.UserName
  2595. order.DrordDrProfttl = ""
  2596. order.CurrDrordFlag = "1"
  2597. orders = append(orders, &order)
  2598. }
  2599. for _, subItem := range item.HisPrescriptionProject {
  2600. if subItem.Type == 2 {
  2601. var order models.FsiOrderDtos
  2602. order.RxID = strconv.FormatInt(item.ID, 10)
  2603. order.Rxno = strconv.FormatInt(item.ID, 10)
  2604. order.LongDrordFlag = "0"
  2605. order.HilistType = "1"
  2606. order.ChrgType = "1"
  2607. order.DrordBhvr = "-"
  2608. order.HilistCode = subItem.HisProject.MedicalCode
  2609. order.HosplistName = subItem.HisProject.ProjectName
  2610. order.HilistLv = "1"
  2611. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2612. order.HosplistCode = subItem.HisProject.MedicalCode
  2613. order.HosplistName = subItem.HisProject.ProjectName
  2614. order.Cnt = subItem.Count
  2615. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2616. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2617. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2618. order.OwnpayAmt = ""
  2619. order.SelfpayAmt = ""
  2620. order.Spec = ""
  2621. order.SpecUnt = ""
  2622. order.DrordBegnDate = s_tm
  2623. order.DrordStopDate = ""
  2624. order.DrordDrCodg = "1"
  2625. order.DrordDeptName = department.Name
  2626. order.DrordDrCodg = "1"
  2627. order.DrordDrName = doctor_info.UserName
  2628. order.DrordDrProfttl = ""
  2629. order.CurrDrordFlag = "1"
  2630. orders = append(orders, &order)
  2631. }
  2632. if subItem.Type == 3 {
  2633. var order models.FsiOrderDtos
  2634. order.RxID = strconv.FormatInt(item.ID, 10)
  2635. order.Rxno = strconv.FormatInt(item.ID, 10)
  2636. order.LongDrordFlag = "0"
  2637. order.HilistType = "1"
  2638. order.ChrgType = "1"
  2639. order.DrordBhvr = "-"
  2640. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2641. order.HosplistName = subItem.GoodInfo.GoodName
  2642. order.HilistLv = "1"
  2643. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2644. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2645. order.HosplistName = subItem.GoodInfo.GoodName
  2646. order.Cnt = subItem.Count
  2647. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2648. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2649. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2650. order.OwnpayAmt = ""
  2651. order.SelfpayAmt = ""
  2652. order.Spec = ""
  2653. order.SpecUnt = ""
  2654. order.DrordBegnDate = s_tm
  2655. order.DrordStopDate = ""
  2656. order.DrordDrCodg = "1"
  2657. order.DrordDeptName = department.Name
  2658. order.DrordDrCodg = "1"
  2659. order.DrordDrName = doctor_info.UserName
  2660. order.DrordDrProfttl = ""
  2661. order.CurrDrordFlag = "1"
  2662. orders = append(orders, &order)
  2663. }
  2664. }
  2665. }
  2666. //处方医嘱信息
  2667. fed.MatnStas = "0"
  2668. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2669. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2670. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2671. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2672. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2673. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2674. fed.SetlTotlnum = "1"
  2675. fed.Insutype = his.Insutype
  2676. fed.ReimFlag = "0"
  2677. fed.OutSetlFlag = "0"
  2678. var fopd []*models.FsiOperationDtosData
  2679. data := make(map[string]interface{})
  2680. data["fed"] = fed
  2681. data["fdd"] = fdds
  2682. data["fod"] = orders
  2683. data["pd"] = pd
  2684. data["pp"] = pp
  2685. data["fopd"] = fopd
  2686. data["trig_scen"] = trig_scen
  2687. client := &http.Client{}
  2688. bytesData, _ := json.Marshal(data)
  2689. var req *http.Request
  2690. if miConfig.MdtrtareaAdmvs == "320921" {
  2691. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2692. } else {
  2693. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2694. }
  2695. resp, _ := client.Do(req)
  2696. defer resp.Body.Close()
  2697. body, ioErr := ioutil.ReadAll(resp.Body)
  2698. if ioErr != nil {
  2699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2701. return res
  2702. }
  2703. var respJSON map[string]interface{}
  2704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2707. return res
  2708. }
  2709. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2710. result, _ := json.Marshal(respJSON)
  2711. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2712. utils.ErrorLog("解析失败:%v", err)
  2713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2714. return res
  2715. }
  2716. return res
  2717. //手术操作集合
  2718. //手术操作集合
  2719. }
  2720. func (c *HisApiController) Check() {
  2721. psn_no := c.GetString("psn_no")
  2722. in := c.GetString("in")
  2723. mt := c.GetString("mt")
  2724. baseParams := models.BaseParams{
  2725. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2726. FixmedinsCode: "H15049901371",
  2727. InsuplcAdmdvs: "150499",
  2728. MdtrtareaAdmvs: "150499",
  2729. OrgName: "赤峰费森血液透析中心",
  2730. Doctor: "1111",
  2731. }
  2732. service.Gdyb2001(baseParams, psn_no, in, mt)
  2733. }
  2734. func (c *HisApiController) GetPsnNcdsInfo() {
  2735. admin_user_id, _ := c.GetInt64("admin_user_id")
  2736. patient_id, _ := c.GetInt64("patient_id")
  2737. id, _ := c.GetInt64("id")
  2738. adminUser := c.GetAdminUserInfo()
  2739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2740. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2741. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2743. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2744. //
  2745. //if psn_record.ID == 0 {
  2746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2747. // return
  2748. //}
  2749. var res Result5301
  2750. var res10265 Result5301For10265
  2751. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2752. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2753. var api string
  2754. if miConfig.MdtrtareaAdmvs == "320921" {
  2755. 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 +
  2756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2757. } else {
  2758. 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 +
  2759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2760. }
  2761. resp, requestErr := http.Get(api)
  2762. if requestErr != nil {
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2764. return
  2765. }
  2766. body, ioErr := ioutil.ReadAll(resp.Body)
  2767. if ioErr != nil {
  2768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. return
  2771. }
  2772. var respJSON map[string]interface{}
  2773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. return
  2777. }
  2778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2779. result, _ := json.Marshal(respJSON)
  2780. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2781. utils.ErrorLog("解析失败:%v", err)
  2782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2783. return
  2784. }
  2785. res.ErrMsg = res10265.ErrMsg
  2786. res.Output = res10265.Output
  2787. res.InfRefmsgid = res10265.InfRefmsgid
  2788. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2789. res.Infcode = infocode
  2790. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2791. p, _ := service.GetHisPatientById(patient_id)
  2792. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2793. var dat map[string]interface{}
  2794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2795. fmt.Println(dat)
  2796. } else {
  2797. fmt.Println(err)
  2798. }
  2799. userJSONBytes, _ := json.Marshal(dat)
  2800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2801. utils.ErrorLog("解析失败:%v", err)
  2802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2803. return
  2804. }
  2805. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2806. p, _ := service.GetHisPatientById(patient_id)
  2807. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2808. var dat map[string]interface{}
  2809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2810. fmt.Println(dat)
  2811. } else {
  2812. fmt.Println(err)
  2813. }
  2814. userJSONBytes, _ := json.Marshal(dat)
  2815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2816. utils.ErrorLog("解析失败:%v", err)
  2817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2818. return
  2819. }
  2820. } else {
  2821. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2822. var dat map[string]interface{}
  2823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2824. fmt.Println(dat)
  2825. } else {
  2826. fmt.Println(err)
  2827. }
  2828. userJSONBytes, _ := json.Marshal(dat)
  2829. if miConfig.Code == "H15049901371" {
  2830. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2831. utils.ErrorLog("解析失败:%v", err)
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2833. return
  2834. }
  2835. res.InfRefmsgid = res10265.InfRefmsgid
  2836. res.Output = res10265.Output
  2837. res.ErrMsg = res10265.ErrMsg
  2838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2839. res.Infcode = infocode
  2840. } else {
  2841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. }
  2847. }
  2848. if res.Infcode == 0 {
  2849. c.ServeSuccessJSON(map[string]interface{}{
  2850. "result": res.Output.Result,
  2851. })
  2852. }
  2853. }
  2854. func (c *HisApiController) CheckInsutype() {
  2855. his_patient_id, _ := c.GetInt64("his_patient_id")
  2856. admin_user_id, _ := c.GetInt64("admin_user_id")
  2857. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2858. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2859. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2860. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2861. var dat map[string]interface{}
  2862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2863. fmt.Println(dat)
  2864. } else {
  2865. fmt.Println(err)
  2866. }
  2867. userJSONBytes, _ := json.Marshal(dat)
  2868. var res Result90100
  2869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2870. utils.ErrorLog("解析失败:%v", err)
  2871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. return
  2873. }
  2874. if res.Infcode != 0 {
  2875. c.ServeSuccessJSON(map[string]interface{}{
  2876. "failed_code": -10,
  2877. "msg": res.ErrMsg,
  2878. })
  2879. return
  2880. } else {
  2881. fmt.Println(res)
  2882. }
  2883. }
  2884. func (c *HisApiController) CheckCardPWD() {
  2885. card_pwd := c.GetString("card_pwd")
  2886. his_patient_id, _ := c.GetInt64("his_patient_id")
  2887. admin_user_id, _ := c.GetInt64("admin_user_id")
  2888. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2889. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2890. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2891. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2892. bas := strings.Split(psn.CardInfo, "|")
  2893. basNumber := bas[2]
  2894. if psn.InsuplcAdmdvs[:4] == "4403" {
  2895. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2896. var dat map[string]interface{}
  2897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2898. fmt.Println(dat)
  2899. } else {
  2900. fmt.Println(err)
  2901. }
  2902. userJSONBytes, _ := json.Marshal(dat)
  2903. var res Result90991
  2904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2905. utils.ErrorLog("解析失败:%v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. if res.Infcode != 0 {
  2910. c.ServeSuccessJSON(map[string]interface{}{
  2911. "failed_code": -10,
  2912. "msg": res.ErrMsg,
  2913. })
  2914. return
  2915. } else {
  2916. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2917. var msg string
  2918. switch res.Output.Result.CardStat {
  2919. case "00":
  2920. msg = "未激活"
  2921. break
  2922. case "10":
  2923. msg = "激活"
  2924. break
  2925. case "20":
  2926. msg = "窗口挂失"
  2927. break
  2928. case "21":
  2929. msg = "电话挂失"
  2930. break
  2931. case "22":
  2932. msg = "单位网上申报挂失"
  2933. break
  2934. case "23":
  2935. msg = "保健办挂失"
  2936. break
  2937. case "24":
  2938. msg = "个人网上挂失"
  2939. break
  2940. case "25":
  2941. msg = "网上服务大厅挂失"
  2942. break
  2943. case "30":
  2944. msg = "注销"
  2945. break
  2946. case "40":
  2947. msg = "回收"
  2948. break
  2949. case "99":
  2950. msg = "制卡中(无效卡)"
  2951. break
  2952. }
  2953. c.ServeSuccessJSON(map[string]interface{}{
  2954. "failed_code": -10,
  2955. "msg": msg,
  2956. })
  2957. return
  2958. } else {
  2959. c.ServeSuccessJSON(map[string]interface{}{
  2960. "msg": "校验成功",
  2961. })
  2962. return
  2963. }
  2964. }
  2965. } else {
  2966. c.ServeSuccessJSON(map[string]interface{}{
  2967. "msg": "校验成功",
  2968. })
  2969. return
  2970. }
  2971. }
  2972. func (c *HisApiController) CheckCardPWDTwo() {
  2973. //card_pwd := c.GetString("card_pwd")
  2974. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2975. admin_user_id, _ := c.GetInt64("admin_user_id")
  2976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2978. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2979. var dat map[string]interface{}
  2980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2981. fmt.Println(dat)
  2982. } else {
  2983. fmt.Println(err)
  2984. }
  2985. userJSONBytes, _ := json.Marshal(dat)
  2986. var res Result90991
  2987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. if res.Infcode != 0 {
  2993. c.ServeSuccessJSON(map[string]interface{}{
  2994. "failed_code": -10,
  2995. "msg": res.ErrMsg,
  2996. })
  2997. return
  2998. } else {
  2999. if res.Output.Result.SscnoCheckStat == "0" {
  3000. var msg string
  3001. switch res.Output.Result.CardStat {
  3002. case "00":
  3003. msg = "未激活"
  3004. break
  3005. case "10":
  3006. msg = "激活"
  3007. break
  3008. case "20":
  3009. msg = "窗口挂失"
  3010. break
  3011. case "21":
  3012. msg = "电话挂失"
  3013. break
  3014. case "22":
  3015. msg = "单位网上申报挂失"
  3016. break
  3017. case "23":
  3018. msg = "保健办挂失"
  3019. break
  3020. case "24":
  3021. msg = "个人网上挂失"
  3022. break
  3023. case "25":
  3024. msg = "网上服务大厅挂失"
  3025. break
  3026. case "30":
  3027. msg = "注销"
  3028. break
  3029. case "40":
  3030. msg = "回收"
  3031. break
  3032. case "99":
  3033. msg = "制卡中(无效卡)"
  3034. break
  3035. }
  3036. c.ServeSuccessJSON(map[string]interface{}{
  3037. "failed_code": -10,
  3038. "msg": msg,
  3039. })
  3040. return
  3041. } else {
  3042. c.ServeSuccessJSON(map[string]interface{}{
  3043. "msg": "校验成功",
  3044. })
  3045. return
  3046. }
  3047. }
  3048. }
  3049. type ELeCertData struct {
  3050. Data struct {
  3051. Extra string `json:"extra"`
  3052. IDNo string `json:"idNo"`
  3053. IDType string `json:"idType"`
  3054. EcToken string `json:"ecToken"`
  3055. InsuOrg string `json:"insuOrg"`
  3056. UserName string `json:"userName"`
  3057. EcIndexNo string `json:"ecIndexNo"`
  3058. Gender string `json:"gender"`
  3059. Birthday string `json:"birthday"`
  3060. Nationality string `json:"nationality"`
  3061. Email string `json:"email"`
  3062. } `json:"OutData"`
  3063. }
  3064. func (c *HisApiController) ReadCard() {
  3065. id_card_type, _ := c.GetInt64("id_card_type")
  3066. admin_user_id, _ := c.GetInt64("admin_user_id")
  3067. certificates, _ := c.GetInt64("certificates")
  3068. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  3069. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3070. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3071. switch id_card_type {
  3072. case 1:
  3073. if miConfig.MdtrtareaAdmvs == "421300" {
  3074. var res ResultTwo
  3075. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  3076. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3077. "&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)
  3078. resp, requestErr := http.Get(api)
  3079. if requestErr != nil {
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. body, ioErr := ioutil.ReadAll(resp.Body)
  3084. if ioErr != nil {
  3085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. return
  3088. }
  3089. var respJSON map[string]interface{}
  3090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3093. return
  3094. }
  3095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3096. result, _ := json.Marshal(respJSON)
  3097. fmt.Println("log")
  3098. fmt.Println(string(result))
  3099. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3100. utils.ErrorLog("解析失败:%v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. if res.Infcode == 0 {
  3105. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3106. if err == gorm.ErrRecordNotFound {
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3108. return
  3109. } else if err != nil {
  3110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3111. return
  3112. } else {
  3113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3115. infoStr := string(Iinfos)
  3116. idetinfoStr := string(Idetinfos)
  3117. psn := &models.HisPsn{
  3118. PsnNo: res.Output.Baseinfo.PsnNo,
  3119. Age: res.Output.Baseinfo.Age,
  3120. PatientId: patient.ID,
  3121. Certno: res.Output.Baseinfo.Certno,
  3122. Brdy: res.Output.Baseinfo.Brdy,
  3123. Gend: res.Output.Baseinfo.Gend,
  3124. Naty: res.Output.Baseinfo.Naty,
  3125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3126. PsnName: res.Output.Baseinfo.PsnName,
  3127. Idetinfo: idetinfoStr,
  3128. Insuinfo: infoStr,
  3129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3130. }
  3131. service.CreateHisPsn(psn)
  3132. c.ServeSuccessJSON(map[string]interface{}{
  3133. "patient": patient,
  3134. "number": res.Output.Baseinfo.Certno,
  3135. })
  3136. }
  3137. } else {
  3138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3139. return
  3140. }
  3141. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3142. var api string
  3143. if miConfig.MdtrtareaAdmvs == "320921" {
  3144. 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 +
  3145. "&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
  3146. fmt.Println(api)
  3147. } else {
  3148. 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 +
  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)
  3150. }
  3151. resp, requestErr := http.Get(api)
  3152. if requestErr != nil {
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3154. return
  3155. }
  3156. body, ioErr := ioutil.ReadAll(resp.Body)
  3157. if ioErr != nil {
  3158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. var respJSON map[string]interface{}
  3163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3166. return
  3167. }
  3168. var status string
  3169. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3170. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3171. //console.log()
  3172. fmt.Println("type===")
  3173. fmt.Println(card_type)
  3174. var token string
  3175. var res ResultTwo //1101结果
  3176. var res10265 ResultTwo10265 //1101结果
  3177. var card_info string //卡信息
  3178. var busi_card_info string
  3179. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3180. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3181. if status == "0" { //读卡成功
  3182. if card_type == "1" {
  3183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3184. result, _ := json.Marshal(respJSON)
  3185. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3186. utils.ErrorLog("解析失败:%v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. res.ErrMsg = res10265.ErrMsg
  3191. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3192. res.Infcode = infocode
  3193. res.Output = res10265.Output
  3194. res.InfRefmsgid = res10265.InfRefmsgid
  3195. } else {
  3196. //var card_info string //卡信息
  3197. //var busi_card_info string
  3198. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3199. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3200. //fmt.Println(card_info)
  3201. //fmt.Println(busi_card_info)
  3202. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3203. result, _ := json.Marshal(respJSON)
  3204. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3205. utils.ErrorLog("解析失败:%v", err)
  3206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3207. return
  3208. }
  3209. res.ErrMsg = res10265.ErrMsg
  3210. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3211. res.Infcode = infocode
  3212. res.Output = res10265.Output
  3213. res.InfRefmsgid = res10265.InfRefmsgid
  3214. }
  3215. if res.Infcode == 0 {
  3216. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3217. if err == gorm.ErrRecordNotFound {
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3219. return
  3220. } else if err != nil {
  3221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3222. return
  3223. } else {
  3224. if card_type == "1" {
  3225. bas := strings.Split(card_info, "|")
  3226. basNumber := bas[2]
  3227. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3228. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3229. infoStr := string(Iinfos)
  3230. idetinfoStr := string(Idetinfos)
  3231. psn := &models.HisPsn{
  3232. PsnNo: res.Output.Baseinfo.PsnNo,
  3233. Age: res.Output.Baseinfo.Age,
  3234. PatientId: patient.ID,
  3235. Certno: res.Output.Baseinfo.Certno,
  3236. Brdy: res.Output.Baseinfo.Brdy,
  3237. Gend: res.Output.Baseinfo.Gend,
  3238. Naty: res.Output.Baseinfo.Naty,
  3239. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3240. PsnName: res.Output.Baseinfo.PsnName,
  3241. Idetinfo: idetinfoStr,
  3242. Insuinfo: infoStr,
  3243. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3244. CardInfo: card_info,
  3245. VerifyNumber: busi_card_info,
  3246. }
  3247. service.CreateHisPsn(psn)
  3248. var rf []*ResultFive
  3249. json.Unmarshal([]byte(infoStr), &rf)
  3250. var insutypes []*ResultFive
  3251. var insutype string
  3252. var is390 int = 0
  3253. var is310 int = 0
  3254. for _, item := range rf {
  3255. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3256. insutypes = append(insutypes, item)
  3257. }
  3258. }
  3259. if len(insutypes) == 1 {
  3260. insutype = insutypes[0].Insutype
  3261. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3262. } else {
  3263. for _, i := range insutypes {
  3264. if i.Insutype == "390" {
  3265. is390 = 1
  3266. }
  3267. if i.Insutype == "310" {
  3268. is310 = 1
  3269. }
  3270. }
  3271. }
  3272. if is390 == 1 {
  3273. insutype = "390"
  3274. }
  3275. if is310 == 1 {
  3276. insutype = "310"
  3277. }
  3278. if len(insutypes) == 0 {
  3279. insutype = "310"
  3280. }
  3281. c.ServeSuccessJSON(map[string]interface{}{
  3282. "patient": patient,
  3283. "number": basNumber,
  3284. "insutype": insutype,
  3285. })
  3286. } else {
  3287. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3288. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3289. infoStr := string(Iinfos)
  3290. idetinfoStr := string(Idetinfos)
  3291. psn := &models.HisPsn{
  3292. PsnNo: res.Output.Baseinfo.PsnNo,
  3293. Age: res.Output.Baseinfo.Age,
  3294. PatientId: patient.ID,
  3295. Certno: res.Output.Baseinfo.Certno,
  3296. Brdy: res.Output.Baseinfo.Brdy,
  3297. Gend: res.Output.Baseinfo.Gend,
  3298. Naty: res.Output.Baseinfo.Naty,
  3299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3300. PsnName: res.Output.Baseinfo.PsnName,
  3301. Idetinfo: idetinfoStr,
  3302. Insuinfo: infoStr,
  3303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3304. CardInfo: card_info,
  3305. VerifyNumber: token,
  3306. }
  3307. service.CreateHisPsn(psn)
  3308. c.ServeSuccessJSON(map[string]interface{}{
  3309. "patient": patient,
  3310. "number": token,
  3311. })
  3312. }
  3313. }
  3314. } else {
  3315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3316. return
  3317. }
  3318. } else { //读卡失败
  3319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3320. return
  3321. }
  3322. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3323. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  3324. cardnum = DeleteExtraSpaceTwo(cardnum)
  3325. cardCode = DeleteExtraSpaceTwo(cardCode)
  3326. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  3327. name = DeleteExtraSpaceTwo(name)
  3328. errmsg = DeleteExtraSpaceTwo(errmsg)
  3329. cardnum = Remove0000(cardnum)
  3330. cardCode = Remove0000(cardCode)
  3331. id_card_no = Remove0000(id_card_no)
  3332. name = Remove0000(name)
  3333. errmsg = Remove0000(errmsg)
  3334. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  3335. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  3336. //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)
  3337. //fmt.Println(result2)
  3338. //fmt.Println(requestLog2)
  3339. //fmt.Println(errMsgLog2)
  3340. 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)
  3341. saveLog(result, requestLog, "1101", "获取人员信息")
  3342. fmt.Println(errMsgLog)
  3343. if len(errMsgLog) > 0 {
  3344. } else {
  3345. var dat map[string]interface{}
  3346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3347. fmt.Println(dat)
  3348. } else {
  3349. fmt.Println(err)
  3350. }
  3351. userJSONBytes, _ := json.Marshal(dat)
  3352. var res ResultTwo
  3353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3354. utils.ErrorLog("解析失败:%v", err)
  3355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3356. return
  3357. }
  3358. res.ErrMsg = errMsgLog
  3359. if res.Infcode == 0 {
  3360. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  3361. if err == gorm.ErrRecordNotFound {
  3362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3363. return
  3364. } else if err != nil {
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3366. return
  3367. } else {
  3368. fmt.Println(res)
  3369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3371. infoStr := string(Iinfos)
  3372. idetinfoStr := string(Idetinfos)
  3373. var rf []*ResultFive
  3374. json.Unmarshal([]byte(infoStr), &rf)
  3375. var insutypes []*ResultFive
  3376. var insutype string
  3377. var is390 int = 0
  3378. var is310 int = 0
  3379. for _, item := range rf {
  3380. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3381. insutypes = append(insutypes, item)
  3382. }
  3383. }
  3384. if len(insutypes) == 1 {
  3385. insutype = insutypes[0].Insutype
  3386. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3387. } else {
  3388. for _, i := range insutypes {
  3389. if i.Insutype == "390" {
  3390. is390 = 1
  3391. }
  3392. if i.Insutype == "310" {
  3393. is310 = 1
  3394. }
  3395. }
  3396. }
  3397. if is390 == 1 {
  3398. insutype = "390"
  3399. }
  3400. if is310 == 1 {
  3401. insutype = "310"
  3402. }
  3403. if len(insutypes) == 0 {
  3404. insutype = "390"
  3405. }
  3406. var insuplc_admdvs string
  3407. for _, item := range rf {
  3408. if item.Insutype == insutype {
  3409. insuplc_admdvs = item.InsuplcAdmdvs
  3410. }
  3411. }
  3412. psn := &models.HisPsn{
  3413. PsnNo: res.Output.Baseinfo.PsnNo,
  3414. Age: res.Output.Baseinfo.Age,
  3415. PatientId: patient.ID,
  3416. Certno: res.Output.Baseinfo.Certno,
  3417. Brdy: res.Output.Baseinfo.Brdy,
  3418. Gend: res.Output.Baseinfo.Gend,
  3419. Naty: res.Output.Baseinfo.Naty,
  3420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3421. PsnName: res.Output.Baseinfo.PsnName,
  3422. Idetinfo: idetinfoStr,
  3423. Insuinfo: infoStr,
  3424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3425. CardInfo: basStr,
  3426. VerifyNumber: "",
  3427. InsuplcAdmdvs: insuplc_admdvs,
  3428. }
  3429. service.CreateHisPsn(psn)
  3430. c.ServeSuccessJSON(map[string]interface{}{
  3431. "patient": patient,
  3432. "number": cardnum,
  3433. "insutype": insutype,
  3434. })
  3435. }
  3436. } else {
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3438. return
  3439. }
  3440. }
  3441. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3442. fmt.Println(initFlag)
  3443. fmt.Println("initFlag")
  3444. if initFlag == 0 {
  3445. c.TestGetJiangXiBasBaseInit()
  3446. }
  3447. basStr := c.GetBasBaseInfo()
  3448. if len(basStr) == 0 {
  3449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3450. return
  3451. }
  3452. fmt.Println(basStr)
  3453. bas := strings.Split(basStr, "|")
  3454. basNumber := bas[1]
  3455. fmt.Println(basNumber)
  3456. card_sn := bas[3]
  3457. fmt.Println(card_sn)
  3458. 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, "")
  3459. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3460. var dat map[string]interface{}
  3461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3462. fmt.Println(dat)
  3463. } else {
  3464. fmt.Println(err)
  3465. }
  3466. userJSONBytes, _ := json.Marshal(dat)
  3467. var res ResultTwo
  3468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. if res.Infcode == 0 {
  3474. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3475. if err == gorm.ErrRecordNotFound {
  3476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3477. return
  3478. } else if err != nil {
  3479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3480. return
  3481. } else {
  3482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3484. infoStr := string(Iinfos)
  3485. idetinfoStr := string(Idetinfos)
  3486. psn := &models.HisPsn{
  3487. PsnNo: res.Output.Baseinfo.PsnNo,
  3488. Age: res.Output.Baseinfo.Age,
  3489. PatientId: patient.ID,
  3490. Certno: res.Output.Baseinfo.Certno,
  3491. Brdy: res.Output.Baseinfo.Brdy,
  3492. Gend: res.Output.Baseinfo.Gend,
  3493. Naty: res.Output.Baseinfo.Naty,
  3494. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3495. PsnName: res.Output.Baseinfo.PsnName,
  3496. Idetinfo: idetinfoStr,
  3497. Insuinfo: infoStr,
  3498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3499. CardInfo: basStr,
  3500. VerifyNumber: "",
  3501. }
  3502. service.CreateHisPsn(psn)
  3503. var rf []*ResultFive
  3504. json.Unmarshal([]byte(infoStr), &rf)
  3505. var insutypes []*ResultFive
  3506. var insutype string
  3507. var is390 int = 0
  3508. var is310 int = 0
  3509. for _, item := range rf {
  3510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3511. insutypes = append(insutypes, item)
  3512. }
  3513. }
  3514. if len(insutypes) == 1 {
  3515. insutype = insutypes[0].Insutype
  3516. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3517. } else {
  3518. for _, i := range insutypes {
  3519. if i.Insutype == "390" {
  3520. is390 = 1
  3521. }
  3522. if i.Insutype == "310" {
  3523. is310 = 1
  3524. }
  3525. }
  3526. }
  3527. if is390 == 1 {
  3528. insutype = "390"
  3529. }
  3530. if is310 == 1 {
  3531. insutype = "310"
  3532. }
  3533. if len(insutypes) == 0 {
  3534. insutype = "310"
  3535. }
  3536. c.ServeSuccessJSON(map[string]interface{}{
  3537. "patient": patient,
  3538. "number": basNumber,
  3539. "insutype": insutype,
  3540. })
  3541. }
  3542. } else {
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3544. return
  3545. }
  3546. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3547. fmt.Println(initFlag)
  3548. fmt.Println("initFlag")
  3549. if initFlag == 0 {
  3550. c.TestGetHnBasBaseInit()
  3551. }
  3552. basStr := c.GetBasBaseInfo()
  3553. if len(basStr) == 0 {
  3554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3555. return
  3556. }
  3557. fmt.Println(basStr)
  3558. bas := strings.Split(basStr, "|")
  3559. basNumber := bas[1]
  3560. fmt.Println(basNumber)
  3561. card_sn := bas[3]
  3562. card_no := bas[2]
  3563. fmt.Println(card_sn)
  3564. name := bas[4]
  3565. name = ConvertToString(name, "gbk", "utf-8")
  3566. 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)
  3567. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3568. var dat map[string]interface{}
  3569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3570. fmt.Println(dat)
  3571. } else {
  3572. fmt.Println(err)
  3573. }
  3574. userJSONBytes, _ := json.Marshal(dat)
  3575. var res ResultTwo
  3576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3577. utils.ErrorLog("解析失败:%v", err)
  3578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3579. return
  3580. }
  3581. if res.Infcode == 0 {
  3582. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3583. if err == gorm.ErrRecordNotFound {
  3584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3585. return
  3586. } else if err != nil {
  3587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3588. return
  3589. } else {
  3590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3591. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3592. infoStr := string(Iinfos)
  3593. idetinfoStr := string(Idetinfos)
  3594. psn := &models.HisPsn{
  3595. PsnNo: res.Output.Baseinfo.PsnNo,
  3596. Age: res.Output.Baseinfo.Age,
  3597. PatientId: patient.ID,
  3598. Certno: res.Output.Baseinfo.Certno,
  3599. Brdy: res.Output.Baseinfo.Brdy,
  3600. Gend: res.Output.Baseinfo.Gend,
  3601. Naty: res.Output.Baseinfo.Naty,
  3602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3603. PsnName: res.Output.Baseinfo.PsnName,
  3604. Idetinfo: idetinfoStr,
  3605. Insuinfo: infoStr,
  3606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3607. CardInfo: basStr,
  3608. VerifyNumber: "",
  3609. }
  3610. service.CreateHisPsn(psn)
  3611. var rf []*ResultFive
  3612. json.Unmarshal([]byte(infoStr), &rf)
  3613. var insutypes []*ResultFive
  3614. var insutype string
  3615. var is390 int = 0
  3616. var is310 int = 0
  3617. for _, item := range rf {
  3618. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3619. insutypes = append(insutypes, item)
  3620. }
  3621. }
  3622. if len(insutypes) == 1 {
  3623. insutype = insutypes[0].Insutype
  3624. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3625. } else {
  3626. for _, i := range insutypes {
  3627. if i.Insutype == "390" {
  3628. is390 = 1
  3629. }
  3630. if i.Insutype == "310" {
  3631. is310 = 1
  3632. }
  3633. }
  3634. }
  3635. if is390 == 1 {
  3636. insutype = "390"
  3637. }
  3638. if is310 == 1 {
  3639. insutype = "310"
  3640. }
  3641. if len(insutypes) == 0 {
  3642. insutype = "310"
  3643. }
  3644. c.ServeSuccessJSON(map[string]interface{}{
  3645. "patient": patient,
  3646. "number": basNumber,
  3647. "insutype": insutype,
  3648. })
  3649. }
  3650. } else {
  3651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3652. return
  3653. }
  3654. } else {
  3655. if initFlag == 0 {
  3656. c.TestGetBasBaseInit()
  3657. }
  3658. basStr := c.GetBasBaseInfo()
  3659. if len(basStr) == 0 {
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3661. return
  3662. }
  3663. fmt.Println(basStr)
  3664. bas := strings.Split(basStr, "|")
  3665. basNumber := bas[1]
  3666. fmt.Println(basNumber)
  3667. card_sn := bas[3]
  3668. fmt.Println(card_sn)
  3669. cardNumber := bas[2]
  3670. fmt.Println(cardNumber)
  3671. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3672. var result string
  3673. if bas[0][:2] == "44" {
  3674. 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)
  3675. } else {
  3676. 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)
  3677. }
  3678. var dat map[string]interface{}
  3679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3680. fmt.Println(dat)
  3681. } else {
  3682. fmt.Println(err)
  3683. }
  3684. userJSONBytes, _ := json.Marshal(dat)
  3685. var res ResultTwo
  3686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3687. utils.ErrorLog("解析失败:%v", err)
  3688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3689. return
  3690. }
  3691. if res.Infcode == 0 {
  3692. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3693. if err == gorm.ErrRecordNotFound {
  3694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3695. return
  3696. } else if err != nil {
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3698. return
  3699. } else {
  3700. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3701. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3702. infoStr := string(Iinfos)
  3703. idetinfoStr := string(Idetinfos)
  3704. var rf []*ResultFive
  3705. json.Unmarshal([]byte(infoStr), &rf)
  3706. var insutypes []*ResultFive
  3707. var insutype string
  3708. var is390 int = 0
  3709. var is310 int = 0
  3710. var insuplc_admdvs string
  3711. for _, item := range rf {
  3712. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3713. insutypes = append(insutypes, item)
  3714. }
  3715. }
  3716. if len(insutypes) == 1 {
  3717. insutype = insutypes[0].Insutype
  3718. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3719. } else {
  3720. for _, i := range insutypes {
  3721. if i.Insutype == "390" {
  3722. is390 = 1
  3723. }
  3724. if i.Insutype == "310" {
  3725. is310 = 1
  3726. }
  3727. }
  3728. }
  3729. if is390 == 1 {
  3730. insutype = "390"
  3731. }
  3732. if is310 == 1 {
  3733. insutype = "310"
  3734. }
  3735. if len(insutypes) == 0 {
  3736. insutype = "310"
  3737. }
  3738. for _, item := range rf {
  3739. if item.Insutype == insutype {
  3740. insuplc_admdvs = item.InsuplcAdmdvs
  3741. }
  3742. }
  3743. psn := &models.HisPsn{
  3744. PsnNo: res.Output.Baseinfo.PsnNo,
  3745. Age: res.Output.Baseinfo.Age,
  3746. PatientId: patient.ID,
  3747. Certno: res.Output.Baseinfo.Certno,
  3748. Brdy: res.Output.Baseinfo.Brdy,
  3749. Gend: res.Output.Baseinfo.Gend,
  3750. Naty: res.Output.Baseinfo.Naty,
  3751. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3752. PsnName: res.Output.Baseinfo.PsnName,
  3753. Idetinfo: idetinfoStr,
  3754. Insuinfo: infoStr,
  3755. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3756. CardInfo: basStr,
  3757. VerifyNumber: "",
  3758. InsuplcAdmdvs: insuplc_admdvs,
  3759. }
  3760. service.CreateHisPsn(psn)
  3761. c.ServeSuccessJSON(map[string]interface{}{
  3762. "patient": patient,
  3763. "number": basNumber,
  3764. })
  3765. }
  3766. } else {
  3767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3768. return
  3769. }
  3770. break
  3771. }
  3772. case 2:
  3773. if miConfig.MdtrtareaAdmvs == "430800" {
  3774. if initFlag == 0 {
  3775. c.TestGetHnBasBaseInit()
  3776. }
  3777. SFZStr := c.GetSFZBaseInfo()
  3778. if len(SFZStr) == 0 {
  3779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3780. return
  3781. }
  3782. fmt.Println(SFZStr)
  3783. id_card_str := strings.Split(SFZStr, "^")
  3784. card_no := id_card_str[0]
  3785. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3786. //name := id_card_str[1]
  3787. //name = ConvertToString(name, "gbk", "utf-8")
  3788. 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)
  3789. var dat map[string]interface{}
  3790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3791. fmt.Println(dat)
  3792. } else {
  3793. fmt.Println(err)
  3794. }
  3795. userJSONBytes, _ := json.Marshal(dat)
  3796. var res ResultTwo
  3797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3798. utils.ErrorLog("解析失败:%v", err)
  3799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3800. return
  3801. }
  3802. if res.Infcode == 0 {
  3803. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3804. if err == gorm.ErrRecordNotFound {
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3806. return
  3807. } else if err != nil {
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3809. return
  3810. } else {
  3811. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3812. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3813. infoStr := string(Iinfos)
  3814. idetinfoStr := string(Idetinfos)
  3815. psn := &models.HisPsn{
  3816. PsnNo: res.Output.Baseinfo.PsnNo,
  3817. Age: res.Output.Baseinfo.Age,
  3818. PatientId: patient.ID,
  3819. Certno: res.Output.Baseinfo.Certno,
  3820. Brdy: res.Output.Baseinfo.Brdy,
  3821. Gend: res.Output.Baseinfo.Gend,
  3822. Naty: res.Output.Baseinfo.Naty,
  3823. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3824. PsnName: res.Output.Baseinfo.PsnName,
  3825. Idetinfo: idetinfoStr,
  3826. Insuinfo: infoStr,
  3827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3828. CardInfo: SFZStr,
  3829. VerifyNumber: "",
  3830. }
  3831. service.CreateHisPsn(psn)
  3832. var rf []*ResultFive
  3833. json.Unmarshal([]byte(infoStr), &rf)
  3834. var insutypes []*ResultFive
  3835. var insutype string
  3836. var is390 int = 0
  3837. var is310 int = 0
  3838. for _, item := range rf {
  3839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3840. insutypes = append(insutypes, item)
  3841. }
  3842. }
  3843. if len(insutypes) == 1 {
  3844. insutype = insutypes[0].Insutype
  3845. } else {
  3846. for _, i := range insutypes {
  3847. if i.Insutype == "390" {
  3848. is390 = 1
  3849. }
  3850. if i.Insutype == "310" {
  3851. is310 = 1
  3852. }
  3853. }
  3854. }
  3855. if is390 == 1 {
  3856. insutype = "390"
  3857. }
  3858. if is310 == 1 {
  3859. insutype = "310"
  3860. }
  3861. if len(insutypes) == 0 {
  3862. insutype = "310"
  3863. }
  3864. c.ServeSuccessJSON(map[string]interface{}{
  3865. "patient": patient,
  3866. "number": card_no,
  3867. "insutype": insutype,
  3868. })
  3869. }
  3870. } else {
  3871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3872. return
  3873. }
  3874. } else {
  3875. SFZStr := c.GetSFZBaseInfo()
  3876. id_card_str := strings.Split(SFZStr, "^")
  3877. id_card_number := id_card_str[0]
  3878. card_sn := ""
  3879. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3880. var dat map[string]interface{}
  3881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3882. fmt.Println(dat)
  3883. } else {
  3884. fmt.Println(err)
  3885. }
  3886. userJSONBytes, _ := json.Marshal(dat)
  3887. var res ResultTwo
  3888. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3889. utils.ErrorLog("解析失败:%v", err)
  3890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. return
  3892. }
  3893. if res.Infcode == 0 {
  3894. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3895. if err == gorm.ErrRecordNotFound {
  3896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3897. return
  3898. } else if err != nil {
  3899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3900. return
  3901. } else {
  3902. c.ServeSuccessJSON(map[string]interface{}{
  3903. "patient": patient,
  3904. "number": id_card_number,
  3905. })
  3906. }
  3907. } else {
  3908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3909. return
  3910. }
  3911. }
  3912. break
  3913. case 3:
  3914. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3915. var api string
  3916. if miConfig.MdtrtareaAdmvs == "320921" {
  3917. 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 +
  3918. "&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
  3919. fmt.Println(api)
  3920. } else {
  3921. 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 +
  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)
  3923. }
  3924. resp, requestErr := http.Get(api)
  3925. if requestErr != nil {
  3926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3927. return
  3928. }
  3929. body, ioErr := ioutil.ReadAll(resp.Body)
  3930. if ioErr != nil {
  3931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. return
  3934. }
  3935. var respJSON map[string]interface{}
  3936. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. var status string
  3942. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3943. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3944. var token string
  3945. var res ResultTwo //1101结果
  3946. var res10265 ResultTwo10265 //1101结果
  3947. var card_info string //卡信息
  3948. var busi_card_info string
  3949. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3950. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3951. if status == "0" { //读卡成功
  3952. if card_type == "1" {
  3953. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3954. result, _ := json.Marshal(respJSON)
  3955. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3956. utils.ErrorLog("解析失败:%v", err)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. res.ErrMsg = res10265.ErrMsg
  3961. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3962. res.Infcode = infocode
  3963. res.Output = res10265.Output
  3964. res.InfRefmsgid = res10265.InfRefmsgid
  3965. } else {
  3966. //var card_info string //卡信息
  3967. //var busi_card_info string
  3968. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3969. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3970. //fmt.Println(card_info)
  3971. //fmt.Println(busi_card_info)
  3972. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3973. result, _ := json.Marshal(respJSON)
  3974. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3975. utils.ErrorLog("解析失败:%v", err)
  3976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3977. return
  3978. }
  3979. res.ErrMsg = res10265.ErrMsg
  3980. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3981. res.Infcode = infocode
  3982. res.Output = res10265.Output
  3983. res.InfRefmsgid = res10265.InfRefmsgid
  3984. }
  3985. if res.Infcode == 0 {
  3986. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3987. if err == gorm.ErrRecordNotFound {
  3988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3989. return
  3990. } else if err != nil {
  3991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3992. return
  3993. } else {
  3994. if card_type == "1" {
  3995. bas := strings.Split(card_info, "|")
  3996. basNumber := bas[2]
  3997. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3998. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3999. infoStr := string(Iinfos)
  4000. idetinfoStr := string(Idetinfos)
  4001. psn := &models.HisPsn{
  4002. PsnNo: res.Output.Baseinfo.PsnNo,
  4003. Age: res.Output.Baseinfo.Age,
  4004. PatientId: patient.ID,
  4005. Certno: res.Output.Baseinfo.Certno,
  4006. Brdy: res.Output.Baseinfo.Brdy,
  4007. Gend: res.Output.Baseinfo.Gend,
  4008. Naty: res.Output.Baseinfo.Naty,
  4009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4010. PsnName: res.Output.Baseinfo.PsnName,
  4011. Idetinfo: idetinfoStr,
  4012. Insuinfo: infoStr,
  4013. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4014. CardInfo: card_info,
  4015. VerifyNumber: busi_card_info,
  4016. }
  4017. service.CreateHisPsn(psn)
  4018. c.ServeSuccessJSON(map[string]interface{}{
  4019. "patient": patient,
  4020. "number": basNumber,
  4021. })
  4022. } else {
  4023. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4024. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4025. infoStr := string(Iinfos)
  4026. idetinfoStr := string(Idetinfos)
  4027. psn := &models.HisPsn{
  4028. PsnNo: res.Output.Baseinfo.PsnNo,
  4029. Age: res.Output.Baseinfo.Age,
  4030. PatientId: patient.ID,
  4031. Certno: res.Output.Baseinfo.Certno,
  4032. Brdy: res.Output.Baseinfo.Brdy,
  4033. Gend: res.Output.Baseinfo.Gend,
  4034. Naty: res.Output.Baseinfo.Naty,
  4035. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4036. PsnName: res.Output.Baseinfo.PsnName,
  4037. Idetinfo: idetinfoStr,
  4038. Insuinfo: infoStr,
  4039. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4040. CardInfo: card_info,
  4041. VerifyNumber: token,
  4042. }
  4043. service.CreateHisPsn(psn)
  4044. var rf []*ResultFive
  4045. json.Unmarshal([]byte(infoStr), &rf)
  4046. var insutypes []*ResultFive
  4047. var insutype string
  4048. var is390 int = 0
  4049. var is310 int = 0
  4050. for _, item := range rf {
  4051. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4052. insutypes = append(insutypes, item)
  4053. }
  4054. }
  4055. if len(insutypes) == 1 {
  4056. insutype = insutypes[0].Insutype
  4057. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4058. } else {
  4059. for _, i := range insutypes {
  4060. if i.Insutype == "390" {
  4061. is390 = 1
  4062. }
  4063. if i.Insutype == "310" {
  4064. is310 = 1
  4065. }
  4066. }
  4067. }
  4068. if is390 == 1 {
  4069. insutype = "390"
  4070. }
  4071. if is310 == 1 {
  4072. insutype = "310"
  4073. }
  4074. if len(insutypes) == 0 {
  4075. insutype = "310"
  4076. }
  4077. c.ServeSuccessJSON(map[string]interface{}{
  4078. "patient": patient,
  4079. "number": token,
  4080. "insutype": insutype,
  4081. })
  4082. }
  4083. }
  4084. } else {
  4085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4086. return
  4087. }
  4088. } else { //读卡失败
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4090. return
  4091. }
  4092. }
  4093. break
  4094. case 4:
  4095. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4096. var api string
  4097. if miConfig.MdtrtareaAdmvs == "320921" {
  4098. 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 +
  4099. "&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
  4100. fmt.Println(api)
  4101. } else {
  4102. 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 +
  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)
  4104. }
  4105. resp, requestErr := http.Get(api)
  4106. if requestErr != nil {
  4107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4108. return
  4109. }
  4110. body, ioErr := ioutil.ReadAll(resp.Body)
  4111. if ioErr != nil {
  4112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4114. return
  4115. }
  4116. var respJSON map[string]interface{}
  4117. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4120. return
  4121. }
  4122. var status string
  4123. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4124. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4125. var token string
  4126. var res ResultTwo //1101结果
  4127. var res10265 ResultTwo10265 //1101结果
  4128. if status == "0" { //读卡成功
  4129. var card_info string //卡信息
  4130. var busi_card_info string
  4131. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4132. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4133. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4134. fmt.Println(card_info)
  4135. fmt.Println(busi_card_info)
  4136. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4137. result, _ := json.Marshal(respJSON)
  4138. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4139. utils.ErrorLog("解析失败:%v", err)
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. return
  4142. }
  4143. res.ErrMsg = res10265.ErrMsg
  4144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4145. res.Infcode = infocode
  4146. res.Output = res10265.Output
  4147. res.InfRefmsgid = res10265.InfRefmsgid
  4148. if res.Infcode == 0 {
  4149. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4150. if err == gorm.ErrRecordNotFound {
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4152. return
  4153. } else if err != nil {
  4154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4155. return
  4156. } else {
  4157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4159. infoStr := string(Iinfos)
  4160. idetinfoStr := string(Idetinfos)
  4161. psn := &models.HisPsn{
  4162. PsnNo: res.Output.Baseinfo.PsnNo,
  4163. Age: res.Output.Baseinfo.Age,
  4164. PatientId: patient.ID,
  4165. Certno: res.Output.Baseinfo.Certno,
  4166. Brdy: res.Output.Baseinfo.Brdy,
  4167. Gend: res.Output.Baseinfo.Gend,
  4168. Naty: res.Output.Baseinfo.Naty,
  4169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4170. PsnName: res.Output.Baseinfo.PsnName,
  4171. Idetinfo: idetinfoStr,
  4172. Insuinfo: infoStr,
  4173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4174. CardInfo: card_info,
  4175. VerifyNumber: token,
  4176. }
  4177. var rf []*ResultFive
  4178. json.Unmarshal([]byte(infoStr), &rf)
  4179. var insutypes []*ResultFive
  4180. var insutype string
  4181. var is390 int = 0
  4182. var is310 int = 0
  4183. for _, item := range rf {
  4184. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4185. insutypes = append(insutypes, item)
  4186. }
  4187. }
  4188. if len(insutypes) == 1 {
  4189. insutype = insutypes[0].Insutype
  4190. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4191. } else {
  4192. for _, i := range insutypes {
  4193. if i.Insutype == "390" {
  4194. is390 = 1
  4195. }
  4196. if i.Insutype == "310" {
  4197. is310 = 1
  4198. }
  4199. }
  4200. }
  4201. if is390 == 1 {
  4202. insutype = "390"
  4203. }
  4204. if is310 == 1 {
  4205. insutype = "310"
  4206. }
  4207. if len(insutypes) == 0 {
  4208. insutype = "310"
  4209. }
  4210. service.CreateHisPsn(psn)
  4211. c.ServeSuccessJSON(map[string]interface{}{
  4212. "patient": patient,
  4213. "number": token,
  4214. "insutype": insutype,
  4215. })
  4216. }
  4217. } else {
  4218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4219. return
  4220. }
  4221. } else { //读卡失败
  4222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4223. return
  4224. }
  4225. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4226. idNo := c.GetString("idNo")
  4227. userName := c.GetString("userName")
  4228. ecToken := c.GetString("ecToken")
  4229. insuOrg := c.GetString("insuOrg")
  4230. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4231. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4232. var res ResultTwo
  4233. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4234. utils.ErrorLog("解析失败:%v", err)
  4235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4236. return
  4237. }
  4238. if res.Infcode == 0 {
  4239. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4240. if err == gorm.ErrRecordNotFound {
  4241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4242. return
  4243. } else if err != nil {
  4244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4245. return
  4246. } else {
  4247. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4248. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4249. infoStr := string(Iinfos)
  4250. idetinfoStr := string(Idetinfos)
  4251. psn := &models.HisPsn{
  4252. PsnNo: res.Output.Baseinfo.PsnNo,
  4253. Age: res.Output.Baseinfo.Age,
  4254. PatientId: patient.ID,
  4255. Certno: res.Output.Baseinfo.Certno,
  4256. Brdy: res.Output.Baseinfo.Brdy,
  4257. Gend: res.Output.Baseinfo.Gend,
  4258. Naty: res.Output.Baseinfo.Naty,
  4259. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4260. PsnName: res.Output.Baseinfo.PsnName,
  4261. Idetinfo: idetinfoStr,
  4262. Insuinfo: infoStr,
  4263. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4264. CardInfo: "",
  4265. Stage: "1",
  4266. VerifyNumber: ecToken,
  4267. InsuplcAdmdvs: insuOrg,
  4268. }
  4269. service.CreateHisPsn(psn)
  4270. var rf []*ResultFive
  4271. json.Unmarshal([]byte(infoStr), &rf)
  4272. var insutypes []*ResultFive
  4273. var insutype string
  4274. var is390 int = 0
  4275. var is310 int = 0
  4276. for _, item := range rf {
  4277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4278. insutypes = append(insutypes, item)
  4279. }
  4280. }
  4281. if len(insutypes) == 1 {
  4282. insutype = insutypes[0].Insutype
  4283. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4284. } else {
  4285. for _, i := range insutypes {
  4286. if i.Insutype == "390" {
  4287. is390 = 1
  4288. }
  4289. if i.Insutype == "310" {
  4290. is310 = 1
  4291. }
  4292. }
  4293. }
  4294. if is390 == 1 {
  4295. insutype = "390"
  4296. }
  4297. if is310 == 1 {
  4298. insutype = "310"
  4299. }
  4300. if len(insutypes) == 0 {
  4301. insutype = "310"
  4302. }
  4303. c.ServeSuccessJSON(map[string]interface{}{
  4304. "patient": patient,
  4305. "number": ecToken,
  4306. "insutype": insutype,
  4307. })
  4308. }
  4309. } else {
  4310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4311. return
  4312. }
  4313. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4314. //if initFlag == 0 {
  4315. c.TestGetJiangXiBasBaseInit()
  4316. //}
  4317. //if initEleFlag == 0 {
  4318. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4319. //}
  4320. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4321. type ELeData struct {
  4322. Data struct {
  4323. IdNo string `json:"idNo"`
  4324. IdType string `json:"idType"`
  4325. UserName string `json:"userName"`
  4326. EcToken string `json:"ecToken"`
  4327. InsuOrg string `json:"insuOrg"`
  4328. Gender string `json:"gender"`
  4329. Birthday string `json:"birthday"`
  4330. Nationality string `json:"nationality"`
  4331. Email string `json:"email"`
  4332. Extra string `json:"extra"`
  4333. } `json:"data"`
  4334. Code int `json:"code"`
  4335. Message string `json:"message"`
  4336. }
  4337. var ele ELeData
  4338. err := json.Unmarshal([]byte(json_result), &ele)
  4339. if err != nil {
  4340. utils.ErrorLog("解析失败:%v", err)
  4341. }
  4342. token := ele.Data.EcToken
  4343. token = Remove0000(token)
  4344. 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)
  4345. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4346. var res ResultTwo
  4347. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. if res.Infcode == 0 {
  4353. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4354. if err == gorm.ErrRecordNotFound {
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4356. return
  4357. } else if err != nil {
  4358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4359. return
  4360. } else {
  4361. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4362. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4363. infoStr := string(Iinfos)
  4364. idetinfoStr := string(Idetinfos)
  4365. psn := &models.HisPsn{
  4366. PsnNo: res.Output.Baseinfo.PsnNo,
  4367. Age: res.Output.Baseinfo.Age,
  4368. PatientId: patient.ID,
  4369. Certno: res.Output.Baseinfo.Certno,
  4370. Brdy: res.Output.Baseinfo.Brdy,
  4371. Gend: res.Output.Baseinfo.Gend,
  4372. Naty: res.Output.Baseinfo.Naty,
  4373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4374. PsnName: res.Output.Baseinfo.PsnName,
  4375. Idetinfo: idetinfoStr,
  4376. Insuinfo: infoStr,
  4377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4378. CardInfo: "",
  4379. //RecordDate:
  4380. VerifyNumber: token,
  4381. }
  4382. service.CreateHisPsn(psn)
  4383. var rf []*ResultFive
  4384. json.Unmarshal([]byte(infoStr), &rf)
  4385. var insutypes []*ResultFive
  4386. var insutype string
  4387. var is390 int = 0
  4388. var is310 int = 0
  4389. for _, item := range rf {
  4390. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4391. insutypes = append(insutypes, item)
  4392. }
  4393. }
  4394. if len(insutypes) == 1 {
  4395. insutype = insutypes[0].Insutype
  4396. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4397. } else {
  4398. for _, i := range insutypes {
  4399. if i.Insutype == "390" {
  4400. is390 = 1
  4401. }
  4402. if i.Insutype == "310" {
  4403. is310 = 1
  4404. }
  4405. }
  4406. }
  4407. if is390 == 1 {
  4408. insutype = "390"
  4409. }
  4410. if is310 == 1 {
  4411. insutype = "310"
  4412. }
  4413. if len(insutypes) == 0 {
  4414. insutype = "310"
  4415. }
  4416. c.ServeSuccessJSON(map[string]interface{}{
  4417. "patient": patient,
  4418. "number": token,
  4419. "insutype": insutype,
  4420. })
  4421. }
  4422. } else {
  4423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4424. return
  4425. }
  4426. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4427. //if initFlag == 0 {
  4428. c.TestGetJiangXiBasBaseInit()
  4429. //}
  4430. //if initEleFlag == 0 {
  4431. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4432. //}
  4433. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4434. type ELeData struct {
  4435. Data struct {
  4436. IdNo string `json:"idNo"`
  4437. IdType string `json:"idType"`
  4438. UserName string `json:"userName"`
  4439. EcToken string `json:"ecToken"`
  4440. InsuOrg string `json:"insuOrg"`
  4441. Gender string `json:"gender"`
  4442. Birthday string `json:"birthday"`
  4443. Nationality string `json:"nationality"`
  4444. Email string `json:"email"`
  4445. Extra string `json:"extra"`
  4446. } `json:"data"`
  4447. Code int `json:"code"`
  4448. Message string `json:"message"`
  4449. }
  4450. var ele ELeData
  4451. err := json.Unmarshal([]byte(json_result), &ele)
  4452. if err != nil {
  4453. utils.ErrorLog("解析失败:%v", err)
  4454. }
  4455. token := ele.Data.EcToken
  4456. token = Remove0000(token)
  4457. 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)
  4458. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4459. var res ResultTwo
  4460. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4461. utils.ErrorLog("解析失败:%v", err)
  4462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4463. return
  4464. }
  4465. if res.Infcode == 0 {
  4466. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4467. if err == gorm.ErrRecordNotFound {
  4468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4469. return
  4470. } else if err != nil {
  4471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4472. return
  4473. } else {
  4474. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4475. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4476. infoStr := string(Iinfos)
  4477. idetinfoStr := string(Idetinfos)
  4478. psn := &models.HisPsn{
  4479. PsnNo: res.Output.Baseinfo.PsnNo,
  4480. Age: res.Output.Baseinfo.Age,
  4481. PatientId: patient.ID,
  4482. Certno: res.Output.Baseinfo.Certno,
  4483. Brdy: res.Output.Baseinfo.Brdy,
  4484. Gend: res.Output.Baseinfo.Gend,
  4485. Naty: res.Output.Baseinfo.Naty,
  4486. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4487. PsnName: res.Output.Baseinfo.PsnName,
  4488. Idetinfo: idetinfoStr,
  4489. Insuinfo: infoStr,
  4490. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4491. CardInfo: "",
  4492. VerifyNumber: token,
  4493. }
  4494. service.CreateHisPsn(psn)
  4495. var rf []*ResultFive
  4496. json.Unmarshal([]byte(infoStr), &rf)
  4497. var insutypes []*ResultFive
  4498. var insutype string
  4499. var is390 int = 0
  4500. var is310 int = 0
  4501. for _, item := range rf {
  4502. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4503. insutypes = append(insutypes, item)
  4504. }
  4505. }
  4506. if len(insutypes) == 1 {
  4507. insutype = insutypes[0].Insutype
  4508. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4509. } else {
  4510. for _, i := range insutypes {
  4511. if i.Insutype == "390" {
  4512. is390 = 1
  4513. }
  4514. if i.Insutype == "310" {
  4515. is310 = 1
  4516. }
  4517. }
  4518. }
  4519. if is390 == 1 {
  4520. insutype = "390"
  4521. }
  4522. if is310 == 1 {
  4523. insutype = "310"
  4524. }
  4525. if len(insutypes) == 0 {
  4526. insutype = "310"
  4527. }
  4528. c.ServeSuccessJSON(map[string]interface{}{
  4529. "patient": patient,
  4530. "number": token,
  4531. "insutype": insutype,
  4532. })
  4533. }
  4534. } else {
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4536. return
  4537. }
  4538. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4539. type ELeData struct {
  4540. Code string `json:"code"`
  4541. Data struct {
  4542. Aac002 string `json:"aac002"`
  4543. Aaz500 string `json:"aaz500"`
  4544. ActCardNo string `json:"actCardNo"`
  4545. Bab520 string `json:"bab520"`
  4546. Bkz543 string `json:"bkz543"`
  4547. BusinessType string `json:"businessType"`
  4548. CertfCodg string `json:"certfCodg"`
  4549. EcIndexNo string `json:"ecIndexNo"`
  4550. EcToken string `json:"ecToken"`
  4551. ID0000 string `json:"id0000"`
  4552. IDNo string `json:"idNo"`
  4553. IDType string `json:"idType"`
  4554. Idcode string `json:"idcode"`
  4555. IdentityToken string `json:"identity_token"`
  4556. InsuOrg string `json:"insuOrg"`
  4557. OfficeID string `json:"officeId"`
  4558. OfficeName string `json:"officeName"`
  4559. OperatorID string `json:"operatorId"`
  4560. OperatorName string `json:"operatorName"`
  4561. OrgID string `json:"orgId"`
  4562. UserName string `json:"userName"`
  4563. } `json:"data"`
  4564. Infno interface{} `json:"infno"`
  4565. Message string `json:"message"`
  4566. OrgID string `json:"orgId"`
  4567. TransType string `json:"transType"`
  4568. }
  4569. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4570. outPutInfo = Remove0000(outPutInfo)
  4571. if len(outPutInfo) > 0 {
  4572. var ele ELeData
  4573. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4574. if err != nil {
  4575. utils.ErrorLog("解析失败:%v", err)
  4576. }
  4577. token := ele.Data.EcToken
  4578. fmt.Println(inputInfo)
  4579. fmt.Println(outPutInfo)
  4580. 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)
  4581. saveLog(result, requestLog, "1101", "获取人员信息")
  4582. var dat map[string]interface{}
  4583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4584. fmt.Println(dat)
  4585. } else {
  4586. fmt.Println(err)
  4587. }
  4588. userJSONBytes, _ := json.Marshal(dat)
  4589. var res ResultTwo
  4590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4591. utils.ErrorLog("解析失败:%v", err)
  4592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4593. return
  4594. }
  4595. res.ErrMsg = errMsgLog
  4596. if res.Infcode == 0 {
  4597. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4598. if err == gorm.ErrRecordNotFound {
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4600. return
  4601. } else if err != nil {
  4602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4603. return
  4604. } else {
  4605. fmt.Println(res)
  4606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4608. infoStr := string(Iinfos)
  4609. idetinfoStr := string(Idetinfos)
  4610. psn := &models.HisPsn{
  4611. PsnNo: res.Output.Baseinfo.PsnNo,
  4612. Age: res.Output.Baseinfo.Age,
  4613. PatientId: patient.ID,
  4614. Certno: res.Output.Baseinfo.Certno,
  4615. Brdy: res.Output.Baseinfo.Brdy,
  4616. Gend: res.Output.Baseinfo.Gend,
  4617. Naty: res.Output.Baseinfo.Naty,
  4618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4619. PsnName: res.Output.Baseinfo.PsnName,
  4620. Idetinfo: idetinfoStr,
  4621. Insuinfo: infoStr,
  4622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4623. CardInfo: outPutInfo,
  4624. VerifyNumber: token,
  4625. InsuplcAdmdvs: ele.Data.InsuOrg,
  4626. }
  4627. service.CreateHisPsn(psn)
  4628. var rf []*ResultFive
  4629. json.Unmarshal([]byte(infoStr), &rf)
  4630. var insutypes []*ResultFive
  4631. var insutype string
  4632. var is390 int = 0
  4633. var is310 int = 0
  4634. for _, item := range rf {
  4635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4636. insutypes = append(insutypes, item)
  4637. }
  4638. }
  4639. if len(insutypes) == 1 {
  4640. insutype = insutypes[0].Insutype
  4641. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4642. } else {
  4643. for _, i := range insutypes {
  4644. if i.Insutype == "390" {
  4645. is390 = 1
  4646. }
  4647. if i.Insutype == "310" {
  4648. is310 = 1
  4649. }
  4650. }
  4651. }
  4652. if is390 == 1 {
  4653. insutype = "390"
  4654. }
  4655. if is310 == 1 {
  4656. insutype = "310"
  4657. }
  4658. if len(insutypes) == 0 {
  4659. insutype = "310"
  4660. }
  4661. c.ServeSuccessJSON(map[string]interface{}{
  4662. "patient": patient,
  4663. "number": token,
  4664. "insutype": insutype,
  4665. })
  4666. }
  4667. } else {
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4669. return
  4670. }
  4671. }
  4672. } else {
  4673. type ELeData struct {
  4674. Code string `json:"code"`
  4675. Data struct {
  4676. Aac002 string `json:"aac002"`
  4677. Aaz500 string `json:"aaz500"`
  4678. ActCardNo string `json:"actCardNo"`
  4679. Bab520 string `json:"bab520"`
  4680. Bkz543 string `json:"bkz543"`
  4681. BusinessType string `json:"businessType"`
  4682. CertfCodg string `json:"certfCodg"`
  4683. EcIndexNo string `json:"ecIndexNo"`
  4684. EcToken string `json:"ecToken"`
  4685. ID0000 string `json:"id0000"`
  4686. IDNo string `json:"idNo"`
  4687. IDType string `json:"idType"`
  4688. Idcode string `json:"idcode"`
  4689. IdentityToken string `json:"identity_token"`
  4690. InsuOrg string `json:"insuOrg"`
  4691. OfficeID string `json:"officeId"`
  4692. OfficeName string `json:"officeName"`
  4693. OperatorID string `json:"operatorId"`
  4694. OperatorName string `json:"operatorName"`
  4695. OrgID string `json:"orgId"`
  4696. UserName string `json:"userName"`
  4697. } `json:"data"`
  4698. Infno interface{} `json:"infno"`
  4699. Message string `json:"message"`
  4700. OrgID string `json:"orgId"`
  4701. TransType string `json:"transType"`
  4702. }
  4703. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  4704. fmt.Println(result)
  4705. outPutInfo := Remove0000(result)
  4706. fmt.Println(outPutInfo)
  4707. if len(outPutInfo) > 0 {
  4708. var ele ELeData
  4709. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4710. if err != nil {
  4711. utils.ErrorLog("解析失败:%v", err)
  4712. }
  4713. token := ele.Data.EcToken
  4714. fmt.Println(outPutInfo)
  4715. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4716. saveLog(result, requestLog, "1101", "获取人员信息")
  4717. var dat map[string]interface{}
  4718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4719. fmt.Println(dat)
  4720. } else {
  4721. fmt.Println(err)
  4722. }
  4723. userJSONBytes, _ := json.Marshal(dat)
  4724. var res ResultTwo
  4725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4726. utils.ErrorLog("解析失败:%v", err)
  4727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4728. return
  4729. }
  4730. if res.Infcode == 0 {
  4731. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4732. if err == gorm.ErrRecordNotFound {
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4734. return
  4735. } else if err != nil {
  4736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4737. return
  4738. } else {
  4739. fmt.Println(res)
  4740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4741. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4742. infoStr := string(Iinfos)
  4743. idetinfoStr := string(Idetinfos)
  4744. psn := &models.HisPsn{
  4745. PsnNo: res.Output.Baseinfo.PsnNo,
  4746. Age: res.Output.Baseinfo.Age,
  4747. PatientId: patient.ID,
  4748. Certno: res.Output.Baseinfo.Certno,
  4749. Brdy: res.Output.Baseinfo.Brdy,
  4750. Gend: res.Output.Baseinfo.Gend,
  4751. Naty: res.Output.Baseinfo.Naty,
  4752. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4753. PsnName: res.Output.Baseinfo.PsnName,
  4754. Idetinfo: idetinfoStr,
  4755. Insuinfo: infoStr,
  4756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4757. CardInfo: outPutInfo,
  4758. VerifyNumber: token,
  4759. InsuplcAdmdvs: ele.Data.InsuOrg,
  4760. }
  4761. service.CreateHisPsn(psn)
  4762. var rf []*ResultFive
  4763. json.Unmarshal([]byte(infoStr), &rf)
  4764. var insutypes []*ResultFive
  4765. var insutype string
  4766. var is390 int = 0
  4767. var is310 int = 0
  4768. for _, item := range rf {
  4769. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4770. insutypes = append(insutypes, item)
  4771. }
  4772. }
  4773. if len(insutypes) == 1 {
  4774. insutype = insutypes[0].Insutype
  4775. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4776. } else {
  4777. for _, i := range insutypes {
  4778. if i.Insutype == "390" {
  4779. is390 = 1
  4780. }
  4781. if i.Insutype == "310" {
  4782. is310 = 1
  4783. }
  4784. }
  4785. }
  4786. if is390 == 1 {
  4787. insutype = "390"
  4788. }
  4789. if is310 == 1 {
  4790. insutype = "310"
  4791. }
  4792. if len(insutypes) == 0 {
  4793. insutype = "310"
  4794. }
  4795. c.ServeSuccessJSON(map[string]interface{}{
  4796. "patient": patient,
  4797. "number": token,
  4798. "insutype": insutype,
  4799. })
  4800. }
  4801. } else {
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4803. return
  4804. }
  4805. }
  4806. //fmt.Println(result)
  4807. //
  4808. //if initFlag == 0 {
  4809. // c.TestGetBasBaseInit()
  4810. //}
  4811. //token := c.GetEleBaseInfo()
  4812. //
  4813. //token = Remove0000(token)
  4814. //
  4815. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4816. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  4817. ////
  4818. //var res ResultTwo
  4819. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4820. // utils.ErrorLog("解析失败:%v", err)
  4821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4822. // return
  4823. //}
  4824. //
  4825. //if res.Infcode == 0 {
  4826. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4827. // if err == gorm.ErrRecordNotFound {
  4828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4829. // return
  4830. // } else if err != nil {
  4831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4832. // return
  4833. //
  4834. // } else {
  4835. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4836. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4837. // infoStr := string(Iinfos)
  4838. // idetinfoStr := string(Idetinfos)
  4839. //
  4840. //
  4841. //
  4842. //
  4843. // var rf []*ResultFive
  4844. // json.Unmarshal([]byte(infoStr), &rf)
  4845. //
  4846. // var insutypes []*ResultFive
  4847. // var insutype string
  4848. // var is390 int = 0
  4849. // var is310 int = 0
  4850. // var insuplc_admdvs string
  4851. //
  4852. // for _, item := range rf {
  4853. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4854. // insutypes = append(insutypes, item)
  4855. // }
  4856. // }
  4857. //
  4858. // if len(insutypes) == 1 {
  4859. // insutype = insutypes[0].Insutype
  4860. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4861. // } else {
  4862. // for _, i := range insutypes {
  4863. // if i.Insutype == "390" {
  4864. // is390 = 1
  4865. // }
  4866. //
  4867. // if i.Insutype == "310" {
  4868. // is310 = 1
  4869. // }
  4870. // }
  4871. // }
  4872. // if is390 == 1 {
  4873. // insutype = "390"
  4874. // }
  4875. //
  4876. // if is310 == 1 {
  4877. // insutype = "310"
  4878. // }
  4879. // if len(insutypes) == 0 {
  4880. // insutype = "310"
  4881. // }
  4882. // for _, item := range rf {
  4883. // if item.Insutype == insutype {
  4884. // insuplc_admdvs = item.InsuplcAdmdvs
  4885. // }
  4886. // }
  4887. // psn := &models.HisPsn{
  4888. // PsnNo: res.Output.Baseinfo.PsnNo,
  4889. // Age: res.Output.Baseinfo.Age,
  4890. // PatientId: patient.ID,
  4891. // Certno: res.Output.Baseinfo.Certno,
  4892. // Brdy: res.Output.Baseinfo.Brdy,
  4893. // Gend: res.Output.Baseinfo.Gend,
  4894. // Naty: res.Output.Baseinfo.Naty,
  4895. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  4896. // PsnName: res.Output.Baseinfo.PsnName,
  4897. // Idetinfo: idetinfoStr,
  4898. // Insuinfo: infoStr,
  4899. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4900. // CardInfo: "",
  4901. // VerifyNumber: token,
  4902. // InsuplcAdmdvs: insuplc_admdvs,
  4903. // }
  4904. // service.CreateHisPsn(psn)
  4905. //
  4906. // c.ServeSuccessJSON(map[string]interface{}{
  4907. // "patient": patient,
  4908. // "number": token,
  4909. // })
  4910. // }
  4911. //} else {
  4912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4913. // return
  4914. //}
  4915. }
  4916. break
  4917. }
  4918. }
  4919. var initFlag int64 = 0
  4920. var initEleFlag int64 = 0
  4921. func (c *HisApiController) TestGetBasBaseInit() {
  4922. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4923. Iinit := DllDef.MustFindProc("Init")
  4924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4925. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4926. if ret != 0 {
  4927. fmt.Println("SSCard的报错原因:", err)
  4928. fmt.Println("SSCard的运算结果为:", ret)
  4929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4930. return
  4931. }
  4932. result := int(ret)
  4933. fmt.Println("SSCard的运算结果为1:", result)
  4934. initFlag = 1
  4935. return
  4936. }
  4937. func (c *HisApiController) HandleJiangXiReadCard() {
  4938. fmt.Println("~~~~~~")
  4939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4940. admin_user_id, _ := c.GetInt64("admin_user_id")
  4941. id_card_type, _ := c.GetInt64("id_card_type")
  4942. //certificates, _ := c.GetInt64("certificates")
  4943. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4944. if initFlag == 0 {
  4945. c.TestGetJiangXiBasBaseInit()
  4946. }
  4947. basStr := c.GetBasBaseInfo()
  4948. if len(basStr) == 0 {
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4950. return
  4951. }
  4952. fmt.Println(basStr)
  4953. bas := strings.Split(basStr, "|")
  4954. basNumber := bas[1]
  4955. fmt.Println(basNumber)
  4956. card_sn := bas[3]
  4957. fmt.Println(card_sn)
  4958. 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, "")
  4959. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4960. var dat map[string]interface{}
  4961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4962. fmt.Println(dat)
  4963. } else {
  4964. fmt.Println(err)
  4965. }
  4966. userJSONBytes, _ := json.Marshal(dat)
  4967. var res ResultTwo
  4968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4969. utils.ErrorLog("解析失败:%v", err)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. if res.Infcode == 0 {
  4974. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4975. if err == gorm.ErrRecordNotFound {
  4976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4977. return
  4978. } else if err != nil {
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4980. return
  4981. } else {
  4982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4984. infoStr := string(Iinfos)
  4985. idetinfoStr := string(Idetinfos)
  4986. psn := &models.HisPsn{
  4987. PsnNo: res.Output.Baseinfo.PsnNo,
  4988. Age: res.Output.Baseinfo.Age,
  4989. PatientId: patient.ID,
  4990. Certno: res.Output.Baseinfo.Certno,
  4991. Brdy: res.Output.Baseinfo.Brdy,
  4992. Gend: res.Output.Baseinfo.Gend,
  4993. Naty: res.Output.Baseinfo.Naty,
  4994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4995. PsnName: res.Output.Baseinfo.PsnName,
  4996. Idetinfo: idetinfoStr,
  4997. Insuinfo: infoStr,
  4998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4999. CardInfo: basStr,
  5000. VerifyNumber: "",
  5001. }
  5002. service.CreateHisPsn(psn)
  5003. c.ServeSuccessJSON(map[string]interface{}{
  5004. "patient": patient,
  5005. "number": basNumber,
  5006. })
  5007. }
  5008. } else {
  5009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5010. return
  5011. }
  5012. }
  5013. func (c *HisApiController) TestGetHnBasBaseInit() {
  5014. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5015. Iinit := DllDef.MustFindProc("Init")
  5016. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5017. //http://10.77.211.236/CSB/hsa-fsi-1303
  5018. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  5019. if ret != 0 {
  5020. fmt.Println("SSCard的报错原因:", err)
  5021. fmt.Println("SSCard的运算结果为:", ret)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5023. return
  5024. }
  5025. result := int(ret)
  5026. fmt.Println("SSCard的运算结果为1:", result)
  5027. initFlag = 1
  5028. return
  5029. }
  5030. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  5031. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5032. Iinit := DllDef.MustFindProc("Init")
  5033. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5034. //http://10.77.211.236/CSB/hsa-fsi-1303
  5035. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  5036. if ret != 0 {
  5037. fmt.Println("SSCard的报错原因:", err)
  5038. fmt.Println("SSCard的运算结果为:", ret)
  5039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5040. return
  5041. }
  5042. result := int(ret)
  5043. fmt.Println("SSCard的运算结果为1:", result)
  5044. initFlag = 1
  5045. return
  5046. }
  5047. func (c *HisApiController) GetSFZBaseInfo() string {
  5048. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5049. readCard := DllDef.MustFindProc("ReadSFZ")
  5050. if readCard == nil {
  5051. fmt.Println("readcard is nil")
  5052. readCard = DllDef.MustFindProc("ReadSFZ")
  5053. }
  5054. str := make([]byte, 8096)
  5055. str1 := make([]byte, 8096)
  5056. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  5057. fmt.Println(r)
  5058. return Remove0000(string(str))
  5059. }
  5060. func (c *HisApiController) GetEleBaseInfo() string {
  5061. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5062. readCard := DllDef.MustFindProc("GetQRBase")
  5063. fmt.Println(readCard)
  5064. if readCard == nil {
  5065. fmt.Println("readcard is nil")
  5066. readCard = DllDef.MustFindProc("GetQRBase")
  5067. }
  5068. str := make([]byte, 1024)
  5069. str1 := make([]byte, 1024)
  5070. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5071. fmt.Println(ret2)
  5072. fmt.Println(string(str1))
  5073. fmt.Println(string(str))
  5074. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5075. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5076. if ret2 != 0 {
  5077. return ""
  5078. }
  5079. return string(str)
  5080. }
  5081. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5082. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5083. readCard := DllDef.MustFindProc("NationEcTrans")
  5084. fmt.Println(readCard)
  5085. fmt.Println("!!!!!")
  5086. pBusiCardInfo := make([]byte, 2048)
  5087. input := make(map[string]interface{})
  5088. inputData := make(map[string]interface{})
  5089. inputData["orgId"] = code
  5090. inputData["businessType"] = "01101"
  5091. inputData["operatorId"] = "1"
  5092. inputData["operatorName"] = "admin"
  5093. inputData["officeId"] = "001"
  5094. inputData["officeName"] = "血透室"
  5095. inputData["deviceType"] = ""
  5096. input["data"] = inputData
  5097. input["orgId"] = code
  5098. input["transType"] = "ec.query"
  5099. bytesData, _ := json.Marshal(input)
  5100. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5101. fmt.Println(ret2)
  5102. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5103. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5104. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  5105. }
  5106. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5107. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5108. readCard := DllDef.MustFindProc("NationEcTrans")
  5109. fmt.Println(readCard)
  5110. fmt.Println("!!!!!")
  5111. pBusiCardInfo := make([]byte, 2048)
  5112. input := make(map[string]interface{})
  5113. inputData := make(map[string]interface{})
  5114. inputData["orgId"] = code
  5115. inputData["businessType"] = "01101"
  5116. inputData["operatorId"] = "9"
  5117. inputData["operatorName"] = "admin"
  5118. inputData["officeId"] = "001"
  5119. inputData["officeName"] = "血透室"
  5120. inputData["deviceType"] = ""
  5121. input["data"] = inputData
  5122. input["orgId"] = code
  5123. input["transType"] = "ec.query"
  5124. bytesData, _ := json.Marshal(input)
  5125. 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])))
  5126. fmt.Println(ret2)
  5127. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5128. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5129. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5130. }
  5131. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  5132. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5133. readCard := DllDef.MustFindProc("NationEcTrans")
  5134. fmt.Println(readCard)
  5135. fmt.Println("!!!!!")
  5136. pBusiCardInfo := make([]byte, 2048)
  5137. input := make(map[string]interface{})
  5138. inputData := make(map[string]interface{})
  5139. inputData["orgId"] = code
  5140. inputData["businessType"] = "01301"
  5141. inputData["operatorId"] = "9"
  5142. inputData["operatorName"] = "admin"
  5143. inputData["officeId"] = "001"
  5144. inputData["officeName"] = "血透室"
  5145. inputData["deviceType"] = ""
  5146. input["data"] = inputData
  5147. input["orgId"] = code
  5148. input["transType"] = "ec.query"
  5149. bytesData, _ := json.Marshal(input)
  5150. 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])))
  5151. fmt.Println(ret2)
  5152. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5153. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5154. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5155. }
  5156. func GetJxEleBaseInfo(org_id int64) string {
  5157. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5158. readCard := DllDef.MustFindProc("NationEcTrans")
  5159. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5160. if readCard == nil {
  5161. fmt.Println("readcard is nil")
  5162. readCard = DllDef.MustFindProc("NationEcTrans")
  5163. }
  5164. str1 := make([]byte, 1024)
  5165. data := make(map[string]interface{})
  5166. inputData := make(map[string]interface{})
  5167. inputData["orgId"] = miConfig.Code
  5168. inputData["businessType"] = "01101"
  5169. inputData["operatorId"] = "test001"
  5170. inputData["operatorName"] = "cn"
  5171. inputData["officeId"] = "32760"
  5172. inputData["officeName"] = "waike"
  5173. inputData["deviceType"] = ""
  5174. data["data"] = inputData
  5175. data["transType"] = "ec.query"
  5176. data["extra "] = ""
  5177. data["orgId"] = miConfig.Code
  5178. bytesData, _ := json.Marshal(data)
  5179. //bytesData, _ := json.Marshal(data)
  5180. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5181. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5182. fmt.Println(ret2)
  5183. fmt.Println(string(str1))
  5184. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5185. if ret2 != 0 {
  5186. return ""
  5187. }
  5188. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5189. }
  5190. func GetJxEleBaseInitInfo(org_id int64) string {
  5191. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5192. readCard := DllDef.MustFindProc("NationEcTrans")
  5193. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5194. if readCard == nil {
  5195. fmt.Println("readcard is nil")
  5196. readCard = DllDef.MustFindProc("NationEcTrans")
  5197. }
  5198. str1 := make([]byte, 2048)
  5199. data := make(map[string]interface{})
  5200. inputData := make(map[string]interface{})
  5201. inputData["orgId"] = miConfig.Code
  5202. inputData["businessType"] = "01101"
  5203. inputData["operatorId"] = "1"
  5204. inputData["operatorName"] = "huangchuang"
  5205. inputData["officeId"] = "101"
  5206. inputData["officeName"] = "xuetou"
  5207. inputData["deviceType"] = ""
  5208. data["data"] = inputData
  5209. data["transType"] = "ec.query"
  5210. data["orgId"] = miConfig.Code
  5211. bytesData, _ := json.Marshal(data)
  5212. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5213. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5214. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  5215. fmt.Println(ret2)
  5216. fmt.Println(string(str1))
  5217. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5218. if ret2 != 0 {
  5219. return ""
  5220. }
  5221. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  5222. initEleFlag = 1
  5223. }
  5224. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5225. }
  5226. func (c *HisApiController) GetBasBaseInfo() string {
  5227. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5228. readCard := DllDef.MustFindProc("ReadCardBas")
  5229. if readCard == nil {
  5230. fmt.Println("readcard is nil")
  5231. readCard = DllDef.MustFindProc("ReadCardBas")
  5232. }
  5233. str := make([]byte, 1024)
  5234. str1 := make([]byte, 1024)
  5235. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5236. fmt.Println(string(str1))
  5237. fmt.Println(string(str))
  5238. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5239. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5240. if ret2 != 0 {
  5241. return ""
  5242. }
  5243. return string(str)
  5244. }
  5245. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  5246. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  5247. readCard := DllDef.MustFindProc("read_cardinfo")
  5248. if readCard == nil {
  5249. fmt.Println("readcard is nil")
  5250. readCard = DllDef.MustFindProc("read_cardinfo")
  5251. }
  5252. str := make([]byte, 1024) //卡号
  5253. str1 := make([]byte, 1024) //卡识别码
  5254. str2 := make([]byte, 1024) //身份证号
  5255. str3 := make([]byte, 1024) //姓名
  5256. str4 := make([]byte, 1024) //错误信息
  5257. 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])))
  5258. fmt.Println(string(str1))
  5259. fmt.Println(string(str))
  5260. fmt.Println(string(str2))
  5261. fmt.Println(string(str3))
  5262. fmt.Println(string(str4))
  5263. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5264. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5265. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  5266. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  5267. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  5268. if ret2 != 0 {
  5269. return "", "", "", "", ""
  5270. }
  5271. return string(str), string(str1), string(str2), string(str3), string(str4)
  5272. }
  5273. type CustomFundPay struct {
  5274. FundPayType string `json:"fund_pay_type"`
  5275. FundPayamt float64 `json:"fund_payamt"`
  5276. }
  5277. func (c *HisApiController) GetSettleList() {
  5278. order_id, _ := c.GetInt64("order_id")
  5279. admin_user_id, _ := c.GetInt64("admin_user_id")
  5280. order, _ := service.GetHisOrderByIDTwo(order_id)
  5281. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5282. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5283. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5284. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5285. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5286. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5287. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5288. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5289. if order.ID == 0 {
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5291. return
  5292. }
  5293. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5294. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5295. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5296. //fmt.Println(count)
  5297. //var zero string
  5298. //number := count + 1
  5299. //if number >= 1000 {
  5300. // zero = "0000" + strconv.FormatInt(number, 10)
  5301. //} else if number >= 10000 {
  5302. // zero = "000" + strconv.FormatInt(number, 10)
  5303. //} else if number >= 100000 {
  5304. // zero = "00" + strconv.FormatInt(number, 10)
  5305. //} else if number >= 1000000 {
  5306. // zero = "0" + strconv.FormatInt(number, 10)
  5307. //} else {
  5308. // zero = strconv.FormatInt(number, 10)
  5309. //}
  5310. //fmt.Println(zero)
  5311. struct4101 := service.Struct4101{
  5312. PsnNo: order.PsnNo,
  5313. MdtrtId: order.MdtrtId,
  5314. SetlId: order.SetlId,
  5315. PsnName: order.PsnName,
  5316. Gend: order.Gend,
  5317. Brdy: his.Brdy,
  5318. Age: his.Age,
  5319. Naty: order.Naty,
  5320. PatnCertType: "01",
  5321. Certno: order.Certno,
  5322. Prfs: "90",
  5323. ConerName: roles[0].UserName,
  5324. PatnRlts: "99",
  5325. ConerAddr: miConfig.OrgName,
  5326. ConerTel: admin.Mobile,
  5327. HiType: order.Insutype,
  5328. Insuplc: miConfig.InsuplcAdmdvs,
  5329. MaindiagFlag: "1",
  5330. BillCode: order.SetlId,
  5331. BillNo: order.SetlId,
  5332. BizSn: order.Number,
  5333. PsnSelfPay: order.PsnPartAmt,
  5334. PsnOwnPay: order.PsnPartAmt,
  5335. AcctPay: order.AcctPay,
  5336. PsnCashpay: order.PsnCashPay,
  5337. HiPaymtd: "1",
  5338. Hsorg: miConfig.InsuplcAdmdvs,
  5339. HsorgOpter: miConfig.InsuplcAdmdvs,
  5340. MedinsFillPsn: curRoles.UserName,
  5341. MedinsFillDept: depart.Name,
  5342. IptMedType: "2",
  5343. }
  5344. struct4101.SetlBegnDate = order.SetlTime
  5345. struct4101.SetlEndDate = order.SetlTime
  5346. time_arr := strings.Split(order.SetlTime, " ")
  5347. struct4101.AdmTime = time_arr[0]
  5348. struct4101.AdmEndTime = time_arr[0]
  5349. var rf []CustomFundPay
  5350. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5351. var tempFunPays []service.CustomStruct
  5352. for _, item := range rf {
  5353. var tempFunPay service.CustomStruct
  5354. tempFunPay.FundPayamt = item.FundPayamt
  5355. tempFunPay.FundPayType = item.FundPayType
  5356. tempFunPays = append(tempFunPays, tempFunPay)
  5357. }
  5358. struct4101.CustomStruct = tempFunPays
  5359. var tempDiaginfos []service.DiaginfoStructTwo
  5360. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5361. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5362. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5363. var config []*models.HisXtDiagnoseConfig
  5364. for _, item := range diagnosis_ids {
  5365. id, _ := strconv.ParseInt(item, 10, 64)
  5366. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5367. config = append(config, &diagnosisConfig)
  5368. }
  5369. for index, item := range config {
  5370. if index == 0 {
  5371. var tempDiaginfo service.DiaginfoStructTwo
  5372. tempDiaginfo.DiagCode = item.CountryCode
  5373. tempDiaginfo.DiagName = item.CountryContentName
  5374. tempDiaginfo.DiagType = "1"
  5375. tempDiaginfo.MaindiagFlag = "1"
  5376. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5377. } else {
  5378. var tempDiaginfo service.DiaginfoStructTwo
  5379. tempDiaginfo.DiagCode = item.CountryCode
  5380. tempDiaginfo.DiagName = item.CountryContentName
  5381. tempDiaginfo.DiagType = "2"
  5382. tempDiaginfo.MaindiagFlag = "0"
  5383. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5384. }
  5385. }
  5386. struct4101.Diseinfo = tempDiaginfos
  5387. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5388. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5389. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5390. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  5391. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  5392. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5393. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5394. var iteminfo service.IteminfoStruct
  5395. var bedCostTotal float64 = 0 //床位总费
  5396. var bedCostSelfTotal float64 = 0 //床位自费
  5397. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5398. var operationCostTotal float64 = 0 //手术费
  5399. var operationCostSelfTotal float64 = 0 //手术费
  5400. var operationCostPartSelfTotal float64 = 0 //手术费
  5401. var otherCostTotal float64 = 0 //其他费用
  5402. var otherCostSelfTotal float64 = 0 //其他费用
  5403. var otherCostPartSelfTotal float64 = 0 //其他费用
  5404. var materialCostTotal float64 = 0 //材料费
  5405. var materialCostSelfTotal float64 = 0 //材料费
  5406. var materialCostPartSelfTotal float64 = 0 //材料费
  5407. var westernMedicineCostTotal float64 = 0 //西药费
  5408. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5409. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5410. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5411. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5412. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5413. var checkCostTotal float64 = 0 //检查费
  5414. var checkCostSelfTotal float64 = 0 //检查费
  5415. var checkCostPartSelfTotal float64 = 0 //检查费
  5416. var laboratoryCostTotal float64 = 0 //化验费
  5417. var laboratoryCostSelfTotal float64 = 0 //化验费
  5418. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5419. var treatCostTotal float64 = 0 //治疗费用
  5420. var treatCostSelfTotal float64 = 0 //治疗费用
  5421. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5422. decimal.DivisionPrecision = 2
  5423. var bed_fulamt_ownpay_amt float64 = 0
  5424. var operation_fulamt_ownpay_amt float64 = 0
  5425. var other_fulamt_ownpay_amt float64 = 0
  5426. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5427. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5428. var check_fulamt_ownpay_amt float64 = 0
  5429. var material_fulamt_ownpay_amt float64 = 0
  5430. var laboratory_fulamt_ownpay_amt float64 = 0
  5431. var treat_fulamt_ownpay_amt float64 = 0
  5432. var bed_claa_sunmfee float64 = 0
  5433. var bed_clab_amt float64 = 0
  5434. var bed_other_amt float64 = 0
  5435. var operation_claa_sunmfee float64 = 0
  5436. var operation_clab_amt float64 = 0
  5437. var operation_other_amt float64 = 0
  5438. var other_claa_sunmfee float64 = 0
  5439. var other_clab_amt float64 = 0
  5440. var other_other_amt float64 = 0
  5441. var westernMedicine_claa_sunmfee float64 = 0
  5442. var westernMedicine_clab_amt float64 = 0
  5443. var westernMedicine_other_amt float64 = 0
  5444. var chineseTraditional_claa_sunmfee float64 = 0
  5445. var chineseTraditional_clab_amt float64 = 0
  5446. var chineseTraditional_other_amt float64 = 0
  5447. var check_claa_sunmfee float64 = 0
  5448. var check_clab_amt float64 = 0
  5449. var check_other_amt float64 = 0
  5450. var material_claa_sunmfee float64 = 0
  5451. var material_clab_amt float64 = 0
  5452. var material_other_amt float64 = 0
  5453. var laboratory_claa_sunmfee float64 = 0
  5454. var laboratory_clab_amt float64 = 0
  5455. var laboratory_other_amt float64 = 0
  5456. var treat_claa_sunmfee float64 = 0
  5457. var treat_clab_amt float64 = 0
  5458. var treat_other_amt float64 = 0
  5459. for _, item := range order.HisOrderInfo {
  5460. if item.MedChrgitmType == "01" { //床位费
  5461. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5462. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5463. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5464. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5465. if item.ChrgitmLv == "1" {
  5466. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5467. }
  5468. if item.ChrgitmLv == "2" {
  5469. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5470. }
  5471. if item.ChrgitmLv == "3" {
  5472. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5473. }
  5474. }
  5475. if item.MedChrgitmType == "03" { //检查费
  5476. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5477. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5478. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5479. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5480. if item.ChrgitmLv == "1" {
  5481. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5482. }
  5483. if item.ChrgitmLv == "2" {
  5484. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5485. }
  5486. if item.ChrgitmLv == "3" {
  5487. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5488. }
  5489. }
  5490. if item.MedChrgitmType == "04" { //化验费
  5491. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5492. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5493. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5494. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5495. if item.ChrgitmLv == "1" {
  5496. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5497. }
  5498. if item.ChrgitmLv == "2" {
  5499. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5500. }
  5501. if item.ChrgitmLv == "3" {
  5502. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5503. }
  5504. }
  5505. if item.MedChrgitmType == "05" { //治疗费
  5506. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5507. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5508. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5509. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5510. if item.ChrgitmLv == "1" {
  5511. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5512. }
  5513. if item.ChrgitmLv == "2" {
  5514. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5515. }
  5516. if item.ChrgitmLv == "3" {
  5517. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5518. }
  5519. }
  5520. if item.MedChrgitmType == "06" { //手术费
  5521. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5522. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5523. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5524. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5525. if item.ChrgitmLv == "1" {
  5526. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5527. }
  5528. if item.ChrgitmLv == "2" {
  5529. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5530. }
  5531. if item.ChrgitmLv == "3" {
  5532. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5533. }
  5534. }
  5535. if item.MedChrgitmType == "08" { //材料费
  5536. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5537. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5538. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5539. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5540. if item.ChrgitmLv == "1" {
  5541. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5542. }
  5543. if item.ChrgitmLv == "2" {
  5544. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5545. }
  5546. if item.ChrgitmLv == "3" {
  5547. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5548. }
  5549. }
  5550. if item.MedChrgitmType == "09" { //西药费
  5551. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5552. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5553. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5554. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5555. if item.ChrgitmLv == "1" {
  5556. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5557. }
  5558. if item.ChrgitmLv == "2" {
  5559. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5560. }
  5561. if item.ChrgitmLv == "3" {
  5562. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5563. }
  5564. }
  5565. if item.MedChrgitmType == "11" { //中成费
  5566. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5567. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5568. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5569. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5570. if item.ChrgitmLv == "1" {
  5571. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5572. }
  5573. if item.ChrgitmLv == "2" {
  5574. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5575. }
  5576. if item.ChrgitmLv == "3" {
  5577. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5578. }
  5579. }
  5580. if item.MedChrgitmType == "14" { //其他费
  5581. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5582. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5583. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5584. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5585. if item.ChrgitmLv == "1" {
  5586. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5587. }
  5588. if item.ChrgitmLv == "2" {
  5589. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5590. }
  5591. if item.ChrgitmLv == "3" {
  5592. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5593. }
  5594. }
  5595. }
  5596. var iteminfoStructs []service.IteminfoStruct
  5597. if bedCostTotal != 0 {
  5598. iteminfo.MedChrgitm = "01"
  5599. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5600. iteminfo.Amt = bedCostTotal
  5601. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5602. iteminfo.ClabAmt = bed_clab_amt
  5603. iteminfo.OthAmt = bed_other_amt
  5604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5605. }
  5606. if checkCostTotal != 0 {
  5607. iteminfo.MedChrgitm = "03"
  5608. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5609. iteminfo.Amt = checkCostTotal
  5610. iteminfo.ClaaSumfee = check_claa_sunmfee
  5611. iteminfo.ClabAmt = check_clab_amt
  5612. iteminfo.OthAmt = check_other_amt
  5613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5614. }
  5615. if laboratoryCostTotal != 0 {
  5616. iteminfo.MedChrgitm = "04"
  5617. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5618. iteminfo.Amt = laboratoryCostTotal
  5619. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5620. iteminfo.ClabAmt = laboratory_clab_amt
  5621. iteminfo.OthAmt = laboratory_other_amt
  5622. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5623. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5624. }
  5625. if treatCostTotal != 0 {
  5626. iteminfo.MedChrgitm = "05"
  5627. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5628. iteminfo.Amt = treatCostTotal
  5629. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5630. iteminfo.ClabAmt = treat_clab_amt
  5631. iteminfo.OthAmt = treat_other_amt
  5632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5633. //(struct4101.IteminfoStruct, iteminfo)
  5634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5635. }
  5636. if operationCostTotal != 0 {
  5637. iteminfo.MedChrgitm = "06"
  5638. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5639. iteminfo.Amt = operationCostTotal
  5640. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5641. iteminfo.ClabAmt = operation_clab_amt
  5642. iteminfo.OthAmt = operation_other_amt
  5643. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5644. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5645. }
  5646. if materialCostTotal != 0 {
  5647. iteminfo.MedChrgitm = "08"
  5648. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5649. iteminfo.Amt = materialCostTotal
  5650. iteminfo.ClaaSumfee = material_claa_sunmfee
  5651. iteminfo.ClabAmt = material_clab_amt
  5652. iteminfo.OthAmt = material_other_amt
  5653. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5654. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5655. }
  5656. if westernMedicineCostTotal != 0 {
  5657. iteminfo.MedChrgitm = "09"
  5658. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5659. iteminfo.Amt = westernMedicineCostTotal
  5660. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5661. iteminfo.ClabAmt = westernMedicine_clab_amt
  5662. iteminfo.OthAmt = westernMedicine_other_amt
  5663. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5664. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5665. }
  5666. if chineseTraditionalMedicineCostTotal != 0 {
  5667. iteminfo.MedChrgitm = "11"
  5668. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5669. iteminfo.Amt = westernMedicineCostTotal
  5670. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5671. iteminfo.ClabAmt = westernMedicine_clab_amt
  5672. iteminfo.OthAmt = westernMedicine_other_amt
  5673. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5674. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5675. }
  5676. if otherCostTotal != 0 {
  5677. iteminfo.MedChrgitm = "14"
  5678. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5679. iteminfo.Amt = otherCostTotal
  5680. iteminfo.ClaaSumfee = other_claa_sunmfee
  5681. iteminfo.ClabAmt = other_clab_amt
  5682. iteminfo.OthAmt = other_other_amt
  5683. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5684. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5685. }
  5686. struct4101.IteminfoStruct = iteminfoStructs
  5687. struct4101.Ntly = "中国"
  5688. struct4101.AdmCaty = "A03.06"
  5689. struct4101.DoctorName = doctor.UserName
  5690. struct4101.DoctorCode = doctor.DoctorNumber
  5691. var res ResultSeventeen
  5692. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5693. struct4101.BillCode = order.Number
  5694. struct4101.BillNo = order.SetlId
  5695. var resOther ResultSeventeenOther
  5696. var pp models.PublicParams
  5697. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5698. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5699. pp.FixmedinsName = miConfig.OrgName
  5700. pp.FixmedinsCode = miConfig.Code
  5701. pp.RequestUrl = miConfig.Url
  5702. pp.Cainfo = miConfig.Cainfo
  5703. pp.SecretKey = miConfig.SecretKey
  5704. pp.AccessKey = miConfig.AccessKey
  5705. pp.OpterName = curRoles.UserName
  5706. client := &http.Client{}
  5707. var req *http.Request
  5708. data := make(map[string]interface{})
  5709. data["struct4101"] = struct4101
  5710. data["pp"] = pp
  5711. bytesData, _ := json.Marshal(data)
  5712. if miConfig.MdtrtareaAdmvs == "320921" {
  5713. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5714. } else {
  5715. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5716. }
  5717. resp, _ := client.Do(req)
  5718. defer resp.Body.Close()
  5719. body, ioErr := ioutil.ReadAll(resp.Body)
  5720. if ioErr != nil {
  5721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5723. return
  5724. }
  5725. var respJSON map[string]interface{}
  5726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5732. userJSONBytes, _ := json.Marshal(respJSON)
  5733. fmt.Println("log")
  5734. fmt.Println(string(userJSONBytes))
  5735. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5736. utils.ErrorLog("解析失败:%v", err)
  5737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5738. return
  5739. }
  5740. res.InfRefmsgid = resOther.InfRefmsgid
  5741. res.Output = resOther.Output
  5742. res.ErrMsg = resOther.ErrMsg
  5743. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5744. res.Infcode = infocode
  5745. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5746. var pp models.PublicParams
  5747. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5748. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5749. pp.FixmedinsName = miConfig.OrgName
  5750. pp.FixmedinsCode = miConfig.Code
  5751. pp.RequestUrl = miConfig.Url
  5752. pp.Cainfo = miConfig.Cainfo
  5753. pp.SecretKey = miConfig.SecretKey
  5754. pp.AccessKey = miConfig.AccessKey
  5755. pp.OpterName = curRoles.UserName
  5756. result, _ := service.Jxyb4101(struct4101, pp)
  5757. var dat map[string]interface{}
  5758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5759. fmt.Println(dat)
  5760. } else {
  5761. fmt.Println(err)
  5762. }
  5763. userJSONBytes, _ := json.Marshal(dat)
  5764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5765. utils.ErrorLog("解析失败:%v", err)
  5766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5767. return
  5768. }
  5769. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5770. var pp models.PublicParams
  5771. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5772. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5773. pp.FixmedinsName = miConfig.OrgName
  5774. pp.FixmedinsCode = miConfig.Code
  5775. pp.RequestUrl = miConfig.Url
  5776. pp.Cainfo = miConfig.Cainfo
  5777. pp.SecretKey = miConfig.SecretKey
  5778. pp.AccessKey = miConfig.AccessKey
  5779. pp.OpterName = curRoles.UserName
  5780. result, _ := service.Hnyb4101(struct4101, pp)
  5781. var dat map[string]interface{}
  5782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5783. fmt.Println(dat)
  5784. } else {
  5785. fmt.Println(err)
  5786. }
  5787. userJSONBytes, _ := json.Marshal(dat)
  5788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5789. utils.ErrorLog("解析失败:%v", err)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. } else {
  5794. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5795. var dat map[string]interface{}
  5796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5797. fmt.Println(dat)
  5798. } else {
  5799. fmt.Println(err)
  5800. }
  5801. userJSONBytes, _ := json.Marshal(dat)
  5802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5803. utils.ErrorLog("解析失败:%v", err)
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. }
  5808. if res.Infcode != 0 {
  5809. c.ServeSuccessJSON(map[string]interface{}{
  5810. "failed_code": -10,
  5811. "msg": res.ErrMsg,
  5812. })
  5813. return
  5814. } else {
  5815. //order.FaPiaoNumber = zero
  5816. //order.FaPiaoCode = last_order.FaPiaoCode
  5817. //service.UpdateOrder(order)
  5818. hisFundSettleListResult := &models.HisFundSettleListResult{
  5819. Number: res.Output.SetlListId,
  5820. Status: 1,
  5821. Ctime: time.Now().Unix(),
  5822. Mtime: time.Now().Unix(),
  5823. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5824. IsUpload: 1,
  5825. OrderId: order_id,
  5826. }
  5827. service.CreateUploadRecord(hisFundSettleListResult)
  5828. c.ServeSuccessJSON(map[string]interface{}{
  5829. "msg": "上传成功",
  5830. "result": hisFundSettleListResult,
  5831. })
  5832. return
  5833. }
  5834. }
  5835. func (c *HisApiController) GetSettleListHospital() {
  5836. order_id, _ := c.GetInt64("order_id")
  5837. admin_user_id, _ := c.GetInt64("admin_user_id")
  5838. order, _ := service.GetHisOrderByIDTwo(order_id)
  5839. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5840. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5841. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5842. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5843. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5845. if order.ID == 0 {
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5847. return
  5848. }
  5849. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5850. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5851. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5852. fmt.Println(count)
  5853. var zero string
  5854. number := count + 1
  5855. if number >= 1000 {
  5856. zero = "0000" + strconv.FormatInt(number, 10)
  5857. } else if number >= 10000 {
  5858. zero = "000" + strconv.FormatInt(number, 10)
  5859. } else if number >= 100000 {
  5860. zero = "00" + strconv.FormatInt(number, 10)
  5861. } else if number >= 1000000 {
  5862. zero = "0" + strconv.FormatInt(number, 10)
  5863. } else {
  5864. zero = strconv.FormatInt(number, 10)
  5865. }
  5866. fmt.Println(zero)
  5867. struct4101 := service.Struct4101{
  5868. PsnNo: order.PsnNo,
  5869. MdtrtId: order.MdtrtId,
  5870. SetlId: order.SetlId,
  5871. PsnName: order.PsnName,
  5872. Gend: order.Gend,
  5873. Brdy: his.Brdy,
  5874. Age: int64(order.Age),
  5875. Naty: order.Naty,
  5876. PatnCertType: "01",
  5877. Certno: order.Certno,
  5878. Prfs: "90",
  5879. ConerName: roles[0].UserName,
  5880. PatnRlts: "99",
  5881. ConerAddr: miConfig.OrgName,
  5882. ConerTel: admin.Mobile,
  5883. HiType: order.Insutype,
  5884. Insuplc: miConfig.InsuplcAdmdvs,
  5885. MaindiagFlag: "1",
  5886. BillCode: order.SetlId,
  5887. BillNo: order.SetlId,
  5888. BizSn: order.Number,
  5889. PsnSelfPay: order.PsnPartAmt,
  5890. PsnOwnPay: order.PsnPartAmt,
  5891. AcctPay: order.AcctPay,
  5892. PsnCashpay: order.PsnCashPay,
  5893. HiPaymtd: "1",
  5894. Hsorg: miConfig.InsuplcAdmdvs,
  5895. HsorgOpter: miConfig.InsuplcAdmdvs,
  5896. MedinsFillPsn: curRoles.UserName,
  5897. MedinsFillDept: depart.Name,
  5898. IptMedType: "2",
  5899. AdmTime: his.InHosptialTime,
  5900. AdmEndTime: his.OutHosptialTime,
  5901. }
  5902. struct4101.SetlBegnDate = order.SetlTime
  5903. struct4101.SetlEndDate = order.SetlTime
  5904. var rf []CustomFundPay
  5905. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5906. var tempFunPays []service.CustomStruct
  5907. for _, item := range rf {
  5908. var tempFunPay service.CustomStruct
  5909. tempFunPay.FundPayamt = item.FundPayamt
  5910. tempFunPay.FundPayType = item.FundPayType
  5911. tempFunPays = append(tempFunPays, tempFunPay)
  5912. }
  5913. struct4101.CustomStruct = tempFunPays
  5914. var tempDiaginfos []service.DiaginfoStructTwo
  5915. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5916. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5917. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5918. var config []*models.HisXtDiagnoseConfig
  5919. for _, item := range diagnosis_ids {
  5920. id, _ := strconv.ParseInt(item, 10, 64)
  5921. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5922. config = append(config, &diagnosisConfig)
  5923. }
  5924. for index, item := range config {
  5925. if index == 0 {
  5926. var tempDiaginfo service.DiaginfoStructTwo
  5927. tempDiaginfo.DiagCode = item.CountryCode
  5928. tempDiaginfo.DiagName = item.CountryContentName
  5929. tempDiaginfo.DiagType = "1"
  5930. tempDiaginfo.MaindiagFlag = "1"
  5931. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5932. } else {
  5933. var tempDiaginfo service.DiaginfoStructTwo
  5934. tempDiaginfo.DiagCode = item.CountryCode
  5935. tempDiaginfo.DiagName = item.CountryContentName
  5936. tempDiaginfo.DiagType = "2"
  5937. tempDiaginfo.MaindiagFlag = "0"
  5938. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5939. }
  5940. }
  5941. struct4101.Diseinfo = tempDiaginfos
  5942. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5943. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5944. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5945. tempOpspdiseinfo2.OprnOprtCode = ""
  5946. tempOpspdiseinfo2.OprnOprtName = ""
  5947. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5948. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5949. var iteminfo service.IteminfoStruct
  5950. var bedCostTotal float64 = 0 //床位总费
  5951. var bedCostSelfTotal float64 = 0 //床位自费
  5952. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5953. var operationCostTotal float64 = 0 //手术费
  5954. var operationCostSelfTotal float64 = 0 //手术费
  5955. var operationCostPartSelfTotal float64 = 0 //手术费
  5956. var otherCostTotal float64 = 0 //其他费用
  5957. var otherCostSelfTotal float64 = 0 //其他费用
  5958. var otherCostPartSelfTotal float64 = 0 //其他费用
  5959. var materialCostTotal float64 = 0 //材料费
  5960. var materialCostSelfTotal float64 = 0 //材料费
  5961. var materialCostPartSelfTotal float64 = 0 //材料费
  5962. var westernMedicineCostTotal float64 = 0 //西药费
  5963. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5964. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5965. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5966. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5967. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5968. var checkCostTotal float64 = 0 //检查费
  5969. var checkCostSelfTotal float64 = 0 //检查费
  5970. var checkCostPartSelfTotal float64 = 0 //检查费
  5971. var laboratoryCostTotal float64 = 0 //化验费
  5972. var laboratoryCostSelfTotal float64 = 0 //化验费
  5973. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5974. var treatCostTotal float64 = 0 //治疗费用
  5975. var treatCostSelfTotal float64 = 0 //治疗费用
  5976. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5977. decimal.DivisionPrecision = 2
  5978. var bed_fulamt_ownpay_amt float64 = 0
  5979. var operation_fulamt_ownpay_amt float64 = 0
  5980. var other_fulamt_ownpay_amt float64 = 0
  5981. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5982. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5983. var check_fulamt_ownpay_amt float64 = 0
  5984. var material_fulamt_ownpay_amt float64 = 0
  5985. var laboratory_fulamt_ownpay_amt float64 = 0
  5986. var treat_fulamt_ownpay_amt float64 = 0
  5987. var bed_claa_sunmfee float64 = 0
  5988. var bed_clab_amt float64 = 0
  5989. var bed_other_amt float64 = 0
  5990. var operation_claa_sunmfee float64 = 0
  5991. var operation_clab_amt float64 = 0
  5992. var operation_other_amt float64 = 0
  5993. var other_claa_sunmfee float64 = 0
  5994. var other_clab_amt float64 = 0
  5995. var other_other_amt float64 = 0
  5996. var westernMedicine_claa_sunmfee float64 = 0
  5997. var westernMedicine_clab_amt float64 = 0
  5998. var westernMedicine_other_amt float64 = 0
  5999. var chineseTraditional_claa_sunmfee float64 = 0
  6000. var chineseTraditional_clab_amt float64 = 0
  6001. var chineseTraditional_other_amt float64 = 0
  6002. var check_claa_sunmfee float64 = 0
  6003. var check_clab_amt float64 = 0
  6004. var check_other_amt float64 = 0
  6005. var material_claa_sunmfee float64 = 0
  6006. var material_clab_amt float64 = 0
  6007. var material_other_amt float64 = 0
  6008. var laboratory_claa_sunmfee float64 = 0
  6009. var laboratory_clab_amt float64 = 0
  6010. var laboratory_other_amt float64 = 0
  6011. var treat_claa_sunmfee float64 = 0
  6012. var treat_clab_amt float64 = 0
  6013. var treat_other_amt float64 = 0
  6014. for _, item := range order.HisOrderInfo {
  6015. if item.MedChrgitmType == "01" { //床位费
  6016. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6017. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6018. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6019. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6020. if item.ChrgitmLv == "1" {
  6021. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6022. }
  6023. if item.ChrgitmLv == "2" {
  6024. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6025. }
  6026. if item.ChrgitmLv == "3" {
  6027. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6028. }
  6029. }
  6030. if item.MedChrgitmType == "03" { //检查费
  6031. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6032. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6033. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6034. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6035. if item.ChrgitmLv == "1" {
  6036. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6037. }
  6038. if item.ChrgitmLv == "2" {
  6039. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6040. }
  6041. if item.ChrgitmLv == "3" {
  6042. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6043. }
  6044. }
  6045. if item.MedChrgitmType == "04" { //化验费
  6046. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6047. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6048. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6049. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6050. if item.ChrgitmLv == "1" {
  6051. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6052. }
  6053. if item.ChrgitmLv == "2" {
  6054. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6055. }
  6056. if item.ChrgitmLv == "3" {
  6057. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6058. }
  6059. }
  6060. if item.MedChrgitmType == "05" { //治疗费
  6061. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6062. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6063. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6064. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6065. if item.ChrgitmLv == "1" {
  6066. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6067. }
  6068. if item.ChrgitmLv == "2" {
  6069. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6070. }
  6071. if item.ChrgitmLv == "3" {
  6072. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6073. }
  6074. }
  6075. if item.MedChrgitmType == "06" { //手术费
  6076. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6077. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6078. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6079. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6080. if item.ChrgitmLv == "1" {
  6081. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6082. }
  6083. if item.ChrgitmLv == "2" {
  6084. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6085. }
  6086. if item.ChrgitmLv == "3" {
  6087. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6088. }
  6089. }
  6090. if item.MedChrgitmType == "08" { //材料费
  6091. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6092. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6093. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6094. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6095. if item.ChrgitmLv == "1" {
  6096. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6097. }
  6098. if item.ChrgitmLv == "2" {
  6099. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6100. }
  6101. if item.ChrgitmLv == "3" {
  6102. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6103. }
  6104. }
  6105. if item.MedChrgitmType == "09" { //西药费
  6106. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6107. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6108. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6109. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6110. if item.ChrgitmLv == "1" {
  6111. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6112. }
  6113. if item.ChrgitmLv == "2" {
  6114. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6115. }
  6116. if item.ChrgitmLv == "3" {
  6117. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6118. }
  6119. }
  6120. if item.MedChrgitmType == "11" { //中成费
  6121. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6122. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6123. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6124. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6125. if item.ChrgitmLv == "1" {
  6126. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6127. }
  6128. if item.ChrgitmLv == "2" {
  6129. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6130. }
  6131. if item.ChrgitmLv == "3" {
  6132. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6133. }
  6134. }
  6135. if item.MedChrgitmType == "14" { //其他费
  6136. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6137. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6138. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6139. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6140. if item.ChrgitmLv == "1" {
  6141. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6142. }
  6143. if item.ChrgitmLv == "2" {
  6144. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6145. }
  6146. if item.ChrgitmLv == "3" {
  6147. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6148. }
  6149. }
  6150. }
  6151. var iteminfoStructs []service.IteminfoStruct
  6152. if bedCostTotal != 0 {
  6153. iteminfo.MedChrgitm = "01"
  6154. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6155. iteminfo.Amt = bedCostTotal
  6156. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6157. iteminfo.ClabAmt = bed_clab_amt
  6158. iteminfo.OthAmt = bed_other_amt
  6159. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6160. }
  6161. if checkCostTotal != 0 {
  6162. iteminfo.MedChrgitm = "03"
  6163. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6164. iteminfo.Amt = checkCostTotal
  6165. iteminfo.ClaaSumfee = check_claa_sunmfee
  6166. iteminfo.ClabAmt = check_clab_amt
  6167. iteminfo.OthAmt = check_other_amt
  6168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6169. }
  6170. if laboratoryCostTotal != 0 {
  6171. iteminfo.MedChrgitm = "04"
  6172. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6173. iteminfo.Amt = laboratoryCostTotal
  6174. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6175. iteminfo.ClabAmt = laboratory_clab_amt
  6176. iteminfo.OthAmt = laboratory_other_amt
  6177. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6178. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6179. }
  6180. if treatCostTotal != 0 {
  6181. iteminfo.MedChrgitm = "05"
  6182. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6183. iteminfo.Amt = treatCostTotal
  6184. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6185. iteminfo.ClabAmt = treat_clab_amt
  6186. iteminfo.OthAmt = treat_other_amt
  6187. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6188. //(struct4101.IteminfoStruct, iteminfo)
  6189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6190. }
  6191. if operationCostTotal != 0 {
  6192. iteminfo.MedChrgitm = "06"
  6193. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6194. iteminfo.Amt = operationCostTotal
  6195. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6196. iteminfo.ClabAmt = operation_clab_amt
  6197. iteminfo.OthAmt = operation_other_amt
  6198. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6199. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6200. }
  6201. if materialCostTotal != 0 {
  6202. iteminfo.MedChrgitm = "08"
  6203. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6204. iteminfo.Amt = materialCostTotal
  6205. iteminfo.ClaaSumfee = material_claa_sunmfee
  6206. iteminfo.ClabAmt = material_clab_amt
  6207. iteminfo.OthAmt = material_other_amt
  6208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6210. }
  6211. if westernMedicineCostTotal != 0 {
  6212. iteminfo.MedChrgitm = "09"
  6213. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6214. iteminfo.Amt = westernMedicineCostTotal
  6215. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6216. iteminfo.ClabAmt = westernMedicine_clab_amt
  6217. iteminfo.OthAmt = westernMedicine_other_amt
  6218. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6219. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6220. }
  6221. if chineseTraditionalMedicineCostTotal != 0 {
  6222. iteminfo.MedChrgitm = "11"
  6223. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6224. iteminfo.Amt = westernMedicineCostTotal
  6225. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6226. iteminfo.ClabAmt = westernMedicine_clab_amt
  6227. iteminfo.OthAmt = westernMedicine_other_amt
  6228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6230. }
  6231. if otherCostTotal != 0 {
  6232. iteminfo.MedChrgitm = "14"
  6233. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6234. iteminfo.Amt = otherCostTotal
  6235. iteminfo.ClaaSumfee = other_claa_sunmfee
  6236. iteminfo.ClabAmt = other_clab_amt
  6237. iteminfo.OthAmt = other_other_amt
  6238. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6240. }
  6241. struct4101.IteminfoStruct = iteminfoStructs
  6242. struct4101.Ntly = "中国"
  6243. struct4101.AdmCaty = "A03.06"
  6244. var resOther ResultSeventeenOther
  6245. var res ResultSeventeen
  6246. if miConfig.MdtrtareaAdmvs == "150499" {
  6247. var pp models.PublicParams
  6248. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6249. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6250. pp.FixmedinsName = miConfig.OrgName
  6251. pp.FixmedinsCode = miConfig.Code
  6252. pp.RequestUrl = miConfig.Url
  6253. pp.Cainfo = miConfig.Cainfo
  6254. pp.SecretKey = miConfig.SecretKey
  6255. pp.AccessKey = miConfig.AccessKey
  6256. pp.OpterName = curRoles.UserName
  6257. client := &http.Client{}
  6258. var req *http.Request
  6259. data := make(map[string]interface{})
  6260. data["struct4101"] = struct4101
  6261. data["pp"] = pp
  6262. bytesData, _ := json.Marshal(data)
  6263. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  6264. resp, _ := client.Do(req)
  6265. defer resp.Body.Close()
  6266. body, ioErr := ioutil.ReadAll(resp.Body)
  6267. if ioErr != nil {
  6268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6270. return
  6271. }
  6272. var respJSON map[string]interface{}
  6273. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6276. return
  6277. }
  6278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6279. userJSONBytes, _ := json.Marshal(respJSON)
  6280. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6281. utils.ErrorLog("解析失败:%v", err)
  6282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6283. return
  6284. }
  6285. res.InfRefmsgid = resOther.InfRefmsgid
  6286. res.Output = resOther.Output
  6287. res.ErrMsg = resOther.ErrMsg
  6288. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6289. res.Infcode = infocode
  6290. } else {
  6291. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6292. var dat map[string]interface{}
  6293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6294. fmt.Println(dat)
  6295. } else {
  6296. fmt.Println(err)
  6297. }
  6298. userJSONBytes, _ := json.Marshal(dat)
  6299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6300. utils.ErrorLog("解析失败:%v", err)
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. return
  6303. }
  6304. }
  6305. if res.Infcode != 0 {
  6306. c.ServeSuccessJSON(map[string]interface{}{
  6307. "failed_code": -10,
  6308. "msg": res.ErrMsg,
  6309. })
  6310. return
  6311. } else {
  6312. if miConfig.MdtrtareaAdmvs != "150499" {
  6313. order.FaPiaoNumber = zero
  6314. order.FaPiaoCode = last_order.FaPiaoCode
  6315. service.UpdateOrder(order)
  6316. }
  6317. hisFundSettleListResult := &models.HisFundSettleListResult{
  6318. Number: res.Output.SetlListId,
  6319. Status: 1,
  6320. Ctime: time.Now().Unix(),
  6321. Mtime: time.Now().Unix(),
  6322. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6323. IsUpload: 1,
  6324. OrderId: order_id,
  6325. }
  6326. service.CreateUploadRecord(hisFundSettleListResult)
  6327. c.ServeSuccessJSON(map[string]interface{}{
  6328. "msg": "上传成功",
  6329. "result": hisFundSettleListResult,
  6330. })
  6331. return
  6332. }
  6333. }
  6334. //func (c *HisApiController) GetBatchSettleList() {
  6335. // orders, _ := service.GetAllHisOrder(10106)
  6336. // for _, item := range orders {
  6337. // order_id := item.ID
  6338. // order, _ := service.GetHisOrderByIDTwo(order_id)
  6339. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6340. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6341. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6342. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  6343. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6344. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6345. //
  6346. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6347. //
  6348. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6349. //
  6350. // if order.ID == 0 {
  6351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6352. // return
  6353. // }
  6354. // if his.BalanceAccountsType == 2 {
  6355. // continue
  6356. // }
  6357. // struct4101 := service.Struct4101{
  6358. // PsnNo: order.PsnNo,
  6359. // MdtrtId: order.MdtrtId,
  6360. // SetlId: order.SetlId,
  6361. // PsnName: order.PsnName,
  6362. // Gend: order.Gend,
  6363. // Brdy: his.Brdy,
  6364. // Age: his.Age,
  6365. // Naty: order.Naty,
  6366. // PatnCertType: "01",
  6367. // Certno: order.Certno,
  6368. // Prfs: "90",
  6369. // ConerName: roles[0].UserName,
  6370. // PatnRlts: "99",
  6371. // ConerAddr: miConfig.OrgName,
  6372. // ConerTel: admin.Mobile,
  6373. // HiType: order.Insutype,
  6374. // Insuplc: his.InsuplcAdmdvs,
  6375. // MaindiagFlag: "1",
  6376. // BillCode: order.SetlId,
  6377. // BillNo: order.SetlId,
  6378. // BizSn: order.Number,
  6379. // PsnSelfPay: order.PsnPartAmt,
  6380. // PsnOwnPay: order.PsnPartAmt,
  6381. // AcctPay: order.AcctPay,
  6382. // PsnCashpay: order.PsnCashPay,
  6383. // HiPaymtd: "1",
  6384. // Hsorg: his.InsuplcAdmdvs,
  6385. // HsorgOpter: his.InsuplcAdmdvs,
  6386. // MedinsFillPsn: curRoles.UserName,
  6387. // MedinsFillDept: depart.Name,
  6388. // IptMedType: "2",
  6389. // }
  6390. // struct4101.SetlBegnDate = order.SetlTime
  6391. // struct4101.SetlEndDate = order.SetlTime
  6392. // //if order.SettleType == 1 {
  6393. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  6394. // // dateStr := t.Format("2006-01-02")
  6395. // // struct4101.SetlBegnDate = dateStr
  6396. // // struct4101.SetlEndDate = dateStr
  6397. // //} else {
  6398. // // t := time.Unix(int64(order.SettleStartTime), 0)
  6399. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  6400. // // dateStartStr := t.Format("2006-01-02")
  6401. // // dateEndStr := t2.Format("2006-01-02")
  6402. // // struct4101.SetlBegnDate = dateStartStr
  6403. // // struct4101.SetlEndDate = dateEndStr
  6404. // //}
  6405. //
  6406. // var rf []CustomFundPay
  6407. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  6408. //
  6409. // var tempFunPays []service.CustomStruct
  6410. // var tempFunPay610100 service.CustomStruct
  6411. //
  6412. // for _, item := range rf {
  6413. // if item.FundPayType == "610100" {
  6414. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  6415. // tempFunPay610100.FundPayType = item.FundPayType
  6416. // } else {
  6417. // var tempFunPay service.CustomStruct
  6418. // tempFunPay.FundPayamt = item.FundPayamt
  6419. // tempFunPay.FundPayType = item.FundPayType
  6420. // tempFunPays = append(tempFunPays, tempFunPay)
  6421. // }
  6422. // }
  6423. // tempFunPays = append(tempFunPays, tempFunPay610100)
  6424. // struct4101.CustomStruct = tempFunPays
  6425. //
  6426. // var tempDiaginfos []service.DiaginfoStructTwo
  6427. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6428. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6429. //
  6430. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6431. // var config []*models.HisXtDiagnoseConfig
  6432. // for _, item := range diagnosis_ids {
  6433. // id, _ := strconv.ParseInt(item, 10, 64)
  6434. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6435. // config = append(config, &diagnosisConfig)
  6436. // }
  6437. //
  6438. // for index, item := range config {
  6439. // if index == 0 {
  6440. // var tempDiaginfo service.DiaginfoStructTwo
  6441. // tempDiaginfo.DiagCode = item.CountryCode
  6442. // tempDiaginfo.DiagName = item.CountryContentName
  6443. // tempDiaginfo.DiagType = "1"
  6444. // tempDiaginfo.MaindiagFlag = "1"
  6445. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6446. // } else {
  6447. //
  6448. // var tempDiaginfo service.DiaginfoStructTwo
  6449. // tempDiaginfo.DiagCode = item.CountryCode
  6450. // tempDiaginfo.DiagName = item.CountryContentName
  6451. // tempDiaginfo.DiagType = "2"
  6452. // tempDiaginfo.MaindiagFlag = "0"
  6453. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6454. // }
  6455. // }
  6456. // struct4101.Diseinfo = tempDiaginfos
  6457. //
  6458. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  6459. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6460. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6461. // tempOpspdiseinfo2.OprnOprtCode = ""
  6462. // tempOpspdiseinfo2.OprnOprtName = ""
  6463. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6464. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6465. //
  6466. // var iteminfo service.IteminfoStruct
  6467. //
  6468. // var bedCostTotal float64 = 0 //床位总费
  6469. // var bedCostSelfTotal float64 = 0 //床位自费
  6470. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6471. //
  6472. // var examineCostTotal float64 = 0 //诊查总费
  6473. // var examineCostSelfTotal float64 = 0 //诊查自费
  6474. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  6475. //
  6476. // var nursingCostTotal float64 = 0 //护理总费
  6477. // var nursingCostSelfTotal float64 = 0 //护理自费
  6478. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  6479. //
  6480. // var chineseMedicineCostTotal float64 = 0 //中成药
  6481. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  6482. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  6483. //
  6484. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  6485. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  6486. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  6487. //
  6488. // var registerCostTotal float64 = 0 //一般诊疗费
  6489. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  6490. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  6491. //
  6492. // var operationCostTotal float64 = 0 //手术费
  6493. // var operationCostSelfTotal float64 = 0 //手术费
  6494. // var operationCostPartSelfTotal float64 = 0 //手术费
  6495. //
  6496. // var otherCostTotal float64 = 0 //其他费用
  6497. // var otherCostSelfTotal float64 = 0 //其他费用
  6498. // var otherCostPartSelfTotal float64 = 0 //其他费用
  6499. //
  6500. // var materialCostTotal float64 = 0 //材料费
  6501. // var materialCostSelfTotal float64 = 0 //材料费
  6502. // var materialCostPartSelfTotal float64 = 0 //材料费
  6503. //
  6504. // var westernMedicineCostTotal float64 = 0 //西药费
  6505. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  6506. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6507. //
  6508. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6509. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6510. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6511. //
  6512. // var checkCostTotal float64 = 0 //检查费
  6513. // var checkCostSelfTotal float64 = 0 //检查费
  6514. // var checkCostPartSelfTotal float64 = 0 //检查费
  6515. //
  6516. // var laboratoryCostTotal float64 = 0 //化验费
  6517. // var laboratoryCostSelfTotal float64 = 0 //化验费
  6518. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6519. //
  6520. // var treatCostTotal float64 = 0 //治疗费用
  6521. // var treatCostSelfTotal float64 = 0 //治疗费用
  6522. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6523. //
  6524. // decimal.DivisionPrecision = 2
  6525. //
  6526. // var bed_fulamt_ownpay_amt float64 = 0
  6527. //
  6528. // var examine_fulamt_ownpay_amt float64 = 0
  6529. //
  6530. // var nursing_fulamt_ownpay_amt float64 = 0
  6531. //
  6532. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6533. //
  6534. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6535. //
  6536. // var register_fulamt_ownpay_amt float64 = 0
  6537. //
  6538. // var operation_fulamt_ownpay_amt float64 = 0
  6539. // var other_fulamt_ownpay_amt float64 = 0
  6540. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6541. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6542. // var check_fulamt_ownpay_amt float64 = 0
  6543. // var material_fulamt_ownpay_amt float64 = 0
  6544. // var laboratory_fulamt_ownpay_amt float64 = 0
  6545. // var treat_fulamt_ownpay_amt float64 = 0
  6546. //
  6547. // var bed_claa_sunmfee float64 = 0
  6548. // var bed_clab_amt float64 = 0
  6549. // var bed_other_amt float64 = 0
  6550. //
  6551. // var examine_claa_sunmfee float64 = 0
  6552. // var examine_clab_amt float64 = 0
  6553. // var examine_other_amt float64 = 0
  6554. //
  6555. // var nursing_claa_sunmfee float64 = 0
  6556. // var nursing_clab_amt float64 = 0
  6557. // var nursing_other_amt float64 = 0
  6558. //
  6559. // var chinese_medicine_claa_sunmfee float64 = 0
  6560. // var chinese_medicine_clab_amt float64 = 0
  6561. // var chinese_medicine_other_amt float64 = 0
  6562. //
  6563. // var commonly_treatment_claa_sunmfee float64 = 0
  6564. // var commonly_treatment_clab_amt float64 = 0
  6565. // var commonly_treatment_other_amt float64 = 0
  6566. //
  6567. // var operation_claa_sunmfee float64 = 0
  6568. // var operation_clab_amt float64 = 0
  6569. // var operation_other_amt float64 = 0
  6570. //
  6571. // var other_claa_sunmfee float64 = 0
  6572. // var other_clab_amt float64 = 0
  6573. // var other_other_amt float64 = 0
  6574. //
  6575. // var westernMedicine_claa_sunmfee float64 = 0
  6576. // var westernMedicine_clab_amt float64 = 0
  6577. // var westernMedicine_other_amt float64 = 0
  6578. //
  6579. // var chineseTraditional_claa_sunmfee float64 = 0
  6580. // var chineseTraditional_clab_amt float64 = 0
  6581. // var chineseTraditional_other_amt float64 = 0
  6582. //
  6583. // var check_claa_sunmfee float64 = 0
  6584. // var check_clab_amt float64 = 0
  6585. // var check_other_amt float64 = 0
  6586. //
  6587. // var material_claa_sunmfee float64 = 0
  6588. // var material_clab_amt float64 = 0
  6589. // var material_other_amt float64 = 0
  6590. //
  6591. // var laboratory_claa_sunmfee float64 = 0
  6592. // var laboratory_clab_amt float64 = 0
  6593. // var laboratory_other_amt float64 = 0
  6594. //
  6595. // var treat_claa_sunmfee float64 = 0
  6596. // var treat_clab_amt float64 = 0
  6597. // var treat_other_amt float64 = 0
  6598. //
  6599. // var register_claa_sunmfee float64 = 0
  6600. // var register_clab_amt float64 = 0
  6601. // var register_other_amt float64 = 0
  6602. //
  6603. // for _, item := range order.HisOrderInfo {
  6604. // if item.MedChrgitmType == "01" { //床位费
  6605. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6606. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6607. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6608. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6609. // if item.ChrgitmLv == "1" {
  6610. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6611. // }
  6612. // if item.ChrgitmLv == "2" {
  6613. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6614. //
  6615. // }
  6616. // if item.ChrgitmLv == "3" {
  6617. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6618. // }
  6619. //
  6620. // }
  6621. //
  6622. // if item.MedChrgitmType == "02" { //诊查
  6623. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6624. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6625. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6626. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6627. // if item.ChrgitmLv == "1" {
  6628. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6629. // }
  6630. // if item.ChrgitmLv == "2" {
  6631. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6632. //
  6633. // }
  6634. // if item.ChrgitmLv == "3" {
  6635. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6636. // }
  6637. //
  6638. // }
  6639. //
  6640. // if item.MedChrgitmType == "03" { //检查费
  6641. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6642. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6643. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6644. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6645. // if item.ChrgitmLv == "1" {
  6646. //
  6647. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6648. //
  6649. // }
  6650. // if item.ChrgitmLv == "2" {
  6651. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6652. //
  6653. // }
  6654. // if item.ChrgitmLv == "3" {
  6655. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6656. // }
  6657. // }
  6658. //
  6659. // if item.MedChrgitmType == "04" { //化验费
  6660. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6661. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6662. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6663. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6664. // if item.ChrgitmLv == "1" {
  6665. //
  6666. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6667. //
  6668. // }
  6669. // if item.ChrgitmLv == "2" {
  6670. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6671. //
  6672. // }
  6673. // if item.ChrgitmLv == "3" {
  6674. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6675. // }
  6676. // }
  6677. //
  6678. // if item.MedChrgitmType == "05" { //治疗费
  6679. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6680. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6681. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6682. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6683. // if item.ChrgitmLv == "1" {
  6684. //
  6685. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6686. //
  6687. // }
  6688. // if item.ChrgitmLv == "2" {
  6689. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6690. //
  6691. // }
  6692. // if item.ChrgitmLv == "3" {
  6693. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6694. // }
  6695. // }
  6696. //
  6697. // if item.MedChrgitmType == "06" { //手术费
  6698. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6699. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6700. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6701. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6702. //
  6703. // if item.ChrgitmLv == "1" {
  6704. //
  6705. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6706. //
  6707. // }
  6708. // if item.ChrgitmLv == "2" {
  6709. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6710. //
  6711. // }
  6712. // if item.ChrgitmLv == "3" {
  6713. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6714. // }
  6715. // }
  6716. //
  6717. // if item.MedChrgitmType == "07" { //手术费
  6718. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6719. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6720. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6721. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6722. //
  6723. // if item.ChrgitmLv == "1" {
  6724. //
  6725. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6726. //
  6727. // }
  6728. // if item.ChrgitmLv == "2" {
  6729. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6730. //
  6731. // }
  6732. // if item.ChrgitmLv == "3" {
  6733. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6734. // }
  6735. // }
  6736. //
  6737. // if item.MedChrgitmType == "08" { //材料费
  6738. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6739. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6740. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6741. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6742. // if item.ChrgitmLv == "1" {
  6743. //
  6744. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6745. //
  6746. // }
  6747. // if item.ChrgitmLv == "2" {
  6748. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6749. //
  6750. // }
  6751. // if item.ChrgitmLv == "3" {
  6752. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6753. // }
  6754. // }
  6755. // if item.MedChrgitmType == "09" { //西药费
  6756. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6757. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6758. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6759. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6760. // if item.ChrgitmLv == "1" {
  6761. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6762. // }
  6763. // if item.ChrgitmLv == "2" {
  6764. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6765. // }
  6766. // if item.ChrgitmLv == "3" {
  6767. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6768. // }
  6769. // }
  6770. // if item.MedChrgitmType == "10" { //中药饮片
  6771. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6772. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6773. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6774. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6775. // if item.ChrgitmLv == "1" {
  6776. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6777. // }
  6778. // if item.ChrgitmLv == "2" {
  6779. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6780. // }
  6781. // if item.ChrgitmLv == "3" {
  6782. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6783. // }
  6784. // }
  6785. //
  6786. // if item.MedChrgitmType == "11" { //中成费
  6787. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6788. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6789. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6790. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6791. // if item.ChrgitmLv == "1" {
  6792. //
  6793. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6794. //
  6795. // }
  6796. // if item.ChrgitmLv == "2" {
  6797. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6798. //
  6799. // }
  6800. // if item.ChrgitmLv == "3" {
  6801. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6802. // }
  6803. // }
  6804. //
  6805. // if item.MedChrgitmType == "12" { //中成费
  6806. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6807. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6808. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6809. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6810. // if item.ChrgitmLv == "1" {
  6811. //
  6812. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6813. //
  6814. // }
  6815. // if item.ChrgitmLv == "2" {
  6816. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6817. //
  6818. // }
  6819. // if item.ChrgitmLv == "3" {
  6820. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6821. // }
  6822. // }
  6823. //
  6824. // if item.MedChrgitmType == "13" { //中成费
  6825. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6826. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6827. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6828. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6829. // if item.ChrgitmLv == "1" {
  6830. //
  6831. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6832. //
  6833. // }
  6834. // if item.ChrgitmLv == "2" {
  6835. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6836. //
  6837. // }
  6838. // if item.ChrgitmLv == "3" {
  6839. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6840. // }
  6841. // }
  6842. //
  6843. // if item.MedChrgitmType == "14" { //其他费
  6844. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6845. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6846. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6847. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6848. // if item.ChrgitmLv == "1" {
  6849. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6850. //
  6851. // }
  6852. // if item.ChrgitmLv == "2" {
  6853. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6854. //
  6855. // }
  6856. // if item.ChrgitmLv == "3" {
  6857. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6858. // }
  6859. // }
  6860. //
  6861. // }
  6862. //
  6863. // var iteminfoStructs []service.IteminfoStruct
  6864. //
  6865. // if bedCostTotal != 0 {
  6866. // iteminfo.MedChrgitm = "01"
  6867. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6868. // iteminfo.Amt = bedCostTotal
  6869. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  6870. // iteminfo.ClabAmt = bed_clab_amt
  6871. // iteminfo.OthAmt = bed_other_amt
  6872. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6873. // }
  6874. //
  6875. // if examineCostTotal != 0 {
  6876. // iteminfo.MedChrgitm = "02"
  6877. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  6878. // iteminfo.Amt = examineCostTotal
  6879. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  6880. // iteminfo.ClabAmt = examine_clab_amt
  6881. // iteminfo.OthAmt = examine_other_amt
  6882. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6883. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6884. // }
  6885. //
  6886. // if checkCostTotal != 0 {
  6887. // iteminfo.MedChrgitm = "03"
  6888. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6889. // iteminfo.Amt = checkCostTotal
  6890. // iteminfo.ClaaSumfee = check_claa_sunmfee
  6891. // iteminfo.ClabAmt = check_clab_amt
  6892. // iteminfo.OthAmt = check_other_amt
  6893. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6894. //
  6895. // }
  6896. //
  6897. // if laboratoryCostTotal != 0 {
  6898. // iteminfo.MedChrgitm = "04"
  6899. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6900. // iteminfo.Amt = laboratoryCostTotal
  6901. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6902. // iteminfo.ClabAmt = laboratory_clab_amt
  6903. // iteminfo.OthAmt = laboratory_other_amt
  6904. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6905. //
  6906. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6907. //
  6908. // }
  6909. //
  6910. // if treatCostTotal != 0 {
  6911. // iteminfo.MedChrgitm = "05"
  6912. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6913. // iteminfo.Amt = treatCostTotal
  6914. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  6915. // iteminfo.ClabAmt = treat_clab_amt
  6916. // iteminfo.OthAmt = treat_other_amt
  6917. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6918. // //(struct4101.IteminfoStruct, iteminfo)
  6919. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6920. // }
  6921. //
  6922. // if operationCostTotal != 0 {
  6923. // iteminfo.MedChrgitm = "06"
  6924. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6925. // iteminfo.Amt = operationCostTotal
  6926. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  6927. // iteminfo.ClabAmt = operation_clab_amt
  6928. // iteminfo.OthAmt = operation_other_amt
  6929. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6930. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6931. // }
  6932. //
  6933. // if nursingCostTotal != 0 {
  6934. // iteminfo.MedChrgitm = "07"
  6935. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  6936. // iteminfo.Amt = nursingCostTotal
  6937. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  6938. // iteminfo.ClabAmt = nursing_clab_amt
  6939. // iteminfo.OthAmt = nursing_other_amt
  6940. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6941. // }
  6942. //
  6943. // if materialCostTotal != 0 {
  6944. // iteminfo.MedChrgitm = "08"
  6945. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6946. // iteminfo.Amt = materialCostTotal
  6947. // iteminfo.ClaaSumfee = material_claa_sunmfee
  6948. // iteminfo.ClabAmt = material_clab_amt
  6949. // iteminfo.OthAmt = material_other_amt
  6950. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6951. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6952. // }
  6953. //
  6954. // if westernMedicineCostTotal != 0 {
  6955. // iteminfo.MedChrgitm = "09"
  6956. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6957. // iteminfo.Amt = westernMedicineCostTotal
  6958. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6959. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6960. // iteminfo.OthAmt = westernMedicine_other_amt
  6961. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6962. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6963. //
  6964. // }
  6965. //
  6966. // if chineseMedicineCostTotal != 0 {
  6967. // iteminfo.MedChrgitm = "10"
  6968. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6969. // iteminfo.Amt = chineseMedicineCostTotal
  6970. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6971. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  6972. // iteminfo.OthAmt = chinese_medicine_other_amt
  6973. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6974. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6975. //
  6976. // }
  6977. //
  6978. // if chineseTraditionalMedicineCostTotal != 0 {
  6979. // iteminfo.MedChrgitm = "11"
  6980. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6981. // iteminfo.Amt = westernMedicineCostTotal
  6982. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6983. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6984. // iteminfo.OthAmt = westernMedicine_other_amt
  6985. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6986. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6987. //
  6988. // }
  6989. //
  6990. // if commonlyTreatmentCostTotal != 0 {
  6991. // iteminfo.MedChrgitm = "12"
  6992. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6993. // iteminfo.Amt = commonlyTreatmentCostTotal
  6994. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6995. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  6996. // iteminfo.OthAmt = commonly_treatment_other_amt
  6997. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6998. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6999. //
  7000. // }
  7001. //
  7002. // if registerCostTotal != 0 {
  7003. // iteminfo.MedChrgitm = "13"
  7004. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  7005. // iteminfo.Amt = registerCostTotal
  7006. // iteminfo.ClaaSumfee = register_claa_sunmfee
  7007. // iteminfo.ClabAmt = register_clab_amt
  7008. // iteminfo.OthAmt = register_other_amt
  7009. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7010. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7011. //
  7012. // }
  7013. //
  7014. // if otherCostTotal != 0 {
  7015. // iteminfo.MedChrgitm = "14"
  7016. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7017. // iteminfo.Amt = otherCostTotal
  7018. // iteminfo.ClaaSumfee = other_claa_sunmfee
  7019. // iteminfo.ClabAmt = other_clab_amt
  7020. // iteminfo.OthAmt = other_other_amt
  7021. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7022. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7023. //
  7024. // }
  7025. // struct4101.IteminfoStruct = iteminfoStructs
  7026. // time_arr := strings.Split(order.SetlTime, " ")
  7027. // struct4101.AdmTime = time_arr[0]
  7028. // struct4101.AdmEndTime = time_arr[0]
  7029. //
  7030. // struct4101.DoctorName = doctor.UserName
  7031. // struct4101.DoctorCode = doctor.DoctorNumber
  7032. //
  7033. // struct4101.Ntly = "中国"
  7034. // struct4101.AdmCaty = "A03.06"
  7035. // var res ResultSeventeen
  7036. // if miConfig.MdtrtareaAdmvs == "421300" {
  7037. // data := make(map[string]interface{})
  7038. // data["struct4101"] = struct4101
  7039. // data["secret_key"] = miConfig.SecretKey
  7040. // data["org_name"] = miConfig.OrgName
  7041. // data["opera"] = curRoles.UserName
  7042. // data["code"] = miConfig.Code
  7043. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7044. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7045. //
  7046. // client := &http.Client{}
  7047. // bytesData, _ := json.Marshal(data)
  7048. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  7049. // resp, _ := client.Do(req)
  7050. // defer resp.Body.Close()
  7051. // body, ioErr := ioutil.ReadAll(resp.Body)
  7052. // if ioErr != nil {
  7053. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. // return
  7056. // }
  7057. // var respJSON map[string]interface{}
  7058. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7059. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. // return
  7062. // }
  7063. //
  7064. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7065. // userJSONBytes, _ := json.Marshal(respJSON)
  7066. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7067. // utils.ErrorLog("解析失败:%v", err)
  7068. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7069. // adminUser := c.GetAdminUserInfo()
  7070. // errlog := &models.HisOrderError{
  7071. // UserOrgId: adminUser.CurrentOrgId,
  7072. // Ctime: time.Now().Unix(),
  7073. // Mtime: time.Now().Unix(),
  7074. // ErrMsg: res.ErrMsg + "解析失败",
  7075. // Status: 1,
  7076. // PatientId: order_id,
  7077. // Stage: 10088,
  7078. // }
  7079. // service.CreateErrMsgLog(errlog)
  7080. // continue
  7081. // }
  7082. //
  7083. // } else {
  7084. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  7085. // fmt.Println(result)
  7086. //
  7087. // var dat map[string]interface{}
  7088. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7089. // fmt.Println(dat)
  7090. // } else {
  7091. // fmt.Println(err)
  7092. // }
  7093. // userJSONBytes, _ := json.Marshal(dat)
  7094. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7095. // utils.ErrorLog("解析失败:%v", err)
  7096. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. // adminUser := c.GetAdminUserInfo()
  7098. // errlog := &models.HisOrderError{
  7099. // UserOrgId: adminUser.CurrentOrgId,
  7100. // Ctime: time.Now().Unix(),
  7101. // Mtime: time.Now().Unix(),
  7102. // ErrMsg: res.ErrMsg + "解析失败",
  7103. // Status: 1,
  7104. // PatientId: order_id,
  7105. // Stage: 10106,
  7106. // }
  7107. // service.CreateErrMsgLog(errlog)
  7108. // continue
  7109. // }
  7110. // }
  7111. //
  7112. // if res.Infcode != 0 {
  7113. // adminUser := c.GetAdminUserInfo()
  7114. // errlog := &models.HisOrderError{
  7115. // UserOrgId: adminUser.CurrentOrgId,
  7116. // Ctime: time.Now().Unix(),
  7117. // Mtime: time.Now().Unix(),
  7118. // ErrMsg: res.ErrMsg,
  7119. // Status: 1,
  7120. // PatientId: order_id,
  7121. // Stage: 10106,
  7122. // }
  7123. // service.CreateErrMsgLog(errlog)
  7124. // continue
  7125. // } else {
  7126. // hisFundSettleListResult := &models.HisFundSettleListResult{
  7127. // Number: res.Output.SetlListId,
  7128. // Status: 1,
  7129. // Ctime: time.Now().Unix(),
  7130. // Mtime: time.Now().Unix(),
  7131. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7132. // IsUpload: 1,
  7133. // OrderId: order_id,
  7134. // }
  7135. // service.CreateUploadRecord(hisFundSettleListResult)
  7136. // continue
  7137. // }
  7138. // }
  7139. //}
  7140. func (c *HisApiController) GetOrgInfo() {
  7141. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  7142. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  7143. }
  7144. func (c *HisApiController) GetHisPatientInfo() {
  7145. medical_insurance_card := c.GetString("medical_insurance_card")
  7146. id_card_type, _ := c.GetInt64("id_card_type")
  7147. id_card := c.GetString("id_card")
  7148. adminInfo := c.GetAdminUserInfo()
  7149. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7150. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7151. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  7152. IdCardNo := ""
  7153. if id_card_type == 1 {
  7154. IdCardNo = medical_insurance_card
  7155. } else if id_card_type == 2 {
  7156. IdCardNo = id_card
  7157. }
  7158. if config.IsOpen == 1 {
  7159. 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
  7160. resp, requestErr := http.Get(api)
  7161. if requestErr != nil {
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. return
  7164. }
  7165. defer resp.Body.Close()
  7166. body, ioErr := ioutil.ReadAll(resp.Body)
  7167. if ioErr != nil {
  7168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7170. return
  7171. }
  7172. var respJSON map[string]interface{}
  7173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7179. userJSONBytes, _ := json.Marshal(userJSON)
  7180. var res ResultTwo
  7181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7182. utils.ErrorLog("解析失败:%v", err)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7187. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7188. infoStr := string(Iinfos)
  7189. idetinfoStr := string(Idetinfos)
  7190. if res.Infcode == 0 {
  7191. his := models.VMHisPatient{
  7192. Status: 1,
  7193. Ctime: time.Now().Unix(),
  7194. Mtime: time.Now().Unix(),
  7195. PsnNo: res.Output.Baseinfo.PsnNo,
  7196. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7197. Certno: res.Output.Baseinfo.Certno,
  7198. PsnName: res.Output.Baseinfo.PsnName,
  7199. Gend: res.Output.Baseinfo.Gend,
  7200. Naty: res.Output.Baseinfo.Naty,
  7201. Brdy: res.Output.Baseinfo.Brdy,
  7202. Age: res.Output.Baseinfo.Age,
  7203. Iinfo: infoStr,
  7204. Idetinfo: idetinfoStr,
  7205. UserOrgId: adminInfo.CurrentOrgId,
  7206. IsReturn: 1,
  7207. IdCardType: id_card_type,
  7208. }
  7209. c.ServeSuccessJSON(map[string]interface{}{
  7210. "info": his,
  7211. })
  7212. } else {
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7214. return
  7215. }
  7216. }
  7217. }
  7218. //func GetBasBaseInfo() (jsonStr string, err error) {
  7219. //
  7220. // handle := syscall.NewLazyDLL("SSCard.dll")
  7221. // add := handle.NewProc("ReadCardBas")
  7222. // str := make([]byte, 1024)
  7223. // str1 := make([]byte, 1024)
  7224. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7225. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  7226. //
  7227. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  7228. //
  7229. // fmt.Println("> Add(4,5)的结果为:", ret)
  7230. // handle.Release()
  7231. //
  7232. // return "", nil
  7233. //
  7234. //}
  7235. //func GetQRBaseInfo() (jsonStr string, err error) {
  7236. // handle := syscall.LoadDLL("SSCard.dll")
  7237. // ReadCardBas := handle.FindProc("GetQRBase")
  7238. //
  7239. // str := make([]byte, 256)
  7240. // str1 := make([]byte, 256)
  7241. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7242. //
  7243. // fmt.Println(string(str))
  7244. // fmt.Println(r)
  7245. // return string(str), nil
  7246. //}
  7247. //func CardInit() int {
  7248. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  7249. // add := DllTestDef.MustFindProc("Init")
  7250. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7251. // if err != nil {
  7252. // fmt.Println("SSCard的运算结果为:", ret)
  7253. // }
  7254. // result := int(ret)
  7255. // return result
  7256. //}
  7257. //func CardInit() int {
  7258. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7259. // if err != nil {
  7260. // fmt.Println("SSCard的运算结果为:", ret)
  7261. // }
  7262. // fmt.Println(err)
  7263. // result := int(ret)
  7264. // return result
  7265. //}
  7266. func IntPtr(n int) uintptr {
  7267. return uintptr(n)
  7268. }
  7269. func StrPtr(s string) uintptr {
  7270. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  7271. }
  7272. type Result2001 struct {
  7273. Cainfo interface{} `json:"cainfo"`
  7274. ErrMsg string `json:"err_msg"`
  7275. InfRefmsgid string `json:"inf_refmsgid"`
  7276. Infcode int64 `json:"infcode"`
  7277. Output struct {
  7278. Trtinfo struct {
  7279. PsnNo string `json:"psn_no"`
  7280. TrtChkType string `json:"trt_chk_type"`
  7281. FundPayType string `json:"fund_pay_type"`
  7282. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7283. Begndate string `json:"begndate"`
  7284. Enddate string `json:"enddate"`
  7285. TrtChkRslt string `json:"trt_chk_rslt"`
  7286. } `json:"trtinfo"`
  7287. } `json:"output"`
  7288. RefmsgTime string `json:"refmsg_time"`
  7289. RespondTime string `json:"respond_time"`
  7290. Signtype interface{} `json:"signtype"`
  7291. WarnMsg interface{} `json:"warn_msg"`
  7292. }
  7293. type Result2001Org10265 struct {
  7294. Cainfo interface{} `json:"cainfo"`
  7295. ErrMsg string `json:"err_msg"`
  7296. InfRefmsgid string `json:"inf_refmsgid"`
  7297. Infcode string `json:"infcode"`
  7298. Output struct {
  7299. Trtinfo struct {
  7300. PsnNo string `json:"psn_no"`
  7301. TrtChkType string `json:"trt_chk_type"`
  7302. FundPayType string `json:"fund_pay_type"`
  7303. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7304. Begndate string `json:"begndate"`
  7305. Enddate string `json:"enddate"`
  7306. TrtChkRslt string `json:"trt_chk_rslt"`
  7307. } `json:"trtinfo"`
  7308. } `json:"output"`
  7309. RefmsgTime string `json:"refmsg_time"`
  7310. RespondTime string `json:"respond_time"`
  7311. Signtype interface{} `json:"signtype"`
  7312. WarnMsg interface{} `json:"warn_msg"`
  7313. }
  7314. type ResultTwo struct {
  7315. ErrMsg string `json:"err_msg"`
  7316. InfRefmsgid string `json:"inf_refmsgid"`
  7317. Infcode int64 `json:"infcode"`
  7318. Output struct {
  7319. Baseinfo struct {
  7320. Age float64 `json:"age"`
  7321. Brdy string `json:"brdy"`
  7322. Certno string `json:"certno"`
  7323. Gend string `json:"gend"`
  7324. Naty string `json:"naty"`
  7325. PsnCertType string `json:"psn_cert_type"`
  7326. PsnName string `json:"psn_name"`
  7327. PsnNo string `json:"psn_no"`
  7328. } `json:"baseinfo"`
  7329. Idetinfo []interface{} `json:"idetinfo"`
  7330. Iinfo []struct {
  7331. Balc float64 `json:"balc"`
  7332. CvlservFlag string `json:"cvlserv_flag"`
  7333. EmpName string `json:"emp_name"`
  7334. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7335. Insutype string `json:"insutype"`
  7336. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7337. PausInsuDate string `json:"paus_insu_date"`
  7338. PsnInsuDate string `json:"psn_insu_date"`
  7339. PsnInsuStas string `json:"psn_insu_stas"`
  7340. PsnType string `json:"psn_type"`
  7341. } `json:"insuinfo"`
  7342. } `json:"output"`
  7343. RefmsgTime string `json:"refmsg_time"`
  7344. RespondTime string `json:"respond_time"`
  7345. Signtype interface{} `json:"signtype"`
  7346. WarnInfo interface{} `json:"warn_info"`
  7347. }
  7348. type ResultTwo10265 struct {
  7349. ErrMsg string `json:"err_msg"`
  7350. InfRefmsgid string `json:"inf_refmsgid"`
  7351. Infcode string `json:"infcode"`
  7352. Output struct {
  7353. Baseinfo struct {
  7354. Age float64 `json:"age"`
  7355. Brdy string `json:"brdy"`
  7356. Certno string `json:"certno"`
  7357. Gend string `json:"gend"`
  7358. Naty string `json:"naty"`
  7359. PsnCertType string `json:"psn_cert_type"`
  7360. PsnName string `json:"psn_name"`
  7361. PsnNo string `json:"psn_no"`
  7362. } `json:"baseinfo"`
  7363. Idetinfo []interface{} `json:"idetinfo"`
  7364. Iinfo []struct {
  7365. Balc float64 `json:"balc"`
  7366. CvlservFlag string `json:"cvlserv_flag"`
  7367. EmpName string `json:"emp_name"`
  7368. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7369. Insutype string `json:"insutype"`
  7370. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7371. PausInsuDate string `json:"paus_insu_date"`
  7372. PsnInsuDate string `json:"psn_insu_date"`
  7373. PsnInsuStas string `json:"psn_insu_stas"`
  7374. PsnType string `json:"psn_type"`
  7375. } `json:"insuinfo"`
  7376. } `json:"output"`
  7377. RefmsgTime string `json:"refmsg_time"`
  7378. RespondTime string `json:"respond_time"`
  7379. Signtype interface{} `json:"signtype"`
  7380. WarnInfo interface{} `json:"warn_info"`
  7381. }
  7382. type ResultThree struct {
  7383. Cainfo interface{} `json:"cainfo"`
  7384. ErrMsg string `json:"err_msg"`
  7385. InfRefmsgid string `json:"inf_refmsgid"`
  7386. Infcode int64 `json:"infcode"`
  7387. Output struct {
  7388. Data struct {
  7389. IptOtpNo string `json:"ipt_otp_no"`
  7390. MdtrtID string `json:"mdtrt_id"`
  7391. PsnNo string `json:"psn_no"`
  7392. } `json:"data"`
  7393. } `json:"output"`
  7394. RefmsgTime string `json:"refmsg_time"`
  7395. RespondTime string `json:"respond_time"`
  7396. Signtype interface{} `json:"signtype"`
  7397. WarnMsg interface{} `json:"warn_msg"`
  7398. }
  7399. type ResultThree10265 struct {
  7400. Cainfo interface{} `json:"cainfo"`
  7401. ErrMsg string `json:"err_msg"`
  7402. InfRefmsgid string `json:"inf_refmsgid"`
  7403. Infcode string `json:"infcode"`
  7404. Output struct {
  7405. Data struct {
  7406. IptOtpNo string `json:"ipt_otp_no"`
  7407. MdtrtID string `json:"mdtrt_id"`
  7408. PsnNo string `json:"psn_no"`
  7409. } `json:"data"`
  7410. } `json:"output"`
  7411. RefmsgTime string `json:"refmsg_time"`
  7412. RespondTime string `json:"respond_time"`
  7413. Signtype interface{} `json:"signtype"`
  7414. WarnMsg interface{} `json:"warn_msg"`
  7415. }
  7416. type ResultFour struct {
  7417. Cainfo string `json:"cainfo"`
  7418. ErrMsg string `json:"err_msg"`
  7419. InfRefmsgid string `json:"inf_refmsgid"`
  7420. Infcode int64 `json:"infcode"`
  7421. Output struct {
  7422. Result []struct {
  7423. BasMednFlag string `json:"bas_medn_flag"`
  7424. ChldMedcFlag string `json:"chld_medc_flag"`
  7425. ChrgitmLv string `json:"chrgitm_lv"`
  7426. Cnt float64 `json:"cnt"`
  7427. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7428. DrtReimFlag string `json:"drt_reim_flag"`
  7429. FeedetlSn string `json:"feedetl_sn"`
  7430. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7431. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7432. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7433. ListSpItemFlag string `json:"list_sp_item_flag"`
  7434. LmtUsedFlag string `json:"lmt_used_flag"`
  7435. MedChrgitmType string `json:"med_chrgitm_type"`
  7436. Memo string `json:"memo"`
  7437. OverlmtAmt float64 `json:"overlmt_amt"`
  7438. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7439. Pric float64 `json:"pric"`
  7440. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7441. SelfpayProp float64 `json:"selfpay_prop"`
  7442. } `json:"result"`
  7443. } `json:"output"`
  7444. RefmsgTime string `json:"refmsg_time"`
  7445. RespondTime string `json:"respond_time"`
  7446. Signtype string `json:"signtype"`
  7447. WarnMsg string `json:"warn_msg"`
  7448. }
  7449. type ResultFour10265 struct {
  7450. Cainfo string `json:"cainfo"`
  7451. ErrMsg string `json:"err_msg"`
  7452. InfRefmsgid string `json:"inf_refmsgid"`
  7453. Infcode string `json:"infcode"`
  7454. Output struct {
  7455. Result []struct {
  7456. BasMednFlag string `json:"bas_medn_flag"`
  7457. ChldMedcFlag string `json:"chld_medc_flag"`
  7458. ChrgitmLv string `json:"chrgitm_lv"`
  7459. Cnt float64 `json:"cnt"`
  7460. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7461. DrtReimFlag string `json:"drt_reim_flag"`
  7462. FeedetlSn string `json:"feedetl_sn"`
  7463. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7464. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7465. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7466. ListSpItemFlag string `json:"list_sp_item_flag"`
  7467. LmtUsedFlag string `json:"lmt_used_flag"`
  7468. MedChrgitmType string `json:"med_chrgitm_type"`
  7469. Memo string `json:"memo"`
  7470. OverlmtAmt float64 `json:"overlmt_amt"`
  7471. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7472. Pric float64 `json:"pric"`
  7473. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7474. SelfpayProp float64 `json:"selfpay_prop"`
  7475. } `json:"result"`
  7476. } `json:"output"`
  7477. RefmsgTime string `json:"refmsg_time"`
  7478. RespondTime string `json:"respond_time"`
  7479. Signtype string `json:"signtype"`
  7480. WarnMsg string `json:"warn_msg"`
  7481. }
  7482. type ResultMemo struct {
  7483. InsuAdmdvs string `json:"insuAdmdvs"`
  7484. }
  7485. // [{"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}]
  7486. type ResultIDInfo struct {
  7487. Begntime string `json:"begntime"`
  7488. Endtime string `json:"endtime"`
  7489. Memo string `json:"memo"`
  7490. }
  7491. type ResultFive struct {
  7492. Balc float64 `json:"balc"`
  7493. CvlservFlag string `json:"cvlserv_flag"`
  7494. EmpName string `json:"emp_name"`
  7495. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7496. Insutype string `json:"insutype"`
  7497. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7498. PausInsuDate string `json:"paus_insu_date"`
  7499. PsnInsuDate string `json:"psn_insu_date"`
  7500. PsnInsuStas string `json:"psn_insu_stas"`
  7501. PsnType string `json:"psn_type"`
  7502. }
  7503. type ResultSix struct {
  7504. Cainfo interface{} `json:"cainfo"`
  7505. ErrMsg string `json:"err_msg"`
  7506. InfRefmsgid string `json:"inf_refmsgid"`
  7507. Infcode int64 `json:"infcode"`
  7508. Output struct {
  7509. } `json:"output"`
  7510. RefmsgTime string `json:"refmsg_time"`
  7511. RespondTime string `json:"respond_time"`
  7512. Signtype interface{} `json:"signtype"`
  7513. WarnMsg interface{} `json:"warn_msg"`
  7514. }
  7515. type ResultSix10265 struct {
  7516. Cainfo interface{} `json:"cainfo"`
  7517. ErrMsg string `json:"err_msg"`
  7518. InfRefmsgid string `json:"inf_refmsgid"`
  7519. Infcode string `json:"infcode"`
  7520. Output struct {
  7521. } `json:"output"`
  7522. RefmsgTime string `json:"refmsg_time"`
  7523. RespondTime string `json:"respond_time"`
  7524. Signtype interface{} `json:"signtype"`
  7525. WarnMsg interface{} `json:"warn_msg"`
  7526. }
  7527. type ResultSeven struct {
  7528. Cainfo string `json:"cainfo"`
  7529. ErrMsg string `json:"err_msg"`
  7530. InfRefmsgid string `json:"inf_refmsgid"`
  7531. Infcode int64 `json:"infcode"`
  7532. Output struct {
  7533. Setldetail []interface{} `json:"setldetail"`
  7534. Setlinfo struct {
  7535. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7536. AcctPay float64 `json:"acct_pay"`
  7537. ActPayDedc float64 `json:"act_pay_dedc"`
  7538. Age float64 `json:"age"`
  7539. Balc float64 `json:"balc"`
  7540. Brdy string `json:"brdy"`
  7541. Certno string `json:"certno"`
  7542. ClrOptins string `json:"clr_optins"`
  7543. ClrType string `json:"clr_type"`
  7544. ClrWay string `json:"clr_way"`
  7545. CvlservFlag string `json:"cvlserv_flag"`
  7546. CvlservPay float64 `json:"cvlserv_pay"`
  7547. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7548. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7549. Gend string `json:"gend"`
  7550. HifesPay float64 `json:"hifes_pay"`
  7551. HifmiPay float64 `json:"hifmi_pay"`
  7552. HifpPay float64 `json:"hifp_pay"`
  7553. HospPartAmt float64 `json:"hosp_part_amt"`
  7554. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7555. Insutype string `json:"insutype"`
  7556. MafPay float64 `json:"maf_pay"`
  7557. MdtrtCertType string `json:"mdtrt_cert_type"`
  7558. HifobPay float64 `json:"hifob_pay"`
  7559. MdtrtID string `json:"mdtrt_id"`
  7560. MedType string `json:"med_type"`
  7561. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7562. MedinsSetlID string `json:"medins_setl_id"`
  7563. Naty string `json:"naty"`
  7564. OthPay float64 `json:"oth_pay"`
  7565. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7566. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7567. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7568. PsnCashPay float64 `json:"psn_cash_pay"`
  7569. PsnCertType string `json:"psn_cert_type"`
  7570. PsnName string `json:"psn_name"`
  7571. PsnNo string `json:"psn_no"`
  7572. PsnPartAmt float64 `json:"psn_part_amt"`
  7573. PsnType string `json:"psn_type"`
  7574. SetlID string `json:"setl_id"`
  7575. SetlTime string `json:"setl_time"`
  7576. } `json:"setlinfo"`
  7577. } `json:"output"`
  7578. RefmsgTime string `json:"refmsg_time"`
  7579. RespondTime string `json:"respond_time"`
  7580. Signtype interface{} `json:"signtype"`
  7581. WarnMsg interface{} `json:"warn_msg"`
  7582. }
  7583. type ResultSeven10265 struct {
  7584. Cainfo string `json:"cainfo"`
  7585. ErrMsg string `json:"err_msg"`
  7586. InfRefmsgid string `json:"inf_refmsgid"`
  7587. Infcode string `json:"infcode"`
  7588. Output struct {
  7589. Setldetail []interface{} `json:"setldetail"`
  7590. Setlinfo struct {
  7591. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7592. AcctPay float64 `json:"acct_pay"`
  7593. ActPayDedc float64 `json:"act_pay_dedc"`
  7594. Age float64 `json:"age"`
  7595. Balc float64 `json:"balc"`
  7596. Brdy string `json:"brdy"`
  7597. Certno string `json:"certno"`
  7598. ClrOptins string `json:"clr_optins"`
  7599. ClrType string `json:"clr_type"`
  7600. ClrWay string `json:"clr_way"`
  7601. CvlservFlag string `json:"cvlserv_flag"`
  7602. CvlservPay float64 `json:"cvlserv_pay"`
  7603. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7604. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7605. Gend string `json:"gend"`
  7606. HifesPay float64 `json:"hifes_pay"`
  7607. HifmiPay float64 `json:"hifmi_pay"`
  7608. HifpPay float64 `json:"hifp_pay"`
  7609. HospPartAmt float64 `json:"hosp_part_amt"`
  7610. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7611. Insutype string `json:"insutype"`
  7612. MafPay float64 `json:"maf_pay"`
  7613. MdtrtCertType string `json:"mdtrt_cert_type"`
  7614. HifobPay float64 `json:"hifob_pay"`
  7615. MdtrtID string `json:"mdtrt_id"`
  7616. MedType string `json:"med_type"`
  7617. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7618. MedinsSetlID string `json:"medins_setl_id"`
  7619. Naty string `json:"naty"`
  7620. OthPay float64 `json:"oth_pay"`
  7621. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7622. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7623. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7624. PsnCashPay float64 `json:"psn_cash_pay"`
  7625. PsnCertType string `json:"psn_cert_type"`
  7626. PsnName string `json:"psn_name"`
  7627. PsnNo string `json:"psn_no"`
  7628. PsnPartAmt float64 `json:"psn_part_amt"`
  7629. PsnType string `json:"psn_type"`
  7630. SetlID string `json:"setl_id"`
  7631. SetlTime string `json:"setl_time"`
  7632. } `json:"setlinfo"`
  7633. } `json:"output"`
  7634. RefmsgTime string `json:"refmsg_time"`
  7635. RespondTime string `json:"respond_time"`
  7636. Signtype interface{} `json:"signtype"`
  7637. WarnMsg interface{} `json:"warn_msg"`
  7638. }
  7639. type ResultEight struct {
  7640. Cainfo string `json:"cainfo"`
  7641. ErrMsg string `json:"err_msg"`
  7642. InfRefmsgid string `json:"inf_refmsgid"`
  7643. Infcode int64 `json:"infcode"`
  7644. Output struct {
  7645. Stmtinfo struct {
  7646. SetlOptins string `json:"setl_optins"`
  7647. StmtRslt string `json:"stmt_rslt"`
  7648. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7649. } `json:"stmtinfo"`
  7650. } `json:"output"`
  7651. RefmsgTime string `json:"refmsg_time"`
  7652. RespondTime string `json:"respond_time"`
  7653. Signtype interface{} `json:"signtype"`
  7654. WarnMsg interface{} `json:"warn_msg"`
  7655. }
  7656. type ResultEightFor10188 struct {
  7657. Cainfo string `json:"cainfo"`
  7658. ErrMsg string `json:"err_msg"`
  7659. InfRefmsgid string `json:"inf_refmsgid"`
  7660. Infcode string `json:"infcode"`
  7661. Output struct {
  7662. Stmtinfo struct {
  7663. SetlOptins string `json:"setl_optins"`
  7664. StmtRslt string `json:"stmt_rslt"`
  7665. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7666. } `json:"stmtinfo"`
  7667. } `json:"output"`
  7668. RefmsgTime string `json:"refmsg_time"`
  7669. RespondTime string `json:"respond_time"`
  7670. Signtype interface{} `json:"signtype"`
  7671. WarnMsg interface{} `json:"warn_msg"`
  7672. }
  7673. type ResultNine struct {
  7674. Cainfo string `json:"cainfo"`
  7675. ErrMsg string `json:"err_msg"`
  7676. InfRefmsgid string `json:"inf_refmsgid"`
  7677. Infcode int64 `json:"infcode"`
  7678. Output struct {
  7679. FileQuryNo string `json:"file_qury_no"`
  7680. } `json:"output"`
  7681. RefmsgTime string `json:"refmsg_time"`
  7682. RespondTime string `json:"respond_time"`
  7683. Signtype interface{} `json:"signtype"`
  7684. WarnMsg interface{} `json:"warn_msg"`
  7685. }
  7686. type ResultTen struct {
  7687. Cainfo string `json:"cainfo"`
  7688. ErrMsg string `json:"err_msg"`
  7689. InfRefmsgid string `json:"inf_refmsgid"`
  7690. Infcode int64 `json:"infcode"`
  7691. Output struct {
  7692. DldEndtime string `json:"dld_endtime"`
  7693. FileQuryNo string `json:"file_qury_no"`
  7694. Filename string `json:"filename"`
  7695. } `json:"output"`
  7696. RefmsgTime string `json:"refmsg_time"`
  7697. RespondTime string `json:"respond_time"`
  7698. Signtype interface{} `json:"signtype"`
  7699. WarnMsg interface{} `json:"warn_msg"`
  7700. }
  7701. //type Autogenerated struct {
  7702. // Output struct {
  7703. // Setlinfo struct {
  7704. // SetlTime string `json:"setl_time"`
  7705. // CvlservPay float64 `json:"cvlserv_pay"`
  7706. // Year string `json:"year"`
  7707. // MedType string `json:"med_type"`
  7708. // PsnPay float64 `json:"psn_pay"`
  7709. // OpterID string `json:"opter_id"`
  7710. // Begndate string `json:"begndate"`
  7711. // FlxempeFlag string `json:"flxempe_flag"`
  7712. // HifmiPay float64 `json:"hifmi_pay"`
  7713. // PsnNo string `json:"psn_no"`
  7714. // ActPayDedc float64 `json:"act_pay_dedc"`
  7715. // MedinsSetlID interface{} `json:"medins_setl_id"`
  7716. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7717. // ClrWay string `json:"clr_way"`
  7718. // OthPay float64 `json:"oth_pay"`
  7719. // Gend string `json:"gend"`
  7720. // MdtrtID string `json:"mdtrt_id"`
  7721. // AcctPay float64 `json:"acct_pay"`
  7722. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  7723. // Insutype string `json:"insutype"`
  7724. // Invono interface{} `json:"invono"`
  7725. // Enddate string `json:"enddate"`
  7726. // CashPayamt float64 `json:"cash_payamt"`
  7727. // PsnType string `json:"psn_type"`
  7728. // FixmedinsName string `json:"fixmedins_name"`
  7729. // HifpPay float64 `json:"hifp_pay"`
  7730. // NewFlag interface{} `json:"new_flag"`
  7731. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7732. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  7733. // PayLoc string `json:"pay_loc"`
  7734. // ClrType string `json:"clr_type"`
  7735. // RefdSetlFlag string `json:"refd_setl_flag"`
  7736. // CvlservFlag string `json:"cvlserv_flag"`
  7737. // EmpName string `json:"emp_name"`
  7738. // Brdy string `json:"brdy"`
  7739. // Naty string `json:"naty"`
  7740. // Certno string `json:"certno"`
  7741. // DiseCode string `json:"dise_code"`
  7742. // FixmedinsCode string `json:"fixmedins_code"`
  7743. // DedcHospLv string `json:"dedc_hosp_lv"`
  7744. // OpterName string `json:"opter_name"`
  7745. // Balc float64 `json:"balc"`
  7746. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7747. // PsnCertType string `json:"psn_cert_type"`
  7748. // HifobPay float64 `json:"hifob_pay"`
  7749. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  7750. // HifesPay float64 `json:"hifes_pay"`
  7751. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7752. // OptTime string `json:"opt_time"`
  7753. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7754. // SetlID string `json:"setl_id"`
  7755. // MafPay float64 `json:"maf_pay"`
  7756. // PsnName string `json:"psn_name"`
  7757. // InsuOptins interface{} `json:"insu_optins"`
  7758. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7759. // ClrOptins string `json:"clr_optins"`
  7760. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7761. // DiseName string `json:"dise_name"`
  7762. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7763. // Age float64 `json:"age"`
  7764. // DtrtCertType string `json:"dtrt_cert_type"`
  7765. // HospLv string `json:"hosp_lv"`
  7766. // } `json:"setlinfo"`
  7767. // Setldetail []struct {
  7768. // FundPayType string `json:"fund_pay_type"`
  7769. // FundPayamt float64 `json:"fund_payamt"`
  7770. // SetlProcInfo interface{} `json:"setl_proc_info"`
  7771. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  7772. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  7773. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  7774. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7775. // } `json:"setldetail"`
  7776. // } `json:"output"`
  7777. // Infcode int `json:"infcode"`
  7778. // WarnMsg interface{} `json:"warn_msg"`
  7779. // Cainfo interface{} `json:"cainfo"`
  7780. // ErrMsg interface{} `json:"err_msg"`
  7781. // RefmsgTime string `json:"refmsg_time"`
  7782. // Signtype interface{} `json:"signtype"`
  7783. // RespondTime string `json:"respond_time"`
  7784. // InfRefmsgid string `json:"inf_refmsgid"`
  7785. //}
  7786. type ResultEleven struct {
  7787. Cainfo string `json:"cainfo"`
  7788. ErrMsg string `json:"err_msg"`
  7789. InfRefmsgid string `json:"inf_refmsgid"`
  7790. Infcode int64 `json:"infcode"`
  7791. Output struct {
  7792. Setlinfo struct {
  7793. SetlTime string `json:"setl_time"`
  7794. CvlservPay float64 `json:"cvlserv_pay"`
  7795. Year string `json:"year"`
  7796. MedType string `json:"med_type"`
  7797. PsnPay float64 `json:"psn_pay"`
  7798. OpterID string `json:"opter_id"`
  7799. Begndate string `json:"begndate"`
  7800. FlxempeFlag string `json:"flxempe_flag"`
  7801. HifmiPay float64 `json:"hifmi_pay"`
  7802. PsnNo string `json:"psn_no"`
  7803. ActPayDedc float64 `json:"act_pay_dedc"`
  7804. MedinsSetlID interface{} `json:"medins_setl_id"`
  7805. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7806. ClrWay string `json:"clr_way"`
  7807. OthPay float64 `json:"oth_pay"`
  7808. Gend string `json:"gend"`
  7809. MdtrtID string `json:"mdtrt_id"`
  7810. AcctPay float64 `json:"acct_pay"`
  7811. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7812. Insutype string `json:"insutype"`
  7813. Invono interface{} `json:"invono"`
  7814. Enddate string `json:"enddate"`
  7815. CashPayamt float64 `json:"cash_payamt"`
  7816. PsnType string `json:"psn_type"`
  7817. FixmedinsName string `json:"fixmedins_name"`
  7818. HifpPay float64 `json:"hifp_pay"`
  7819. NewFlag interface{} `json:"new_flag"`
  7820. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7821. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7822. PayLoc string `json:"pay_loc"`
  7823. ClrType string `json:"clr_type"`
  7824. RefdSetlFlag string `json:"refd_setl_flag"`
  7825. CvlservFlag string `json:"cvlserv_flag"`
  7826. EmpName string `json:"emp_name"`
  7827. Brdy string `json:"brdy"`
  7828. Naty string `json:"naty"`
  7829. Certno string `json:"certno"`
  7830. DiseCode string `json:"dise_code"`
  7831. FixmedinsCode string `json:"fixmedins_code"`
  7832. DedcHospLv string `json:"dedc_hosp_lv"`
  7833. OpterName string `json:"opter_name"`
  7834. Balc float64 `json:"balc"`
  7835. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7836. PsnCertType string `json:"psn_cert_type"`
  7837. HifobPay float64 `json:"hifob_pay"`
  7838. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7839. HifesPay float64 `json:"hifes_pay"`
  7840. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7841. OptTime string `json:"opt_time"`
  7842. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7843. SetlID string `json:"setl_id"`
  7844. MafPay float64 `json:"maf_pay"`
  7845. PsnName string `json:"psn_name"`
  7846. InsuOptins interface{} `json:"insu_optins"`
  7847. PrefFundPay interface{} `json:"pref_fund_pay"`
  7848. ClrOptins string `json:"clr_optins"`
  7849. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7850. DiseName string `json:"dise_name"`
  7851. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7852. Age float64 `json:"age"`
  7853. DtrtCertType string `json:"dtrt_cert_type"`
  7854. HospLv string `json:"hosp_lv"`
  7855. PsnCashPay float64
  7856. } `json:"setlinfo"`
  7857. } `json:"output"`
  7858. RefmsgTime string `json:"refmsg_time"`
  7859. RespondTime string `json:"respond_time"`
  7860. Signtype interface{} `json:"signtype"`
  7861. WarnMsg interface{} `json:"warn_msg"`
  7862. }
  7863. type ResultEleven10265 struct {
  7864. Cainfo string `json:"cainfo"`
  7865. ErrMsg string `json:"err_msg"`
  7866. InfRefmsgid string `json:"inf_refmsgid"`
  7867. Infcode string `json:"infcode"`
  7868. Output struct {
  7869. Setlinfo struct {
  7870. SetlTime string `json:"setl_time"`
  7871. CvlservPay float64 `json:"cvlserv_pay"`
  7872. Year string `json:"year"`
  7873. MedType string `json:"med_type"`
  7874. PsnPay float64 `json:"psn_pay"`
  7875. OpterID string `json:"opter_id"`
  7876. Begndate string `json:"begndate"`
  7877. FlxempeFlag string `json:"flxempe_flag"`
  7878. HifmiPay float64 `json:"hifmi_pay"`
  7879. PsnNo string `json:"psn_no"`
  7880. ActPayDedc float64 `json:"act_pay_dedc"`
  7881. MedinsSetlID interface{} `json:"medins_setl_id"`
  7882. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7883. ClrWay string `json:"clr_way"`
  7884. OthPay float64 `json:"oth_pay"`
  7885. Gend string `json:"gend"`
  7886. MdtrtID string `json:"mdtrt_id"`
  7887. AcctPay float64 `json:"acct_pay"`
  7888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7889. Insutype string `json:"insutype"`
  7890. Invono interface{} `json:"invono"`
  7891. Enddate string `json:"enddate"`
  7892. CashPayamt float64 `json:"cash_payamt"`
  7893. PsnType string `json:"psn_type"`
  7894. FixmedinsName string `json:"fixmedins_name"`
  7895. HifpPay float64 `json:"hifp_pay"`
  7896. NewFlag interface{} `json:"new_flag"`
  7897. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7898. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7899. PayLoc string `json:"pay_loc"`
  7900. ClrType string `json:"clr_type"`
  7901. RefdSetlFlag string `json:"refd_setl_flag"`
  7902. CvlservFlag string `json:"cvlserv_flag"`
  7903. EmpName string `json:"emp_name"`
  7904. Brdy string `json:"brdy"`
  7905. Naty string `json:"naty"`
  7906. Certno string `json:"certno"`
  7907. DiseCode string `json:"dise_code"`
  7908. FixmedinsCode string `json:"fixmedins_code"`
  7909. DedcHospLv string `json:"dedc_hosp_lv"`
  7910. OpterName string `json:"opter_name"`
  7911. Balc float64 `json:"balc"`
  7912. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7913. PsnCertType string `json:"psn_cert_type"`
  7914. HifobPay float64 `json:"hifob_pay"`
  7915. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7916. HifesPay float64 `json:"hifes_pay"`
  7917. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7918. OptTime string `json:"opt_time"`
  7919. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7920. SetlID string `json:"setl_id"`
  7921. MafPay float64 `json:"maf_pay"`
  7922. PsnName string `json:"psn_name"`
  7923. InsuOptins interface{} `json:"insu_optins"`
  7924. PrefFundPay interface{} `json:"pref_fund_pay"`
  7925. ClrOptins string `json:"clr_optins"`
  7926. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7927. DiseName string `json:"dise_name"`
  7928. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7929. Age float64 `json:"age"`
  7930. DtrtCertType string `json:"dtrt_cert_type"`
  7931. HospLv string `json:"hosp_lv"`
  7932. PsnCashPay float64
  7933. } `json:"setlinfo"`
  7934. } `json:"output"`
  7935. RefmsgTime string `json:"refmsg_time"`
  7936. RespondTime string `json:"respond_time"`
  7937. Signtype interface{} `json:"signtype"`
  7938. WarnMsg interface{} `json:"warn_msg"`
  7939. }
  7940. type ResultTwelve struct {
  7941. Cainfo string `json:"cainfo"`
  7942. ErrMsg string `json:"err_msg"`
  7943. InfRefmsgid string `json:"inf_refmsgid"`
  7944. Infcode int64 `json:"infcode"`
  7945. Output struct {
  7946. MdtrtId string `json:"mdtrt_id"`
  7947. ChrgBchno string `json:"chrg_bchno"`
  7948. PsnNo string `json:"psn_no"`
  7949. } `json:"output"`
  7950. RefmsgTime string `json:"refmsg_time"`
  7951. RespondTime string `json:"respond_time"`
  7952. Signtype interface{} `json:"signtype"`
  7953. WarnMsg interface{} `json:"warn_msg"`
  7954. }
  7955. type ResultThirteen struct {
  7956. ErrMsg string `json:"err_msg"`
  7957. InfRefmsgid string `json:"inf_refmsgid"`
  7958. Infcode int64 `json:"infcode"`
  7959. Output struct {
  7960. Result struct {
  7961. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7962. } `json:"result"`
  7963. } `json:"output"`
  7964. RefmsgTime string `json:"refmsg_time"`
  7965. RespondTime string `json:"respond_time"`
  7966. Signtype interface{} `json:"signtype"`
  7967. WarnInfo interface{} `json:"warn_info"`
  7968. }
  7969. type ResultThirteen10265 struct {
  7970. ErrMsg string `json:"err_msg"`
  7971. InfRefmsgid string `json:"inf_refmsgid"`
  7972. Infcode string `json:"infcode"`
  7973. Output struct {
  7974. Result struct {
  7975. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7976. } `json:"result"`
  7977. } `json:"output"`
  7978. RefmsgTime string `json:"refmsg_time"`
  7979. RespondTime string `json:"respond_time"`
  7980. Signtype interface{} `json:"signtype"`
  7981. WarnInfo interface{} `json:"warn_info"`
  7982. }
  7983. type ResultFourteen struct {
  7984. ErrMsg string `json:"err_msg"`
  7985. InfRefmsgid string `json:"inf_refmsgid"`
  7986. Infcode int64 `json:"infcode"`
  7987. Output struct {
  7988. } `json:"output"`
  7989. RefmsgTime string `json:"refmsg_time"`
  7990. RespondTime string `json:"respond_time"`
  7991. Signtype interface{} `json:"signtype"`
  7992. WarnInfo interface{} `json:"warn_info"`
  7993. }
  7994. type ResultFourteen10265 struct {
  7995. ErrMsg string `json:"err_msg"`
  7996. InfRefmsgid string `json:"inf_refmsgid"`
  7997. Infcode string `json:"infcode"`
  7998. Output struct {
  7999. } `json:"output"`
  8000. RefmsgTime string `json:"refmsg_time"`
  8001. RespondTime string `json:"respond_time"`
  8002. Signtype interface{} `json:"signtype"`
  8003. WarnInfo interface{} `json:"warn_info"`
  8004. }
  8005. type ResultSixteen struct {
  8006. Cainfo string `json:"cainfo"`
  8007. ErrMsg string `json:"err_msg"`
  8008. InfRefmsgid string `json:"inf_refmsgid"`
  8009. Infcode int64 `json:"infcode"`
  8010. Output struct {
  8011. Setldetail []interface{} `json:"setldetail"`
  8012. Setlinfo struct {
  8013. MdtrtID string `json:"mdtrt_id"`
  8014. SetlID string `json:"setl_id"`
  8015. ClrOptins string `json:"clr_optins"`
  8016. SetlTime string `json:"setl_time"`
  8017. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8018. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8019. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8020. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8021. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8022. ActPayDedc float64 `json:"act_pay_dedc"`
  8023. HifpPay float64 `json:"hifp_pay"`
  8024. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8025. Lfpay float64 `json:"selfpay"`
  8026. CvlservPay float64 `json:"cvlserv_pay"`
  8027. HifesPay float64 `json:"hifes_pay"`
  8028. HifmiPay float64 `json:"hifmi_pay"`
  8029. HifobPay float64 `json:"hifob_pay"`
  8030. MafPay float64 `json:"maf_pay"`
  8031. OthPay float64 `json:"oth_pay"`
  8032. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8033. PsnPartAmt float64 `json:"psn_part_amt"`
  8034. AcctPay float64 `json:"acct_pay"`
  8035. Balc float64 `json:"balc"`
  8036. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8037. HospPartAmt float64 `json:"hosp_part_amt"`
  8038. MedinsSetlID string `json:"medins_setl_id"`
  8039. PdnCashPay string `json:"pdn_cash_pay"`
  8040. } `json:"setlinfo"`
  8041. } `json:"output"`
  8042. RefmsgTime string `json:"refmsg_time"`
  8043. RespondTime string `json:"respond_time"`
  8044. Signtype interface{} `json:"signtype"`
  8045. WarnMsg interface{} `json:"warn_msg"`
  8046. }
  8047. type ResultSixteen10265 struct {
  8048. Cainfo string `json:"cainfo"`
  8049. ErrMsg string `json:"err_msg"`
  8050. InfRefmsgid string `json:"inf_refmsgid"`
  8051. Infcode string `json:"infcode"`
  8052. Output struct {
  8053. Setldetail []interface{} `json:"setldetail"`
  8054. Setlinfo struct {
  8055. MdtrtID string `json:"mdtrt_id"`
  8056. SetlID string `json:"setl_id"`
  8057. ClrOptins string `json:"clr_optins"`
  8058. SetlTime string `json:"setl_time"`
  8059. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8060. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8062. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8063. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8064. ActPayDedc float64 `json:"act_pay_dedc"`
  8065. HifpPay float64 `json:"hifp_pay"`
  8066. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8067. Lfpay float64 `json:"selfpay"`
  8068. CvlservPay float64 `json:"cvlserv_pay"`
  8069. HifesPay float64 `json:"hifes_pay"`
  8070. HifmiPay float64 `json:"hifmi_pay"`
  8071. HifobPay float64 `json:"hifob_pay"`
  8072. MafPay float64 `json:"maf_pay"`
  8073. OthPay float64 `json:"oth_pay"`
  8074. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8075. PsnPartAmt float64 `json:"psn_part_amt"`
  8076. AcctPay float64 `json:"acct_pay"`
  8077. Balc float64 `json:"balc"`
  8078. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8079. HospPartAmt float64 `json:"hosp_part_amt"`
  8080. MedinsSetlID string `json:"medins_setl_id"`
  8081. PdnCashPay string `json:"pdn_cash_pay"`
  8082. } `json:"setlinfo"`
  8083. } `json:"output"`
  8084. RefmsgTime string `json:"refmsg_time"`
  8085. RespondTime string `json:"respond_time"`
  8086. Signtype interface{} `json:"signtype"`
  8087. WarnMsg interface{} `json:"warn_msg"`
  8088. }
  8089. type ResultSeventeen struct {
  8090. ErrMsg string `json:"err_msg"`
  8091. InfRefmsgid string `json:"inf_refmsgid"`
  8092. Infcode int64 `json:"infcode"`
  8093. Output struct {
  8094. SetlListId string `json:"setl_list_id"`
  8095. } `json:"output"`
  8096. RefmsgTime string `json:"refmsg_time"`
  8097. RespondTime string `json:"respond_time"`
  8098. Signtype string `json:"signtype"`
  8099. WarnInfo string `json:"warn_info"`
  8100. }
  8101. type ResultSeventeenOther struct {
  8102. ErrMsg string `json:"err_msg"`
  8103. InfRefmsgid string `json:"inf_refmsgid"`
  8104. Infcode string `json:"infcode"`
  8105. Output struct {
  8106. SetlListId string `json:"setl_list_id"`
  8107. } `json:"output"`
  8108. RefmsgTime string `json:"refmsg_time"`
  8109. RespondTime string `json:"respond_time"`
  8110. Signtype string `json:"signtype"`
  8111. WarnInfo string `json:"warn_info"`
  8112. }
  8113. type Result90991 struct {
  8114. ErrMsg string `json:"err_msg"`
  8115. InfRefmsgid string `json:"inf_refmsgid"`
  8116. Infcode int64 `json:"infcode"`
  8117. Output struct {
  8118. Result struct {
  8119. PsnNo string `json:"psn_no"`
  8120. CardStat string `json:"card_stat"`
  8121. Certno string `json:"certno"`
  8122. PsnName string `json:"psn_name"`
  8123. CheckStat string `json:"check_stat"`
  8124. SscnoCheckStat string `json:"sscno_check_stat"`
  8125. } `json:"result"`
  8126. } `json:"output"`
  8127. RefmsgTime string `json:"refmsg_time"`
  8128. RespondTime string `json:"respond_time"`
  8129. Signtype interface{} `json:"signtype"`
  8130. WarnInfo interface{} `json:"warn_info"`
  8131. }
  8132. type Result90100 struct {
  8133. ErrMsg string `json:"err_msg"`
  8134. InfRefmsgid string `json:"inf_refmsgid"`
  8135. Infcode int64 `json:"infcode"`
  8136. Output struct {
  8137. PoolareaNo string `json:"poolarea_no"`
  8138. PoolareaNoName string `json:"poolarea_no_name"`
  8139. Insutype string `json:"insutype"`
  8140. InsutypeName string `json:"insutype_name"`
  8141. ClctType string `json:"clct_type"`
  8142. ClctTypeName string `json:"clct_type_name"`
  8143. ClctFlag string `json:"clct_flag"`
  8144. ClctFlagName string `json:"clct_flag_name"`
  8145. AccrymBegn string `json:"accrym_begn"`
  8146. AccrymEnd string `json:"accrym_end"`
  8147. ClctTime string `json:"clct_time"`
  8148. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  8149. } `json:"output"`
  8150. RefmsgTime string `json:"refmsg_time"`
  8151. RespondTime string `json:"respond_time"`
  8152. Signtype interface{} `json:"signtype"`
  8153. WarnInfo interface{} `json:"warn_info"`
  8154. }
  8155. type Custom struct {
  8156. DetItemFeeSumamt string
  8157. Cut string
  8158. FeedetlSn string
  8159. Price string
  8160. MedListCodg string
  8161. Type int64
  8162. AdviceId int64
  8163. ProjectId int64
  8164. ItemId int64
  8165. }
  8166. type Result5301 struct {
  8167. ErrMsg string `json:"err_msg"`
  8168. InfRefmsgid string `json:"inf_refmsgid"`
  8169. Infcode int64 `json:"infcode"`
  8170. Output struct {
  8171. Result []struct {
  8172. OpspDiseCode string `json:"opsp_dise_code"`
  8173. OpspDiseName string `json:"opsp_dise_name"`
  8174. Begndate string `json:"begndate"`
  8175. Enddate string `json:"enddate"`
  8176. } `json:"feedetail"`
  8177. } `json:"output"`
  8178. RefmsgTime string `json:"refmsg_time"`
  8179. RespondTime string `json:"respond_time"`
  8180. Signtype interface{} `json:"signtype"`
  8181. WarnInfo interface{} `json:"warn_info"`
  8182. }
  8183. type Result5301For10265 struct {
  8184. ErrMsg string `json:"err_msg"`
  8185. InfRefmsgid string `json:"inf_refmsgid"`
  8186. Infcode string `json:"infcode"`
  8187. Output struct {
  8188. Result []struct {
  8189. OpspDiseCode string `json:"opsp_dise_code"`
  8190. OpspDiseName string `json:"opsp_dise_name"`
  8191. Begndate string `json:"begndate"`
  8192. Enddate string `json:"enddate"`
  8193. } `json:"feedetail"`
  8194. } `json:"output"`
  8195. RefmsgTime string `json:"refmsg_time"`
  8196. RespondTime string `json:"respond_time"`
  8197. Signtype interface{} `json:"signtype"`
  8198. WarnInfo interface{} `json:"warn_info"`
  8199. }
  8200. //获取个人信息----挂号-----上传就诊信息
  8201. func (c *HisApiController) GetRegisterInfo() {
  8202. id, _ := c.GetInt64("id")
  8203. record_time := c.GetString("record_time")
  8204. settlementValue, _ := c.GetInt64("settlement_value")
  8205. medical_insurance_card := c.GetString("medical_insurance_card")
  8206. name := c.GetString("name")
  8207. id_card_type, _ := c.GetInt64("id_card_type")
  8208. certificates, _ := c.GetInt64("certificates")
  8209. medical_care, _ := c.GetInt64("medical_care")
  8210. birthday := c.GetString("birthday")
  8211. id_card := c.GetString("id_card")
  8212. register_type, _ := c.GetInt64("register")
  8213. doctor, _ := c.GetInt64("doctor")
  8214. department, _ := c.GetInt64("department")
  8215. gender, _ := c.GetInt64("sex")
  8216. registration_fee, _ := c.GetFloat("registration_fee")
  8217. medical_expenses, _ := c.GetFloat("medical_expenses")
  8218. social_type, _ := c.GetInt64("social_type")
  8219. admin_user_id, _ := c.GetInt64("admin_user_id")
  8220. insuplc_admdvs := c.GetString("insuplc_admdvs")
  8221. mdtrt_type := c.GetString("mdtrt_type")
  8222. timeLayout := "2006-01-02"
  8223. loc, _ := time.LoadLocation("Local")
  8224. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  8225. birthUnix := birthdays.Unix()
  8226. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8227. if err != nil {
  8228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8229. return
  8230. }
  8231. recordDateTime := theTime.Unix()
  8232. adminInfo := c.GetAdminUserInfo()
  8233. var patient service.Patients
  8234. if id == 0 {
  8235. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  8236. } else {
  8237. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  8238. }
  8239. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8240. if patientPrescription.ID == 0 {
  8241. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8242. }
  8243. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8244. if patient.ID == 0 {
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8246. return
  8247. }
  8248. if len(patient.IdCardNo) == 0 {
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8250. return
  8251. }
  8252. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8253. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  8254. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  8255. //就诊结算未完成,不能进行二次挂号
  8256. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  8257. if len(his) >= 1 {
  8258. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  8259. if len(his) >= 1 && order.ID == 0 {
  8260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  8261. return
  8262. }
  8263. }
  8264. //var register_log string
  8265. if config.IsOpen == 1 {
  8266. var res ResultTwo
  8267. var res10265 ResultTwo10265
  8268. var PsnNo string
  8269. var PsnCertType string
  8270. var Certno string
  8271. var PsnName string
  8272. var Gend string
  8273. var Naty string
  8274. var Brdy string
  8275. var Age float64
  8276. var infoStr string
  8277. var idetinfoStr string
  8278. var infocode int64
  8279. var verify_number string
  8280. fmt.Println(verify_number)
  8281. if miConfig.MdtrtareaAdmvs == "421300" {
  8282. psn_info, _ := service.GetPsnByPatientId(id)
  8283. PsnNo = psn_info.PsnNo
  8284. PsnCertType = psn_info.PsnCertType
  8285. Certno = psn_info.Certno
  8286. PsnName = psn_info.PsnName
  8287. Gend = psn_info.Gend
  8288. Naty = psn_info.Naty
  8289. Brdy = psn_info.Brdy
  8290. Age = psn_info.Age
  8291. infoStr = psn_info.Insuinfo
  8292. idetinfoStr = psn_info.Idetinfo
  8293. infocode = 0
  8294. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8295. psn_info, _ := service.GetPsnByPatientId(id)
  8296. PsnNo = psn_info.PsnNo
  8297. PsnCertType = psn_info.PsnCertType
  8298. Certno = psn_info.Certno
  8299. PsnName = psn_info.PsnName
  8300. Gend = psn_info.Gend
  8301. Naty = psn_info.Naty
  8302. Brdy = psn_info.Brdy
  8303. Age = psn_info.Age
  8304. infoStr = psn_info.Insuinfo
  8305. idetinfoStr = psn_info.Idetinfo
  8306. infocode = 0
  8307. verify_number = psn_info.VerifyNumber
  8308. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8309. if id_card_type == 1 {
  8310. psn_info, _ := service.GetPsnByPatientId(id)
  8311. PsnNo = psn_info.PsnNo
  8312. PsnCertType = psn_info.PsnCertType
  8313. Certno = psn_info.Certno
  8314. PsnName = psn_info.PsnName
  8315. Gend = psn_info.Gend
  8316. Naty = psn_info.Naty
  8317. Brdy = psn_info.Brdy
  8318. Age = psn_info.Age
  8319. infoStr = psn_info.Insuinfo
  8320. idetinfoStr = psn_info.Idetinfo
  8321. infocode = 0
  8322. verify_number = psn_info.VerifyNumber
  8323. } else if id_card_type == 2 {
  8324. 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)
  8325. fmt.Println(errMsgLog)
  8326. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8327. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8328. utils.ErrorLog("解析失败:%v", err)
  8329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8330. return
  8331. }
  8332. PsnNo = res.Output.Baseinfo.PsnNo
  8333. PsnCertType = res.Output.Baseinfo.PsnCertType
  8334. Certno = res.Output.Baseinfo.Certno
  8335. PsnName = res.Output.Baseinfo.PsnName
  8336. Gend = res.Output.Baseinfo.Gend
  8337. Naty = res.Output.Baseinfo.Naty
  8338. Brdy = res.Output.Baseinfo.Brdy
  8339. Age = res.Output.Baseinfo.Age
  8340. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8341. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8342. infoStr = string(Iinfos)
  8343. idetinfoStr = string(Idetinfos)
  8344. infocode = res.Infcode
  8345. }
  8346. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8347. if id_card_type == 1 {
  8348. psn_info, _ := service.GetPsnByPatientId(id)
  8349. PsnNo = psn_info.PsnNo
  8350. PsnCertType = psn_info.PsnCertType
  8351. Certno = psn_info.Certno
  8352. PsnName = psn_info.PsnName
  8353. Gend = psn_info.Gend
  8354. Naty = psn_info.Naty
  8355. Brdy = psn_info.Brdy
  8356. Age = psn_info.Age
  8357. infoStr = psn_info.Insuinfo
  8358. idetinfoStr = psn_info.Idetinfo
  8359. infocode = 0
  8360. verify_number = psn_info.VerifyNumber
  8361. } else if id_card_type == 2 {
  8362. 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, "")
  8363. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8365. utils.ErrorLog("解析失败:%v", err)
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8367. return
  8368. }
  8369. PsnNo = res.Output.Baseinfo.PsnNo
  8370. PsnCertType = res.Output.Baseinfo.PsnCertType
  8371. Certno = res.Output.Baseinfo.Certno
  8372. PsnName = res.Output.Baseinfo.PsnName
  8373. Gend = res.Output.Baseinfo.Gend
  8374. Naty = res.Output.Baseinfo.Naty
  8375. Brdy = res.Output.Baseinfo.Brdy
  8376. Age = res.Output.Baseinfo.Age
  8377. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8378. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8379. infoStr = string(Iinfos)
  8380. idetinfoStr = string(Idetinfos)
  8381. infocode = res.Infcode
  8382. }
  8383. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8384. if id_card_type == 1 {
  8385. psn_info, _ := service.GetPsnByPatientId(id)
  8386. PsnNo = psn_info.PsnNo
  8387. PsnCertType = psn_info.PsnCertType
  8388. Certno = psn_info.Certno
  8389. PsnName = psn_info.PsnName
  8390. Gend = psn_info.Gend
  8391. Naty = psn_info.Naty
  8392. Brdy = psn_info.Brdy
  8393. Age = psn_info.Age
  8394. infoStr = psn_info.Insuinfo
  8395. idetinfoStr = psn_info.Idetinfo
  8396. infocode = 0
  8397. verify_number = psn_info.VerifyNumber
  8398. } else if id_card_type == 2 {
  8399. 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)
  8400. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8402. utils.ErrorLog("解析失败:%v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. PsnNo = res.Output.Baseinfo.PsnNo
  8407. PsnCertType = res.Output.Baseinfo.PsnCertType
  8408. Certno = res.Output.Baseinfo.Certno
  8409. PsnName = res.Output.Baseinfo.PsnName
  8410. Gend = res.Output.Baseinfo.Gend
  8411. Naty = res.Output.Baseinfo.Naty
  8412. Brdy = res.Output.Baseinfo.Brdy
  8413. Age = res.Output.Baseinfo.Age
  8414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8416. infoStr = string(Iinfos)
  8417. idetinfoStr = string(Idetinfos)
  8418. infocode = res.Infcode
  8419. } else if id_card_type == 4 {
  8420. psn_info, _ := service.GetPsnByPatientId(id)
  8421. PsnNo = psn_info.PsnNo
  8422. PsnCertType = psn_info.PsnCertType
  8423. Certno = psn_info.Certno
  8424. PsnName = psn_info.PsnName
  8425. Gend = psn_info.Gend
  8426. Naty = psn_info.Naty
  8427. Brdy = psn_info.Brdy
  8428. Age = psn_info.Age
  8429. infoStr = psn_info.Insuinfo
  8430. idetinfoStr = psn_info.Idetinfo
  8431. infocode = 0
  8432. verify_number = psn_info.VerifyNumber
  8433. }
  8434. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8435. var result string
  8436. var requestLog string
  8437. 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), "")
  8438. if id_card_type == 4 {
  8439. psn_info, _ := service.GetPsnByPatientId(id)
  8440. PsnNo = psn_info.PsnNo
  8441. PsnCertType = psn_info.PsnCertType
  8442. Certno = psn_info.Certno
  8443. PsnName = psn_info.PsnName
  8444. Gend = psn_info.Gend
  8445. Naty = psn_info.Naty
  8446. Brdy = psn_info.Brdy
  8447. Age = psn_info.Age
  8448. infoStr = psn_info.Insuinfo
  8449. idetinfoStr = psn_info.Idetinfo
  8450. infocode = 0
  8451. verify_number = psn_info.VerifyNumber
  8452. } else {
  8453. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8454. if miConfig.Code == "H15049901371" {
  8455. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8456. utils.ErrorLog("解析失败:%v", err)
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8458. return
  8459. }
  8460. res.ErrMsg = res10265.ErrMsg
  8461. res.Output = res10265.Output
  8462. res.InfRefmsgid = res10265.InfRefmsgid
  8463. } else {
  8464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8465. utils.ErrorLog("解析失败:%v", err)
  8466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8467. return
  8468. }
  8469. }
  8470. PsnNo = res.Output.Baseinfo.PsnNo
  8471. PsnCertType = res.Output.Baseinfo.PsnCertType
  8472. Certno = res.Output.Baseinfo.Certno
  8473. PsnName = res.Output.Baseinfo.PsnName
  8474. Gend = res.Output.Baseinfo.Gend
  8475. Naty = res.Output.Baseinfo.Naty
  8476. Brdy = res.Output.Baseinfo.Brdy
  8477. Age = res.Output.Baseinfo.Age
  8478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8480. infoStr = string(Iinfos)
  8481. idetinfoStr = string(Idetinfos)
  8482. if miConfig.Code == "H15049901371" {
  8483. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8484. } else {
  8485. infocode = res.Infcode
  8486. }
  8487. }
  8488. } else {
  8489. var result string
  8490. var requestLog string
  8491. //if miConfig.UserOrgId == 10138 {
  8492. if id_card_type != 4 || id_card_type != 1 {
  8493. var insa string
  8494. if len(patient.InsuplcAdmdvs) > 0 {
  8495. insa = patient.InsuplcAdmdvs
  8496. } else {
  8497. insa = miConfig.InsuplcAdmdvs
  8498. }
  8499. //psn_info, _ := service.GetPsnByPatientId(id)
  8500. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  8501. 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)
  8502. }
  8503. //}
  8504. //else {
  8505. // var insa string
  8506. // if len(patient.InsuplcAdmdvs) > 0 {
  8507. // insa = patient.InsuplcAdmdvs
  8508. // } else {
  8509. // insa = miConfig.InsuplcAdmdvs
  8510. // }
  8511. // 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)
  8512. //}
  8513. if id_card_type == 4 || id_card_type == 1 {
  8514. psn_info, _ := service.GetPsnByPatientId(id)
  8515. PsnNo = psn_info.PsnNo
  8516. PsnCertType = psn_info.PsnCertType
  8517. Certno = psn_info.Certno
  8518. PsnName = psn_info.PsnName
  8519. Gend = psn_info.Gend
  8520. Naty = psn_info.Naty
  8521. Brdy = psn_info.Brdy
  8522. Age = psn_info.Age
  8523. infoStr = psn_info.Insuinfo
  8524. idetinfoStr = psn_info.Idetinfo
  8525. infocode = 0
  8526. verify_number = psn_info.VerifyNumber
  8527. } else {
  8528. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8529. if miConfig.Code == "H15049901371" {
  8530. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8531. utils.ErrorLog("解析失败:%v", err)
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. return
  8534. }
  8535. res.ErrMsg = res10265.ErrMsg
  8536. res.Output = res10265.Output
  8537. res.InfRefmsgid = res10265.InfRefmsgid
  8538. } else {
  8539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8540. utils.ErrorLog("解析失败:%v", err)
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8542. return
  8543. }
  8544. }
  8545. PsnNo = res.Output.Baseinfo.PsnNo
  8546. PsnCertType = res.Output.Baseinfo.PsnCertType
  8547. Certno = res.Output.Baseinfo.Certno
  8548. PsnName = res.Output.Baseinfo.PsnName
  8549. Gend = res.Output.Baseinfo.Gend
  8550. Naty = res.Output.Baseinfo.Naty
  8551. Brdy = res.Output.Baseinfo.Brdy
  8552. Age = res.Output.Baseinfo.Age
  8553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8555. infoStr = string(Iinfos)
  8556. idetinfoStr = string(Idetinfos)
  8557. if miConfig.Code == "H15049901371" {
  8558. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8559. } else {
  8560. infocode = res.Infcode
  8561. }
  8562. }
  8563. }
  8564. if infocode == 0 {
  8565. his := models.VMHisPatient{
  8566. Name: name,
  8567. Gender: gender,
  8568. Birthday: birthUnix,
  8569. MedicalTreatmentType: medical_care,
  8570. IdType: certificates,
  8571. IdCardNo: id_card,
  8572. BalanceAccountsType: settlementValue,
  8573. SocialType: social_type,
  8574. MedicalInsuranceNumber: medical_insurance_card,
  8575. RegisterType: register_type,
  8576. RegisterCost: registration_fee,
  8577. TreatmentCost: medical_expenses,
  8578. Status: 1,
  8579. Ctime: time.Now().Unix(),
  8580. Mtime: time.Now().Unix(),
  8581. PsnNo: PsnNo,
  8582. PsnCertType: PsnCertType,
  8583. Certno: Certno,
  8584. PsnName: PsnName,
  8585. Gend: Gend,
  8586. Naty: Naty,
  8587. Brdy: Brdy,
  8588. Age: Age,
  8589. Iinfo: infoStr,
  8590. Idetinfo: idetinfoStr,
  8591. PatientId: patient.ID,
  8592. RecordDate: theTime.Unix(),
  8593. UserOrgId: adminInfo.CurrentOrgId,
  8594. AdminUserId: admin_user_id,
  8595. IsReturn: 1,
  8596. IdCardType: id_card_type,
  8597. Doctor: doctor,
  8598. Departments: department,
  8599. MdtrtGrpType: mdtrt_type,
  8600. }
  8601. timestamp := time.Now().Unix()
  8602. tempTime := time.Unix(timestamp, 0)
  8603. timeFormat := tempTime.Format("20060102150405")
  8604. chrgBchno := rand.Intn(100000) + 10000
  8605. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8606. his.Number = ipt_otp_no
  8607. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8608. department, _ := service.GetDepartMentDetail(department)
  8609. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8610. IdCardNo := ""
  8611. if id_card_type == 1 {
  8612. // IdCardNo = medical_insurance_card
  8613. IdCardNo = patient.IdCardNo
  8614. } else {
  8615. IdCardNo = patient.IdCardNo
  8616. }
  8617. var rf []*ResultFive
  8618. json.Unmarshal([]byte(his.Iinfo), &rf)
  8619. var insutypes []*ResultFive
  8620. var insutype string
  8621. var insuplc_admdvs_temp string
  8622. var is390 int = 0
  8623. var is310 int = 0
  8624. for _, item := range rf {
  8625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8626. insutypes = append(insutypes, item)
  8627. }
  8628. }
  8629. if len(insutypes) == 1 {
  8630. insutype = insutypes[0].Insutype
  8631. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8632. } else {
  8633. for _, i := range insutypes {
  8634. if i.Insutype == "390" {
  8635. is390 = 1
  8636. }
  8637. if i.Insutype == "310" {
  8638. is310 = 1
  8639. }
  8640. }
  8641. }
  8642. if is390 == 1 {
  8643. insutype = "390"
  8644. }
  8645. if is310 == 1 {
  8646. insutype = "310"
  8647. }
  8648. fmt.Println(social_type)
  8649. if social_type > 0 {
  8650. insutype = strconv.FormatInt(social_type, 10)
  8651. }
  8652. var infocode int64
  8653. var resThree ResultThree
  8654. var resThree10265 ResultThree10265
  8655. if len(insuplc_admdvs) == 0 {
  8656. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  8657. } else {
  8658. insuplc_admdvs_temp = insuplc_admdvs
  8659. }
  8660. if miConfig.MdtrtareaAdmvs == "421300" {
  8661. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  8662. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  8663. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8664. "&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
  8665. resp, requestErr := http.Get(api)
  8666. if requestErr != nil {
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. body, ioErr := ioutil.ReadAll(resp.Body)
  8671. if ioErr != nil {
  8672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. var respJSON map[string]interface{}
  8677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8683. result, _ := json.Marshal(respJSON)
  8684. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8685. utils.ErrorLog("解析失败:%v", err)
  8686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8687. return
  8688. }
  8689. infocode = resThree.Infcode
  8690. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8691. psn_info, _ := service.GetPsnByPatientId(id)
  8692. his.PsnNo = psn_info.PsnNo
  8693. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8694. var cert_no string
  8695. if id_card_type == 3 {
  8696. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  8697. cert_no = IdCardNo
  8698. } else if id_card_type == 4 {
  8699. cert_no = IdCardNo
  8700. psn_info.VerifyNumber = psn_info.VerifyNumber
  8701. } else {
  8702. bas := strings.Split(psn_info.CardInfo, "|")
  8703. cert_no = bas[2]
  8704. }
  8705. var hisPrescription []*models.HisPrescription
  8706. for _, item := range rf {
  8707. if item.Insutype == insutype {
  8708. //insuplc_admdvs = item.InsuplcAdmdvs
  8709. his.InsuplcAdmdvs = insuplc_admdvs
  8710. }
  8711. }
  8712. his.Insutype = insutype
  8713. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  8714. fmt.Println(res3101)
  8715. fmt.Println(res3101.Infcode)
  8716. if res3101.Infcode == "0" {
  8717. fmt.Println("33333333")
  8718. if len(res3101.Output.Result) > 0 {
  8719. fmt.Println("222222")
  8720. for _, item := range res3101.Output.Result {
  8721. if len(res3101.ErrMsg) == 0 {
  8722. res3101.ErrMsg = item.VolaCont
  8723. } else {
  8724. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  8725. }
  8726. }
  8727. c.ServeSuccessJSON(map[string]interface{}{
  8728. "failed_code": -10,
  8729. "msg": res3101.ErrMsg,
  8730. })
  8731. return
  8732. } else {
  8733. fmt.Println("11111")
  8734. var api string
  8735. if miConfig.MdtrtareaAdmvs == "320921" {
  8736. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8737. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8738. "&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
  8739. } else {
  8740. api = "http://192.168.5.251: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. }
  8744. resp, requestErr := http.Get(api)
  8745. if requestErr != nil {
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. body, ioErr := ioutil.ReadAll(resp.Body)
  8750. if ioErr != nil {
  8751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. var respJSON map[string]interface{}
  8756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8762. result, _ := json.Marshal(respJSON)
  8763. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8764. utils.ErrorLog("解析失败:%v", err)
  8765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8766. return
  8767. }
  8768. resThree.ErrMsg = resThree10265.ErrMsg
  8769. resThree.Output = resThree10265.Output
  8770. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8771. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8772. }
  8773. } else if res3101.Infcode != "0" {
  8774. c.ServeSuccessJSON(map[string]interface{}{
  8775. "failed_code": -10,
  8776. "msg": res3101.ErrMsg,
  8777. })
  8778. return
  8779. }
  8780. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8781. psn_info, _ := service.GetPsnByPatientId(id)
  8782. var cert_no string
  8783. if id_card_type == 1 {
  8784. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8785. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8786. } else if id_card_type == 4 {
  8787. cert_no = psn_info.VerifyNumber
  8788. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8789. } else {
  8790. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8791. cert_no = psn_info.VerifyNumber
  8792. }
  8793. 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)
  8794. saveLog(result, requestLog, "2201", "挂号")
  8795. if miConfig.Code == "H15049901371" {
  8796. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8797. utils.ErrorLog("解析失败:%v", err)
  8798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8799. return
  8800. }
  8801. resThree.ErrMsg = resThree10265.ErrMsg
  8802. resThree.Output = resThree10265.Output
  8803. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8804. } else {
  8805. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8806. utils.ErrorLog("解析失败:%v", err)
  8807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8808. return
  8809. }
  8810. }
  8811. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8812. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  8813. psn_info, _ := service.GetPsnByPatientId(id)
  8814. var result string
  8815. var requestLog string
  8816. if id_card_type == 1 {
  8817. bas := strings.Split(psn_info.CardInfo, "|")
  8818. basNumber := bas[2]
  8819. card_sn := bas[3]
  8820. 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)
  8821. saveLog(result, requestLog, "2201A", "挂号")
  8822. } else if id_card_type == 2 {
  8823. 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, "", "")
  8824. saveLog(result, requestLog, "2201A", "挂号")
  8825. } else {
  8826. 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, "", "")
  8827. saveLog(result, requestLog, "2201A", "挂号")
  8828. }
  8829. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. infocode = resThree.Infcode
  8835. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  8836. psn_info, _ := service.GetPsnByPatientId(id)
  8837. var result string
  8838. var requestLog string
  8839. if id_card_type == 1 {
  8840. bas := strings.Split(psn_info.CardInfo, "|")
  8841. basNumber := bas[2]
  8842. card_sn := bas[3]
  8843. 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)
  8844. saveLog(result, requestLog, "2201A", "挂号")
  8845. } else if id_card_type == 2 {
  8846. 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, "", "")
  8847. saveLog(result, requestLog, "2201A", "挂号")
  8848. } else {
  8849. 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, "", "")
  8850. saveLog(result, requestLog, "2201A", "挂号")
  8851. }
  8852. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8853. utils.ErrorLog("解析失败:%v", err)
  8854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8855. return
  8856. }
  8857. infocode = resThree.Infcode
  8858. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8859. psn_info, _ := service.GetPsnByPatientId(id)
  8860. 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)
  8861. saveLog(result, requestLog, "2201A", "挂号")
  8862. if miConfig.Code == "H15049901371" {
  8863. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8864. utils.ErrorLog("解析失败:%v", err)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. resThree.ErrMsg = resThree10265.ErrMsg
  8869. resThree.Output = resThree10265.Output
  8870. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8871. } else {
  8872. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8873. utils.ErrorLog("解析失败:%v", err)
  8874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8875. return
  8876. }
  8877. }
  8878. if miConfig.Code == "H15049901371" {
  8879. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8880. } else {
  8881. infocode = resThree.Infcode
  8882. }
  8883. } else {
  8884. psn_info, _ := service.GetPsnByPatientId(id)
  8885. if id_card_type == 4 || id_card_type == 1 {
  8886. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8887. }
  8888. var rf []*ResultFive
  8889. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  8890. var insutypes []*ResultFive
  8891. var insutype string
  8892. var is390 int = 0
  8893. var is310 int = 0
  8894. for _, item := range rf {
  8895. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8896. insutypes = append(insutypes, item)
  8897. }
  8898. }
  8899. if len(insutypes) == 1 {
  8900. insutype = insutypes[0].Insutype
  8901. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8902. } else {
  8903. for _, i := range insutypes {
  8904. if i.Insutype == "390" {
  8905. is390 = 1
  8906. }
  8907. if i.Insutype == "310" {
  8908. is310 = 1
  8909. }
  8910. }
  8911. }
  8912. if is390 == 1 {
  8913. insutype = "390"
  8914. }
  8915. if is310 == 1 {
  8916. insutype = "310"
  8917. }
  8918. fmt.Println(len(insutypes))
  8919. if len(insutypes) == 0 {
  8920. for index, item := range rf {
  8921. if index == 0 {
  8922. insutype = item.Insutype
  8923. insuplc_admdvs = item.InsuplcAdmdvs
  8924. }
  8925. }
  8926. fmt.Println(insutype)
  8927. fmt.Println(insuplc_admdvs)
  8928. }
  8929. if social_type > 0 {
  8930. insutype = strconv.FormatInt(social_type, 10)
  8931. }
  8932. 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)
  8933. saveLog(result, requestLog, "2201A", "挂号")
  8934. if miConfig.Code == "H15049901371" {
  8935. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8936. utils.ErrorLog("解析失败:%v", err)
  8937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8938. return
  8939. }
  8940. resThree.ErrMsg = resThree10265.ErrMsg
  8941. resThree.Output = resThree10265.Output
  8942. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8943. } else {
  8944. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8945. utils.ErrorLog("解析失败:%v", err)
  8946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8947. return
  8948. }
  8949. }
  8950. if miConfig.Code == "H15049901371" {
  8951. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8952. } else {
  8953. infocode = resThree.Infcode
  8954. }
  8955. }
  8956. if infocode != 0 {
  8957. adminUser := c.GetAdminUserInfo()
  8958. errlog := &models.HisOrderError{
  8959. UserOrgId: adminUser.CurrentOrgId,
  8960. Ctime: time.Now().Unix(),
  8961. Mtime: time.Now().Unix(),
  8962. ErrMsg: resThree.ErrMsg,
  8963. Status: 1,
  8964. PatientId: id,
  8965. RecordTime: recordDateTime,
  8966. Stage: 2,
  8967. }
  8968. service.CreateErrMsgLog(errlog)
  8969. c.ServeSuccessJSON(map[string]interface{}{
  8970. "failed_code": -10,
  8971. "msg": resThree.ErrMsg,
  8972. })
  8973. return
  8974. }
  8975. his.Number = resThree.Output.Data.MdtrtID
  8976. his.PsnNo = resThree.Output.Data.PsnNo
  8977. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8978. his.IdCardNo = patient.IdCardNo
  8979. his.PhoneNumber = patient.Phone
  8980. his.UserOrgId = adminInfo.CurrentOrgId
  8981. his.Insutype = insutype
  8982. his.Ctime = time.Now().Unix()
  8983. his.Mtime = time.Now().Unix()
  8984. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8985. his.Status = 1
  8986. his.MdtrtGrpType = mdtrt_type
  8987. service.UpdateHisPatientStatus(&his)
  8988. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8989. c.ServeSuccessJSON(map[string]interface{}{
  8990. "his_info": his,
  8991. })
  8992. } else {
  8993. adminUser := c.GetAdminUserInfo()
  8994. errlog := &models.HisOrderError{
  8995. UserOrgId: adminUser.CurrentOrgId,
  8996. Ctime: time.Now().Unix(),
  8997. Mtime: time.Now().Unix(),
  8998. ErrMsg: res.ErrMsg,
  8999. Status: 1,
  9000. PatientId: id,
  9001. RecordTime: recordDateTime,
  9002. Stage: 1,
  9003. }
  9004. service.CreateErrMsgLog(errlog)
  9005. c.ServeSuccessJSON(map[string]interface{}{
  9006. "failed_code": -10,
  9007. "msg": res.ErrMsg,
  9008. })
  9009. return
  9010. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9011. }
  9012. }
  9013. }
  9014. func (c *HisApiController) GetUploadInfo() {
  9015. id, _ := c.GetInt64("id")
  9016. record_time := c.GetString("record_time")
  9017. his_patient_id, _ := c.GetInt64("his_patient_id")
  9018. order_id, _ := c.GetInt64("order_id")
  9019. pay_way, _ := c.GetInt64("pay_way")
  9020. pay_ways := c.GetString("pay_ways")
  9021. oth_desc := c.GetString("oth_desc")
  9022. pay_price, _ := c.GetFloat("pay_price")
  9023. pay_card_no := c.GetString("pay_card_no")
  9024. discount_price, _ := c.GetFloat("discount_price")
  9025. preferential_price, _ := c.GetFloat("preferential_price")
  9026. reality_price, _ := c.GetFloat("reality_price")
  9027. found_price, _ := c.GetFloat("found_price")
  9028. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  9029. private_price, _ := c.GetFloat("private_price")
  9030. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9031. admin_user_id, _ := c.GetInt64("admin_user_id")
  9032. fapiao_code := c.GetString("fapiao_code")
  9033. fapiao_number := c.GetString("fapiao_number")
  9034. diagnosis_id := c.GetString("diagnosis")
  9035. sick_type, _ := c.GetInt64("sick_type")
  9036. reg_type, _ := c.GetInt64("p_type")
  9037. begin_time := c.GetString("begin_time")
  9038. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  9039. cash_pay := c.GetString("cash_pay")
  9040. band_card_pay := c.GetString("band_card_pay")
  9041. wechat_pay := c.GetString("wechat_pay")
  9042. ali_pay := c.GetString("ali_pay")
  9043. jifen_pay := c.GetString("jifen_pay")
  9044. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  9045. fmt.Println(acct_used_flag)
  9046. id_str := c.GetString("ids")
  9047. ids_arr := strings.Split(id_str, ",")
  9048. timeLayout := "2006-01-02"
  9049. loc, _ := time.LoadLocation("Local")
  9050. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9051. if err != nil {
  9052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9053. return
  9054. }
  9055. recordDateTime := theTime.Unix()
  9056. adminUser := c.GetAdminUserInfo()
  9057. var tempOrder models.HisOrder
  9058. tempOrder, _ = service.GetHisOrderByID(order_id)
  9059. var prescriptions []*models.HisPrescription
  9060. var start_time int64
  9061. var end_time int64
  9062. //押金模块
  9063. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  9064. tmp_decimal := c.GetString("tmp_decimal")
  9065. var decimal float64 //本次使用的押金
  9066. var errmsg error
  9067. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  9068. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  9069. return
  9070. }
  9071. if len(tmp_decimal) > 0 {
  9072. if tmp_decimal[0] == 45 {
  9073. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  9074. return
  9075. }
  9076. }
  9077. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  9078. fmt.Println(errs)
  9079. decimal = tt
  9080. //if adminUser.CurrentOrgId == 10106{
  9081. // if len(fapiao_code) == 0{
  9082. // fapiao_code = "144072080589"
  9083. // }
  9084. // if len(fapiao_number) == 0{
  9085. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  9086. // if order.ID == 0{
  9087. // fapiao_number = "00001520"
  9088. // }else{
  9089. // //fapiao_code = "00001520"
  9090. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  9091. // var zero string
  9092. // if fpNumber >= 1000{
  9093. // zero = "0000" + strconv.Itoa(fpNumber)
  9094. // }else if fpNumber >= 10000{
  9095. // zero = "000" + strconv.Itoa(fpNumber)
  9096. // } else if fpNumber >= 100000{
  9097. // zero = "00" + strconv.Itoa(fpNumber)
  9098. // } else if fpNumber >= 1000000{
  9099. // zero = "0" + strconv.Itoa(fpNumber)
  9100. // }else {
  9101. // zero = strconv.Itoa(fpNumber)
  9102. // }
  9103. // fapiao_number = zero
  9104. // }
  9105. // }
  9106. //}
  9107. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9108. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9109. var patientPrescription models.HisPrescriptionInfo
  9110. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9111. if patientPrescription.ID == 0 {
  9112. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9113. }
  9114. //if patientPrescription.Do
  9115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9116. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9117. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9118. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9119. var config []*models.HisXtDiagnoseConfig
  9120. for _, item := range diagnosis_ids {
  9121. id, _ := strconv.ParseInt(item, 10, 64)
  9122. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9123. config = append(config, &diagnosisConfig)
  9124. }
  9125. sickConfig, _ := service.FindSickById(sick_type)
  9126. //if tempOrder.ID == 0 {
  9127. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  9128. //}
  9129. if tempOrder.ID == 0 {
  9130. var result string
  9131. var requestLog string
  9132. var res2 ResultSix
  9133. var ressix10265 ResultSix10265
  9134. if miConfig.MdtrtareaAdmvs == "421300" {
  9135. data := make(map[string]interface{})
  9136. client := &http.Client{}
  9137. data["psn_no"] = his.PsnNo
  9138. data["mdtrt_id"] = his.Number
  9139. data["opter"] = roles.UserName
  9140. data["org_name"] = miConfig.OrgName
  9141. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9142. data["doctor_id"] = doctor_info.DoctorNumber
  9143. data["doctor_name"] = doctor_info.UserName
  9144. data["department"] = department.Name
  9145. data["fixmedins_code"] = miConfig.Code
  9146. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9147. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9148. data["secret_key"] = miConfig.SecretKey
  9149. data["sick_code"] = sickConfig.CountryCode
  9150. data["sick_name"] = sickConfig.ClassName
  9151. data["dept"] = strconv.FormatInt(department.ID, 10)
  9152. data["config"] = config
  9153. data["begin_time"] = begin_time
  9154. bytesData, _ := json.Marshal(data)
  9155. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9156. resp, _ := client.Do(req)
  9157. defer resp.Body.Close()
  9158. body, ioErr := ioutil.ReadAll(resp.Body)
  9159. if ioErr != nil {
  9160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9162. return
  9163. }
  9164. var respJSON map[string]interface{}
  9165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9168. return
  9169. }
  9170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9171. userJSONBytes, _ := json.Marshal(respJSON)
  9172. fmt.Println("log")
  9173. fmt.Println(string(userJSONBytes))
  9174. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9175. utils.ErrorLog("解析失败:%v", err)
  9176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9177. return
  9178. }
  9179. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9180. data := make(map[string]interface{})
  9181. client := &http.Client{}
  9182. data["psn_no"] = his.PsnNo
  9183. data["mdtrt_id"] = his.Number
  9184. data["doctor"] = roles.UserName
  9185. data["department"] = department.Name
  9186. data["org_name"] = miConfig.OrgName
  9187. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9188. data["doctor_id"] = doctor_info.DoctorNumber
  9189. data["new_doctor_name"] = doctor_info.UserName
  9190. data["fixmedins_code"] = miConfig.Code
  9191. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9192. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9193. data["secret_key"] = miConfig.SecretKey
  9194. data["sick_code"] = sickConfig.CountryCode
  9195. data["sick_name"] = sickConfig.ClassName
  9196. data["url"] = miConfig.Url
  9197. data["ak"] = miConfig.AccessKey
  9198. data["begin_time"] = begin_time
  9199. data["cainfo"] = miConfig.Cainfo
  9200. data["dept"] = strconv.FormatInt(department.ID, 10)
  9201. data["config"] = config
  9202. bytesData, _ := json.Marshal(data)
  9203. var req *http.Request
  9204. if miConfig.MdtrtareaAdmvs == "320921" {
  9205. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9206. //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 +
  9207. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  9208. } else {
  9209. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9210. }
  9211. resp, _ := client.Do(req)
  9212. defer resp.Body.Close()
  9213. body, ioErr := ioutil.ReadAll(resp.Body)
  9214. if ioErr != nil {
  9215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9217. return
  9218. }
  9219. var respJSON map[string]interface{}
  9220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9223. return
  9224. }
  9225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9226. userJSONBytes, _ := json.Marshal(respJSON)
  9227. fmt.Println("log")
  9228. fmt.Println(string(userJSONBytes))
  9229. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  9230. utils.ErrorLog("解析失败:%v", err)
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9232. return
  9233. }
  9234. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9235. res2.Output = ressix10265.Output
  9236. res2.ErrMsg = ressix10265.ErrMsg
  9237. res2.Cainfo = ressix10265.Cainfo
  9238. res2.WarnMsg = ressix10265.WarnMsg
  9239. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9240. res2.Infcode = infocode
  9241. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9242. 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)
  9243. saveLog(result, requestLog, "2203", "上传就诊信息")
  9244. var respJSON2 map[string]interface{}
  9245. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9248. return
  9249. }
  9250. userJSONBytes2, _ := json.Marshal(respJSON2)
  9251. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9252. utils.ErrorLog("解析失败:%v", err)
  9253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9254. return
  9255. }
  9256. 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)
  9257. fmt.Println(result2)
  9258. fmt.Println(src_request)
  9259. } else {
  9260. if miConfig.MdtrtareaAdmvs == "440781" { //
  9261. 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)
  9262. } else {
  9263. if miConfig.Code == "H15049901371" {
  9264. //赤峰地区国家医保医疗类别
  9265. //职工透析:医疗类别选特殊情况门诊990502
  9266. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9267. var med_type string
  9268. if his.Insutype == "390" {
  9269. if reg_type == 14 {
  9270. med_type = "9933"
  9271. } else if reg_type == 11 {
  9272. med_type = "11"
  9273. }
  9274. } else if his.Insutype == "310" {
  9275. if reg_type == 14 {
  9276. med_type = "990502"
  9277. } else if reg_type == 11 {
  9278. med_type = "11"
  9279. }
  9280. }
  9281. 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)
  9282. } else {
  9283. 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)
  9284. }
  9285. }
  9286. saveLog(result, requestLog, "2203", "上传就诊信息")
  9287. var respJSON2 map[string]interface{}
  9288. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9291. return
  9292. }
  9293. userJSONBytes2, _ := json.Marshal(respJSON2)
  9294. if miConfig.Code == "H15049901371" {
  9295. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  9296. utils.ErrorLog("解析失败:%v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9301. res2.Output = ressix10265.Output
  9302. res2.ErrMsg = ressix10265.ErrMsg
  9303. res2.Cainfo = ressix10265.Cainfo
  9304. res2.WarnMsg = ressix10265.WarnMsg
  9305. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9306. res2.Infcode = infocode
  9307. } else {
  9308. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9309. utils.ErrorLog("解析失败:%v", err)
  9310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9311. return
  9312. }
  9313. }
  9314. }
  9315. if res2.Infcode != 0 {
  9316. adminUser := c.GetAdminUserInfo()
  9317. errlog := &models.HisOrderError{
  9318. UserOrgId: adminUser.CurrentOrgId,
  9319. Ctime: time.Now().Unix(),
  9320. Mtime: time.Now().Unix(),
  9321. ErrMsg: res2.ErrMsg,
  9322. Status: 1,
  9323. PatientId: id,
  9324. RecordTime: recordDateTime,
  9325. Stage: 3,
  9326. }
  9327. service.CreateErrMsgLog(errlog)
  9328. c.ServeSuccessJSON(map[string]interface{}{
  9329. "failed_code": -10,
  9330. "msg": res2.ErrMsg,
  9331. })
  9332. return
  9333. } else {
  9334. his.Diagnosis = diagnosis_id
  9335. his.SickType = sickConfig.ID
  9336. //var p_type int64
  9337. //if reg_type == 1111 || reg_type == 1112 {
  9338. // p_type = 11
  9339. //
  9340. //}
  9341. his.PType = fmt.Sprintf("%d", reg_type)
  9342. service.UpdateHisPatientThree(&his)
  9343. data := make(map[string]interface{})
  9344. if settle_accounts_type == 1 { //日结
  9345. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9346. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9347. } else {
  9348. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9349. }
  9350. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  9351. data["pre"] = prescriptions
  9352. } else { //月结
  9353. start_time_str := c.GetString("start_time")
  9354. end_time_str := c.GetString("end_time")
  9355. timeLayout := "2006-01-02"
  9356. loc, _ := time.LoadLocation("Local")
  9357. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9358. if err != nil {
  9359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9360. return
  9361. }
  9362. recordStartTime := theStartTime.Unix()
  9363. start_time = recordStartTime
  9364. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9365. if err != nil {
  9366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9367. return
  9368. }
  9369. recordEndTime := theEndTime.Unix()
  9370. end_time = recordEndTime
  9371. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9372. data["pre"] = prescriptions
  9373. }
  9374. timestamp := time.Now().Unix()
  9375. tempTime := time.Unix(timestamp, 0)
  9376. timeFormat := tempTime.Format("20060102150405")
  9377. chrgBchno := rand.Intn(100000) + 10000
  9378. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9379. strconv.FormatInt(his.PatientId, 10)
  9380. client := &http.Client{}
  9381. data["psn_no"] = his.PsnNo
  9382. data["mdtrt_id"] = his.Number
  9383. data["chrg_bchno"] = chrg_bchno
  9384. data["org_name"] = miConfig.OrgName
  9385. data["doctor"] = doctor_info.UserName
  9386. data["doctor_id"] = doctor_info.DoctorNumber
  9387. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9388. data["fixmedins_code"] = miConfig.Code
  9389. data["opter"] = roles.UserName
  9390. data["dept_code"] = department.Number
  9391. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9392. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9393. data["secret_key"] = miConfig.SecretKey
  9394. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9395. data["url"] = miConfig.Url
  9396. data["ak"] = miConfig.AccessKey
  9397. data["new_doctor_name"] = patientPrescription.Doctor
  9398. data["diag_code"] = sickConfig.CountryCode
  9399. data["cainfo"] = miConfig.Cainfo
  9400. data["opter"] = roles.UserName
  9401. var ids []int64
  9402. for _, item := range prescriptions {
  9403. ids = append(ids, item.ID)
  9404. }
  9405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9406. if config.IsOpen == 1 { //对接了医保,走医保流程
  9407. var res ResultFour
  9408. var resFour10265 ResultFour10265
  9409. if miConfig.MdtrtareaAdmvs == "421300" {
  9410. bytesData, _ := json.Marshal(data)
  9411. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9412. resp, _ := client.Do(req)
  9413. defer resp.Body.Close()
  9414. body, ioErr := ioutil.ReadAll(resp.Body)
  9415. if ioErr != nil {
  9416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. var respJSON map[string]interface{}
  9421. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9424. return
  9425. }
  9426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9427. userJSONBytes, _ := json.Marshal(respJSON)
  9428. fmt.Println("log")
  9429. fmt.Println(string(userJSONBytes))
  9430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9431. utils.ErrorLog("解析失败:%v", err)
  9432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9433. return
  9434. }
  9435. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9436. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9437. if result3101.Infcode == "0" {
  9438. if len(result3101.Output.Result) > 0 {
  9439. var errMsgs []string
  9440. for _, item := range result3101.Output.Result {
  9441. errMsgs = append(errMsgs, item.VolaCont)
  9442. }
  9443. c.ServeSuccessJSON(map[string]interface{}{
  9444. "failed_code": -10,
  9445. "msg": errMsgs,
  9446. })
  9447. return
  9448. }
  9449. }
  9450. if miConfig.MdtrtareaAdmvs == "320921" {
  9451. data["doctor_id"] = "D320923012139"
  9452. } else {
  9453. data["doctor_id"] = "D371621008686"
  9454. }
  9455. bytesData, _ := json.Marshal(data)
  9456. var req *http.Request
  9457. if miConfig.MdtrtareaAdmvs == "320921" {
  9458. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9459. } else {
  9460. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9461. }
  9462. resp, _ := client.Do(req)
  9463. defer resp.Body.Close()
  9464. body, ioErr := ioutil.ReadAll(resp.Body)
  9465. if ioErr != nil {
  9466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9468. return
  9469. }
  9470. var respJSON map[string]interface{}
  9471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. return
  9475. }
  9476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9477. userJSONBytes, _ := json.Marshal(respJSON)
  9478. fmt.Println("log")
  9479. fmt.Println(string(userJSONBytes))
  9480. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9481. utils.ErrorLog("解析失败:%v", err)
  9482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9483. return
  9484. }
  9485. res.InfRefmsgid = resFour10265.InfRefmsgid
  9486. res.Output = resFour10265.Output
  9487. res.ErrMsg = resFour10265.ErrMsg
  9488. res.Cainfo = resFour10265.Cainfo
  9489. res.WarnMsg = resFour10265.WarnMsg
  9490. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9491. res.Infcode = infocode
  9492. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9493. 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)
  9494. var dat map[string]interface{}
  9495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9496. fmt.Println(dat)
  9497. } else {
  9498. fmt.Println(err)
  9499. }
  9500. saveLog(result, request_log, "2204", "上传费用明细")
  9501. userJSONBytes, _ := json.Marshal(dat)
  9502. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9503. utils.ErrorLog("解析失败:%v", err)
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9505. return
  9506. }
  9507. res.InfRefmsgid = resFour10265.InfRefmsgid
  9508. res.Output = resFour10265.Output
  9509. res.ErrMsg = resFour10265.ErrMsg
  9510. res.Cainfo = resFour10265.Cainfo
  9511. res.WarnMsg = resFour10265.WarnMsg
  9512. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9513. res.Infcode = infocode
  9514. } else {
  9515. if miConfig.Code == "H15049901371" {
  9516. 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)
  9517. var dat map[string]interface{}
  9518. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9519. fmt.Println(dat)
  9520. } else {
  9521. fmt.Println(err)
  9522. }
  9523. saveLog(result, request_log, "2204", "上传费用明细")
  9524. userJSONBytes, _ := json.Marshal(dat)
  9525. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9526. utils.ErrorLog("解析失败:%v", err)
  9527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9528. return
  9529. }
  9530. res.InfRefmsgid = resFour10265.InfRefmsgid
  9531. res.Output = resFour10265.Output
  9532. res.ErrMsg = resFour10265.ErrMsg
  9533. res.Cainfo = resFour10265.Cainfo
  9534. res.WarnMsg = resFour10265.WarnMsg
  9535. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9536. res.Infcode = infocode
  9537. } else {
  9538. 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)
  9539. var dat map[string]interface{}
  9540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9541. fmt.Println(dat)
  9542. } else {
  9543. fmt.Println(err)
  9544. }
  9545. saveLog(result, request_log, "2204", "上传费用明细")
  9546. userJSONBytes, _ := json.Marshal(dat)
  9547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9548. utils.ErrorLog("解析失败:%v", err)
  9549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. return
  9551. }
  9552. }
  9553. }
  9554. if res.Infcode == 0 {
  9555. order := &models.HisOrder{
  9556. UserOrgId: adminUser.CurrentOrgId,
  9557. HisPatientId: his.ID,
  9558. PatientId: his.PatientId,
  9559. SettleAccountsDate: recordDateTime,
  9560. MdtrtId: his.Number,
  9561. PsnNo: his.PsnNo,
  9562. MedType: strconv.FormatInt(reg_type, 10),
  9563. Ctime: time.Now().Unix(),
  9564. Mtime: time.Now().Unix(),
  9565. Status: 1,
  9566. Number: chrg_bchno,
  9567. Infcode: res.Infcode,
  9568. WarnMsg: res.WarnMsg,
  9569. Cainfo: res.Cainfo,
  9570. ErrMsg: res.ErrMsg,
  9571. RespondTime: res.RefmsgTime,
  9572. InfRefmsgid: res.InfRefmsgid,
  9573. OrderStatus: 1,
  9574. PayWay: pay_way,
  9575. PayWays: pay_ways,
  9576. OthDesc: oth_desc,
  9577. PayPrice: pay_price,
  9578. PayCardNo: pay_card_no,
  9579. DiscountPrice: discount_price,
  9580. PreferentialPrice: preferential_price,
  9581. RealityPrice: reality_price,
  9582. FoundPrice: found_price,
  9583. MedicalInsurancePrice: medical_insurance_price,
  9584. PrivatePrice: private_price,
  9585. IsMedicineInsurance: 1,
  9586. SettleType: settle_accounts_type,
  9587. SettleStartTime: start_time,
  9588. SettleEndTime: end_time,
  9589. Creator: roles.AdminUserId,
  9590. Modify: roles.AdminUserId,
  9591. FaPiaoNumber: fapiao_number,
  9592. FaPiaoCode: fapiao_code,
  9593. PType: 2,
  9594. Diagnosis: diagnosis_id,
  9595. CashPay: cash_pay,
  9596. WechatPay: wechat_pay,
  9597. AliPay: ali_pay,
  9598. JifenPay: jifen_pay,
  9599. BandCardPay: band_card_pay,
  9600. }
  9601. err = service.CreateOrder(order)
  9602. if err != nil {
  9603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9604. return
  9605. }
  9606. for _, item := range res.Output.Result {
  9607. temp := strings.Split(item.FeedetlSn, "-")
  9608. var advice_id int64 = 0
  9609. var project_id int64 = 0
  9610. var types int64 = 0
  9611. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9612. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9613. if temp[1] == "1" {
  9614. advice_id = id
  9615. project_id = 0
  9616. } else if temp[1] == "2" {
  9617. advice_id = 0
  9618. project_id = id
  9619. }
  9620. if item.MedChrgitmType == "9" {
  9621. item.MedChrgitmType = "09"
  9622. }
  9623. info := &models.HisOrderInfo{
  9624. OrderNumber: order.Number,
  9625. FeedetlSn: item.FeedetlSn,
  9626. UploadDate: time.Now().Unix(),
  9627. AdviceId: advice_id,
  9628. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9629. Cnt: item.Cnt,
  9630. Pric: float64(item.Pric),
  9631. PatientId: his.PatientId,
  9632. PricUplmtAmt: item.PricUplmtAmt,
  9633. SelfpayProp: item.SelfpayProp,
  9634. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9635. OverlmtAmt: item.OverlmtAmt,
  9636. PreselfpayAmt: item.PreselfpayAmt,
  9637. BasMednFlag: item.BasMednFlag,
  9638. MedChrgitmType: item.MedChrgitmType,
  9639. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9640. Status: 1,
  9641. Memo: item.Memo,
  9642. Mtime: time.Now().Unix(),
  9643. InscpScpAmt: item.InscpScpAmt,
  9644. DrtReimFlag: item.DrtReimFlag,
  9645. Ctime: time.Now().Unix(),
  9646. ListSpItemFlag: item.ListSpItemFlag,
  9647. ChldMedcFlag: item.ChldMedcFlag,
  9648. LmtUsedFlag: item.LmtUsedFlag,
  9649. ChrgitmLv: item.ChrgitmLv,
  9650. UserOrgId: adminUser.CurrentOrgId,
  9651. HisPatientId: his.ID,
  9652. OrderId: order.ID,
  9653. ProjectId: project_id,
  9654. Type: types,
  9655. }
  9656. service.CreateOrderInfo(info)
  9657. }
  9658. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9659. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9660. var total float64
  9661. for _, item := range prescriptions {
  9662. if item.Type == 1 { //药品
  9663. for _, subItem := range item.HisDoctorAdviceInfo {
  9664. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9665. total_one := price * subItem.PrescribingNumber
  9666. total = total + total_one
  9667. }
  9668. }
  9669. if item.Type == 2 { //项目
  9670. for _, subItem := range item.HisPrescriptionProject {
  9671. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9672. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9673. total_one := price * cnt
  9674. total = total + total_one
  9675. }
  9676. }
  9677. }
  9678. allTotal := fmt.Sprintf("%f", total)
  9679. //if adminUser.CurrentOrgId == 9919 {
  9680. //
  9681. // allTotal = fmt.Sprintf("%.2f", total)
  9682. //
  9683. //} else {
  9684. //
  9685. // allTotal = fmt.Sprintf("%.2f", total)
  9686. //
  9687. //}
  9688. if res.Infcode == 0 {
  9689. var rf []*ResultFive
  9690. json.Unmarshal([]byte(his.Iinfo), &rf)
  9691. chrg_bchno := chrg_bchno
  9692. cert_no := his.Certno
  9693. var insutypes []string
  9694. var insutype string
  9695. var is390 int = 0
  9696. var is310 int = 0
  9697. for _, item := range rf {
  9698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9699. insutypes = append(insutypes, item.Insutype)
  9700. }
  9701. }
  9702. if len(insutypes) == 1 {
  9703. insutype = insutypes[0]
  9704. } else {
  9705. for _, i := range insutypes {
  9706. if i == "390" {
  9707. is390 = 1
  9708. }
  9709. if i == "310" {
  9710. is310 = 1
  9711. }
  9712. }
  9713. }
  9714. if is390 == 1 {
  9715. insutype = "390"
  9716. }
  9717. if is310 == 1 {
  9718. insutype = "310"
  9719. }
  9720. if len(insutypes) == 0 {
  9721. insutype = "310"
  9722. }
  9723. if len(insutypes) == 2 {
  9724. insutype = strconv.FormatInt(his.SocialType, 10)
  9725. }
  9726. insutype = strconv.FormatInt(his.SocialType, 10)
  9727. //insutype = "390"
  9728. if his.IdCardType == 1 {
  9729. // cert_no = his.MedicalInsuranceNumber
  9730. cert_no = his.Certno
  9731. } else {
  9732. cert_no = his.Certno
  9733. }
  9734. var res ResultSeven
  9735. var resSeven10265 ResultSeven10265
  9736. var src_resquest string
  9737. var result2 string
  9738. if miConfig.MdtrtareaAdmvs == "421300" {
  9739. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9740. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9741. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9743. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9744. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9745. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9746. resp, requestErr := http.Get(api)
  9747. if requestErr != nil {
  9748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9749. return
  9750. }
  9751. body, ioErr := ioutil.ReadAll(resp.Body)
  9752. if ioErr != nil {
  9753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9755. return
  9756. }
  9757. var respJSON map[string]interface{}
  9758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9761. return
  9762. }
  9763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9764. result, _ := json.Marshal(respJSON)
  9765. if miConfig.Code == "H15049901371" {
  9766. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9772. res.Output = resSeven10265.Output
  9773. res.ErrMsg = resSeven10265.ErrMsg
  9774. res.Cainfo = resSeven10265.Cainfo
  9775. res.WarnMsg = resSeven10265.WarnMsg
  9776. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9777. res.Infcode = infocode
  9778. } else {
  9779. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9780. utils.ErrorLog("解析失败:%v", err)
  9781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9782. return
  9783. }
  9784. }
  9785. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9786. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  9787. if result3101.Infcode == "0" {
  9788. if len(result3101.Output.Result) > 0 {
  9789. var errMsgs []string
  9790. for _, item := range result3101.Output.Result {
  9791. errMsgs = append(errMsgs, item.VolaCont)
  9792. }
  9793. c.ServeSuccessJSON(map[string]interface{}{
  9794. "failed_code": -10,
  9795. "msg": errMsgs,
  9796. })
  9797. return
  9798. } else {
  9799. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9800. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9801. bas := strings.Split(psn_info.CardInfo, "|")
  9802. if his.IdCardType == 1 {
  9803. cert_no = bas[2]
  9804. } else if his.IdCardType == 3 {
  9805. cert_no = his.Certno
  9806. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9807. } else if his.IdCardType == 4 {
  9808. cert_no = his.Certno
  9809. psn_info.VerifyNumber = psn_info.VerifyNumber
  9810. }
  9811. var api string
  9812. if miConfig.MdtrtareaAdmvs == "320921" {
  9813. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9814. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9815. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9817. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9818. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9819. "&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
  9820. } else {
  9821. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9822. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9823. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9825. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9826. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9827. "&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
  9828. }
  9829. resp, requestErr := http.Get(api)
  9830. if requestErr != nil {
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. body, ioErr := ioutil.ReadAll(resp.Body)
  9835. if ioErr != nil {
  9836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9838. return
  9839. }
  9840. var respJSON map[string]interface{}
  9841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9844. return
  9845. }
  9846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9847. result, _ := json.Marshal(respJSON)
  9848. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9849. utils.ErrorLog("解析失败:%v", err)
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9851. return
  9852. }
  9853. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9854. res.Output = resSeven10265.Output
  9855. res.ErrMsg = resSeven10265.ErrMsg
  9856. res.Cainfo = resSeven10265.Cainfo
  9857. res.WarnMsg = resSeven10265.WarnMsg
  9858. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9859. res.Infcode = infocode
  9860. }
  9861. }
  9862. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9863. var cert_no string
  9864. if his.IdCardType == 4 {
  9865. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9866. cert_no = psn_info.VerifyNumber
  9867. 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)
  9868. } else if his.IdCardType == 1 {
  9869. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9870. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9871. 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)
  9872. }
  9873. //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)
  9874. var dat map[string]interface{}
  9875. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9876. fmt.Println(dat)
  9877. } else {
  9878. fmt.Println(err)
  9879. }
  9880. saveLog(result2, src_resquest, "2207", "结算")
  9881. userJSONBytes, _ := json.Marshal(dat)
  9882. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9883. utils.ErrorLog("解析失败:%v", err)
  9884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9885. return
  9886. }
  9887. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9888. res.Output = resSeven10265.Output
  9889. res.ErrMsg = resSeven10265.ErrMsg
  9890. res.Cainfo = resSeven10265.Cainfo
  9891. res.WarnMsg = resSeven10265.WarnMsg
  9892. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9893. res.Infcode = infocode
  9894. } else {
  9895. if miConfig.Code == "H15049901371" {
  9896. //赤峰地区国家医保医疗类别
  9897. //职工透析:医疗类别选特殊情况门诊990502
  9898. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9899. var med_type string
  9900. if his.Insutype == "390" {
  9901. if reg_type == 14 {
  9902. med_type = "9933"
  9903. } else if reg_type == 11 {
  9904. med_type = "11"
  9905. }
  9906. } else if his.Insutype == "310" {
  9907. if reg_type == 14 {
  9908. med_type = "990502"
  9909. } else if reg_type == 11 {
  9910. med_type = "11"
  9911. }
  9912. }
  9913. 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, "")
  9914. } else {
  9915. if his.IdCardType == 4 {
  9916. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9917. var token string
  9918. token = psn_info.VerifyNumber
  9919. 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)
  9920. } else {
  9921. 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, "")
  9922. }
  9923. }
  9924. //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)
  9925. var dat map[string]interface{}
  9926. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9927. fmt.Println(dat)
  9928. } else {
  9929. fmt.Println(err)
  9930. }
  9931. saveLog(result2, src_resquest, "2207", "结算")
  9932. userJSONBytes, _ := json.Marshal(dat)
  9933. if miConfig.Code == "H15049901371" {
  9934. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9935. utils.ErrorLog("解析失败:%v", err)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9940. res.Output = resSeven10265.Output
  9941. res.ErrMsg = resSeven10265.ErrMsg
  9942. res.Cainfo = resSeven10265.Cainfo
  9943. res.WarnMsg = resSeven10265.WarnMsg
  9944. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9945. res.Infcode = infocode
  9946. } else {
  9947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9948. utils.ErrorLog("解析失败:%v", err)
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9950. return
  9951. }
  9952. }
  9953. }
  9954. if res.Infcode != 0 {
  9955. errlog := &models.HisOrderError{
  9956. UserOrgId: adminUser.CurrentOrgId,
  9957. Ctime: time.Now().Unix(),
  9958. Mtime: time.Now().Unix(),
  9959. Number: chrg_bchno,
  9960. ErrMsg: res.ErrMsg,
  9961. Status: 1,
  9962. PatientId: id,
  9963. RecordTime: recordDateTime,
  9964. Stage: 6,
  9965. }
  9966. service.CreateErrMsgLog(errlog)
  9967. c.ServeSuccessJSON(map[string]interface{}{
  9968. "failed_code": -10,
  9969. "msg": res.ErrMsg,
  9970. })
  9971. return
  9972. } else {
  9973. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9974. order.OrderStatus = 2
  9975. order.Status = 1
  9976. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9977. order.SetlId = res.Output.Setlinfo.SetlID
  9978. order.PsnNo = res.Output.Setlinfo.PsnNo
  9979. order.PsnName = res.Output.Setlinfo.PsnName
  9980. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9981. order.Certno = res.Output.Setlinfo.Certno
  9982. order.Gend = res.Output.Setlinfo.Gend
  9983. order.Naty = res.Output.Setlinfo.Naty
  9984. order.Age = res.Output.Setlinfo.Age
  9985. order.Insutype = res.Output.Setlinfo.Insutype
  9986. order.PsnType = res.Output.Setlinfo.PsnType
  9987. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9988. order.SetlTime = res.Output.Setlinfo.SetlTime
  9989. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9990. if res.Output.Setlinfo.MedType == "140101" {
  9991. order.MedType = "14"
  9992. } else {
  9993. order.MedType = res.Output.Setlinfo.MedType
  9994. }
  9995. if reg_type == 1112 {
  9996. order.MedType = "1112"
  9997. }
  9998. if reg_type == 1111 {
  9999. order.MedType = "1111"
  10000. }
  10001. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10002. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10003. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10004. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10005. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10006. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10007. order.HifpPay = res.Output.Setlinfo.HifpPay
  10008. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10009. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10010. order.HifesPay = res.Output.Setlinfo.HifesPay
  10011. order.HifobPay = res.Output.Setlinfo.HifobPay
  10012. order.MafPay = res.Output.Setlinfo.MafPay
  10013. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10014. order.OthPay = res.Output.Setlinfo.OthPay
  10015. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10016. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10017. order.AcctPay = res.Output.Setlinfo.AcctPay
  10018. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10019. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10020. order.Balc = res.Output.Setlinfo.Balc
  10021. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10022. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10023. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10024. order.ClrType = res.Output.Setlinfo.ClrType
  10025. order.ClrWay = res.Output.Setlinfo.ClrWay
  10026. order.Creator = order.Creator
  10027. order.Modify = roles.AdminUserId
  10028. order.RequestLog = src_resquest
  10029. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10030. detailStr := string(setlDetail)
  10031. order.SetlDetail = detailStr
  10032. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10033. err = service.UpDateOrder(order)
  10034. if err == nil {
  10035. //判断是否使用了押金
  10036. if dec_way == "true" {
  10037. tmpstring := strconv.FormatInt(order.ID, 10)
  10038. order.Decimal = decimal
  10039. service.UpDateOrder(order)
  10040. //扣押金
  10041. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10042. if errmsg != nil {
  10043. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10044. return
  10045. }
  10046. }
  10047. c.ServeSuccessJSON(map[string]interface{}{
  10048. "msg": "结算成功",
  10049. })
  10050. } else {
  10051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10052. return
  10053. }
  10054. }
  10055. } else {
  10056. adminUser := c.GetAdminUserInfo()
  10057. errlog := &models.HisOrderError{
  10058. UserOrgId: adminUser.CurrentOrgId,
  10059. Ctime: time.Now().Unix(),
  10060. Mtime: time.Now().Unix(),
  10061. ErrMsg: res.ErrMsg,
  10062. Status: 1,
  10063. PatientId: id,
  10064. RecordTime: recordDateTime,
  10065. Stage: 4,
  10066. }
  10067. service.CreateErrMsgLog(errlog)
  10068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10069. return
  10070. }
  10071. } else {
  10072. adminUser := c.GetAdminUserInfo()
  10073. errlog := &models.HisOrderError{
  10074. UserOrgId: adminUser.CurrentOrgId,
  10075. Ctime: time.Now().Unix(),
  10076. Mtime: time.Now().Unix(),
  10077. ErrMsg: res.ErrMsg,
  10078. Status: 1,
  10079. PatientId: id,
  10080. RecordTime: recordDateTime,
  10081. Stage: 4,
  10082. }
  10083. service.CreateErrMsgLog(errlog)
  10084. c.ServeSuccessJSON(map[string]interface{}{
  10085. "failed_code": -10,
  10086. "msg": res.ErrMsg,
  10087. })
  10088. return
  10089. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10090. //return
  10091. }
  10092. }
  10093. }
  10094. } else if tempOrder.ID > 0 {
  10095. if tempOrder.IsPre == 1 {
  10096. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  10097. var rf []*ResultFive
  10098. json.Unmarshal([]byte(his.Iinfo), &rf)
  10099. chrg_bchno := tempOrder.Number
  10100. cert_no := his.Certno
  10101. var insutypes []string
  10102. var insutype string
  10103. var is390 int = 0
  10104. var is310 int = 0
  10105. for _, item := range rf {
  10106. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10107. insutypes = append(insutypes, item.Insutype)
  10108. }
  10109. }
  10110. if len(insutypes) == 1 {
  10111. insutype = insutypes[0]
  10112. } else {
  10113. for _, i := range insutypes {
  10114. if i == "390" {
  10115. is390 = 1
  10116. }
  10117. if i == "310" {
  10118. is310 = 1
  10119. }
  10120. }
  10121. }
  10122. if is390 == 1 {
  10123. insutype = "390"
  10124. }
  10125. if is310 == 1 {
  10126. insutype = "310"
  10127. }
  10128. if len(insutypes) == 0 {
  10129. insutype = "310"
  10130. }
  10131. if len(insutypes) == 2 {
  10132. insutype = strconv.FormatInt(his.SocialType, 10)
  10133. }
  10134. //insutype = "390"
  10135. if his.IdCardType == 1 {
  10136. // cert_no = his.MedicalInsuranceNumber
  10137. cert_no = his.Certno
  10138. } else {
  10139. cert_no = his.Certno
  10140. }
  10141. var res ResultSeven
  10142. var resSeven10265 ResultSeven10265
  10143. var src_resquest string
  10144. var result2 string
  10145. if miConfig.MdtrtareaAdmvs == "421300" {
  10146. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10147. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10148. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10149. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10150. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10151. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10152. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10153. resp, requestErr := http.Get(api)
  10154. if requestErr != nil {
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. return
  10157. }
  10158. body, ioErr := ioutil.ReadAll(resp.Body)
  10159. if ioErr != nil {
  10160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. var respJSON map[string]interface{}
  10165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. return
  10169. }
  10170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10171. result, _ := json.Marshal(respJSON)
  10172. fmt.Println("log")
  10173. fmt.Println(string(result))
  10174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10175. utils.ErrorLog("解析失败:%v", err)
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10180. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  10181. if result3101.Infcode == "0" {
  10182. if len(result3101.Output.Result) > 0 {
  10183. var errMsgs []string
  10184. for _, item := range result3101.Output.Result {
  10185. errMsgs = append(errMsgs, item.VolaCont)
  10186. }
  10187. c.ServeSuccessJSON(map[string]interface{}{
  10188. "failed_code": -10,
  10189. "msg": errMsgs,
  10190. })
  10191. return
  10192. } else {
  10193. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10194. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10195. bas := strings.Split(psn_info.CardInfo, "|")
  10196. if his.IdCardType == 1 {
  10197. cert_no = bas[2]
  10198. } else if his.IdCardType == 3 {
  10199. cert_no = his.Certno
  10200. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10201. } else if his.IdCardType == 4 {
  10202. cert_no = his.Certno
  10203. psn_info.VerifyNumber = psn_info.VerifyNumber
  10204. }
  10205. //江苏地区国家医保医疗类别
  10206. //职工透析:医疗类别选特殊情况门诊9933
  10207. //居民血透门慢: 医疗类别选门诊慢病1402
  10208. //var med_type string
  10209. //if his.Insutype == "310" {
  10210. // if reg_type == 14 {
  10211. // med_type = "9933"
  10212. // } else if reg_type == 11 {
  10213. // med_type = "11"
  10214. //
  10215. // }
  10216. //} else if his.Insutype == "390" {
  10217. // if reg_type == 14 {
  10218. // med_type = "1402"
  10219. // } else if reg_type == 11 {
  10220. // med_type = "11"
  10221. // }
  10222. //}
  10223. var api string
  10224. if miConfig.MdtrtareaAdmvs == "320921" {
  10225. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10226. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10227. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10228. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10229. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10230. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10231. "&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
  10232. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10233. } else {
  10234. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10235. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10236. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10237. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10239. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10240. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10241. "&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
  10242. }
  10243. resp, requestErr := http.Get(api)
  10244. if requestErr != nil {
  10245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10246. return
  10247. }
  10248. body, ioErr := ioutil.ReadAll(resp.Body)
  10249. if ioErr != nil {
  10250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10252. return
  10253. }
  10254. var respJSON map[string]interface{}
  10255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10258. return
  10259. }
  10260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10261. result, _ := json.Marshal(respJSON)
  10262. fmt.Println("log")
  10263. fmt.Println(string(result))
  10264. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10265. utils.ErrorLog("解析失败:%v", err)
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10267. return
  10268. }
  10269. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10270. res.Output = resSeven10265.Output
  10271. res.ErrMsg = resSeven10265.ErrMsg
  10272. res.Cainfo = resSeven10265.Cainfo
  10273. res.WarnMsg = resSeven10265.WarnMsg
  10274. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10275. res.Infcode = infocode
  10276. }
  10277. }
  10278. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10279. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10280. var cert_no string
  10281. if his.IdCardType == 1 {
  10282. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10283. } else {
  10284. cert_no = psn_info.VerifyNumber
  10285. }
  10286. 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)
  10287. var dat map[string]interface{}
  10288. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10289. fmt.Println(dat)
  10290. } else {
  10291. fmt.Println(err)
  10292. }
  10293. saveLog(result2, src_resquest, "2207", "结算")
  10294. userJSONBytes, _ := json.Marshal(dat)
  10295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10296. utils.ErrorLog("解析失败:%v", err)
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10298. return
  10299. }
  10300. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10301. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10302. var cert_no string
  10303. if his.IdCardType == 1 {
  10304. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10305. } else if his.IdCardType == 2 {
  10306. cert_no = his.IdCardNo
  10307. } else {
  10308. cert_no = psn_info.VerifyNumber
  10309. }
  10310. 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, "")
  10311. var dat map[string]interface{}
  10312. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10313. fmt.Println(dat)
  10314. } else {
  10315. fmt.Println(err)
  10316. }
  10317. saveLog(result2, src_resquest, "2207", "结算")
  10318. userJSONBytes, _ := json.Marshal(dat)
  10319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10320. utils.ErrorLog("解析失败:%v", err)
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10322. return
  10323. }
  10324. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10325. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10326. var cert_no string
  10327. if his.IdCardType == 1 {
  10328. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10329. } else if his.IdCardType == 2 {
  10330. cert_no = his.IdCardNo
  10331. } else {
  10332. cert_no = psn_info.VerifyNumber
  10333. }
  10334. 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, "")
  10335. var dat map[string]interface{}
  10336. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10337. fmt.Println(dat)
  10338. } else {
  10339. fmt.Println(err)
  10340. }
  10341. saveLog(result2, src_resquest, "2207", "结算")
  10342. userJSONBytes, _ := json.Marshal(dat)
  10343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10344. utils.ErrorLog("解析失败:%v", err)
  10345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10346. return
  10347. }
  10348. } else {
  10349. var src_resquest string
  10350. if miConfig.Code == "H15049901371" {
  10351. //赤峰地区国家医保医疗类别
  10352. //职工透析:医疗类别选特殊情况门诊990502
  10353. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10354. var med_type string
  10355. if his.Insutype == "390" {
  10356. if reg_type == 14 {
  10357. med_type = "9933"
  10358. } else if reg_type == 11 {
  10359. med_type = "11"
  10360. }
  10361. } else if his.Insutype == "310" {
  10362. if reg_type == 14 {
  10363. med_type = "990502"
  10364. } else if reg_type == 11 {
  10365. med_type = "11"
  10366. }
  10367. }
  10368. 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, "")
  10369. } else {
  10370. if his.IdCardType == 4 {
  10371. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10372. token := psn_info.VerifyNumber
  10373. 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)
  10374. } else {
  10375. 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, "")
  10376. }
  10377. }
  10378. var dat map[string]interface{}
  10379. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10380. fmt.Println(dat)
  10381. } else {
  10382. fmt.Println(err)
  10383. }
  10384. saveLog(result2, src_resquest, "2207", "结算")
  10385. userJSONBytes, _ := json.Marshal(dat)
  10386. if miConfig.Code == "H15049901371" {
  10387. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10388. utils.ErrorLog("解析失败:%v", err)
  10389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10390. return
  10391. }
  10392. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10393. res.Output = resSeven10265.Output
  10394. res.ErrMsg = resSeven10265.ErrMsg
  10395. res.Cainfo = resSeven10265.Cainfo
  10396. res.WarnMsg = resSeven10265.WarnMsg
  10397. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10398. res.Infcode = infocode
  10399. } else {
  10400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10401. utils.ErrorLog("解析失败:%v", err)
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10403. return
  10404. }
  10405. }
  10406. }
  10407. if res.Infcode != 0 {
  10408. errlog := &models.HisOrderError{
  10409. UserOrgId: adminUser.CurrentOrgId,
  10410. Ctime: time.Now().Unix(),
  10411. Mtime: time.Now().Unix(),
  10412. Number: chrg_bchno,
  10413. ErrMsg: res.ErrMsg,
  10414. Status: 1,
  10415. PatientId: id,
  10416. RecordTime: recordDateTime,
  10417. Stage: 6,
  10418. }
  10419. service.CreateErrMsgLog(errlog)
  10420. c.ServeSuccessJSON(map[string]interface{}{
  10421. "failed_code": -10,
  10422. "msg": res.ErrMsg,
  10423. })
  10424. return
  10425. } else {
  10426. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10427. order.OrderStatus = 2
  10428. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10429. order.SetlId = res.Output.Setlinfo.SetlID
  10430. order.PsnNo = res.Output.Setlinfo.PsnNo
  10431. order.PsnName = res.Output.Setlinfo.PsnName
  10432. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10433. order.Certno = res.Output.Setlinfo.Certno
  10434. order.Gend = res.Output.Setlinfo.Gend
  10435. order.Naty = res.Output.Setlinfo.Naty
  10436. order.Age = res.Output.Setlinfo.Age
  10437. order.Insutype = res.Output.Setlinfo.Insutype
  10438. order.PsnType = res.Output.Setlinfo.PsnType
  10439. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10440. order.SetlTime = res.Output.Setlinfo.SetlTime
  10441. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10442. order.PayWays = pay_ways
  10443. order.AcctUsedFlag = acct_used_flag
  10444. order.WechatPay = wechat_pay
  10445. order.AliPay = ali_pay
  10446. order.JifenPay = jifen_pay
  10447. order.BandCardPay = band_card_pay
  10448. order.CashPay = cash_pay
  10449. order.OthDesc = oth_desc
  10450. //order.MedType = res.Output.Setlinfo.MedType
  10451. if reg_type == 1112 {
  10452. order.MedType = "1112"
  10453. }
  10454. if reg_type == 1111 {
  10455. order.MedType = "1111"
  10456. }
  10457. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10458. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10459. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10460. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10461. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10462. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10463. order.HifpPay = res.Output.Setlinfo.HifpPay
  10464. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10465. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10466. order.HifesPay = res.Output.Setlinfo.HifesPay
  10467. order.HifobPay = res.Output.Setlinfo.HifobPay
  10468. order.MafPay = res.Output.Setlinfo.MafPay
  10469. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10470. order.OthPay = res.Output.Setlinfo.OthPay
  10471. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10472. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10473. order.AcctPay = res.Output.Setlinfo.AcctPay
  10474. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10475. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10476. order.Balc = res.Output.Setlinfo.Balc
  10477. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10478. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10479. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10480. order.ClrWay = res.Output.Setlinfo.ClrWay
  10481. order.Creator = order.Creator
  10482. order.Modify = roles.AdminUserId
  10483. order.RequestLog = src_resquest
  10484. order.Diagnosis = diagnosis_id
  10485. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10486. detailStr := string(setlDetail)
  10487. order.SetlDetail = detailStr
  10488. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10489. err = service.UpDateOrder(order)
  10490. if err == nil {
  10491. //判断是否使用了押金
  10492. if dec_way == "true" {
  10493. tmpstring := strconv.FormatInt(order.ID, 10)
  10494. //扣押金
  10495. order.Decimal = decimal
  10496. service.UpDateOrder(order)
  10497. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10498. if errmsg != nil {
  10499. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10500. return
  10501. }
  10502. }
  10503. c.ServeSuccessJSON(map[string]interface{}{
  10504. "msg": "结算成功",
  10505. })
  10506. } else {
  10507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10508. return
  10509. }
  10510. }
  10511. }
  10512. }
  10513. }
  10514. //func (c *HisApiController) GetPreUploadInfo() {
  10515. // id, _ := c.GetInt64("id")
  10516. // record_time := c.GetString("record_time")
  10517. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10518. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10519. //
  10520. // timeLayout := "2006-01-02"
  10521. // loc, _ := time.LoadLocation("Local")
  10522. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10523. // if err != nil {
  10524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10525. // return
  10526. // }
  10527. // recordDateTime := theTime.Unix()
  10528. // adminUser := c.GetAdminUserInfo()
  10529. //
  10530. // var prescriptions []*models.HisPrescription
  10531. //
  10532. // var start_time int64
  10533. // var end_time int64
  10534. //
  10535. // data := make(map[string]interface{})
  10536. // if settle_accounts_type == 1 { //日结
  10537. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10538. // data["pre"] = prescriptions
  10539. //
  10540. // } else { //月结
  10541. // start_time_str := c.GetString("start_time")
  10542. // end_time_str := c.GetString("end_time")
  10543. // timeLayout := "2006-01-02"
  10544. // loc, _ := time.LoadLocation("Local")
  10545. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10546. // if err != nil {
  10547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10548. // return
  10549. // }
  10550. // recordStartTime := theStartTime.Unix()
  10551. // start_time = recordStartTime
  10552. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10553. // if err != nil {
  10554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10555. // return
  10556. // }
  10557. // recordEndTime := theEndTime.Unix()
  10558. // end_time = recordEndTime
  10559. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10560. // data["pre"] = prescriptions
  10561. //
  10562. // }
  10563. //
  10564. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10565. //
  10566. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10567. // timestamp := time.Now().Unix()
  10568. // tempTime := time.Unix(timestamp, 0)
  10569. // timeFormat := tempTime.Format("20060102150405")
  10570. // chrgBchno := rand.Intn(100000) + 10000
  10571. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10572. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10573. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10574. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10575. // strconv.FormatInt(his.PatientId, 10)
  10576. // client := &http.Client{}
  10577. // data["psn_no"] = his.PsnNo
  10578. // data["mdtrt_id"] = his.Number
  10579. // data["chrg_bchno"] = chrg_bchno
  10580. // data["org_name"] = miConfig.OrgName
  10581. // data["doctor"] = roles.UserName
  10582. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10583. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10584. // data["fixmedins_code"] = miConfig.Code
  10585. // data["dept_code"] = department.Number
  10586. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10587. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10588. // data["secret_key"] = miConfig.SecretKey
  10589. // var ids []int64
  10590. //
  10591. // for _, item := range prescriptions {
  10592. // ids = append(ids, item.ID)
  10593. // }
  10594. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10595. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10596. // bytesData, _ := json.Marshal(data)
  10597. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10598. // resp, _ := client.Do(req)
  10599. // defer resp.Body.Close()
  10600. // body, ioErr := ioutil.ReadAll(resp.Body)
  10601. // if ioErr != nil {
  10602. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10604. // return
  10605. // }
  10606. // var respJSON map[string]interface{}
  10607. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10608. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10610. // return
  10611. // }
  10612. //
  10613. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10614. // userJSONBytes, _ := json.Marshal(respJSON)
  10615. // var res ResultFour
  10616. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10617. // utils.ErrorLog("解析失败:%v", err)
  10618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10619. // return
  10620. // }
  10621. //
  10622. // if res.Infcode == 0 {
  10623. // order := &models.HisOrder{
  10624. // UserOrgId: adminUser.CurrentOrgId,
  10625. // HisPatientId: his.ID,
  10626. // PatientId: his.PatientId,
  10627. // SettleAccountsDate: recordDateTime,
  10628. // Ctime: time.Now().Unix(),
  10629. // Mtime: time.Now().Unix(),
  10630. // Status: 1,
  10631. // Number: chrg_bchno,
  10632. // Infcode: res.Infcode,
  10633. // WarnMsg: res.WarnMsg,
  10634. // Cainfo: res.Cainfo,
  10635. // ErrMsg: res.ErrMsg,
  10636. // RespondTime: res.RefmsgTime,
  10637. // InfRefmsgid: res.InfRefmsgid,
  10638. // OrderStatus: 1,
  10639. // IsMedicineInsurance: 1,
  10640. // SettleType: settle_accounts_type,
  10641. // SettleStartTime: start_time,
  10642. // SettleEndTime: end_time,
  10643. // Creator: roles.ID,
  10644. // Modify: roles.ID,
  10645. // PType: 2,
  10646. // }
  10647. // err = service.CreateOrder(order)
  10648. // if err != nil {
  10649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10650. // return
  10651. // }
  10652. //
  10653. // for _, item := range res.Output.Result {
  10654. // temp := strings.Split(item.FeedetlSn, "-")
  10655. // var advice_id int64 = 0
  10656. // var project_id int64 = 0
  10657. // var types int64 = 0
  10658. //
  10659. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  10660. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  10661. //
  10662. // if temp[1] == "1" {
  10663. // advice_id = id
  10664. // project_id = 0
  10665. // } else if temp[1] == "2" {
  10666. // advice_id = 0
  10667. // project_id = id
  10668. // }
  10669. //
  10670. // info := &models.HisOrderInfo{
  10671. // OrderNumber: order.Number,
  10672. // FeedetlSn: item.FeedetlSn,
  10673. // UploadDate: time.Now().Unix(),
  10674. // AdviceId: advice_id,
  10675. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  10676. // Cnt: item.Cnt,
  10677. // Pric: float64(item.Pric),
  10678. // PatientId: his.PatientId,
  10679. // PricUplmtAmt: item.PricUplmtAmt,
  10680. // SelfpayProp: item.SelfpayProp,
  10681. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10682. // OverlmtAmt: item.OverlmtAmt,
  10683. // PreselfpayAmt: item.PreselfpayAmt,
  10684. // BasMednFlag: item.BasMednFlag,
  10685. // MedChrgitmType: item.MedChrgitmType,
  10686. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  10687. // Status: 1,
  10688. // Memo: item.Memo,
  10689. // Mtime: time.Now().Unix(),
  10690. // InscpScpAmt: item.InscpScpAmt,
  10691. // DrtReimFlag: item.DrtReimFlag,
  10692. // Ctime: time.Now().Unix(),
  10693. // ListSpItemFlag: item.ListSpItemFlag,
  10694. // ChldMedcFlag: item.ChldMedcFlag,
  10695. // LmtUsedFlag: item.LmtUsedFlag,
  10696. // ChrgitmLv: item.ChrgitmLv,
  10697. // UserOrgId: adminUser.CurrentOrgId,
  10698. // HisPatientId: his.ID,
  10699. // OrderId: order.ID,
  10700. // ProjectId: project_id,
  10701. // Type: types,
  10702. // }
  10703. // service.CreateOrderInfo(info)
  10704. //
  10705. // }
  10706. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10707. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  10708. //
  10709. // var total float64
  10710. // for _, item := range prescriptions {
  10711. // if item.Type == 1 { //药品
  10712. // for _, subItem := range item.HisDoctorAdviceInfo {
  10713. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10714. // }
  10715. // }
  10716. // if item.Type == 2 { //项目
  10717. // for _, subItem := range item.HisPrescriptionProject {
  10718. // total = total + (subItem.Price * float64(subItem.Count))
  10719. // }
  10720. // }
  10721. // }
  10722. //
  10723. // for _, item := range prescriptions {
  10724. // for _, subItem := range item.HisAdditionalCharge {
  10725. // total = total + (subItem.Price * float64(subItem.Count))
  10726. // }
  10727. // }
  10728. //
  10729. // allTotal := fmt.Sprintf("%.2f", total)
  10730. // if res.Infcode == 0 {
  10731. // var rf []*ResultFive
  10732. // json.Unmarshal([]byte(his.Iinfo), &rf)
  10733. // psn_no := his.PsnNo
  10734. // mdtrt_id := his.Number
  10735. // chrg_bchno := chrg_bchno
  10736. // cert_no := his.Certno
  10737. // insutype := rf[0].Insutype
  10738. //
  10739. // if his.IdCardType == 1 {
  10740. // cert_no = his.MedicalInsuranceNumber
  10741. //
  10742. // } else {
  10743. //
  10744. // cert_no = his.Certno
  10745. //
  10746. // }
  10747. //
  10748. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  10749. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  10750. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  10751. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  10752. // resp, requestErr := http.Get(api)
  10753. // if requestErr != nil {
  10754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10755. // return
  10756. // }
  10757. // defer resp.Body.Close()
  10758. // body, ioErr := ioutil.ReadAll(resp.Body)
  10759. // if ioErr != nil {
  10760. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10762. // return
  10763. // }
  10764. // var respJSON map[string]interface{}
  10765. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10766. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. // return
  10769. // }
  10770. // fmt.Println(respJSON)
  10771. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10772. // userJSONBytes, _ := json.Marshal(respJSON)
  10773. // var res ResultSeven
  10774. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10775. // utils.ErrorLog("解析失败:%v", err)
  10776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10777. // return
  10778. // }
  10779. // if res.Infcode != 0 {
  10780. // errlog := &models.HisOrderError{
  10781. // UserOrgId: adminUser.CurrentOrgId,
  10782. // Ctime: time.Now().Unix(),
  10783. // Mtime: time.Now().Unix(),
  10784. // Number: chrg_bchno,
  10785. // ErrMsg: res.ErrMsg,
  10786. // Status: 1,
  10787. // PatientId: id,
  10788. // RecordTime: recordDateTime,
  10789. // Stage: 7,
  10790. // }
  10791. // service.CreateErrMsgLog(errlog)
  10792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10793. // return
  10794. // } else {
  10795. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10796. // order.OrderStatus = 1
  10797. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10798. // order.SetlId = res.Output.Setlinfo.SetlID
  10799. // order.PsnNo = res.Output.Setlinfo.PsnNo
  10800. // order.PsnName = res.Output.Setlinfo.PsnName
  10801. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10802. // order.Certno = res.Output.Setlinfo.Certno
  10803. // order.Gend = res.Output.Setlinfo.Gend
  10804. // order.Naty = res.Output.Setlinfo.Naty
  10805. // order.Age = res.Output.Setlinfo.Age
  10806. // order.Insutype = res.Output.Setlinfo.Insutype
  10807. // order.PsnType = res.Output.Setlinfo.PsnType
  10808. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10809. // order.SetlTime = res.Output.Setlinfo.SetlTime
  10810. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10811. // order.MedType = res.Output.Setlinfo.MedType
  10812. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10813. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10814. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10815. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10816. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10817. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10818. // order.HifpPay = res.Output.Setlinfo.HifpPay
  10819. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10820. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10821. // order.HifesPay = res.Output.Setlinfo.HifesPay
  10822. // order.HifobPay = res.Output.Setlinfo.HifobPay
  10823. // order.MafPay = res.Output.Setlinfo.MafPay
  10824. // order.OthPay = res.Output.Setlinfo.OthPay
  10825. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10826. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10827. // order.AcctPay = res.Output.Setlinfo.AcctPay
  10828. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10829. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10830. // order.Balc = res.Output.Setlinfo.Balc
  10831. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10832. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10833. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10834. // order.ClrWay = res.Output.Setlinfo.ClrWay
  10835. // order.Creator = order.Creator
  10836. // order.Modify = roles.ID
  10837. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10838. // detailStr := string(setlDetail)
  10839. // order.SetlDetail = detailStr
  10840. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10841. // err = service.UpDateOrder(order)
  10842. // if err == nil {
  10843. // c.ServeSuccessJSON(map[string]interface{}{
  10844. // "msg": "预结算成功",
  10845. // })
  10846. // } else {
  10847. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10848. // return
  10849. // }
  10850. // }
  10851. // } else {
  10852. // adminUser := c.GetAdminUserInfo()
  10853. // errlog := &models.HisOrderError{
  10854. // UserOrgId: adminUser.CurrentOrgId,
  10855. // Ctime: time.Now().Unix(),
  10856. // Mtime: time.Now().Unix(),
  10857. // ErrMsg: res.ErrMsg,
  10858. // Status: 1,
  10859. // PatientId: id,
  10860. // RecordTime: recordDateTime,
  10861. // Stage: 4,
  10862. // }
  10863. // service.CreateErrMsgLog(errlog)
  10864. //
  10865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10866. // return
  10867. // }
  10868. // } else {
  10869. // adminUser := c.GetAdminUserInfo()
  10870. // errlog := &models.HisOrderError{
  10871. // UserOrgId: adminUser.CurrentOrgId,
  10872. // Ctime: time.Now().Unix(),
  10873. // Mtime: time.Now().Unix(),
  10874. // ErrMsg: res.ErrMsg,
  10875. // Status: 1,
  10876. // PatientId: id,
  10877. // RecordTime: recordDateTime,
  10878. // Stage: 4,
  10879. // }
  10880. // service.CreateErrMsgLog(errlog)
  10881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10882. // return
  10883. // }
  10884. //
  10885. // } else {
  10886. // var total float64
  10887. // for _, item := range prescriptions {
  10888. // if item.Type == 1 { //药品
  10889. // for _, subItem := range item.HisDoctorAdviceInfo {
  10890. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10891. // }
  10892. // }
  10893. // if item.Type == 2 { //项目
  10894. // for _, subItem := range item.HisPrescriptionProject {
  10895. // total = total + (subItem.Price * float64(subItem.Count))
  10896. // }
  10897. // }
  10898. //
  10899. // for _, subItem := range item.HisAdditionalCharge {
  10900. // total = total + (subItem.Price * float64(subItem.Count))
  10901. // }
  10902. // }
  10903. //
  10904. // allTotal := fmt.Sprintf("%.2f", total)
  10905. // totals, _ := strconv.ParseFloat(allTotal, 64)
  10906. // order := &models.HisOrder{
  10907. // UserOrgId: adminUser.CurrentOrgId,
  10908. // HisPatientId: his.ID,
  10909. // PatientId: id,
  10910. // SettleAccountsDate: recordDateTime,
  10911. // Ctime: time.Now().Unix(),
  10912. // Mtime: time.Now().Unix(),
  10913. // Status: 1,
  10914. // OrderStatus: 2,
  10915. // Number: chrg_bchno,
  10916. // MedfeeSumamt: totals,
  10917. // }
  10918. // err = service.CreateOrder(order)
  10919. // if err != nil {
  10920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10921. // return
  10922. // }
  10923. //
  10924. // var customs []*Custom
  10925. // for _, item := range prescriptions {
  10926. //
  10927. // if item.Type == 1 { //药品
  10928. // for _, subItem := range item.HisDoctorAdviceInfo {
  10929. // cus := &Custom{
  10930. // AdviceId: subItem.ID,
  10931. // ProjectId: 0,
  10932. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  10933. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  10934. // FeedetlSn: subItem.FeedetlSn,
  10935. // Price: fmt.Sprintf("%.2f", subItem.Price),
  10936. // MedListCodg: subItem.MedListCodg,
  10937. // Type: 1,
  10938. // }
  10939. // customs = append(customs, cus)
  10940. // }
  10941. // }
  10942. //
  10943. // if item.Type == 2 { //项目
  10944. // for _, subItem := range item.HisPrescriptionProject {
  10945. //
  10946. // cus := &Custom{
  10947. // AdviceId: 0,
  10948. // ProjectId: subItem.ID,
  10949. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  10950. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  10951. // FeedetlSn: subItem.FeedetlSn,
  10952. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  10953. // MedListCodg: subItem.MedListCodg,
  10954. // Type: 2,
  10955. // }
  10956. //
  10957. // customs = append(customs, cus)
  10958. // }
  10959. // }
  10960. //
  10961. // for _, item := range item.HisAdditionalCharge {
  10962. // cus := &Custom{
  10963. // ItemId: item.ID,
  10964. // AdviceId: 0,
  10965. // ProjectId: 0,
  10966. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  10967. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  10968. // FeedetlSn: item.FeedetlSn,
  10969. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  10970. // MedListCodg: item.XtHisAddtionConfig.Code,
  10971. // Type: 3,
  10972. // }
  10973. //
  10974. // customs = append(customs, cus)
  10975. // }
  10976. //
  10977. // }
  10978. //
  10979. // for _, item := range customs {
  10980. // var advice_id int64 = 0
  10981. // var project_id int64 = 0
  10982. // var item_id int64 = 0
  10983. //
  10984. // var types int64 = 0
  10985. //
  10986. // if item.Type == 1 {
  10987. // advice_id = item.AdviceId
  10988. // project_id = 0
  10989. // item_id = 0
  10990. // } else if item.Type == 2 {
  10991. // advice_id = 0
  10992. // item_id = 0
  10993. //
  10994. // project_id = item.ProjectId
  10995. // } else if item.Type == 3 {
  10996. // advice_id = 0
  10997. // item_id = item.ItemId
  10998. // project_id = 0
  10999. // }
  11000. //
  11001. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  11002. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  11003. // pric, _ := strconv.ParseFloat(item.Price, 32)
  11004. //
  11005. // info := &models.HisOrderInfo{
  11006. // OrderNumber: order.Number,
  11007. // UploadDate: time.Now().Unix(),
  11008. // AdviceId: advice_id,
  11009. // DetItemFeeSumamt: detItemFeeSumamt,
  11010. // Cnt: cut,
  11011. // Pric: pric,
  11012. // PatientId: id,
  11013. // Status: 1,
  11014. // Mtime: time.Now().Unix(),
  11015. // Ctime: time.Now().Unix(),
  11016. // UserOrgId: adminUser.CurrentOrgId,
  11017. // HisPatientId: his.ID,
  11018. // OrderId: order.ID,
  11019. // ProjectId: project_id,
  11020. // Type: types,
  11021. // ItemId: item_id,
  11022. // }
  11023. // service.CreateOrderInfo(info)
  11024. // }
  11025. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11026. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11027. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  11028. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11029. // if err == nil {
  11030. // c.ServeSuccessJSON(map[string]interface{}{
  11031. // "msg": "结算成功",
  11032. // })
  11033. // } else {
  11034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11035. // return
  11036. // }
  11037. // }
  11038. //}
  11039. // 上传明细-预结算-
  11040. func (c *HisApiController) GetPreUploadInfo() {
  11041. id, _ := c.GetInt64("id")
  11042. record_time := c.GetString("record_time")
  11043. his_patient_id, _ := c.GetInt64("his_patient_id")
  11044. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11045. admin_user_id, _ := c.GetInt64("admin_user_id")
  11046. diagnosis_id := c.GetString("diagnosis")
  11047. sick_type, _ := c.GetInt64("sick_type")
  11048. reg_type, _ := c.GetInt64("p_type")
  11049. begin_time := c.GetString("begin_time")
  11050. acct_used_flag := c.GetString("acct_used_flag")
  11051. id_str := c.GetString("ids")
  11052. ids_arr := strings.Split(id_str, ",")
  11053. timeLayout := "2006-01-02"
  11054. loc, _ := time.LoadLocation("Local")
  11055. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11056. if err != nil {
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11058. return
  11059. }
  11060. recordDateTime := theTime.Unix()
  11061. adminUser := c.GetAdminUserInfo()
  11062. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11063. var config []*models.HisXtDiagnoseConfig
  11064. for _, item := range diagnosis_ids {
  11065. id, _ := strconv.ParseInt(item, 10, 64)
  11066. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11067. config = append(config, &diagnosisConfig)
  11068. }
  11069. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  11070. sickConfig, _ := service.FindSickById(sick_type)
  11071. var prescriptions []*models.HisPrescription
  11072. var start_time int64
  11073. var end_time int64
  11074. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11075. fmt.Println(his_patient_id)
  11076. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11077. timestamp := time.Now().Unix()
  11078. tempTime := time.Unix(timestamp, 0)
  11079. timeFormat := tempTime.Format("20060102150405")
  11080. chrgBchno := rand.Intn(100000) + 10000
  11081. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11083. var patientPrescription models.HisPrescriptionInfo
  11084. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11085. if patientPrescription.ID == 0 {
  11086. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11087. }
  11088. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11089. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11090. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11091. strconv.FormatInt(his.PatientId, 10)
  11092. var res2 ResultSix
  11093. var resSix10265 ResultSix10265
  11094. //var time_stamp string
  11095. if miConfig.MdtrtareaAdmvs == "421300" {
  11096. data := make(map[string]interface{})
  11097. client := &http.Client{}
  11098. data["psn_no"] = his.PsnNo
  11099. data["mdtrt_id"] = his.Number
  11100. data["department"] = department.Name
  11101. data["org_name"] = miConfig.OrgName
  11102. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11103. data["doctor_id"] = doctor_info.DoctorNumber
  11104. data["doctor_name"] = roles.UserName
  11105. data["fixmedins_code"] = miConfig.Code
  11106. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11107. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11108. data["secret_key"] = miConfig.SecretKey
  11109. data["sick_code"] = sickConfig.CountryCode
  11110. data["sick_name"] = sickConfig.ClassName
  11111. data["begin_time"] = begin_time
  11112. data["dept"] = strconv.FormatInt(department.ID, 10)
  11113. data["config"] = config
  11114. data["opter"] = roles.UserName
  11115. fmt.Println(data)
  11116. bytesData, _ := json.Marshal(data)
  11117. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11118. resp, _ := client.Do(req)
  11119. defer resp.Body.Close()
  11120. body, ioErr := ioutil.ReadAll(resp.Body)
  11121. if ioErr != nil {
  11122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. var respJSON map[string]interface{}
  11127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11133. userJSONBytes, _ := json.Marshal(respJSON)
  11134. fmt.Println("log")
  11135. fmt.Println(string(userJSONBytes))
  11136. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11137. utils.ErrorLog("解析失败:%v", err)
  11138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11139. return
  11140. }
  11141. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11142. data := make(map[string]interface{})
  11143. client := &http.Client{}
  11144. data["psn_no"] = his.PsnNo
  11145. data["mdtrt_id"] = his.Number
  11146. data["doctor"] = roles.UserName
  11147. data["department"] = department.Name
  11148. data["org_name"] = miConfig.OrgName
  11149. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11150. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  11151. data["fixmedins_code"] = miConfig.Code
  11152. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11153. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11154. data["secret_key"] = miConfig.SecretKey
  11155. data["sick_code"] = sickConfig.CountryCode
  11156. data["sick_name"] = sickConfig.ClassName
  11157. data["begin_time"] = begin_time
  11158. data["dept"] = strconv.FormatInt(department.ID, 10)
  11159. data["config"] = config
  11160. data["url"] = miConfig.Url
  11161. data["ak"] = miConfig.AccessKey
  11162. data["cainfo"] = miConfig.Cainfo
  11163. bytesData, _ := json.Marshal(data)
  11164. var req *http.Request
  11165. if miConfig.MdtrtareaAdmvs == "320921" {
  11166. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11167. } else {
  11168. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11169. }
  11170. resp, _ := client.Do(req)
  11171. defer resp.Body.Close()
  11172. body, ioErr := ioutil.ReadAll(resp.Body)
  11173. if ioErr != nil {
  11174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11176. return
  11177. }
  11178. var respJSON map[string]interface{}
  11179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11182. return
  11183. }
  11184. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  11185. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  11186. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  11187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11188. userJSONBytes, _ := json.Marshal(respJSON)
  11189. fmt.Println("log")
  11190. fmt.Println(string(userJSONBytes))
  11191. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11192. utils.ErrorLog("解析失败:%v", err)
  11193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11194. return
  11195. }
  11196. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11197. res2.Output = resSix10265.Output
  11198. res2.ErrMsg = resSix10265.ErrMsg
  11199. res2.Cainfo = resSix10265.Cainfo
  11200. res2.WarnMsg = resSix10265.WarnMsg
  11201. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11202. res2.Infcode = infocode
  11203. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11204. 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)
  11205. saveLog(result, requestLog, "2203", "上传就诊信息")
  11206. var respJSON2 map[string]interface{}
  11207. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11210. return
  11211. }
  11212. userJSONBytes2, _ := json.Marshal(respJSON2)
  11213. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11214. utils.ErrorLog("解析失败:%v", err)
  11215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11216. return
  11217. }
  11218. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11219. var result string
  11220. var requestLog string
  11221. 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, "")
  11222. saveLog(result, requestLog, "2203", "上传就诊信息")
  11223. var respJSON2 map[string]interface{}
  11224. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11227. return
  11228. }
  11229. userJSONBytes2, _ := json.Marshal(respJSON2)
  11230. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11231. utils.ErrorLog("解析失败:%v", err)
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11233. return
  11234. }
  11235. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11236. var result string
  11237. var requestLog string
  11238. 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, "")
  11239. saveLog(result, requestLog, "2203", "上传就诊信息")
  11240. var respJSON2 map[string]interface{}
  11241. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11244. return
  11245. }
  11246. userJSONBytes2, _ := json.Marshal(respJSON2)
  11247. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11248. utils.ErrorLog("解析失败:%v", err)
  11249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11250. return
  11251. }
  11252. } else {
  11253. var result string
  11254. var requestLog string
  11255. if miConfig.MdtrtareaAdmvs == "440781" { //
  11256. 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)
  11257. } else {
  11258. if miConfig.Code == "H15049901371" {
  11259. //赤峰地区国家医保医疗类别
  11260. //职工透析:医疗类别选特殊情况门诊990502
  11261. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11262. var med_type string
  11263. if his.Insutype == "390" {
  11264. if reg_type == 14 {
  11265. med_type = "9933"
  11266. } else if reg_type == 11 {
  11267. med_type = "11"
  11268. }
  11269. } else if his.Insutype == "310" {
  11270. if reg_type == 14 {
  11271. med_type = "990502"
  11272. } else if reg_type == 11 {
  11273. med_type = "11"
  11274. }
  11275. }
  11276. 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)
  11277. } else {
  11278. 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)
  11279. }
  11280. saveLog(result, requestLog, "2203", "上传就诊信息")
  11281. var respJSON2 map[string]interface{}
  11282. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11285. return
  11286. }
  11287. userJSONBytes2, _ := json.Marshal(respJSON2)
  11288. if miConfig.Code == "H15049901371" {
  11289. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  11290. utils.ErrorLog("解析失败:%v", err)
  11291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11292. return
  11293. }
  11294. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11295. res2.Output = resSix10265.Output
  11296. res2.ErrMsg = resSix10265.ErrMsg
  11297. res2.Cainfo = resSix10265.Cainfo
  11298. res2.WarnMsg = resSix10265.WarnMsg
  11299. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11300. res2.Infcode = infocode
  11301. } else {
  11302. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11303. utils.ErrorLog("解析失败:%v", err)
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. return
  11306. }
  11307. }
  11308. }
  11309. }
  11310. if res2.Infcode != 0 {
  11311. adminUser := c.GetAdminUserInfo()
  11312. errlog := &models.HisOrderError{
  11313. UserOrgId: adminUser.CurrentOrgId,
  11314. Ctime: time.Now().Unix(),
  11315. Mtime: time.Now().Unix(),
  11316. ErrMsg: res2.ErrMsg,
  11317. Status: 1,
  11318. PatientId: id,
  11319. RecordTime: recordDateTime,
  11320. Stage: 3,
  11321. }
  11322. service.CreateErrMsgLog(errlog)
  11323. c.ServeSuccessJSON(map[string]interface{}{
  11324. "failed_code": -10,
  11325. "msg": res2.ErrMsg,
  11326. })
  11327. return
  11328. } else {
  11329. his.Diagnosis = diagnosis_id
  11330. his.SickType = sickConfig.ID
  11331. his.PType = fmt.Sprintf("%d", reg_type)
  11332. service.UpdateHisPatientThree(&his)
  11333. data := make(map[string]interface{})
  11334. if settle_accounts_type == 1 { //日结
  11335. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11336. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11337. } else {
  11338. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11339. }
  11340. data["pre"] = prescriptions
  11341. } else { //月结
  11342. start_time_str := c.GetString("start_time")
  11343. end_time_str := c.GetString("end_time")
  11344. timeLayout := "2006-01-02"
  11345. loc, _ := time.LoadLocation("Local")
  11346. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11347. if err != nil {
  11348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11349. return
  11350. }
  11351. recordStartTime := theStartTime.Unix()
  11352. start_time = recordStartTime
  11353. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11354. if err != nil {
  11355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11356. return
  11357. }
  11358. recordEndTime := theEndTime.Unix()
  11359. end_time = recordEndTime
  11360. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11361. data["pre"] = prescriptions
  11362. }
  11363. client := &http.Client{}
  11364. data["psn_no"] = his.PsnNo
  11365. data["mdtrt_id"] = his.Number
  11366. data["chrg_bchno"] = chrg_bchno
  11367. data["org_name"] = miConfig.OrgName
  11368. data["doctor"] = doctor_info.UserName
  11369. data["doctor_id"] = doctor_info.DoctorNumber
  11370. data["dept"] = department.Name
  11371. data["fixmedins_code"] = miConfig.Code
  11372. data["opter"] = roles.UserName
  11373. data["dept_code"] = department.Number
  11374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11376. data["secret_key"] = miConfig.SecretKey
  11377. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11378. data["url"] = miConfig.Url
  11379. data["ak"] = miConfig.AccessKey
  11380. data["new_doctor_name"] = patientPrescription.Doctor
  11381. data["diag_code"] = sickConfig.CountryCode
  11382. data["cainfo"] = miConfig.Cainfo
  11383. data["opter"] = roles.UserName
  11384. var ids []int64
  11385. for _, item := range prescriptions {
  11386. ids = append(ids, item.ID)
  11387. }
  11388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11389. if config.IsOpen == 1 { //对接了医保,走医保流程
  11390. var res ResultFour
  11391. var resFour10265 ResultFour10265
  11392. if miConfig.MdtrtareaAdmvs == "421300" {
  11393. bytesData, _ := json.Marshal(data)
  11394. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11395. resp, _ := client.Do(req)
  11396. defer resp.Body.Close()
  11397. body, ioErr := ioutil.ReadAll(resp.Body)
  11398. if ioErr != nil {
  11399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11401. return
  11402. }
  11403. var respJSON map[string]interface{}
  11404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11407. return
  11408. }
  11409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11410. userJSONBytes, _ := json.Marshal(respJSON)
  11411. fmt.Println("log")
  11412. fmt.Println(string(userJSONBytes))
  11413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11414. utils.ErrorLog("解析失败:%v", err)
  11415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11416. return
  11417. }
  11418. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11419. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11420. if result3101.Infcode == "0" {
  11421. if len(result3101.Output.Result) > 0 {
  11422. var errMsgs []string
  11423. for _, item := range result3101.Output.Result {
  11424. errMsgs = append(errMsgs, item.VolaCont)
  11425. }
  11426. c.ServeSuccessJSON(map[string]interface{}{
  11427. "failed_code": -10,
  11428. "msg": errMsgs,
  11429. })
  11430. return
  11431. } else {
  11432. if miConfig.MdtrtareaAdmvs == "320921" {
  11433. data["doctor_id"] = "D320923012139"
  11434. } else {
  11435. data["doctor_id"] = "D371621008686"
  11436. }
  11437. bytesData, _ := json.Marshal(data)
  11438. var req *http.Request
  11439. if miConfig.MdtrtareaAdmvs == "320921" {
  11440. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11441. } else {
  11442. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11443. }
  11444. resp, _ := client.Do(req)
  11445. defer resp.Body.Close()
  11446. body, ioErr := ioutil.ReadAll(resp.Body)
  11447. if ioErr != nil {
  11448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11450. return
  11451. }
  11452. var respJSON map[string]interface{}
  11453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11456. return
  11457. }
  11458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11459. userJSONBytes, _ := json.Marshal(respJSON)
  11460. fmt.Println("log")
  11461. fmt.Println(string(userJSONBytes))
  11462. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11463. utils.ErrorLog("解析失败:%v", err)
  11464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11465. return
  11466. }
  11467. res.InfRefmsgid = resFour10265.InfRefmsgid
  11468. res.Output = resFour10265.Output
  11469. res.ErrMsg = resFour10265.ErrMsg
  11470. res.Cainfo = resFour10265.Cainfo
  11471. res.WarnMsg = resFour10265.WarnMsg
  11472. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11473. res.Infcode = infocode
  11474. }
  11475. }
  11476. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11477. 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)
  11478. var dat map[string]interface{}
  11479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11480. fmt.Println(dat)
  11481. } else {
  11482. fmt.Println(err)
  11483. }
  11484. saveLog(result, request_log, "2204", "上传费用明细")
  11485. userJSONBytes, _ := json.Marshal(dat)
  11486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11487. utils.ErrorLog("解析失败:%v", err)
  11488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11489. return
  11490. }
  11491. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11492. 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, "", "")
  11493. var dat map[string]interface{}
  11494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11495. fmt.Println(dat)
  11496. } else {
  11497. fmt.Println(err)
  11498. }
  11499. saveLog(result, request_log, "2204", "上传费用明细")
  11500. userJSONBytes, _ := json.Marshal(dat)
  11501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11502. utils.ErrorLog("解析失败:%v", err)
  11503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11504. return
  11505. }
  11506. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11507. 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, "", "")
  11508. var dat map[string]interface{}
  11509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11510. fmt.Println(dat)
  11511. } else {
  11512. fmt.Println(err)
  11513. }
  11514. saveLog(result, request_log, "2204", "上传费用明细")
  11515. userJSONBytes, _ := json.Marshal(dat)
  11516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11517. utils.ErrorLog("解析失败:%v", err)
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11519. return
  11520. }
  11521. } else {
  11522. if miConfig.Code == "H15049901371" {
  11523. 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)
  11524. var dat map[string]interface{}
  11525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11526. fmt.Println(dat)
  11527. } else {
  11528. fmt.Println(err)
  11529. }
  11530. saveLog(result, request_log, "2204", "上传费用明细")
  11531. userJSONBytes, _ := json.Marshal(dat)
  11532. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11533. utils.ErrorLog("解析失败:%v", err)
  11534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11535. return
  11536. }
  11537. res.InfRefmsgid = resFour10265.InfRefmsgid
  11538. res.Output = resFour10265.Output
  11539. res.ErrMsg = resFour10265.ErrMsg
  11540. res.Cainfo = resFour10265.Cainfo
  11541. res.WarnMsg = resFour10265.WarnMsg
  11542. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11543. res.Infcode = infocode
  11544. } else {
  11545. 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)
  11546. var dat map[string]interface{}
  11547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11548. fmt.Println(dat)
  11549. } else {
  11550. fmt.Println(err)
  11551. }
  11552. saveLog(result, request_log, "2204", "上传费用明细")
  11553. userJSONBytes, _ := json.Marshal(dat)
  11554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11555. utils.ErrorLog("解析失败:%v", err)
  11556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11557. return
  11558. }
  11559. }
  11560. }
  11561. var total_two float64
  11562. if res.Infcode == 0 {
  11563. order := &models.HisOrder{
  11564. UserOrgId: adminUser.CurrentOrgId,
  11565. HisPatientId: his.ID,
  11566. PatientId: his.PatientId,
  11567. SettleAccountsDate: recordDateTime,
  11568. Ctime: time.Now().Unix(),
  11569. Mtime: time.Now().Unix(),
  11570. MdtrtId: his.Number,
  11571. PsnNo: his.PsnNo,
  11572. MedType: strconv.FormatInt(reg_type, 10),
  11573. Status: 1,
  11574. Number: chrg_bchno,
  11575. Infcode: res.Infcode,
  11576. WarnMsg: res.WarnMsg,
  11577. Cainfo: res.Cainfo,
  11578. ErrMsg: res.ErrMsg,
  11579. RespondTime: res.RefmsgTime,
  11580. InfRefmsgid: res.InfRefmsgid,
  11581. OrderStatus: 1,
  11582. IsMedicineInsurance: 1,
  11583. SettleType: settle_accounts_type,
  11584. SettleStartTime: start_time,
  11585. SettleEndTime: end_time,
  11586. Creator: roles.AdminUserId,
  11587. Modify: roles.AdminUserId,
  11588. PType: 2,
  11589. Diagnosis: diagnosis_id,
  11590. }
  11591. err = service.CreateOrder(order)
  11592. if err != nil {
  11593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11594. return
  11595. }
  11596. for _, item := range res.Output.Result {
  11597. temp := strings.Split(item.FeedetlSn, "-")
  11598. var advice_id int64 = 0
  11599. var project_id int64 = 0
  11600. var types int64 = 0
  11601. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11602. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11603. if temp[1] == "1" {
  11604. advice_id = id
  11605. project_id = 0
  11606. } else if temp[1] == "2" {
  11607. advice_id = 0
  11608. project_id = id
  11609. }
  11610. total_two = total_two + item.DetItemFeeSumamt
  11611. info := &models.HisOrderInfo{
  11612. OrderNumber: order.Number,
  11613. FeedetlSn: item.FeedetlSn,
  11614. UploadDate: time.Now().Unix(),
  11615. AdviceId: advice_id,
  11616. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11617. Cnt: item.Cnt,
  11618. Pric: float64(item.Pric),
  11619. PatientId: his.PatientId,
  11620. PricUplmtAmt: item.PricUplmtAmt,
  11621. SelfpayProp: item.SelfpayProp,
  11622. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11623. OverlmtAmt: item.OverlmtAmt,
  11624. PreselfpayAmt: item.PreselfpayAmt,
  11625. BasMednFlag: item.BasMednFlag,
  11626. MedChrgitmType: item.MedChrgitmType,
  11627. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11628. Status: 1,
  11629. Memo: item.Memo,
  11630. Mtime: time.Now().Unix(),
  11631. InscpScpAmt: item.InscpScpAmt,
  11632. DrtReimFlag: item.DrtReimFlag,
  11633. Ctime: time.Now().Unix(),
  11634. ListSpItemFlag: item.ListSpItemFlag,
  11635. ChldMedcFlag: item.ChldMedcFlag,
  11636. LmtUsedFlag: item.LmtUsedFlag,
  11637. ChrgitmLv: item.ChrgitmLv,
  11638. UserOrgId: adminUser.CurrentOrgId,
  11639. HisPatientId: his.ID,
  11640. OrderId: order.ID,
  11641. ProjectId: project_id,
  11642. Type: types,
  11643. }
  11644. service.CreateOrderInfo(info)
  11645. }
  11646. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11647. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11648. var total float64
  11649. for _, item := range prescriptions {
  11650. if item.Type == 1 { //药品
  11651. for _, subItem := range item.HisDoctorAdviceInfo {
  11652. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11653. total_one := price * subItem.PrescribingNumber
  11654. fmt.Println("subItem")
  11655. fmt.Println(subItem.Price)
  11656. fmt.Println("price")
  11657. fmt.Println(price)
  11658. fmt.Println("total_one")
  11659. fmt.Println(total_one)
  11660. total = total + total_one
  11661. fmt.Println(total)
  11662. }
  11663. }
  11664. if item.Type == 2 { //项目
  11665. for _, subItem := range item.HisPrescriptionProject {
  11666. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11667. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11668. total_one := price * cnt
  11669. total = total + total_one
  11670. }
  11671. }
  11672. }
  11673. allTotal := fmt.Sprintf("%2f", total)
  11674. if res.Infcode == 0 {
  11675. var rf []*ResultFive
  11676. json.Unmarshal([]byte(his.Iinfo), &rf)
  11677. chrg_bchno := chrg_bchno
  11678. cert_no := his.Certno
  11679. var insutypes []string
  11680. var insutype string
  11681. var is390 int = 0
  11682. var is310 int = 0
  11683. for _, item := range rf {
  11684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11685. insutypes = append(insutypes, item.Insutype)
  11686. }
  11687. }
  11688. if len(insutypes) == 1 {
  11689. insutype = insutypes[0]
  11690. } else {
  11691. for _, i := range insutypes {
  11692. if i == "390" {
  11693. is390 = 1
  11694. }
  11695. if i == "310" {
  11696. is310 = 1
  11697. }
  11698. }
  11699. }
  11700. if is390 == 1 {
  11701. insutype = "390"
  11702. }
  11703. if is310 == 1 {
  11704. insutype = "310"
  11705. }
  11706. if len(insutypes) == 0 {
  11707. insutype = "390"
  11708. }
  11709. if len(insutypes) == 2 {
  11710. insutype = strconv.FormatInt(his.SocialType, 10)
  11711. }
  11712. //insutype = "390"
  11713. if his.IdCardType == 1 {
  11714. cert_no = his.MedicalInsuranceNumber
  11715. } else {
  11716. cert_no = his.Certno
  11717. }
  11718. var res ResultSeven
  11719. var resSeven10265 ResultSeven10265
  11720. if miConfig.MdtrtareaAdmvs == "421300" {
  11721. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11727. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  11728. resp, requestErr := http.Get(api)
  11729. if requestErr != nil {
  11730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11731. return
  11732. }
  11733. body, ioErr := ioutil.ReadAll(resp.Body)
  11734. if ioErr != nil {
  11735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11737. return
  11738. }
  11739. var respJSON map[string]interface{}
  11740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11743. return
  11744. }
  11745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11746. result, _ := json.Marshal(respJSON)
  11747. fmt.Println("log")
  11748. fmt.Println(string(result))
  11749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11750. utils.ErrorLog("解析失败:%v", err)
  11751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11752. return
  11753. }
  11754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11755. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  11756. if result3101.Infcode == "0" {
  11757. if len(result3101.Output.Result) > 0 {
  11758. var errMsgs []string
  11759. for _, item := range result3101.Output.Result {
  11760. errMsgs = append(errMsgs, item.VolaCont)
  11761. }
  11762. c.ServeSuccessJSON(map[string]interface{}{
  11763. "failed_code": -10,
  11764. "msg": errMsgs,
  11765. })
  11766. return
  11767. } else {
  11768. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11769. if his.IdCardType != 4 {
  11770. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11771. bas := strings.Split(psn_info.CardInfo, "|")
  11772. if his.IdCardType == 1 {
  11773. cert_no = bas[2]
  11774. } else {
  11775. cert_no = bas[1]
  11776. }
  11777. } else {
  11778. cert_no = his.Certno
  11779. }
  11780. //江苏地区国家医保医疗类别
  11781. //职工透析:医疗类别选特殊情况门诊9933
  11782. //居民血透门慢: 医疗类别选门诊慢病1402
  11783. //var med_type string
  11784. //if his.Insutype == "310" {
  11785. // if reg_type == 14 {
  11786. // med_type = "9933"
  11787. // } else if reg_type == 11 {
  11788. // med_type = "11"
  11789. //
  11790. // }
  11791. //} else if his.Insutype == "390" {
  11792. // if reg_type == 14 {
  11793. // med_type = "1402"
  11794. // } else if reg_type == 11 {
  11795. // med_type = "11"
  11796. // }
  11797. //}
  11798. var api string
  11799. if miConfig.MdtrtareaAdmvs == "320921" {
  11800. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11801. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11802. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11804. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11805. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11806. "&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
  11807. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11808. } else {
  11809. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11810. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11811. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11812. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11814. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11815. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11816. "&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
  11817. }
  11818. resp, requestErr := http.Get(api)
  11819. if requestErr != nil {
  11820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11821. return
  11822. }
  11823. body, ioErr := ioutil.ReadAll(resp.Body)
  11824. if ioErr != nil {
  11825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11827. return
  11828. }
  11829. var respJSON map[string]interface{}
  11830. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11833. return
  11834. }
  11835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11836. result, _ := json.Marshal(respJSON)
  11837. fmt.Println("log")
  11838. fmt.Println(string(result))
  11839. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11840. utils.ErrorLog("解析失败:%v", err)
  11841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11842. return
  11843. }
  11844. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11845. res.Output = resSeven10265.Output
  11846. res.ErrMsg = resSeven10265.ErrMsg
  11847. res.Cainfo = resSeven10265.Cainfo
  11848. res.WarnMsg = resSeven10265.WarnMsg
  11849. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11850. res.Infcode = infocode
  11851. }
  11852. }
  11853. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11854. acct_used_flag := "1"
  11855. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  11856. var result string
  11857. var request_log string
  11858. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  11859. 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)
  11860. } else {
  11861. 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)
  11862. }
  11863. var dat map[string]interface{}
  11864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11865. fmt.Println(dat)
  11866. } else {
  11867. fmt.Println(err)
  11868. }
  11869. saveLog(result, request_log, "2206", "预结算")
  11870. userJSONBytes, _ := json.Marshal(dat)
  11871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11872. utils.ErrorLog("解析失败:%v", err)
  11873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11874. return
  11875. }
  11876. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11877. var result string
  11878. var request_log string
  11879. if his.IdCardType == 2 {
  11880. 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, "")
  11881. } else if his.IdCardType == 1 {
  11882. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11883. bas := strings.Split(psn_info.CardInfo, "|")
  11884. basNumber := bas[2]
  11885. card_sn := bas[3]
  11886. 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)
  11887. } else {
  11888. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11889. 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, "")
  11890. }
  11891. var dat map[string]interface{}
  11892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11893. fmt.Println(dat)
  11894. } else {
  11895. fmt.Println(err)
  11896. }
  11897. saveLog(result, request_log, "2206", "预结算")
  11898. userJSONBytes, _ := json.Marshal(dat)
  11899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11900. utils.ErrorLog("解析失败:%v", err)
  11901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11902. return
  11903. }
  11904. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11905. var result string
  11906. var request_log string
  11907. if his.IdCardType == 2 {
  11908. 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")
  11909. } else if his.IdCardType == 1 {
  11910. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11911. bas := strings.Split(psn_info.CardInfo, "|")
  11912. basNumber := bas[2]
  11913. card_sn := bas[3]
  11914. 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")
  11915. } else {
  11916. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11917. 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")
  11918. }
  11919. var dat map[string]interface{}
  11920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11921. fmt.Println(dat)
  11922. } else {
  11923. fmt.Println(err)
  11924. }
  11925. saveLog(result, request_log, "2206", "预结算")
  11926. userJSONBytes, _ := json.Marshal(dat)
  11927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11928. utils.ErrorLog("解析失败:%v", err)
  11929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11930. return
  11931. }
  11932. } else {
  11933. var result string
  11934. var request_log string
  11935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11936. allTotal = fmt.Sprintf("%2f", total_two)
  11937. if his.IdCardType == 4 {
  11938. 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)
  11939. } else {
  11940. 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)
  11941. }
  11942. var dat map[string]interface{}
  11943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11944. fmt.Println(dat)
  11945. } else {
  11946. fmt.Println(err)
  11947. }
  11948. saveLog(result, request_log, "2206", "预结算")
  11949. //userJSONBytes, _ := json.Marshal(dat)
  11950. //
  11951. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11952. // utils.ErrorLog("解析失败:%v", err)
  11953. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11954. // return
  11955. //}
  11956. userJSONBytes, _ := json.Marshal(dat)
  11957. if miConfig.Code == "H15049901371" {
  11958. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11959. utils.ErrorLog("解析失败:%v", err)
  11960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11961. return
  11962. }
  11963. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11964. res.Output = resSeven10265.Output
  11965. res.ErrMsg = resSeven10265.ErrMsg
  11966. res.Cainfo = resSeven10265.Cainfo
  11967. res.WarnMsg = resSeven10265.WarnMsg
  11968. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11969. res.Infcode = infocode
  11970. } else {
  11971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11972. utils.ErrorLog("解析失败:%v", err)
  11973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11974. return
  11975. }
  11976. }
  11977. }
  11978. if res.Infcode != 0 {
  11979. errlog := &models.HisOrderError{
  11980. UserOrgId: adminUser.CurrentOrgId,
  11981. Ctime: time.Now().Unix(),
  11982. Mtime: time.Now().Unix(),
  11983. Number: chrg_bchno,
  11984. ErrMsg: res.ErrMsg,
  11985. Status: 1,
  11986. PatientId: id,
  11987. RecordTime: recordDateTime,
  11988. Stage: 20,
  11989. }
  11990. service.CreateErrMsgLog(errlog)
  11991. c.ServeSuccessJSON(map[string]interface{}{
  11992. "failed_code": -10,
  11993. "msg": res.ErrMsg,
  11994. })
  11995. return
  11996. } else {
  11997. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11998. order.OrderStatus = 1
  11999. order.IsPre = 1
  12000. order.Status = 1
  12001. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12002. order.SetlId = res.Output.Setlinfo.SetlID
  12003. order.PsnNo = res.Output.Setlinfo.PsnNo
  12004. order.PsnName = res.Output.Setlinfo.PsnName
  12005. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12006. order.Certno = res.Output.Setlinfo.Certno
  12007. order.Gend = res.Output.Setlinfo.Gend
  12008. order.Naty = res.Output.Setlinfo.Naty
  12009. order.Age = res.Output.Setlinfo.Age
  12010. order.Insutype = res.Output.Setlinfo.Insutype
  12011. order.PsnType = res.Output.Setlinfo.PsnType
  12012. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12013. order.SetlTime = res.Output.Setlinfo.SetlTime
  12014. order.AcctUsedFlag = acct_used_flag
  12015. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12016. if res.Output.Setlinfo.MedType == "140101" {
  12017. order.MedType = "14"
  12018. } else {
  12019. order.MedType = res.Output.Setlinfo.MedType
  12020. }
  12021. if reg_type == 1112 {
  12022. order.MedType = "1112"
  12023. }
  12024. if reg_type == 1111 {
  12025. order.MedType = "1111"
  12026. }
  12027. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12028. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12029. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12030. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12031. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12032. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12033. order.HifpPay = res.Output.Setlinfo.HifpPay
  12034. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12035. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12036. order.HifesPay = res.Output.Setlinfo.HifesPay
  12037. order.HifobPay = res.Output.Setlinfo.HifobPay
  12038. order.MafPay = res.Output.Setlinfo.MafPay
  12039. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12040. order.OthPay = res.Output.Setlinfo.OthPay
  12041. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12042. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12043. order.AcctPay = res.Output.Setlinfo.AcctPay
  12044. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12045. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12046. order.Balc = res.Output.Setlinfo.Balc
  12047. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12048. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12049. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12050. order.ClrWay = res.Output.Setlinfo.ClrWay
  12051. order.Creator = order.Creator
  12052. order.Modify = roles.AdminUserId
  12053. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12054. detailStr := string(setlDetail)
  12055. order.SetlDetail = detailStr
  12056. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12057. err = service.UpDateOrder(order)
  12058. if err == nil {
  12059. c.ServeSuccessJSON(map[string]interface{}{
  12060. "msg": "预结算成功",
  12061. })
  12062. } else {
  12063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12064. return
  12065. }
  12066. }
  12067. } else {
  12068. adminUser := c.GetAdminUserInfo()
  12069. errlog := &models.HisOrderError{
  12070. UserOrgId: adminUser.CurrentOrgId,
  12071. Ctime: time.Now().Unix(),
  12072. Mtime: time.Now().Unix(),
  12073. ErrMsg: res.ErrMsg,
  12074. Status: 1,
  12075. PatientId: id,
  12076. RecordTime: recordDateTime,
  12077. Stage: 4,
  12078. }
  12079. service.CreateErrMsgLog(errlog)
  12080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12081. return
  12082. }
  12083. } else {
  12084. adminUser := c.GetAdminUserInfo()
  12085. errlog := &models.HisOrderError{
  12086. UserOrgId: adminUser.CurrentOrgId,
  12087. Ctime: time.Now().Unix(),
  12088. Mtime: time.Now().Unix(),
  12089. ErrMsg: res.ErrMsg,
  12090. Status: 1,
  12091. PatientId: id,
  12092. RecordTime: recordDateTime,
  12093. Stage: 4,
  12094. }
  12095. service.CreateErrMsgLog(errlog)
  12096. c.ServeSuccessJSON(map[string]interface{}{
  12097. "failed_code": -10,
  12098. "msg": res.ErrMsg,
  12099. })
  12100. return
  12101. }
  12102. }
  12103. }
  12104. }
  12105. // 退款
  12106. func (c *HisApiController) Refund() {
  12107. order_id, _ := c.GetInt64("order_id")
  12108. admin_user_id, _ := c.GetInt64("admin_user_id")
  12109. adminUser := c.GetAdminUserInfo()
  12110. var order models.HisOrder
  12111. order, _ = service.GetHisOrderByID(order_id)
  12112. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12113. if order.ID == 0 {
  12114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12115. return
  12116. }
  12117. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12119. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12120. if config.IsOpen == 1 { //对接了医保,走医保流程
  12121. var res ResultSixteen
  12122. var resSixteen10265 ResultSixteen10265
  12123. var src_resquest string
  12124. var result string
  12125. if miConfig.MdtrtareaAdmvs == "421300" {
  12126. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  12127. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12129. resp3, requestErr3 := http.Get(api3)
  12130. if requestErr3 != nil {
  12131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12132. return
  12133. }
  12134. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12135. if ioErr3 != nil {
  12136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12138. return
  12139. }
  12140. var respJSON3 map[string]interface{}
  12141. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12144. return
  12145. }
  12146. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12147. userJSONBytes3, _ := json.Marshal(respJSON3)
  12148. fmt.Println("log")
  12149. fmt.Println(string(userJSONBytes3))
  12150. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  12151. utils.ErrorLog("解析失败:%v", err)
  12152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12153. return
  12154. }
  12155. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12156. var api3 string
  12157. if miConfig.MdtrtareaAdmvs == "320921" {
  12158. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12159. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12161. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12162. } else {
  12163. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12164. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12165. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12167. }
  12168. resp3, requestErr3 := http.Get(api3)
  12169. if requestErr3 != nil {
  12170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12171. return
  12172. }
  12173. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12174. if ioErr3 != nil {
  12175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12177. return
  12178. }
  12179. var respJSON3 map[string]interface{}
  12180. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12183. return
  12184. }
  12185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12186. userJSONBytes3, _ := json.Marshal(respJSON3)
  12187. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  12188. utils.ErrorLog("解析失败:%v", err)
  12189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12190. return
  12191. }
  12192. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12193. res.Output = resSixteen10265.Output
  12194. res.ErrMsg = resSixteen10265.ErrMsg
  12195. res.Cainfo = resSixteen10265.Cainfo
  12196. res.WarnMsg = resSixteen10265.WarnMsg
  12197. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12198. res.Infcode = infocode
  12199. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12200. 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)
  12201. var dat map[string]interface{}
  12202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12203. fmt.Println(dat)
  12204. } else {
  12205. fmt.Println(err)
  12206. }
  12207. saveLog(result, src_resquest, "2208", "退费")
  12208. userJSONBytes, _ := json.Marshal(dat)
  12209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12210. utils.ErrorLog("解析失败:%v", err)
  12211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12212. return
  12213. }
  12214. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12215. 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, "")
  12216. var dat map[string]interface{}
  12217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12218. fmt.Println(dat)
  12219. } else {
  12220. fmt.Println(err)
  12221. }
  12222. saveLog(result, src_resquest, "2208", "退费")
  12223. userJSONBytes, _ := json.Marshal(dat)
  12224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12225. utils.ErrorLog("解析失败:%v", err)
  12226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12227. return
  12228. }
  12229. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12230. 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, "")
  12231. var dat map[string]interface{}
  12232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12233. fmt.Println(dat)
  12234. } else {
  12235. fmt.Println(err)
  12236. }
  12237. saveLog(result, src_resquest, "2208", "退费")
  12238. userJSONBytes, _ := json.Marshal(dat)
  12239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12240. utils.ErrorLog("解析失败:%v", err)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. } else {
  12245. if miConfig.Code == "H15049901371" {
  12246. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12247. var dat map[string]interface{}
  12248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12249. fmt.Println(dat)
  12250. } else {
  12251. fmt.Println(err)
  12252. }
  12253. saveLog(result, src_resquest, "2208", "退费")
  12254. userJSONBytes, _ := json.Marshal(dat)
  12255. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  12256. utils.ErrorLog("解析失败:%v", err)
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12258. return
  12259. }
  12260. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12261. res.Output = resSixteen10265.Output
  12262. res.ErrMsg = resSixteen10265.ErrMsg
  12263. res.Cainfo = resSixteen10265.Cainfo
  12264. res.WarnMsg = resSixteen10265.WarnMsg
  12265. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12266. res.Infcode = infocode
  12267. } else {
  12268. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12269. var dat map[string]interface{}
  12270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12271. fmt.Println(dat)
  12272. } else {
  12273. fmt.Println(err)
  12274. }
  12275. saveLog(result, src_resquest, "2208", "退费")
  12276. userJSONBytes, _ := json.Marshal(dat)
  12277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12278. utils.ErrorLog("解析失败:%v", err)
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. }
  12283. }
  12284. if res.Infcode == 0 {
  12285. var res2 ResultSix
  12286. var resSix10265 ResultSix10265
  12287. if miConfig.MdtrtareaAdmvs == "421300" {
  12288. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12289. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12290. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12291. resp3, requestErr3 := http.Get(api3)
  12292. if requestErr3 != nil {
  12293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12294. return
  12295. }
  12296. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12297. if ioErr3 != nil {
  12298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12300. return
  12301. }
  12302. var respJSON3 map[string]interface{}
  12303. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12306. return
  12307. }
  12308. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12309. userJSONBytes3, _ := json.Marshal(respJSON3)
  12310. fmt.Println("log")
  12311. fmt.Println(string(userJSONBytes3))
  12312. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12313. utils.ErrorLog("解析失败:%v", err)
  12314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12315. return
  12316. }
  12317. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12318. var api3 string
  12319. if miConfig.MdtrtareaAdmvs == "320921" {
  12320. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12321. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12323. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12324. } else {
  12325. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12326. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12327. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12328. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12329. }
  12330. resp3, requestErr3 := http.Get(api3)
  12331. if requestErr3 != nil {
  12332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12333. return
  12334. }
  12335. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12336. if ioErr3 != nil {
  12337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. return
  12340. }
  12341. var respJSON3 map[string]interface{}
  12342. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12345. return
  12346. }
  12347. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12348. userJSONBytes3, _ := json.Marshal(respJSON3)
  12349. fmt.Println("log")
  12350. fmt.Println(string(userJSONBytes3))
  12351. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12352. utils.ErrorLog("解析失败:%v", err)
  12353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12354. return
  12355. }
  12356. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12357. res2.Output = resSix10265.Output
  12358. res2.ErrMsg = resSix10265.ErrMsg
  12359. res2.Cainfo = resSix10265.Cainfo
  12360. res2.WarnMsg = resSix10265.WarnMsg
  12361. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12362. res2.Infcode = infocode
  12363. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12364. 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)
  12365. var dat map[string]interface{}
  12366. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12367. fmt.Println(dat)
  12368. } else {
  12369. fmt.Println(err)
  12370. }
  12371. saveLog(result2, src_request, "2205", "撤销明细")
  12372. userJSONBytes, _ := json.Marshal(dat)
  12373. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12379. 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, "")
  12380. var dat map[string]interface{}
  12381. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12382. fmt.Println(dat)
  12383. } else {
  12384. fmt.Println(err)
  12385. }
  12386. saveLog(result2, src_request, "2205", "撤销明细")
  12387. userJSONBytes, _ := json.Marshal(dat)
  12388. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12389. utils.ErrorLog("解析失败:%v", err)
  12390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. return
  12392. }
  12393. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12394. 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, "")
  12395. var dat map[string]interface{}
  12396. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12397. fmt.Println(dat)
  12398. } else {
  12399. fmt.Println(err)
  12400. }
  12401. saveLog(result2, src_request, "2205", "撤销明细")
  12402. userJSONBytes, _ := json.Marshal(dat)
  12403. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12404. utils.ErrorLog("解析失败:%v", err)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12406. return
  12407. }
  12408. } else {
  12409. if miConfig.Code == "H15049901371" {
  12410. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12411. var dat map[string]interface{}
  12412. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12413. fmt.Println(dat)
  12414. } else {
  12415. fmt.Println(err)
  12416. }
  12417. saveLog(result2, src_request, "2205", "撤销明细")
  12418. userJSONBytes, _ := json.Marshal(dat)
  12419. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12420. utils.ErrorLog("解析失败:%v", err)
  12421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12422. return
  12423. }
  12424. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12425. res2.Output = resSix10265.Output
  12426. res2.ErrMsg = resSix10265.ErrMsg
  12427. res2.Cainfo = resSix10265.Cainfo
  12428. res2.WarnMsg = resSix10265.WarnMsg
  12429. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12430. res2.Infcode = infocode
  12431. } else {
  12432. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12433. var dat map[string]interface{}
  12434. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12435. fmt.Println(dat)
  12436. } else {
  12437. fmt.Println(err)
  12438. }
  12439. saveLog(result2, src_request, "2205", "撤销明细")
  12440. userJSONBytes, _ := json.Marshal(dat)
  12441. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12442. utils.ErrorLog("解析失败:%v", err)
  12443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12444. return
  12445. }
  12446. }
  12447. }
  12448. if res2.Infcode == 0 {
  12449. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  12450. if err == nil {
  12451. //当押金不为零时产生退费记录
  12452. if order.Decimal != 0 {
  12453. tmp := strconv.FormatInt(order.ID, 10)
  12454. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  12455. if err != nil {
  12456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12457. return
  12458. }
  12459. }
  12460. c.ServeSuccessJSON(map[string]interface{}{
  12461. "msg": "退费成功",
  12462. })
  12463. } else {
  12464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12465. return
  12466. }
  12467. } else {
  12468. c.ServeSuccessJSON(map[string]interface{}{
  12469. "code": -10,
  12470. "msg": res2.ErrMsg,
  12471. })
  12472. }
  12473. } else {
  12474. c.ServeSuccessJSON(map[string]interface{}{
  12475. "code": -10,
  12476. "msg": res.ErrMsg,
  12477. })
  12478. }
  12479. }
  12480. }
  12481. func (c *HisApiController) RefundNumber() {
  12482. record_time := c.GetString("record_time")
  12483. //patient_id, _ := c.GetInt64("patient_id")
  12484. admin_user_id, _ := c.GetInt64("admin_user_id")
  12485. his_patient_id, _ := c.GetInt64("id")
  12486. timeLayout := "2006-01-02"
  12487. loc, _ := time.LoadLocation("Local")
  12488. adminUser := c.GetAdminUserInfo()
  12489. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12490. fmt.Println(err)
  12491. if err != nil {
  12492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12493. return
  12494. }
  12495. recordDateTime := theTime.Unix()
  12496. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12497. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  12498. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12499. //order, _ := service.GetHisOrderByID(order_id)
  12500. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12501. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12503. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  12504. if count > 0 {
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  12506. return
  12507. }
  12508. if config.IsOpen == 1 { //对接了医保,走医保流程
  12509. var res2 ResultSix
  12510. var resSix10265 ResultSix10265
  12511. if miConfig.MdtrtareaAdmvs == "421300" {
  12512. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  12513. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12515. resp3, requestErr3 := http.Get(api3)
  12516. if requestErr3 != nil {
  12517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12518. return
  12519. }
  12520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12521. if ioErr3 != nil {
  12522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12524. return
  12525. }
  12526. var respJSON3 map[string]interface{}
  12527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12530. return
  12531. }
  12532. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12533. userJSONBytes3, _ := json.Marshal(respJSON3)
  12534. fmt.Println("log")
  12535. fmt.Println(string(userJSONBytes3))
  12536. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12537. utils.ErrorLog("解析失败:%v", err)
  12538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12539. return
  12540. }
  12541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12542. var api3 string
  12543. if miConfig.MdtrtareaAdmvs == "320921" {
  12544. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12545. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12547. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12548. } else {
  12549. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12550. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12551. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12553. }
  12554. resp3, requestErr3 := http.Get(api3)
  12555. if requestErr3 != nil {
  12556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12557. return
  12558. }
  12559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12560. if ioErr3 != nil {
  12561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12563. return
  12564. }
  12565. var respJSON3 map[string]interface{}
  12566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12569. return
  12570. }
  12571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12572. userJSONBytes3, _ := json.Marshal(respJSON3)
  12573. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12574. utils.ErrorLog("解析失败:%v", err)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12579. res2.Output = resSix10265.Output
  12580. res2.ErrMsg = resSix10265.ErrMsg
  12581. res2.Cainfo = resSix10265.Cainfo
  12582. res2.WarnMsg = resSix10265.WarnMsg
  12583. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12584. res2.Infcode = infocode
  12585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12586. 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)
  12587. var dat map[string]interface{}
  12588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12589. fmt.Println(dat)
  12590. } else {
  12591. fmt.Println(err)
  12592. }
  12593. saveLog(result, request, "2202", "退号")
  12594. userJSONBytes, _ := json.Marshal(dat)
  12595. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12596. utils.ErrorLog("解析失败:%v", err)
  12597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12598. return
  12599. }
  12600. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12601. 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, "")
  12602. var dat map[string]interface{}
  12603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12604. fmt.Println(dat)
  12605. } else {
  12606. fmt.Println(err)
  12607. }
  12608. saveLog(result, request, "2202", "退号")
  12609. userJSONBytes, _ := json.Marshal(dat)
  12610. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12611. utils.ErrorLog("解析失败:%v", err)
  12612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12613. return
  12614. }
  12615. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12616. 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, "")
  12617. var dat map[string]interface{}
  12618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12619. fmt.Println(dat)
  12620. } else {
  12621. fmt.Println(err)
  12622. }
  12623. saveLog(result, request, "2202", "退号")
  12624. userJSONBytes, _ := json.Marshal(dat)
  12625. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12626. utils.ErrorLog("解析失败:%v", err)
  12627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12628. return
  12629. }
  12630. } else {
  12631. var api3 string
  12632. if miConfig.Code == "H15049901371" {
  12633. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12634. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12636. } else {
  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. }
  12641. resp3, requestErr3 := http.Get(api3)
  12642. if requestErr3 != nil {
  12643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12644. return
  12645. }
  12646. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12647. if ioErr3 != nil {
  12648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12650. return
  12651. }
  12652. var respJSON3 map[string]interface{}
  12653. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return
  12657. }
  12658. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12659. userJSONBytes3, _ := json.Marshal(respJSON3)
  12660. if miConfig.Code == "H15049901371" {
  12661. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12662. utils.ErrorLog("解析失败:%v", err)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12667. res2.Output = resSix10265.Output
  12668. res2.ErrMsg = resSix10265.ErrMsg
  12669. res2.Cainfo = resSix10265.Cainfo
  12670. res2.WarnMsg = resSix10265.WarnMsg
  12671. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12672. res2.Infcode = infocode
  12673. } else {
  12674. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12675. utils.ErrorLog("解析失败:%v", err)
  12676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12677. return
  12678. }
  12679. }
  12680. }
  12681. if res2.Infcode == 0 {
  12682. if err == nil {
  12683. c.ServeSuccessJSON(map[string]interface{}{
  12684. "msg": "退号成功",
  12685. })
  12686. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  12687. } else {
  12688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12689. return
  12690. }
  12691. } else {
  12692. c.ServeSuccessJSON(map[string]interface{}{
  12693. "code": -10,
  12694. "msg": res2.ErrMsg,
  12695. })
  12696. }
  12697. } else {
  12698. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  12699. //if err == nil {
  12700. // c.ServeSuccessJSON(map[string]interface{}{
  12701. // "msg": "退费成功",
  12702. // })
  12703. //} else {
  12704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12705. // return
  12706. //}
  12707. }
  12708. }
  12709. func (c *HisApiController) RefundDetail() {
  12710. order_id, _ := c.GetInt64("order_id")
  12711. admin_user_id, _ := c.GetInt64("admin_user_id")
  12712. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12713. number := c.GetString("number")
  12714. record_time := c.GetString("record_time")
  12715. patient_id, _ := c.GetInt64("patient_id")
  12716. //med_type, _ := c.GetInt64("med_type")
  12717. timeLayout := "2006-01-02"
  12718. loc, _ := time.LoadLocation("Local")
  12719. adminUser := c.GetAdminUserInfo()
  12720. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12721. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12722. fmt.Println(err)
  12723. if err != nil {
  12724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12725. return
  12726. }
  12727. recordDateTime := theTime.Unix()
  12728. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12729. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12732. var order models.HisOrder
  12733. order, _ = service.GetHisOrderByID(order_id)
  12734. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12735. if config.IsOpen == 1 { //对接了医保,走医保流程
  12736. var res2 ResultSix
  12737. if miConfig.MdtrtareaAdmvs == "421300" {
  12738. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12739. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12741. resp3, requestErr3 := http.Get(api3)
  12742. if requestErr3 != nil {
  12743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12744. return
  12745. }
  12746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12747. if ioErr3 != nil {
  12748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12750. return
  12751. }
  12752. var respJSON3 map[string]interface{}
  12753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12756. return
  12757. }
  12758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12759. userJSONBytes3, _ := json.Marshal(respJSON3)
  12760. fmt.Println("log")
  12761. fmt.Println(string(userJSONBytes3))
  12762. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12763. utils.ErrorLog("解析失败:%v", err)
  12764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12765. return
  12766. }
  12767. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12768. if err == nil {
  12769. c.ServeSuccessJSON(map[string]interface{}{
  12770. "msg": "撤销明细成功",
  12771. })
  12772. return
  12773. } else {
  12774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12775. return
  12776. }
  12777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12778. var resSix10265 ResultSix10265
  12779. var api3 string
  12780. if miConfig.MdtrtareaAdmvs == "320921" {
  12781. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12784. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12785. } else {
  12786. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12787. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12788. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12790. }
  12791. resp3, requestErr3 := http.Get(api3)
  12792. if requestErr3 != nil {
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12794. return
  12795. }
  12796. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12797. if ioErr3 != nil {
  12798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12800. return
  12801. }
  12802. var respJSON3 map[string]interface{}
  12803. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12806. return
  12807. }
  12808. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12809. userJSONBytes3, _ := json.Marshal(respJSON3)
  12810. fmt.Println("log")
  12811. fmt.Println(string(userJSONBytes3))
  12812. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12813. utils.ErrorLog("解析失败:%v", err)
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12815. return
  12816. }
  12817. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12818. res2.Output = resSix10265.Output
  12819. res2.ErrMsg = resSix10265.ErrMsg
  12820. res2.Cainfo = resSix10265.Cainfo
  12821. res2.WarnMsg = resSix10265.WarnMsg
  12822. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12823. res2.Infcode = infocode
  12824. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12825. if err == nil {
  12826. c.ServeSuccessJSON(map[string]interface{}{
  12827. "msg": "撤销明细成功",
  12828. })
  12829. return
  12830. } else {
  12831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12832. return
  12833. }
  12834. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12835. 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)
  12836. var dat map[string]interface{}
  12837. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12838. fmt.Println(dat)
  12839. } else {
  12840. fmt.Println(err)
  12841. }
  12842. saveLog(result2, src_request, "2205", "撤销明细")
  12843. userJSONBytes, _ := json.Marshal(dat)
  12844. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12845. utils.ErrorLog("解析失败:%v", err)
  12846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12847. return
  12848. }
  12849. if res2.Infcode == 0 {
  12850. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12851. if err == nil {
  12852. c.ServeSuccessJSON(map[string]interface{}{
  12853. "msg": "撤销明细成功",
  12854. })
  12855. return
  12856. } else {
  12857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12858. return
  12859. }
  12860. } else {
  12861. c.ServeSuccessJSON(map[string]interface{}{
  12862. "code": -10,
  12863. "msg": res2.ErrMsg,
  12864. })
  12865. }
  12866. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12867. 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, "")
  12868. var dat map[string]interface{}
  12869. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12870. fmt.Println(dat)
  12871. } else {
  12872. fmt.Println(err)
  12873. }
  12874. saveLog(result2, src_request, "2205", "撤销明细")
  12875. userJSONBytes, _ := json.Marshal(dat)
  12876. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12877. utils.ErrorLog("解析失败:%v", err)
  12878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12879. return
  12880. }
  12881. if res2.Infcode == 0 {
  12882. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12883. if err == nil {
  12884. c.ServeSuccessJSON(map[string]interface{}{
  12885. "msg": "撤销明细成功",
  12886. })
  12887. return
  12888. } else {
  12889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12890. return
  12891. }
  12892. } else {
  12893. c.ServeSuccessJSON(map[string]interface{}{
  12894. "code": -10,
  12895. "msg": res2.ErrMsg,
  12896. })
  12897. }
  12898. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12899. 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, "")
  12900. var dat map[string]interface{}
  12901. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12902. fmt.Println(dat)
  12903. } else {
  12904. fmt.Println(err)
  12905. }
  12906. saveLog(result2, src_request, "2205", "撤销明细")
  12907. userJSONBytes, _ := json.Marshal(dat)
  12908. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12909. utils.ErrorLog("解析失败:%v", err)
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. return
  12912. }
  12913. if res2.Infcode == 0 {
  12914. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12915. if err == nil {
  12916. c.ServeSuccessJSON(map[string]interface{}{
  12917. "msg": "撤销明细成功",
  12918. })
  12919. return
  12920. } else {
  12921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12922. return
  12923. }
  12924. } else {
  12925. c.ServeSuccessJSON(map[string]interface{}{
  12926. "code": -10,
  12927. "msg": res2.ErrMsg,
  12928. })
  12929. }
  12930. } else {
  12931. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  12932. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12934. resp2, requestErr2 := http.Get(api2)
  12935. if requestErr2 != nil {
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12937. return
  12938. }
  12939. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12940. if ioErr2 != nil {
  12941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12943. return
  12944. }
  12945. var respJSON2 map[string]interface{}
  12946. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12949. return
  12950. }
  12951. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12952. if err == nil {
  12953. c.ServeSuccessJSON(map[string]interface{}{
  12954. "msg": "撤销明细成功",
  12955. })
  12956. return
  12957. } else {
  12958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12959. return
  12960. }
  12961. }
  12962. } else {
  12963. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12964. if err == nil {
  12965. c.ServeSuccessJSON(map[string]interface{}{
  12966. "msg": "退费成功",
  12967. })
  12968. } else {
  12969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12970. return
  12971. }
  12972. }
  12973. }
  12974. // 对账
  12975. func (c *HisApiController) GetCheckAccount() {
  12976. start_time := c.GetString("start_time")
  12977. end_time := c.GetString("end_time")
  12978. insutype := c.GetString("insutype")
  12979. clr_type := c.GetString("clr_type")
  12980. clr_org := c.GetString("clr_optins")
  12981. admin_user_id, _ := c.GetInt64("admin_user_id")
  12982. adminUser := c.GetAdminUserInfo()
  12983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12984. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12985. if len(clr_org) == 0 {
  12986. clr_org = miConfig.MdtrtareaAdmvs
  12987. }
  12988. timeLayout := "2006-01-02"
  12989. loc, _ := time.LoadLocation("Local")
  12990. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12991. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12992. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12993. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12994. fixmedins_setl_cnt := int64(len(orders))
  12995. var medfee_sumamt float64
  12996. var acct_pay float64
  12997. var fund_pay_sumamt float64
  12998. for _, item := range orders {
  12999. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13000. acct_pay = acct_pay + item.AcctPay
  13001. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13002. }
  13003. var user_name string
  13004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13005. if role.ID == 0 {
  13006. user_name = "xxx"
  13007. } else {
  13008. user_name = role.UserName
  13009. }
  13010. var res ResultEight
  13011. var res10188 ResultEightFor10188
  13012. if config.IsOpen == 1 {
  13013. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13014. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  13015. "insutype=" + insutype +
  13016. "&clr_type=" + clr_type +
  13017. "&setl_optins=" + clr_org +
  13018. "&stmt_begndate=" + start_time +
  13019. "&stm_enddate=" + end_time +
  13020. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13021. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13022. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13023. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13024. "&fixmedins_code=" + miConfig.Code +
  13025. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13026. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13027. "&secret_key=" + miConfig.SecretKey +
  13028. "&org_name=" + miConfig.OrgName +
  13029. "&doctor=" + user_name +
  13030. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13031. fmt.Println(api)
  13032. resp, requestErr := http.Get(api)
  13033. if requestErr != nil {
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. body, ioErr := ioutil.ReadAll(resp.Body)
  13038. fmt.Println(body)
  13039. if ioErr != nil {
  13040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13042. return
  13043. }
  13044. var respJSON map[string]interface{}
  13045. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13048. return
  13049. }
  13050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13051. userJSONBytes, _ := json.Marshal(respJSON)
  13052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13053. utils.ErrorLog("解析失败:%v", err)
  13054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13055. return
  13056. }
  13057. res.InfRefmsgid = res10188.InfRefmsgid
  13058. res.Output = res10188.Output
  13059. res.ErrMsg = res10188.ErrMsg
  13060. res.Cainfo = res10188.Cainfo
  13061. res.WarnMsg = res10188.WarnMsg
  13062. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13063. res.Infcode = infocode
  13064. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13065. if clr_type == "11" {
  13066. fixmedins_setl_cnt = 2
  13067. }
  13068. //if clr_type == "21" {
  13069. // clr_type = "22"
  13070. //}
  13071. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  13072. "insutype=" + insutype +
  13073. "&clr_type=" + clr_type +
  13074. "&setl_optins=" + clr_org +
  13075. "&stmt_begndate=" + start_time +
  13076. "&stm_enddate=" + end_time +
  13077. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13078. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13079. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13080. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13081. "&fixmedins_code=" + miConfig.Code +
  13082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13083. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13084. "&secret_key=" + miConfig.SecretKey +
  13085. "&org_name=" + miConfig.OrgName +
  13086. "&doctor=" + user_name
  13087. resp, requestErr := http.Get(api)
  13088. if requestErr != nil {
  13089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13090. return
  13091. }
  13092. body, ioErr := ioutil.ReadAll(resp.Body)
  13093. if ioErr != nil {
  13094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13096. return
  13097. }
  13098. var respJSON map[string]interface{}
  13099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13102. return
  13103. }
  13104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13105. result, _ := json.Marshal(respJSON)
  13106. fmt.Println("log")
  13107. fmt.Println(string(result))
  13108. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  13109. utils.ErrorLog("解析失败:%v", err)
  13110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13111. return
  13112. }
  13113. res.InfRefmsgid = res10188.InfRefmsgid
  13114. res.Output = res10188.Output
  13115. res.ErrMsg = res10188.ErrMsg
  13116. res.Cainfo = res10188.Cainfo
  13117. res.WarnMsg = res10188.WarnMsg
  13118. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13119. res.Infcode = infocode
  13120. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13121. var baseParams models.BaseParams
  13122. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13123. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13124. baseParams.SecretKey = miConfig.SecretKey
  13125. baseParams.OrgName = miConfig.OrgName
  13126. baseParams.FixmedinsCode = miConfig.Code
  13127. baseParams.EncKey = miConfig.EncKey
  13128. baseParams.AppSecret = miConfig.AppSecret
  13129. baseParams.SignKey = miConfig.SignKey
  13130. baseParams.AppID = miConfig.Code
  13131. baseParams.Doctor = role.UserName
  13132. baseParams.RequestUrl = miConfig.Url
  13133. businessParams := models.BusinessParams{
  13134. Insutype: insutype,
  13135. ClrType: clr_type,
  13136. SetlOptins: clr_org,
  13137. StmtBegndate: start_time,
  13138. StmtEnddate: end_time,
  13139. MedfeeSumamt: medfee_sumamt,
  13140. FundPaySumamt: fund_pay_sumamt,
  13141. AcctPay: acct_pay,
  13142. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13143. }
  13144. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13145. fmt.Println(requestLog)
  13146. fmt.Println(result)
  13147. fmt.Println(err_msg)
  13148. var dat map[string]interface{}
  13149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13150. fmt.Println(dat)
  13151. } else {
  13152. fmt.Println(err)
  13153. }
  13154. userJSONBytes, _ := json.Marshal(dat)
  13155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13156. utils.ErrorLog("解析失败:%v", err)
  13157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13158. return
  13159. }
  13160. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13161. var baseParams models.BaseParams
  13162. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13163. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13164. baseParams.SecretKey = miConfig.SecretKey
  13165. baseParams.OrgName = miConfig.OrgName
  13166. baseParams.FixmedinsCode = miConfig.Code
  13167. baseParams.EncKey = miConfig.EncKey
  13168. baseParams.AppSecret = miConfig.AppSecret
  13169. baseParams.SignKey = miConfig.SignKey
  13170. baseParams.AppID = miConfig.Code
  13171. baseParams.Doctor = role.UserName
  13172. baseParams.RequestUrl = miConfig.Url
  13173. baseParams.AccessKey = miConfig.AccessKey
  13174. businessParams := models.BusinessParams{
  13175. Insutype: insutype,
  13176. ClrType: clr_type,
  13177. SetlOptins: "430822",
  13178. StmtBegndate: start_time,
  13179. StmtEnddate: end_time,
  13180. MedfeeSumamt: medfee_sumamt,
  13181. FundPaySumamt: fund_pay_sumamt,
  13182. AcctPay: acct_pay,
  13183. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13184. }
  13185. 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)
  13186. fmt.Println(requestLog)
  13187. fmt.Println(result)
  13188. var dat map[string]interface{}
  13189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13190. fmt.Println(dat)
  13191. } else {
  13192. fmt.Println(err)
  13193. }
  13194. userJSONBytes, _ := json.Marshal(dat)
  13195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13196. utils.ErrorLog("解析失败:%v", err)
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13198. return
  13199. }
  13200. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13201. var baseParams models.BaseParams
  13202. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13203. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13204. baseParams.SecretKey = miConfig.SecretKey
  13205. baseParams.OrgName = miConfig.OrgName
  13206. baseParams.FixmedinsCode = miConfig.Code
  13207. baseParams.EncKey = miConfig.EncKey
  13208. baseParams.AppSecret = miConfig.AppSecret
  13209. baseParams.SignKey = miConfig.SignKey
  13210. baseParams.AppID = miConfig.Code
  13211. baseParams.Doctor = role.UserName
  13212. baseParams.RequestUrl = miConfig.Url
  13213. businessParams := models.BusinessParams{
  13214. Insutype: insutype,
  13215. ClrType: clr_type,
  13216. SetlOptins: clr_org,
  13217. StmtBegndate: start_time,
  13218. StmtEnddate: end_time,
  13219. MedfeeSumamt: medfee_sumamt,
  13220. FundPaySumamt: fund_pay_sumamt,
  13221. AcctPay: acct_pay,
  13222. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13223. }
  13224. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13225. fmt.Println(requestLog)
  13226. fmt.Println(result)
  13227. fmt.Println(err_msg)
  13228. var dat map[string]interface{}
  13229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13230. fmt.Println(dat)
  13231. } else {
  13232. fmt.Println(err)
  13233. }
  13234. userJSONBytes, _ := json.Marshal(dat)
  13235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13236. utils.ErrorLog("解析失败:%v", err)
  13237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13238. return
  13239. }
  13240. } else {
  13241. if len(clr_type) == 0 {
  13242. clr_type = "11"
  13243. }
  13244. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13245. "insutype=" + insutype +
  13246. "&clr_type=" + clr_type +
  13247. "&setl_optins=" + clr_org +
  13248. "&stmt_begndate=" + start_time +
  13249. "&stm_enddate=" + end_time +
  13250. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13251. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13252. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13253. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13254. "&fixmedins_code=" + miConfig.Code +
  13255. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13256. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13257. "&secret_key=" + miConfig.SecretKey +
  13258. "&org_name=" + miConfig.OrgName +
  13259. "&doctor=" + user_name
  13260. fmt.Println(api)
  13261. resp, requestErr := http.Get(api)
  13262. if requestErr != nil {
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13264. return
  13265. }
  13266. body, ioErr := ioutil.ReadAll(resp.Body)
  13267. fmt.Println(body)
  13268. if ioErr != nil {
  13269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13271. return
  13272. }
  13273. var respJSON map[string]interface{}
  13274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13277. return
  13278. }
  13279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13280. userJSONBytes, _ := json.Marshal(respJSON)
  13281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13282. utils.ErrorLog("解析失败:%v", err)
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. }
  13287. if res.Infcode == 0 {
  13288. if res.Output.Stmtinfo.StmtRslt == "0" {
  13289. micc := &models.MedicalInsuranceCostCompare{
  13290. StartTime: startime.Unix(),
  13291. EndTime: endtime.Unix(),
  13292. Insutype: insutype,
  13293. CheckType: 1,
  13294. Num: fixmedins_setl_cnt,
  13295. Mtime: time.Now().Unix(),
  13296. Status: 1,
  13297. UserOrgId: adminUser.CurrentOrgId,
  13298. CostTotal: medfee_sumamt,
  13299. FuncTotal: fund_pay_sumamt,
  13300. PsnPay: acct_pay,
  13301. Creator: admin_user_id,
  13302. Ctime: time.Now().Unix(),
  13303. ClrType: clr_type,
  13304. }
  13305. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  13306. if err == nil {
  13307. c.ServeSuccessJSON(map[string]interface{}{
  13308. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13309. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13310. })
  13311. } else {
  13312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13313. }
  13314. } else {
  13315. c.ServeSuccessJSON(map[string]interface{}{
  13316. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13317. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13318. })
  13319. }
  13320. } else {
  13321. c.ServeSuccessJSON(map[string]interface{}{
  13322. "code": -10,
  13323. "msg": res.ErrMsg,
  13324. })
  13325. }
  13326. }
  13327. }
  13328. func (c *HisApiController) Check310() {
  13329. adminUser := c.GetAdminUserInfo()
  13330. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13331. var user_name string
  13332. user_name = "高慧裕"
  13333. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13334. "insutype=" + "310" +
  13335. "&clr_type=" + "" +
  13336. "&setl_optins=" + "441202" +
  13337. "&stmt_begndate=" + "2022-03-01" +
  13338. "&stm_enddate=" + "2022-03-31" +
  13339. "&medfee_sumamt=" + "194930.12" +
  13340. "&fund_pay_sumamt=" + "188741.46" +
  13341. "&acct_pay=" + "0" +
  13342. "&fixmedins_setl_cnt=" + "452" +
  13343. "&fixmedins_code=" + miConfig.Code +
  13344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13345. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13346. "&secret_key=" + miConfig.SecretKey +
  13347. "&org_name=" + miConfig.OrgName +
  13348. "&doctor=" + user_name
  13349. fmt.Println(api)
  13350. resp, requestErr := http.Get(api)
  13351. if requestErr != nil {
  13352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13353. return
  13354. }
  13355. body, ioErr := ioutil.ReadAll(resp.Body)
  13356. fmt.Println(body)
  13357. if ioErr != nil {
  13358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13360. return
  13361. }
  13362. var respJSON map[string]interface{}
  13363. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13366. return
  13367. }
  13368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13369. userJSONBytes, _ := json.Marshal(respJSON)
  13370. var res ResultEight
  13371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13372. utils.ErrorLog("解析失败:%v", err)
  13373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13374. return
  13375. }
  13376. }
  13377. func (c *HisApiController) Check390() {
  13378. adminUser := c.GetAdminUserInfo()
  13379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13380. var user_name string
  13381. user_name = "高慧裕"
  13382. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13383. "insutype=" + "390" +
  13384. "&clr_type=" + "" +
  13385. "&setl_optins=" + "441202" +
  13386. "&stmt_begndate=" + "2022-03-01" +
  13387. "&stm_enddate=" + "2022-03-31" +
  13388. "&medfee_sumamt=" + "1068448.89" +
  13389. "&fund_pay_sumamt=" + "1014677.62" +
  13390. "&acct_pay=" + "0" +
  13391. "&fixmedins_setl_cnt=" + "1950" +
  13392. "&fixmedins_code=" + miConfig.Code +
  13393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13394. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13395. "&secret_key=" + miConfig.SecretKey +
  13396. "&org_name=" + miConfig.OrgName +
  13397. "&doctor=" + user_name
  13398. fmt.Println(api)
  13399. resp, requestErr := http.Get(api)
  13400. if requestErr != nil {
  13401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13402. return
  13403. }
  13404. body, ioErr := ioutil.ReadAll(resp.Body)
  13405. fmt.Println(body)
  13406. if ioErr != nil {
  13407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13409. return
  13410. }
  13411. var respJSON map[string]interface{}
  13412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13415. return
  13416. }
  13417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13418. userJSONBytes, _ := json.Marshal(respJSON)
  13419. var res ResultEight
  13420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13421. utils.ErrorLog("解析失败:%v", err)
  13422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13423. return
  13424. }
  13425. }
  13426. // 对账明细
  13427. func (c *HisApiController) GetCheckDetailAccount() {
  13428. start_time := c.GetString("start_time")
  13429. end_time := c.GetString("end_time")
  13430. admin_user_id, _ := c.GetInt64("admin_user_id")
  13431. adminUser := c.GetAdminUserInfo()
  13432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13434. timeLayout := "2006-01-02"
  13435. loc, _ := time.LoadLocation("Local")
  13436. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13437. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13438. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13439. rand.Seed(time.Now().UnixNano())
  13440. num := rand.Intn(30000)
  13441. Mkdir(miConfig.OrgName)
  13442. file := strconv.FormatInt(int64(num), 10)
  13443. file_name := file + ".txt"
  13444. zip_name := file + ".zip"
  13445. zip_path := miConfig.OrgName + "/" + zip_name
  13446. file_path := miConfig.OrgName + "/" + file_name
  13447. decimal.DivisionPrecision = 2
  13448. var medfee_sumamt float64
  13449. var psn_cash_pay float64
  13450. var fund_pay_sumamt float64
  13451. fixmedins_setl_cnt := int64(len(orders))
  13452. for _, item := range orders {
  13453. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13454. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  13455. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13456. }
  13457. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  13458. defer f.Close()
  13459. if err != nil {
  13460. fmt.Println(err.Error())
  13461. } else {
  13462. for _, item := range orders {
  13463. var refd_setl_flag string
  13464. if item.OrderStatus == 2 {
  13465. refd_setl_flag = "0"
  13466. var str string
  13467. str = item.SetlId + " " +
  13468. item.MdtrtId + " " +
  13469. item.PsnNo + " " +
  13470. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13471. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13472. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  13473. _, err = f.Write([]byte(str))
  13474. }
  13475. if item.OrderStatus == 3 {
  13476. var str string
  13477. str = item.SetlId + " " +
  13478. item.MdtrtId + " " +
  13479. item.PsnNo + " " +
  13480. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13481. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13482. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  13483. _, err = f.Write([]byte(str))
  13484. var str2 string
  13485. str2 = item.SetlId + " " +
  13486. item.MdtrtId + " " +
  13487. item.PsnNo + " " +
  13488. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  13489. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  13490. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  13491. _, err = f.Write([]byte(str2))
  13492. }
  13493. }
  13494. }
  13495. Zip(file_path, zip_path)
  13496. fmt.Println(ReadFile(zip_path))
  13497. fmt.Println(string(ReadFile(zip_path)))
  13498. if config.IsOpen == 1 {
  13499. var user_name string
  13500. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13501. if role.ID == 0 {
  13502. user_name = "管理员"
  13503. } else {
  13504. user_name = role.UserName
  13505. }
  13506. baseParams := models.BaseParams{
  13507. SecretKey: miConfig.SecretKey,
  13508. FixmedinsCode: miConfig.Code,
  13509. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13510. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13511. OrgName: miConfig.OrgName,
  13512. Doctor: user_name,
  13513. }
  13514. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  13515. var dat map[string]interface{}
  13516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13517. fmt.Println(dat)
  13518. } else {
  13519. fmt.Println(err)
  13520. }
  13521. userJSONBytes, _ := json.Marshal(dat)
  13522. var res ResultNine
  13523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13524. utils.ErrorLog("解析失败:%v", err)
  13525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13526. return
  13527. }
  13528. if res.Infcode == 0 {
  13529. fileNo := res.Output.FileQuryNo
  13530. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  13531. "file_qury_no=" + fileNo +
  13532. "&setl_optins=" + "定点医保中心" +
  13533. "&stmt_begndate=" + start_time +
  13534. "&stm_enddate=" + end_time +
  13535. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13536. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13537. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13538. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13539. "&fixmedins_code=" + miConfig.Code +
  13540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13541. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13542. "&secret_key=" + miConfig.SecretKey +
  13543. "&org_name=" + miConfig.OrgName +
  13544. "&doctor=" + user_name
  13545. resp, requestErr := http.Get(api)
  13546. if requestErr != nil {
  13547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13548. return
  13549. }
  13550. body, ioErr := ioutil.ReadAll(resp.Body)
  13551. if ioErr != nil {
  13552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13554. return
  13555. }
  13556. var respJSON map[string]interface{}
  13557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13560. return
  13561. }
  13562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13563. userJSONBytes, _ := json.Marshal(respJSON)
  13564. var res ResultTen
  13565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13566. utils.ErrorLog("解析失败:%v", err)
  13567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13568. return
  13569. }
  13570. if res.Infcode == 0 {
  13571. service.Gdyb9102(baseParams, zip_name, fileNo)
  13572. micc := &models.MedicalInsuranceCostCompare{
  13573. StartTime: startime.Unix(),
  13574. EndTime: endtime.Unix(),
  13575. Insutype: "0",
  13576. CheckType: 2,
  13577. Num: fixmedins_setl_cnt,
  13578. Mtime: time.Now().Unix(),
  13579. Status: 1,
  13580. UserOrgId: adminUser.CurrentOrgId,
  13581. CostTotal: medfee_sumamt,
  13582. FuncTotal: fund_pay_sumamt,
  13583. PsnPay: psn_cash_pay,
  13584. Creator: admin_user_id,
  13585. Ctime: time.Now().Unix(),
  13586. }
  13587. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13588. c.ServeSuccessJSON(map[string]interface{}{
  13589. "msg": "明细对账成功",
  13590. })
  13591. }
  13592. } else {
  13593. }
  13594. }
  13595. }
  13596. type CustomOrderInfo struct {
  13597. Name string
  13598. Spec string
  13599. Unit string
  13600. Count float64
  13601. Price float64
  13602. Total float64
  13603. }
  13604. func (c *HisApiController) GetBatchSettleAccounts() {
  13605. admin_user_id, _ := c.GetInt64("admin_user_id")
  13606. order_ids := c.GetString("order_ids")
  13607. order_ids_arr := strings.Split(order_ids, ",")
  13608. data3 := []map[string]interface{}{}
  13609. for _, item := range order_ids_arr {
  13610. id, _ := strconv.ParseInt(item, 10, 64)
  13611. order_id := id
  13612. adminUser := c.GetAdminUserInfo()
  13613. order, _ := service.GetHisOrderByID(order_id)
  13614. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13615. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13616. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13617. orderInfos = append(orderInfos, orderInfos_two...)
  13618. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13619. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13620. var diagnosis_ids []string
  13621. if his.ID > 0 {
  13622. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13623. } else {
  13624. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13625. }
  13626. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13627. var dia_config []*models.HisXtDiagnoseConfig
  13628. var name string
  13629. for _, item := range diagnosis_ids {
  13630. id, _ := strconv.ParseInt(item, 10, 64)
  13631. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13632. dia_config = append(dia_config, &diagnosisConfig)
  13633. if len(name) == 0 {
  13634. name = diagnosisConfig.ClassName
  13635. } else {
  13636. name = name + "," + diagnosisConfig.ClassName
  13637. }
  13638. }
  13639. var bedCostTotal float64 = 0 //床位总费
  13640. var bedCostSelfTotal float64 = 0 //床位自费
  13641. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13642. var bedSelfTotal float64 = 0 //床位部分项目自费
  13643. var bedInscpTotal float64 = 0 //床位部分项目自费
  13644. var operationCostTotal float64 = 0 //手术费
  13645. var operationCostSelfTotal float64 = 0 //手术费
  13646. var operationCostPartSelfTotal float64 = 0 //手术费
  13647. var operationSelfTotal float64 = 0 //床位部分项目自费
  13648. var operationInscpTotal float64 = 0 //床位部分项目自费
  13649. var otherCostTotal float64 = 0 //其他费用
  13650. var otherCostSelfTotal float64 = 0 //其他费用
  13651. var otherCostPartSelfTotal float64 = 0 //其他费用
  13652. var otherSelfTotal float64 = 0 //床位部分项目自费
  13653. var otherInscpTotal float64 = 0 //床位部分项目自费
  13654. var materialCostTotal float64 = 0 //材料费
  13655. var materialCostSelfTotal float64 = 0 //材料费
  13656. var materialCostPartSelfTotal float64 = 0 //材料费
  13657. var materialSelfTotal float64 = 0 //床位部分项目自费
  13658. var materialInscpTotal float64 = 0 //床位部分项目自费
  13659. var westernMedicineCostTotal float64 = 0 //西药费
  13660. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13661. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13662. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13663. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13664. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13665. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13666. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13667. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  13668. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  13669. var checkCostTotal float64 = 0 //检查费
  13670. var checkCostSelfTotal float64 = 0 //检查费
  13671. var checkCostPartSelfTotal float64 = 0 //检查费
  13672. var checkSelfTotal float64 = 0 //床位部分项目自费
  13673. var checkInscpTotal float64 = 0 //床位部分项目自费
  13674. var laboratoryCostTotal float64 = 0 //化验费
  13675. var laboratoryCostSelfTotal float64 = 0 //化验费
  13676. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13677. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  13678. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  13679. var treatCostTotal float64 = 0 //治疗费用
  13680. var treatCostSelfTotal float64 = 0 //治疗费用
  13681. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13682. var treatSelfTotal float64 = 0 //床位部分项目自费
  13683. var treatInscpTotal float64 = 0 //床位部分项目自费
  13684. decimal.DivisionPrecision = 2
  13685. for _, item := range orderInfos {
  13686. if item.MedChrgitmType == "01" { //床位费
  13687. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13688. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13689. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13690. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13691. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13692. }
  13693. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  13694. if item.MedChrgitmType == "03" { //检查费
  13695. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13696. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13697. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13698. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13699. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13700. }
  13701. } else {
  13702. if item.MedChrgitmType == "03" { //检查费
  13703. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13704. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13705. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13706. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13707. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13708. }
  13709. }
  13710. if item.MedChrgitmType == "04" { //化验费
  13711. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13712. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13713. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13714. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13715. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13716. }
  13717. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  13718. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13719. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13720. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13721. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13722. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13723. }
  13724. if item.MedChrgitmType == "06" { //手术费
  13725. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13726. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13727. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13728. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13729. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13730. }
  13731. if item.MedChrgitmType == "08" { //材料费
  13732. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13733. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13734. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13735. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13736. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13737. }
  13738. if item.MedChrgitmType == "09" { //西药费
  13739. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13740. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13741. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13742. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13743. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13744. }
  13745. if item.MedChrgitmType == "11" { //中成费
  13746. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13747. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13748. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13749. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13750. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13751. }
  13752. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  13753. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13754. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13755. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13756. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13757. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13758. }
  13759. }
  13760. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13761. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13762. var user_name string
  13763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13764. if role.ID == 0 {
  13765. user_name = "管理员"
  13766. } else {
  13767. user_name = role.UserName
  13768. }
  13769. baseParams := models.BaseParams{
  13770. SecretKey: miConfig.SecretKey,
  13771. FixmedinsCode: miConfig.Code,
  13772. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13773. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13774. OrgName: miConfig.OrgName,
  13775. Doctor: user_name,
  13776. RequestUrl: miConfig.Url,
  13777. AccessKey: miConfig.AccessKey,
  13778. }
  13779. businessParams := models.BusinessParams{
  13780. PsnNo: order.PsnNo,
  13781. MdtrtId: order.MdtrtId,
  13782. SetlId: order.SetlId,
  13783. }
  13784. var res ResultEleven
  13785. var resEleven10265 ResultEleven10265
  13786. if config.IsOpen == 1 {
  13787. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  13788. result := service.Gdyb5203(baseParams, businessParams)
  13789. //service.Gdyb5204(baseParams, businessParams)
  13790. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  13791. var dat map[string]interface{}
  13792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13793. fmt.Println(dat)
  13794. } else {
  13795. fmt.Println(err)
  13796. }
  13797. userJSONBytes, _ := json.Marshal(dat)
  13798. if miConfig.Code == "H15049901371" {
  13799. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  13800. utils.ErrorLog("解析失败:%v", err)
  13801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13802. return
  13803. }
  13804. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13805. res.Output = resEleven10265.Output
  13806. res.ErrMsg = resEleven10265.ErrMsg
  13807. res.Cainfo = resEleven10265.Cainfo
  13808. res.WarnMsg = resEleven10265.WarnMsg
  13809. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13810. res.Infcode = infocode
  13811. } else {
  13812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13813. utils.ErrorLog("解析失败:%v", err)
  13814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13815. return
  13816. }
  13817. }
  13818. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13819. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13820. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13821. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13822. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13823. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13824. var doctor_name string
  13825. if roles.ID == 0 {
  13826. doctor_name = "管理员"
  13827. } else {
  13828. doctor_name = roles.UserName
  13829. }
  13830. yiliao_leibie := ""
  13831. switch order.MedType {
  13832. case "11":
  13833. yiliao_leibie = "普通门诊"
  13834. break
  13835. case "12":
  13836. yiliao_leibie = "门诊挂号"
  13837. break
  13838. case "13":
  13839. yiliao_leibie = "急诊"
  13840. break
  13841. case "14":
  13842. yiliao_leibie = "门诊特殊病"
  13843. break
  13844. case "15":
  13845. yiliao_leibie = "门诊统筹"
  13846. break
  13847. case "16":
  13848. yiliao_leibie = "门诊慢性病"
  13849. break
  13850. case "21":
  13851. yiliao_leibie = "普通住院"
  13852. break
  13853. }
  13854. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13855. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13856. if res.Infcode == 0 {
  13857. data2 := map[string]interface{}{
  13858. "diagnosis": name,
  13859. "order_infos": orderInfos,
  13860. "number": order.MdtrtId,
  13861. "date": order.SettleAccountsDate,
  13862. "charge_admin": charge_admin,
  13863. "printor_admin": printor_admin,
  13864. "info": res.Output.Setlinfo,
  13865. "order": order,
  13866. "bedCostTotal": bedCostTotal,
  13867. "bedCostSelfTotal": bedCostSelfTotal,
  13868. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13869. "bedSelfTotal": bedSelfTotal,
  13870. "bedInscpTotal": bedInscpTotal,
  13871. "operationCostTotal": operationCostTotal,
  13872. "operationCostSelfTotal": operationCostSelfTotal,
  13873. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13874. "operationSelfTotal": operationSelfTotal,
  13875. "operationInscpTotal": operationInscpTotal,
  13876. "otherCostTotal": otherCostTotal,
  13877. "otherCostSelfTotal": otherCostSelfTotal,
  13878. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13879. "otherSelfTotal": otherSelfTotal,
  13880. "otherInscpTotal": otherInscpTotal,
  13881. "materialCostTotal": materialCostTotal,
  13882. "materialCostSelfTotal": materialCostSelfTotal,
  13883. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13884. "materialSelfTotal": materialSelfTotal,
  13885. "materialInscpTotal": materialInscpTotal,
  13886. "westernMedicineCostTotal": westernMedicineCostTotal,
  13887. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13888. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13889. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13890. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13891. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13892. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13893. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13894. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13895. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13896. "checkCostTotal": checkCostTotal,
  13897. "checkCostSelfTotal": checkCostSelfTotal,
  13898. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13899. "checkSelfTotal": checkSelfTotal,
  13900. "checkInscpTotal": checkInscpTotal,
  13901. "laboratoryCostTotal": laboratoryCostTotal,
  13902. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13903. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13904. "laboratorySelfTotal": laboratorySelfTotal,
  13905. "laboratoryInscpTotal": laboratoryInscpTotal,
  13906. "treatCostTotal": treatCostTotal,
  13907. "treatCostSelfTotal": treatCostSelfTotal,
  13908. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13909. "treatSelfTotal": treatSelfTotal,
  13910. "treatInscpTotal": treatInscpTotal,
  13911. "doctor_info": doctor_info,
  13912. "doctor_code": adminRole_two.DoctorCode,
  13913. "doctor_name": doctor_name,
  13914. "health_card_no": order.PsnNo,
  13915. "department": departments.Name,
  13916. "yiliao_leibie": yiliao_leibie,
  13917. "after_money": order.AccountPrice,
  13918. "patient": patient,
  13919. "org_name": miConfig.OrgName,
  13920. "org_code": miConfig.Code,
  13921. "order_number": order.Number,
  13922. "his_hospital": his_hospital,
  13923. "his": his,
  13924. "dia_config": dia_config,
  13925. "psn_cash_pay": order.PsnCashPay,
  13926. //"check_order_info": cus_slice,
  13927. }
  13928. data3 = append(data3, data2)
  13929. }
  13930. }
  13931. }
  13932. c.ServeSuccessJSON(map[string]interface{}{
  13933. "infos": data3,
  13934. })
  13935. }
  13936. func (c *HisApiController) GetSettleAccounts() {
  13937. //id, _ := c.GetInt64("id")
  13938. //record_time := c.GetString("record_time")
  13939. order_id, _ := c.GetInt64("order_id")
  13940. admin_user_id, _ := c.GetInt64("admin_user_id")
  13941. //timeLayout := "2006-01-02"
  13942. //loc, _ := time.LoadLocation("Local")
  13943. //
  13944. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13945. //if err != nil {
  13946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13947. // return
  13948. //}
  13949. //recordDateTime := theTime.Unix()
  13950. adminUser := c.GetAdminUserInfo()
  13951. order, _ := service.GetHisOrderByID(order_id)
  13952. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13953. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13954. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13955. orderInfos = append(orderInfos, orderInfos_two...)
  13956. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13957. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13958. var diagnosis_ids []string
  13959. if his.ID > 0 {
  13960. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13961. } else {
  13962. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13963. }
  13964. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13965. var dia_config []*models.HisXtDiagnoseConfig
  13966. var name string
  13967. for _, item := range diagnosis_ids {
  13968. id, _ := strconv.ParseInt(item, 10, 64)
  13969. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13970. dia_config = append(dia_config, &diagnosisConfig)
  13971. if len(name) == 0 {
  13972. name = diagnosisConfig.ClassName
  13973. } else {
  13974. name = name + "," + diagnosisConfig.ClassName
  13975. }
  13976. }
  13977. var bedCostTotal float64 = 0 //床位总费
  13978. var bedCostSelfTotal float64 = 0 //床位自费
  13979. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13980. var bedSelfTotal float64 = 0 //床位部分项目自费
  13981. var bedInscpTotal float64 = 0 //床位部分项目自费
  13982. var operationCostTotal float64 = 0 //手术费
  13983. var operationCostSelfTotal float64 = 0 //手术费
  13984. var operationCostPartSelfTotal float64 = 0 //手术费
  13985. var operationSelfTotal float64 = 0 //床位部分项目自费
  13986. var operationInscpTotal float64 = 0 //床位部分项目自费
  13987. var otherCostTotal float64 = 0 //其他费用
  13988. var otherCostSelfTotal float64 = 0 //其他费用
  13989. var otherCostPartSelfTotal float64 = 0 //其他费用
  13990. var otherSelfTotal float64 = 0 //床位部分项目自费
  13991. var otherInscpTotal float64 = 0 //床位部分项目自费
  13992. var materialCostTotal float64 = 0 //材料费
  13993. var materialCostSelfTotal float64 = 0 //材料费
  13994. var materialCostPartSelfTotal float64 = 0 //材料费
  13995. var materialSelfTotal float64 = 0 //床位部分项目自费
  13996. var materialInscpTotal float64 = 0 //床位部分项目自费
  13997. var westernMedicineCostTotal float64 = 0 //西药费
  13998. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13999. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14000. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14001. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14002. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14003. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14004. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14005. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14006. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14007. var checkCostTotal float64 = 0 //检查费
  14008. var checkCostSelfTotal float64 = 0 //检查费
  14009. var checkCostPartSelfTotal float64 = 0 //检查费
  14010. var checkSelfTotal float64 = 0 //床位部分项目自费
  14011. var checkInscpTotal float64 = 0 //床位部分项目自费
  14012. var laboratoryCostTotal float64 = 0 //化验费
  14013. var laboratoryCostSelfTotal float64 = 0 //化验费
  14014. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14015. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14016. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14017. var treatCostTotal float64 = 0 //治疗费用
  14018. var treatCostSelfTotal float64 = 0 //治疗费用
  14019. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14020. var treatSelfTotal float64 = 0 //床位部分项目自费
  14021. var treatInscpTotal float64 = 0 //床位部分项目自费
  14022. decimal.DivisionPrecision = 2
  14023. for _, item := range orderInfos {
  14024. if item.MedChrgitmType == "01" { //床位费
  14025. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14026. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14027. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14028. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14029. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14030. }
  14031. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14032. if item.MedChrgitmType == "03" { //检查费
  14033. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14034. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14035. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14036. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14037. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14038. }
  14039. } else {
  14040. if item.MedChrgitmType == "03" { //检查费
  14041. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14042. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14043. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14044. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14045. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14046. }
  14047. }
  14048. if item.MedChrgitmType == "04" { //化验费
  14049. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14050. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14051. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14052. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14053. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14054. }
  14055. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14056. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14057. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14058. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14059. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14060. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14061. }
  14062. if item.MedChrgitmType == "06" { //手术费
  14063. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14064. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14065. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14066. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14067. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14068. }
  14069. if item.MedChrgitmType == "08" { //材料费
  14070. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14071. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14072. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14073. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14074. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14075. }
  14076. if item.MedChrgitmType == "09" { //西药费
  14077. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14078. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14079. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14080. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14081. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14082. }
  14083. if item.MedChrgitmType == "11" { //中成费
  14084. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14085. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14086. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14087. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14088. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14089. }
  14090. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14091. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14092. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14093. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14094. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14095. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14096. }
  14097. }
  14098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14100. var user_name string
  14101. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14102. if role.ID == 0 {
  14103. user_name = "管理员"
  14104. } else {
  14105. user_name = role.UserName
  14106. }
  14107. baseParams := models.BaseParams{
  14108. SecretKey: miConfig.SecretKey,
  14109. FixmedinsCode: miConfig.Code,
  14110. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14111. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14112. OrgName: miConfig.OrgName,
  14113. Doctor: user_name,
  14114. RequestUrl: miConfig.Url,
  14115. AccessKey: miConfig.AccessKey,
  14116. }
  14117. businessParams := models.BusinessParams{
  14118. PsnNo: order.PsnNo,
  14119. MdtrtId: order.MdtrtId,
  14120. SetlId: order.SetlId,
  14121. }
  14122. var res ResultEleven
  14123. var resEleven10265 ResultEleven10265
  14124. if config.IsOpen == 1 {
  14125. if miConfig.MdtrtareaAdmvs == "421300" {
  14126. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14127. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14129. resp, requestErr := http.Get(api)
  14130. if requestErr != nil {
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14132. return
  14133. }
  14134. body, ioErr := ioutil.ReadAll(resp.Body)
  14135. if ioErr != nil {
  14136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14138. return
  14139. }
  14140. var respJSON map[string]interface{}
  14141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14144. return
  14145. }
  14146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14147. result, _ := json.Marshal(respJSON)
  14148. fmt.Println("log")
  14149. fmt.Println(string(result))
  14150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14151. utils.ErrorLog("解析失败:%v", err)
  14152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14153. return
  14154. }
  14155. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14156. var api string
  14157. if miConfig.MdtrtareaAdmvs == "320921" {
  14158. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14159. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14161. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14162. } else {
  14163. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14164. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14165. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14167. }
  14168. resp, requestErr := http.Get(api)
  14169. if requestErr != nil {
  14170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14171. return
  14172. }
  14173. body, ioErr := ioutil.ReadAll(resp.Body)
  14174. if ioErr != nil {
  14175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14177. return
  14178. }
  14179. var respJSON map[string]interface{}
  14180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14183. return
  14184. }
  14185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14186. result, _ := json.Marshal(respJSON)
  14187. fmt.Println("log")
  14188. fmt.Println(string(result))
  14189. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14190. utils.ErrorLog("解析失败:%v", err)
  14191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14192. return
  14193. }
  14194. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14195. res.Output = resEleven10265.Output
  14196. res.ErrMsg = resEleven10265.ErrMsg
  14197. res.Cainfo = resEleven10265.Cainfo
  14198. res.WarnMsg = resEleven10265.WarnMsg
  14199. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14200. res.Infcode = infocode
  14201. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14202. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14203. saveLog(result, requestLog, "5203", "结算单")
  14204. var dat map[string]interface{}
  14205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14206. fmt.Println(dat)
  14207. } else {
  14208. fmt.Println(err)
  14209. }
  14210. userJSONBytes, _ := json.Marshal(dat)
  14211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14212. utils.ErrorLog("解析失败:%v", err)
  14213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14214. return
  14215. }
  14216. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14217. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  14218. saveLog(result, requestLog, "5203", "结算单")
  14219. var dat map[string]interface{}
  14220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14221. fmt.Println(dat)
  14222. } else {
  14223. fmt.Println(err)
  14224. }
  14225. userJSONBytes, _ := json.Marshal(dat)
  14226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14227. utils.ErrorLog("解析失败:%v", err)
  14228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14229. return
  14230. }
  14231. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14232. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  14233. saveLog(result, requestLog, "5203", "结算单")
  14234. var dat map[string]interface{}
  14235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14236. fmt.Println(dat)
  14237. } else {
  14238. fmt.Println(err)
  14239. }
  14240. userJSONBytes, _ := json.Marshal(dat)
  14241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14242. utils.ErrorLog("解析失败:%v", err)
  14243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14244. return
  14245. }
  14246. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14247. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14248. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14249. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14250. resp, requestErr := http.Get(api)
  14251. if requestErr != nil {
  14252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14253. return
  14254. }
  14255. body, ioErr := ioutil.ReadAll(resp.Body)
  14256. if ioErr != nil {
  14257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. var respJSON map[string]interface{}
  14262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14265. return
  14266. }
  14267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14268. result, _ := json.Marshal(respJSON)
  14269. fmt.Println("log")
  14270. fmt.Println(string(result))
  14271. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14272. utils.ErrorLog("解析失败:%v", err)
  14273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14274. return
  14275. }
  14276. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14277. res.Output = resEleven10265.Output
  14278. res.ErrMsg = resEleven10265.ErrMsg
  14279. res.Cainfo = resEleven10265.Cainfo
  14280. res.WarnMsg = resEleven10265.WarnMsg
  14281. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14282. res.Infcode = infocode
  14283. } else {
  14284. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14285. result := service.Gdyb5203(baseParams, businessParams)
  14286. //service.Gdyb5204(baseParams, businessParams)
  14287. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14288. var dat map[string]interface{}
  14289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14290. fmt.Println(dat)
  14291. } else {
  14292. fmt.Println(err)
  14293. }
  14294. userJSONBytes, _ := json.Marshal(dat)
  14295. if miConfig.Code == "H15049901371" {
  14296. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14297. utils.ErrorLog("解析失败:%v", err)
  14298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14299. return
  14300. }
  14301. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14302. res.Output = resEleven10265.Output
  14303. res.ErrMsg = resEleven10265.ErrMsg
  14304. res.Cainfo = resEleven10265.Cainfo
  14305. res.WarnMsg = resEleven10265.WarnMsg
  14306. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14307. res.Infcode = infocode
  14308. } else {
  14309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14310. utils.ErrorLog("解析失败:%v", err)
  14311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14312. return
  14313. }
  14314. }
  14315. }
  14316. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14317. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14318. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14319. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14320. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14322. var doctor_name string
  14323. if roles.ID == 0 {
  14324. doctor_name = "管理员"
  14325. } else {
  14326. doctor_name = roles.UserName
  14327. }
  14328. yiliao_leibie := ""
  14329. switch order.MedType {
  14330. case "11":
  14331. yiliao_leibie = "普通门诊"
  14332. break
  14333. case "12":
  14334. yiliao_leibie = "门诊挂号"
  14335. break
  14336. case "13":
  14337. yiliao_leibie = "急诊"
  14338. break
  14339. case "14":
  14340. yiliao_leibie = "门诊特殊病"
  14341. break
  14342. case "15":
  14343. yiliao_leibie = "门诊统筹"
  14344. break
  14345. case "16":
  14346. yiliao_leibie = "门诊慢性病"
  14347. break
  14348. case "21":
  14349. yiliao_leibie = "普通住院"
  14350. break
  14351. }
  14352. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14353. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14354. if res.Infcode == 0 {
  14355. c.ServeSuccessJSON(map[string]interface{}{
  14356. "diagnosis": name,
  14357. "order_infos": orderInfos,
  14358. "number": order.MdtrtId,
  14359. "date": order.SettleAccountsDate,
  14360. "charge_admin": charge_admin,
  14361. "printor_admin": printor_admin,
  14362. "info": res.Output.Setlinfo,
  14363. "order": order,
  14364. "bedCostTotal": bedCostTotal,
  14365. "bedCostSelfTotal": bedCostSelfTotal,
  14366. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14367. "bedSelfTotal": bedSelfTotal,
  14368. "bedInscpTotal": bedInscpTotal,
  14369. "operationCostTotal": operationCostTotal,
  14370. "operationCostSelfTotal": operationCostSelfTotal,
  14371. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14372. "operationSelfTotal": operationSelfTotal,
  14373. "operationInscpTotal": operationInscpTotal,
  14374. "otherCostTotal": otherCostTotal,
  14375. "otherCostSelfTotal": otherCostSelfTotal,
  14376. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14377. "otherSelfTotal": otherSelfTotal,
  14378. "otherInscpTotal": otherInscpTotal,
  14379. "materialCostTotal": materialCostTotal,
  14380. "materialCostSelfTotal": materialCostSelfTotal,
  14381. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14382. "materialSelfTotal": materialSelfTotal,
  14383. "materialInscpTotal": materialInscpTotal,
  14384. "westernMedicineCostTotal": westernMedicineCostTotal,
  14385. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14386. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14387. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14388. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14389. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14390. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14391. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14392. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14393. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14394. "checkCostTotal": checkCostTotal,
  14395. "checkCostSelfTotal": checkCostSelfTotal,
  14396. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14397. "checkSelfTotal": checkSelfTotal,
  14398. "checkInscpTotal": checkInscpTotal,
  14399. "laboratoryCostTotal": laboratoryCostTotal,
  14400. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14401. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14402. "laboratorySelfTotal": laboratorySelfTotal,
  14403. "laboratoryInscpTotal": laboratoryInscpTotal,
  14404. "treatCostTotal": treatCostTotal,
  14405. "treatCostSelfTotal": treatCostSelfTotal,
  14406. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14407. "treatSelfTotal": treatSelfTotal,
  14408. "treatInscpTotal": treatInscpTotal,
  14409. "doctor_info": doctor_info,
  14410. "doctor_code": adminRole_two.DoctorCode,
  14411. "doctor_name": doctor_name,
  14412. "health_card_no": order.PsnNo,
  14413. "department": departments.Name,
  14414. "yiliao_leibie": yiliao_leibie,
  14415. "after_money": order.AccountPrice,
  14416. "patient": patient,
  14417. "org_name": miConfig.OrgName,
  14418. "org_code": miConfig.Code,
  14419. "order_number": order.Number,
  14420. "his_hospital": his_hospital,
  14421. "his": his,
  14422. "dia_config": dia_config,
  14423. "psn_cash_pay": order.PsnCashPay,
  14424. //"check_order_info": cus_slice,
  14425. })
  14426. }
  14427. }
  14428. }
  14429. func (c *HisApiController) CheckTreatment() {
  14430. patient_id, _ := c.GetInt64("patient_id")
  14431. id_card_no := c.GetString("id_card_no")
  14432. insutype := c.GetString("insutype")
  14433. med_type := c.GetString("med_type")
  14434. admin_user_id, _ := c.GetInt64("admin_user_id")
  14435. adminUser := c.GetAdminUserInfo()
  14436. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14438. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14439. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14440. if miConfig.MdtrtareaAdmvs == "421300" {
  14441. var res ResultTwo
  14442. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  14443. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14444. "&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)
  14445. resp, requestErr := http.Get(api)
  14446. if requestErr != nil {
  14447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14448. return
  14449. }
  14450. body, ioErr := ioutil.ReadAll(resp.Body)
  14451. if ioErr != nil {
  14452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14454. return
  14455. }
  14456. var respJSON map[string]interface{}
  14457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14460. return
  14461. }
  14462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14463. result, _ := json.Marshal(respJSON)
  14464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14465. utils.ErrorLog("解析失败:%v", err)
  14466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14467. return
  14468. }
  14469. if res.Infcode == 0 {
  14470. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  14471. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14472. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  14473. resp, requestErr := http.Get(api)
  14474. if requestErr != nil {
  14475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14476. return
  14477. }
  14478. body, ioErr := ioutil.ReadAll(resp.Body)
  14479. if ioErr != nil {
  14480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14482. return
  14483. }
  14484. var respJSON map[string]interface{}
  14485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14488. return
  14489. }
  14490. var res Result2001
  14491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14492. result2, _ := json.Marshal(respJSON)
  14493. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14494. utils.ErrorLog("解析失败:%v", err)
  14495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14496. return
  14497. }
  14498. if res.Infcode == 0 {
  14499. c.ServeSuccessJSON(map[string]interface{}{
  14500. "msg": res.Output.Trtinfo,
  14501. })
  14502. }
  14503. } else {
  14504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14505. return
  14506. }
  14507. } else {
  14508. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14509. var dat map[string]interface{}
  14510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14511. fmt.Println(dat)
  14512. } else {
  14513. fmt.Println(err)
  14514. }
  14515. userJSONBytes, _ := json.Marshal(dat)
  14516. var res ResultTwo
  14517. var res10265 ResultTwo10265
  14518. if miConfig.Code == "H15049901371" {
  14519. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14520. utils.ErrorLog("解析失败:%v", err)
  14521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14522. return
  14523. }
  14524. res.ErrMsg = res10265.ErrMsg
  14525. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14526. res.Infcode = infocode
  14527. res.Output = res10265.Output
  14528. res.InfRefmsgid = res10265.InfRefmsgid
  14529. } else {
  14530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14531. utils.ErrorLog("解析失败:%v", err)
  14532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14533. return
  14534. }
  14535. }
  14536. var user_name string
  14537. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  14538. if role.ID == 0 {
  14539. user_name = "xxx"
  14540. } else {
  14541. user_name = role.UserName
  14542. }
  14543. baseParams := models.BaseParams{
  14544. SecretKey: miConfig.SecretKey,
  14545. FixmedinsCode: miConfig.Code,
  14546. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14547. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14548. OrgName: miConfig.OrgName,
  14549. Doctor: user_name,
  14550. }
  14551. if config.IsOpen == 1 {
  14552. if miConfig.Code == "H15049901371" {
  14553. if med_type == "14" {
  14554. if insutype == "390" {
  14555. med_type = "9933"
  14556. } else if insutype == "310" {
  14557. med_type = "990502"
  14558. }
  14559. } else if med_type == "11" {
  14560. med_type = "11"
  14561. }
  14562. }
  14563. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  14564. var dat map[string]interface{}
  14565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14566. fmt.Println(dat)
  14567. } else {
  14568. fmt.Println(err)
  14569. }
  14570. var res Result2001
  14571. var res10265 Result2001Org10265
  14572. if miConfig.Code == "H15049901371" {
  14573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14574. utils.ErrorLog("解析失败:%v", err)
  14575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14576. return
  14577. }
  14578. res.ErrMsg = res10265.ErrMsg
  14579. res.Output = res10265.Output
  14580. res.InfRefmsgid = res10265.InfRefmsgid
  14581. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14582. res.Infcode = infocode
  14583. } else {
  14584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14585. utils.ErrorLog("解析失败:%v", err)
  14586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14587. return
  14588. }
  14589. }
  14590. if res.Infcode == 0 {
  14591. c.ServeSuccessJSON(map[string]interface{}{
  14592. "msg": res.Output.Trtinfo,
  14593. })
  14594. }
  14595. }
  14596. }
  14597. }
  14598. //func (c *HisApiController) PutRecord() {
  14599. // id, _ := c.GetInt64("id")
  14600. // record_time := c.GetString("record_time")
  14601. // timeLayout := "2006-01-02"
  14602. // loc, _ := time.LoadLocation("Local")
  14603. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14604. // if err != nil {
  14605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14606. // return
  14607. // }
  14608. // recordDateTime := theTime.Unix()
  14609. //
  14610. // adminInfo := c.GetAdminUserInfo()
  14611. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  14612. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14613. //
  14614. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14615. //
  14616. // fmt.Println(miConfig.SecretKey)
  14617. //
  14618. // if patient == nil {
  14619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14620. // return
  14621. // }
  14622. // if len(patient.IdCardNo) == 0 {
  14623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  14624. // return
  14625. // }
  14626. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14627. // if config.IsOpen == 1 {
  14628. // 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
  14629. // resp, requestErr := http.Get(api)
  14630. // if requestErr != nil {
  14631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14632. // return
  14633. // }
  14634. // defer resp.Body.Close()
  14635. // body, ioErr := ioutil.ReadAll(resp.Body)
  14636. // if ioErr != nil {
  14637. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14639. // return
  14640. // }
  14641. // var respJSON map[string]interface{}
  14642. //
  14643. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14644. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14646. // return
  14647. // }
  14648. //
  14649. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14650. // userJSONBytes, _ := json.Marshal(userJSON)
  14651. // var res ResultTwo
  14652. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14653. // utils.ErrorLog("解析失败:%v", err)
  14654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14655. // return
  14656. // }
  14657. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14658. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14659. // infoStr := string(Iinfos)
  14660. // idetinfoStr := string(Idetinfos)
  14661. //
  14662. // if res.Infcode == 0 {
  14663. // his := models.VMHisPatient{
  14664. // Status: 1,
  14665. // Ctime: time.Now().Unix(),
  14666. // Mtime: time.Now().Unix(),
  14667. // PsnNo: res.Output.Baseinfo.PsnNo,
  14668. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  14669. // Certno: res.Output.Baseinfo.Certno,
  14670. // PsnName: res.Output.Baseinfo.PsnName,
  14671. // Gend: res.Output.Baseinfo.Gend,
  14672. // Naty: res.Output.Baseinfo.Naty,
  14673. // Brdy: res.Output.Baseinfo.Brdy,
  14674. // Age: res.Output.Baseinfo.Age,
  14675. // Iinfo: infoStr,
  14676. // Idetinfo: idetinfoStr,
  14677. // PatientId: patient.ID,
  14678. // RecordDate: theTime.Unix(),
  14679. // UserOrgId: adminInfo.CurrentOrgId,
  14680. // AdminUserId: adminInfo.AdminUser.Id,
  14681. // IsReturn: 1,
  14682. // }
  14683. //
  14684. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  14685. // //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")
  14686. // //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")
  14687. //
  14688. // //var dat map[string]interface{}
  14689. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14690. // // fmt.Println(dat)
  14691. // //} else {
  14692. // // fmt.Println(err)
  14693. // //}
  14694. //
  14695. // var dat2 map[string]interface{}
  14696. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14697. // fmt.Println(dat2)
  14698. // } else {
  14699. // fmt.Println(err)
  14700. // }
  14701. //
  14702. // } else {
  14703. // adminUser := c.GetAdminUserInfo()
  14704. // errlog := &models.HisOrderError{
  14705. // UserOrgId: adminUser.CurrentOrgId,
  14706. // Ctime: time.Now().Unix(),
  14707. // Mtime: time.Now().Unix(),
  14708. // ErrMsg: res.ErrMsg,
  14709. // Status: 1,
  14710. // PatientId: id,
  14711. // RecordTime: recordDateTime,
  14712. // Stage: 1,
  14713. // }
  14714. // service.CreateErrMsgLog(errlog)
  14715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  14716. // return
  14717. // }
  14718. // }
  14719. //
  14720. //}
  14721. //func (c *HisApiController) GetUploadDiag() {
  14722. // id, _ := c.GetInt64("id")
  14723. // record_time := c.GetString("record_time")
  14724. //
  14725. // diagnosis_id, _ := c.GetInt64("diagnosis")
  14726. // sick_type, _ := c.GetInt64("sick_type")
  14727. // reg_type, _ := c.GetInt64("reg_type")
  14728. //
  14729. // timeLayout := "2006-01-02"
  14730. // loc, _ := time.LoadLocation("Local")
  14731. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14732. // if err != nil {
  14733. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14734. // return
  14735. // }
  14736. //
  14737. // var patientPrescription models.HisPrescriptionInfo
  14738. // recordDateTime := theTime.Unix()
  14739. // adminInfo := c.GetAdminUserInfo()
  14740. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14741. //
  14742. // if patientPrescription.ID == 0 {
  14743. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14744. // }
  14745. //
  14746. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14747. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  14748. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14749. // sickConfig, _ := service.FindSickById(sick_type)
  14750. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14751. //
  14752. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  14753. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  14754. // "&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 +
  14755. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  14756. // resp2, requestErr2 := http.Get(api2)
  14757. // if requestErr2 != nil {
  14758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14759. // return
  14760. // }
  14761. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  14762. // if ioErr2 != nil {
  14763. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  14764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14765. // return
  14766. // }
  14767. // var respJSON2 map[string]interface{}
  14768. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  14769. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14771. // return
  14772. // }
  14773. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14774. // userJSONBytes2, _ := json.Marshal(respJSON2)
  14775. //
  14776. // var res2 ResultSix
  14777. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14778. // utils.ErrorLog("解析失败:%v", err)
  14779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14780. // return
  14781. // }
  14782. // if res2.Infcode != 0 {
  14783. // adminUser := c.GetAdminUserInfo()
  14784. // errlog := &models.HisOrderError{
  14785. // UserOrgId: adminUser.CurrentOrgId,
  14786. // Ctime: time.Now().Unix(),
  14787. // Mtime: time.Now().Unix(),
  14788. // ErrMsg: res2.ErrMsg,
  14789. // Status: 1,
  14790. // PatientId: id,
  14791. // RecordTime: recordDateTime,
  14792. // Stage: 3,
  14793. // }
  14794. // service.CreateErrMsgLog(errlog)
  14795. //
  14796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  14797. // return
  14798. // }
  14799. //
  14800. // c.ServeSuccessJSON(map[string]interface{}{
  14801. // "msg": "上传成功",
  14802. // })
  14803. //
  14804. //}
  14805. type QueryResult struct {
  14806. ID int64
  14807. Name string
  14808. Code string
  14809. List_type_code string
  14810. }
  14811. func (c *HisApiController) GetCheckCode() {
  14812. ids_str := c.GetString("ids")
  14813. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14814. ids_arr := strings.Split(ids_str, ",")
  14815. var queryResult []QueryResult
  14816. ids := make([]int64, 0)
  14817. for _, item := range ids_arr {
  14818. id, _ := strconv.ParseInt(item, 10, 64)
  14819. ids = append(ids, id)
  14820. }
  14821. if record_type == 1 {
  14822. drugs, _ := service.GetBatchDrugList(ids)
  14823. for _, item := range drugs {
  14824. result := QueryResult{
  14825. ID: item.ID,
  14826. Name: item.DrugName,
  14827. Code: item.MedicalInsuranceNumber,
  14828. List_type_code: "101",
  14829. }
  14830. queryResult = append(queryResult, result)
  14831. }
  14832. } else if record_type == 2 {
  14833. goods, _ := service.GetBatchGoodInformationList(ids)
  14834. for _, item := range goods {
  14835. result := QueryResult{
  14836. ID: item.ID,
  14837. Name: item.GoodName,
  14838. Code: item.MedicalInsuranceNumber,
  14839. List_type_code: "301",
  14840. }
  14841. queryResult = append(queryResult, result)
  14842. }
  14843. } else if record_type == 3 {
  14844. projects, _ := service.GetBathchMyPorjecgList(ids)
  14845. for _, item := range projects {
  14846. result := QueryResult{
  14847. ID: item.ID,
  14848. Name: item.ProjectName,
  14849. Code: item.MedicalCode,
  14850. List_type_code: "201",
  14851. }
  14852. queryResult = append(queryResult, result)
  14853. }
  14854. }
  14855. admin_user_id, _ := c.GetInt64("admin_user_id")
  14856. adminUser := c.GetAdminUserInfo()
  14857. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14858. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14859. var user_name string
  14860. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14861. if role.ID == 0 {
  14862. user_name = "xxx"
  14863. } else {
  14864. user_name = role.UserName
  14865. }
  14866. baseParams := &models.BaseParams{
  14867. SecretKey: miConfig.SecretKey,
  14868. FixmedinsCode: miConfig.Code,
  14869. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14870. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14871. OrgName: miConfig.OrgName,
  14872. Doctor: user_name,
  14873. }
  14874. if config.IsOpen == 1 {
  14875. for _, item := range queryResult {
  14876. var result string
  14877. if record_type == 1 {
  14878. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14879. } else if record_type == 2 {
  14880. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14881. } else if record_type == 3 {
  14882. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14883. }
  14884. var dat map[string]interface{}
  14885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14886. fmt.Println(dat)
  14887. } else {
  14888. fmt.Println(err)
  14889. }
  14890. userJSONBytes, _ := json.Marshal(dat)
  14891. var res ResultSix
  14892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14893. utils.ErrorLog("解析失败:%v", err)
  14894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14895. return
  14896. }
  14897. if res.Infcode == 0 {
  14898. if record_type == 1 {
  14899. service.UpdateBaseDrugById(item.ID)
  14900. } else if record_type == 2 {
  14901. service.UpdateGoodInformaitonByDetail(item.ID)
  14902. } else if record_type == 3 {
  14903. service.UpdateProjectById(item.ID)
  14904. }
  14905. c.ServeSuccessJSON(map[string]interface{}{
  14906. "failed_code": 0,
  14907. "msg": "目录对照成功",
  14908. })
  14909. } else {
  14910. c.ServeSuccessJSON(map[string]interface{}{
  14911. "failed_code": -10,
  14912. "msg": res.ErrMsg,
  14913. })
  14914. }
  14915. }
  14916. }
  14917. }
  14918. func (c *HisApiController) UnCheckCode() {
  14919. ids_str := c.GetString("ids")
  14920. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14921. admin_user_id, _ := c.GetInt64("admin_user_id")
  14922. ids_arr := strings.Split(ids_str, ",")
  14923. var queryResult []QueryResult
  14924. ids := make([]int64, 0)
  14925. for _, item := range ids_arr {
  14926. id, _ := strconv.ParseInt(item, 10, 64)
  14927. ids = append(ids, id)
  14928. }
  14929. if record_type == 1 {
  14930. drugs, _ := service.GetBatchDrugList(ids)
  14931. for _, item := range drugs {
  14932. result := QueryResult{
  14933. ID: item.ID,
  14934. Name: item.DrugName,
  14935. Code: item.MedicalInsuranceNumber,
  14936. List_type_code: "101",
  14937. }
  14938. queryResult = append(queryResult, result)
  14939. }
  14940. } else if record_type == 2 {
  14941. goods, _ := service.GetBatchGoodInformationList(ids)
  14942. for _, item := range goods {
  14943. result := QueryResult{
  14944. ID: item.ID,
  14945. Name: item.GoodName,
  14946. Code: item.MedicalInsuranceNumber,
  14947. List_type_code: "301",
  14948. }
  14949. queryResult = append(queryResult, result)
  14950. }
  14951. } else if record_type == 3 {
  14952. projects, _ := service.GetBathchMyPorjecgList(ids)
  14953. for _, item := range projects {
  14954. result := QueryResult{
  14955. ID: item.ID,
  14956. Name: item.ProjectName,
  14957. Code: item.MedicalCode,
  14958. List_type_code: "201",
  14959. }
  14960. queryResult = append(queryResult, result)
  14961. }
  14962. }
  14963. adminUser := c.GetAdminUserInfo()
  14964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14965. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14966. var user_name string
  14967. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14968. if role.ID == 0 {
  14969. user_name = "xxx"
  14970. } else {
  14971. user_name = role.UserName
  14972. }
  14973. baseParams := &models.BaseParams{
  14974. SecretKey: miConfig.SecretKey,
  14975. FixmedinsCode: miConfig.Code,
  14976. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14977. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14978. OrgName: miConfig.OrgName,
  14979. Doctor: user_name,
  14980. }
  14981. if config.IsOpen == 1 {
  14982. for _, item := range queryResult {
  14983. var result string
  14984. if record_type == 1 {
  14985. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14986. } else if record_type == 2 {
  14987. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14988. } else if record_type == 3 {
  14989. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14990. }
  14991. var dat2 map[string]interface{}
  14992. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  14993. fmt.Println(dat2)
  14994. } else {
  14995. fmt.Println(err)
  14996. }
  14997. userJSONBytes, _ := json.Marshal(dat2)
  14998. var res ResultSix
  14999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15000. utils.ErrorLog("解析失败:%v", err)
  15001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15002. return
  15003. }
  15004. if res.Infcode == 0 {
  15005. if record_type == 1 {
  15006. service.UpdateDrugByIdDetail(item.ID)
  15007. } else if record_type == 2 {
  15008. service.UpdateGoodInfoById(item.ID)
  15009. } else if record_type == 3 {
  15010. service.UpdateMyProjectById(item.ID)
  15011. }
  15012. c.ServeSuccessJSON(map[string]interface{}{
  15013. "failed_code": 0,
  15014. "msg": "撤销目录对照成功",
  15015. })
  15016. } else {
  15017. c.ServeSuccessJSON(map[string]interface{}{
  15018. "failed_code": -10,
  15019. "msg": res.ErrMsg,
  15020. })
  15021. }
  15022. }
  15023. }
  15024. }
  15025. func (c *HisApiController) GetPatientInfo() {
  15026. id_card_no := c.GetString("id_card_no")
  15027. admin_user_id, _ := c.GetInt64("admin_user_id")
  15028. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  15029. if patient.ID == 0 {
  15030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15031. return
  15032. }
  15033. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15034. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15035. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  15036. if config.IsOpen == 1 {
  15037. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15038. var dat map[string]interface{}
  15039. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15040. fmt.Println(dat)
  15041. } else {
  15042. fmt.Println(err)
  15043. }
  15044. userJSONBytes, _ := json.Marshal(dat)
  15045. var res ResultTwo
  15046. var res10265 ResultTwo10265
  15047. if miConfig.Code == "H15049901371" {
  15048. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15049. utils.ErrorLog("解析失败:%v", err)
  15050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15051. return
  15052. }
  15053. res.ErrMsg = res10265.ErrMsg
  15054. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15055. res.Infcode = infocode
  15056. res.Output = res10265.Output
  15057. res.InfRefmsgid = res10265.InfRefmsgid
  15058. } else {
  15059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15060. utils.ErrorLog("解析失败:%v", err)
  15061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15062. return
  15063. }
  15064. }
  15065. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15066. // utils.ErrorLog("解析失败:%v", err)
  15067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15068. // return
  15069. //}
  15070. for index, item := range res.Output.Iinfo {
  15071. if item.PsnInsuStas == "2" {
  15072. fmt.Println("--------")
  15073. res.Output.Iinfo[index].Insutype = "300"
  15074. res.Output.Iinfo[index].PsnInsuStas = "1"
  15075. }
  15076. }
  15077. fmt.Println(res.Output.Iinfo)
  15078. if res.Infcode != 0 {
  15079. c.ServeSuccessJSON(map[string]interface{}{
  15080. "failed_code": -10,
  15081. "msg": res.ErrMsg,
  15082. })
  15083. } else {
  15084. c.ServeSuccessJSON(map[string]interface{}{
  15085. "failed_code": 0,
  15086. "info": res,
  15087. })
  15088. }
  15089. }
  15090. }
  15091. func (c *HisApiController) PsnPutOnRecord() {
  15092. record_type, _ := c.GetInt64("type")
  15093. patient_id, _ := c.GetInt64("patient_id")
  15094. admin_user_id, _ := c.GetInt64("admin_user_id")
  15095. start_time := c.GetString("start_time")
  15096. end_time := c.GetString("end_time")
  15097. adminUser := c.GetAdminUserInfo()
  15098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15100. var patients []*models.Patients
  15101. if record_type == 1 { //全部备案
  15102. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  15103. patients = append(patients, patient...)
  15104. } else { //单个备案
  15105. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15106. patients = append(patients, patient)
  15107. }
  15108. var user_name string
  15109. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15110. if role.ID == 0 {
  15111. user_name = "xxx"
  15112. } else {
  15113. user_name = role.UserName
  15114. }
  15115. if config.IsOpen == 1 {
  15116. for _, item := range patients {
  15117. 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
  15118. resp, requestErr := http.Get(api)
  15119. if requestErr != nil {
  15120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15121. return
  15122. }
  15123. defer resp.Body.Close()
  15124. body, ioErr := ioutil.ReadAll(resp.Body)
  15125. if ioErr != nil {
  15126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15128. return
  15129. }
  15130. var respJSON map[string]interface{}
  15131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15134. return
  15135. }
  15136. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15137. userJSONBytes, _ := json.Marshal(userJSON)
  15138. var res ResultTwo
  15139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15140. utils.ErrorLog("解析失败:%v", err)
  15141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15142. return
  15143. }
  15144. if res.Infcode == 0 {
  15145. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  15146. var dat map[string]interface{}
  15147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15148. fmt.Println(dat)
  15149. } else {
  15150. fmt.Println(err)
  15151. }
  15152. userJSONBytes, _ := json.Marshal(dat)
  15153. var res2 ResultThirteen
  15154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15155. utils.ErrorLog("解析失败:%v", err)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. if res2.Infcode == 0 {
  15160. psnResult := &models.GdybPsnRecord{
  15161. UserOrgId: adminUser.CurrentOrgId,
  15162. PatientId: item.ID,
  15163. PsnNo: res.Output.Baseinfo.PsnNo,
  15164. Ctime: time.Now().Unix(),
  15165. Mtime: time.Now().Unix(),
  15166. Status: 1,
  15167. IsCancel: 1,
  15168. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15169. }
  15170. service.CreatePsnRecord(psnResult)
  15171. } else {
  15172. c.ServeSuccessJSON(map[string]interface{}{
  15173. "failed_code": -10,
  15174. "msg": res2.ErrMsg,
  15175. })
  15176. return
  15177. }
  15178. }
  15179. }
  15180. }
  15181. }
  15182. func (c *HisApiController) PsnUnPutOnRecord() {
  15183. id, _ := c.GetInt64("id")
  15184. //record_type, _ := c.GetInt64("type")
  15185. admin_user_id, _ := c.GetInt64("admin_user_id")
  15186. adminUser := c.GetAdminUserInfo()
  15187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15188. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15189. var user_name string
  15190. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15191. if role.ID == 0 {
  15192. user_name = "xxx"
  15193. } else {
  15194. user_name = role.UserName
  15195. }
  15196. psn_record, _ := service.GetPsnRecordById(id)
  15197. if psn_record.ID == 0 {
  15198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15199. return
  15200. }
  15201. if config.IsOpen == 1 {
  15202. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15203. var dat map[string]interface{}
  15204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15205. fmt.Println(dat)
  15206. } else {
  15207. fmt.Println(err)
  15208. }
  15209. userJSONBytes, _ := json.Marshal(dat)
  15210. var res ResultFourteen
  15211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15212. utils.ErrorLog("解析失败:%v", err)
  15213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15214. return
  15215. }
  15216. if res.Infcode == 0 {
  15217. psn_record.IsCancel = 2
  15218. service.CreatePsnRecord(&psn_record)
  15219. } else {
  15220. c.ServeSuccessJSON(map[string]interface{}{
  15221. "failed_code": -10,
  15222. "msg": res.ErrMsg,
  15223. })
  15224. return
  15225. }
  15226. }
  15227. }
  15228. func (c *HisApiController) PsnPutNCDSOnRecord() {
  15229. patient_id, _ := c.GetInt64("patient_id")
  15230. insutype_two := c.GetString("insutype")
  15231. psn_no := c.GetString("psn_no")
  15232. doctor_id, _ := c.GetInt64("doctor_id")
  15233. sick_id, _ := c.GetInt64("sick_id")
  15234. department_id, _ := c.GetInt64("department_id")
  15235. start_time := c.GetString("start_time")
  15236. end_time := c.GetString("end_time")
  15237. check_time := c.GetString("check_time")
  15238. hospital_code := c.GetString("hospital_code")
  15239. hospital_name := c.GetString("hospital_name")
  15240. adminUser := c.GetAdminUserInfo()
  15241. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15243. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15244. sick, _ := service.FindSickById(sick_id)
  15245. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15246. if len(hospital_code) == 0 {
  15247. hospital_code = miConfig.Code
  15248. }
  15249. if len(hospital_name) == 0 {
  15250. hospital_name = miConfig.OrgName
  15251. }
  15252. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15253. var res ResultTwo
  15254. var res10265 ResultTwo10265
  15255. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15256. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  15257. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  15258. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  15259. "&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
  15260. resp, requestErr := http.Get(api)
  15261. if requestErr != nil {
  15262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15263. return
  15264. }
  15265. body, ioErr := ioutil.ReadAll(resp.Body)
  15266. if ioErr != nil {
  15267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15269. return
  15270. }
  15271. var respJSON map[string]interface{}
  15272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15275. return
  15276. }
  15277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15278. result, _ := json.Marshal(respJSON)
  15279. fmt.Println("log")
  15280. fmt.Println(string(result))
  15281. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15282. utils.ErrorLog("解析失败:%v", err)
  15283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15284. return
  15285. }
  15286. res.ErrMsg = res10265.ErrMsg
  15287. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15288. res.Infcode = infocode
  15289. res.Output = res10265.Output
  15290. res.InfRefmsgid = res10265.InfRefmsgid
  15291. } else {
  15292. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15293. if miConfig.Code == "H15049901371" {
  15294. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15295. utils.ErrorLog("解析失败:%v", err)
  15296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15297. return
  15298. }
  15299. res.ErrMsg = res10265.ErrMsg
  15300. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15301. res.Infcode = infocode
  15302. res.Output = res10265.Output
  15303. res.InfRefmsgid = res10265.InfRefmsgid
  15304. } else {
  15305. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15306. utils.ErrorLog("解析失败:%v", err)
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. return
  15309. }
  15310. }
  15311. }
  15312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15313. infoStr := string(Iinfos)
  15314. var rf []*ResultFive
  15315. json.Unmarshal([]byte(infoStr), &rf)
  15316. var insuplc_admdvs string
  15317. var insutype string
  15318. var is390 int = 0
  15319. var is310 int = 0
  15320. var insutypes []*ResultFive
  15321. for _, item := range rf {
  15322. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15323. insutypes = append(insutypes, item)
  15324. }
  15325. }
  15326. if len(insutypes) == 1 {
  15327. insutype = insutypes[0].Insutype
  15328. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15329. } else {
  15330. for _, i := range insutypes {
  15331. if i.Insutype == "390" {
  15332. is390 = 1
  15333. }
  15334. if i.Insutype == "310" {
  15335. is310 = 1
  15336. }
  15337. }
  15338. }
  15339. if is390 == 1 {
  15340. insutype = "390"
  15341. }
  15342. if is310 == 1 {
  15343. insutype = "310"
  15344. }
  15345. if len(insutypes) == 2 {
  15346. insutype = insutype_two
  15347. }
  15348. if len(insutypes) == 0 {
  15349. insutype = "310"
  15350. }
  15351. insutype = insutype_two
  15352. fmt.Println(insutype)
  15353. for _, item := range rf {
  15354. fmt.Println(item.Insutype)
  15355. fmt.Println(insutype)
  15356. if item.Insutype == insutype {
  15357. fmt.Println(item.Insutype)
  15358. fmt.Println(insutype)
  15359. insuplc_admdvs = item.InsuplcAdmdvs
  15360. }
  15361. }
  15362. fmt.Println(insuplc_admdvs)
  15363. var res2 ResultThirteen
  15364. var res10265_2 ResultThirteen10265
  15365. if config.IsOpen == 1 {
  15366. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15367. } else {
  15368. 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)
  15369. var dat map[string]interface{}
  15370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15371. fmt.Println(dat)
  15372. } else {
  15373. fmt.Println(err)
  15374. }
  15375. userJSONBytes, _ := json.Marshal(dat)
  15376. if miConfig.Code == "H15049901371" {
  15377. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  15378. utils.ErrorLog("解析失败:%v", err)
  15379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15380. return
  15381. }
  15382. res2.ErrMsg = res10265_2.ErrMsg
  15383. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  15384. res2.Infcode = infocode
  15385. res2.Output = res10265_2.Output
  15386. res2.InfRefmsgid = res10265_2.InfRefmsgid
  15387. } else {
  15388. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15389. utils.ErrorLog("解析失败:%v", err)
  15390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15391. return
  15392. }
  15393. }
  15394. }
  15395. if res2.Infcode == 0 {
  15396. psnResult := &models.GdybPsnNcdsRecord{
  15397. UserOrgId: adminUser.CurrentOrgId,
  15398. PatientId: patient.ID,
  15399. PsnNo: psn_no,
  15400. DoctorId: doctor.AdminUserId,
  15401. DepartmentId: department_id,
  15402. SickType: sick_id,
  15403. Insutype: insutype,
  15404. Ctime: time.Now().Unix(),
  15405. Mtime: time.Now().Unix(),
  15406. Status: 1,
  15407. IsCancel: 1,
  15408. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15409. }
  15410. service.CreatePsnNCDSRecord(psnResult)
  15411. c.ServeSuccessJSON(map[string]interface{}{
  15412. "failed_code": 0,
  15413. "msg": "备案成功",
  15414. "result": psnResult,
  15415. })
  15416. } else {
  15417. c.ServeSuccessJSON(map[string]interface{}{
  15418. "failed_code": -10,
  15419. "msg": res2.ErrMsg,
  15420. })
  15421. return
  15422. }
  15423. }
  15424. }
  15425. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  15426. id, _ := c.GetInt64("id")
  15427. admin_user_id, _ := c.GetInt64("admin_user_id")
  15428. adminUser := c.GetAdminUserInfo()
  15429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15431. //config, _ := service.Ge(adminUser.CurrentOrgId)
  15432. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  15433. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15434. //var user_name string
  15435. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15436. //if role.ID == 0 {
  15437. // user_name = "xxx"
  15438. //} else {
  15439. // user_name = role.UserName
  15440. //}
  15441. psn_record, _ := service.GetPsnNCDSRecordById(id)
  15442. if psn_record.ID == 0 {
  15443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15444. return
  15445. }
  15446. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15447. var res ResultTwo
  15448. var res10265 ResultTwo10265
  15449. if miConfig.Code == "H15049901371" {
  15450. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15451. utils.ErrorLog("解析失败:%v", err)
  15452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15453. return
  15454. }
  15455. res.ErrMsg = res10265.ErrMsg
  15456. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15457. res.Infcode = infocode
  15458. res.Output = res10265.Output
  15459. res.InfRefmsgid = res10265.InfRefmsgid
  15460. } else {
  15461. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15462. utils.ErrorLog("解析失败:%v", err)
  15463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15464. return
  15465. }
  15466. }
  15467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15468. infoStr := string(Iinfos)
  15469. var rf []*ResultFive
  15470. json.Unmarshal([]byte(infoStr), &rf)
  15471. var insuplc_admdvs string
  15472. var insutype string
  15473. var is390 int = 0
  15474. var is310 int = 0
  15475. var insutypes []*ResultFive
  15476. for _, item := range rf {
  15477. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15478. insutypes = append(insutypes, item)
  15479. }
  15480. }
  15481. if len(insutypes) == 1 {
  15482. insutype = insutypes[0].Insutype
  15483. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15484. } else {
  15485. for _, i := range insutypes {
  15486. if i.Insutype == "390" {
  15487. is390 = 1
  15488. }
  15489. if i.Insutype == "310" {
  15490. is310 = 1
  15491. }
  15492. }
  15493. }
  15494. if is390 == 1 {
  15495. insutype = "390"
  15496. }
  15497. if is310 == 1 {
  15498. insutype = "310"
  15499. }
  15500. if len(insutypes) == 0 {
  15501. insutype = "310"
  15502. }
  15503. insutype = psn_record.Insutype
  15504. for _, item := range rf {
  15505. if item.Insutype == insutype {
  15506. insuplc_admdvs = item.InsuplcAdmdvs
  15507. }
  15508. }
  15509. if config.IsOpen == 1 {
  15510. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15511. var dat map[string]interface{}
  15512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15513. fmt.Println(dat)
  15514. } else {
  15515. fmt.Println(err)
  15516. }
  15517. userJSONBytes, _ := json.Marshal(dat)
  15518. var res ResultFourteen
  15519. var res10265 ResultFourteen10265
  15520. if miConfig.Code == "H15049901371" {
  15521. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15522. utils.ErrorLog("解析失败:%v", err)
  15523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15524. return
  15525. }
  15526. res.ErrMsg = res10265.ErrMsg
  15527. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15528. res.Infcode = infocode
  15529. res.Output = res10265.Output
  15530. res.InfRefmsgid = res10265.InfRefmsgid
  15531. } else {
  15532. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15533. utils.ErrorLog("解析失败:%v", err)
  15534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15535. return
  15536. }
  15537. }
  15538. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15539. // utils.ErrorLog("解析失败:%v", err)
  15540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15541. // return
  15542. //}
  15543. if res.Infcode == 0 {
  15544. psn_record.IsCancel = 2
  15545. service.CreatePsnNCDSRecord(&psn_record)
  15546. c.ServeSuccessJSON(map[string]interface{}{
  15547. "failed_code": 0,
  15548. "msg": "撤销备案成功",
  15549. })
  15550. } else {
  15551. c.ServeSuccessJSON(map[string]interface{}{
  15552. "failed_code": -10,
  15553. "msg": res.ErrMsg,
  15554. })
  15555. return
  15556. }
  15557. }
  15558. }
  15559. func (c *HisApiController) TestTest() {
  15560. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  15561. fmt.Println(patient.Iinfo)
  15562. }
  15563. type CustomData struct {
  15564. MsgId string
  15565. PsnNo string
  15566. Info string
  15567. }
  15568. func (c *HisApiController) ReversalData() {
  15569. var customData []*CustomData
  15570. custom := &CustomData{
  15571. MsgId: "H44022900158202103301714472004",
  15572. PsnNo: "44020000001101329945",
  15573. Info: "2207",
  15574. }
  15575. customData = append(customData, custom)
  15576. custom1 := &CustomData{
  15577. MsgId: "H4402290015820210330172057803",
  15578. PsnNo: "44020000001101161813",
  15579. Info: "2207",
  15580. }
  15581. customData = append(customData, custom1)
  15582. custom2 := &CustomData{
  15583. MsgId: "H44022900158202103301705198813",
  15584. PsnNo: "44190000133097375417",
  15585. Info: "2207",
  15586. }
  15587. customData = append(customData, custom2)
  15588. custom3 := &CustomData{
  15589. MsgId: "H44022900158202103301715524756",
  15590. PsnNo: "44020000001100187221",
  15591. Info: "2207",
  15592. }
  15593. customData = append(customData, custom3)
  15594. custom4 := &CustomData{
  15595. MsgId: "H44022900158202103301730376224",
  15596. PsnNo: "44020000001101959155",
  15597. Info: "2207",
  15598. }
  15599. customData = append(customData, custom4)
  15600. custom5 := &CustomData{
  15601. MsgId: "H44022900158202103301748008725",
  15602. PsnNo: "44020000001104246641",
  15603. Info: "2207",
  15604. }
  15605. customData = append(customData, custom5)
  15606. custom6 := &CustomData{
  15607. MsgId: "H44022900158202103301718096755",
  15608. PsnNo: "44020000001102211860",
  15609. Info: "2207",
  15610. }
  15611. customData = append(customData, custom6)
  15612. custom7 := &CustomData{
  15613. MsgId: "H44022900158202103301736551640",
  15614. PsnNo: "44020000001102687718",
  15615. Info: "2207",
  15616. }
  15617. customData = append(customData, custom7)
  15618. custom8 := &CustomData{
  15619. MsgId: "H44022900158202103301743097676",
  15620. PsnNo: "44020000001102127785",
  15621. Info: "2207",
  15622. }
  15623. customData = append(customData, custom8)
  15624. custom9 := &CustomData{
  15625. MsgId: "H44022900158202103301712304203",
  15626. PsnNo: "44020000001101518097",
  15627. Info: "2207",
  15628. }
  15629. customData = append(customData, custom9)
  15630. custom10 := &CustomData{
  15631. MsgId: "H44022900158202103301738448785",
  15632. PsnNo: "44020000001100500813",
  15633. Info: "2207",
  15634. }
  15635. customData = append(customData, custom10)
  15636. custom11 := &CustomData{
  15637. MsgId: "H44022900158202103301732455843",
  15638. PsnNo: "44020000001102690557",
  15639. Info: "2207",
  15640. }
  15641. customData = append(customData, custom11)
  15642. custom12 := &CustomData{
  15643. MsgId: "H44022900158202103301745421708",
  15644. PsnNo: "44020000001102211928",
  15645. Info: "2207",
  15646. }
  15647. customData = append(customData, custom12)
  15648. custom1212 := &CustomData{
  15649. MsgId: "H440229001582021033017351627",
  15650. PsnNo: "44020000001102481733",
  15651. Info: "2207",
  15652. }
  15653. customData = append(customData, custom1212)
  15654. custom13 := &CustomData{
  15655. MsgId: "H44022900158202103301740327951",
  15656. PsnNo: "44020000001103174866",
  15657. Info: "2207",
  15658. }
  15659. customData = append(customData, custom13)
  15660. custom14 := &CustomData{
  15661. MsgId: "H4402290015820210330174922668",
  15662. PsnNo: "44020000001102927272",
  15663. Info: "2207",
  15664. }
  15665. customData = append(customData, custom14)
  15666. custom15 := &CustomData{
  15667. MsgId: "H44022900158202103301752362273",
  15668. PsnNo: "44020000001102942890",
  15669. Info: "2207",
  15670. }
  15671. customData = append(customData, custom15)
  15672. custom16 := &CustomData{
  15673. MsgId: "H44022900158202103301751082917",
  15674. PsnNo: "44020000001101662162",
  15675. Info: "2207",
  15676. }
  15677. customData = append(customData, custom16)
  15678. custom17 := &CustomData{
  15679. MsgId: "H44022900158202103301754147728",
  15680. PsnNo: "44020000000229014511",
  15681. Info: "2207",
  15682. }
  15683. customData = append(customData, custom17)
  15684. adminUser := c.GetAdminUserInfo()
  15685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15686. for _, item := range customData {
  15687. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  15688. fmt.Println(result)
  15689. }
  15690. }
  15691. func (c *HisApiController) GetAllopatry() {
  15692. year := c.GetString("year")
  15693. month := c.GetString("month")
  15694. admin_user_id, _ := c.GetInt64("admin_user_id")
  15695. adminUser := c.GetAdminUserInfo()
  15696. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15697. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15698. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15699. var dat map[string]interface{}
  15700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15701. fmt.Println(dat)
  15702. } else {
  15703. fmt.Println(err)
  15704. }
  15705. userJSONBytes, _ := json.Marshal(dat)
  15706. var res models.Result9001
  15707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15708. utils.ErrorLog("解析失败:%v", err)
  15709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15710. return
  15711. }
  15712. fmt.Println(res.Output.Signinoutb)
  15713. fmt.Println(res.Output.Signinoutb.SignNo)
  15714. fmt.Println(string(userJSONBytes))
  15715. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15716. var dat3 map[string]interface{}
  15717. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  15718. fmt.Println(dat3)
  15719. } else {
  15720. fmt.Println(err)
  15721. }
  15722. userJSONBytes3, _ := json.Marshal(dat3)
  15723. var res3 models.Result3260
  15724. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  15725. utils.ErrorLog("解析失败:%v", err)
  15726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15727. return
  15728. }
  15729. var curpage int
  15730. var pagesize int = 100
  15731. var start int = 1
  15732. //var stop int
  15733. //pagecount := 10
  15734. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  15735. for curpage = 1; curpage <= pagecount; curpage++ {
  15736. if curpage == 1 {
  15737. start = 0
  15738. } else {
  15739. start = (curpage-1)*pagesize + 1
  15740. }
  15741. //stop = curpage * pagesize
  15742. //if stop > int(res3.Output.Totalrow) {
  15743. // stop =int(res3.Output.Totalrow)
  15744. //}
  15745. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  15746. var dat2 map[string]interface{}
  15747. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15748. fmt.Println(dat)
  15749. } else {
  15750. fmt.Println(err)
  15751. }
  15752. userJSONBytes2, _ := json.Marshal(dat2)
  15753. var res2 models.Result3260
  15754. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15755. utils.ErrorLog("解析失败:%v", err)
  15756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15757. return
  15758. }
  15759. //if res2.Infcode == 0 {
  15760. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15761. // //var dat2 map[string]interface{}
  15762. // //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  15763. // // fmt.Println(dat)
  15764. // //} else {
  15765. // // fmt.Println(err)
  15766. // //}
  15767. // //c.ServeSuccessJSON(map[string]interface{}{
  15768. // // "list": res2.Output.Data,
  15769. // //})
  15770. // //return
  15771. //}
  15772. }
  15773. }
  15774. func (c *HisApiController) ComfirmAllopatry() {
  15775. year := c.GetString("year")
  15776. month := c.GetString("month")
  15777. admin_user_id, _ := c.GetInt64("admin_user_id")
  15778. adminUser := c.GetAdminUserInfo()
  15779. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15780. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15781. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15782. var dat map[string]interface{}
  15783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15784. fmt.Println(dat)
  15785. } else {
  15786. fmt.Println(err)
  15787. }
  15788. userJSONBytes, _ := json.Marshal(dat)
  15789. var res models.Result9001
  15790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15791. utils.ErrorLog("解析失败:%v", err)
  15792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15793. return
  15794. }
  15795. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15796. var dat2 map[string]interface{}
  15797. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15798. fmt.Println(dat)
  15799. } else {
  15800. fmt.Println(err)
  15801. }
  15802. userJSONBytes2, _ := json.Marshal(dat2)
  15803. var res2 models.Result3260
  15804. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15805. utils.ErrorLog("解析失败:%v", err)
  15806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15807. return
  15808. }
  15809. //if res2.Infcode == 0 {
  15810. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15811. // var dat map[string]interface{}
  15812. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15813. // fmt.Println(dat)
  15814. // } else {
  15815. // fmt.Println(err)
  15816. // }
  15817. // userJSONBytes, _ := json.Marshal(dat)
  15818. // var res3 models.Result3261
  15819. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  15820. // utils.ErrorLog("解析失败:%v", err)
  15821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15822. // return
  15823. // }
  15824. //
  15825. // if res3.Infcode == 0 {
  15826. // record := &models.HisYidiClearRecord{
  15827. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15828. // Ctime: time.Now().Unix(),
  15829. // Mtime: time.Now().Unix(),
  15830. // Status: 1,
  15831. // MsgId: msgId,
  15832. // }
  15833. // service.SaveClearRecord(record)
  15834. // c.ServeSuccessJSON(map[string]interface{}{
  15835. // "msg": "提取成功",
  15836. // })
  15837. // }
  15838. //}
  15839. }
  15840. func (c *HisApiController) RefundAllopatry() {
  15841. year := c.GetString("year")
  15842. month := c.GetString("month")
  15843. //id, _ := c.GetInt64("id")
  15844. admin_user_id, _ := c.GetInt64("admin_user_id")
  15845. adminUser := c.GetAdminUserInfo()
  15846. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15847. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15848. //record, _ := service.GetClearRecordById(id)
  15849. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15850. var dat map[string]interface{}
  15851. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15852. fmt.Println(dat)
  15853. } else {
  15854. fmt.Println(err)
  15855. }
  15856. userJSONBytes, _ := json.Marshal(dat)
  15857. var res models.Result9001
  15858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15859. utils.ErrorLog("解析失败:%v", err)
  15860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15861. return
  15862. }
  15863. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  15864. var dat2 map[string]interface{}
  15865. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  15866. fmt.Println(dat)
  15867. } else {
  15868. fmt.Println(err)
  15869. }
  15870. userJSONBytes2, _ := json.Marshal(dat2)
  15871. var empty ResultFourteen
  15872. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  15873. utils.ErrorLog("解析失败:%v", err)
  15874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15875. return
  15876. }
  15877. if empty.Infcode == 0 {
  15878. c.ServeSuccessJSON(map[string]interface{}{
  15879. "msg": "撤销成功",
  15880. })
  15881. return
  15882. }
  15883. }
  15884. func (c *HisApiController) ReversalOtherData() {
  15885. var customData []*CustomData
  15886. custom := &CustomData{
  15887. MsgId: "H44022900158202103301714472004",
  15888. PsnNo: "44020000001101329945",
  15889. Info: "2208",
  15890. }
  15891. customData = append(customData, custom)
  15892. custom1 := &CustomData{
  15893. MsgId: "H4402290015820210330172057803",
  15894. PsnNo: "44020000001101161813",
  15895. Info: "2208",
  15896. }
  15897. customData = append(customData, custom1)
  15898. custom2 := &CustomData{
  15899. MsgId: "H44022900158202103301705198813",
  15900. PsnNo: "44190000133097375417",
  15901. Info: "2208",
  15902. }
  15903. customData = append(customData, custom2)
  15904. custom3 := &CustomData{
  15905. MsgId: "H44022900158202103301715524756",
  15906. PsnNo: "44020000001100187221",
  15907. Info: "2208",
  15908. }
  15909. customData = append(customData, custom3)
  15910. custom4 := &CustomData{
  15911. MsgId: "H44022900158202103301730376224",
  15912. PsnNo: "44020000001101959155",
  15913. Info: "2208",
  15914. }
  15915. customData = append(customData, custom4)
  15916. custom5 := &CustomData{
  15917. MsgId: "H44022900158202103301748008725",
  15918. PsnNo: "44020000001104246641",
  15919. Info: "2208",
  15920. }
  15921. customData = append(customData, custom5)
  15922. custom6 := &CustomData{
  15923. MsgId: "H44022900158202103301718096755",
  15924. PsnNo: "44020000001102211860",
  15925. Info: "2208",
  15926. }
  15927. customData = append(customData, custom6)
  15928. custom7 := &CustomData{
  15929. MsgId: "H44022900158202103301736551640",
  15930. PsnNo: "44020000001102687718",
  15931. Info: "2208",
  15932. }
  15933. customData = append(customData, custom7)
  15934. custom8 := &CustomData{
  15935. MsgId: "H44022900158202103301743097676",
  15936. PsnNo: "44020000001102127785",
  15937. Info: "2208",
  15938. }
  15939. customData = append(customData, custom8)
  15940. custom9 := &CustomData{
  15941. MsgId: "H44022900158202103301712304203",
  15942. PsnNo: "44020000001101518097",
  15943. Info: "2208",
  15944. }
  15945. customData = append(customData, custom9)
  15946. custom10 := &CustomData{
  15947. MsgId: "H44022900158202103301738448785",
  15948. PsnNo: "44020000001100500813",
  15949. Info: "2208",
  15950. }
  15951. customData = append(customData, custom10)
  15952. custom11 := &CustomData{
  15953. MsgId: "H44022900158202103301732455843",
  15954. PsnNo: "44020000001102690557",
  15955. Info: "2208",
  15956. }
  15957. customData = append(customData, custom11)
  15958. custom12 := &CustomData{
  15959. MsgId: "H44022900158202103301745421708",
  15960. PsnNo: "44020000001102211928",
  15961. Info: "2208",
  15962. }
  15963. customData = append(customData, custom12)
  15964. custom1212 := &CustomData{
  15965. MsgId: "H440229001582021033017351627",
  15966. PsnNo: "44020000001102481733",
  15967. Info: "2208",
  15968. }
  15969. customData = append(customData, custom1212)
  15970. custom13 := &CustomData{
  15971. MsgId: "H44022900158202103301740327951",
  15972. PsnNo: "44020000001103174866",
  15973. Info: "2208",
  15974. }
  15975. customData = append(customData, custom13)
  15976. custom14 := &CustomData{
  15977. MsgId: "H4402290015820210330174922668",
  15978. PsnNo: "44020000001102927272",
  15979. Info: "2208",
  15980. }
  15981. customData = append(customData, custom14)
  15982. custom15 := &CustomData{
  15983. MsgId: "H44022900158202103301752362273",
  15984. PsnNo: "44020000001102942890",
  15985. Info: "2208",
  15986. }
  15987. customData = append(customData, custom15)
  15988. custom16 := &CustomData{
  15989. MsgId: "H44022900158202103301751082917",
  15990. PsnNo: "44020000001101662162",
  15991. Info: "2208",
  15992. }
  15993. customData = append(customData, custom16)
  15994. custom17 := &CustomData{
  15995. MsgId: "H44022900158202103301754147728",
  15996. PsnNo: "44020000000229014511",
  15997. Info: "2208",
  15998. }
  15999. customData = append(customData, custom17)
  16000. adminUser := c.GetAdminUserInfo()
  16001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16002. for _, item := range customData {
  16003. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16004. fmt.Println(result)
  16005. }
  16006. }
  16007. func PathExists(path string) (bool, error) {
  16008. _, err := os.Stat(path)
  16009. if err == nil {
  16010. return true, nil
  16011. }
  16012. if os.IsNotExist(err) {
  16013. return false, nil
  16014. }
  16015. return false, err
  16016. }
  16017. // 创建文件夹
  16018. func Mkdir(dir string) {
  16019. // 创建文件夹
  16020. exist, err := PathExists(dir)
  16021. if err != nil {
  16022. fmt.Println(err.Error())
  16023. } else {
  16024. if exist {
  16025. fmt.Println(dir + "文件夹已存在!")
  16026. } else {
  16027. // 文件夹名称,权限
  16028. err := os.Mkdir(dir, os.ModePerm)
  16029. if err != nil {
  16030. fmt.Println(dir+"文件夹创建失败:", err.Error())
  16031. } else {
  16032. fmt.Println(dir + "文件夹创建成功!")
  16033. }
  16034. }
  16035. }
  16036. }
  16037. // 压缩文件
  16038. func Zip(srcFile string, destZip string) error {
  16039. zipfile, err := os.Create(destZip)
  16040. if err != nil {
  16041. return err
  16042. }
  16043. defer zipfile.Close()
  16044. archive := zip.NewWriter(zipfile)
  16045. defer archive.Close()
  16046. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  16047. if err != nil {
  16048. return err
  16049. }
  16050. header, err := zip.FileInfoHeader(info)
  16051. if err != nil {
  16052. return err
  16053. }
  16054. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  16055. // header.Name = path
  16056. if info.IsDir() {
  16057. header.Name += "/"
  16058. } else {
  16059. header.Method = zip.Deflate
  16060. }
  16061. writer, err := archive.CreateHeader(header)
  16062. if err != nil {
  16063. return err
  16064. }
  16065. if !info.IsDir() {
  16066. file, err := os.Open(path)
  16067. if err != nil {
  16068. return err
  16069. }
  16070. defer file.Close()
  16071. _, err = io.Copy(writer, file)
  16072. }
  16073. return err
  16074. })
  16075. return err
  16076. }
  16077. func ReadFile(filePath string) []byte {
  16078. f, err := os.Open(filePath)
  16079. if err != nil {
  16080. fmt.Println("read file fail", err)
  16081. return nil
  16082. }
  16083. defer f.Close()
  16084. fd, err := ioutil.ReadAll(f)
  16085. if err != nil {
  16086. fmt.Println("read to fd fail", err)
  16087. return nil
  16088. }
  16089. return fd
  16090. }
  16091. func saveLog(result string, request string, infno string, desc string) {
  16092. org_id, _ := beego.AppConfig.Int64("org_id")
  16093. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16094. dir := miConfig.OrgName + "日志"
  16095. utils.Mkdir(dir)
  16096. month := time.Unix(1557042972, 0).Format("1")
  16097. year := time.Now().Format("2006")
  16098. month = time.Now().Format("01")
  16099. day := time.Now().Format("02")
  16100. hour := time.Now().Format("15")
  16101. min := time.Now().Format("04")
  16102. sec := time.Now().Format("05")
  16103. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  16104. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  16105. file_name := file + ".txt"
  16106. file_path := miConfig.OrgName + "日志" + "/" + file_name
  16107. exist, _ := utils.PathExists(file_path)
  16108. if exist { //存在
  16109. fmt.Println("存在")
  16110. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  16111. if err != nil {
  16112. fmt.Println("read fail")
  16113. }
  16114. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  16115. n, _ := f.Seek(0, 2)
  16116. _, err = f.WriteAt([]byte(content), n)
  16117. } else { //不存在
  16118. fmt.Println("文件不存在,创建文件")
  16119. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  16120. defer f.Close()
  16121. if err != nil {
  16122. } else {
  16123. _, err = f.Write([]byte("记录日志"))
  16124. }
  16125. }
  16126. }
  16127. type Charset string
  16128. const (
  16129. UTF8 = Charset("UTF-8")
  16130. GB18030 = Charset("GB18030")
  16131. )
  16132. func ConvertToString(src string, srcCode string, tagCode string) string {
  16133. srcCoder := mahonia.NewDecoder(srcCode)
  16134. srcResult := srcCoder.ConvertString(src)
  16135. tagCoder := mahonia.NewDecoder(tagCode)
  16136. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  16137. result := string(cdata)
  16138. return result
  16139. }
  16140. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  16141. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  16142. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16143. var token string
  16144. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16145. var api string
  16146. if miConfig.MdtrtareaAdmvs == "320921" {
  16147. 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 +
  16148. "&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
  16149. fmt.Println(api)
  16150. } else {
  16151. 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 +
  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. }
  16154. resp, requestErr := http.Get(api)
  16155. if requestErr != nil {
  16156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16157. return ""
  16158. }
  16159. body, ioErr := ioutil.ReadAll(resp.Body)
  16160. if ioErr != nil {
  16161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16163. return ""
  16164. }
  16165. var respJSON map[string]interface{}
  16166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16169. return ""
  16170. }
  16171. var status string
  16172. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16173. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16174. var res ResultTwo //1101结果
  16175. var res10265 ResultTwo10265 //1101结果
  16176. if status == "0" { //读卡成功
  16177. var card_info string //卡信息
  16178. var busi_card_info string
  16179. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16180. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16181. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16182. fmt.Println(card_info)
  16183. fmt.Println(busi_card_info)
  16184. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16185. result, _ := json.Marshal(respJSON)
  16186. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16187. utils.ErrorLog("解析失败:%v", err)
  16188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16189. return ""
  16190. }
  16191. res.ErrMsg = res10265.ErrMsg
  16192. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16193. res.Infcode = infocode
  16194. res.Output = res10265.Output
  16195. res.InfRefmsgid = res10265.InfRefmsgid
  16196. if res.Infcode == 0 {
  16197. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16198. if err == gorm.ErrRecordNotFound {
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16200. return ""
  16201. } else if err != nil {
  16202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16203. return ""
  16204. } else {
  16205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16207. infoStr := string(Iinfos)
  16208. idetinfoStr := string(Idetinfos)
  16209. psn := &models.HisPsn{
  16210. PsnNo: res.Output.Baseinfo.PsnNo,
  16211. Age: res.Output.Baseinfo.Age,
  16212. PatientId: patient.ID,
  16213. Certno: res.Output.Baseinfo.Certno,
  16214. Brdy: res.Output.Baseinfo.Brdy,
  16215. Gend: res.Output.Baseinfo.Gend,
  16216. Naty: res.Output.Baseinfo.Naty,
  16217. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16218. PsnName: res.Output.Baseinfo.PsnName,
  16219. Idetinfo: idetinfoStr,
  16220. Insuinfo: infoStr,
  16221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16222. CardInfo: card_info,
  16223. VerifyNumber: token,
  16224. }
  16225. service.CreateHisPsn(psn)
  16226. return token
  16227. }
  16228. }
  16229. } else {
  16230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16231. return ""
  16232. }
  16233. } else { //读卡失败
  16234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16235. return ""
  16236. }
  16237. return token
  16238. }
  16239. func DeleteExtraSpaceTwo(s string) string {
  16240. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16241. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16242. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16243. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16244. s2 := make([]byte, len(s1)) //定义字符数组切片
  16245. copy(s2, s1) //将字符串复制到切片
  16246. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16247. for len(spc_index) > 0 { //找到适配项
  16248. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16249. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16250. }
  16251. return string(s2)
  16252. }
  16253. func Remove0000(s string) string {
  16254. str := make([]rune, 0, len(s))
  16255. for _, v := range []rune(s) {
  16256. if v == 0 {
  16257. continue
  16258. }
  16259. str = append(str, v)
  16260. }
  16261. return string(str)
  16262. }
  16263. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  16264. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  16265. readCard := DllDef.MustFindProc("EcQuery")
  16266. pCardInfo := make([]byte, 8192)
  16267. pBusiCardInfo := make([]byte, 8192)
  16268. data := make(map[string]interface{})
  16269. //pData := make(map[string]interface{})
  16270. inputData := make(map[string]interface{})
  16271. inputData["orgId"] = code
  16272. inputData["businessType"] = "01101"
  16273. inputData["operatorId"] = operator_id
  16274. inputData["operatorName"] = operator_name
  16275. inputData["officeId"] = "001"
  16276. inputData["officeName"] = "血透室"
  16277. //
  16278. data["data"] = inputData
  16279. data["transType"] = "ec.query"
  16280. data["orgId"] = code
  16281. bytesData, _ := json.Marshal(data)
  16282. pCardInfo = bytesData
  16283. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16284. fmt.Println(ret2)
  16285. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  16286. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16287. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  16288. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16289. if ret2 != 0 {
  16290. return "", ""
  16291. }
  16292. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  16293. }
  16294. func DeleteExtraSpace(s string) string {
  16295. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16296. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16297. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16298. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16299. s2 := make([]byte, len(s1)) //定义字符数组切片
  16300. copy(s2, s1) //将字符串复制到切片
  16301. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16302. for len(spc_index) > 0 { //找到适配项
  16303. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16304. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16305. }
  16306. return string(s2)
  16307. }
  16308. // 对账
  16309. func (c *HisApiController) Post3202() {
  16310. start_time := c.GetString("start_time")
  16311. end_time := c.GetString("end_time")
  16312. //insutype := c.GetString("insutype")
  16313. clr_type := c.GetString("clr_type")
  16314. clr_org := c.GetString("clr_optins")
  16315. admin_user_id, _ := c.GetInt64("admin_user_id")
  16316. adminUser := c.GetAdminUserInfo()
  16317. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16318. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16319. if len(clr_org) == 0 {
  16320. clr_org = miConfig.MdtrtareaAdmvs
  16321. }
  16322. timeLayout := "2006-01-02"
  16323. loc, _ := time.LoadLocation("Local")
  16324. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16325. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16326. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16327. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  16328. //fixmedins_setl_cnt := int64(len(orders))
  16329. var medfee_sumamt float64
  16330. var acct_pay float64
  16331. var fund_pay_sumamt float64
  16332. for _, item := range orders {
  16333. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16334. acct_pay = acct_pay + item.AcctPay
  16335. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16336. }
  16337. //var medfee_sumamt_two float64
  16338. //var acct_pay_two float64
  16339. //var fund_pay_sumamt_two float64
  16340. //for _, item := range orders_two {
  16341. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  16342. // acct_pay_two = acct_pay_two + item.AcctPay
  16343. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  16344. //}
  16345. //var user_name string
  16346. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16347. //if role.ID == 0 {
  16348. // user_name = "xxx"
  16349. //} else {
  16350. // user_name = role.UserName
  16351. //}
  16352. var res ResultSix
  16353. if config.IsOpen == 1 {
  16354. var bps []*models.BusinessParamsTwo
  16355. var bp models.BusinessParamsTwo
  16356. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  16357. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  16358. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  16359. bp.MedfeeSumamt = medfee_sumamt_str
  16360. bp.AcctPay = acct_pay_str
  16361. bp.FundPaySumamt = fund_pay_sumamt_str
  16362. bp.Insutype = "390"
  16363. bp.StmtBegndate = start_time
  16364. bp.ClrType = clr_type
  16365. bp.SetlOptins = clr_org
  16366. bp.StmtEnddate = end_time
  16367. bps = append(bps, &bp)
  16368. data := make(map[string]interface{})
  16369. data["bps"] = bps
  16370. data["org_name"] = miConfig.OrgName
  16371. data["doctor"] = role.UserName
  16372. data["fixmedins_code"] = miConfig.Code
  16373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16375. if miConfig.MdtrtareaAdmvs == "421300" {
  16376. client := &http.Client{}
  16377. bytesData, _ := json.Marshal(data)
  16378. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  16379. resp, _ := client.Do(req)
  16380. defer resp.Body.Close()
  16381. body, ioErr := ioutil.ReadAll(resp.Body)
  16382. if ioErr != nil {
  16383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16385. return
  16386. }
  16387. var respJSON map[string]interface{}
  16388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16391. return
  16392. }
  16393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16394. userJSONBytes, _ := json.Marshal(respJSON)
  16395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16396. utils.ErrorLog("解析失败:%v", err)
  16397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16398. return
  16399. }
  16400. }
  16401. if res.Infcode == 0 {
  16402. c.ServeSuccessJSON(map[string]interface{}{
  16403. "msg": "发起成功",
  16404. })
  16405. } else {
  16406. c.ServeSuccessJSON(map[string]interface{}{
  16407. "code": -10,
  16408. "msg": res.ErrMsg,
  16409. })
  16410. }
  16411. }
  16412. }
  16413. func (c *HisApiController) Post3501() {
  16414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16415. data := make(map[string]interface{})
  16416. var struct3501s []models.Struct3501
  16417. var struct3501 models.Struct3501
  16418. struct3501.OrgName = miConfig.OrgName
  16419. struct3501.AccessKey = miConfig.AccessKey
  16420. struct3501.RequestUrl = miConfig.Url
  16421. struct3501.SecretKey = miConfig.SecretKey
  16422. struct3501.ManuDate = "2022-08-17"
  16423. struct3501.FixmedinsBchno = ""
  16424. struct3501.ManuLotnum = ""
  16425. struct3501.RxFlag = "0"
  16426. struct3501.ExpyEnd = "2022-08-17"
  16427. struct3501.Invdate = "2022-08-17"
  16428. struct3501.InvCnt = "20.25"
  16429. struct3501.Memo = ""
  16430. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16431. struct3501.FixmedinsHilistId = miConfig.Code
  16432. struct3501.FixmedinsHilistName = miConfig.OrgName
  16433. struct3501s = append(struct3501s, struct3501)
  16434. data["struct_3501s"] = struct3501s
  16435. client := &http.Client{}
  16436. bytesData, _ := json.Marshal(data)
  16437. var req *http.Request
  16438. if miConfig.MdtrtareaAdmvs == "320921" {
  16439. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16440. } else {
  16441. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16442. }
  16443. resp, _ := client.Do(req)
  16444. defer resp.Body.Close()
  16445. body, ioErr := ioutil.ReadAll(resp.Body)
  16446. if ioErr != nil {
  16447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16449. return
  16450. }
  16451. var respJSON map[string]interface{}
  16452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16455. return
  16456. }
  16457. var res ResultSix
  16458. var resSix10265 ResultSix10265 //1101结果
  16459. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16460. result, _ := json.Marshal(respJSON)
  16461. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16462. utils.ErrorLog("解析失败:%v", err)
  16463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16464. return
  16465. }
  16466. res.InfRefmsgid = resSix10265.InfRefmsgid
  16467. res.Output = resSix10265.Output
  16468. res.ErrMsg = resSix10265.ErrMsg
  16469. res.Cainfo = resSix10265.Cainfo
  16470. res.WarnMsg = resSix10265.WarnMsg
  16471. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16472. res.Infcode = infocode
  16473. if infocode == 0 {
  16474. c.ServeSuccessJSON(map[string]interface{}{
  16475. "msg": "上传成功",
  16476. })
  16477. return
  16478. } else {
  16479. c.ServeSuccessJSON(map[string]interface{}{
  16480. "failed_code": -10,
  16481. "msg": res.ErrMsg,
  16482. })
  16483. return
  16484. }
  16485. }
  16486. func (c *HisApiController) Post3502() {
  16487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16488. data := make(map[string]interface{})
  16489. var struct3502s []models.Struct3502
  16490. var struct3502 models.Struct3502
  16491. struct3502.OrgName = miConfig.OrgName
  16492. struct3502.AccessKey = miConfig.AccessKey
  16493. struct3502.RequestUrl = miConfig.Url
  16494. struct3502.SecretKey = miConfig.SecretKey
  16495. struct3502.ManuDate = "2022-08-15"
  16496. struct3502.FixmedinsBchno = ""
  16497. struct3502.ManuLotnum = ""
  16498. struct3502.RxFlag = "0"
  16499. struct3502.ExpyEnd = "2022-08-15"
  16500. struct3502.Invdate = "2022-08-15"
  16501. struct3502.InvCnt = "20.25"
  16502. struct3502.Memo = ""
  16503. struct3502.MedListCodg = "XB01ABD056B002020200517"
  16504. struct3502.FixmedinsHilistId = miConfig.Code
  16505. struct3502.FixmedinsHilistName = miConfig.OrgName
  16506. struct3502s = append(struct3502s, struct3502)
  16507. data["struct_3502s"] = struct3502s
  16508. client := &http.Client{}
  16509. bytesData, _ := json.Marshal(data)
  16510. var req *http.Request
  16511. if miConfig.MdtrtareaAdmvs == "320921" {
  16512. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16513. } else {
  16514. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16515. }
  16516. resp, _ := client.Do(req)
  16517. defer resp.Body.Close()
  16518. body, ioErr := ioutil.ReadAll(resp.Body)
  16519. if ioErr != nil {
  16520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16522. return
  16523. }
  16524. var respJSON map[string]interface{}
  16525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16528. return
  16529. }
  16530. var res ResultSix
  16531. var resSix10265 ResultSix10265 //1101结果
  16532. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16533. result, _ := json.Marshal(respJSON)
  16534. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16535. utils.ErrorLog("解析失败:%v", err)
  16536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16537. return
  16538. }
  16539. res.InfRefmsgid = resSix10265.InfRefmsgid
  16540. res.Output = resSix10265.Output
  16541. res.ErrMsg = resSix10265.ErrMsg
  16542. res.Cainfo = resSix10265.Cainfo
  16543. res.WarnMsg = resSix10265.WarnMsg
  16544. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16545. res.Infcode = infocode
  16546. if infocode == 0 {
  16547. c.ServeSuccessJSON(map[string]interface{}{
  16548. "msg": "上传成功",
  16549. })
  16550. return
  16551. } else {
  16552. c.ServeSuccessJSON(map[string]interface{}{
  16553. "failed_code": -10,
  16554. "msg": res.ErrMsg,
  16555. })
  16556. return
  16557. }
  16558. }
  16559. func (c *HisApiController) Post3503() {
  16560. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16561. data := make(map[string]interface{})
  16562. var struct3501s []models.Struct3501
  16563. var struct3501 models.Struct3501
  16564. struct3501.OrgName = miConfig.OrgName
  16565. struct3501.AccessKey = miConfig.AccessKey
  16566. struct3501.RequestUrl = miConfig.Url
  16567. struct3501.SecretKey = miConfig.SecretKey
  16568. struct3501.ManuDate = "2022-08-15"
  16569. struct3501.FixmedinsBchno = ""
  16570. struct3501.ManuLotnum = ""
  16571. struct3501.RxFlag = "0"
  16572. struct3501.ExpyEnd = "2022-08-15"
  16573. struct3501.Invdate = "2022-08-15"
  16574. struct3501.InvCnt = "20.25"
  16575. struct3501.Memo = ""
  16576. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16577. struct3501.FixmedinsHilistId = miConfig.Code
  16578. struct3501.FixmedinsHilistName = miConfig.OrgName
  16579. struct3501s = append(struct3501s, struct3501)
  16580. data["struct_3501s"] = struct3501s
  16581. client := &http.Client{}
  16582. bytesData, _ := json.Marshal(data)
  16583. var req *http.Request
  16584. if miConfig.MdtrtareaAdmvs == "320921" {
  16585. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16586. } else {
  16587. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16588. }
  16589. resp, _ := client.Do(req)
  16590. defer resp.Body.Close()
  16591. body, ioErr := ioutil.ReadAll(resp.Body)
  16592. if ioErr != nil {
  16593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16595. return
  16596. }
  16597. var respJSON map[string]interface{}
  16598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16601. return
  16602. }
  16603. var res ResultSix
  16604. var resSix10265 ResultSix10265 //1101结果
  16605. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16606. result, _ := json.Marshal(respJSON)
  16607. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16608. utils.ErrorLog("解析失败:%v", err)
  16609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16610. return
  16611. }
  16612. res.InfRefmsgid = resSix10265.InfRefmsgid
  16613. res.Output = resSix10265.Output
  16614. res.ErrMsg = resSix10265.ErrMsg
  16615. res.Cainfo = resSix10265.Cainfo
  16616. res.WarnMsg = resSix10265.WarnMsg
  16617. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16618. res.Infcode = infocode
  16619. if infocode == 0 {
  16620. c.ServeSuccessJSON(map[string]interface{}{
  16621. "msg": "上传成功",
  16622. })
  16623. return
  16624. } else {
  16625. c.ServeSuccessJSON(map[string]interface{}{
  16626. "failed_code": -10,
  16627. "msg": res.ErrMsg,
  16628. })
  16629. return
  16630. }
  16631. }
  16632. func (c *HisApiController) Post3504() {
  16633. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16634. data := make(map[string]interface{})
  16635. var struct3501s []models.Struct3501
  16636. var struct3501 models.Struct3501
  16637. struct3501.OrgName = miConfig.OrgName
  16638. struct3501.AccessKey = miConfig.AccessKey
  16639. struct3501.RequestUrl = miConfig.Url
  16640. struct3501.SecretKey = miConfig.SecretKey
  16641. struct3501.ManuDate = "2022-08-15"
  16642. struct3501.FixmedinsBchno = ""
  16643. struct3501.ManuLotnum = ""
  16644. struct3501.RxFlag = "0"
  16645. struct3501.ExpyEnd = "2022-08-15"
  16646. struct3501.Invdate = "2022-08-15"
  16647. struct3501.InvCnt = "20.25"
  16648. struct3501.Memo = ""
  16649. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16650. struct3501.FixmedinsHilistId = miConfig.Code
  16651. struct3501.FixmedinsHilistName = miConfig.OrgName
  16652. struct3501s = append(struct3501s, struct3501)
  16653. data["struct_3501s"] = struct3501s
  16654. client := &http.Client{}
  16655. bytesData, _ := json.Marshal(data)
  16656. var req *http.Request
  16657. if miConfig.MdtrtareaAdmvs == "320921" {
  16658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16659. } else {
  16660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16661. }
  16662. resp, _ := client.Do(req)
  16663. defer resp.Body.Close()
  16664. body, ioErr := ioutil.ReadAll(resp.Body)
  16665. if ioErr != nil {
  16666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16668. return
  16669. }
  16670. var respJSON map[string]interface{}
  16671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16674. return
  16675. }
  16676. var res ResultSix
  16677. var resSix10265 ResultSix10265 //1101结果
  16678. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16679. result, _ := json.Marshal(respJSON)
  16680. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16681. utils.ErrorLog("解析失败:%v", err)
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16683. return
  16684. }
  16685. res.InfRefmsgid = resSix10265.InfRefmsgid
  16686. res.Output = resSix10265.Output
  16687. res.ErrMsg = resSix10265.ErrMsg
  16688. res.Cainfo = resSix10265.Cainfo
  16689. res.WarnMsg = resSix10265.WarnMsg
  16690. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16691. res.Infcode = infocode
  16692. if infocode == 0 {
  16693. c.ServeSuccessJSON(map[string]interface{}{
  16694. "msg": "上传成功",
  16695. })
  16696. return
  16697. } else {
  16698. c.ServeSuccessJSON(map[string]interface{}{
  16699. "failed_code": -10,
  16700. "msg": res.ErrMsg,
  16701. })
  16702. return
  16703. }
  16704. }
  16705. func (c *HisApiController) Post3505() {
  16706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16707. data := make(map[string]interface{})
  16708. var struct3501s []models.Struct3501
  16709. var struct3501 models.Struct3501
  16710. struct3501.OrgName = miConfig.OrgName
  16711. struct3501.AccessKey = miConfig.AccessKey
  16712. struct3501.RequestUrl = miConfig.Url
  16713. struct3501.SecretKey = miConfig.SecretKey
  16714. struct3501.ManuDate = "2022-08-15"
  16715. struct3501.FixmedinsBchno = ""
  16716. struct3501.ManuLotnum = ""
  16717. struct3501.RxFlag = "0"
  16718. struct3501.ExpyEnd = "2022-08-15"
  16719. struct3501.Invdate = "2022-08-15"
  16720. struct3501.InvCnt = "20.25"
  16721. struct3501.Memo = ""
  16722. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16723. struct3501.FixmedinsHilistId = miConfig.Code
  16724. struct3501.FixmedinsHilistName = miConfig.OrgName
  16725. struct3501s = append(struct3501s, struct3501)
  16726. data["struct_3501s"] = struct3501s
  16727. client := &http.Client{}
  16728. bytesData, _ := json.Marshal(data)
  16729. var req *http.Request
  16730. if miConfig.MdtrtareaAdmvs == "320921" {
  16731. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16732. } else {
  16733. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16734. }
  16735. resp, _ := client.Do(req)
  16736. defer resp.Body.Close()
  16737. body, ioErr := ioutil.ReadAll(resp.Body)
  16738. if ioErr != nil {
  16739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16741. return
  16742. }
  16743. var respJSON map[string]interface{}
  16744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16747. return
  16748. }
  16749. var res ResultSix
  16750. var resSix10265 ResultSix10265 //1101结果
  16751. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16752. result, _ := json.Marshal(respJSON)
  16753. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16754. utils.ErrorLog("解析失败:%v", err)
  16755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16756. return
  16757. }
  16758. res.InfRefmsgid = resSix10265.InfRefmsgid
  16759. res.Output = resSix10265.Output
  16760. res.ErrMsg = resSix10265.ErrMsg
  16761. res.Cainfo = resSix10265.Cainfo
  16762. res.WarnMsg = resSix10265.WarnMsg
  16763. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16764. res.Infcode = infocode
  16765. if infocode == 0 {
  16766. c.ServeSuccessJSON(map[string]interface{}{
  16767. "msg": "上传成功",
  16768. })
  16769. return
  16770. } else {
  16771. c.ServeSuccessJSON(map[string]interface{}{
  16772. "failed_code": -10,
  16773. "msg": res.ErrMsg,
  16774. })
  16775. return
  16776. }
  16777. }
  16778. func (c *HisApiController) Post3506() {
  16779. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16780. data := make(map[string]interface{})
  16781. var struct3501s []models.Struct3501
  16782. var struct3501 models.Struct3501
  16783. struct3501.OrgName = miConfig.OrgName
  16784. struct3501.AccessKey = miConfig.AccessKey
  16785. struct3501.RequestUrl = miConfig.Url
  16786. struct3501.SecretKey = miConfig.SecretKey
  16787. struct3501.ManuDate = "2022-08-15"
  16788. struct3501.FixmedinsBchno = ""
  16789. struct3501.ManuLotnum = ""
  16790. struct3501.RxFlag = "0"
  16791. struct3501.ExpyEnd = "2022-08-15"
  16792. struct3501.Invdate = "2022-08-15"
  16793. struct3501.InvCnt = "20.25"
  16794. struct3501.Memo = ""
  16795. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16796. struct3501.FixmedinsHilistId = miConfig.Code
  16797. struct3501.FixmedinsHilistName = miConfig.OrgName
  16798. struct3501s = append(struct3501s, struct3501)
  16799. data["struct_3501s"] = struct3501s
  16800. client := &http.Client{}
  16801. bytesData, _ := json.Marshal(data)
  16802. var req *http.Request
  16803. if miConfig.MdtrtareaAdmvs == "320921" {
  16804. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16805. } else {
  16806. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16807. }
  16808. resp, _ := client.Do(req)
  16809. defer resp.Body.Close()
  16810. body, ioErr := ioutil.ReadAll(resp.Body)
  16811. if ioErr != nil {
  16812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16814. return
  16815. }
  16816. var respJSON map[string]interface{}
  16817. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16820. return
  16821. }
  16822. var res ResultSix
  16823. var resSix10265 ResultSix10265 //1101结果
  16824. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16825. result, _ := json.Marshal(respJSON)
  16826. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16827. utils.ErrorLog("解析失败:%v", err)
  16828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16829. return
  16830. }
  16831. res.InfRefmsgid = resSix10265.InfRefmsgid
  16832. res.Output = resSix10265.Output
  16833. res.ErrMsg = resSix10265.ErrMsg
  16834. res.Cainfo = resSix10265.Cainfo
  16835. res.WarnMsg = resSix10265.WarnMsg
  16836. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16837. res.Infcode = infocode
  16838. if infocode == 0 {
  16839. c.ServeSuccessJSON(map[string]interface{}{
  16840. "msg": "上传成功",
  16841. })
  16842. return
  16843. } else {
  16844. c.ServeSuccessJSON(map[string]interface{}{
  16845. "failed_code": -10,
  16846. "msg": res.ErrMsg,
  16847. })
  16848. return
  16849. }
  16850. }
  16851. func (c *HisApiController) Post3507() {
  16852. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16853. data := make(map[string]interface{})
  16854. var struct3501s []models.Struct3501
  16855. var struct3501 models.Struct3501
  16856. struct3501.OrgName = miConfig.OrgName
  16857. struct3501.AccessKey = miConfig.AccessKey
  16858. struct3501.RequestUrl = miConfig.Url
  16859. struct3501.SecretKey = miConfig.SecretKey
  16860. struct3501.ManuDate = "2022-08-15"
  16861. struct3501.FixmedinsBchno = ""
  16862. struct3501.ManuLotnum = ""
  16863. struct3501.RxFlag = "0"
  16864. struct3501.ExpyEnd = "2022-08-15"
  16865. struct3501.Invdate = "2022-08-15"
  16866. struct3501.InvCnt = "20.25"
  16867. struct3501.Memo = ""
  16868. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16869. struct3501.FixmedinsHilistId = miConfig.Code
  16870. struct3501.FixmedinsHilistName = miConfig.OrgName
  16871. struct3501s = append(struct3501s, struct3501)
  16872. data["struct_3501s"] = struct3501s
  16873. client := &http.Client{}
  16874. bytesData, _ := json.Marshal(data)
  16875. var req *http.Request
  16876. if miConfig.MdtrtareaAdmvs == "320921" {
  16877. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16878. } else {
  16879. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16880. }
  16881. resp, _ := client.Do(req)
  16882. defer resp.Body.Close()
  16883. body, ioErr := ioutil.ReadAll(resp.Body)
  16884. if ioErr != nil {
  16885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16887. return
  16888. }
  16889. var respJSON map[string]interface{}
  16890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16893. return
  16894. }
  16895. var res ResultSix
  16896. var resSix10265 ResultSix10265 //1101结果
  16897. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16898. result, _ := json.Marshal(respJSON)
  16899. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16900. utils.ErrorLog("解析失败:%v", err)
  16901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16902. return
  16903. }
  16904. res.InfRefmsgid = resSix10265.InfRefmsgid
  16905. res.Output = resSix10265.Output
  16906. res.ErrMsg = resSix10265.ErrMsg
  16907. res.Cainfo = resSix10265.Cainfo
  16908. res.WarnMsg = resSix10265.WarnMsg
  16909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16910. res.Infcode = infocode
  16911. if infocode == 0 {
  16912. c.ServeSuccessJSON(map[string]interface{}{
  16913. "msg": "上传成功",
  16914. })
  16915. return
  16916. } else {
  16917. c.ServeSuccessJSON(map[string]interface{}{
  16918. "failed_code": -10,
  16919. "msg": res.ErrMsg,
  16920. })
  16921. return
  16922. }
  16923. }
  16924. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  16925. // WebSocket服务器地址
  16926. serverURL := "ws://127.0.0.1:8899"
  16927. // 解析WebSocket服务器地址
  16928. u, err := url.Parse(serverURL)
  16929. if err != nil {
  16930. }
  16931. // 建立WebSocket连接
  16932. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16933. if err != nil {
  16934. }
  16935. defer conn.Close()
  16936. input2 := make(map[string]interface{})
  16937. input := make(map[string]interface{})
  16938. inputData := make(map[string]interface{})
  16939. inputData["orgId"] = code
  16940. inputData["businessType"] = "01101"
  16941. inputData["operatorId"] = operator_id
  16942. inputData["operatorName"] = operator_name
  16943. inputData["officeId"] = "001"
  16944. inputData["officeName"] = "血透室"
  16945. inputData["deviceType"] = ""
  16946. input["data"] = inputData
  16947. input["orgId"] = code
  16948. input["transType"] = "ec.query"
  16949. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16950. input2["indata"] = input
  16951. bytesData, _ := json.Marshal(input2)
  16952. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16953. if err != nil {
  16954. fmt.Println(err)
  16955. }
  16956. // 接收消息
  16957. _, receivedMessage, err := conn.ReadMessage()
  16958. if err != nil {
  16959. fmt.Println(err)
  16960. }
  16961. return "", string(receivedMessage)
  16962. }
  16963. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  16964. // WebSocket服务器地址
  16965. serverURL := "ws://127.0.0.1:8899"
  16966. // 解析WebSocket服务器地址
  16967. u, err := url.Parse(serverURL)
  16968. if err != nil {
  16969. }
  16970. // 建立WebSocket连接
  16971. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16972. if err != nil {
  16973. }
  16974. defer conn.Close()
  16975. input2 := make(map[string]interface{})
  16976. input := make(map[string]interface{})
  16977. inputData := make(map[string]interface{})
  16978. inputData["orgId"] = code
  16979. inputData["businessType"] = "01301"
  16980. inputData["operatorId"] = operator_id
  16981. inputData["operatorName"] = operator_name
  16982. inputData["officeId"] = "001"
  16983. inputData["officeName"] = "血透室"
  16984. inputData["deviceType"] = ""
  16985. input["data"] = inputData
  16986. input["orgId"] = code
  16987. input["transType"] = "ec.query"
  16988. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16989. input2["indata"] = input
  16990. bytesData, _ := json.Marshal(input2)
  16991. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16992. if err != nil {
  16993. fmt.Println(err)
  16994. }
  16995. // 接收消息
  16996. _, receivedMessage, err := conn.ReadMessage()
  16997. if err != nil {
  16998. fmt.Println(err)
  16999. }
  17000. return "", string(receivedMessage)
  17001. }